-
Notifications
You must be signed in to change notification settings - Fork 601
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
ensure account of native token keeps alive after charge fee #1204
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to have some tests
let native_is_enough = <T as Config>::Currency::free_balance(who) | ||
.checked_sub(&fee_and_alive_gap) | ||
.map_or(false, |new_free_balance| { | ||
<T as Config>::Currency::ensure_can_withdraw(who, fee, reason, new_free_balance).is_ok() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<T as Config>::Currency::ensure_can_withdraw(who, fee, reason, new_free_balance).is_ok() | |
<T as Config>::Currency::ensure_can_withdraw(who, fee, reason, fee_and_alive_gap).is_ok() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xlc The old code seems to be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the last parameter is expected new balance after withdraw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we removed the last parameter
* origin/master: update orml (#1206) ensure account of native token keeps alive after charge fee (#1204) bump version (#1205) Update event name mapping (#1203) update call filter to disable sudo and enable transfer & dex (#1202) refactor calculation of initial lp token (#1198) enable unsigned transaction for parachain-system (#1197) Configurable BaseXcmWeight. (#1200) Update release.md Bring back CurrencyIdConvert test. (#1199) refactor some calculation from saturating to checked (#1195) # Conflicts: # orml
charge fee maybe fail even if the account has sufficient tokens for these reasons:
Acala/modules/transaction-payment/src/lib.rs
Line 676 in ae1dba9
Acala/modules/transaction-payment/src/lib.rs
Line 593 in ae1dba9
balances::transfer
will executed when swap native token andtransfer
requires the receiver is alive, otherwise theswap
will fail.So fix
ensure_can_charge_fee
to guarantee account will keep alive.