From 655a6e147f544bf1ff3ca66fc8e907dad1493e92 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Apr 2024 11:47:54 +0200 Subject: [PATCH] clean native/required plugin list --- .../src/tests/runAndDeploy_injected.test.ts | 4 +- apps/remix-ide/src/remixAppManager.js | 23 +++-- .../run-tab/src/lib/components/account.tsx | 90 +++++++++---------- 3 files changed, 57 insertions(+), 60 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/runAndDeploy_injected.test.ts b/apps/remix-ide-e2e/src/tests/runAndDeploy_injected.test.ts index 9d13417560..8f29fbd5ca 100644 --- a/apps/remix-ide-e2e/src/tests/runAndDeploy_injected.test.ts +++ b/apps/remix-ide-e2e/src/tests/runAndDeploy_injected.test.ts @@ -44,7 +44,7 @@ module.exports = { .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) .click('*[data-id="landingPageStartSolidity"]') .clickLaunchIcon('udapp') - .switchEnvironment('MetaMask') + .switchEnvironment('injected-MetaMask') .waitForElementPresent('*[data-id="settingsNetworkEnv"]') .assert.containsText('*[data-id="settingsNetworkEnv"]', 'Sepolia (11155111) network') .pause(5000) @@ -123,7 +123,7 @@ module.exports = { .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) .click('*[data-id="landingPageStartSolidity"]') .clickLaunchIcon('udapp') - .switchEnvironment('MetaMask') + .switchEnvironment('injected-MetaMask') .waitForElementPresent('*[data-id="settingsNetworkEnv"]') .assert.containsText('*[data-id="settingsNetworkEnv"]', 'Main (1) network') }, diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 47c4af6202..a4ef226d38 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -52,11 +52,6 @@ let requiredModules = [ // services + layout views + system views 'ganache-provider', 'foundry-provider', 'basic-http-provider', - 'injected-trustwallet', - 'injected-optimism-provider', - 'injected-arbitrum-one-provider', - 'injected-ephemery-testnet-provider', - 'injected-skale-chaos-testnet-provider', 'vm-custom-fork', 'vm-goerli-fork', 'vm-mainnet-fork', @@ -97,7 +92,12 @@ const sensitiveCalls = { web3Provider: ['sendAsync'] } +const isInjectedProvicer = (name) => { + return name.startsWith('injected') +} + export function isNative(name) { + // nativePlugin allows to bypass the permission request const nativePlugins = [ 'vyper', @@ -116,19 +116,16 @@ export function isNative(name) { 'ganache-provider', 'foundry-provider', 'basic-http-provider', - 'injected-optimism-provider', 'tabs', - 'injected-arbitrum-one-provider', - 'injected-skale-chaos-testnet-provider', - 'injected-ephemery-testnet-provider', 'doc-gen', 'doc-viewer', 'circuit-compiler', 'compilationDetails', 'vyperCompilationDetails', 'remixGuide', + 'walletconnect' ] - return nativePlugins.includes(name) || requiredModules.includes(name) + return nativePlugins.includes(name) || requiredModules.includes(name) || isInjectedProvicer(name) } /** @@ -162,7 +159,7 @@ export class RemixAppManager extends PluginManager { } async canDeactivatePlugin(from, to) { - if (requiredModules.includes(to.name)) return false + if (this.isRequired(to.name)) return false return isNative(from.name) } @@ -207,7 +204,7 @@ export class RemixAppManager extends PluginManager { ) this.event.emit('activate', plugin) this.emit('activate', plugin) - if (!requiredModules.includes(plugin.name)) _paq.push(['trackEvent', 'pluginManager', 'activate', plugin.name]) + if (!this.isRequired(plugin.name)) _paq.push(['trackEvent', 'pluginManager', 'activate', plugin.name]) } getAll() { @@ -235,7 +232,7 @@ export class RemixAppManager extends PluginManager { isRequired(name) { // excluding internal use plugins - return requiredModules.includes(name) + return requiredModules.includes(name) || isInjectedProvicer(name) } async registeredPlugins() { diff --git a/libs/remix-ui/run-tab/src/lib/components/account.tsx b/libs/remix-ui/run-tab/src/lib/components/account.tsx index 5abd3a277a..21b0d67db4 100644 --- a/libs/remix-ui/run-tab/src/lib/components/account.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/account.tsx @@ -33,61 +33,61 @@ export function AccountUI(props: AccountProps) { }) } else { switch (selectExEnv) { - case 'vm-cancun': - setPlusOpt({ - classList: '', - title: intl.formatMessage({id: 'udapp.createNewAccount'}) - }) - break + case 'vm-cancun': + setPlusOpt({ + classList: '', + title: intl.formatMessage({id: 'udapp.createNewAccount'}) + }) + break - case 'vm-paris': - setPlusOpt({ - classList: '', - title: intl.formatMessage({id: 'udapp.createNewAccount'}) - }) - break + case 'vm-paris': + setPlusOpt({ + classList: '', + title: intl.formatMessage({id: 'udapp.createNewAccount'}) + }) + break - case 'vm-london': - setPlusOpt({ - classList: '', - title: intl.formatMessage({id: 'udapp.createNewAccount'}) - }) - break + case 'vm-london': + setPlusOpt({ + classList: '', + title: intl.formatMessage({id: 'udapp.createNewAccount'}) + }) + break - case 'vm-berlin': + case 'vm-berlin': + setPlusOpt({ + classList: '', + title: intl.formatMessage({id: 'udapp.createNewAccount'}) + }) + break + + case 'vm-shanghai': + setPlusOpt({ + classList: '', + title: intl.formatMessage({id: 'udapp.createNewAccount'}) + }) + break + + case 'web3': + if (!personalMode) { setPlusOpt({ - classList: '', - title: intl.formatMessage({id: 'udapp.createNewAccount'}) + classList: 'disableMouseEvents', + title: intl.formatMessage({id: 'udapp.web3Title'}) }) - break - - case 'vm-shanghai': + } else { setPlusOpt({ classList: '', title: intl.formatMessage({id: 'udapp.createNewAccount'}) }) - break - - case 'web3': - if (!personalMode) { - setPlusOpt({ - classList: 'disableMouseEvents', - title: intl.formatMessage({id: 'udapp.web3Title'}) - }) - } else { - setPlusOpt({ - classList: '', - title: intl.formatMessage({id: 'udapp.createNewAccount'}) - }) - } - break - - default: - setPlusOpt({ - classList: 'disableMouseEvents', - title: intl.formatMessage({id: 'udapp.defaultTitle'}, {selectExEnv}) - }) } + break + + default: + setPlusOpt({ + classList: 'disableMouseEvents', + title: intl.formatMessage({id: 'udapp.defaultTitle'}, {selectExEnv}) + }) + } } }, [selectExEnv, personalMode])