From a24dc7029618e046d66b2af2028925cca7ba6338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=C3=B4ng=20Li=E1=BB=81u?= <93205232+DongLieu@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:23:09 +0700 Subject: [PATCH] change minor logic for SetAccountBalanceForDenom in interchainstaking (#669) Co-authored-by: Nguyen Thanh Nhan --- x/interchainstaking/keeper/zones.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/x/interchainstaking/keeper/zones.go b/x/interchainstaking/keeper/zones.go index 220b1808c..a10dc14da 100644 --- a/x/interchainstaking/keeper/zones.go +++ b/x/interchainstaking/keeper/zones.go @@ -265,7 +265,16 @@ func (k *Keeper) SetAccountBalanceForDenom(ctx sdk.Context, zone *types.Zone, ad } k.Logger(ctx).Info("Matched withdrawal address", "address", address, "wg", zone.WithdrawalAddress.BalanceWaitgroup, "balance", zone.WithdrawalAddress.Balance) case zone.PerformanceAddress != nil && address == zone.PerformanceAddress.Address: - k.Logger(ctx).Info("Matched performance address") + existing := zone.PerformanceAddress.Balance.AmountOf(coin.Denom) + err = zone.PerformanceAddress.SetBalance(zone.PerformanceAddress.Balance.Sub(sdk.NewCoins(sdk.NewCoin(coin.Denom, existing))...).Add(coin)) // reset this denom + if err != nil { + return err + } + err = zone.PerformanceAddress.DecrementBalanceWaitgroup() + if err != nil { + return err + } + k.Logger(ctx).Info("Matched performance address", "address", address, "wg", zone.PerformanceAddress.BalanceWaitgroup, "balance", zone.PerformanceAddress.Balance) default: panic("unexpected") }