From 32278b095bf5b862bd2744a8deea4406ca6faa4d Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 24 Oct 2023 11:10:13 +0200 Subject: [PATCH] fix calling a provider from a plugin --- apps/remix-ide/src/app/tabs/web3-provider.js | 10 +++++++--- apps/remix-ide/src/blockchain/blockchain.tsx | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/web3-provider.js b/apps/remix-ide/src/app/tabs/web3-provider.js index 0158ff11f9..5382dd56ce 100644 --- a/apps/remix-ide/src/app/tabs/web3-provider.js +++ b/apps/remix-ide/src/app/tabs/web3-provider.js @@ -27,8 +27,7 @@ export class Web3ProviderModule extends Plugin { async (result) => { if (result) { const provider = this.blockchain.web3().currentProvider - // see https://github.com/ethereum/web3.js/pull/1018/files#diff-d25786686c1053b786cc2626dc6e048675050593c0ebaafbf0814e1996f22022R129 - provider[provider.sendAsync ? 'sendAsync' : 'send'](payload, async (error, message) => { + const resultFn = async (error, message) => { if (error) { // Handle 'The method "debug_traceTransaction" does not exist / is not available.' error if(error.message && error.code && error.code === -32601) { @@ -55,7 +54,12 @@ export class Web3ProviderModule extends Plugin { } } resolve(message) - }) + } + try { + resultFn(null, await provider.sendAsync(payload)) + } catch (e) { + resultFn(e.message) + } } else { reject(new Error('User denied permission')) } diff --git a/apps/remix-ide/src/blockchain/blockchain.tsx b/apps/remix-ide/src/blockchain/blockchain.tsx index f718187206..dbb3eaa77c 100644 --- a/apps/remix-ide/src/blockchain/blockchain.tsx +++ b/apps/remix-ide/src/blockchain/blockchain.tsx @@ -552,7 +552,6 @@ export class Blockchain extends Plugin { } web3() { - // @todo(https://github.com/ethereum/remix-project/issues/431) const isVM = this.executionContext.isVM() if (isVM) { return (this.providers.vm as VMProvider).web3