This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
better handle of the revert raison of a call (issue #4454) #5962
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5e2cc19
improvement of 'web3-core-method.buildCall.sendTxCallback(err, result…
nicos99 687b8d6
continuation of previous work on 'web3-core-method.buildCall.sendTxCa…
nicos99 6e9dce5
add fixed #4454 in the CHANGELOG
nicos99 964577c
Merge 1.x into manage-revert-call-from-metamask
nicos99 7464687
add unit test to cover my improvement of 'web3-core-method.buildCall.…
nicos99 2877e11
removal of unnecessary debug logs
nicos99 fd28ba8
Merge remote-tracking branch 'remotes/origin/develop' into manage-rev…
nicos99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| var chai = require('chai'); | ||
| var assert = chai.assert; | ||
| var FakeIpcProvider = require('./helpers/FakeIpcProvider'); | ||
| var Web3 = require('../packages/web3'); | ||
|
|
||
| describe('call revert', function () { | ||
| var provider; | ||
| var web3; | ||
|
|
||
| beforeEach(function () { | ||
| provider = new FakeIpcProvider(); | ||
| web3 = new Web3(provider); | ||
| web3.eth.handleRevert = true; | ||
| }); | ||
|
|
||
| it('Errors with revert reason string through MetaMask', async function() { | ||
| provider.injectRawError({ | ||
| "code": -32603, | ||
| "message": "execution reverted: DeadlineExpired", | ||
| "data": { | ||
| "originalError": { | ||
| "code": 3, | ||
| "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f446561646c696e65457870697265640000000000000000000000000000000000", | ||
| "message": "execution reverted: DeadlineExpired" | ||
| } | ||
| } | ||
| }); | ||
| provider.injectValidation(function (payload) { | ||
| assert.equal(payload.jsonrpc, '2.0'); | ||
| assert.equal(payload.method, 'eth_call'); | ||
| assert.deepEqual( | ||
| payload.params, | ||
| [{ | ||
| to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', | ||
| data: '0x23455654', | ||
| gas: '0xb', | ||
| gasPrice: '0xb' | ||
| }, 'latest'] | ||
| ); | ||
| }); | ||
|
|
||
| var options = { | ||
| to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', | ||
| data: '0x23455654', | ||
| gas: 11, | ||
| gasPrice: 11 | ||
| }; | ||
|
|
||
| try { | ||
| await web3.eth.call(options, 'latest'); | ||
| assert.fail('call should have failed!'); | ||
| } catch (error) { | ||
| assert.equal(error.reason, 'DeadlineExpired'); | ||
| } | ||
| }); | ||
|
|
||
| it('Errors with revert reason string from Ganache through MetaMask', async function() { | ||
| provider.injectRawError({ | ||
| "code": -32603, | ||
| "message": "Internal JSON-RPC error.", | ||
| "data": { | ||
| "message": "VM Exception while processing transaction: revert ImproperState", | ||
| "stack": "CallError: VM Exception while processing transaction: revert ImproperState\n at Blockchain.simulateTransaction (C:\\Users\\nicos\\AppData\\Roaming\\npm\\node_modules\\ganache\\dist\\node\\1.js:2:82786)", | ||
| "code": -32000, | ||
| "name": "CallError", | ||
| "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d496d70726f706572537461746500000000000000000000000000000000000000" | ||
| } | ||
| }); | ||
| provider.injectValidation(function (payload) { | ||
| assert.equal(payload.jsonrpc, '2.0'); | ||
| assert.equal(payload.method, 'eth_call'); | ||
| assert.deepEqual( | ||
| payload.params, | ||
| [{ | ||
| to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', | ||
| data: '0x23455654', | ||
| gas: '0xb', | ||
| gasPrice: '0xb' | ||
| }, 'latest'] | ||
| ); | ||
| }); | ||
|
|
||
| var options = { | ||
| to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', | ||
| data: '0x23455654', | ||
| gas: 11, | ||
| gasPrice: 11 | ||
| }; | ||
|
|
||
| try { | ||
| await web3.eth.call(options, 'latest'); | ||
| assert.fail('call should have failed!'); | ||
| } catch (error) { | ||
| assert.equal(error.reason, 'ImproperState'); | ||
| } | ||
| }); | ||
|
|
||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.