From 14c2d03b735f8a20ec27b8d6b9c3d0369df102ef Mon Sep 17 00:00:00 2001 From: Kevin Davis Date: Sat, 8 Oct 2022 20:39:24 -0600 Subject: [PATCH] Tally Handler Fixes (#1342) (#1343) * reassign after addition since values are not modified in place * fix incorrect logic; add bkava when there is no error Co-authored-by: Nick DeLuca --- app/tally_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/tally_handler.go b/app/tally_handler.go index 4e68e73ea1..b24f230aa6 100644 --- a/app/tally_handler.go +++ b/app/tally_handler.go @@ -193,13 +193,13 @@ func (bkavaMap bkavaByDenom) add(coin sdk.Coin) { if !found { bkavaMap[coin.Denom] = sdk.ZeroInt() } - bkavaMap[coin.Denom].Add(coin.Amount) + bkavaMap[coin.Denom] = bkavaMap[coin.Denom].Add(coin.Amount) } func (bkavaMap bkavaByDenom) toCoins() sdk.Coins { coins := sdk.Coins{} for denom, amt := range bkavaMap { - coins.Add(sdk.NewCoin(denom, amt)) + coins = coins.Add(sdk.NewCoin(denom, amt)) } return coins.Sort() } @@ -245,7 +245,7 @@ func (th TallyHandler) addBkavaFromEarn(ctx sdk.Context, addr sdk.AccAddress, bk } for _, share := range shares { if th.lk.IsDerivativeDenom(ctx, share.Denom) { - if coin, err := th.ek.ConvertToAssets(ctx, share); err != nil { + if coin, err := th.ek.ConvertToAssets(ctx, share); err == nil { bkava.add(coin) } }