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

When contracts return a string type starting with '0x' like '0x9e' , brwonie may have an error #1692

Open
kejaly opened this issue May 21, 2023 · 0 comments

Comments

@kejaly
Copy link

kejaly commented May 21, 2023

Environment information

  • brownie Version: v1.19.3

What was wrong?

When Brownie returns a string starting with "0x", it will go to unhex it , which leads to an error if you want to directly return a string starting with "0x", such as "0x9e".

The test code is as follows:
the left is test0x.sol , and the right is test.py

image

and I found out that the reason is the _format_single function :

image

when the type is string ,it will call to_string(value) , and in the to_string function , it will try to unhex the value ,if it is start with a '0x':

image

How can it be fixed

in my opinion, i think since it is already a string type, you can directly return str(value) instead of calling to_string(value)

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

No branches or pull requests

1 participant