From a9728befea3014321bfd2233d0c0978230531db2 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 26 Oct 2022 16:30:42 +0200 Subject: [PATCH] refactor: adapting transfer metadata bytes field to memo string (backport #2595) (#2599) * refactor: adapting transfer metadata bytes field to memo string (#2595) * adapting transfer metadata bytes field to memo string * updating changelog (cherry picked from commit 05685b3f1bb4241ec04c4768dbb7152273f83a96) # Conflicts: # CHANGELOG.md # modules/apps/29-fee/transfer_test.go # modules/apps/transfer/client/cli/tx.go # modules/apps/transfer/keeper/mbt_relay_test.go # modules/apps/transfer/keeper/msg_server_test.go # modules/apps/transfer/keeper/relay.go # modules/apps/transfer/keeper/relay_test.go # modules/apps/transfer/transfer_test.go # modules/apps/transfer/types/msgs.go # modules/apps/transfer/types/msgs_test.go # modules/apps/transfer/types/packet.go # modules/apps/transfer/types/packet.pb.go # modules/apps/transfer/types/packet_test.go # modules/apps/transfer/types/tx.pb.go * resolving conflicts Co-authored-by: Damian Nolan --- CHANGELOG.md | 2 +- docs/ibc/proto-docs.md | 4 +- modules/apps/transfer/client/cli/tx.go | 8 +- modules/apps/transfer/ibc_module.go | 7 +- modules/apps/transfer/keeper/msg_server.go | 2 +- .../apps/transfer/keeper/msg_server_test.go | 2 +- modules/apps/transfer/keeper/relay.go | 6 +- modules/apps/transfer/keeper/relay_test.go | 16 +-- modules/apps/transfer/types/events.go | 2 +- modules/apps/transfer/types/packet.pb.go | 71 +++++++------- modules/apps/transfer/types/tx.pb.go | 98 +++++++++---------- proto/ibc/applications/transfer/v1/tx.proto | 4 +- .../ibc/applications/transfer/v2/packet.proto | 4 +- 13 files changed, 110 insertions(+), 116 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79808b137d0..252f4e8db1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features -* (apps/transfer) [\#2305](https://github.com/cosmos/ibc-go/pull/2305) Added optional metadata field to `FungibleTokenPacketData` and `MsgTransfer`. +* (apps/transfer) [\#2595](https://github.com/cosmos/ibc-go/pull/2595) Adding optional memo field to `FungibleTokenPacketData` and `MsgTransfer`. ### Bug Fixes diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 3a4a7885361..c7f1b1e9652 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -2146,7 +2146,7 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transf | `receiver` | [string](#string) | | the recipient address on the destination chain | | `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | | `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp in absolute nanoseconds since unix epoch. The timeout is disabled when set to 0. | -| `metadata` | [bytes](#bytes) | | optional metadata | +| `memo` | [string](#string) | | optional memo | @@ -2208,7 +2208,7 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transf | `amount` | [string](#string) | | the token amount to be transferred | | `sender` | [string](#string) | | the sender address | | `receiver` | [string](#string) | | the recipient address on the destination chain | -| `metadata` | [bytes](#bytes) | | optional metadata | +| `memo` | [string](#string) | | optional memo | diff --git a/modules/apps/transfer/client/cli/tx.go b/modules/apps/transfer/client/cli/tx.go index f75af8f1285..614f56f6a66 100644 --- a/modules/apps/transfer/client/cli/tx.go +++ b/modules/apps/transfer/client/cli/tx.go @@ -22,7 +22,7 @@ const ( flagPacketTimeoutHeight = "packet-timeout-height" flagPacketTimeoutTimestamp = "packet-timeout-timestamp" flagAbsoluteTimeouts = "absolute-timeouts" - flagMetadata = "metadata" + flagMemo = "memo" ) // NewTransferTxCmd returns the command to create a NewMsgTransfer transaction @@ -77,7 +77,7 @@ corresponding to the counterparty channel. Any timeout set to 0 is disabled.`), return err } - metadataStr, err := cmd.Flags().GetString(flagMetadata) + memo, err := cmd.Flags().GetString(flagMemo) if err != nil { return err } @@ -119,7 +119,7 @@ corresponding to the counterparty channel. Any timeout set to 0 is disabled.`), msg := types.NewMsgTransfer( srcPort, srcChannel, coin, sender, receiver, timeoutHeight, timeoutTimestamp, ) - msg.Metadata = []byte(metadataStr) + msg.Memo = memo return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, @@ -128,7 +128,7 @@ corresponding to the counterparty channel. Any timeout set to 0 is disabled.`), cmd.Flags().String(flagPacketTimeoutHeight, types.DefaultRelativePacketTimeoutHeight, "Packet timeout block height. The timeout is disabled when set to 0-0.") cmd.Flags().Uint64(flagPacketTimeoutTimestamp, types.DefaultRelativePacketTimeoutTimestamp, "Packet timeout timestamp in nanoseconds from now. Default is 10 minutes. The timeout is disabled when set to 0.") cmd.Flags().Bool(flagAbsoluteTimeouts, false, "Timeout flags are used as absolute timeouts.") - cmd.Flags().String(flagMetadata, "", "Metadata to be sent along with the packet. The CLI accepts only strings here but you can construct a packet with arbitrary bytes via code.") + cmd.Flags().String(flagMemo, "", "Memo to be sent along with the packet.") flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index 1f2bfd1341c..e77495d6b3e 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -1,7 +1,6 @@ package transfer import ( - "encoding/hex" "fmt" "math" "strings" @@ -195,7 +194,7 @@ func (im IBCModule) OnRecvPacket( sdk.NewAttribute(types.AttributeKeyReceiver, data.Receiver), sdk.NewAttribute(types.AttributeKeyDenom, data.Denom), sdk.NewAttribute(types.AttributeKeyAmount, data.Amount), - sdk.NewAttribute(types.AttributeKeyMetadata, hex.EncodeToString(data.Metadata)), + sdk.NewAttribute(types.AttributeKeyMemo, data.Memo), sdk.NewAttribute(types.AttributeKeyAckSuccess, fmt.Sprintf("%t", ack.Success())), } @@ -242,7 +241,7 @@ func (im IBCModule) OnAcknowledgementPacket( sdk.NewAttribute(types.AttributeKeyReceiver, data.Receiver), sdk.NewAttribute(types.AttributeKeyDenom, data.Denom), sdk.NewAttribute(types.AttributeKeyAmount, data.Amount), - sdk.NewAttribute(types.AttributeKeyMetadata, hex.EncodeToString(data.Metadata)), + sdk.NewAttribute(types.AttributeKeyMemo, data.Memo), sdk.NewAttribute(types.AttributeKeyAck, ack.String()), ), ) @@ -289,7 +288,7 @@ func (im IBCModule) OnTimeoutPacket( sdk.NewAttribute(types.AttributeKeyRefundReceiver, data.Sender), sdk.NewAttribute(types.AttributeKeyRefundDenom, data.Denom), sdk.NewAttribute(types.AttributeKeyRefundAmount, data.Amount), - sdk.NewAttribute(types.AttributeKeyMetadata, hex.EncodeToString(data.Metadata)), + sdk.NewAttribute(types.AttributeKeyMemo, data.Memo), ), ) diff --git a/modules/apps/transfer/keeper/msg_server.go b/modules/apps/transfer/keeper/msg_server.go index 9822eaa7caa..adf49544057 100644 --- a/modules/apps/transfer/keeper/msg_server.go +++ b/modules/apps/transfer/keeper/msg_server.go @@ -21,7 +21,7 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. sequence, err := k.sendTransfer( ctx, msg.SourcePort, msg.SourceChannel, msg.Token, sender, msg.Receiver, msg.TimeoutHeight, msg.TimeoutTimestamp, - msg.Metadata) + msg.Memo) if err != nil { return nil, err } diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index 87d7e981a48..71982258e39 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -55,7 +55,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { coin, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.chainB.GetTimeoutHeight(), 0, // only use timeout height ) - msg.Metadata = []byte("custom metadata") + msg.Memo = "memo" tc.malleate() diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 33b8e82a703..e67be0232a7 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -69,7 +69,7 @@ func (k Keeper) SendTransfer( receiver, timeoutHeight, timeoutTimestamp, - nil, + "", ) return err } @@ -84,7 +84,7 @@ func (k Keeper) sendTransfer( receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, - metadata []byte, + memo string, ) (uint64, error) { if !k.GetSendEnabled(ctx) { return 0, types.ErrSendDisabled @@ -177,7 +177,7 @@ func (k Keeper) sendTransfer( packetData := types.NewFungibleTokenPacketData( fullDenomPath, token.Amount.String(), sender.String(), receiver, ) - packetData.Metadata = metadata + packetData.Memo = memo packet := channeltypes.NewPacket( packetData.GetBytes(), diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 6deca12a996..08b1e5f6c94 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -163,7 +163,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { trace types.DenomTrace amount math.Int receiver string - metadata []byte + memo string ) testCases := []struct { @@ -173,12 +173,12 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { expPass bool }{ {"success receive on source chain", func() {}, true, true}, - {"success receive on source chain with metadata", func() { - metadata = []byte("metadata") + {"success receive on source chain with memo", func() { + memo = "memo" }, true, true}, {"success receive with coin from another chain as source", func() {}, false, true}, - {"success receive with coin from another chain as source with metadata", func() { - metadata = []byte("metadata") + {"success receive with coin from another chain as source with memo", func() { + memo = "memo" }, false, true}, {"empty coin", func() { trace = types.DenomTrace{} @@ -220,7 +220,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { suite.coordinator.Setup(path) receiver = suite.chainB.SenderAccount.GetAddress().String() // must be explicitly changed in malleate - metadata = []byte{} // can be explicitly changed in malleate + memo = "" // can be explicitly changed in malleate amount = sdk.NewInt(100) // must be explicitly changed in malleate seq := uint64(1) @@ -247,14 +247,14 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { // send coin from chainA to chainB transferMsg := types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoin(trace.IBCDenom(), amount), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(0, 110), 0) - transferMsg.Metadata = metadata + transferMsg.Memo = memo _, err := suite.chainA.SendMsgs(transferMsg) suite.Require().NoError(err) // message committed tc.malleate() data := types.NewFungibleTokenPacketData(trace.GetFullDenomPath(), amount.String(), suite.chainA.SenderAccount.GetAddress().String(), receiver) - data.Metadata = metadata + data.Memo = memo packet := channeltypes.NewPacket(data.GetBytes(), seq, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(0, 100), 0) err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, data) diff --git a/modules/apps/transfer/types/events.go b/modules/apps/transfer/types/events.go index 5cc87f11797..89964a8a9a4 100644 --- a/modules/apps/transfer/types/events.go +++ b/modules/apps/transfer/types/events.go @@ -18,5 +18,5 @@ const ( AttributeKeyAck = "acknowledgement" AttributeKeyAckError = "error" AttributeKeyTraceHash = "trace_hash" - AttributeKeyMetadata = "metadata" + AttributeKeyMemo = "memo" ) diff --git a/modules/apps/transfer/types/packet.pb.go b/modules/apps/transfer/types/packet.pb.go index 6b94ff2503b..e8beeaf9d6f 100644 --- a/modules/apps/transfer/types/packet.pb.go +++ b/modules/apps/transfer/types/packet.pb.go @@ -34,8 +34,8 @@ type FungibleTokenPacketData struct { Sender string `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"` // the recipient address on the destination chain Receiver string `protobuf:"bytes,4,opt,name=receiver,proto3" json:"receiver,omitempty"` - // optional metadata - Metadata []byte `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` + // optional memo + Memo string `protobuf:"bytes,5,opt,name=memo,proto3" json:"memo,omitempty"` } func (m *FungibleTokenPacketData) Reset() { *m = FungibleTokenPacketData{} } @@ -99,11 +99,11 @@ func (m *FungibleTokenPacketData) GetReceiver() string { return "" } -func (m *FungibleTokenPacketData) GetMetadata() []byte { +func (m *FungibleTokenPacketData) GetMemo() string { if m != nil { - return m.Metadata + return m.Memo } - return nil + return "" } func init() { @@ -115,24 +115,23 @@ func init() { } var fileDescriptor_653ca2ce9a5ca313 = []byte{ - // 259 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4a, 0xc4, 0x40, - 0x10, 0x86, 0xb3, 0xea, 0x1d, 0x1a, 0xac, 0x82, 0x68, 0x10, 0x59, 0x0e, 0xab, 0xb3, 0x30, 0x0b, - 0x27, 0x62, 0x2f, 0x62, 0xad, 0x87, 0x95, 0xdd, 0xee, 0x66, 0x8c, 0xcb, 0x65, 0x77, 0xc2, 0xee, - 0x24, 0xe0, 0x5b, 0xd8, 0xf9, 0x4a, 0x96, 0x57, 0x5a, 0x4a, 0xf2, 0x22, 0x92, 0xc4, 0x3b, 0xae, - 0xfc, 0xbe, 0xf9, 0xa7, 0xf9, 0xe2, 0x2b, 0xa3, 0xb4, 0x90, 0x55, 0x55, 0x1a, 0x2d, 0xc9, 0xa0, - 0x0b, 0x82, 0xbc, 0x74, 0xe1, 0x0d, 0xbc, 0x68, 0x16, 0xa2, 0x92, 0x7a, 0x05, 0x94, 0x55, 0x1e, - 0x09, 0x93, 0x0b, 0xa3, 0x74, 0xb6, 0x3b, 0xcd, 0x36, 0xd3, 0xac, 0x59, 0x5c, 0x7e, 0xb1, 0xf8, - 0xec, 0xb1, 0x76, 0x85, 0x51, 0x25, 0xbc, 0xe0, 0x0a, 0xdc, 0xd3, 0xf0, 0xfb, 0x20, 0x49, 0x26, - 0x27, 0xf1, 0x24, 0x07, 0x87, 0x36, 0x65, 0x33, 0x36, 0x3f, 0x5a, 0x8e, 0x90, 0x9c, 0xc6, 0x53, - 0x69, 0xb1, 0x76, 0x94, 0xee, 0x0d, 0xfa, 0x9f, 0x7a, 0x1f, 0xc0, 0xe5, 0xe0, 0xd3, 0xfd, 0xd1, - 0x8f, 0x94, 0x9c, 0xc7, 0x87, 0x1e, 0x34, 0x98, 0x06, 0x7c, 0x7a, 0x30, 0x5c, 0xb6, 0xdc, 0xdf, - 0x2c, 0x90, 0xcc, 0x25, 0xc9, 0x74, 0x32, 0x63, 0xf3, 0xe3, 0xe5, 0x96, 0xef, 0x9f, 0xbf, 0x5b, - 0xce, 0xd6, 0x2d, 0x67, 0xbf, 0x2d, 0x67, 0x9f, 0x1d, 0x8f, 0xd6, 0x1d, 0x8f, 0x7e, 0x3a, 0x1e, - 0xbd, 0xde, 0x15, 0x86, 0xde, 0x6b, 0x95, 0x69, 0xb4, 0x42, 0x63, 0xb0, 0x18, 0x84, 0x51, 0xfa, - 0xba, 0x40, 0xd1, 0xdc, 0x0a, 0x8b, 0x79, 0x5d, 0x42, 0xe8, 0xe3, 0xec, 0x44, 0xa1, 0x8f, 0x0a, - 0x82, 0x9a, 0x0e, 0x45, 0x6e, 0xfe, 0x02, 0x00, 0x00, 0xff, 0xff, 0x82, 0x54, 0x27, 0x1e, 0x3e, - 0x01, 0x00, 0x00, + // 254 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4a, 0x34, 0x31, + 0x14, 0x46, 0x27, 0xff, 0xbf, 0xbb, 0x68, 0xca, 0x20, 0x3a, 0x88, 0x04, 0xb1, 0xd2, 0xc2, 0x09, + 0xac, 0x88, 0xbd, 0x88, 0xb5, 0x8a, 0x95, 0x5d, 0x92, 0xb9, 0x8e, 0x61, 0x27, 0xb9, 0x21, 0xc9, + 0x0c, 0xf8, 0x14, 0xfa, 0x58, 0x96, 0x5b, 0x5a, 0xca, 0xcc, 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, + 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xd1, 0xc3, 0x04, 0x36, 0x01, 0x00, 0x00, } func (m *FungibleTokenPacketData) Marshal() (dAtA []byte, err error) { @@ -155,10 +154,10 @@ func (m *FungibleTokenPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if len(m.Metadata) > 0 { - i -= len(m.Metadata) - copy(dAtA[i:], m.Metadata) - i = encodeVarintPacket(dAtA, i, uint64(len(m.Metadata))) + if len(m.Memo) > 0 { + i -= len(m.Memo) + copy(dAtA[i:], m.Memo) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Memo))) i-- dAtA[i] = 0x2a } @@ -226,7 +225,7 @@ func (m *FungibleTokenPacketData) Size() (n int) { if l > 0 { n += 1 + l + sovPacket(uint64(l)) } - l = len(m.Metadata) + l = len(m.Memo) if l > 0 { n += 1 + l + sovPacket(uint64(l)) } @@ -398,9 +397,9 @@ func (m *FungibleTokenPacketData) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Memo", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPacket @@ -410,25 +409,23 @@ func (m *FungibleTokenPacketData) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthPacket } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthPacket } if postIndex > l { return io.ErrUnexpectedEOF } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} - } + m.Memo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/modules/apps/transfer/types/tx.pb.go b/modules/apps/transfer/types/tx.pb.go index e4f5c740b87..3c763bedab7 100644 --- a/modules/apps/transfer/types/tx.pb.go +++ b/modules/apps/transfer/types/tx.pb.go @@ -50,8 +50,8 @@ type MsgTransfer struct { // Timeout timestamp in absolute nanoseconds since unix epoch. // The timeout is disabled when set to 0. TimeoutTimestamp uint64 `protobuf:"varint,7,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty" yaml:"timeout_timestamp"` - // optional metadata - Metadata []byte `protobuf:"bytes,8,opt,name=metadata,proto3" json:"metadata,omitempty"` + // optional memo + Memo string `protobuf:"bytes,8,opt,name=memo,proto3" json:"memo,omitempty"` } func (m *MsgTransfer) Reset() { *m = MsgTransfer{} } @@ -143,40 +143,40 @@ func init() { } var fileDescriptor_7401ed9bed2f8e09 = []byte{ - // 521 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, 0xa1, 0x15, 0x18, 0xa8, 0xdc, 0xa8, 0xd8, 0x91, 0x25, 0xa4, - 0x30, 0x70, 0x27, 0x17, 0x55, 0x95, 0x3a, 0xa1, 0x74, 0x81, 0xa1, 0x12, 0x58, 0x9d, 0x58, 0xca, - 0xf9, 0xf2, 0x70, 0x4e, 0xc4, 0x77, 0xc6, 0x77, 0xb1, 0xe8, 0x37, 0x60, 0xe4, 0x23, 0xf4, 0xd3, - 0xa0, 0x8e, 0x1d, 0x99, 0x22, 0x94, 0x2c, 0xcc, 0xf9, 0x04, 0xe8, 0x6c, 0x27, 0x38, 0x0b, 0xea, - 0x94, 0xfb, 0xbf, 0xf7, 0x7b, 0xf9, 0xfb, 0xdd, 0x7b, 0x87, 0x5e, 0xf0, 0x98, 0x11, 0x9a, 0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0x9e, 0xfd, 0x63, 0xe9, 0x59, 0xb7, 0x4b, - 0xcf, 0xfa, 0xb5, 0xf4, 0xac, 0x8f, 0x27, 0x09, 0xd7, 0x93, 0x59, 0x8c, 0x99, 0x4c, 0x49, 0xbd, - 0xd2, 0x3c, 0x66, 0xaf, 0x12, 0x49, 0x8a, 0x63, 0x92, 0xca, 0xf1, 0x6c, 0x0a, 0xca, 0x3c, 0xa1, - 0xc6, 0xd3, 0xd1, 0x57, 0x19, 0xa8, 0xb8, 0x53, 0xae, 0xf1, 0xeb, 0xbf, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xa0, 0x73, 0x9e, 0xaf, 0x64, 0x03, 0x00, 0x00, + // 516 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xb5, 0x49, 0x1a, 0xc2, 0x46, 0xad, 0x60, 0x81, 0xca, 0x8d, 0x8a, 0x1d, 0x59, 0x42, 0x0a, + 0x07, 0x76, 0xe5, 0xa2, 0xaa, 0x52, 0x4f, 0x28, 0xbd, 0xc0, 0xa1, 0x12, 0x58, 0x3d, 0x71, 0x29, + 0xf6, 0x76, 0x70, 0x56, 0xc4, 0x1e, 0xe3, 0xdd, 0x58, 0xf4, 0x0f, 0x38, 0xf2, 0x09, 0xfd, 0x12, + 0xce, 0x3d, 0xf6, 0xc8, 0x29, 0x42, 0xc9, 0x85, 0x73, 0xbe, 0x00, 0xad, 0xed, 0x84, 0xe4, 0x82, + 0x38, 0x79, 0x66, 0xde, 0x1b, 0xbf, 0x7d, 0x3b, 0xb3, 0xe4, 0xb9, 0x8c, 0x05, 0x8f, 0xf2, 0x7c, + 0x22, 0x45, 0xa4, 0x25, 0x66, 0x8a, 0xeb, 0x22, 0xca, 0xd4, 0x27, 0x28, 0x78, 0x19, 0x70, 0xfd, + 0x95, 0xe5, 0x05, 0x6a, 0xa4, 0x87, 0x32, 0x16, 0x6c, 0x93, 0xc6, 0x56, 0x34, 0x56, 0x06, 0xfd, + 0x27, 0x09, 0x26, 0x58, 0x11, 0xb9, 0x89, 0xea, 0x9e, 0xbe, 0x2b, 0x50, 0xa5, 0xa8, 0x78, 0x1c, + 0x29, 0xe0, 0x65, 0x10, 0x83, 0x8e, 0x02, 0x2e, 0x50, 0x66, 0x0d, 0xee, 0x19, 0x69, 0x81, 0x05, + 0x70, 0x31, 0x91, 0x90, 0x69, 0x23, 0x58, 0x47, 0x35, 0xc1, 0xff, 0xd1, 0x22, 0xbd, 0x73, 0x95, + 0x5c, 0x34, 0x4a, 0xf4, 0x84, 0xf4, 0x14, 0x4e, 0x0b, 0x01, 0x97, 0x39, 0x16, 0xda, 0xb1, 0x07, + 0xf6, 0xf0, 0xc1, 0x68, 0x7f, 0x39, 0xf3, 0xe8, 0x75, 0x94, 0x4e, 0x4e, 0xfd, 0x0d, 0xd0, 0x0f, + 0x49, 0x9d, 0xbd, 0xc3, 0x42, 0xd3, 0xd7, 0x64, 0xaf, 0xc1, 0xc4, 0x38, 0xca, 0x32, 0x98, 0x38, + 0xf7, 0xaa, 0xde, 0x83, 0xe5, 0xcc, 0x7b, 0xba, 0xd5, 0xdb, 0xe0, 0x7e, 0xb8, 0x5b, 0x17, 0xce, + 0xea, 0x9c, 0x1e, 0x93, 0x1d, 0x8d, 0x9f, 0x21, 0x73, 0x5a, 0x03, 0x7b, 0xd8, 0x3b, 0x3a, 0x60, + 0xb5, 0x37, 0x66, 0xbc, 0xb1, 0xc6, 0x1b, 0x3b, 0x43, 0x99, 0x8d, 0xda, 0xb7, 0x33, 0xcf, 0x0a, + 0x6b, 0x36, 0xdd, 0x27, 0x1d, 0x05, 0xd9, 0x15, 0x14, 0x4e, 0xdb, 0x08, 0x86, 0x4d, 0x46, 0xfb, + 0xa4, 0x5b, 0x80, 0x00, 0x59, 0x42, 0xe1, 0xec, 0x54, 0xc8, 0x3a, 0xa7, 0x1f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xe5, 0x31, 0x4f, 0xf1, 0x6a, 0x3a, 0x01, 0x65, 0x9e, 0xce, 0xc6, 0x93, 0xd1, 0xd7, 0x39, + 0xa8, 0xb8, 0x53, 0xad, 0xef, 0xab, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x15, 0x53, 0xcc, + 0x5c, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -281,10 +281,10 @@ func (m *MsgTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Metadata) > 0 { - i -= len(m.Metadata) - copy(dAtA[i:], m.Metadata) - i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + if len(m.Memo) > 0 { + i -= len(m.Memo) + copy(dAtA[i:], m.Memo) + i = encodeVarintTx(dAtA, i, uint64(len(m.Memo))) i-- dAtA[i] = 0x42 } @@ -412,7 +412,7 @@ func (m *MsgTransfer) Size() (n int) { if m.TimeoutTimestamp != 0 { n += 1 + sovTx(uint64(m.TimeoutTimestamp)) } - l = len(m.Metadata) + l = len(m.Memo) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -681,9 +681,9 @@ func (m *MsgTransfer) Unmarshal(dAtA []byte) error { } case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Memo", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -693,25 +693,23 @@ func (m *MsgTransfer) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} - } + m.Memo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/proto/ibc/applications/transfer/v1/tx.proto b/proto/ibc/applications/transfer/v1/tx.proto index ded470d8a34..c15256de5b5 100644 --- a/proto/ibc/applications/transfer/v1/tx.proto +++ b/proto/ibc/applications/transfer/v1/tx.proto @@ -38,8 +38,8 @@ message MsgTransfer { // Timeout timestamp in absolute nanoseconds since unix epoch. // The timeout is disabled when set to 0. uint64 timeout_timestamp = 7 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""]; - // optional metadata - bytes metadata = 8; + // optional memo + string memo = 8; } // MsgTransferResponse defines the Msg/Transfer response type. diff --git a/proto/ibc/applications/transfer/v2/packet.proto b/proto/ibc/applications/transfer/v2/packet.proto index 8cff9d9346d..af06b977525 100644 --- a/proto/ibc/applications/transfer/v2/packet.proto +++ b/proto/ibc/applications/transfer/v2/packet.proto @@ -16,6 +16,6 @@ message FungibleTokenPacketData { string sender = 3; // the recipient address on the destination chain string receiver = 4; - // optional metadata - bytes metadata = 5; + // optional memo + string memo = 5; }