diff --git a/apps/remix-ide/src/app/providers/injected-custom-provider.tsx b/apps/remix-ide/src/app/providers/injected-custom-provider.tsx index 9e9807e78c..95a8e08830 100644 --- a/apps/remix-ide/src/app/providers/injected-custom-provider.tsx +++ b/apps/remix-ide/src/app/providers/injected-custom-provider.tsx @@ -4,23 +4,27 @@ export class InjectedCustomProvider extends InjectedProviderDefaultBase { chainName: string chainId: string rpcUrls: Array + nativeCurrency: Record + blockExplorerUrls: Array - constructor(profile: any, chainName: string, chainId: string, rpcUrls: Array) { + constructor(profile: any, chainName: string, chainId: string, rpcUrls: Array, nativeCurrency?: Record, blockExplorerUrls?: Array) { super(profile) this.chainName = chainName this.chainId = chainId this.rpcUrls = rpcUrls + this.nativeCurrency = nativeCurrency + this.blockExplorerUrls = blockExplorerUrls } async init() { await super.init() - if (this.chainName && this.rpcUrls && this.rpcUrls.length > 0) await addCustomNetwork(this.chainName, this.chainId, this.rpcUrls) + if (this.chainName && this.rpcUrls && this.rpcUrls.length > 0) await addCustomNetwork(this.chainName, this.chainId, this.rpcUrls, this.nativeCurrency, this.blockExplorerUrls) else throw new Error('Cannot add the custom network to main injected provider') return {} } } -export const addCustomNetwork = async (chainName: string, chainId: string, rpcUrls: Array) => { +export const addCustomNetwork = async (chainName: string, chainId: string, rpcUrls: Array, nativeCurrency?: Record, blockExplorerUrls?: Array) => { try { await (window as any).ethereum.request({ method: 'wallet_switchEthereumChain', @@ -30,15 +34,16 @@ export const addCustomNetwork = async (chainName: string, chainId: string, rpcUr // This error code indicates that the chain has not been added to MetaMask. if (switchError.code === 4902) { try { + let paramsObj: Record = { + chainId: chainId, + chainName: chainName, + rpcUrls: rpcUrls, + } + if (nativeCurrency) paramsObj.nativeCurrency = nativeCurrency + if (blockExplorerUrls) paramsObj.blockExplorerUrls = blockExplorerUrls await (window as any).ethereum.request({ method: 'wallet_addEthereumChain', - params: [ - { - chainId: chainId, - chainName: chainName, - rpcUrls: rpcUrls - } - ] + params: [ paramsObj ] }) await (window as any).ethereum.request({ diff --git a/apps/remix-ide/src/app/providers/injected-ephemery-testnet-provider.tsx b/apps/remix-ide/src/app/providers/injected-ephemery-testnet-provider.tsx index 9cfcb3f493..9c7e2918bb 100644 --- a/apps/remix-ide/src/app/providers/injected-ephemery-testnet-provider.tsx +++ b/apps/remix-ide/src/app/providers/injected-ephemery-testnet-provider.tsx @@ -12,6 +12,19 @@ const profile = { export class InjectedEphemeryTestnetProvider extends InjectedCustomProvider { constructor() { - super(profile, 'Ephemery Testnet', '0x259C709', ['https://otter.bordel.wtf/erigon', 'https://eth.ephemeral.zeus.fyi']) + super(profile, + 'Ephemery Testnet', + '', + ['https://otter.bordel.wtf/erigon', 'https://eth.ephemeral.zeus.fyi'], + { + "name": "Ephemery ETH", + "symbol": "ETH", + "decimals": 18 + }, + [ + 'https://otter.bordel.wtf/', + 'https://explorer.ephemery.dev/' + ] + ) } }