Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: replace continue with if/else #6700

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 30 additions & 33 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,49 +224,46 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t

// Appending token. The new denom has been computed
receivedCoins = append(receivedCoins, coin)
} else {
// sender chain is the source, mint vouchers

// Continue processing rest of tokens in packet data.
continue
}
// since SendPacket did not prefix the denomination, we must add the destination port and channel to the trace
trace := []types.Trace{types.NewTrace(packet.DestinationPort, packet.DestinationChannel)}
token.Denom.Trace = append(trace, token.Denom.Trace...)

// sender chain is the source, mint vouchers
if !k.HasDenom(ctx, token.Denom.Hash()) {
k.SetDenom(ctx, token.Denom)
}

// since SendPacket did not prefix the denomination, we must add the destination port and channel to the trace
trace := []types.Trace{types.NewTrace(packet.DestinationPort, packet.DestinationChannel)}
token.Denom.Trace = append(trace, token.Denom.Trace...)
voucherDenom := token.Denom.IBCDenom()
if !k.bankKeeper.HasDenomMetaData(ctx, voucherDenom) {
k.setDenomMetadata(ctx, token.Denom)
}

if !k.HasDenom(ctx, token.Denom.Hash()) {
k.SetDenom(ctx, token.Denom)
}
events.EmitDenomEvent(ctx, token)

voucherDenom := token.Denom.IBCDenom()
if !k.bankKeeper.HasDenomMetaData(ctx, voucherDenom) {
k.setDenomMetadata(ctx, token.Denom)
}
voucher := sdk.NewCoin(voucherDenom, transferAmount)

events.EmitDenomEvent(ctx, token)
// mint new tokens if the source of the transfer is the same chain
if err := k.bankKeeper.MintCoins(
ctx, types.ModuleName, sdk.NewCoins(voucher),
); err != nil {
return errorsmod.Wrap(err, "failed to mint IBC tokens")
}

voucher := sdk.NewCoin(voucherDenom, transferAmount)
// send to receiver
if err := k.bankKeeper.SendCoinsFromModuleToAccount(
ctx, types.ModuleName, receiver, sdk.NewCoins(voucher),
); err != nil {
return errorsmod.Wrapf(err, "failed to send coins to receiver %s", receiver.String())
}

// mint new tokens if the source of the transfer is the same chain
if err := k.bankKeeper.MintCoins(
ctx, types.ModuleName, sdk.NewCoins(voucher),
); err != nil {
return errorsmod.Wrap(err, "failed to mint IBC tokens")
}
denomPath := token.Denom.Path()
labels = append(labels, telemetry.NewLabel(coretypes.LabelSource, "false"))
defer internaltelemetry.ReportOnRecvPacketTelemetry(transferAmount, denomPath, labels)

// send to receiver
if err := k.bankKeeper.SendCoinsFromModuleToAccount(
ctx, types.ModuleName, receiver, sdk.NewCoins(voucher),
); err != nil {
return errorsmod.Wrapf(err, "failed to send coins to receiver %s", receiver.String())
receivedCoins = append(receivedCoins, voucher)
}

denomPath := token.Denom.Path()
labels = append(labels, telemetry.NewLabel(coretypes.LabelSource, "false"))
defer internaltelemetry.ReportOnRecvPacketTelemetry(transferAmount, denomPath, labels)

receivedCoins = append(receivedCoins, voucher)
}

if data.ShouldBeForwarded() {
Expand Down
Loading