Skip to content

Commit

Permalink
Update chains
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Nov 6, 2023
1 parent e290911 commit 1363805
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 95 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@amplitude/analytics-browser": "^1.2.3",
"@heroicons/react": "^2.0.18",
"@metamask/post-message-stream": "^5.0.0",
"@revoke.cash/chains": "^11.0.0",
"@revoke.cash/chains": "^22.0.0",
"eth-rpc-errors": "^4.0.3",
"extension-port-stream": "^2.0.1",
"i18next": "^21.10.0",
Expand Down
205 changes: 116 additions & 89 deletions src/lib/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,115 +5,137 @@ import { Chain, PublicClient, createPublicClient, defineChain, http } from 'viem

export const getChainName = (chainId: number): string => {
const overrides: Record<number, string> = {
[ChainId.EthereumMainnet]: 'Ethereum',
[ChainId.BNBSmartChainMainnet]: 'BNB Chain',
[ChainId['AvalancheC-Chain']]: 'Avalanche',
[ChainId.PolygonMainnet]: 'Polygon',
[ChainId.ArbitrumOne]: 'Arbitrum',
[ChainId.ArbitrumGoerli]: 'Arbitrum Goerli',
[ChainId.ArbitrumNova]: 'Arbitrum Nova',
[ChainId.CronosMainnet]: 'Cronos',
[ChainId.FantomOpera]: 'Fantom',
[ChainId.KlaytnMainnetCypress]: 'Klaytn',
[ChainId.KlaytnTestnetBaobab]: 'Klaytn Baobab',
[ChainId.ArbitrumOne]: 'Arbitrum',
[ChainId.AuroraMainnet]: 'Aurora',
[ChainId.CeloMainnet]: 'Celo',
[ChainId.HuobiECOChainMainnet]: 'HECO',
[ChainId.RSKMainnet]: 'Rootstock',
[ChainId.MetisAndromedaMainnet]: 'Metis',
[ChainId.TelosEVMMainnet]: 'Telos',
[ChainId.IoTeXNetworkMainnet]: 'IoTeX',
[ChainId.IoTeXNetworkTestnet]: 'IoTeX Testnet',
[ChainId.HarmonyMainnetShard0]: 'Harmony',
[ChainId.HarmonyTestnetShard0]: 'Harmony Testnet',
[ChainId.GodwokenMainnet]: 'Godwoken',
[ChainId.SmartBitcoinCash]: 'SmartBCH',
[ChainId.FuseMainnet]: 'Fuse',
[ChainId.SyscoinMainnet]: 'Syscoin',
[ChainId.CLVParachain]: 'CLV',
[ChainId.BitTorrentChainMainnet]: 'BTT Chain',
[ChainId.Goerli]: 'Goerli',
[ChainId.BNBSmartChainTestnet]: 'BNB Chain Testnet',
[ChainId['AvalancheC-Chain']]: 'Avalanche',
[ChainId.AvalancheFujiTestnet]: 'Avalanche Fuji',
[ChainId.Mumbai]: 'Polygon Mumbai',
[ChainId.OptimismGoerliTestnet]: 'Optimism Goerli',
[ChainId.ArbitrumGoerli]: 'Arbitrum Goerli',
[ChainId.CeloAlfajoresTestnet]: 'Celo Alfajores',
[ChainId.HuobiECOChainTestnet]: 'HECO Testnet',
[ChainId.MetisStardustTestnet]: 'Metis Stardust',
[ChainId.TelosEVMTestnet]: 'Telos Testnet',
[ChainId.SmartBitcoinCashTestnet]: 'SmartBCH Testnet',
[ChainId.SyscoinTanenbaumTestnet]: 'Syscoin Tanenbaum',
[ChainId.BaseGoerliTestnet]: 'Base Goerli',
[ChainId.BitgertMainnet]: 'Bitgert',
[ChainId.BitTorrentChainMainnet]: 'BTT Chain',
[ChainId.BitTorrentChainTestnet]: 'BTTC Testnet',
[ChainId.OasisEmerald]: 'Oasis Emerald',
[ChainId.OasisEmeraldTestnet]: 'Oasis Testnet',
[ChainId.EthereumClassicMainnet]: 'Ethereum Classic',
[ChainId.Canto]: 'Canto',
[ChainId.KavaEVM]: 'Kava',
[ChainId.KavaEVMTestnet]: 'Kava Testnet',
[ChainId.DogechainMainnet]: 'Dogechain',
[ChainId.DogechainTestnet]: 'Dogechain Testnet',
[ChainId.BNBSmartChainMainnet]: 'BNB Chain',
[ChainId.BNBSmartChainTestnet]: 'BNB Chain Testnet',
[ChainId.BobaNetwork]: 'Boba',
[ChainId.CallistoMainnet]: 'Callisto',
[ChainId.NahmiiMainnet]: 'Nahmii',
[ChainId.Canto]: 'Canto',
[ChainId.CeloAlfajoresTestnet]: 'Celo Alfajores',
[ChainId.CeloMainnet]: 'Celo',
[ChainId.CoinExSmartChainMainnet]: 'CoinEx Smart Chain',
[ChainId.CoinExSmartChainTestnet]: 'CoinEx Testnet',
[ChainId.CoreBlockchainMainnet]: 'CORE',
[ChainId.CronosMainnet]: 'Cronos',
[ChainId.DogechainMainnet]: 'Dogechain',
[ChainId.DogechainTestnet]: 'Dogechain Testnet',
[ChainId.ElastosSmartChain]: 'Elastos',
[ChainId.ENULSMainnet]: 'ENULS',
[ChainId.EthereumClassicMainnet]: 'Ethereum Classic',
[ChainId.EthereumMainnet]: 'Ethereum',
[ChainId.ExosamaNetwork]: 'Exosama',
[ChainId.FantomOpera]: 'Fantom',
[ChainId.FlareMainnet]: 'Flare',
[ChainId['SongbirdCanary-Network']]: 'Songbird',
[ChainId.BobaNetwork]: 'Boba',
[ChainId.FuseMainnet]: 'Fuse',
[ChainId.GatherMainnetNetwork]: 'Gather',
[ChainId.GatherTestnetNetwork]: 'Gather Testnet',
[ChainId.Gnosis]: 'Gnosis Chain',
[ChainId.GodwokenMainnet]: 'Godwoken',
[ChainId.Goerli]: 'Ethereum Goerli',
[ChainId.HarmonyMainnetShard0]: 'Harmony',
[ChainId.HarmonyTestnetShard0]: 'Harmony Testnet',
[ChainId.HorizenEONMainnet]: 'Horizen EON',
[ChainId.HorizenGobiTestnet]: 'Horizen Gobi',
[ChainId.ZkSyncEraMainnet]: 'zkSync Era',
[ChainId.ZkSyncEraTestnet]: 'zkSync Era Goerli',
[ChainId.HuobiECOChainMainnet]: 'HECO',
[ChainId.HuobiECOChainTestnet]: 'HECO Testnet',
[ChainId.IoTeXNetworkMainnet]: 'IoTeX',
[ChainId.IoTeXNetworkTestnet]: 'IoTeX Testnet',
[ChainId.KardiaChainMainnet]: 'KardiaChain',
[ChainId.Kava]: 'Kava',
[ChainId.KavaTestnet]: 'Kava Testnet',
[ChainId.KCCMainnet]: 'KCC',
[ChainId.KlaytnMainnetCypress]: 'Klaytn',
[ChainId.KlaytnTestnetBaobab]: 'Klaytn Baobab',
[ChainId.Linea]: 'Linea',
[ChainId.LineaTestnet]: 'Linea Goerli',
[ChainId.MantaPacificMainnet]: 'Manta Pacific',
[ChainId.MaxxChainMainnet]: 'MaxxChain',
[ChainId.MetisAndromedaMainnet]: 'Metis',
[ChainId.MetisStardustTestnet]: 'Metis Stardust',
[ChainId.MilkomedaC1Mainnet]: 'Milkomeda C1',
[ChainId.Mumbai]: 'Polygon Mumbai',
[ChainId.NahmiiMainnet]: 'Nahmii',
[ChainId.OasisEmerald]: 'Oasis Emerald',
[ChainId.OasisEmeraldTestnet]: 'Oasis Testnet',
[ChainId.OasysMainnet]: 'Oasys',
[ChainId.OctaSpace]: 'OctaSpace',
[ChainId.OpBNBMainnet]: 'opBNB',
[ChainId.OPMainnet]: 'Optimism',
[ChainId.OptimismGoerliTestnet]: 'Optimism Goerli',
[ChainId.PegoNetwork]: 'Pego',
[ChainId['PGN(PublicGoodsNetwork)']]: 'PGN',
[ChainId.PolygonMainnet]: 'Polygon',
[ChainId.PolygonzkEVM]: 'Polygon zkEVM',
[ChainId.PolygonzkEVMTestnet]: 'Polygon zkEVM Testnet',
[ChainId.PulseChain]: 'PulseChain',
[ChainId.PulseChainTestnetv4]: 'PulseChain Testnet',
[ChainId.Linea]: 'Linea',
[ChainId.LineaTestnet]: 'Linea Goerli',
[ChainId.ScrollAlphaTestnet]: 'Scroll Alpha',
[ChainId.BaseGoerliTestnet]: 'Base Goerli',
[ChainId.RedlightChainMainnet]: 'Redlight',
[ChainId.GatherMainnetNetwork]: 'Gather',
[ChainId.GatherTestnetNetwork]: 'Gather Testnet',
[ChainId.TaikoGrimsvotnL2]: 'Taiko Grimsvotn',
[ChainId.CoreBlockchainMainnet]: 'CORE',
[ChainId.KCCMainnet]: 'KCC',
[ChainId.RolluxMainnet]: 'Rollux',
[ChainId.RootstockMainnet]: 'Rootstock',
[ChainId.Scroll]: 'Scroll',
[ChainId.ScrollSepoliaTestnet]: 'Scroll Sepolia',
[ChainId.Sepolia]: 'Ethereum Sepolia',
[ChainId.Shibarium]: 'Shibarium',
[ChainId.ShimmerEVMMainnet]: 'Shimmer',
[ChainId.ShimmerEVMTestnet]: 'Shimmer Testnet',
[ChainId.OasysMainnet]: 'Oasys',
[ChainId.ENULSMainnet]: 'ENULS',
[ChainId.SmartBitcoinCash]: 'SmartBCH',
[ChainId['SongbirdCanary-Network']]: 'Songbird',
[ChainId.SyscoinMainnet]: 'Syscoin',
[ChainId.SyscoinTanenbaumTestnet]: 'Syscoin Tanenbaum',
[ChainId.TaikoJolnirL2]: 'Taiko Jolnir',
[ChainId.TelosEVMMainnet]: 'Telos',
[ChainId.TelosEVMTestnet]: 'Telos Testnet',
[ChainId.VelasEVMMainnet]: 'Velas',
[ChainId['WEMIX3.0Mainnet']]: 'WEMIX',
[ChainId.XDCNetwork]: 'XDC',
[ChainId.ZetaChainAthens3Testnet]: 'ZetaChain Athens',
[ChainId.OPMainnet]: 'Optimism',
[ChainId.ZetaChainMainnet]: 'ZetaChain',
[ChainId.ZkSyncEraMainnet]: 'zkSync Era',
[ChainId.ZkSyncEraTestnet]: 'zkSync Era Goerli',
[1234567890]: 'Taiko', // TODO: This is a placeholder so we can add a description for Taiko
};

const name = overrides[chainId] ?? chains.get(chainId)?.name ?? `Chain ID ${chainId}`;

return name;
};

