Skip to content

Commit

Permalink
add force finish unbonding
Browse files Browse the repository at this point in the history
  • Loading branch information
sontrinh16 committed Jul 17, 2024
1 parent 4f7eded commit a71a1eb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/upgrades/v1.1.5/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func CreateUpgradeHandler(
// unbond all delegations from account
forceUnbondTokens(ctx, addr, bk, sk)

forceFinishUnbonding(ctx, addr, bk, sk)

// send to dao module account
// vesting account should be able to send coins normaly after
// we converted it back to a base account
Expand All @@ -60,6 +62,25 @@ func CreateUpgradeHandler(
}
}

func forceFinishUnbonding(ctx sdk.Context, delAddr string, bk *bankkeeper.BaseKeeper, sk *stakingkeeper.Keeper) error {
ubdQueue := sk.GetAllUnbondingDelegations(ctx, sdk.AccAddress(delAddr))
bondDenom := sk.BondDenom(ctx)
for _, ubd := range ubdQueue {
for _, entry := range ubd.Entries {
err := bk.UndelegateCoinsFromModuleToAccount(ctx, stakingtypes.NotBondedPoolName, sdk.AccAddress(delAddr), sdk.NewCoins(sdk.NewCoin(bondDenom, entry.Balance)))
if err != nil {
return err
}
}

// empty out all entries
ubd.Entries = []stakingtypes.UnbondingDelegationEntry{}
sk.SetUnbondingDelegation(ctx, ubd)
}

return nil
}

func forceUnbondTokens(ctx sdk.Context, delAddr string, bk *bankkeeper.BaseKeeper, sk *stakingkeeper.Keeper) error {
delAccAddr := sdk.AccAddress(delAddr)
dels := sk.GetDelegatorDelegations(ctx, delAccAddr, 100)
Expand Down

0 comments on commit a71a1eb

Please sign in to comment.