diff --git a/.github/workflows/update-chains.yml b/.github/workflows/update-chains.yml new file mode 100644 index 00000000000..e512074de01 --- /dev/null +++ b/.github/workflows/update-chains.yml @@ -0,0 +1,41 @@ +name: Update Chains + +on: + schedule: + - cron: '20 16 * * FRI' # Runs every Friday at 16:20 UTC + workflow_dispatch: # Can be dispatched manually + +jobs: + update-chains: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies + run: yarn install + + - name: Install ts-node + run: yarn global add ts-node + + - name: Update chains data + run: npx ts-node -O '{"module":"commonjs"}' ./src/scripts/update-chains.ts + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: update-chains + branch-suffix: timestamp + commit-message: | + Update chains data + base: dev + title: Update chains data + body: Automated update of chains data from https://chainid.network/chains.json + labels: update 🔄 \ No newline at end of file diff --git a/src/data/chains.ts b/src/data/chains.ts new file mode 100644 index 00000000000..c3246f267e6 --- /dev/null +++ b/src/data/chains.ts @@ -0,0 +1,1590 @@ +const chains = [ + { + name: "Ethereum Mainnet", + infoURL: "https://ethereum.org", + chainId: 1, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Expanse Network", + infoURL: "https://expanse.tech", + chainId: 2, + nativeCurrency: { + name: "Expanse Network Ether", + symbol: "EXP", + decimals: 18, + }, + chain: "EXP", + }, + { + name: "ThaiChain", + infoURL: "https://thaichain.io", + chainId: 7, + nativeCurrency: { + name: "ThaiChain Ether", + symbol: "TCH", + decimals: 18, + }, + chain: "TCH", + }, + { + name: "Ubiq", + infoURL: "https://ubiqsmart.com", + chainId: 8, + nativeCurrency: { + name: "Ubiq Ether", + symbol: "UBQ", + decimals: 18, + }, + chain: "UBQ", + }, + { + name: "OP Mainnet", + infoURL: "https://optimism.io", + chainId: 10, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Metadium Mainnet", + infoURL: "https://metadium.com", + chainId: 11, + nativeCurrency: { + name: "Metadium Mainnet Ether", + symbol: "META", + decimals: 18, + }, + chain: "META", + }, + { + name: "ThaiChain 2.0 ThaiFi", + infoURL: "https://exp.thaifi.com", + chainId: 17, + nativeCurrency: { + name: "Thaifi Ether", + symbol: "TFI", + decimals: 18, + }, + chain: "TCH", + }, + { + name: "Elastos Smart Chain", + infoURL: "https://www.elastos.org/", + chainId: 20, + nativeCurrency: { + name: "Elastos", + symbol: "ELA", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "ELA-DID-Sidechain Mainnet", + infoURL: "https://www.elastos.org/", + chainId: 22, + nativeCurrency: { + name: "Elastos", + symbol: "ELA", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "GoodData Mainnet", + infoURL: "https://www.goodata.org", + chainId: 33, + nativeCurrency: { + name: "GoodData Mainnet Ether", + symbol: "GooD", + decimals: 18, + }, + chain: "GooD", + }, + { + name: "TBWG Chain", + infoURL: "https://tbwg.io", + chainId: 35, + nativeCurrency: { + name: "TBWG Ether", + symbol: "TBG", + decimals: 18, + }, + chain: "TBWG", + }, + { + name: "GoChain", + infoURL: "https://gochain.io", + chainId: 60, + nativeCurrency: { + name: "GoChain Ether", + symbol: "GO", + decimals: 18, + }, + chain: "GO", + }, + { + name: "Ethereum Classic", + infoURL: "https://ethereumclassic.org", + chainId: 61, + nativeCurrency: { + name: "Ether", + symbol: "ETC", + decimals: 18, + }, + chain: "ETC", + }, + { + name: "Ellaism", + infoURL: "https://ellaism.org", + chainId: 64, + nativeCurrency: { + name: "Ellaism Ether", + symbol: "ELLA", + decimals: 18, + }, + chain: "ELLA", + }, + { + name: "SoterOne Mainnet", + infoURL: "https://www.soterone.com", + chainId: 68, + nativeCurrency: { + name: "SoterOne Mainnet Ether", + symbol: "SOTER", + decimals: 18, + }, + chain: "SOTER", + }, + { + name: "Optimism Kovan", + infoURL: "https://optimism.io", + chainId: 69, + nativeCurrency: { + name: "Kovan Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Mix", + infoURL: "https://mix-blockchain.org", + chainId: 76, + nativeCurrency: { + name: "Mix Ether", + symbol: "MIX", + decimals: 18, + }, + chain: "MIX", + }, + { + name: "POA Network Sokol", + infoURL: "https://poa.network", + chainId: 77, + nativeCurrency: { + name: "POA Sokol Ether", + symbol: "SPOA", + decimals: 18, + }, + chain: "POA", + }, + { + name: "PrimusChain mainnet", + infoURL: "https://primusmoney.com", + chainId: 78, + nativeCurrency: { + name: "Primus Ether", + symbol: "PETH", + decimals: 18, + }, + chain: "PC", + }, + { + name: "POA Network Core", + infoURL: "https://poa.network", + chainId: 99, + nativeCurrency: { + name: "POA Network Core Ether", + symbol: "POA", + decimals: 18, + }, + chain: "POA", + }, + { + name: "EtherInc", + infoURL: "https://einc.io", + chainId: 101, + nativeCurrency: { + name: "EtherInc Ether", + symbol: "ETI", + decimals: 18, + }, + chain: "ETI", + }, + { + name: "EtherLite Chain", + infoURL: "https://etherlite.org", + chainId: 111, + nativeCurrency: { + name: "EtherLite", + symbol: "ETL", + decimals: 18, + }, + chain: "ETL", + }, + { + name: "Factory 127 Mainnet", + infoURL: "https://www.factory127.com", + chainId: 127, + nativeCurrency: { + name: "Factory 127 Token", + symbol: "FETH", + decimals: 18, + }, + chain: "FETH", + }, + { + name: "Defi Oracle Meta Mainnet", + infoURL: "https://info.defi-oracle.io/", + chainId: 138, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "dfiometa", + }, + { + name: "Manta Pacific Mainnet", + infoURL: "https://pacific-info.manta.network", + chainId: 169, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Manta Pacific", + }, + { + name: "Mint Mainnet", + infoURL: "https://www.mintchain.io", + chainId: 185, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Blast Mainnet", + infoURL: "https://docs.blastblockchain.com", + chainId: 238, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Fraxtal", + infoURL: "https://mainnet.frax.com", + chainId: 252, + nativeCurrency: { + name: "Frax Ether", + symbol: "frxETH", + decimals: 18, + }, + chain: "FRAX", + }, + { + name: "Swan Chain Mainnet", + infoURL: "https://swanchain.io/", + chainId: 254, + nativeCurrency: { + name: "SWANETH", + symbol: "sETH", + decimals: 18, + }, + chain: "SWAN", + }, + { + name: "Kroma", + infoURL: "https://kroma.network", + chainId: 255, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "High Performance Blockchain", + infoURL: "https://hpb.io", + chainId: 269, + nativeCurrency: { + name: "High Performance Blockchain Ether", + symbol: "HPB", + decimals: 18, + }, + chain: "HPB", + }, + { + name: "Boba Network", + infoURL: "https://boba.network", + chainId: 288, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Orderly Mainnet", + infoURL: "www.orderly.network", + chainId: 291, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "zkSync Mainnet", + infoURL: "https://zksync.io/", + chainId: 324, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "GRVT Mainnet", + infoURL: "https://grvt.io/", + chainId: 325, + nativeCurrency: { + name: "ETH", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Lisinski", + infoURL: "https://lisinski.online", + chainId: 385, + nativeCurrency: { + name: "Lisinski Ether", + symbol: "LISINS", + decimals: 18, + }, + chain: "CRO", + }, + { + name: "Syndr L3", + infoURL: "https://syndr.com", + chainId: 404, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "SYNDR", + }, + { + name: "PGN (Public Goods Network)", + infoURL: "https://publicgoods.network/", + chainId: 424, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Redstone", + infoURL: "https://redstone.xyz", + chainId: 690, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Patex", + infoURL: "https://patex.io/", + chainId: 789, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Firechain zkEVM", + infoURL: "https://docs.thefirechain.com/", + chainId: 814, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Firechain", + }, + { + name: "Lyra Chain", + infoURL: "https://lyra.finance", + chainId: 957, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Lyra", + }, + { + name: "Nepal Blockchain Network", + infoURL: "https://nepalblockchain.network", + chainId: 977, + nativeCurrency: { + name: "Nepal Blockchain Network Ether", + symbol: "YETI", + decimals: 18, + }, + chain: "YETI", + }, + { + name: "TOP Mainnet EVM", + infoURL: "https://www.topnetwork.org/", + chainId: 980, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "TOP", + }, + { + name: "Metis Andromeda Mainnet", + infoURL: "https://www.metis.io", + chainId: 1088, + nativeCurrency: { + name: "Metis", + symbol: "METIS", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Polygon zkEVM", + infoURL: "https://polygon.technology/polygon-zkevm", + chainId: 1101, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Polygon", + }, + { + name: "Lisk", + infoURL: "https://lisk.com", + chainId: 1135, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Dogether Mainnet", + infoURL: "https://www.dogether.dog/", + chainId: 1248, + nativeCurrency: { + name: "Dogether", + symbol: "dogeth", + decimals: 18, + }, + chain: "Dogether", + }, + { + name: "ZKBase Mainnet", + infoURL: "https://zkbase.org/", + chainId: 1456, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Ethereum Inscription Mainnet", + infoURL: "https://www.etins.org", + chainId: 1617, + nativeCurrency: { + name: "Ethereum Inscription", + symbol: "ETINS", + decimals: 18, + }, + chain: "ETINS", + }, + { + name: "Atheios", + infoURL: "https://atheios.org", + chainId: 1620, + nativeCurrency: { + name: "Atheios Ether", + symbol: "ATH", + decimals: 18, + }, + chain: "ATH", + }, + { + name: "Anytype EVM Chain", + infoURL: "https://evm.anytype.io", + chainId: 1701, + nativeCurrency: { + name: "ANY", + symbol: "ANY", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Reya Network", + infoURL: "https://reya.network", + chainId: 1729, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Reya", + }, + { + name: "Metal L2", + infoURL: "https://metall2.com", + chainId: 1750, + nativeCurrency: { + name: "ETH", + symbol: "ETH", + decimals: 18, + }, + chain: "Metal L2", + }, + { + name: "Teslafunds", + infoURL: "https://teslafunds.io", + chainId: 1856, + nativeCurrency: { + name: "Teslafunds Ether", + symbol: "TSF", + decimals: 18, + }, + chain: "TSF", + }, + { + name: "Lightlink Phoenix Mainnet", + infoURL: "https://lightlink.io", + chainId: 1890, + nativeCurrency: { + name: "Ethereum", + symbol: "ETH", + decimals: 18, + }, + chain: "Lightlink Phoenix Mainnet", + }, + { + name: "Scalind", + infoURL: "https://scalind.com", + chainId: 1911, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "EtherGem", + infoURL: "https://egem.io", + chainId: 1987, + nativeCurrency: { + name: "EtherGem Ether", + symbol: "EGEM", + decimals: 18, + }, + chain: "EGEM", + }, + { + name: "BOSagora Mainnet", + infoURL: "https://docs.bosagora.org", + chainId: 2151, + nativeCurrency: { + name: "BOSAGORA", + symbol: "BOA", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Karak Mainnet", + infoURL: "https://karak.network", + chainId: 2410, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Karak", + }, + { + name: "Nanon", + infoURL: "https://www.nanon.network", + chainId: 2748, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "GM Network Mainnet", + infoURL: "https://gmnetwork.ai", + chainId: 2777, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "GM Network Mainnet", + }, + { + name: "HYCHAIN", + infoURL: "https://www.hychain.com", + chainId: 2911, + nativeCurrency: { + name: "TOPIA", + symbol: "TOPIA", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "EthStorage Mainnet", + infoURL: "https://ethstorage.io/", + chainId: 3335, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "EthStorage", + }, + { + name: "Astar zkEVM", + infoURL: "https://astar.network", + chainId: 3776, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Firechain zkEVM Ghostrider", + infoURL: "https://docs.thefirechain.com/", + chainId: 3885, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Firechain", + }, + { + name: "Nahmii 3 Mainnet", + infoURL: "https://nahmii.io", + chainId: 4061, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Nahmii", + }, + { + name: "Muster Mainnet", + infoURL: "", + chainId: 4078, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Muster", + }, + { + name: "Mantle", + infoURL: "https://mantle.xyz", + chainId: 5000, + nativeCurrency: { + name: "Mantle", + symbol: "MNT", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Ham", + infoURL: "https://ham.fun", + chainId: 5112, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Ham", + }, + { + name: "Nahmii 2 Mainnet", + infoURL: "https://nahmii.io", + chainId: 5551, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Nahmii", + }, + { + name: "Ganache", + infoURL: "https://trufflesuite.com/ganache/", + chainId: 5777, + nativeCurrency: { + name: "Ganache Test Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "RACE Mainnet", + infoURL: "https://race.foundation/", + chainId: 6805, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Cyber Mainnet", + infoURL: "https://cyber.co/", + chainId: 7560, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Cyber", + }, + { + name: "Kinto Mainnet", + infoURL: "https://kinto.xyz", + chainId: 7887, + nativeCurrency: { + name: "Ethereum", + symbol: "ETH", + decimals: 18, + }, + chain: "Kinto Mainnet", + }, + { + name: "Base", + infoURL: "https://base.org", + chainId: 8453, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "SuperLumio", + infoURL: "https://lumio.io/", + chainId: 8866, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "SuperLumio", + }, + { + name: "SJATSH", + infoURL: "https://sjis.me", + chainId: 10086, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "L3X Protocol", + infoURL: "https://l3x.com", + chainId: 12324, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "L3X", + }, + { + name: "unreal", + infoURL: "https://raas.gelato.network/rollups/details/public/unreal", + chainId: 18233, + nativeCurrency: { + name: "unreal Ether", + symbol: "reETH", + decimals: 18, + }, + chain: "unreal", + }, + { + name: "Camelark Mainnet", + infoURL: "https://www.camelark.com", + chainId: 20001, + nativeCurrency: { + name: "EthereumPoW", + symbol: "ETHW", + decimals: 18, + }, + chain: "ETHW", + }, + { + name: "Nautilus Mainnet", + infoURL: "https://docs.nautchain.xyz", + chainId: 22222, + nativeCurrency: { + name: "Zebec", + symbol: "ZBC", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Webchain", + infoURL: "https://webchain.network", + chainId: 24484, + nativeCurrency: { + name: "Webchain Ether", + symbol: "WEB", + decimals: 18, + }, + chain: "WEB", + }, + { + name: "Vizing Mainnet", + infoURL: "https://vizing.com", + chainId: 28518, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Vizing Mainnet", + }, + { + name: "Ethersocial Network", + infoURL: "https://ethersocial.org", + chainId: 31102, + nativeCurrency: { + name: "Ethersocial Network Ether", + symbol: "ESN", + decimals: 18, + }, + chain: "ESN", + }, + { + name: "Funki", + infoURL: "https://funkichain.com", + chainId: 33979, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Mode", + infoURL: "https://docs.mode.network/", + chainId: 34443, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Arbitrum One", + infoURL: "https://arbitrum.io", + chainId: 42161, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Arbitrum Nova", + infoURL: "https://arbitrum.io", + chainId: 42170, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Athereum", + infoURL: "https://athereum.ava.network", + chainId: 43110, + nativeCurrency: { + name: "Athereum Ether", + symbol: "ATH", + decimals: 18, + }, + chain: "ATH", + }, + { + name: "Zircuit Mainnet", + infoURL: "https://www.zircuit.com/", + chainId: 48900, + nativeCurrency: { + name: "ETH", + symbol: "ETH", + decimals: 18, + }, + chain: "Zircuit Mainnet", + }, + { + name: "Liveplex OracleEVM", + infoURL: "", + chainId: 50001, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Liveplex OracleEVM Network", + }, + { + name: "Titan", + infoURL: "https://tokamak.network", + chainId: 55004, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Lambda Chain Mainnet", + infoURL: "https://lambda.im", + chainId: 56026, + nativeCurrency: { + name: "ETH", + symbol: "ETH", + decimals: 18, + }, + chain: "Lambda Chain", + }, + { + name: "Linea", + infoURL: "https://linea.build", + chainId: 59144, + nativeCurrency: { + name: "Linea Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "BOB", + infoURL: "https://gobob.xyz", + chainId: 60808, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Optopia Mainnet", + infoURL: "https://optopia.ai", + chainId: 62050, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Condrieu", + infoURL: "https://condrieu.ethdevops.io", + chainId: 69420, + nativeCurrency: { + name: "Condrieu Testnet Ether", + symbol: "CTE", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Proof of Play - Apex", + infoURL: "https://proofofplay.com", + chainId: 70700, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Mixin Virtual Machine", + infoURL: "https://mvm.dev", + chainId: 73927, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "MVM", + }, + { + name: "ResinCoin Mainnet", + infoURL: "https://resincoin.dev", + chainId: 75000, + nativeCurrency: { + name: "Ether", + symbol: "RESIN", + decimals: 18, + }, + chain: "RESIN", + }, + { + name: "Cycle Network Mainnet Sailboat", + infoURL: "https://www.cyclenetwork.io/", + chainId: 77677, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Firenze test network", + infoURL: "https://primusmoney.com", + chainId: 78110, + nativeCurrency: { + name: "Firenze Ether", + symbol: "FIN", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Blast", + infoURL: "https://blast.io/", + chainId: 81457, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Nautilus Trition Chain", + infoURL: "https://docs.nautchain.xyz", + chainId: 91002, + nativeCurrency: { + name: "Nautilus Zebec Testnet Tokens", + symbol: "tZBC", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "re.al", + infoURL: "https://re.al", + chainId: 111188, + nativeCurrency: { + name: "re.al Ether", + symbol: "reETH", + decimals: 18, + }, + chain: "re.al", + }, + { + name: "Taiko Mainnet", + infoURL: "https://taiko.xyz", + chainId: 167000, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Taiko Katla L2", + infoURL: "https://taiko.xyz", + chainId: 167008, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Taiko Hekla L2", + infoURL: "https://taiko.xyz", + chainId: 167009, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Akroma", + infoURL: "https://akroma.io", + chainId: 200625, + nativeCurrency: { + name: "Akroma Ether", + symbol: "AKA", + decimals: 18, + }, + chain: "AKA", + }, + { + name: "Jellie", + infoURL: "https://twala.io/", + chainId: 202624, + nativeCurrency: { + name: "Twala Coin", + symbol: "TWL", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "HydraDX", + infoURL: "https://hydradx.io", + chainId: 222222, + nativeCurrency: { + name: "Wrapped ETH", + symbol: "WETH", + decimals: 18, + }, + chain: "HDX", + }, + { + name: "ARTIS sigma1", + infoURL: "https://artis.eco", + chainId: 246529, + nativeCurrency: { + name: "ARTIS sigma1 Ether", + symbol: "ATS", + decimals: 18, + }, + chain: "ARTIS", + }, + { + name: "Nal Mainnet", + infoURL: "https://www.nal.network", + chainId: 328527, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Scroll", + infoURL: "https://scroll.io", + chainId: 534352, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "zkLink Nova Mainnet", + infoURL: "https://zklink.io", + chainId: 810180, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "zKatana", + infoURL: "https://astar.network", + chainId: 1261120, + nativeCurrency: { + name: "Sepolia Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Etho Protocol", + infoURL: "https://ethoprotocol.com", + chainId: 1313114, + nativeCurrency: { + name: "Etho Protocol", + symbol: "ETHO", + decimals: 18, + }, + chain: "ETHO", + }, + { + name: "Xerom", + infoURL: "https://xerom.org", + chainId: 1313500, + nativeCurrency: { + name: "Xerom Ether", + symbol: "XERO", + decimals: 18, + }, + chain: "XERO", + }, + { + name: "Turkey Demo Dev", + infoURL: "", + chainId: 1731313, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Xterio Chain", + infoURL: "https://xter.io", + chainId: 2702128, + nativeCurrency: { + name: "ETH", + symbol: "ETH", + decimals: 18, + }, + chain: "Xterio", + }, + { + name: "AltLayer Zero Gas Network", + infoURL: "https://altlayer.io", + chainId: 4000003, + nativeCurrency: { + name: "ZERO", + symbol: "ZERO", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Worlds Caldera", + infoURL: "https://caldera.xyz/", + chainId: 4281033, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "WCal", + }, + { + name: "Astar zKyoto", + infoURL: "https://astar.network", + chainId: 6038361, + nativeCurrency: { + name: "Sepolia Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "OpenVessel", + infoURL: "https://www.openvessel.io", + chainId: 7355310, + nativeCurrency: { + name: "Vessel ETH", + symbol: "VETH", + decimals: 18, + }, + chain: "VSL", + }, + { + name: "Zora", + infoURL: "https://zora.energy", + chainId: 7777777, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Hokum", + infoURL: "https://hokum.gg", + chainId: 8080808, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Hokum", + }, + { + name: "AlienX Mainnet", + infoURL: "https://alienxchain.io/home", + chainId: 10241024, + nativeCurrency: { + name: "Ethereum", + symbol: "ETH", + decimals: 18, + }, + chain: "AlienX Mainnet", + }, + { + name: "PepChain Churchill", + infoURL: "https://pepchain.io", + chainId: 13371337, + nativeCurrency: { + name: "PepChain Churchill Ether", + symbol: "TPEP", + decimals: 18, + }, + chain: "PEP", + }, + { + name: "IOLite", + infoURL: "https://iolite.io", + chainId: 18289463, + nativeCurrency: { + name: "IOLite Ether", + symbol: "ILT", + decimals: 18, + }, + chain: "ILT", + }, + { + name: "DBK Chain", + infoURL: "https://docs.dbkchain.io", + chainId: 20240603, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "DBK Chain", + }, + { + name: "Aquachain", + infoURL: "https://aquachain.github.io", + chainId: 61717561, + nativeCurrency: { + name: "Aquachain Ether", + symbol: "AQUA", + decimals: 18, + }, + chain: "AQUA", + }, + { + name: "Polygon Blackberry", + infoURL: + "https://raas.gelato.network/rollups/details/public/polygon-blackberry", + chainId: 94204209, + nativeCurrency: { + name: "Sepolia Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "OP Celestia Raspberry", + infoURL: + "https://raas.gelato.network/rollups/details/public/opcelestia-raspberry", + chainId: 123420111, + nativeCurrency: { + name: "Sepolia Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Ancient8", + infoURL: "https://ancient8.gg/", + chainId: 888888888, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "Ancient8", + }, + { + name: "IPOS Network", + infoURL: "https://iposlab.com", + chainId: 1122334455, + nativeCurrency: { + name: "IPOS Network Ether", + symbol: "IPOS", + decimals: 18, + }, + chain: "IPOS", + }, + { + name: "Aurora Mainnet", + infoURL: "https://aurora.dev", + chainId: 1313161554, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "NEAR", + }, + { + name: "Aurora Betanet", + infoURL: "https://aurora.dev", + chainId: 1313161556, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "NEAR", + }, + { + name: "PowerGold", + infoURL: "https://www.powergold.tech", + chainId: 1313161560, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "NEAR", + }, + { + name: "RARI Chain Mainnet", + infoURL: "https://rarichain.org/", + chainId: 1380012617, + nativeCurrency: { + name: "Ethereum", + symbol: "ETH", + decimals: 18, + }, + chain: "RARI", + }, + { + name: "Pirl", + infoURL: "https://pirl.io", + chainId: 3125659152, + nativeCurrency: { + name: "Pirl Ether", + symbol: "PIRL", + decimals: 18, + }, + chain: "PIRL", + }, + { + name: "Arbitrum Blueberry", + infoURL: "https://raas.gelato.network/rollups/details/public/arb-blueberry", + chainId: 88153591557, + nativeCurrency: { + name: "GelatoCGT", + symbol: "CGT", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "Molereum Network", + infoURL: "https://github.com/Jdubedition/molereum", + chainId: 6022140761023, + nativeCurrency: { + name: "Molereum Ether", + symbol: "MOLE", + decimals: 18, + }, + chain: "ETH", + }, + { + name: "DCHAIN", + infoURL: "https://www.dchain.foundation/", + chainId: 2716446429837000, + nativeCurrency: { + name: "Ether", + symbol: "ETH", + decimals: 18, + }, + chain: "dchainmainnet", + }, +] as const + +export default chains diff --git a/src/data/wallets/wallet-data.ts b/src/data/wallets/wallet-data.ts index db5f9115b81..ce6ebfd898d 100644 --- a/src/data/wallets/wallet-data.ts +++ b/src/data/wallets/wallet-data.ts @@ -1,6 +1,6 @@ import { WalletData } from "@/lib/types" -import { newToCrypto } from "./new-to-crypto" +import { newToCrypto } from "@/data/wallets/new-to-crypto" import OneInchWalletImage from "@/public/images/wallets/1inch.png" import AlphaWalletImage from "@/public/images/wallets/alpha.png" @@ -42,7 +42,12 @@ import TrustWalletImage from "@/public/images/wallets/trustwallet.png" import UnstoppableWalletImage from "@/public/images/wallets/unstoppable.png" import ZerionImage from "@/public/images/wallets/zerion.png" -const walletsData = [ +/** + * See src/data/chains.ts for available chains and names for use within + * the optional `supported_chains` array. + */ + +export const walletsData: WalletData[] = [ { last_updated: "2024-10-30", name: "Keystone", @@ -89,6 +94,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://support.keyst.one/", documentation: "https://guide.keyst.one/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-30", @@ -136,6 +142,7 @@ const walletsData = [ social_recovery: true, onboard_documentation: "https://docs-wallet.loopring.io/", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-03-07", @@ -182,6 +189,7 @@ const walletsData = [ social_recovery: true, onboard_documentation: "https://www.argent.xyz/learn/", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-11-15", @@ -238,6 +246,7 @@ const walletsData = [ onboard_documentation: "https://www.coinbase.com/wallet/tutorials", documentation: "", // note: "Community contribution, let's follow up with Coinbase", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-06-22", @@ -282,6 +291,7 @@ const walletsData = [ onboard_documentation: "https://framelabs.notion.site/Getting-Started-Guide-775a95edec3244ce80e118ead8ea6516", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-06-22", @@ -370,6 +380,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://support.metamask.io", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2023-01-25", @@ -413,6 +424,7 @@ const walletsData = [ social_recovery: true, onboard_documentation: "https://docs.safe.global/", documentation: "https://docs.safe.global/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "May 10, 2024", @@ -483,6 +495,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://coin.space/ethereum-wallet/", documentation: "https://support.coin.space/hc/en-us", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-30", @@ -527,6 +540,7 @@ const walletsData = [ onboard_documentation: "https://help.ambire.com/hc/en-us/categories/4404980091538-Ambire-Wallet", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-08-31", @@ -582,6 +596,7 @@ const walletsData = [ onboard_documentation: "https://support.token.im/hc/categories/360000925393", documentation: "https://support.token.im/hc/en-us", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-08-30", @@ -642,6 +657,7 @@ const walletsData = [ onboard_documentation: "https://help.1inch.io/en/collections/2897068-1inch-wallet", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-30", @@ -700,6 +716,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://hc.foxwallet.com/docs/", documentation: "https://hc.foxwallet.com/docs/faq", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-06-24", @@ -746,6 +763,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "", documentation: "https://help.pillar.fi/en/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-06-24", @@ -790,6 +808,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://www.mewtopia.com/", documentation: "https://help.myetherwallet.com/en/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-06-24", @@ -834,6 +853,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "", documentation: "https://unstoppable.money/faq", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { @@ -879,6 +899,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://alphawallet.zendesk.com/hc/en-us", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-07-24", @@ -923,6 +944,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://www.mtpelerin.com/learn", documentation: "https://www.mtpelerin.com/support", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-09-14", @@ -968,6 +990,7 @@ const walletsData = [ onboard_documentation: "https://docs.tor.us/wallet/faq-1/users", documentation: "https://docs.tor.us/", mpc: true, + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-07-18", @@ -1035,6 +1058,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "", documentation: "https://help.tokenpocket.pro/developer-en/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-06-30", @@ -1092,6 +1116,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://learn.rainbow.me/", documentation: "", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-09-01", @@ -1136,6 +1161,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://trezor.io/support", documentation: "https://trezor.io/learn", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-08-21", @@ -1192,6 +1218,7 @@ const walletsData = [ onboard_documentation: "", documentation: "https://support.ledger.com/hc/en-us/categories/4404376139409?docs=true", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-08-16", @@ -1236,6 +1263,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "", documentation: "https://docs.infinitywallet.io/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-08-19", @@ -1286,6 +1314,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "", documentation: "https://support.exodus.com/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-07-24", @@ -1334,6 +1363,27 @@ const walletsData = [ social_recovery: false, onboard_documentation: "", documentation: "", + supported_chains: [ + "Arbitrum One", + "Astar zkEVM", + "Aurora Mainnet", + "Base", + "Blast", + "Boba Network", + "Cyber Mainnet", + "DBK Chain", + "Fraxtal", + "Karak Mainnet", + "Metis Andromeda Mainnet", + "Mint Mainnet", + "Mode", + "Linea", + "OP Mainnet", + "Polygon zkEVM", + "Scroll", + "zkSync Mainnet", + "Zora", + ], }, { last_updated: "2024-09-26", @@ -1394,6 +1444,7 @@ const walletsData = [ onboard_documentation: "https://help.zerion.io/en/collections/5525626-zerion-wallet", documentation: "https://help.zerion.io/en/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-08-31", @@ -1438,6 +1489,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "", documentation: "https://www.mewtopia.com/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2022-10-31", @@ -1482,6 +1534,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://www.youtube.com/c/GridPlus", documentation: "https://docs.gridplus.io/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2023-01-24", @@ -1526,6 +1579,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://study.bitkeep.com/en/", documentation: "https://docs.bitkeep.com/guide/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-31", @@ -1576,6 +1630,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://blockwallet.io/docs", documentation: "https://github.com/block-wallet/extension", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-30", @@ -1639,6 +1694,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://help.onekey.so/hc/en-us", documentation: "https://developer.onekey.so/guide/introduction", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2023-04-21", @@ -1688,6 +1744,7 @@ const walletsData = [ "https://tahowallet.notion.site/Taho-Knowledge-Base-4d95ed5439c64d6db3d3d27abf1fdae5", documentation: "https://tahowallet.notion.site/Taho-Knowledge-Base-4d95ed5439c64d6db3d3d27abf1fdae5", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-30", @@ -1760,6 +1817,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://phantom.app/learn", documentation: "https://docs.phantom.app/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2023-08-29", @@ -1806,6 +1864,7 @@ const walletsData = [ social_recovery: true, onboard_documentation: "https://intercom.help/ctrlwallet/en/", documentation: "https://docs.xdefi.io/docs", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2023-11-02", @@ -1869,6 +1928,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://community.trustwallet.com/", documentation: "https://developer.trustwallet.com/developer/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2023-10-30", @@ -1915,6 +1975,7 @@ const walletsData = [ "https://docs.getaurox.com/product-docs/aurox-ecosystem/what-is-the-aurox-ecosystem", documentation: "https://docs.getaurox.com/product-docs/aurox-ecosystem/what-is-the-aurox-ecosystem", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-07", @@ -1973,6 +2034,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://docs.shapeshift.com/", documentation: "https://docs.shapeshift.com/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-06-20", @@ -2032,6 +2094,7 @@ const walletsData = [ social_recovery: false, onboard_documentation: "https://docs.gemwallet.com/", documentation: "https://docs.gemwallet.com/", + supported_chains: ["Ethereum Mainnet"], // TODO: Add supported chains }, { last_updated: "2024-10-31", diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 3984d7922b9..5f2467905cf 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -132,6 +132,24 @@ export const DEVELOPER_FEATURES = [ "erc_20_support", ] +// Chains +export const CHAINID_NETWORK_ENDPOINT = "https://chainid.network/chains.json" + +export const TESTNETS = [ + "goerli", + "holesky", + "kiln", + "kintsugi", + "ropsten", + "rinkeby", + "sepolia", + "zhejiang", +] + +export const EXCLUDED_NAMES = ["deprecated", "testnet"] + +export const ETH = "ETH" + /** * Navigation */ diff --git a/src/lib/types.ts b/src/lib/types.ts index c654d2ae24e..79d74b5f2da 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -20,6 +20,7 @@ import type { BreadcrumbsProps } from "@/components/Breadcrumbs" import type { CallToActionProps } from "@/components/Hero/CallToAction" import type { SimulatorNav } from "@/components/Simulator/interfaces" +import chains from "@/data/chains" import allQuizData from "@/data/quizzes" import allQuestionData from "@/data/quizzes/questionBank" @@ -585,8 +586,50 @@ export type CommunityConference = { imageUrl: string } +// Chains +export type ChainIdNetworkResponse = { + name: string + chain: string + title?: string + icon?: string + rpc: string[] + features?: { name: string }[] + faucets?: string[] + nativeCurrency: { + name: string + symbol: string + decimals: number + } + infoURL: string + shortName: string + chainId: number + networkId: number + redFlags?: string[] + slip44?: number + ens?: { registry: string } + explorers?: { + name: string + url: string + icon?: string + standard: string + }[] + status?: "deprecated" | "active" | "incubating" + parent?: { + type: "L2" | "shard" + chain: string + bridges?: { url: string }[] + } +} + +export type Chain = Pick< + ChainIdNetworkResponse, + "name" | "infoURL" | "chainId" | "nativeCurrency" | "chain" +> + +export type ChainName = (typeof chains)[number]["name"] + // Wallets -export interface WalletData { +export type WalletData = { last_updated: string name: string image: StaticImageData @@ -620,6 +663,7 @@ export interface WalletData { swaps: boolean multichain?: boolean layer_2: boolean + supported_chains?: ChainName[] gas_fee_customization: boolean ens_support: boolean erc_20_support: boolean diff --git a/src/scripts/update-chains.ts b/src/scripts/update-chains.ts new file mode 100644 index 00000000000..65777c67b2b --- /dev/null +++ b/src/scripts/update-chains.ts @@ -0,0 +1,90 @@ +import { execSync } from "child_process" +import fs from "fs" +import path from "path" + +import type { Chain, ChainIdNetworkResponse } from "@/lib/types" + +import { + CHAINID_NETWORK_ENDPOINT, + ETH, + EXCLUDED_NAMES, + TESTNETS, +} from "../lib/constants" + +/** + * Fetches the chain data from the chainid.network endpoint. + * + * @returns A promise that resolves to an array of ChainIdNetwork objects. + */ +export const fetchChainIdNetworks = async (): Promise< + ChainIdNetworkResponse[] +> => { + try { + const response = await fetch(CHAINID_NETWORK_ENDPOINT) + + if (!response.ok) throw new Error("Failed to fetch chains.json data") + + return await response.json() + } catch (error) { + console.error((error as Error).message) + return [] + } +} + +const parseChains = async ( + chains: ChainIdNetworkResponse[] +): Promise => + chains + .filter((item: ChainIdNetworkResponse) => { + const { name, status, chain, nativeCurrency } = item + + const containsEther = nativeCurrency.name.toLowerCase().includes("ether") + const containsETH = nativeCurrency.symbol.includes(ETH) + const isEthereum = chain === ETH || containsETH || containsEther + + const isActive = !["deprecated", "incubating"].includes(status || "") + const isExcluded = [...EXCLUDED_NAMES, ...TESTNETS].some((word) => + name.toLowerCase().includes(word) + ) + + return isEthereum && isActive && !isExcluded + }) + // Map into simplified Chain object + .map(({ chain, name, infoURL, chainId, nativeCurrency }) => ({ + name, + infoURL, + chainId, + nativeCurrency, + chain, + })) + +/** + * Updates the chains data by calling the ChainIdNetworkImport function and + * writing the result to a TypeScript file. + */ +export const updateChainsTsFile = async () => { + // Get the data from ChainIdNetworkImport + const returnedChains = await fetchChainIdNetworks() + + // Parse the chains data + const chains = await parseChains(returnedChains) + + // Path to the new TypeScript file + const chainsTsPath = path.join(process.cwd(), "src/data/chains.ts") + + // Create the TypeScript content + const tsConst = `const chains = ${JSON.stringify(chains, null, 2)} as const` + const tsExport = `export default chains` + + // Write the TypeScript content to the new file + fs.writeFileSync(chainsTsPath, tsConst + `\n\n` + tsExport, "utf-8") + + // Log results + console.log(chains) + console.log(`Generated/updated ${chainsTsPath}`) + + // Run auto-linter on updated TypeScript file + execSync(`npx prettier ${chainsTsPath} --write`) +} + +updateChainsTsFile()