export const getChainExplorerUrl = (chainId: number): string => {
const overrides: Record<number, string> = {
[ChainId.SmartBitcoinCash]: 'https://www.smartscan.cash',
[ChainId.CeloAlfajoresTestnet]: 'https://alfajores.celoscan.io',
[ChainId.ArbitrumGoerli]: 'https://goerli.arbiscan.io',
[ChainId.ArbitrumNova]: 'https://nova.arbiscan.io',
[ChainId.Astar]: 'https://blockscout.com/astar',
[ChainId.AuroraMainnet]: 'https://explorer.aurora.dev',
[ChainId.BitTorrentChainMainnet]: 'https://bttcscan.com',
[ChainId.BitTorrentChainTestnet]: 'https://testnet.bttcscan.com',
[ChainId.CLVParachain]: 'https://clvscan.com',
[ChainId.Astar]: 'https://blockscout.com/astar',
[ChainId.CallistoMainnet]: 'https://explorer.callisto.network',
[ChainId.Canto]: 'https://tuber.build',
[ChainId.CeloAlfajoresTestnet]: 'https://alfajores.celoscan.io',
[ChainId.FuseMainnet]: 'https://explorer.fuse.io',
[ChainId.Gnosis]: 'https://gnosisscan.io',
[ChainId.ArbitrumGoerli]: 'https://goerli.arbiscan.io',
[ChainId.ArbitrumNova]: 'https://nova.arbiscan.io',
[ChainId.KavaEVMTestnet]: 'https://explorer.testnet.kava.io',
[ChainId.GodwokenMainnet]: 'https://www.gwscan.com',
[ChainId.KardiaChainMainnet]: 'https://explorer.kardiachain.io',
[ChainId.Linea]: 'https://lineascan.build',
[ChainId.LineaTestnet]: 'https://goerli.lineascan.build',
[ChainId.OasysMainnet]: 'https://scan.oasys.games',
[ChainId.OptimismGoerliTestnet]: 'https://goerli-optimism.etherscan.io',
[ChainId.PolygonzkEVM]: 'https://zkevm.polygonscan.com',
[ChainId.PolygonzkEVMTestnet]: 'https://testnet-zkevm.polygonscan.com',
[ChainId.PulseChain]: 'https://scan.pulsechain.com',
[ChainId.PulseChainTestnetv4]: 'https://scan.v4.testnet.pulsechain.com',
[ChainId.LineaTestnet]: 'https://goerli.lineascan.build',
[ChainId.OasysMainnet]: 'https://scan.oasys.games',
[ChainId.OptimismGoerliTestnet]: 'https://goerli-optimism.etherscan.io',
[ChainId.FuseMainnet]: 'https://explorer.fuse.io',
[ChainId.CallistoMainnet]: 'https://explorer.callisto.network',
[ChainId.GodwokenMainnet]: 'https://www.gwscan.com',
[ChainId.Scroll]: 'https://scrollscan.com',
[ChainId.SmartBitcoinCash]: 'https://www.smartscan.cash',
[ChainId.Wanchain]: 'https://www.wanscan.org',
[ChainId.Canto]: 'https://tuber.build',
[ChainId.Linea]: 'https://lineascan.build',
[ChainId.ZetaChainAthens3Testnet]: 'https://zetachain-athens-3.blockscout.com',
};

const [explorer] = chains.get(chainId)?.explorers ?? [];
Expand All @@ -125,22 +147,29 @@ export const getChainRpcUrl = (chainId: number): string => {
const infuraKey = INFURA_API_KEY;

const overrides: Record<number, string> = {
[ChainId.ArbitrumOne]: `https://arbitrum-mainnet.infura.io/v3/${infuraKey}`,
[ChainId.Astar]: 'https://evm.astar.network',
[ChainId['AvalancheC-Chain']]: `https://avalanche-mainnet.infura.io/v3/${infuraKey}`,
[ChainId.AvalancheFujiTestnet]: `https://avalanche-fuji.infura.io/v3/${infuraKey}`,
[ChainId.Base]: 'https://mainnet.base.org',
[ChainId.Canto]: 'https://mainnode.plexnode.org:8545',
[ChainId.CoreBlockchainMainnet]: 'https://rpc.coredao.org',
[ChainId.CronosMainnet]: 'https://cronos.blockpi.network/v1/rpc/public',
[ChainId.EthereumMainnet]: `https://mainnet.infura.io/v3/${infuraKey}`,
[ChainId.Goerli]: `https://goerli.infura.io/v3/${infuraKey}`,
[ChainId.Sepolia]: `https://sepolia.infura.io/v3/${infuraKey}`,
[ChainId.ArbitrumOne]: `https://arb1.arbitrum.io/rpc`,
[ChainId.FantomTestnet]: 'https://rpc.ankr.com/fantom_testnet',
[ChainId.Evmos]: 'https://evmos-evm.publicnode.com',
[ChainId.Astar]: 'https://evm.astar.network',
[ChainId.FantomTestnet]: 'https://rpc.ankr.com/fantom_testnet',
[ChainId.Goerli]: `https://goerli.infura.io/v3/${infuraKey}`,
[ChainId.HorizenEONMainnet]: 'https://eon-rpc.horizenlabs.io/ethv1',
[ChainId.Linea]: `https://linea-mainnet.infura.io/v3/${infuraKey}`,
[ChainId.LineaTestnet]: `https://linea-goerli.infura.io/v3/${infuraKey}`,
[ChainId.Mumbai]: `https://polygon-mumbai.infura.io/v3/${infuraKey}`,
[ChainId.OPMainnet]: `https://optimism-mainnet.infura.io/v3/${infuraKey}`,
[ChainId.OptimismGoerliTestnet]: `https://optimism-goerli.infura.io/v3/${infuraKey}`,
[ChainId.CronosMainnet]: 'https://node.croswap.com/rpc',
[ChainId.Mumbai]: 'https://polygon-mumbai.blockpi.network/v1/rpc/public',
[ChainId.LineaTestnet]: `https://linea-goerli.infura.io/v3/${infuraKey}`,
[ChainId.CoreBlockchainMainnet]: 'https://rpc-core.icecreamswap.com',
[ChainId.Base]: 'https://developer-access-mainnet.base.org',
[ChainId.Canto]: 'https://mainnode.plexnode.org:8545',
[ChainId.Linea]: `https://linea-mainnet.infura.io/v3/${infuraKey}`,
[ChainId.PolygonMainnet]: `https://polygon-mainnet.infura.io/v3/${infuraKey}`,
[ChainId.Sepolia]: `https://sepolia.infura.io/v3/${infuraKey}`,
[ChainId.Shiden]: 'https://shiden.public.blastapi.io',
[ChainId.XDCNetwork]: 'https://erpc.xdcrpc.com',
[ChainId.ZetaChainAthens3Testnet]: 'https://zetachain-athens-evm.blockpi.network/v1/rpc/public',
};

const [rpcUrl] = chains.get(chainId)?.rpc ?? [];
Expand Down Expand Up @@ -177,8 +206,6 @@ export const getViemChainConfig = (chainId: number): Chain | undefined => {
url: getChainExplorerUrl(chainId),
},
},
// contracts: getChainDeployedContracts(chainId),
// testnet: CHAIN_SELECT_TESTNETS.includes(chainId),
});
};

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,10 @@ __metadata:
languageName: node
linkType: hard

"@revoke.cash/chains@npm:^11.0.0":
version: 11.0.0
resolution: "@revoke.cash/chains@npm:11.0.0"
checksum: c111c34603cc2dc28c07f54eb6952c777553d40c336d9fe2920dac4f2faa3e4845f2f4199d3a42d999ab731ed1d8774faec036deb1219d2580c4a8146d98d6ae
"@revoke.cash/chains@npm:^22.0.0":
version: 22.0.0
resolution: "@revoke.cash/chains@npm:22.0.0"
checksum: a52be74d79a5d0d3d346806b22f0fc9f30085748e21e0acf382e214089e3168754e30d5bec60ab8c752e91a85b178cbba8764218b1eba04a025ee9e6fa67b5be
languageName: node
linkType: hard

Expand Down Expand Up @@ -7138,7 +7138,7 @@ __metadata:
"@heroicons/react": ^2.0.18
"@localazy/cli": ^1.7.3
"@metamask/post-message-stream": ^5.0.0
"@revoke.cash/chains": ^11.0.0
"@revoke.cash/chains": ^22.0.0
"@types/chrome": ^0.0.243
"@types/object-hash": ^2.2.1
"@types/react": ^17.0.0
Expand Down

0 comments on commit 1363805

Please sign in to comment.