Skip to content

Commit

Permalink
Auto claim unstaking (#1010)
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Lau <[email protected]>
  • Loading branch information
AurevoirXavier authored Mar 11, 2023
1 parent 001c526 commit 34db767
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pallet/account-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub mod pallet {

migration::put_storage_value(b"Identity", b"Registrars", &[], rs);
}
if let Some(l) = <Ledgers<T>>::take(&from) {
if let Some(mut l) = <Ledgers<T>>::take(&from) {
if let Some(ds) = <Deposits<T>>::take(&from) {
<pallet_balances::Pallet<T> as Currency<_>>::transfer(
&to,
Expand All @@ -456,7 +456,13 @@ pub mod pallet {
);
}

let now = <frame_system::Pallet<T>>::block_number();

l.unstaking_ring.retain(|(_, t)| t > &now);
l.unstaking_kton.retain(|(_, t)| t > &now);

let staking_pot = darwinia_staking::account_id();

<pallet_balances::Pallet<T> as Currency<_>>::transfer(
&to,
&staking_pot,
Expand All @@ -465,6 +471,7 @@ pub mod pallet {
)?;

let sum = l.staked_kton + l.unstaking_kton.iter().map(|(k, _)| k).sum::<Balance>();

if let Some(amount) = <pallet_assets::Pallet<T>>::maybe_balance(KTON_ID, to) {
if amount >= sum {
<pallet_assets::Pallet<T>>::transfer(
Expand Down

0 comments on commit 34db767

Please sign in to comment.