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
and I found out that the reason is the _format_single function :
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':
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)
Environment information
brownie
Version: v1.19.3What 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
and I found out that the reason is the
_format_single
function :when the type is string ,it will call
to_string(value)
, and in theto_string
function , it will try to unhex the value ,if it is start with a '0x':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 callingto_string(value)