-
Notifications
You must be signed in to change notification settings - Fork 78
Description
The wallet-standard intentionally does not expect an instance of Transaction for the Transaction related features. It looks like today, suit passes Transaction instances, which satisfy the wallet-standard at a type-level, but can lead to error prone wallet implementations caused by having multiple instances of the @mysten/sui sdk.
The relevant code is here: https://github.com/suiet/wallet-kit/blob/main/packages/kit/src/components/WalletProvider.tsx#L336-L340
The wallet-provider normalizes a transaction by serializing/re-parsing the transaction, and then passing that instance to the wallet adapter, which in turn will pass it directly to the wallet feature.
The wallet standard expects just an object with an async toJSON method:
The reason for this is to force wallet standard implementations to parse the transaction from json, rather than accepting an instance of a Transaction (similar to the normalizeTransaction method used in the code linked above).
When wallets use transaction instances passed from apps (or wallet-kit) it leads can incompatibilities when they try to build those transactions with clients created by different versions of the @mysten/sui sdk.
The intention is for libraries like wallet-kit to implement something like this: https://github.com/MystenLabs/ts-sdks/blob/main/packages/dapp-kit/src/hooks/wallet/useSignAndExecuteTransaction.ts#L133-L147
This SHOUlD be optional in wallet-kit, and as long as wallets only use the toJSON method, everything would be fine, but it seems like some wallet implementations may be using the provided input as if it were a transaction instance, not just an object with a toJSON method