From 4108ea40e8f4cc8ed3d1e1e1e7c5042fe8f1527d Mon Sep 17 00:00:00 2001 From: yutianwu Date: Mon, 16 Jan 2023 11:07:49 +0800 Subject: [PATCH] update cross chain event --- proto/cosmos/crosschain/v1/event.proto | 2 +- x/crosschain/keeper/keeper.go | 3 +- x/crosschain/types/event.pb.go | 60 +++++++++++++------------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/proto/cosmos/crosschain/v1/event.proto b/proto/cosmos/crosschain/v1/event.proto index 78d3cfb898..a8529667b8 100644 --- a/proto/cosmos/crosschain/v1/event.proto +++ b/proto/cosmos/crosschain/v1/event.proto @@ -12,7 +12,7 @@ message EventCrossChain { uint64 sequence = 4; uint32 package_type = 5; uint64 timestamp = 6; - bytes package_load = 7; + string package_load = 7; string relayer_fee = 8; string ack_relayer_fee = 9; } diff --git a/x/crosschain/keeper/keeper.go b/x/crosschain/keeper/keeper.go index 14c422685c..aa60e74305 100644 --- a/x/crosschain/keeper/keeper.go +++ b/x/crosschain/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "encoding/binary" + "encoding/hex" "fmt" "math/big" @@ -112,7 +113,7 @@ func (k Keeper) CreateRawIBCPackageWithFee(ctx sdk.Context, channelID sdk.Channe Sequence: sequence, PackageType: uint32(packageType), Timestamp: uint64(ctx.BlockTime().Unix()), - PackageLoad: packageLoad, + PackageLoad: hex.EncodeToString(packageLoad), RelayerFee: relayerFee.String(), AckRelayerFee: ackRelayerFee.String(), }) diff --git a/x/crosschain/types/event.pb.go b/x/crosschain/types/event.pb.go index e16e3c85b8..1fac3615d2 100644 --- a/x/crosschain/types/event.pb.go +++ b/x/crosschain/types/event.pb.go @@ -30,7 +30,7 @@ type EventCrossChain struct { Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` PackageType uint32 `protobuf:"varint,5,opt,name=package_type,json=packageType,proto3" json:"package_type,omitempty"` Timestamp uint64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - PackageLoad []byte `protobuf:"bytes,7,opt,name=package_load,json=packageLoad,proto3" json:"package_load,omitempty"` + PackageLoad string `protobuf:"bytes,7,opt,name=package_load,json=packageLoad,proto3" json:"package_load,omitempty"` RelayerFee string `protobuf:"bytes,8,opt,name=relayer_fee,json=relayerFee,proto3" json:"relayer_fee,omitempty"` AckRelayerFee string `protobuf:"bytes,9,opt,name=ack_relayer_fee,json=ackRelayerFee,proto3" json:"ack_relayer_fee,omitempty"` } @@ -110,11 +110,11 @@ func (m *EventCrossChain) GetTimestamp() uint64 { return 0 } -func (m *EventCrossChain) GetPackageLoad() []byte { +func (m *EventCrossChain) GetPackageLoad() string { if m != nil { return m.PackageLoad } - return nil + return "" } func (m *EventCrossChain) GetRelayerFee() string { @@ -138,28 +138,28 @@ func init() { func init() { proto.RegisterFile("cosmos/crosschain/v1/event.proto", fileDescriptor_2a5a3ba75f5dd2c3) } var fileDescriptor_2a5a3ba75f5dd2c3 = []byte{ - // 326 bytes of a gzipped FileDescriptorProto + // 323 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0xd1, 0x4f, 0x4f, 0xfa, 0x30, 0x18, 0xc0, 0x71, 0xca, 0x8f, 0x1f, 0xb2, 0x07, 0x08, 0x49, 0xe3, 0x61, 0x31, 0x3a, 0x27, 0x07, - 0xb3, 0x8b, 0x5b, 0x88, 0xef, 0x40, 0xa2, 0x09, 0x89, 0xa7, 0xc5, 0x93, 0x97, 0xa5, 0xb4, 0x8f, - 0xb0, 0x8c, 0xad, 0x73, 0x2d, 0x44, 0xde, 0x85, 0xef, 0xc8, 0xab, 0x47, 0x8e, 0x1e, 0x0d, 0xbc, - 0x11, 0xd3, 0xf2, 0xf7, 0xb4, 0xec, 0xdb, 0x4f, 0x9f, 0xa4, 0x79, 0xc0, 0xe7, 0x52, 0xe5, 0x52, - 0x45, 0xbc, 0x92, 0x4a, 0xf1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x51, 0xe0, 0xcc, 0x82, 0x7f, 0x0e, 0x78, + 0xbb, 0x32, 0x14, 0xf4, 0x02, 0x1a, 0x1a, 0xdf, 0xe7, 0x58, 0x70, 0xf4, 0x6b, 0x21, 0xe9, 0xd5, + 0x46, 0x87, 0x7f, 0x7a, 0x03, 0xad, 0x92, 0xf1, 0x8c, 0x4d, 0x30, 0x31, 0xcb, 0x12, 0xfd, 0xff, + 0xdb, 0xe9, 0xbb, 0xf6, 0xb2, 0x2c, 0x91, 0x5e, 0x82, 0x67, 0xd2, 0x1c, 0xb5, 0x61, 0x79, 0xe9, + 0xd7, 0xdd, 0xfd, 0x63, 0x38, 0x1d, 0x30, 0x93, 0x4c, 0xf8, 0x67, 0x21, 0xe9, 0x79, 0x87, 0x01, + 0xcf, 0x92, 0x09, 0x7a, 0x0d, 0x4d, 0x85, 0x33, 0xb6, 0x44, 0x95, 0xbc, 0x21, 0xfa, 0x0d, 0x27, + 0x60, 0x97, 0x9e, 0x10, 0xe9, 0x2d, 0x74, 0x18, 0xcf, 0x92, 0x53, 0xe4, 0x39, 0xd4, 0x66, 0x3c, + 0x1b, 0x1d, 0xdc, 0xc3, 0xf0, 0x7b, 0x1d, 0x90, 0xd5, 0x3a, 0x20, 0xbf, 0xeb, 0x80, 0x7c, 0x6e, + 0x82, 0xca, 0x6a, 0x13, 0x54, 0x7e, 0x36, 0x41, 0xe5, 0x35, 0x9e, 0xa4, 0x66, 0x3a, 0x1f, 0x47, + 0x5c, 0xe6, 0xf1, 0x7e, 0x3d, 0xee, 0x73, 0xa7, 0x45, 0x16, 0x7f, 0x9c, 0xee, 0xca, 0x3e, 0x53, + 0x8f, 0xeb, 0x6e, 0x53, 0xf7, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x93, 0x08, 0x3b, 0x98, 0xcd, + 0x01, 0x00, 0x00, } func (m *EventCrossChain) Marshal() (dAtA []byte, err error) { @@ -439,7 +439,7 @@ func (m *EventCrossChain) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PackageLoad", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvent @@ -449,25 +449,23 @@ func (m *EventCrossChain) 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 ErrInvalidLengthEvent } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvent } if postIndex > l { return io.ErrUnexpectedEOF } - m.PackageLoad = append(m.PackageLoad[:0], dAtA[iNdEx:postIndex]...) - if m.PackageLoad == nil { - m.PackageLoad = []byte{} - } + m.PackageLoad = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 8: if wireType != 2 {