sui icon indicating copy to clipboard operation
sui copied to clipboard

implement PaySui and PayAllSui native tx types

Open gegaowp opened this issue 3 years ago • 3 comments

The related issue is https://github.com/MystenLabs/sui/issues/4761

Start a new PR here and will delete https://github.com/MystenLabs/sui/pull/4803 to de-dup.

gegaowp avatar Oct 06 '22 21:10 gegaowp

💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/3201579004#artifacts

github-actions[bot] avatar Oct 06 '22 21:10 github-actions[bot]

@lxfind thanks a lot for the review!

Agreed that I should add integration tests covering both the execution itself and also the gas deduction logic, doing it now!

Another question is in the case of PaySui and PayAllSui, what is the semantics of gas payment? Is the gas always coming out of the first coin in the input, or are we allowed to pay gas collectively using multiple input objects? Say you have 3 coins with balance 50,50,50, and you are calling PayAllSui which costs gas 100. Do you expect this tx to succeed?

it is allowed to take SUI from all input coins, for this example, if it is payAllSui it will succeed; if it is paySui && total amount to pay is < 150 - 100, it will succeed as well; otherwise if paySUI && total amount to pay is > 150 - 100, it will fail.

indeed that I will want to add checks upon txn building to make sure that for paySui, gas_budget + total amount < total coins; same thing for payAllsui.

gegaowp avatar Oct 11 '22 18:10 gegaowp

per discussion with @lxfind and @longbowlu, I made changes in the latest commit:

  • simplify the pay_sui "debit coin and transfer" logic to start with total coins
  • separate the logic of 1) updating the gas coin object and 2) deleting all other input coin objects
  • add extra check in gas.rs to check gas object balance itself is also greater than gas budget * gas price
  • rebase

gegaowp avatar Oct 17 '22 16:10 gegaowp

rebase with changed due to https://github.com/MystenLabs/sui/pull/5491

gegaowp avatar Oct 25 '22 00:10 gegaowp