From 8adab455f443caaa564d2c15c4948ccface85cc9 Mon Sep 17 00:00:00 2001 From: matthiasmatt Date: Wed, 6 Dec 2023 17:05:01 +0100 Subject: [PATCH] fix: improve error handling --- x/inflation/keeper/inflation.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x/inflation/keeper/inflation.go b/x/inflation/keeper/inflation.go index 9fab1b771..9095960ac 100644 --- a/x/inflation/keeper/inflation.go +++ b/x/inflation/keeper/inflation.go @@ -81,21 +81,23 @@ func (k Keeper) AllocatePolynomialInflation( strategicAccountAddr, err := k.sudoKeeper.GetRoot(ctx) if err != nil { k.Logger(ctx).Error("get root account error", "error", err) - return staking, strategic, community, nil + return staking, strategic, community, err } if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, strategicAccountAddr, sdk.NewCoins(strategic)); err != nil { k.Logger(ctx).Error("send coins to root account error", "error", err) - return sdk.Coin{}, sdk.Coin{}, sdk.Coin{}, nil + return sdk.Coin{}, sdk.Coin{}, sdk.Coin{}, err } - _ = ctx.EventManager().EmitTypedEvents( + if err := ctx.EventManager().EmitTypedEvents( &types.InflationDistributionEvent{ StakingRewards: staking, StrategicReserve: strategic, CommunityPool: community, }, - ) + ); err != nil { + return sdk.Coin{}, sdk.Coin{}, sdk.Coin{}, err + } return staking, strategic, community, nil }