Skip to content

Commit

Permalink
add checks for nil handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
puneet2019 committed Apr 5, 2024
1 parent ccee3e6 commit 7ad8432
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions x/liquidstake/keeper/liquidstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7ad8432

Please sign in to comment.