From cfa6663709d0fce6a31c35fab7c85ed30d78a9e5 Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Fri, 29 Oct 2021 15:02:02 +0900 Subject: [PATCH] fix: panic instead of ignoring errors an error returned from `BankKeeper.SendCoins` shouldn't be just silently ignored. similarly, errors from `sdk.AccAddressFromBech32` shouldn't be ignored since that means the state is somehow corrupted. --- x/budget/keeper/budget.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/budget/keeper/budget.go b/x/budget/keeper/budget.go index ebffbe6..9ba1f3d 100644 --- a/x/budget/keeper/budget.go +++ b/x/budget/keeper/budget.go @@ -21,7 +21,7 @@ func (k Keeper) CollectBudgets(ctx sdk.Context) error { for budgetSource, budgetsBySource := range budgetsBySourceMap { budgetSourceAcc, err := sdk.AccAddressFromBech32(budgetSource) if err != nil { - continue + return err } budgetSourceBalances := sdk.NewDecCoinsFromCoins(k.bankKeeper.GetAllBalances(ctx, budgetSourceAcc)...) if budgetSourceBalances.IsZero() { @@ -34,7 +34,7 @@ func (k Keeper) CollectBudgets(ctx sdk.Context) error { for i, budget := range budgetsBySource.Budgets { collectionAcc, err := sdk.AccAddressFromBech32(budget.CollectionAddress) if err != nil { - continue + return err } collectionCoins, _ := budgetSourceBalances.MulDecTruncate(budget.Rate).TruncateDecimal() @@ -48,7 +48,7 @@ func (k Keeper) CollectBudgets(ctx sdk.Context) error { } if err := k.bankKeeper.InputOutputCoins(ctx, inputs, outputs); err != nil { - continue + return err } for i, budget := range budgetsBySource.Budgets { k.AddTotalCollectedCoins(ctx, budget.Name, budgetsBySource.CollectionCoins[i])