huff-rs icon indicating copy to clipboard operation
huff-rs copied to clipboard

Add support for structs in huff interface definition

Open AmadiMichael opened this issue 2 years ago • 0 comments

Currently huffc does not compile when functions with struct parameters are in the interface definition, this means that anyone looking to use huff and uses functions with struct args will have to manually calculate function sigs themselves since __FUNC_SIG(funcName) won't be possible.

e.g Take this solidity function

struct Info{
  string name;
  uint256 age;
}

function storeInfo(Info calldata info) external {
  ... do something
}

And in huff

/// INTERFACES
#define function storeInfo((string name, uint256 age)) nonpayable returns()

#define macro MAIN() = {
  0x00 calldataload 0xe0 shr
  dup1 __FUNC_SIG(storeInfo) eq STORE_INFO_IMPL jumpi
  0x00 0x00 revert

  STORE_INFO_IMPL:
              ... do something
}

Something like the above won't compile in huff and the dev would have to do this in chisel manually bytes4(keccak256("storeInfo((string,uint256))")).

AmadiMichael avatar Oct 04 '23 14:10 AmadiMichael