From 51470343fd7ab8f826a9866eb4935d0141d91403 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 9 Feb 2023 10:11:59 +0000 Subject: [PATCH] add existing chains to wagmi --- src/@utils/wallet/chains.ts | 73 +++++++++++++++++++++++ src/@utils/{wallet.ts => wallet/index.ts} | 4 +- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/@utils/wallet/chains.ts rename src/@utils/{wallet.ts => wallet/index.ts} (93%) diff --git a/src/@utils/wallet/chains.ts b/src/@utils/wallet/chains.ts new file mode 100644 index 000000000..64b030502 --- /dev/null +++ b/src/@utils/wallet/chains.ts @@ -0,0 +1,73 @@ +import { Chain } from 'wagmi' + +export const energyWeb = { + id: 246, + name: 'Energy Web Chain', + network: 'energyweb', + nativeCurrency: { + decimals: 18, + name: 'EWT', + symbol: 'EWT' + }, + rpcUrls: { + public: { + http: ['https://rpc.energyweb.org'], + webSocket: ['wss://rpc.energyweb.org/ws'] + }, + default: { + http: ['https://rpc.energyweb.org'], + webSocket: ['wss://rpc.energyweb.org/ws'] + } + }, + blockExplorers: { + default: { + name: 'Energy Web Chain', + url: 'https://explorer.energyweb.org/' + }, + blockscout: { + name: 'Energy Web Chain', + url: 'https://explorer.energyweb.org/' + } + }, + testnet: false +} as Chain + +// TODO: remove once moonriver is shipped in wagmi as it is already in codebase +// https://github.com/wagmi-dev/references/blob/main/packages/chains/src/moonriver.ts +export const moonriver = { + id: 1285, + name: 'Moonriver', + network: 'moonriver', + nativeCurrency: { + decimals: 18, + name: 'MOVR', + symbol: 'MOVR' + }, + rpcUrls: { + public: { + http: ['https://moonriver.public.blastapi.io'], + webSocket: ['wss://moonriver.public.blastapi.io'] + }, + default: { + http: ['https://moonriver.public.blastapi.io'], + webSocket: ['wss://moonriver.public.blastapi.io'] + } + }, + blockExplorers: { + default: { + name: 'Moonscan', + url: 'https://moonriver.moonscan.io' + }, + etherscan: { + name: 'Moonscan', + url: 'https://moonriver.moonscan.io' + } + }, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 1597904 + } + }, + testnet: false +} as Chain diff --git a/src/@utils/wallet.ts b/src/@utils/wallet/index.ts similarity index 93% rename from src/@utils/wallet.ts rename to src/@utils/wallet/index.ts index 01b882771..f2ea30f86 100644 --- a/src/@utils/wallet.ts +++ b/src/@utils/wallet/index.ts @@ -4,13 +4,15 @@ import { mainnet, polygon, bsc, goerli, polygonMumbai } from 'wagmi/chains' import { ethers, Contract } from 'ethers' import { formatEther } from 'ethers/lib/utils' import { getDefaultClient } from 'connectkit' +import { energyWeb, moonriver } from './chains' // Wagmi client export const wagmiClient = createClient( getDefaultClient({ appName: 'Ocean Market', infuraId: process.env.NEXT_PUBLIC_INFURA_PROJECT_ID, - chains: [mainnet, polygon, bsc, goerli, polygonMumbai] + // TODO: mapping between appConfig.chainIdsSupported and wagmi chainId + chains: [mainnet, polygon, bsc, energyWeb, moonriver, goerli, polygonMumbai] }) )