From 9326fde4ef345d720ef69ee994cff6ff14ea0c2c Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Jul 2022 15:55:33 +0200 Subject: [PATCH] add toast if injected provider locked --- apps/remix-ide/src/app/tabs/injected-provider.tsx | 1 + apps/remix-ide/src/blockchain/execution-context.js | 1 + 2 files changed, 2 insertions(+) diff --git a/apps/remix-ide/src/app/tabs/injected-provider.tsx b/apps/remix-ide/src/app/tabs/injected-provider.tsx index 77f36f08f5..038919206c 100644 --- a/apps/remix-ide/src/app/tabs/injected-provider.tsx +++ b/apps/remix-ide/src/app/tabs/injected-provider.tsx @@ -31,6 +31,7 @@ export class InjectedProvider extends Plugin { } try { if ((window as any) && typeof (window as any).ethereum.enable === 'function') (window as any).ethereum.enable() + if (!await (window as any).ethereum._metamask.isUnlocked()) this.call('notification', 'toast', 'Please make sure the injected provider is unlocked (e.g Metamask).') await addL2Network(this.chainName, this.chainId, this.rpcUrls) const resultData = await this.provider.currentProvider.send(data.method, data.params) resolve({ jsonrpc: '2.0', result: resultData.result, id: data.id }) diff --git a/apps/remix-ide/src/blockchain/execution-context.js b/apps/remix-ide/src/blockchain/execution-context.js index b04e83d656..10d463d3de 100644 --- a/apps/remix-ide/src/blockchain/execution-context.js +++ b/apps/remix-ide/src/blockchain/execution-context.js @@ -155,6 +155,7 @@ export class ExecutionContext { infoCb('No injected Web3 provider found. Make sure your provider (e.g. MetaMask) is active and running (when recently activated you may have to reload the page).') return cb() } else { + if (!await injected._metamask.isUnlocked()) this.call('notification', 'toast', 'Please make sure the injected provider is unlocked (e.g Metamask).') this.askPermission() this.executionContext = context web3.setProvider(injectedProvider)