fuels-ts icon indicating copy to clipboard operation
fuels-ts copied to clipboard

Improve `empty` type for ABI Coder and Typegen

Open nedsalk opened this issue 1 year ago • 1 comments

After merge of #2122, typegen removes empty types from function input arguments, which corresponds to the runtime behavior of the abi-coder, which ignores empty inputs. This led to unexpected function signatures. Based on the abi below,

abi MyContract {
   fn types_value_then_empty(x: u8, y: ()) -> ();
   fn types_value_then_empty_then_value(x: u8, y: (), z: u8) -> ();
}

these are the generated functions (in usage):

contract.functions.empty_then_value(35).call();
contract.functions.value_then_empty_then_value(35, 35).call();
``

This is odd and unexpected and should be like this:
```ts
contract.functions.empty_then_value(null, 35).call();
contract.functions.value_then_empty_then_value(35, null, 35).call();

To implement this, we need to change both the abi-coder to accept null (or undefined, which I prefer) for empty types as well as the typegen to match this new runtime behavior.

nedsalk avatar Apr 23 '24 15:04 nedsalk

Blocked by the ongoing work around v1 encoding, which is spread across multiple issues and PRs:

  • #2050
  • #2109

nedsalk avatar Apr 23 '24 15:04 nedsalk

This is linked to #2532

danielbate avatar Jun 26 '24 12:06 danielbate