fuels-ts
fuels-ts copied to clipboard
Improve `empty` type for ABI Coder and Typegen
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.
Blocked by the ongoing work around v1 encoding, which is spread across multiple issues and PRs:
- #2050
- #2109
This is linked to #2532