Skip to content

Commit

Permalink
fix calling a provider from a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Oct 24, 2023
1 parent 2c3340c commit 32278b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 7 additions & 3 deletions apps/remix-ide/src/app/tabs/web3-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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'))
}
Expand Down
1 change: 0 additions & 1 deletion apps/remix-ide/src/blockchain/blockchain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 32278b0

Please sign in to comment.