sui
sui copied to clipboard
[Question] Need object version check before executing transactions through SDK?
Steps to Reproduce Issue
Now SDK supports some types of transactions about objects, but it seems there is a lack of object version checks which could bring unexpected transaction execution. https://github.com/MystenLabs/sui/blob/bd5724fec26cda5ba29a4cb8af45bbb447369a0e/sdk/typescript/src/signers/txn-data-serializers/txn-data-serializer.ts#L15-L41
Given the current composition of APIs, let's say if a user wants to transfer an amount of SUI to another user through a wallet, the wallet would get coin objects, and merge or split them until getting an object with the expected amount of SUI and transfer it to the target user. But before the transfer success, an object was merged into the transferred object, so the amount of SUI of the object was increased, then at the end, the user transferred more SUI than he expected.
So IMO we need a mechanism like checking the version of objects to avoid such unexpected transaction execution.
@5kbpers Thanks for flagging, about the payment issue, there is a pending PR here https://github.com/MystenLabs/sui/pull/4452 that will solve this problem by wrapping all merging, splitting and transfer into one txn and hide the impl. under the hood.
Not having version number from default txn construction saves complexities and version-number-read-roundtrip. I can look into adding this check as an option, do you have other use cases that would be benefited from this check?
@gegaowp Very excited to see the amazing work of #4452.
BTW I think the version check would still be useful and a great way to get atomicity of operations for an object in the future, but this issue is not an emergency to me after we got #4452, really appreciate it.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.