From 5d4b2eb9c0b0a32ffe0a20cff2a6eaf0435bffe6 Mon Sep 17 00:00:00 2001 From: Kayode Odole <31928403+Kayconfig@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:34:09 +0100 Subject: [PATCH] feat: add support for flow mainnet and testnet --- .changeset/proud-plants-punch.md | 7 + .../common/evmUtils/src/data/chaindata.ts | 136 ++++++++++++++++-- .../src/dataTypes/EvmChain/EvmChain.test.ts | 2 + .../src/dataTypes/EvmChain/EvmChain.ts | 24 +++- 4 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 .changeset/proud-plants-punch.md diff --git a/.changeset/proud-plants-punch.md b/.changeset/proud-plants-punch.md new file mode 100644 index 0000000000..af1b92b6ad --- /dev/null +++ b/.changeset/proud-plants-punch.md @@ -0,0 +1,7 @@ +--- +'@moralisweb3/common-evm-utils': patch +'@moralisweb3/evm-api': patch +'moralis': patch +--- + +Add support for Flow mainnet and testnet diff --git a/packages/common/evmUtils/src/data/chaindata.ts b/packages/common/evmUtils/src/data/chaindata.ts index 6cec07e719..60d84b7674 100644 --- a/packages/common/evmUtils/src/data/chaindata.ts +++ b/packages/common/evmUtils/src/data/chaindata.ts @@ -338,12 +338,12 @@ export const chainList: EvmChainListDataEntry[] = [ ], faucets: [], nativeCurrency: { - name: 'MATIC', - symbol: 'MATIC', + name: 'POL', + symbol: 'POL', decimals: 18, }, infoURL: 'https://polygon.technology/', - shortName: 'matic', + shortName: 'pol', chainId: 137, networkId: 137, slip44: 966, @@ -397,12 +397,66 @@ export const chainList: EvmChainListDataEntry[] = [ }, ], }, + { + name: 'EVM on Flow Testnet', + chain: 'Flow', + rpc: ['https://testnet.evm.nodes.onflow.org'], + faucets: ['https://faucet.flow.com/fund-account'], + nativeCurrency: { + name: 'FLOW', + symbol: 'FLOW', + decimals: 18, + }, + infoURL: 'https://developers.flow.com/evm/about', + shortName: 'flow-testnet', + chainId: 545, + networkId: 545, + icon: 'flowevm', + explorers: [ + { + name: 'FlowScan Testnet', + url: 'https://evm-testnet.flowscan.io', + standard: 'EIP3091', + }, + ], + }, + { + name: 'EVM on Flow', + chain: 'Flow', + rpc: ['https://mainnet.evm.nodes.onflow.org'], + faucets: [], + nativeCurrency: { + name: 'FLOW', + symbol: 'FLOW', + decimals: 18, + }, + infoURL: 'https://developers.flow.com/evm/about', + shortName: 'flow-mainnet', + chainId: 747, + networkId: 747, + icon: 'flowevm', + explorers: [ + { + name: 'FlowScan', + url: 'https://evm.flowscan.io', + standard: 'EIP3091', + }, + ], + }, { name: 'Moonbeam', chain: 'MOON', rpc: [ 'https://rpc.api.moonbeam.network', 'wss://wss.api.moonbeam.network', + 'https://moonbeam.public.blastapi.io', + 'wss://moonbeam.public.blastapi.io', + 'https://moonbeam-rpc.dwellir.com', + 'wss://moonbeam-rpc.dwellir.com', + 'https://moonbeam.api.onfinality.io/public', + 'wss://moonbeam.api.onfinality.io/public-ws', + 'https://moonbeam.unitedbloc.com', + 'wss://moonbeam.unitedbloc.com', 'https://moonbeam-rpc.publicnode.com', 'wss://moonbeam-rpc.publicnode.com', 'https://moonbeam.drpc.org', @@ -432,6 +486,14 @@ export const chainList: EvmChainListDataEntry[] = [ rpc: [ 'https://rpc.api.moonriver.moonbeam.network', 'wss://wss.api.moonriver.moonbeam.network', + 'https://moonriver.public.blastapi.io', + 'wss://moonriver.public.blastapi.io', + 'https://moonriver-rpc.dwellir.com', + 'wss://moonriver-rpc.dwellir.com', + 'https://moonriver.api.onfinality.io/public', + 'wss://moonriver.api.onfinality.io/public-ws', + 'https://moonriver.unitedbloc.com', + 'wss://moonriver.unitedbloc.com', 'https://moonriver-rpc.publicnode.com', 'wss://moonriver-rpc.publicnode.com', 'https://moonriver.drpc.org', @@ -461,6 +523,14 @@ export const chainList: EvmChainListDataEntry[] = [ rpc: [ 'https://rpc.api.moonbase.moonbeam.network', 'wss://wss.api.moonbase.moonbeam.network', + 'https://moonbase-alpha.public.blastapi.io', + 'wss://moonbase-alpha.public.blastapi.io', + 'https://moonbase-rpc.dwellir.com', + 'wss://moonbase-rpc.dwellir.com', + 'https://moonbeam-alpha.api.onfinality.io/public', + 'wss://moonbeam-alpha.api.onfinality.io/public-ws', + 'https://moonbase.unitedbloc.com', + 'wss://moonbase.unitedbloc.com', 'https://moonbase-alpha.drpc.org', 'wss://moonbase-alpha.drpc.org', ], @@ -470,7 +540,7 @@ export const chainList: EvmChainListDataEntry[] = [ symbol: 'DEV', decimals: 18, }, - infoURL: 'https://docs.moonbeam.network/networks/testnet/', + infoURL: 'https://docs.moonbeam.network/learn/platform/networks/moonbase/', shortName: 'mbase', chainId: 1287, networkId: 1287, @@ -606,6 +676,7 @@ export const chainList: EvmChainListDataEntry[] = [ 'wss://ethereum-holesky-rpc.publicnode.com', 'https://holesky.drpc.org', 'wss://holesky.drpc.org', + 'https://rpc-holesky.rockx.com', ], faucets: ['https://faucet.holesky.ethpandaops.io', 'https://holesky-faucet.pk910.de'], nativeCurrency: { @@ -759,6 +830,8 @@ export const chainList: EvmChainListDataEntry[] = [ 'wss://rpc.sepolia.linea.build', 'https://linea-sepolia.infura.io/v3/${INFURA_API_KEY}', 'wss://linea-sepolia.infura.io/ws/v3/${INFURA_API_KEY}', + 'https://linea-sepolia-rpc.publicnode.com', + 'wss://linea-sepolia-rpc.publicnode.com', ], faucets: [], nativeCurrency: { @@ -806,6 +879,8 @@ export const chainList: EvmChainListDataEntry[] = [ 'wss://rpc.linea.build', 'https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}', 'wss://linea-mainnet.infura.io/ws/v3/${INFURA_API_KEY}', + 'https://linea-rpc.publicnode.com', + 'wss://linea-rpc.publicnode.com', ], faucets: [], nativeCurrency: { @@ -981,24 +1056,54 @@ export const chainList: EvmChainListDataEntry[] = [ ], }, { - name: 'IVAR Chain Mainnet', - chain: 'IVAR', - icon: 'ivar', - rpc: ['https://mainnet-rpc.ivarex.com'], - faucets: ['https://faucet.ivarex.com/'], + name: 'Chiliz Spicy Testnet', + chain: 'CHZ', + rpc: ['https://spicy-rpc.chiliz.com'], + faucets: ['https://spicy-faucet.chiliz.com', 'https://tatum.io/faucets/chiliz'], nativeCurrency: { - name: 'Ivar', - symbol: 'IVAR', + name: 'Chiliz', + symbol: 'CHZ', decimals: 18, }, - infoURL: 'https://ivarex.com', - shortName: 'ivar', + icon: 'chilizspicy', + infoURL: 'https://www.chiliz.com/en/chain', + shortName: 'chzspicy', + chainId: 88882, + networkId: 88882, + slip44: 1, + explorers: [ + { + name: 'spicy-explorer', + url: 'https://testnet.chiliscan.com', + standard: 'EIP3091', + }, + ], + }, + { + name: 'Chiliz Chain Mainnet', + chain: 'CHZ', + icon: 'chilizchain', + rpc: ['https://rpc.chiliz.com', 'https://rpc.ankr.com/chiliz', 'https://chiliz.publicnode.com'], + faucets: ['https://spicy-faucet.chiliz.com', 'https://tatum.io/faucets/chiliz'], + nativeCurrency: { + name: 'Chiliz', + symbol: 'CHZ', + decimals: 18, + }, + infoURL: 'https://chiliz.com', + shortName: 'chzmainnet', chainId: 88888, networkId: 88888, + redFlags: ['reusedChainId'], explorers: [ { - name: 'ivarscan', - url: 'https://ivarscan.com', + name: 'chiliscan', + url: 'https://chiliscan.com', + standard: 'EIP3091', + }, + { + name: 'chilizscan', + url: 'https://scan.chiliz.com', standard: 'EIP3091', }, ], @@ -1057,6 +1162,7 @@ export const chainList: EvmChainListDataEntry[] = [ 'wss://ethereum-sepolia-rpc.publicnode.com', 'https://sepolia.drpc.org', 'wss://sepolia.drpc.org', + 'https://rpc-sepolia.rockx.com', ], faucets: ['http://fauceth.komputing.org?chain=11155111&address=${ADDRESS}'], nativeCurrency: { diff --git a/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.test.ts b/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.test.ts index b35e9d0ac4..f46f184924 100644 --- a/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.test.ts +++ b/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.test.ts @@ -128,6 +128,8 @@ describe('EvmChain', () => { expect(EvmChain.MOONRIVER.apiHex).toBe('0x505'); expect(EvmChain.MOONBASE.apiHex).toBe('0x507'); expect(EvmChain.LINEA_SEPOLIA.apiHex).toBe('0xe705'); + expect(EvmChain.FLOW.apiHex).toBe('0x2eb'); + expect(EvmChain.FLOW_TESTNET.apiHex).toBe('0x221'); }); describe('metadata', () => { diff --git a/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.ts b/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.ts index b1722fa698..2fe93be03f 100644 --- a/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.ts +++ b/packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.ts @@ -295,6 +295,24 @@ export class EvmChain implements EvmChainable { return EvmChain.create(59141); } + /** + * Returns FLOW mainnet chain + * + * @example EvmChain.FLOW + */ + public static get FLOW() { + return EvmChain.create(747); + } + + /** + * Returns FLOW testnet chain + * + * @example EvmChain.FLOW_TESTNET + */ + public static get FLOW_TESTNET() { + return EvmChain.create(0x221); + } + /** * Create a new instance of EvmChain from any valid address input. * @@ -381,6 +399,8 @@ export class EvmChain implements EvmChainable { EvmChain.MOONRIVER, EvmChain.MOONBASE, EvmChain.LINEA_SEPOLIA, + EvmChain.FLOW, + EvmChain.FLOW_TESTNET, ]; } @@ -497,7 +517,9 @@ export class EvmChain implements EvmChainable { | '0x504' | '0x505' | '0x507' - | '0xe705'; + | '0xe705' + | '0x2eb' + | '0x221'; } /**