Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better handle of the revert raison of a call (issue #4454) #5962

Closed
wants to merge 7 commits into from

Conversation

nicos99
Copy link
Contributor

@nicos99 nicos99 commented Mar 27, 2023

Description

Improvement of web3-core-method.buildCall.sendTxCallback(err, result) to manage various object data structures when looking for the revert reason info got from some providers like MetaMask. See this comment to know what err.data looks like in MetaMask.

Fixes #4454. I am aware that this is not realy a bug of web3 and that the problem should be corrected at the source, however as the error generated breaks the promise system (uncaught exception) and that this was well handled until version 1.2.9, I considers that it is necessary to adapt the code to better strengthen the library.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist for 1.x:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:cov and my test cases cover all the lines and branches of the added code.
  • I ran npm run build with success.
  • I have tested the built dist/web3.min.js in a browser.
  • I have tested my code on the live network.
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.

@coveralls
Copy link

coveralls commented Mar 27, 2023

Pull Request Test Coverage Report for Build 4671156834

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 72.674%

Files with Coverage Reduction New Missed Lines %
packages/web3-core-method/lib/index.js 5 93.97%
Totals Coverage Status
Change from base Build 4667138294: 0.02%
Covered Lines: 3473
Relevant Lines: 4499

💛 - Coveralls

…)' to manage revert embedded error details got from some providers like MetaMask (related to issue web3#4454)
…llback(err, result)' to handle Revert in all cases: use `originalError` sub-object if provided
@luu-alex
Copy link
Contributor

luu-alex commented Apr 1, 2023

hey @nicos99 thank you for the PR. as well can you update the changelog that notes your change?

@nicos99
Copy link
Contributor Author

nicos99 commented Apr 2, 2023

Hello @luu-alex

hey @nicos99 thank you for the PR. as well can you update the changelog that notes your change?

I updated the file the moment I opened the PR. Now there's a conflict with the 1.x branch but I thought I'd fix it once I got some feedback. I have to do this now?

@luu-alex
Copy link
Contributor

luu-alex commented Apr 2, 2023

My only feedback would be @nicos99 can you also include a reference/link to what err.data looks like in metamask? other than that I dont see any other concern in this PR, other than u needing to fix the conflicting file

@nicos99
Copy link
Contributor Author

nicos99 commented Apr 3, 2023

My only feedback would be @nicos99 can you also include a reference/link to what err.data looks like in metamask? other than that I dont see any other concern in this PR, other than u needing to fix the conflicting file

@luu-alex I put two screenshots inside the issue #4454 when I open the PR. I've juste updated the PR description to add a link to (See this comment to know what err.data looks like in MetaMask.).

@Muhammad-Altabba Muhammad-Altabba added the 1.x 1.0 related issues label Apr 3, 2023
(resolved Conflicts for CHANGELOG.md)
@nicos99
Copy link
Contributor Author

nicos99 commented Apr 5, 2023 via email

…sendTxCallback(err, result)' to better manage revert call reason from some providers like MetaMask (related to issue web3#4454)
@nicos99 nicos99 requested a review from jdevcs April 8, 2023 21:33
test/eth.call.revert.js Outdated Show resolved Hide resolved
@nicos99 nicos99 requested a review from avkos April 10, 2023 19:39
@jdevcs
Copy link
Contributor

jdevcs commented Apr 11, 2023

@nicos99 There is need to fix conflicting files Thanks

…ert-call-from-metamask

(resoled Conflict with 'CHANGELOG.md' and 'packages/web3-core-method/src/index.js' caused last PR on the same bug)
@nicos99
Copy link
Contributor Author

nicos99 commented Apr 11, 2023

@Muhammad-Altabba I'm sorry to have canceled your work (PR #6000) but I've been working on the resolution for a long time, which integrates 2 scenarios and adds Unit Tests

@nicos99
Copy link
Contributor Author

nicos99 commented Apr 11, 2023

There is need to fix conflicting files Thanks

@jdevcs, ok, conflict solved. Can you please merge the PR for me now? (I do not have write access)

Copy link
Contributor

@Muhammad-Altabba Muhammad-Altabba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your contribution

@nicos99
Copy link
Contributor Author

nicos99 commented Apr 12, 2023

Many thanks for your contribution

@Muhammad-Altabba, you're welcome! Now can you or someone else complete the PR please? ( Maybe @avkos or @nikoulai ?)

@luu-alex luu-alex mentioned this pull request Apr 13, 2023
31 tasks
@luu-alex
Copy link
Contributor

Merged #6009 Thank you @nicos99

@luu-alex luu-alex closed this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Uncaught TypeError: o.data.substring is not a function" calling a contract function reverting
7 participants