vyper icon indicating copy to clipboard operation
vyper copied to clipboard

Cannot pass a mere 4-byte signature via '_abi_encode'

Open hedgar2017 opened this issue 2 years ago • 2 comments

Version Information

  • vyper Version (output of vyper --version): 0.3.2
  • OS: linux
  • Python Version (output of python --version): 3.10.2

What's your issue about?

Perhaps, there is no way to pass a mere selector. The way like this does not work as well:

METHOD_ID: constant(Bytes[4]) = b"\x12\x34\x56\x78"

@external
@pure
def f0() -> Bytes[100]:
    return _abi_encode(METHOD_ID, ensure_tuple=False)

this does not work either:

@external
@pure 
def f1() -> Bytes[100]:
    return _abi_encode(method_id=METHOD_ID)

hedgar2017 avatar Apr 08 '22 00:04 hedgar2017

For giggles, can you try METHOD_ID: constant(bytes4) = 0x12345678?

fubuloubu avatar Apr 08 '22 03:04 fubuloubu

meeting notes: _abi_encode must have at least one positional arg. we should document this, and note in the docs that if you just want the 4-byte selector, you can use a constant - e.g. b"\x01\x02\x03\x04" or method_id("foo(uint256)"

charles-cooper avatar Apr 18 '22 20:04 charles-cooper