From 7ad843214ffca2d32104c1ad1564be6df4799287 Mon Sep 17 00:00:00 2001 From: puneetmahajan Date: Fri, 5 Apr 2024 14:07:09 +0400 Subject: [PATCH] add checks for nil handlers. --- x/liquidstake/keeper/liquidstake.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index 8053282b..9d22da3f 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -221,6 +221,9 @@ func (k Keeper) DelegateWithCap( Amount: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), bondAmt), } handler := k.router.Handler(msgDelegate) + if handler == nil { + return sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(msgDelegate)) + } res, err := handler(ctx, msgDelegate) if err != nil { k.Logger(ctx).Error("failed to execute delegate msg,", "msg", msgDelegate.String(), "err", err) @@ -803,6 +806,13 @@ func (k Keeper) WithdrawLiquidRewards(ctx sdk.Context, proxyAcc sdk.AccAddress) // run the message handler handler := k.router.Handler(msgWithdraw) + if handler == nil { + k.Logger(ctx).Error( + "unrecognized message route", + "msgRoute", sdk.MsgTypeURL(msgWithdraw), + ) + return true + } res, err := handler(ctx, msgWithdraw) if err != nil { k.Logger(ctx).Error(