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

V3.1.1 transfer sequence #2

Open
wants to merge 2 commits into
base: v3.1.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,11 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transf
MsgTransferResponse defines the Msg/Transfer response type.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `sequence` | [uint64](#uint64) | | |





Expand Down
7 changes: 4 additions & 3 deletions modules/apps/transfer/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.
if err != nil {
return nil, err
}
if err := k.SendTransfer(
sequence, err := k.SendTransfer(
ctx, msg.SourcePort, msg.SourceChannel, msg.Token, sender, msg.Receiver, msg.TimeoutHeight, msg.TimeoutTimestamp,
); err != nil {
)
if err != nil {
return nil, err
}

Expand All @@ -40,5 +41,5 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.
),
})

return &types.MsgTransferResponse{}, nil
return &types.MsgTransferResponse{Sequence: sequence}, nil
}
20 changes: 10 additions & 10 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ func (k Keeper) SendTransfer(
receiver string,
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
) error {
) (seq uint64, e error) {

if !k.GetSendEnabled(ctx) {
return types.ErrSendDisabled
return 0, types.ErrSendDisabled
}

sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel)
if !found {
return sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel)
return 0, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel)
}

destinationPort := sourceChannelEnd.GetCounterparty().GetPortID()
Expand All @@ -74,7 +74,7 @@ func (k Keeper) SendTransfer(
// get the next sequence
sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel)
if !found {
return sdkerrors.Wrapf(
return 0, sdkerrors.Wrapf(
channeltypes.ErrSequenceSendNotFound,
"source port: %s, source channel: %s", sourcePort, sourceChannel,
)
Expand All @@ -84,7 +84,7 @@ func (k Keeper) SendTransfer(
// See spec for this logic: https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#packet-relay
channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePort, sourceChannel))
if !ok {
return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
return 0, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
}

// NOTE: denomination and hex hash correctness checked during msg.ValidateBasic
Expand All @@ -97,7 +97,7 @@ func (k Keeper) SendTransfer(
if strings.HasPrefix(token.Denom, "ibc/") {
fullDenomPath, err = k.DenomPathFromHash(ctx, token.Denom)
if err != nil {
return err
return 0, err
}
}

Expand All @@ -120,7 +120,7 @@ func (k Keeper) SendTransfer(
if err := k.bankKeeper.SendCoins(
ctx, sender, escrowAddress, sdk.NewCoins(token),
); err != nil {
return err
return 0, err
}

} else {
Expand All @@ -130,7 +130,7 @@ func (k Keeper) SendTransfer(
if err := k.bankKeeper.SendCoinsFromAccountToModule(
ctx, sender, types.ModuleName, sdk.NewCoins(token),
); err != nil {
return err
return 0, err
}

if err := k.bankKeeper.BurnCoins(
Expand Down Expand Up @@ -159,7 +159,7 @@ func (k Keeper) SendTransfer(
)

if err := k.ics4Wrapper.SendPacket(ctx, channelCap, packet); err != nil {
return err
return 0, err
}

defer func() {
Expand All @@ -178,7 +178,7 @@ func (k Keeper) SendTransfer(
)
}()

return nil
return sequence, nil
}

// OnRecvPacket processes a cross chain fungible token transfer. If the
Expand Down
98 changes: 67 additions & 31 deletions modules/apps/transfer/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion proto/ibc/applications/transfer/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ message MsgTransfer {
}

// MsgTransferResponse defines the Msg/Transfer response type.
message MsgTransferResponse {}
message MsgTransferResponse {
uint64 sequence = 1;
}