From 8c45e3e7a83c91cd9726b60a19147abf7258c4d9 Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 8 Apr 2024 17:00:23 +0200 Subject: [PATCH] update amount -> string --- modules/apps/transfer/types/v3/packet.pb.go | 70 ++++++++++++------- .../ibc/applications/transfer/v3/packet.proto | 2 +- 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/modules/apps/transfer/types/v3/packet.pb.go b/modules/apps/transfer/types/v3/packet.pb.go index a97568e7521..145b51c5eb9 100644 --- a/modules/apps/transfer/types/v3/packet.pb.go +++ b/modules/apps/transfer/types/v3/packet.pb.go @@ -102,7 +102,7 @@ type Token struct { // the base token denomination to be transferred Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` // the token amount to be transferred - Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` // the trace of the token Trace []string `protobuf:"bytes,3,rep,name=trace,proto3" json:"trace,omitempty"` } @@ -147,11 +147,11 @@ func (m *Token) GetDenom() string { return "" } -func (m *Token) GetAmount() uint64 { +func (m *Token) GetAmount() string { if m != nil { return m.Amount } - return 0 + return "" } func (m *Token) GetTrace() []string { @@ -171,26 +171,26 @@ func init() { } var fileDescriptor_760742a8894acdbe = []byte{ - // 302 bytes of a gzipped FileDescriptorProto + // 301 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xc1, 0x4a, 0x33, 0x31, 0x14, 0x85, 0x9b, 0x7f, 0xda, 0xf2, 0x1b, 0x77, 0x41, 0x74, 0x10, 0x19, 0x4a, 0xdd, 0xd4, 0x85, 0x09, 0x38, 0x1b, 0xd1, 0x9d, 0x88, 0x1b, 0x37, 0x52, 0xba, 0x72, 0x97, 0xa4, 0xd7, 0x1a, 0xda, 0xe4, 0x0e, 0x49, 0x66, 0xc0, 0xb7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65, 0xc6, 0x68, 0xd7, 0x82, 0xc5, 0xbc, 0x9b, 0xf6, 0x69, 0x1e, 0x3e, + 0xd2, 0x5e, 0x7a, 0xcc, 0x8e, 0x68, 0x6f, 0x0a, 0x0e, 0x6d, 0x4e, 0xd2, 0x75, 0x03, 0x6d, 0x8c, + 0xb4, 0x58, 0xbb, 0xb8, 0x8b, 0xd9, 0x50, 0xab, 0x8e, 0x5e, 0x6a, 0xc8, 0xb3, 0x41, 0xd6, 0xaa, + 0x13, 0xdc, 0x4d, 0x3e, 0x57, 0x05, 0x59, 0xae, 0x0a, 0xf2, 0xbd, 0x2a, 0xc8, 0xfb, 0xba, 0xe8, + 0x2c, 0xd7, 0x45, 0xe7, 0x6b, 0x5d, 0x74, 0x9e, 0x6f, 0x66, 0x26, 0xbe, 0xd6, 0x8a, 0x6b, 0xb4, + 0x42, 0x63, 0xb0, 0x18, 0x84, 0x51, 0xfa, 0x72, 0x86, 0xa2, 0xb9, 0x16, 0x16, 0xa7, 0xf5, 0x02, + 0x42, 0x5b, 0xf8, 0x5e, 0xd1, 0xf1, 0xad, 0x82, 0x20, 0x9a, 0x52, 0xf5, 0x53, 0xd1, 0xe5, 0x4f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x97, 0x4d, 0xcc, 0xde, 0x95, 0x01, 0x00, 0x00, } func (m *FungibleTokenPacketData) Marshal() (dAtA []byte, err error) { @@ -280,10 +280,12 @@ func (m *Token) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } } - if m.Amount != 0 { - i = encodeVarintPacket(dAtA, i, uint64(m.Amount)) + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Amount))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } if len(m.Denom) > 0 { i -= len(m.Denom) @@ -343,8 +345,9 @@ func (m *Token) Size() (n int) { if l > 0 { n += 1 + l + sovPacket(uint64(l)) } - if m.Amount != 0 { - n += 1 + sovPacket(uint64(m.Amount)) + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) } if len(m.Trace) > 0 { for _, s := range m.Trace { @@ -603,10 +606,10 @@ func (m *Token) Unmarshal(dAtA []byte) error { m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } - m.Amount = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPacket @@ -616,11 +619,24 @@ func (m *Token) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Amount |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Trace", wireType) diff --git a/proto/ibc/applications/transfer/v3/packet.proto b/proto/ibc/applications/transfer/v3/packet.proto index 32fc8938cd5..8971472c69d 100644 --- a/proto/ibc/applications/transfer/v3/packet.proto +++ b/proto/ibc/applications/transfer/v3/packet.proto @@ -23,7 +23,7 @@ message Token { // the base token denomination to be transferred string denom = 1; // the token amount to be transferred - uint64 amount = 2; + string amount = 2; // the trace of the token repeated string trace = 3; }