From f1d01af10a02e2410b3c3bb47fa0fb3dde4388c1 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Tue, 25 Jun 2024 16:44:21 +0200 Subject: [PATCH] chore: comment hop slicing for clarity --- modules/apps/transfer/keeper/forwarding.go | 1 + modules/apps/transfer/keeper/msg_server.go | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/apps/transfer/keeper/forwarding.go b/modules/apps/transfer/keeper/forwarding.go index 1029d6369a8..09dd15ebd9d 100644 --- a/modules/apps/transfer/keeper/forwarding.go +++ b/modules/apps/transfer/keeper/forwarding.go @@ -16,6 +16,7 @@ import ( func (k Keeper) forwardPacket(ctx sdk.Context, data types.FungibleTokenPacketDataV2, packet channeltypes.Packet, receivedCoins sdk.Coins) error { var nextForwardingPath types.Forwarding if len(data.Forwarding.Hops) > 1 { + // remove the first hop since it has been completed (this chain has received the packet) nextForwardingPath = types.NewForwarding(false, data.Forwarding.Hops[1:]...) } diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index 2be27e0f776..55202574157 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -81,6 +81,7 @@ func (k Keeper) unwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgT return nil, errorsmod.Wrap(types.ErrInvalidForwarding, "cannot unwind a native token") } var unwindHops []types.Hop + // remove the first hop in denom as it is the current port/channel on this chain for _, trace := range token.Denom.Trace[1:] { unwindHops = append(unwindHops, types.Hop{PortId: trace.PortId, ChannelId: trace.ChannelId}) //nolint: gosimple }