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

Implement structs and enums from type: contract Fuel spec #18

Closed
QuinnLee opened this issue Oct 7, 2021 · 1 comment · Fixed by #221
Closed

Implement structs and enums from type: contract Fuel spec #18

QuinnLee opened this issue Oct 7, 2021 · 1 comment · Fixed by #221
Assignees
Labels
feat Issue is a feature

Comments

@QuinnLee
Copy link
Contributor

QuinnLee commented Oct 7, 2021

Currently, function is only one supported.

With more custom data types, abi of type contract with struct definitions will be added. https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/abi.md#json-abi-format

Implement contract type

@luizstacio
Copy link
Member

Doing swayswap-demo has been a pain point as the returns are not strong typed but instead returning a any type. It's true for ContractId, Address, and custom structures.

Use case;

Contract ABI

fn withdraw(amount: u64, asset_id: ContractId);

Types definition from the typechain

withdraw(
      amount: BigNumberish,
      asset_id: any,
      overrides?: Overrides & { from?: string | Promise<string> }
): Promise<any>;

Typescript implementation

const return = await swayswap.functions.just_return(1, {
      value: REACT_APP_TOKEN_ID
});

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
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants