From 8e4f966f2461128cd96b7a5c8e0e00aeb92980d1 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 1 Feb 2024 19:56:29 +0100 Subject: [PATCH] imp: return error on default branch of ack type switch statement (#5791) --- modules/apps/transfer/keeper/relay.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 81c5dc954d0..43ff4de572a 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -313,12 +313,14 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t // the sender is refunded their tokens using the refundPacketToken function. func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketData, ack channeltypes.Acknowledgement) error { switch ack.Response.(type) { - case *channeltypes.Acknowledgement_Error: - return k.refundPacketToken(ctx, packet, data) - default: + case *channeltypes.Acknowledgement_Result: // the acknowledgement succeeded on the receiving chain so nothing // needs to be executed and no error needs to be returned return nil + case *channeltypes.Acknowledgement_Error: + return k.refundPacketToken(ctx, packet, data) + default: + return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected one of [%T, %T], got %T", channeltypes.Acknowledgement_Result{}, channeltypes.Acknowledgement_Error{}, ack.Response) } }