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

The error from solidity contract is hex encoded, we should parse it to human-readable string format #274

Closed
ashuralyk opened this issue Jul 30, 2023 · 2 comments · Fixed by #390
Assignees
Labels

Comments

@ashuralyk
Copy link
Contributor

ashuralyk commented Jul 30, 2023

PR for referennce

@wenyuanhust
Copy link
Contributor

wenyuanhust commented Nov 27, 2023

The current contract error message got from forcerelay:

0: Contract call reverted with data: 0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c74657374206661696c656420746f2063726561746520636c69656e7400000000

The original test error in solidity:

    require(false, "test failed to create client");

We should convert the above into the below.

This is the doc describing above bytes infos
https://docs.soliditylang.org/en/latest/control-structures.html#revert

Now it can be converted into this form:

"test failed to create client"

@wenyuanhust
Copy link
Contributor

wenyuanhust commented Dec 1, 2023

In hardhat, error messages are handled by getMessageFromLastStackTraceEntry manually. Looks like no existing library is available.

https://docs.rs/ethers/latest/ethers/middleware/contract/enum.ContractError.html#method.decode_revert
https://docs.rs/ethers/latest/ethers/middleware/contract/trait.EthError.html#method.decode_with_selector
only works for Revert, not for panic. although it will make the parse of revert errors more concise, but will make the overall code a little bit more complicated.
So I used the old method to parse hex-encoded error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants