From fcc37032e3d533450bf6e619b425f86c8bfc9a73 Mon Sep 17 00:00:00 2001 From: puneetmahajan Date: Tue, 17 Dec 2024 16:11:30 +0400 Subject: [PATCH] move funds from unbonded to admin --- x/liquidstakeibc/keeper/msg_server.go | 14 +++++++++++--- x/liquidstakeibc/types/keys.go | 1 + x/liquidstakeibc/types/msgs.go | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/x/liquidstakeibc/keeper/msg_server.go b/x/liquidstakeibc/keeper/msg_server.go index b4bfa895..c734277a 100644 --- a/x/liquidstakeibc/keeper/msg_server.go +++ b/x/liquidstakeibc/keeper/msg_server.go @@ -363,7 +363,7 @@ func (k msgServer) UpdateHostChain( if err != nil { return nil, err } - _, err = k.SendICATransfer(ctx, hc, amount, hc.DelegationAccount.Address, k.GetUndelegationModuleAccount(ctx).GetAddress().String(), hc.DelegationAccount.Owner) + _, err = k.SendICATransfer(ctx, hc, amount, hc.DelegationAccount.Address, k.GetParams(ctx).AdminAddress, hc.DelegationAccount.Owner) if err != nil { return nil, err } @@ -372,14 +372,22 @@ func (k msgServer) UpdateHostChain( if err != nil { return nil, err } - _, err = k.SendICATransfer(ctx, hc, amount, hc.RewardsAccount.Address, k.GetUndelegationModuleAccount(ctx).GetAddress().String(), hc.RewardsAccount.Owner) + _, err = k.SendICATransfer(ctx, hc, amount, hc.RewardsAccount.Address, k.GetParams(ctx).AdminAddress, hc.RewardsAccount.Owner) 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)) + err := k.bankKeeper.SendCoins(ctx, k.GetDepositModuleAccount(ctx).GetAddress(), sdktypes.MustAccAddressFromBech32(k.GetParams(ctx).AdminAddress), sdktypes.NewCoins(amount)) + if err != nil { + return nil, err + } + } + case types.KeyForceTransferUnbonded: + amount := k.bankKeeper.GetBalance(ctx, k.GetUndelegationModuleAccount(ctx).GetAddress(), hc.IBCDenom()) + if amount.IsPositive() { + err := k.bankKeeper.SendCoins(ctx, k.GetUndelegationModuleAccount(ctx).GetAddress(), sdktypes.MustAccAddressFromBech32(k.GetParams(ctx).AdminAddress), sdktypes.NewCoins(amount)) if err != nil { return nil, err } diff --git a/x/liquidstakeibc/types/keys.go b/x/liquidstakeibc/types/keys.go index aa898286..8df73a29 100644 --- a/x/liquidstakeibc/types/keys.go +++ b/x/liquidstakeibc/types/keys.go @@ -91,6 +91,7 @@ const ( KeyForceICATransfer string = "force_ica_transfer" KeyForceICATransferRewards string = "force_ica_transfer_rewards" KeyForceTransferDeposits string = "force_transfer_deposits" + KeyForceTransferUnbonded string = "force_transfer_unbonded" ) var ( diff --git a/x/liquidstakeibc/types/msgs.go b/x/liquidstakeibc/types/msgs.go index 7984dbf9..594f8474 100644 --- a/x/liquidstakeibc/types/msgs.go +++ b/x/liquidstakeibc/types/msgs.go @@ -428,6 +428,11 @@ func (m *MsgUpdateHostChain) ValidateBasic() error { if update.Value != "" { return fmt.Errorf("invalid force transfer deposits, expected \"\" ") } + case KeyForceTransferUnbonded: + // expected nothing, "" + if update.Value != "" { + return fmt.Errorf("invalid force transfer unbonded, expected \"\" ") + } default: return fmt.Errorf("invalid or unexpected update key: %s", update.Key) }