Skip to content

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

@kejaly

Description

@kejaly

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions