Skip to content

Commit

Permalink
Merge pull request #807 from persistenceOne/puneet/handle-nil-handlers
Browse files Browse the repository at this point in the history
fix: add checks for nil handlers.
  • Loading branch information
puneet2019 authored Apr 5, 2024
2 parents ccee3e6 + 7ad8432 commit 0cdbfb8
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 0cdbfb8

Please sign in to comment.