From 5edf74a4b911aeeee9326ff0f50df8da08b807c1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 22 Oct 2024 14:09:52 +0200 Subject: [PATCH] fix rpc endpoint properties --- .../injected-arbitrum-one-provider.tsx | 17 -------- .../providers/injected-custom-provider.tsx | 10 +++-- .../injected-ephemery-testnet-provider.tsx | 40 ------------------- .../providers/injected-optimism-provider.tsx | 17 -------- .../injected-provider-trustwallet.tsx | 26 ------------ .../injected-skale-chaos-testnet-provider.tsx | 27 ------------- apps/remix-ide/src/app/udapp/run-tab.tsx | 14 +++---- 7 files changed, 13 insertions(+), 138 deletions(-) delete mode 100644 apps/remix-ide/src/app/providers/injected-arbitrum-one-provider.tsx delete mode 100644 apps/remix-ide/src/app/providers/injected-ephemery-testnet-provider.tsx delete mode 100644 apps/remix-ide/src/app/providers/injected-optimism-provider.tsx delete mode 100644 apps/remix-ide/src/app/providers/injected-provider-trustwallet.tsx delete mode 100644 apps/remix-ide/src/app/providers/injected-skale-chaos-testnet-provider.tsx diff --git a/apps/remix-ide/src/app/providers/injected-arbitrum-one-provider.tsx b/apps/remix-ide/src/app/providers/injected-arbitrum-one-provider.tsx deleted file mode 100644 index 5930572249..0000000000 --- a/apps/remix-ide/src/app/providers/injected-arbitrum-one-provider.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import * as packageJson from '../../../../../package.json' -import { InjectedCustomProvider } from './injected-custom-provider' - -const profile = { - name: 'injected-arbitrum-one-provider', - displayName: 'Injected Arbitrum One Provider', - kind: 'provider', - description: 'injected Arbitrum One Provider', - methods: ['sendAsync', 'init'], - version: packageJson.version -} - -export class InjectedArbitrumOneProvider extends InjectedCustomProvider { - constructor() { - super(profile, 'Arbitrum One', '0xa4b1', ['https://arb1.arbitrum.io/rpc']) - } -} 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 a00604b3d9..7d90e6423a 100644 --- a/apps/remix-ide/src/app/providers/injected-custom-provider.tsx +++ b/apps/remix-ide/src/app/providers/injected-custom-provider.tsx @@ -4,12 +4,14 @@ import { InjectedProviderDefault } from './injected-provider-default' export class InjectedCustomProvider extends InjectedProviderDefault { chainName: string chainId: string + pluginName: string rpcUrls: Array nativeCurrency: Record blockExplorerUrls: Array - constructor(provider: any, chainName: string, chainId: string, rpcUrls: Array, nativeCurrency?: Record, blockExplorerUrls?: Array) { - super(provider, chainName) + constructor(provider: any, pluginName: string, chainName: string, chainId: string, rpcUrls: Array, nativeCurrency?: Record, blockExplorerUrls?: Array) { + super(provider, pluginName) + this.pluginName = pluginName this.chainName = chainName this.chainId = chainId this.rpcUrls = rpcUrls @@ -44,8 +46,8 @@ export const setCustomNetwork = async (chainName: string, chainId: string, rpcUr chainName: chainName, rpcUrls: rpcUrls, } - if (nativeCurrency) paramsObj.nativeCurrency = nativeCurrency - if (blockExplorerUrls) paramsObj.blockExplorerUrls = blockExplorerUrls + paramsObj.nativeCurrency = nativeCurrency ? nativeCurrency : null + paramsObj.blockExplorerUrls = blockExplorerUrls ? blockExplorerUrls : null await (window as any).ethereum.request({ method: 'wallet_addEthereumChain', params: [paramsObj] 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 deleted file mode 100644 index 4b25986ba5..0000000000 --- a/apps/remix-ide/src/app/providers/injected-ephemery-testnet-provider.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import * as packageJson from '../../../../../package.json' -import { InjectedCustomProvider } from './injected-custom-provider' -import { Web3 } from 'web3' - -const profile = { - name: 'injected-ephemery-testnet-provider', - displayName: 'Injected Ephemery Testnet Provider', - kind: 'provider', - description: 'Injected Ephemery Testnet Provider', - methods: ['sendAsync', 'init'], - version: packageJson.version -} - -export class InjectedEphemeryTestnetProvider extends InjectedCustomProvider { - constructor() { - 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/' - ] - ) - } - - async init() { - const chainId = await new Web3(this.rpcUrls[0]).eth.getChainId() - this.chainId = `0x${chainId.toString(16)}` - this.chainName = `Ephemery Testnet ${chainId}` - await super.init() - return {} - } - -} diff --git a/apps/remix-ide/src/app/providers/injected-optimism-provider.tsx b/apps/remix-ide/src/app/providers/injected-optimism-provider.tsx deleted file mode 100644 index dd14c4ab11..0000000000 --- a/apps/remix-ide/src/app/providers/injected-optimism-provider.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import * as packageJson from '../../../../../package.json' -import { InjectedCustomProvider } from './injected-custom-provider' - -const profile = { - name: 'injected-optimism-provider', - displayName: 'Injected Optimism Provider', - kind: 'provider', - description: 'injected Optimism Provider', - methods: ['sendAsync', 'init'], - version: packageJson.version -} - -export class Injected0ptimismProvider extends InjectedCustomProvider { - constructor() { - super(profile, 'Optimism', '0xa', ['https://mainnet.optimism.io']) - } -} diff --git a/apps/remix-ide/src/app/providers/injected-provider-trustwallet.tsx b/apps/remix-ide/src/app/providers/injected-provider-trustwallet.tsx deleted file mode 100644 index ea7185ad4f..0000000000 --- a/apps/remix-ide/src/app/providers/injected-provider-trustwallet.tsx +++ /dev/null @@ -1,26 +0,0 @@ -/* global ethereum */ -import * as packageJson from '../../../../../package.json' -import { InjectedProvider } from './injected-provider' - -const profile = { - name: 'injected-trustwallet', - displayName: 'Trust wallet', - kind: 'provider', - description: 'Trust wallet', - methods: ['sendAsync', 'init'], - version: packageJson.version -} - -export class InjectedProviderTrustWallet extends InjectedProvider { - constructor() { - super(profile) - } - - getInjectedProvider() { - return (window as any).trustwallet - } - - notFound() { - return 'Could not find Trust Wallet provider. Please make sure the Trust Wallet extension is active. Download the latest version from https://trustwallet.com/browser-extension' - } -} diff --git a/apps/remix-ide/src/app/providers/injected-skale-chaos-testnet-provider.tsx b/apps/remix-ide/src/app/providers/injected-skale-chaos-testnet-provider.tsx deleted file mode 100644 index c5da299f76..0000000000 --- a/apps/remix-ide/src/app/providers/injected-skale-chaos-testnet-provider.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import * as packageJson from '../../../../../package.json' -import { InjectedCustomProvider } from './injected-custom-provider' - -const profile = { - name: 'injected-skale-chaos-testnet-provider', - displayName: 'Injected SKALE Chaos Testnet', - kind: 'provider', - description: 'Injected SKALE Chaos Testnet Provider', - methods: ['sendAsync', 'init'], - version: packageJson.version -} - -export class InjectedSKALEChaosTestnetProvider extends InjectedCustomProvider { - - constructor () { - super(profile, - 'SKALE Chaos Testnet', - '0x50877ed6', - ['https://staging-v3.skalenodes.com/v1/staging-fast-active-bellatrix'], - { - "name": "sFUEL", - "symbol": "sFUEL", - "decimals": 18 - } - ) - } -} diff --git a/apps/remix-ide/src/app/udapp/run-tab.tsx b/apps/remix-ide/src/app/udapp/run-tab.tsx index 84c50b5475..b513a76c2e 100644 --- a/apps/remix-ide/src/app/udapp/run-tab.tsx +++ b/apps/remix-ide/src/app/udapp/run-tab.tsx @@ -215,8 +215,8 @@ export class RunTab extends ViewPlugin { const addCustomInjectedProvider = async (position, event, name, displayName, networkId, urls, nativeCurrency?) => { // name = `${name} through ${event.detail.info.name}` - await this.engine.register([new InjectedCustomProvider(event.detail.provider, name, networkId, urls, nativeCurrency)]) - await addProvider(position, name, displayName, true, false) + await this.engine.register([new InjectedCustomProvider(event.detail.provider, name, displayName, networkId, urls, nativeCurrency)]) + await addProvider(position, name, displayName + ' - ' + event.detail.info.name, true, false) } const registerInjectedProvider = async (event) => { const name = 'injected-' + event.detail.info.name @@ -225,21 +225,21 @@ export class RunTab extends ViewPlugin { await addProvider(0, name, displayName, true, false) if (event.detail.info.name === 'MetaMask') { - await addCustomInjectedProvider(7, event, 'injected-metamask-optimism', 'L2 - Optimism - ' + event.detail.info.name, '0xa', ['https://mainnet.optimism.io']) - await addCustomInjectedProvider(8, event, 'injected-metamask-arbitrum', 'L2 - Arbitrum - ' + event.detail.info.name, '0xa4b1', ['https://arb1.arbitrum.io/rpc']) - await addCustomInjectedProvider(5, event, 'injected-metamask-sepolia', 'Sepolia Testnet - ' + event.detail.info.name, '0xaa36a7', [], + await addCustomInjectedProvider(7, event, 'injected-metamask-optimism', 'L2 - Optimism', '0xa', ['https://mainnet.optimism.io']) + await addCustomInjectedProvider(8, event, 'injected-metamask-arbitrum', 'L2 - Arbitrum', '0xa4b1', ['https://arb1.arbitrum.io/rpc']) + await addCustomInjectedProvider(5, event, 'injected-metamask-sepolia', 'Sepolia Testnet', '0xaa36a7', [], { "name": "Sepolia ETH", "symbol": "ETH", "decimals": 18 }) - await addCustomInjectedProvider(9, event, 'injected-metamask-ephemery', 'Ephemery Testnet - ' + event.detail.info.name, '', ['https://otter.bordel.wtf/erigon', 'https://eth.ephemeral.zeus.fyi'], + await addCustomInjectedProvider(9, event, 'injected-metamask-ephemery', 'Ephemery Testnet', '', ['https://otter.bordel.wtf/erigon', 'https://eth.ephemeral.zeus.fyi'], { "name": "Ephemery ETH", "symbol": "ETH", "decimals": 18 }) - await addCustomInjectedProvider(10, event, 'injected-metamask-gnosis', 'Gnosis Mainnet - ' + event.detail.info.name, '', ['https://rpc.ankr.com/gnosis', 'https://1rpc.io/gnosis'], + await addCustomInjectedProvider(10, event, 'injected-metamask-gnosis', 'Gnosis Mainnet', '', ['https://rpc.ankr.com/gnosis', 'https://1rpc.io/gnosis'], { "name": "XDAI", "symbol": "XDAI",