From b73d491fa491b8f3dc042a2b8170f5f10061e3bd Mon Sep 17 00:00:00 2001 From: puneetmahajan Date: Tue, 10 Dec 2024 18:47:06 +0400 Subject: [PATCH] force withdraw from deposits to unbonding account --- x/liquidstakeibc/keeper/msg_server.go | 8 ++++++++ x/liquidstakeibc/types/keys.go | 1 + x/liquidstakeibc/types/msgs.go | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/x/liquidstakeibc/keeper/msg_server.go b/x/liquidstakeibc/keeper/msg_server.go index 3019efe7..6376058e 100644 --- a/x/liquidstakeibc/keeper/msg_server.go +++ b/x/liquidstakeibc/keeper/msg_server.go @@ -376,6 +376,14 @@ func (k msgServer) UpdateHostChain( if err != nil { return nil, err } + case types.KeyForceTransferDeposits: + amount := k.bankKeeper.GetBalance(ctx, k.GetDepositModuleAccount(ctx).GetAddress(), hc.IBCDenom()) + if amount.IsPositive() { + err := k.bankKeeper.SendCoins(ctx, k.GetDepositModuleAccount(ctx).GetAddress(), k.GetUndelegationModuleAccount(ctx).GetAddress(), sdktypes.NewCoins(amount)) + if err != nil { + return nil, err + } + } default: return nil, fmt.Errorf("invalid or unexpected update key: %s", update.Key) } diff --git a/x/liquidstakeibc/types/keys.go b/x/liquidstakeibc/types/keys.go index d1dde07a..aa898286 100644 --- a/x/liquidstakeibc/types/keys.go +++ b/x/liquidstakeibc/types/keys.go @@ -90,6 +90,7 @@ const ( KeyForceUnbond string = "force_unbond" KeyForceICATransfer string = "force_ica_transfer" KeyForceICATransferRewards string = "force_ica_transfer_rewards" + KeyForceTransferDeposits string = "force_transfer_deposits" ) var ( diff --git a/x/liquidstakeibc/types/msgs.go b/x/liquidstakeibc/types/msgs.go index a4dd4582..e9b6133c 100644 --- a/x/liquidstakeibc/types/msgs.go +++ b/x/liquidstakeibc/types/msgs.go @@ -422,6 +422,11 @@ func (m *MsgUpdateHostChain) ValidateBasic() error { if err != nil { return err } + case KeyForceTransferDeposits: + // expected nothing, "" + if update.Value != "" { + return fmt.Errorf("invalid force transfer deposits, expected \"\" ") + } default: return fmt.Errorf("invalid or unexpected update key: %s", update.Key) }