Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve empty type for ABI Coder and Typegen #2148

Closed
nedsalk opened this issue Apr 23, 2024 · 2 comments · Fixed by #2777
Closed

Improve empty type for ABI Coder and Typegen #2148

nedsalk opened this issue Apr 23, 2024 · 2 comments · Fixed by #2777
Assignees
Labels
feat Issue is a feature

Comments

@nedsalk
Copy link
Contributor

nedsalk commented Apr 23, 2024

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:

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 nedsalk added feat Issue is a feature blocked labels Apr 23, 2024
@nedsalk
Copy link
Contributor Author

nedsalk commented Apr 23, 2024

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

@arboleya arboleya changed the title Improve typegen for empty types Improve empty types for ABI Coder and Typegen Apr 23, 2024
@arboleya arboleya changed the title Improve empty types for ABI Coder and Typegen Improve empty type for ABI Coder and Typegen Apr 23, 2024
@arboleya arboleya added p1 and removed blocked labels Jun 9, 2024
@arboleya arboleya added this to the 0.x post-launch milestone Jun 12, 2024
@danielbate
Copy link
Contributor

This is linked to #2532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants