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

Error: "n.data.substring is not a function", when setting web.eth.handleRevert = true #5999

Closed
1 task done
Muhammad-Altabba opened this issue Apr 10, 2023 · 1 comment · Fixed by #6000
Closed
1 task done
Assignees
Labels
1.x 1.0 related issues Bug Addressing a bug

Comments

@Muhammad-Altabba
Copy link
Contributor

Muhammad-Altabba commented Apr 10, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When setting web.eth.handleRevert = true and calling any Smart Contract method that reverts with an error:
The following error is raised: "n.data.substring is not a function".

Expected Behavior

To return an error that contains the actual error from the Smart Contract.

Steps to Reproduce

The full details are at: #5677 (comment)

Web3.js Version

1.8.2

Environment

No response

Anything Else?

The current version of the Infura provider seems to be updated to put the error inside data.data. And here is what the internal object looks like with Infura:
image

And so we need to update web3.js to handle this. And here is the line that needs to be changed:

reasonData = err.data.substring(10);

And it could be changed to something like:

    reasonData = (err.data.data || err.data).substring(10);
@nicos99
Copy link
Contributor

nicos99 commented Apr 11, 2023

It's basically the same problem as #4454

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 Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants