Replies: 4 comments 8 replies
-
💯 Love this! Would suggest keeping the await contract.functions.new_game({ value: contract.id, type: 'ContractId' }); I assume we'll default to an await contract.functions.new_game({ value: contract.address, type: 'Address' }); |
Beta Was this translation helpful? Give feedback.
-
I am lacking proper context here, but ideally, this would be: await contract.functions.new_game(value); This would feel more intuitive and standard (like other usages) since the Sway parameter is a single value: fn new_game(player: Identity); |
Beta Was this translation helpful? Give feedback.
-
Great idea! A solution that'd make the type Identity = {address: string, contractId?: never} | {address?: never; contractId: string}
await contract.functions.new_game({ address: contract.address });
await contract.functions.new_game({ contractId: contract.id }); The |
Beta Was this translation helpful? Give feedback.
-
Thanks, everyone. I created an issue for it: |
Beta Was this translation helpful? Give feedback.
-
Take this Sway function signature for example:
If you try to call this function via the TS SDK, it would look something like this:
It works, but this takes 3-4 attempts to get right and involves some mental gymnastics. I was eventually able to find out how to make this work because I have been working on the SDK for more than a year now. Most new users would find this daunting.
I feel like the API should be simplified to something like:
Any comments & ideas welcome!
Beta Was this translation helpful? Give feedback.
All reactions