-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fetch attestationHash from Transaction Receipt
- Loading branch information
Showing
5 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
export const NETWORK_IDS = { | ||
MAIN_NET: 1, | ||
ROPSTEN: 3, | ||
SEPOLIA: 11155111, | ||
XDAI: 100, | ||
POLYGON: 137, | ||
OPTIMISTIC: 10, | ||
OPTIMISM_SEPOLIA: 11155420, | ||
BSC: 56, | ||
CELO: 42220, | ||
CELO_ALFAJORES: 44787, | ||
ETC: 61, | ||
MORDOR_ETC_TESTNET: 63, | ||
|
||
ARBITRUM_MAINNET: 42161, | ||
ARBITRUM_SEPOLIA: 421614, | ||
|
||
BASE_MAINNET: 8453, | ||
BASE_SEPOLIA: 84532, | ||
|
||
ZKEVM_MAINNET: 1101, | ||
ZKEVM_CARDONA: 2442, | ||
|
||
STELLAR_MAINNET: 1500, | ||
|
||
// https://docs.particle.network/developers/other-services/node-service/solana-api | ||
SOLANA_MAINNET: 101, | ||
SOLANA_TESTNET: 102, | ||
SOLANA_DEVNET: 103, | ||
}; | ||
|
||
export const NETWORK_NAMES = { | ||
BSC: 'bsc', | ||
XDAI: 'xdaichain', | ||
MAINNET: 'mainnet', | ||
ROPSTEN: 'ropsten', | ||
SEPOLIA: 'sepolia', | ||
POLYGON: 'polygon-mainnet', | ||
OPTIMISTIC: 'optimistic-mainnet', | ||
OPTIMISM_SEPOLIA: 'optimism-sepolia-testnet', | ||
CELO: 'Celo', | ||
CELO_ALFAJORES: 'Celo Alfajores', | ||
ETC: 'Ethereum Classic', | ||
MORDOR_ETC_TESTNET: 'Ethereum Classic Testnet', | ||
ARBITRUM_MAINNET: 'Arbitrum Mainnet', | ||
ARBITRUM_SEPOLIA: 'Arbitrum Sepolia', | ||
BASE_MAINNET: 'Base Mainnet', | ||
BASE_SEPOLIA: 'Base Sepolia', | ||
|
||
ZKEVM_CARDONA: 'ZKEVM Cardona', | ||
ZKEVM_MAINNET: 'ZKEVM Mainnet', | ||
|
||
STELLAR_MAINNET: 'Stellar Mainnet', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import {NETWORK_IDS, NETWORK_NAMES} from "./constants.js"; | ||
import {ethers} from "ethers"; | ||
|
||
const INFURA_ID = process.env.INFURA_ID as string; | ||
|
||
export function getProvider(networkId: number) { | ||
let url; | ||
let options; | ||
switch (networkId) { | ||
case NETWORK_IDS.MORDOR_ETC_TESTNET: | ||
url = | ||
(process.env.MORDOR_ETC_TESTNET as string) || | ||
`https://rpc.mordor.etccooperative.org`; | ||
break; | ||
case NETWORK_IDS.ETC: | ||
url = process.env.ETC_NODE_HTTP_URL as string; | ||
break; | ||
case NETWORK_IDS.XDAI: | ||
url = process.env.XDAI_NODE_HTTP_URL as string; | ||
break; | ||
|
||
case NETWORK_IDS.BSC: | ||
// 'https://bsc-dataseed.binance.org/' | ||
url = process.env.BSC_NODE_HTTP_URL as string; | ||
options = { name: NETWORK_NAMES.BSC, chainId: NETWORK_IDS.BSC }; | ||
break; | ||
|
||
case NETWORK_IDS.CELO: | ||
url = | ||
(process.env.CELO_NODE_HTTP_URL as string) || | ||
`https://celo-mainnet.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
|
||
case NETWORK_IDS.CELO_ALFAJORES: | ||
url = | ||
(process.env.CELO_ALFAJORES_NODE_HTTP_URL as string) || | ||
`https://celo-alfajores.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
|
||
case NETWORK_IDS.OPTIMISM_SEPOLIA: | ||
url = `https://optimism-sepolia.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
|
||
case NETWORK_IDS.ARBITRUM_MAINNET: | ||
url = | ||
(process.env.ARBITRUM_MAINNET_NODE_HTTP_URL as string) || | ||
`https://arbitrum-mainnet.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
|
||
case NETWORK_IDS.ARBITRUM_SEPOLIA: | ||
url = | ||
(process.env.ARBITRUM_SEPOLIA_NODE_HTTP_URL as string) || | ||
`https://arbitrum-sepolia.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
|
||
case NETWORK_IDS.BASE_MAINNET: | ||
url = | ||
(process.env.BASE_MAINNET_NODE_HTTP_URL as string) || | ||
`https://base-mainnet.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
|
||
case NETWORK_IDS.BASE_SEPOLIA: | ||
url = | ||
(process.env.BASE_SEPOLIA_NODE_HTTP_URL as string) || | ||
`https://base-sepolia.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
|
||
// Infura doesn support Polygon ZKEVM | ||
case NETWORK_IDS.ZKEVM_MAINNET: | ||
url = process.env.ZKEVM_MAINNET_NODE_HTTP_URL as string; | ||
break; | ||
|
||
case NETWORK_IDS.ZKEVM_CARDONA: | ||
url = process.env.ZKEVM_CARDONA_NODE_HTTP_URL as string; | ||
break; | ||
|
||
case NETWORK_IDS.STELLAR_MAINNET: | ||
url = process.env.STELLAR_HORIZON_API_URL as string; | ||
break; | ||
|
||
default: { | ||
const network = ethers.Network.from(networkId); | ||
url = `https://${network.name}.infura.io/v3/${INFURA_ID}`; | ||
break; | ||
} | ||
} | ||
|
||
return new ethers.JsonRpcProvider( | ||
url, | ||
options, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters