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 DX for IdentityInput #1891

Open
arboleya opened this issue Mar 19, 2024 Discussed in #1844 · 1 comment
Open

Improve DX for IdentityInput #1891

arboleya opened this issue Mar 19, 2024 Discussed in #1844 · 1 comment
Assignees
Labels

Comments

@arboleya
Copy link
Member

Discussed in #1844

Originally posted by Dhaiwat10 March 7, 2024
Take this Sway function signature for example:

fn new_game(player: Identity);

If you try to call this function via the TS SDK, it would look something like this:

await contract.functions.new_game({ Address: { value: walletAddress });
await contract.functions.new_game({ ContractId: { value: contractId });

The idea is to change it to something like:

type Identity = {address: string, contractId?: never} | {address?: never; contractId: string}

await contract.functions.new_game({ address: walletAddress });
await contract.functions.new_game({ contractId: contractId });
@arboleya arboleya added the feat label Mar 19, 2024
@nedsalk
Copy link
Contributor

nedsalk commented Apr 23, 2024

It seems to me that we can generalize this approach for all enums, not just the Identity one?
For example, this is currently possible:

// call-test-contract
    const { value } = await contract.functions
      .take_b256_enum({ Value: 'qweqwe', Data: 'asds' })
      .call();

But we'd want to only provide Value or Data.

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

No branches or pull requests

2 participants