diff --git a/modules/apps/transfer/keeper/export_test.go b/modules/apps/transfer/keeper/export_test.go index cda19c83814..bff6440cf8f 100644 --- a/modules/apps/transfer/keeper/export_test.go +++ b/modules/apps/transfer/keeper/export_test.go @@ -34,12 +34,12 @@ func (k Keeper) TokenFromCoin(ctx sdk.Context, coin sdk.Coin) (types.Token, erro return k.tokenFromCoin(ctx, coin) } -// UnwindHops is a wrapper around unwindToken for testing purposes. +// UnwindHops is a wrapper around unwindHops for testing purposes. func (k Keeper) UnwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgTransfer, error) { return k.unwindHops(ctx, msg) } -// UnwindHops is a wrapper around unwindToken for testing purposes. +// GetForwardedPacket is a wrapper around getForwardedPacket for testing purposes. func (k Keeper) GetForwardedPacket(ctx sdk.Context, portID, channelID string, sequence uint64) (channeltypes.Packet, bool) { return k.getForwardedPacket(ctx, portID, channelID, sequence) } diff --git a/modules/apps/transfer/keeper/forwarding.go b/modules/apps/transfer/keeper/forwarding.go index 29f00714f3e..16cd5d8ae19 100644 --- a/modules/apps/transfer/keeper/forwarding.go +++ b/modules/apps/transfer/keeper/forwarding.go @@ -62,7 +62,7 @@ func (k Keeper) acknowledgeForwardedPacket(ctx sdk.Context, packet, forwardedPac // revertForwardedPacket reverts the logic of receive packet that occurs in the middle chains during a packet forwarding. // If the packet fails to be forwarded all the way to the final destination, the state changes on this chain must be reverted // before sending back the error acknowledgement to ensure atomic packet forwarding. -func (k Keeper) revertForwardedPacket(ctx sdk.Context, prevPacket channeltypes.Packet, failedPacketData types.FungibleTokenPacketDataV2) error { +func (k Keeper) revertForwardedPacket(ctx sdk.Context, forwardedPacket channeltypes.Packet, failedPacketData types.FungibleTokenPacketDataV2) error { /* Recall that RecvPacket handles an incoming packet depending on the denom of the received funds: 1. If the funds are native, then the amount is sent to the receiver from the escrow. @@ -73,9 +73,9 @@ func (k Keeper) revertForwardedPacket(ctx sdk.Context, prevPacket channeltypes.P */ forwardingAddr := k.authKeeper.GetModuleAddress(types.ModuleName) - escrow := types.GetEscrowAddress(prevPacket.DestinationPort, prevPacket.DestinationChannel) + escrow := types.GetEscrowAddress(forwardedPacket.DestinationPort, forwardedPacket.DestinationChannel) - // we can iterate over the received tokens of prevPacket by iterating over the sent tokens of failedPacketData + // we can iterate over the received tokens of forwardedPacket by iterating over the sent tokens of failedPacketData for _, token := range failedPacketData.Tokens { // parse the transfer amount coin, err := token.ToCoin() @@ -85,8 +85,8 @@ func (k Keeper) revertForwardedPacket(ctx sdk.Context, prevPacket channeltypes.P // check if the token we received originated on the sender // given that the packet is being reversed, we check the DestinationChannel and DestinationPort - // of the prevPacket to see if a hop was added to the trace during the receive step - if token.Denom.HasPrefix(prevPacket.DestinationPort, prevPacket.DestinationChannel) { + // of the forwardedPacket to see if a hop was added to the trace during the receive step + if token.Denom.HasPrefix(forwardedPacket.DestinationPort, forwardedPacket.DestinationChannel) { if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil { return err } diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 7166876f139..b14acc95fc3 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -272,14 +272,14 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t // acknowledgement was a success then nothing occurs. If the acknowledgement failed, // then the sender is refunded their tokens using the refundPacketToken function. func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketDataV2, ack channeltypes.Acknowledgement) error { - prevPacket, isForwarded := k.getForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + forwardedPacket, isForwarded := k.getForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) switch ack.Response.(type) { case *channeltypes.Acknowledgement_Result: if isForwarded { - // Write a successful async ack for the prevPacket + // Write a successful async ack for the forwardedPacket forwardAck := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - return k.acknowledgeForwardedPacket(ctx, prevPacket, packet, forwardAck) + return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) } // the acknowledgement succeeded on the receiving chain so nothing @@ -294,12 +294,12 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Pac // the forwarded packet has failed, thus the funds have been refunded to the intermediate address. // we must revert the changes that came from successfully receiving the tokens on our chain // before propagating the error acknowledgement back to original sender chain - if err := k.revertForwardedPacket(ctx, prevPacket, data); err != nil { + if err := k.revertForwardedPacket(ctx, forwardedPacket, data); err != nil { return err } forwardAck := internaltypes.NewForwardErrorAcknowledgement(packet, ack) - return k.acknowledgeForwardedPacket(ctx, prevPacket, packet, forwardAck) + return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) } return nil @@ -316,14 +316,14 @@ func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, dat return err } - prevPacket, isForwarded := k.getForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) + forwardedPacket, isForwarded := k.getForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence) if isForwarded { - if err := k.revertForwardedPacket(ctx, prevPacket, data); err != nil { + if err := k.revertForwardedPacket(ctx, forwardedPacket, data); err != nil { return err } forwardAck := internaltypes.NewForwardTimeoutAcknowledgement(packet) - return k.acknowledgeForwardedPacket(ctx, prevPacket, packet, forwardAck) + return k.acknowledgeForwardedPacket(ctx, forwardedPacket, packet, forwardAck) } return nil