Open PatrickAlphaC opened 3 years ago
I found it:
def _to_hex(value: Any) -> str:
"""Convert a value to a hexstring"""
if isinstance(value, bytes):
return HexBytes(value).hex()
This is in datatypes.py
. The .hex()
call is defined as:
def hex(self) -> str:
"""
Just like :meth:`bytes.hex`, but prepends "0x"
"""
return "0x" + super().hex()
So it always appends 0x
to the start of the bytes. I think a simple "if "0x" -> just return" would fix this.
Right now, my workaround is as follows:
box = A.deploy(eth_utils.to_bytes(hexstr="0x"), {"from": account})
If I want to deploy something with an empty bytes string. But it seems very unintuitive.
Ahh that is strange.. yeah we should fix this.
Dropping a comment to note that this is still an issue. Spent like 12 hours debugging a signature issue; found that it was a bytes field being given a length of 1.
Environment information
brownie
Version: 1.14.6ganache-cli
Version: Ganache CLI v6.12.2 (ganache-core: 2.13.2)solc
Version: 0.6.7+commit.b8d736ae.Darwin.clangWhat was wrong?
When I work with this exact contract:
In remix, and I start with "0x" as the constructor parameter, when I call
length
I get 0.However, when I deploy this in Brownie with the following:
I get 1
Running the same deployment in hardhat, I get 0:
How can it be fixed?
I'm not sure how this can be fixed yet... I'm still triaging. I'm looking for some way to have a size 0 bytes variable. I am able to do this in hardhat, truffle, and remix.