diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 865a6fd0999..bee7c13d7b2 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -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) | | | + + diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index 5d8e5682200..cc51805d34d 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -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 } @@ -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 } diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 3c3a5aa6690..9da38a20773 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -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() @@ -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, ) @@ -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 @@ -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 } } @@ -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 { @@ -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( @@ -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() { @@ -178,7 +178,7 @@ func (k Keeper) SendTransfer( ) }() - return nil + return sequence, nil } // OnRecvPacket processes a cross chain fungible token transfer. If the diff --git a/modules/apps/transfer/types/tx.pb.go b/modules/apps/transfer/types/tx.pb.go index f240ba7368e..b8b848b24d9 100644 --- a/modules/apps/transfer/types/tx.pb.go +++ b/modules/apps/transfer/types/tx.pb.go @@ -87,6 +87,7 @@ var xxx_messageInfo_MsgTransfer proto.InternalMessageInfo // MsgTransferResponse defines the Msg/Transfer response type. type MsgTransferResponse struct { + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (m *MsgTransferResponse) Reset() { *m = MsgTransferResponse{} } @@ -122,6 +123,13 @@ func (m *MsgTransferResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgTransferResponse proto.InternalMessageInfo +func (m *MsgTransferResponse) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + func init() { proto.RegisterType((*MsgTransfer)(nil), "ibc.applications.transfer.v1.MsgTransfer") proto.RegisterType((*MsgTransferResponse)(nil), "ibc.applications.transfer.v1.MsgTransferResponse") @@ -132,38 +140,39 @@ func init() { } var fileDescriptor_7401ed9bed2f8e09 = []byte{ - // 494 bytes of a gzipped FileDescriptorProto + // 506 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x6d, 0x92, 0x86, 0x70, 0x51, 0x2b, 0x30, 0xb4, 0x72, 0xa3, 0x62, 0x47, 0x96, 0x90, - 0xc2, 0xc0, 0x9d, 0xdc, 0x0a, 0x55, 0xea, 0x84, 0xd2, 0x05, 0x86, 0x4a, 0x60, 0x75, 0x62, 0x29, - 0xf6, 0xf5, 0x70, 0x4e, 0xc4, 0xf7, 0xac, 0xbb, 0x8b, 0x45, 0xbf, 0x01, 0x23, 0x1f, 0xa1, 0x33, - 0x9f, 0xa4, 0x63, 0x47, 0xa6, 0x08, 0x25, 0x0b, 0x73, 0x3e, 0x01, 0x3a, 0xfb, 0x12, 0x92, 0x05, - 0x31, 0xd9, 0xef, 0xfd, 0x7f, 0xef, 0xfe, 0x7a, 0xf7, 0xde, 0xa1, 0x17, 0x3c, 0xa3, 0x24, 0x2d, - 0xcb, 0x09, 0xa7, 0xa9, 0xe6, 0x20, 0x14, 0xd1, 0x32, 0x15, 0xea, 0x33, 0x93, 0xa4, 0x8a, 0x89, - 0xfe, 0x8a, 0x4b, 0x09, 0x1a, 0xbc, 0x23, 0x9e, 0x51, 0xbc, 0x89, 0xe1, 0x15, 0x86, 0xab, 0xb8, - 0xff, 0x2c, 0x87, 0x1c, 0x6a, 0x90, 0x98, 0xbf, 0xa6, 0xa6, 0x1f, 0x50, 0x50, 0x05, 0x28, 0x92, - 0xa5, 0x8a, 0x91, 0x2a, 0xce, 0x98, 0x4e, 0x63, 0x42, 0x81, 0x0b, 0xab, 0x87, 0xc6, 0x9a, 0x82, - 0x64, 0x84, 0x4e, 0x38, 0x13, 0xda, 0x18, 0x36, 0x7f, 0x0d, 0x10, 0xfd, 0x68, 0xa1, 0xde, 0x85, - 0xca, 0x2f, 0xad, 0x93, 0x77, 0x8a, 0x7a, 0x0a, 0xa6, 0x92, 0xb2, 0xab, 0x12, 0xa4, 0xf6, 0xdd, - 0x81, 0x3b, 0x7c, 0x34, 0x3a, 0x58, 0xce, 0x42, 0xef, 0x26, 0x2d, 0x26, 0x67, 0xd1, 0x86, 0x18, - 0x25, 0xa8, 0x89, 0xde, 0x83, 0xd4, 0xde, 0x1b, 0xb4, 0x67, 0x35, 0x3a, 0x4e, 0x85, 0x60, 0x13, - 0xff, 0x41, 0x5d, 0x7b, 0xb8, 0x9c, 0x85, 0xfb, 0x5b, 0xb5, 0x56, 0x8f, 0x92, 0xdd, 0x26, 0x71, - 0xde, 0xc4, 0xde, 0x6b, 0xb4, 0xa3, 0xe1, 0x0b, 0x13, 0x7e, 0x6b, 0xe0, 0x0e, 0x7b, 0xc7, 0x87, - 0xb8, 0xe9, 0x0d, 0x9b, 0xde, 0xb0, 0xed, 0x0d, 0x9f, 0x03, 0x17, 0xa3, 0xf6, 0x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xb6, 0xfb, 0x83, 0x68, 0xb7, 0x49, 0xd4, 0xb4, 0xf3, 0x96, 0x3c, 0x5a, 0x11, 0xe6, 0x57, 0xe9, + 0x38, 0xcb, 0xdd, 0xfb, 0x03, 0x7b, 0xd8, 0x1e, 0x1d, 0x2e, 0x67, 0xbe, 0xbb, 0xfd, 0x27, 0x6b, + 0x24, 0x88, 0x1e, 0x36, 0xb9, 0x8b, 0x55, 0xea, 0xb4, 0xfb, 0xed, 0xc6, 0xb7, 0x7e, 0xdf, 0xf8, + 0x56, 0x10, 0x92, 0xc7, 0x1b, 0xb3, 0x8a, 0x40, 0xe5, 0x28, 0x15, 0x18, 0xa7, 0x0a, 0xbe, 0x4c, + 0x41, 0x72, 0xa8, 0x06, 0xd6, 0x8e, 0xd6, 0xf1, 0x11, 0x92, 0xd6, 0xb9, 0x4a, 0x9d, 0x31, 0xe9, + 0xae, 0x47, 0xfc, 0x82, 0xfe, 0x6b, 0xd1, 0xe8, 0x86, 0x42, 0x3f, 0xfc, 0x6f, 0x74, 0xf5, 0x31, + 0xa3, 0xf7, 0xb7, 0x73, 0xcf, 0xbe, 0x9b, 0x7b, 0xf6, 0xaf, 0xb9, 0x67, 0x7f, 0x5f, 0x78, 0xd6, + 0xdd, 0xc2, 0xb3, 0x7e, 0x2e, 0x3c, 0xeb, 0xc3, 0x49, 0x2a, 0xf4, 0x78, 0x9a, 0x50, 0x8e, 0x19, + 0x6b, 0xd6, 0x56, 0x24, 0xfc, 0x65, 0x8a, 0xac, 0x3c, 0x66, 0x19, 0x5e, 0x4d, 0x27, 0xa0, 0xcc, + 0x33, 0xd9, 0x78, 0x1e, 0xfa, 0x3a, 0x07, 0x95, 0x74, 0xaa, 0x55, 0x3d, 0xfe, 0x13, 0x00, 0x00, + 0xff, 0xff, 0x6a, 0xc3, 0xd3, 0xe1, 0x48, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -344,6 +353,11 @@ func (m *MsgTransferResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Sequence != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -396,6 +410,9 @@ func (m *MsgTransferResponse) Size() (n int) { } var l int _ = l + if m.Sequence != 0 { + n += 1 + sovTx(uint64(m.Sequence)) + } return n } @@ -697,6 +714,25 @@ func (m *MsgTransferResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgTransferResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/proto/ibc/applications/transfer/v1/tx.proto b/proto/ibc/applications/transfer/v1/tx.proto index 8f1392b0cf3..52f7f87e017 100644 --- a/proto/ibc/applications/transfer/v1/tx.proto +++ b/proto/ibc/applications/transfer/v1/tx.proto @@ -41,4 +41,6 @@ message MsgTransfer { } // MsgTransferResponse defines the Msg/Transfer response type. -message MsgTransferResponse {} +message MsgTransferResponse { + uint64 sequence = 1; +}