diff --git a/api/band/tunnel/v1beta1/route.pulsar.go b/api/band/tunnel/v1beta1/route.pulsar.go index 8b52f732f..88b50a5d3 100644 --- a/api/band/tunnel/v1beta1/route.pulsar.go +++ b/api/band/tunnel/v1beta1/route.pulsar.go @@ -3,6 +3,7 @@ package tunnelv1beta1 import ( fmt "fmt" + v1beta1 "github.com/bandprotocol/chain/v3/api/band/feeds/v1beta1" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -902,6 +903,1468 @@ func (x *fastReflection_TSSPacketReceipt) ProtoMethods() *protoiface.Methods { } } +var ( + md_IBCRoute protoreflect.MessageDescriptor + fd_IBCRoute_channel_id protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_IBCRoute = File_band_tunnel_v1beta1_route_proto.Messages().ByName("IBCRoute") + fd_IBCRoute_channel_id = md_IBCRoute.Fields().ByName("channel_id") +} + +var _ protoreflect.Message = (*fastReflection_IBCRoute)(nil) + +type fastReflection_IBCRoute IBCRoute + +func (x *IBCRoute) ProtoReflect() protoreflect.Message { + return (*fastReflection_IBCRoute)(x) +} + +func (x *IBCRoute) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_IBCRoute_messageType fastReflection_IBCRoute_messageType +var _ protoreflect.MessageType = fastReflection_IBCRoute_messageType{} + +type fastReflection_IBCRoute_messageType struct{} + +func (x fastReflection_IBCRoute_messageType) Zero() protoreflect.Message { + return (*fastReflection_IBCRoute)(nil) +} +func (x fastReflection_IBCRoute_messageType) New() protoreflect.Message { + return new(fastReflection_IBCRoute) +} +func (x fastReflection_IBCRoute_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_IBCRoute +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_IBCRoute) Descriptor() protoreflect.MessageDescriptor { + return md_IBCRoute +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_IBCRoute) Type() protoreflect.MessageType { + return _fastReflection_IBCRoute_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_IBCRoute) New() protoreflect.Message { + return new(fastReflection_IBCRoute) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_IBCRoute) Interface() protoreflect.ProtoMessage { + return (*IBCRoute)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_IBCRoute) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ChannelId != "" { + value := protoreflect.ValueOfString(x.ChannelId) + if !f(fd_IBCRoute_channel_id, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_IBCRoute) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + return x.ChannelId != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + x.ChannelId = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_IBCRoute) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + value := x.ChannelId + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + x.ChannelId = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + panic(fmt.Errorf("field channel_id of message band.tunnel.v1beta1.IBCRoute is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_IBCRoute) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_IBCRoute) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.IBCRoute", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_IBCRoute) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_IBCRoute) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_IBCRoute) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*IBCRoute) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.ChannelId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*IBCRoute) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.ChannelId) > 0 { + i -= len(x.ChannelId) + copy(dAtA[i:], x.ChannelId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ChannelId))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*IBCRoute) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCRoute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_IBCPacketReceipt protoreflect.MessageDescriptor + fd_IBCPacketReceipt_sequence protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_IBCPacketReceipt = File_band_tunnel_v1beta1_route_proto.Messages().ByName("IBCPacketReceipt") + fd_IBCPacketReceipt_sequence = md_IBCPacketReceipt.Fields().ByName("sequence") +} + +var _ protoreflect.Message = (*fastReflection_IBCPacketReceipt)(nil) + +type fastReflection_IBCPacketReceipt IBCPacketReceipt + +func (x *IBCPacketReceipt) ProtoReflect() protoreflect.Message { + return (*fastReflection_IBCPacketReceipt)(x) +} + +func (x *IBCPacketReceipt) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_IBCPacketReceipt_messageType fastReflection_IBCPacketReceipt_messageType +var _ protoreflect.MessageType = fastReflection_IBCPacketReceipt_messageType{} + +type fastReflection_IBCPacketReceipt_messageType struct{} + +func (x fastReflection_IBCPacketReceipt_messageType) Zero() protoreflect.Message { + return (*fastReflection_IBCPacketReceipt)(nil) +} +func (x fastReflection_IBCPacketReceipt_messageType) New() protoreflect.Message { + return new(fastReflection_IBCPacketReceipt) +} +func (x fastReflection_IBCPacketReceipt_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_IBCPacketReceipt +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_IBCPacketReceipt) Descriptor() protoreflect.MessageDescriptor { + return md_IBCPacketReceipt +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_IBCPacketReceipt) Type() protoreflect.MessageType { + return _fastReflection_IBCPacketReceipt_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_IBCPacketReceipt) New() protoreflect.Message { + return new(fastReflection_IBCPacketReceipt) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_IBCPacketReceipt) Interface() protoreflect.ProtoMessage { + return (*IBCPacketReceipt)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_IBCPacketReceipt) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sequence != uint64(0) { + value := protoreflect.ValueOfUint64(x.Sequence) + if !f(fd_IBCPacketReceipt_sequence, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_IBCPacketReceipt) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + return x.Sequence != uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + x.Sequence = uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_IBCPacketReceipt) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + value := x.Sequence + return protoreflect.ValueOfUint64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + x.Sequence = value.Uint() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + panic(fmt.Errorf("field sequence of message band.tunnel.v1beta1.IBCPacketReceipt is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_IBCPacketReceipt) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_IBCPacketReceipt) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.IBCPacketReceipt", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_IBCPacketReceipt) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_IBCPacketReceipt) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_IBCPacketReceipt) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*IBCPacketReceipt) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Sequence != 0 { + n += 1 + runtime.Sov(uint64(x.Sequence)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*IBCPacketReceipt) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Sequence != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*IBCPacketReceipt) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCPacketReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCPacketReceipt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + x.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_TunnelPricesPacketData_3_list)(nil) + +type _TunnelPricesPacketData_3_list struct { + list *[]*v1beta1.Price +} + +func (x *_TunnelPricesPacketData_3_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_TunnelPricesPacketData_3_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_TunnelPricesPacketData_3_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Price) + (*x.list)[i] = concreteValue +} + +func (x *_TunnelPricesPacketData_3_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Price) + *x.list = append(*x.list, concreteValue) +} + +func (x *_TunnelPricesPacketData_3_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.Price) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_TunnelPricesPacketData_3_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_TunnelPricesPacketData_3_list) NewElement() protoreflect.Value { + v := new(v1beta1.Price) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_TunnelPricesPacketData_3_list) IsValid() bool { + return x.list != nil +} + +var ( + md_TunnelPricesPacketData protoreflect.MessageDescriptor + fd_TunnelPricesPacketData_tunnel_id protoreflect.FieldDescriptor + fd_TunnelPricesPacketData_sequence protoreflect.FieldDescriptor + fd_TunnelPricesPacketData_prices protoreflect.FieldDescriptor + fd_TunnelPricesPacketData_created_at protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_TunnelPricesPacketData = File_band_tunnel_v1beta1_route_proto.Messages().ByName("TunnelPricesPacketData") + fd_TunnelPricesPacketData_tunnel_id = md_TunnelPricesPacketData.Fields().ByName("tunnel_id") + fd_TunnelPricesPacketData_sequence = md_TunnelPricesPacketData.Fields().ByName("sequence") + fd_TunnelPricesPacketData_prices = md_TunnelPricesPacketData.Fields().ByName("prices") + fd_TunnelPricesPacketData_created_at = md_TunnelPricesPacketData.Fields().ByName("created_at") +} + +var _ protoreflect.Message = (*fastReflection_TunnelPricesPacketData)(nil) + +type fastReflection_TunnelPricesPacketData TunnelPricesPacketData + +func (x *TunnelPricesPacketData) ProtoReflect() protoreflect.Message { + return (*fastReflection_TunnelPricesPacketData)(x) +} + +func (x *TunnelPricesPacketData) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TunnelPricesPacketData_messageType fastReflection_TunnelPricesPacketData_messageType +var _ protoreflect.MessageType = fastReflection_TunnelPricesPacketData_messageType{} + +type fastReflection_TunnelPricesPacketData_messageType struct{} + +func (x fastReflection_TunnelPricesPacketData_messageType) Zero() protoreflect.Message { + return (*fastReflection_TunnelPricesPacketData)(nil) +} +func (x fastReflection_TunnelPricesPacketData_messageType) New() protoreflect.Message { + return new(fastReflection_TunnelPricesPacketData) +} +func (x fastReflection_TunnelPricesPacketData_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TunnelPricesPacketData +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TunnelPricesPacketData) Descriptor() protoreflect.MessageDescriptor { + return md_TunnelPricesPacketData +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TunnelPricesPacketData) Type() protoreflect.MessageType { + return _fastReflection_TunnelPricesPacketData_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TunnelPricesPacketData) New() protoreflect.Message { + return new(fastReflection_TunnelPricesPacketData) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TunnelPricesPacketData) Interface() protoreflect.ProtoMessage { + return (*TunnelPricesPacketData)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TunnelPricesPacketData) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.TunnelId != uint64(0) { + value := protoreflect.ValueOfUint64(x.TunnelId) + if !f(fd_TunnelPricesPacketData_tunnel_id, value) { + return + } + } + if x.Sequence != uint64(0) { + value := protoreflect.ValueOfUint64(x.Sequence) + if !f(fd_TunnelPricesPacketData_sequence, value) { + return + } + } + if len(x.Prices) != 0 { + value := protoreflect.ValueOfList(&_TunnelPricesPacketData_3_list{list: &x.Prices}) + if !f(fd_TunnelPricesPacketData_prices, value) { + return + } + } + if x.CreatedAt != int64(0) { + value := protoreflect.ValueOfInt64(x.CreatedAt) + if !f(fd_TunnelPricesPacketData_created_at, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TunnelPricesPacketData) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + return x.TunnelId != uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + return x.Sequence != uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + return len(x.Prices) != 0 + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + return x.CreatedAt != int64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TunnelPricesPacketData) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + x.TunnelId = uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + x.Sequence = uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + x.Prices = nil + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + x.CreatedAt = int64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TunnelPricesPacketData) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + value := x.TunnelId + return protoreflect.ValueOfUint64(value) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + value := x.Sequence + return protoreflect.ValueOfUint64(value) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + if len(x.Prices) == 0 { + return protoreflect.ValueOfList(&_TunnelPricesPacketData_3_list{}) + } + listValue := &_TunnelPricesPacketData_3_list{list: &x.Prices} + return protoreflect.ValueOfList(listValue) + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + value := x.CreatedAt + return protoreflect.ValueOfInt64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TunnelPricesPacketData) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + x.TunnelId = value.Uint() + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + x.Sequence = value.Uint() + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + lv := value.List() + clv := lv.(*_TunnelPricesPacketData_3_list) + x.Prices = *clv.list + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + x.CreatedAt = value.Int() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TunnelPricesPacketData) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + if x.Prices == nil { + x.Prices = []*v1beta1.Price{} + } + value := &_TunnelPricesPacketData_3_list{list: &x.Prices} + return protoreflect.ValueOfList(value) + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + panic(fmt.Errorf("field tunnel_id of message band.tunnel.v1beta1.TunnelPricesPacketData is not mutable")) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + panic(fmt.Errorf("field sequence of message band.tunnel.v1beta1.TunnelPricesPacketData is not mutable")) + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + panic(fmt.Errorf("field created_at of message band.tunnel.v1beta1.TunnelPricesPacketData is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TunnelPricesPacketData) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + return protoreflect.ValueOfUint64(uint64(0)) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + return protoreflect.ValueOfUint64(uint64(0)) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + list := []*v1beta1.Price{} + return protoreflect.ValueOfList(&_TunnelPricesPacketData_3_list{list: &list}) + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + return protoreflect.ValueOfInt64(int64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TunnelPricesPacketData) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.TunnelPricesPacketData", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TunnelPricesPacketData) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TunnelPricesPacketData) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TunnelPricesPacketData) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TunnelPricesPacketData) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TunnelPricesPacketData) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.TunnelId != 0 { + n += 1 + runtime.Sov(uint64(x.TunnelId)) + } + if x.Sequence != 0 { + n += 1 + runtime.Sov(uint64(x.Sequence)) + } + if len(x.Prices) > 0 { + for _, e := range x.Prices { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.CreatedAt != 0 { + n += 1 + runtime.Sov(uint64(x.CreatedAt)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TunnelPricesPacketData) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.CreatedAt != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.CreatedAt)) + i-- + dAtA[i] = 0x20 + } + if len(x.Prices) > 0 { + for iNdEx := len(x.Prices) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Prices[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + } + } + if x.Sequence != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) + i-- + dAtA[i] = 0x10 + } + if x.TunnelId != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.TunnelId)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TunnelPricesPacketData) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TunnelPricesPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TunnelPricesPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TunnelId", wireType) + } + x.TunnelId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.TunnelId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + x.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Prices = append(x.Prices, &v1beta1.Price{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Prices[len(x.Prices)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + x.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.CreatedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -998,6 +2461,144 @@ func (x *TSSPacketReceipt) GetSigningId() uint64 { return 0 } +// IBCRoute is the type for an IBC route +type IBCRoute struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // channel_id is the IBC channel ID + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (x *IBCRoute) Reset() { + *x = IBCRoute{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IBCRoute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IBCRoute) ProtoMessage() {} + +// Deprecated: Use IBCRoute.ProtoReflect.Descriptor instead. +func (*IBCRoute) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{2} +} + +func (x *IBCRoute) GetChannelId() string { + if x != nil { + return x.ChannelId + } + return "" +} + +// IBCPacketReceipt represents a receipt for a IBC packet and implements the PacketReceiptI interface. +type IBCPacketReceipt struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // sequence is representing the sequence of the IBC packet. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (x *IBCPacketReceipt) Reset() { + *x = IBCPacketReceipt{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IBCPacketReceipt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IBCPacketReceipt) ProtoMessage() {} + +// Deprecated: Use IBCPacketReceipt.ProtoReflect.Descriptor instead. +func (*IBCPacketReceipt) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{3} +} + +func (x *IBCPacketReceipt) GetSequence() uint64 { + if x != nil { + return x.Sequence + } + return 0 +} + +// TunnelPricesPacketData represents the IBC packet payload for the tunnel packet. +type TunnelPricesPacketData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // tunnel_id is the tunnel ID + TunnelId uint64 `protobuf:"varint,1,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` + // sequence is representing the sequence of the tunnel packet. + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // prices is the list of prices information from feeds module. + Prices []*v1beta1.Price `protobuf:"bytes,3,rep,name=prices,proto3" json:"prices,omitempty"` + // created_at is the timestamp when the packet is created + CreatedAt int64 `protobuf:"varint,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (x *TunnelPricesPacketData) Reset() { + *x = TunnelPricesPacketData{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TunnelPricesPacketData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TunnelPricesPacketData) ProtoMessage() {} + +// Deprecated: Use TunnelPricesPacketData.ProtoReflect.Descriptor instead. +func (*TunnelPricesPacketData) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{4} +} + +func (x *TunnelPricesPacketData) GetTunnelId() uint64 { + if x != nil { + return x.TunnelId + } + return 0 +} + +func (x *TunnelPricesPacketData) GetSequence() uint64 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *TunnelPricesPacketData) GetPrices() []*v1beta1.Price { + if x != nil { + return x.Prices + } + return nil +} + +func (x *TunnelPricesPacketData) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + var File_band_tunnel_v1beta1_route_proto protoreflect.FileDescriptor var file_band_tunnel_v1beta1_route_proto_rawDesc = []byte{ @@ -1007,7 +2608,9 @@ var file_band_tunnel_v1beta1_route_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, - 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x01, 0x0a, 0x08, 0x54, 0x53, 0x53, 0x52, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x66, 0x65, + 0x65, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x66, 0x65, 0x65, 0x64, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x01, 0x0a, 0x08, 0x54, 0x53, 0x53, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x48, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x16, 0xe2, 0xde, 0x1f, 0x12, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, @@ -1027,21 +2630,41 @@ var file_band_tunnel_v1beta1_route_proto_rawDesc = []byte{ 0x73, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x49, 0x44, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x3a, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, - 0x49, 0x42, 0xdf, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x74, - 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x52, - 0x6f, 0x75, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2f, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, - 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, - 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, - 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x42, 0x61, 0x6e, 0x64, 0x3a, 0x3a, - 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa8, - 0xe2, 0x1e, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x22, 0x43, 0x0a, 0x08, 0x49, 0x42, 0x43, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x2c, 0x0a, + 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x0d, 0xe2, 0xde, 0x1f, 0x09, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, + 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x3a, 0x09, 0xca, 0xb4, 0x2d, + 0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x22, 0x42, 0x0a, 0x10, 0x49, 0x42, 0x43, 0x50, 0x61, 0x63, + 0x6b, 0x65, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, + 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, + 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x3a, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x50, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x22, 0xb7, 0x01, 0x0a, 0x16, 0x54, + 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x29, 0x0a, 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x54, 0x75, + 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, + 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x06, + 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, + 0x61, 0x6e, 0x64, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, + 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x42, 0xdf, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x6e, + 0x64, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x42, 0x0a, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, + 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x42, + 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xca, 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, + 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x42, 0x61, 0x6e, 0x64, 0x5c, + 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x42, 0x61, 0x6e, + 0x64, 0x3a, 0x3a, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xa8, 0xe2, 0x1e, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1056,17 +2679,22 @@ func file_band_tunnel_v1beta1_route_proto_rawDescGZIP() []byte { return file_band_tunnel_v1beta1_route_proto_rawDescData } -var file_band_tunnel_v1beta1_route_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_band_tunnel_v1beta1_route_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_band_tunnel_v1beta1_route_proto_goTypes = []interface{}{ - (*TSSRoute)(nil), // 0: band.tunnel.v1beta1.TSSRoute - (*TSSPacketReceipt)(nil), // 1: band.tunnel.v1beta1.TSSPacketReceipt + (*TSSRoute)(nil), // 0: band.tunnel.v1beta1.TSSRoute + (*TSSPacketReceipt)(nil), // 1: band.tunnel.v1beta1.TSSPacketReceipt + (*IBCRoute)(nil), // 2: band.tunnel.v1beta1.IBCRoute + (*IBCPacketReceipt)(nil), // 3: band.tunnel.v1beta1.IBCPacketReceipt + (*TunnelPricesPacketData)(nil), // 4: band.tunnel.v1beta1.TunnelPricesPacketData + (*v1beta1.Price)(nil), // 5: band.feeds.v1beta1.Price } var file_band_tunnel_v1beta1_route_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 5, // 0: band.tunnel.v1beta1.TunnelPricesPacketData.prices:type_name -> band.feeds.v1beta1.Price + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_band_tunnel_v1beta1_route_proto_init() } @@ -1099,6 +2727,42 @@ func file_band_tunnel_v1beta1_route_proto_init() { return nil } } + file_band_tunnel_v1beta1_route_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IBCRoute); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_band_tunnel_v1beta1_route_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IBCPacketReceipt); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_band_tunnel_v1beta1_route_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TunnelPricesPacketData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1106,7 +2770,7 @@ func file_band_tunnel_v1beta1_route_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_band_tunnel_v1beta1_route_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 1a3dee385..c7d973ee8 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -87,6 +87,7 @@ import ( "github.com/bandprotocol/chain/v3/x/tss" tsskeeper "github.com/bandprotocol/chain/v3/x/tss/keeper" tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" + "github.com/bandprotocol/chain/v3/x/tunnel" tunnelkeeper "github.com/bandprotocol/chain/v3/x/tunnel/keeper" tunneltypes "github.com/bandprotocol/chain/v3/x/tunnel/types" ) @@ -137,6 +138,7 @@ type AppKeepers struct { ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper ScopedOracleKeeper capabilitykeeper.ScopedKeeper + ScopedTunnelKeeper capabilitykeeper.ScopedKeeper } func NewAppKeeper( @@ -197,6 +199,7 @@ func NewAppKeeper( appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) appKeepers.ScopedOracleKeeper = appKeepers.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName) + appKeepers.ScopedTunnelKeeper = appKeepers.CapabilityKeeper.ScopeToModule(tunneltypes.ModuleName) // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating // their scoped modules in `NewApp` with `ScopeToModule` @@ -498,6 +501,9 @@ func NewAppKeeper( appKeepers.BankKeeper, appKeepers.FeedsKeeper, appKeepers.BandtssKeeper, + appKeepers.IBCFeeKeeper, + appKeepers.IBCKeeper.PortKeeper, + appKeepers.ScopedTunnelKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -534,9 +540,13 @@ func NewAppKeeper( // Create Oracle Stack var oracleStack porttypes.IBCModule = oracle.NewIBCModule(appKeepers.OracleKeeper) + // Create Tunnel Stack + var tunnelStack porttypes.IBCModule = tunnel.NewIBCModule(appKeepers.TunnelKeeper) + ibcRouter := porttypes.NewRouter().AddRoute(icahosttypes.SubModuleName, icaHostStack). AddRoute(ibctransfertypes.ModuleName, transferStack). - AddRoute(oracletypes.ModuleName, oracleStack) + AddRoute(oracletypes.ModuleName, oracleStack). + AddRoute(tunneltypes.ModuleName, tunnelStack) appKeepers.IBCKeeper.SetRouter(ibcRouter) diff --git a/grogu/signaller/signaller_test.go b/grogu/signaller/signaller_test.go index 4ef3e0016..8615ba0a6 100644 --- a/grogu/signaller/signaller_test.go +++ b/grogu/signaller/signaller_test.go @@ -1,6 +1,7 @@ package signaller import ( + "sort" "sync" "testing" "time" @@ -199,9 +200,14 @@ func (s *SignallerTestSuite) TestGetNonPendingSignalIDs() { // Update internal variables s.TestUpdateInternalVariables() + expectedSignalIDs := []string{"signal1", "signal2"} + signalIDs = s.Signaller.getNonPendingSignalIDs() s.Require().NotEmpty(signalIDs) - s.Require().Equal("signal1", signalIDs[0]) + + // sort signalIDs to compare + sort.Strings(signalIDs) + s.Require().Equal(expectedSignalIDs, signalIDs) } func (s *SignallerTestSuite) TestSignalPrices() { diff --git a/proto/band/tunnel/v1beta1/route.proto b/proto/band/tunnel/v1beta1/route.proto index ea3bc0079..3884b7086 100644 --- a/proto/band/tunnel/v1beta1/route.proto +++ b/proto/band/tunnel/v1beta1/route.proto @@ -4,6 +4,8 @@ package band.tunnel.v1beta1; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; +import "band/feeds/v1beta1/feeds.proto"; + option go_package = "github.com/bandprotocol/chain/v3/x/tunnel/types"; option (gogoproto.equal_all) = true; @@ -27,3 +29,31 @@ message TSSPacketReceipt { (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/x/bandtss/types.SigningID" ]; } + +// IBCRoute is the type for an IBC route +message IBCRoute { + option (cosmos_proto.implements_interface) = "Route"; + + // channel_id is the IBC channel ID + string channel_id = 1 [(gogoproto.customname) = "ChannelID"]; +} + +// IBCPacketReceipt represents a receipt for a IBC packet and implements the PacketReceiptI interface. +message IBCPacketReceipt { + option (cosmos_proto.implements_interface) = "PacketContentI"; + + // sequence is representing the sequence of the IBC packet. + uint64 sequence = 1; +} + +// TunnelPricesPacketData represents the IBC packet payload for the tunnel packet. +message TunnelPricesPacketData { + // tunnel_id is the tunnel ID + uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"]; + // sequence is representing the sequence of the tunnel packet. + uint64 sequence = 2; + // prices is the list of prices information from feeds module. + repeated band.feeds.v1beta1.Price prices = 3 [(gogoproto.nullable) = false]; + // created_at is the timestamp when the packet is created + int64 created_at = 4; +} diff --git a/scripts/tunnel/create_ibc_tunnel.sh b/scripts/tunnel/create_ibc_tunnel.sh new file mode 100644 index 000000000..9a3474fb4 --- /dev/null +++ b/scripts/tunnel/create_ibc_tunnel.sh @@ -0,0 +1 @@ +bandd tx tunnel create-tunnel ibc channel-0 1 1uband 120 ./scripts/tunnel/signal_deviations.json --from requester --keyring-backend test --gas-prices 0.0025uband -y --chain-id bandchain diff --git a/x/bandtss/keeper/keeper.go b/x/bandtss/keeper/keeper.go index 7c0f34d67..dda170f06 100644 --- a/x/bandtss/keeper/keeper.go +++ b/x/bandtss/keeper/keeper.go @@ -56,6 +56,11 @@ func NewKeeper( } } +// GetAuthority returns the x/bandtss module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + // GetBandtssAccount returns the bandtss ModuleAccount func (k Keeper) GetBandtssAccount(ctx sdk.Context) sdk.ModuleAccountI { return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) diff --git a/x/bandtss/keeper/msg_server.go b/x/bandtss/keeper/msg_server.go index a32e70e56..f251e2bdb 100644 --- a/x/bandtss/keeper/msg_server.go +++ b/x/bandtss/keeper/msg_server.go @@ -27,8 +27,8 @@ func (k msgServer) TransitionGroup( goCtx context.Context, req *types.MsgTransitionGroup, ) (*types.MsgTransitionGroupResponse, error) { - if k.authority != req.Authority { - return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.authority, req.Authority) + if k.Keeper.GetAuthority() != req.Authority { + return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.Keeper.GetAuthority(), req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) @@ -43,12 +43,12 @@ func (k msgServer) TransitionGroup( } // validate transition duration - if err := k.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { + if err := k.Keeper.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { return nil, err } // validate if transition is in progress - if err := k.ValidateTransitionInProgress(ctx); err != nil { + if err := k.Keeper.ValidateTransitionInProgress(ctx); err != nil { return nil, err } @@ -63,13 +63,13 @@ func (k msgServer) TransitionGroup( } // set new group transition - transition, err := k.SetNewGroupTransition(ctx, groupID, req.ExecTime, false) + transition, err := k.Keeper.SetNewGroupTransition(ctx, groupID, req.ExecTime, false) if err != nil { return nil, err } // emit an event for the group transition. - attrs := k.ExtractEventAttributesFromTransition(transition) + attrs := k.Keeper.ExtractEventAttributesFromTransition(transition) ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeGroupTransition, attrs...)) return &types.MsgTransitionGroupResponse{}, nil @@ -81,23 +81,23 @@ func (k msgServer) ForceTransitionGroup( goCtx context.Context, req *types.MsgForceTransitionGroup, ) (*types.MsgForceTransitionGroupResponse, error) { - if k.authority != req.Authority { - return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.authority, req.Authority) + if k.Keeper.GetAuthority() != req.Authority { + return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.Keeper.GetAuthority(), req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) // validate transition duration - if err := k.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { + if err := k.Keeper.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { return nil, err } // validate if transition is in progress - if err := k.ValidateTransitionInProgress(ctx); err != nil { + if err := k.Keeper.ValidateTransitionInProgress(ctx); err != nil { return nil, err } // validate incoming group - currentGroupID := k.GetCurrentGroup(ctx).GroupID + currentGroupID := k.Keeper.GetCurrentGroup(ctx).GroupID if currentGroupID == req.IncomingGroupID { return nil, types.ErrInvalidGroupID.Wrap("incoming group is the same as the current group") } @@ -111,18 +111,18 @@ func (k msgServer) ForceTransitionGroup( } // add members from new group. - if err := k.AddMembers(ctx, req.IncomingGroupID); err != nil { + if err := k.Keeper.AddMembers(ctx, req.IncomingGroupID); err != nil { return nil, err } // set new group transition - transition, err := k.SetNewGroupTransition(ctx, req.IncomingGroupID, req.ExecTime, true) + transition, err := k.Keeper.SetNewGroupTransition(ctx, req.IncomingGroupID, req.ExecTime, true) if err != nil { return nil, err } // emit an event for the group transition. - attrs := k.ExtractEventAttributesFromTransition(transition) + attrs := k.Keeper.ExtractEventAttributesFromTransition(transition) ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeGroupTransition, attrs...)) return &types.MsgForceTransitionGroupResponse{}, nil @@ -149,7 +149,7 @@ func (k msgServer) RequestSignature( } // Execute the handler to process the request. - _, err = k.CreateDirectSigningRequest(ctx, content, req.Memo, feePayer, req.FeeLimit) + _, err = k.Keeper.CreateDirectSigningRequest(ctx, content, req.Memo, feePayer, req.FeeLimit) if err != nil { return nil, err } @@ -166,7 +166,7 @@ func (k msgServer) Activate(goCtx context.Context, msg *types.MsgActivate) (*typ return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid sender address: %s", err) } - if err = k.ActivateMember(ctx, sender, msg.GroupID); err != nil { + if err = k.Keeper.ActivateMember(ctx, sender, msg.GroupID); err != nil { return nil, err } @@ -174,11 +174,11 @@ func (k msgServer) Activate(goCtx context.Context, msg *types.MsgActivate) (*typ } // UpdateParams update the parameter of the module. -func (k Keeper) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, req *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { + if k.Keeper.GetAuthority() != req.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", k.authority, @@ -187,7 +187,7 @@ func (k Keeper) UpdateParams( } ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.SetParams(ctx, req.Params); err != nil { + if err := k.Keeper.SetParams(ctx, req.Params); err != nil { return nil, err } diff --git a/x/feeds/keeper/msg_server.go b/x/feeds/keeper/msg_server.go index 805745d57..a72f0074f 100644 --- a/x/feeds/keeper/msg_server.go +++ b/x/feeds/keeper/msg_server.go @@ -24,7 +24,7 @@ func NewMsgServerImpl(k Keeper) types.MsgServer { } // Vote votes signals. -func (ms msgServer) Vote( +func (k msgServer) Vote( goCtx context.Context, msg *types.MsgVote, ) (*types.MsgVoteResponse, error) { @@ -36,7 +36,7 @@ func (ms msgServer) Vote( return nil, err } - maxCurrentFeeds := ms.GetParams(ctx).MaxCurrentFeeds + maxCurrentFeeds := k.Keeper.GetParams(ctx).MaxCurrentFeeds // check if the number of submitted signals exceeds the maximum allowed feeds if uint64(len(msg.Signals)) > maxCurrentFeeds { @@ -47,13 +47,13 @@ func (ms msgServer) Vote( } // lock the voter's power equal to the sum of the signal powers - err = ms.LockVoterPower(ctx, voter, msg.Signals) + err = k.Keeper.LockVoterPower(ctx, voter, msg.Signals) if err != nil { return nil, err } // RegisterNewSignals deletes previous signals and registers new signals then returns feed power differences - signalIDToPowerDiff := ms.UpdateVoteAndReturnPowerDiff(ctx, voter, msg.Signals) + signalIDToPowerDiff := k.Keeper.UpdateVoteAndReturnPowerDiff(ctx, voter, msg.Signals) // sort keys to guarantee order of signalIDToPowerDiff iteration keys := make([]string, 0, len(signalIDToPowerDiff)) @@ -68,7 +68,7 @@ func (ms msgServer) Vote( powerDiff := signalIDToPowerDiff[signalID] // retrieve the total power of the current signal ID from the store - signalTotalPower, err := ms.GetSignalTotalPower(ctx, signalID) + signalTotalPower, err := k.Keeper.GetSignalTotalPower(ctx, signalID) if err != nil { // initialize a new signal with zero power if the signal ID does not exist signalTotalPower = types.NewSignal( @@ -86,7 +86,7 @@ func (ms msgServer) Vote( } // save the updated signal total power back to the store - ms.SetSignalTotalPower(ctx, signalTotalPower) + k.Keeper.SetSignalTotalPower(ctx, signalTotalPower) } // return an empty response indicating success @@ -94,7 +94,7 @@ func (ms msgServer) Vote( } // SubmitSignalPrices submits new validator prices. -func (ms msgServer) SubmitSignalPrices( +func (k msgServer) SubmitSignalPrices( goCtx context.Context, msg *types.MsgSubmitSignalPrices, ) (*types.MsgSubmitSignalPricesResponse, error) { @@ -102,8 +102,8 @@ func (ms msgServer) SubmitSignalPrices( blockTime := ctx.BlockTime().Unix() blockHeight := ctx.BlockHeight() - params := ms.GetParams(ctx) - currentFeeds := ms.GetCurrentFeeds(ctx) + params := k.Keeper.GetParams(ctx) + currentFeeds := k.Keeper.GetCurrentFeeds(ctx) // check if the number of signal prices exceeds the length of current feeds if len(msg.SignalPrices) > len(currentFeeds.Feeds) { @@ -116,7 +116,7 @@ func (ms msgServer) SubmitSignalPrices( } // check if the validator is required to send prices - if err := ms.ValidateValidatorRequiredToSend(ctx, val); err != nil { + if err := k.Keeper.ValidateValidatorRequiredToSend(ctx, val); err != nil { return nil, err } @@ -137,7 +137,7 @@ func (ms msgServer) SubmitSignalPrices( newValidatorPrices := make([]types.ValidatorPrice, len(currentFeedsMap)) // fill new validator latest price with latest submitted price - prevValPrices, err := ms.GetValidatorPriceList(ctx, val) + prevValPrices, err := k.Keeper.GetValidatorPriceList(ctx, val) if err == nil { for _, p := range prevValPrices.ValidatorPrices { idx, ok := currentFeedsMap[p.SignalID] @@ -171,7 +171,7 @@ func (ms msgServer) SubmitSignalPrices( emitEventSubmitSignalPrice(ctx, val, newValidatorPrices[idx]) } - if err := ms.SetValidatorPriceList(ctx, val, newValidatorPrices); err != nil { + if err := k.Keeper.SetValidatorPriceList(ctx, val, newValidatorPrices); err != nil { return nil, err } @@ -179,14 +179,14 @@ func (ms msgServer) SubmitSignalPrices( } // UpdateReferenceSourceConfig updates reference source configuration. -func (ms msgServer) UpdateReferenceSourceConfig( +func (k msgServer) UpdateReferenceSourceConfig( goCtx context.Context, msg *types.MsgUpdateReferenceSourceConfig, ) (*types.MsgUpdateReferenceSourceConfigResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // check if the request is from the admin - admin := ms.GetParams(ctx).Admin + admin := k.Keeper.GetParams(ctx).Admin if admin != msg.Admin { return nil, types.ErrInvalidSigner.Wrapf( "invalid admin; expected %s, got %s", @@ -196,7 +196,7 @@ func (ms msgServer) UpdateReferenceSourceConfig( } // update the reference source configuration - if err := ms.SetReferenceSourceConfig(ctx, msg.ReferenceSourceConfig); err != nil { + if err := k.Keeper.SetReferenceSourceConfig(ctx, msg.ReferenceSourceConfig); err != nil { return nil, err } @@ -206,23 +206,23 @@ func (ms msgServer) UpdateReferenceSourceConfig( } // UpdateParams updates the feeds module params. -func (ms msgServer) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, msg *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // check if the request is from the authority - if ms.GetAuthority() != msg.Authority { + if k.Keeper.GetAuthority() != msg.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - ms.GetAuthority(), + k.Keeper.GetAuthority(), msg.Authority, ) } // update the parameters - if err := ms.SetParams(ctx, msg.Params); err != nil { + if err := k.Keeper.SetParams(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/oracle/ibc_module.go b/x/oracle/ibc_module.go index ca7dbf72c..02a2766c6 100644 --- a/x/oracle/ibc_module.go +++ b/x/oracle/ibc_module.go @@ -143,7 +143,7 @@ func (im IBCModule) OnChanOpenAck( ctx sdk.Context, portID, channelID string, - _ string, + counterpartyChannelID string, counterpartyVersion string, ) error { if counterpartyVersion != types.Version { diff --git a/x/restake/keeper/msg_server.go b/x/restake/keeper/msg_server.go index 476a5fd37..2a0bbdd56 100644 --- a/x/restake/keeper/msg_server.go +++ b/x/restake/keeper/msg_server.go @@ -35,7 +35,7 @@ func (k msgServer) Stake( // check if all coins are allowed denom coins. allowedDenom := make(map[string]bool) - for _, denom := range k.GetParams(ctx).AllowedDenoms { + for _, denom := range k.Keeper.GetParams(ctx).AllowedDenoms { allowedDenom[denom] = true } @@ -50,9 +50,9 @@ func (k msgServer) Stake( return nil, err } - stake := k.GetStake(ctx, addr) + stake := k.Keeper.GetStake(ctx, addr) stake.Coins = stake.Coins.Add(msg.Coins...) - k.SetStake(ctx, stake) + k.Keeper.SetStake(ctx, stake) ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -79,25 +79,25 @@ func (k msgServer) Unstake( // reduce staked coins. return error if unstake more than staked coins var isNeg bool - stake := k.GetStake(ctx, addr) + stake := k.Keeper.GetStake(ctx, addr) stake.Coins, isNeg = stake.Coins.SafeSub(msg.Coins...) if isNeg { return nil, types.ErrStakeNotEnough } if !stake.Coins.IsZero() { - k.SetStake(ctx, stake) + k.Keeper.SetStake(ctx, stake) } else { - k.DeleteStake(ctx, addr) + k.Keeper.DeleteStake(ctx, addr) } - totalPower, err := k.GetTotalPower(ctx, addr) + totalPower, err := k.Keeper.GetTotalPower(ctx, addr) if err != nil { return nil, err } // check if total power is still more than locked power after unstaking. - if !k.isValidPower(ctx, addr, totalPower) { + if !k.Keeper.isValidPower(ctx, addr, totalPower) { return nil, types.ErrUnableToUnstake.Wrap("power is locked") } @@ -124,15 +124,15 @@ func (k msgServer) UpdateParams( ) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if k.GetAuthority() != req.Authority { + if k.Keeper.GetAuthority() != req.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - k.GetAuthority(), + k.Keeper.GetAuthority(), req.Authority, ) } - if err := k.SetParams(ctx, req.Params); err != nil { + if err := k.Keeper.SetParams(ctx, req.Params); err != nil { return nil, err } diff --git a/x/tss/keeper/msg_server.go b/x/tss/keeper/msg_server.go index b4ae307b7..699a1a54e 100644 --- a/x/tss/keeper/msg_server.go +++ b/x/tss/keeper/msg_server.go @@ -37,7 +37,7 @@ func (k msgServer) SubmitDKGRound1( memberID := req.Round1Info.MemberID // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } @@ -46,12 +46,12 @@ func (k msgServer) SubmitDKGRound1( } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check previous submit - if k.HasRound1Info(ctx, groupID, req.Round1Info.MemberID) { + if k.Keeper.HasRound1Info(ctx, groupID, req.Round1Info.MemberID) { return nil, types.ErrMemberAlreadySubmit.Wrapf( "memberID %d in group ID %d already submit round 1 message", memberID, @@ -59,17 +59,17 @@ func (k msgServer) SubmitDKGRound1( ) } - if err := k.ValidateRound1Info(ctx, group, req.Round1Info); err != nil { + if err := k.Keeper.ValidateRound1Info(ctx, group, req.Round1Info); err != nil { return nil, err } // Add commits to calculate accumulated commits for each index - if err = k.AddCoefficientCommits(ctx, groupID, req.Round1Info.CoefficientCommits); err != nil { + if err = k.Keeper.AddCoefficientCommits(ctx, groupID, req.Round1Info.CoefficientCommits); err != nil { return nil, err } // Add round 1 info - k.AddRound1Info(ctx, groupID, req.Round1Info) + k.Keeper.AddRound1Info(ctx, groupID, req.Round1Info) ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -85,9 +85,9 @@ func (k msgServer) SubmitDKGRound1( ) // Add to the pending process group if members submit their information. - count := k.GetRound1InfoCount(ctx, groupID) + count := k.Keeper.GetRound1InfoCount(ctx, groupID) if count == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgSubmitDKGRound1Response{}, nil @@ -107,7 +107,7 @@ func (k msgServer) SubmitDKGRound2( memberID := req.Round2Info.MemberID // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } @@ -116,12 +116,12 @@ func (k msgServer) SubmitDKGRound2( } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check previous submit - if k.HasRound2Info(ctx, groupID, memberID) { + if k.Keeper.HasRound2Info(ctx, groupID, memberID) { return nil, types.ErrMemberAlreadySubmit.Wrapf( "memberID %d in group ID %d already submit round 2 message", memberID, @@ -135,12 +135,12 @@ func (k msgServer) SubmitDKGRound2( } // Update member public key of the group. - if err := k.UpdateMemberPubKey(ctx, groupID, memberID); err != nil { + if err := k.Keeper.UpdateMemberPubKey(ctx, groupID, memberID); err != nil { return nil, err } // Add round 2 info - k.AddRound2Info(ctx, groupID, req.Round2Info) + k.Keeper.AddRound2Info(ctx, groupID, req.Round2Info) ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -153,9 +153,9 @@ func (k msgServer) SubmitDKGRound2( ) // Add to the pending process group if members submit their information. - count := k.GetRound2InfoCount(ctx, groupID) + count := k.Keeper.GetRound2InfoCount(ctx, groupID) if count == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgSubmitDKGRound2Response{}, nil @@ -170,7 +170,7 @@ func (k msgServer) Complain(goCtx context.Context, req *types.MsgComplain) (*typ memberID := req.Complaints[0].Complainant // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } @@ -179,19 +179,19 @@ func (k msgServer) Complain(goCtx context.Context, req *types.MsgComplain) (*typ } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check already confirm or complain - if k.HasConfirm(ctx, groupID, memberID) { + if k.Keeper.HasConfirm(ctx, groupID, memberID) { return nil, types.ErrMemberAlreadySubmit.Wrapf( "memberID %d in group ID %d already submit confirm message", memberID, groupID, ) } - if k.HasComplaintsWithStatus(ctx, groupID, memberID) { + if k.Keeper.HasComplaintsWithStatus(ctx, groupID, memberID) { return nil, types.ErrMemberAlreadySubmit.Wrapf( "memberID %d in group ID %d already submit complaint message", memberID, @@ -200,21 +200,21 @@ func (k msgServer) Complain(goCtx context.Context, req *types.MsgComplain) (*typ } // Verify complaint if fail to verify, mark complainant as malicious instead. - complaintsWithStatus, err := k.ProcessComplaint(ctx, req.Complaints, groupID, req.Sender) + complaintsWithStatus, err := k.Keeper.ProcessComplaint(ctx, req.Complaints, groupID, req.Sender) if err != nil { return nil, err } // Add complain with status - k.AddComplaintsWithStatus(ctx, groupID, types.ComplaintsWithStatus{ + k.Keeper.AddComplaintsWithStatus(ctx, groupID, types.ComplaintsWithStatus{ MemberID: memberID, ComplaintsWithStatus: complaintsWithStatus, }) // Add to the pending process group if everyone sends confirm or complain already - confirmComplainCount := k.GetConfirmComplainCount(ctx, groupID) + confirmComplainCount := k.Keeper.GetConfirmComplainCount(ctx, groupID) if confirmComplainCount == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgComplainResponse{}, nil @@ -233,7 +233,7 @@ func (k msgServer) Confirm( memberID := req.MemberID // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } @@ -242,19 +242,19 @@ func (k msgServer) Confirm( } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check already confirm or complain - if k.HasConfirm(ctx, groupID, memberID) { + if k.Keeper.HasConfirm(ctx, groupID, memberID) { return nil, types.ErrMemberAlreadySubmit.Wrapf( "memberID %d in group ID %d already submit confirm message", memberID, groupID, ) } - if k.HasComplaintsWithStatus(ctx, groupID, memberID) { + if k.Keeper.HasComplaintsWithStatus(ctx, groupID, memberID) { return nil, types.ErrMemberAlreadySubmit.Wrapf( "memberID %d in group ID %d already submit complaint message", memberID, @@ -263,12 +263,12 @@ func (k msgServer) Confirm( } // Verify OwnPubKeySig - if err := k.VerifyOwnPubKeySignature(ctx, groupID, memberID, req.OwnPubKeySig); err != nil { + if err := k.Keeper.VerifyOwnPubKeySignature(ctx, groupID, memberID, req.OwnPubKeySig); err != nil { return nil, err } // Add confirm - k.AddConfirm(ctx, groupID, types.NewConfirm(memberID, req.OwnPubKeySig)) + k.Keeper.AddConfirm(ctx, groupID, types.NewConfirm(memberID, req.OwnPubKeySig)) // Emit event confirm success ctx.EventManager().EmitEvent( @@ -282,9 +282,9 @@ func (k msgServer) Confirm( ) // Add to the pending process group if everyone sends confirm or complain already - confirmComplainCount := k.GetConfirmComplainCount(ctx, groupID) + confirmComplainCount := k.Keeper.GetConfirmComplainCount(ctx, groupID) if confirmComplainCount == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgConfirmResponse{}, nil @@ -302,7 +302,7 @@ func (k msgServer) SubmitDEs(goCtx context.Context, req *types.MsgSubmitDEs) (*t return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid account address: %s", err) } - err = k.EnqueueDEs(ctx, member, req.DEs) + err = k.Keeper.EnqueueDEs(ctx, member, req.DEs) if err != nil { return nil, err } @@ -321,7 +321,7 @@ func (k msgServer) SubmitSignature( ctx := sdk.UnwrapSDKContext(goCtx) // Get signing and check signing is still waiting for signature - signing, err := k.GetSigning(ctx, req.SigningID) + signing, err := k.Keeper.GetSigning(ctx, req.SigningID) if err != nil { return nil, err } @@ -331,7 +331,7 @@ func (k msgServer) SubmitSignature( ) } - sa, err := k.GetSigningAttempt(ctx, req.SigningID, signing.CurrentAttempt) + sa, err := k.Keeper.GetSigningAttempt(ctx, req.SigningID, signing.CurrentAttempt) if err != nil { return nil, err } @@ -346,7 +346,7 @@ func (k msgServer) SubmitSignature( } // Check member is already signed - if k.HasPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID) { + if k.Keeper.HasPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID) { return nil, types.ErrAlreadySigned.Wrapf( "member ID %d already signed on signing ID: %d", req.MemberID, @@ -385,12 +385,12 @@ func (k msgServer) SubmitSignature( } // Add partial signature - k.AddPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID, req.Signature) + k.Keeper.AddPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID, req.Signature) // Check if the threshold is met, if so, add to the pending process signing. - sigCount := k.GetPartialSignatureCount(ctx, req.SigningID, sa.Attempt) + sigCount := k.Keeper.GetPartialSignatureCount(ctx, req.SigningID, sa.Attempt) if sigCount == uint64(len(assignedMembers)) { - k.AddPendingProcessSigning(ctx, req.SigningID) + k.Keeper.AddPendingProcessSigning(ctx, req.SigningID) } ctx.EventManager().EmitEvent( @@ -411,20 +411,20 @@ func (k msgServer) SubmitSignature( } // UpdateParams update parameter of the module. -func (k Keeper) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, req *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { + if k.Keeper.GetAuthority() != req.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - k.authority, + k.Keeper.GetAuthority(), req.Authority, ) } ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.SetParams(ctx, req.Params); err != nil { + if err := k.Keeper.SetParams(ctx, req.Params); err != nil { return nil, err } diff --git a/x/tunnel/client/cli/tx.go b/x/tunnel/client/cli/tx.go index 353978959..c3c495ea0 100644 --- a/x/tunnel/client/cli/tx.go +++ b/x/tunnel/client/cli/tx.go @@ -46,7 +46,7 @@ func GetTxCmdCreateTunnel() *cobra.Command { } // add create tunnel subcommands - txCmd.AddCommand(GetTxCmdCreateTSSTunnel()) + txCmd.AddCommand(GetTxCmdCreateTSSTunnel(), GetTxCmdCreateIBCTunnel()) return txCmd } @@ -104,6 +104,57 @@ func GetTxCmdCreateTSSTunnel() *cobra.Command { return cmd } +func GetTxCmdCreateIBCTunnel() *cobra.Command { + cmd := &cobra.Command{ + Use: "ibc [channel-id] [encoder] [initial-deposit] [interval] [signalInfos-json-file]", + Short: "Create a new IBC tunnel", + Args: cobra.ExactArgs(5), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + encoder, err := strconv.ParseInt(args[1], 10, 32) + if err != nil { + return err + } + + initialDeposit, err := sdk.ParseCoinsNormalized(args[2]) + if err != nil { + return err + } + + interval, err := strconv.ParseUint(args[3], 10, 64) + if err != nil { + return err + } + + signalInfos, err := parseSignalDeviations(args[4]) + if err != nil { + return err + } + + msg, err := types.NewMsgCreateIBCTunnel( + signalInfos.ToSignalDeviations(), + interval, + args[0], + feedstypes.Encoder(encoder), + initialDeposit, + clientCtx.GetFromAddress(), + ) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + func GetTxCmdUpdateAndResetTunnel() *cobra.Command { cmd := &cobra.Command{ Use: "update-and-reset-tunnel [tunnel-id] [interval] [signalDeviations-json-file] ", diff --git a/x/tunnel/ibc_module.go b/x/tunnel/ibc_module.go new file mode 100644 index 000000000..a3ce72660 --- /dev/null +++ b/x/tunnel/ibc_module.go @@ -0,0 +1,298 @@ +package tunnel + +import ( + "math" + "strings" + + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bandprotocol/chain/v3/x/tunnel/keeper" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +var ( + _ porttypes.IBCModule = (*IBCModule)(nil) + _ porttypes.PacketDataUnmarshaler = (*IBCModule)(nil) + _ porttypes.UpgradableModule = (*IBCModule)(nil) +) + +// IBCModule implements the ICS26 interface for tunnel given the tunnel keeper. +type IBCModule struct { + keeper keeper.Keeper +} + +// NewIBCModule creates a new IBCModule given the keeper +func NewIBCModule(keeper keeper.Keeper) IBCModule { + return IBCModule{ + keeper: keeper, + } +} + +// OnChanOpenInit implements the IBCModule interface +func (im IBCModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + err := ValidateTunnelChannelParams(ctx, im.keeper, order, portID, channelID) + if err != nil { + return "", err + } + + // If version is empty, set it to the current version + if strings.TrimSpace(version) == "" { + version = types.Version + } + + if version != types.Version { + return "", types.ErrInvalidVersion.Wrapf("got %s, expected %s", version, types.Version) + } + + // openInit must claim the channelCapability that IBC passes into the callback + if err := im.keeper.ClaimCapability(ctx, channelCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + + return version, nil +} + +// OnChanOpenTry implements the IBCModule interface +func (im IBCModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + err := ValidateTunnelChannelParams(ctx, im.keeper, order, portID, channelID) + if err != nil { + return "", err + } + + if counterpartyVersion != types.Version { + return "", types.ErrInvalidVersion.Wrapf( + "invalid counterparty version: got: %s, expected %s", + counterpartyVersion, + types.Version, + ) + } + + // module may have already claimed capability in OnChanOpenInit in the case of crossing hellos + // (ie chainA and chainB both call ChanOpenInit before one of them calls ChanOpenTry) + // If module can already authenticate the capability then module already owns it so we don't need to claim + // Otherwise, module does not have channel capability and we must claim it from IBC + if !im.keeper.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) { + // Only claim channel capability passed back by IBC module if we do not already own it + if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + } + + return types.Version, nil +} + +// OnChanOpenAck implements the IBCModule interface +func (im IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyChannelID string, + counterpartyVersion string, +) error { + if counterpartyVersion != types.Version { + return types.ErrInvalidVersion.Wrapf( + "invalid counterparty version: %s, expected %s", + counterpartyVersion, + types.Version, + ) + } + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (im IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnChanCloseInit implements the IBCModule interface +func (im IBCModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // Disallow user-initiated channel closing for tunnel channels + return sdkerrors.ErrInvalidRequest.Wrap("user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (im IBCModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface +func (im IBCModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + // Disallow incoming packets for tunnel channels + ack := channeltypes.NewErrorAcknowledgement( + sdkerrors.ErrInvalidRequest.Wrap("tunnel does not accept incoming packets"), + ) + return ack +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (im IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + // do nothing for out-going packet + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (im IBCModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + // do nothing for out-going packet + return nil +} + +// OnChanUpgradeInit implements the IBCModule interface +func (im IBCModule) OnChanUpgradeInit( + ctx sdk.Context, + portID, channelID string, + proposedOrder channeltypes.Order, + proposedConnectionHops []string, + proposedVersion string, +) (string, error) { + if err := ValidateTunnelChannelParams(ctx, im.keeper, proposedOrder, portID, channelID); err != nil { + return "", err + } + + if proposedVersion != types.Version { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, proposedVersion) + } + + return proposedVersion, nil +} + +// OnChanUpgradeTry implements the IBCModule interface +func (im IBCModule) OnChanUpgradeTry( + ctx sdk.Context, + portID, channelID string, + proposedOrder channeltypes.Order, + proposedConnectionHops []string, + counterpartyVersion string, +) (string, error) { + if err := ValidateTunnelChannelParams(ctx, im.keeper, proposedOrder, portID, channelID); err != nil { + return "", err + } + + if counterpartyVersion != types.Version { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, counterpartyVersion) + } + + return counterpartyVersion, nil +} + +// OnChanUpgradeAck implements the IBCModule interface +func (IBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { + if counterpartyVersion != types.Version { + return errorsmod.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, counterpartyVersion) + } + + return nil +} + +// OnChanUpgradeOpen implements the IBCModule interface +func (IBCModule) OnChanUpgradeOpen( + ctx sdk.Context, + portID, channelID string, + proposedOrder channeltypes.Order, + proposedConnectionHops []string, + proposedVersion string, +) { +} + +// UnmarshalPacketData attempts to unmarshal the provided packet data bytes +// into a TunnelPricesPacketData. This function implements the optional +// PacketDataUnmarshaler interface required for ADR 008 support. +func (IBCModule) UnmarshalPacketData(bz []byte) (interface{}, error) { + var packetData types.TunnelPricesPacketData + if err := types.ModuleCdc.UnmarshalJSON(bz, &packetData); err != nil { + return nil, err + } + + return packetData, nil +} + +// ValidateTunnelChannelParams does validation of a newly created tunnel channel. A tunnel +// channel must be ORDERED, use the correct port (by default 'tunnel'), and use the current +// supported version. Only 2^32 channels are allowed to be created. +func ValidateTunnelChannelParams( + ctx sdk.Context, + keeper keeper.Keeper, + order channeltypes.Order, + portID string, + channelID string, +) error { + // NOTE: for escrow address security only 2^32 channels are allowed to be created + // Issue: https://github.com/cosmos/cosmos-sdk/issues/7737 + channelSequence, err := channeltypes.ParseChannelSequence(channelID) + if err != nil { + return err + } + if channelSequence > uint64(math.MaxUint32) { + return types.ErrMaxTunnelChannels.Wrapf( + "channel sequence %d is greater than max allowed tunnel channels %d", + channelSequence, + uint64(math.MaxUint32), + ) + } + if order != channeltypes.ORDERED { + return channeltypes.ErrInvalidChannelOrdering.Wrapf( + "expected %s channel, got %s", + channeltypes.ORDERED, + order, + ) + } + + // Require portID is the portID tunnel module is bound to + boundPort := keeper.GetPort(ctx) + if boundPort != portID { + return porttypes.ErrInvalidPort.Wrapf("invalid port: %s, expected %s", portID, boundPort) + } + + return nil +} diff --git a/x/tunnel/ibc_module_test.go b/x/tunnel/ibc_module_test.go new file mode 100644 index 000000000..4629de174 --- /dev/null +++ b/x/tunnel/ibc_module_test.go @@ -0,0 +1,63 @@ +package tunnel_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + "github.com/bandprotocol/chain/v3/x/tunnel" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func TestPacketDataUnmarshalerInterface(t *testing.T) { + var ( + data []byte + expPacketData types.TunnelPricesPacketData + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "invalid packet data", + func() { + data = []byte("invalid packet data") + }, + false, + }, + { + "all good", + func() { + expPacketData = types.TunnelPricesPacketData{ + TunnelID: 1, + Sequence: 1, + Prices: []feedstypes.Price{ + {Status: feedstypes.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, SignalID: "BTC", Price: 50000}, + }, + CreatedAt: 1633024800, + } + data = expPacketData.GetBytes() + }, + true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + tc.malleate() + + packetData, err := tunnel.IBCModule{}.UnmarshalPacketData(data) + + if tc.expPass { + require.NoError(t, err) + require.Equal(t, expPacketData, packetData) + } else { + require.Error(t, err) + require.Nil(t, packetData) + } + }) + } +} diff --git a/x/tunnel/keeper/genesis.go b/x/tunnel/keeper/genesis.go index c85d7df2a..0ec18744d 100644 --- a/x/tunnel/keeper/genesis.go +++ b/x/tunnel/keeper/genesis.go @@ -33,6 +33,18 @@ func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState) { } } + k.SetPort(ctx, types.PortID) + // only try to bind to port if it is not already bound, since we may already own + // port capability from capability InitGenesis + if !k.IsBound(ctx, types.PortID) { + // tunnel module binds to the tunnel port on InitChain + // and claims the returned capability + err := k.BindPort(ctx, types.PortID) + if err != nil { + panic(fmt.Sprintf("could not claim port capability: %v", err)) + } + } + // set the deposits var totalDeposits sdk.Coins for _, deposit := range data.Deposits { diff --git a/x/tunnel/keeper/genesis_test.go b/x/tunnel/keeper/genesis_test.go index c56a22a45..50c3fd599 100644 --- a/x/tunnel/keeper/genesis_test.go +++ b/x/tunnel/keeper/genesis_test.go @@ -3,6 +3,9 @@ package keeper_test import ( "go.uber.org/mock/gomock" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,6 +19,13 @@ import ( func (s *KeeperTestSuite) TestInitExportGenesis() { ctx, k := s.ctx, s.keeper + s.scopedKeeper.EXPECT().GetCapability(ctx, host.PortPath(types.PortID)).Return(nil, false).AnyTimes() + s.scopedKeeper.EXPECT(). + ClaimCapability(ctx, &capabilitytypes.Capability{Index: 0}, host.PortPath(types.PortID)). + Return(nil). + AnyTimes() + s.portKeeper.EXPECT().BindPort(ctx, types.PortID).Return(&capabilitytypes.Capability{Index: 0}).AnyTimes() + s.accountKeeper.EXPECT(). GetModuleAccount(ctx, gomock.Any()). Return(sdk.AccountI(&authtypes.ModuleAccount{ diff --git a/x/tunnel/keeper/keeper.go b/x/tunnel/keeper/keeper.go index ae10531dc..42ec95246 100644 --- a/x/tunnel/keeper/keeper.go +++ b/x/tunnel/keeper/keeper.go @@ -3,6 +3,9 @@ package keeper import ( "fmt" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -20,6 +23,9 @@ type Keeper struct { bankKeeper types.BankKeeper feedsKeeper types.FeedsKeeper bandtssKeeper types.BandtssKeeper + ics4Wrapper types.ICS4Wrapper + portKeeper types.PortKeeper + scopedKeeper types.ScopedKeeper authority string } @@ -32,6 +38,9 @@ func NewKeeper( bankKeeper types.BankKeeper, feedsKeeper types.FeedsKeeper, bandtssKeeper types.BandtssKeeper, + ics4Wrapper types.ICS4Wrapper, + portKeeper types.PortKeeper, + scopedKeeper types.ScopedKeeper, authority string, ) Keeper { // ensure tunnel module account is set @@ -51,10 +60,54 @@ func NewKeeper( bankKeeper: bankKeeper, feedsKeeper: feedsKeeper, bandtssKeeper: bandtssKeeper, + ics4Wrapper: ics4Wrapper, + portKeeper: portKeeper, + scopedKeeper: scopedKeeper, authority: authority, } } +// GetAuthority returns the x/tunnel module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// IsBound checks if the module is already bound to the desired port +func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { + _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) + return ok +} + +// BindPort defines a wrapper function for the tunnel Keeper's function in +// order to expose it to module's InitGenesis function +func (k Keeper) BindPort(ctx sdk.Context, portID string) error { + cap := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, cap, host.PortPath(portID)) +} + +// GetPort returns the portID for the tunnel module. Used in ExportGenesis +func (k Keeper) GetPort(ctx sdk.Context) string { + store := ctx.KVStore(k.storeKey) + return string(store.Get(types.PortKey)) +} + +// SetPort sets the portID for the tunnel module. Used in InitGenesis +func (k Keeper) SetPort(ctx sdk.Context, portID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.PortKey, []byte(portID)) +} + +// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function +func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { + return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) +} + +// ClaimCapability allows the tunnel module that can claim a capability that IBC module +// passes to it +func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, cap, name) +} + // GetTunnelAccount returns the tunnel ModuleAccount func (k Keeper) GetTunnelAccount(ctx sdk.Context) sdk.ModuleAccountI { return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) diff --git a/x/tunnel/keeper/keeper_packet.go b/x/tunnel/keeper/keeper_packet.go index 4d30f84c8..96ad54800 100644 --- a/x/tunnel/keeper/keeper_packet.go +++ b/x/tunnel/keeper/keeper_packet.go @@ -213,6 +213,8 @@ func (k Keeper) SendPacket(ctx sdk.Context, packet types.Packet) error { switch r := route.(type) { case *types.TSSRoute: receipt, err = k.SendTSSPacket(ctx, r, packet) + case *types.IBCRoute: + receipt, err = k.SendIBCPacket(ctx, r, packet, tunnel.Interval) default: return types.ErrInvalidRoute.Wrapf("no route found for tunnel ID: %d", tunnel.ID) } diff --git a/x/tunnel/keeper/keeper_packet_ibc.go b/x/tunnel/keeper/keeper_packet_ibc.go new file mode 100644 index 000000000..21d449cfb --- /dev/null +++ b/x/tunnel/keeper/keeper_packet_ibc.go @@ -0,0 +1,50 @@ +package keeper + +import ( + "time" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +// SendIBCPacket sends IBC packet +func (k Keeper) SendIBCPacket( + ctx sdk.Context, + route *types.IBCRoute, + packet types.Packet, + interval uint64, +) (types.PacketReceiptI, error) { + // retrieve the dynamic capability for this channel + channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(types.PortID, route.ChannelID)) + if !ok { + return nil, types.ErrChannelCapabilityNotFound + } + + // create the tunnel prices packet data bytes + packetBytes := types.NewTunnelPricesPacketData( + packet.TunnelID, + packet.Sequence, + packet.Prices, + packet.CreatedAt, + ).GetBytes() + + // send packet to IBC, authenticating with channelCap + sequence, err := k.ics4Wrapper.SendPacket( + ctx, + channelCap, + types.PortID, + route.ChannelID, + clienttypes.NewHeight(0, 0), + uint64(ctx.BlockTime().UnixNano())+interval*uint64(time.Second), + packetBytes, + ) + if err != nil { + return nil, err + } + + return types.NewIBCPacketReceipt(sequence), nil +} diff --git a/x/tunnel/keeper/keeper_packet_ibc_test.go b/x/tunnel/keeper/keeper_packet_ibc_test.go new file mode 100644 index 000000000..c39489446 --- /dev/null +++ b/x/tunnel/keeper/keeper_packet_ibc_test.go @@ -0,0 +1,40 @@ +package keeper_test + +import ( + "time" + + "go.uber.org/mock/gomock" + + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func (s *KeeperTestSuite) TestSendIBCPacket() { + ctx, k := s.ctx, s.keeper + + route := &types.IBCRoute{ + ChannelID: "channel-0", + } + packet := types.Packet{ + TunnelID: 1, + Sequence: 1, + Prices: []feedstypes.Price{}, + CreatedAt: time.Now().Unix(), + } + interval := uint64(60) + + s.scopedKeeper.EXPECT().GetCapability(ctx, gomock.Any()).Return(&capabilitytypes.Capability{}, true) + s.icsWrapper.EXPECT(). + SendPacket(ctx, gomock.Any(), types.PortID, route.ChannelID, clienttypes.NewHeight(0, 0), uint64(ctx.BlockTime().UnixNano())+interval*uint64(time.Second), gomock.Any()). + Return(uint64(1), nil) + + content, err := k.SendIBCPacket(ctx, route, packet, interval) + s.Require().NoError(err) + + packetReceipt, ok := content.(*types.IBCPacketReceipt) + s.Require().True(ok) + s.Require().Equal(uint64(1), packetReceipt.Sequence) +} diff --git a/x/tunnel/keeper/keeper_test.go b/x/tunnel/keeper/keeper_test.go index e02ddacf3..07fc7d12e 100644 --- a/x/tunnel/keeper/keeper_test.go +++ b/x/tunnel/keeper/keeper_test.go @@ -41,6 +41,9 @@ type KeeperTestSuite struct { bankKeeper *testutil.MockBankKeeper feedsKeeper *testutil.MockFeedsKeeper bandtssKeeper *testutil.MockBandtssKeeper + icsWrapper *testutil.MockICS4Wrapper + portKeeper *testutil.MockPortKeeper + scopedKeeper *testutil.MockScopedKeeper ctx sdk.Context authority sdk.AccAddress @@ -60,6 +63,9 @@ func (s *KeeperTestSuite) reset() { bankKeeper := testutil.NewMockBankKeeper(ctrl) feedsKeeper := testutil.NewMockFeedsKeeper(ctrl) bandtssKeeper := testutil.NewMockBandtssKeeper(ctrl) + icsWrapper := testutil.NewMockICS4Wrapper(ctrl) + portKeeper := testutil.NewMockPortKeeper(ctrl) + scopedKeeper := testutil.NewMockScopedKeeper(ctrl) authority := authtypes.NewModuleAddress(govtypes.ModuleName) @@ -72,6 +78,9 @@ func (s *KeeperTestSuite) reset() { bankKeeper, feedsKeeper, bandtssKeeper, + icsWrapper, + portKeeper, + scopedKeeper, authority.String(), ) s.queryServer = keeper.NewQueryServer(s.keeper) @@ -80,6 +89,10 @@ func (s *KeeperTestSuite) reset() { s.bankKeeper = bankKeeper s.feedsKeeper = feedsKeeper s.bandtssKeeper = bandtssKeeper + s.icsWrapper = icsWrapper + s.portKeeper = portKeeper + s.scopedKeeper = scopedKeeper + s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now().UTC()}) s.authority = authority diff --git a/x/tunnel/keeper/keeper_tunnel.go b/x/tunnel/keeper/keeper_tunnel.go index c8330976a..492733a5f 100644 --- a/x/tunnel/keeper/keeper_tunnel.go +++ b/x/tunnel/keeper/keeper_tunnel.go @@ -326,6 +326,8 @@ func (k Keeper) GetRouteFee(ctx sdk.Context, route types.RouteI) (sdk.Coins, err switch route.(type) { case *types.TSSRoute: return sdk.Coins{}, nil + case *types.IBCRoute: + return sdk.Coins{}, nil default: return sdk.Coins{}, types.ErrInvalidRoute } diff --git a/x/tunnel/keeper/msg_server.go b/x/tunnel/keeper/msg_server.go index d075668df..caa4b5917 100644 --- a/x/tunnel/keeper/msg_server.go +++ b/x/tunnel/keeper/msg_server.go @@ -24,13 +24,13 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } // CreateTunnel creates a new tunnel. -func (ms msgServer) CreateTunnel( +func (k msgServer) CreateTunnel( goCtx context.Context, msg *types.MsgCreateTunnel, ) (*types.MsgCreateTunnelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := ms.Keeper.GetParams(ctx) + params := k.Keeper.GetParams(ctx) // validate signal infos and interval if err := types.ValidateSignalDeviations(msg.SignalDeviations, params.MaxSignals, params.MaxDeviationBPS, params.MinDeviationBPS); err != nil { @@ -53,7 +53,7 @@ func (ms msgServer) CreateTunnel( } // add a new tunnel - tunnel, err := ms.Keeper.AddTunnel( + tunnel, err := k.Keeper.AddTunnel( ctx, route, msg.Encoder, @@ -67,7 +67,7 @@ func (ms msgServer) CreateTunnel( // Deposit the initial deposit to the tunnel if !msg.InitialDeposit.IsZero() { - if err := ms.Keeper.DepositToTunnel(ctx, tunnel.ID, creator, msg.InitialDeposit); err != nil { + if err := k.Keeper.DepositToTunnel(ctx, tunnel.ID, creator, msg.InitialDeposit); err != nil { return nil, err } } @@ -78,13 +78,13 @@ func (ms msgServer) CreateTunnel( } // UpdateAndResetTunnel edits a tunnel and reset latest price interval. -func (ms msgServer) UpdateAndResetTunnel( +func (k msgServer) UpdateAndResetTunnel( goCtx context.Context, msg *types.MsgUpdateAndResetTunnel, ) (*types.MsgUpdateAndResetTunnelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := ms.Keeper.GetParams(ctx) + params := k.Keeper.GetParams(ctx) // validate signal infos and interval if err := types.ValidateSignalDeviations(msg.SignalDeviations, params.MaxSignals, params.MaxDeviationBPS, params.MinDeviationBPS); err != nil { @@ -96,7 +96,7 @@ func (ms msgServer) UpdateAndResetTunnel( return nil, err } - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -105,7 +105,7 @@ func (ms msgServer) UpdateAndResetTunnel( return nil, types.ErrInvalidTunnelCreator.Wrapf("creator %s, tunnelID %d", msg.Creator, msg.TunnelID) } - err = ms.Keeper.UpdateAndResetTunnel(ctx, msg.TunnelID, msg.SignalDeviations, msg.Interval) + err = k.Keeper.UpdateAndResetTunnel(ctx, msg.TunnelID, msg.SignalDeviations, msg.Interval) if err != nil { return nil, err } @@ -114,13 +114,13 @@ func (ms msgServer) UpdateAndResetTunnel( } // Activate activates a tunnel. -func (ms msgServer) Activate( +func (k msgServer) Activate( goCtx context.Context, msg *types.MsgActivate, ) (*types.MsgActivateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -135,7 +135,7 @@ func (ms msgServer) Activate( return nil, types.ErrAlreadyActive.Wrapf("tunnelID %d", msg.TunnelID) } - if err := ms.Keeper.ActivateTunnel(ctx, msg.TunnelID); err != nil { + if err := k.Keeper.ActivateTunnel(ctx, msg.TunnelID); err != nil { return nil, err } @@ -143,13 +143,13 @@ func (ms msgServer) Activate( } // Deactivate deactivates a tunnel. -func (ms msgServer) Deactivate( +func (k msgServer) Deactivate( goCtx context.Context, msg *types.MsgDeactivate, ) (*types.MsgDeactivateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -162,7 +162,7 @@ func (ms msgServer) Deactivate( return nil, types.ErrAlreadyInactive.Wrapf("tunnelID %d", msg.TunnelID) } - if err := ms.Keeper.DeactivateTunnel(ctx, msg.TunnelID); err != nil { + if err := k.Keeper.DeactivateTunnel(ctx, msg.TunnelID); err != nil { return nil, err } @@ -170,13 +170,13 @@ func (ms msgServer) Deactivate( } // TriggerTunnel manually triggers a tunnel. -func (ms msgServer) TriggerTunnel( +func (k msgServer) TriggerTunnel( goCtx context.Context, msg *types.MsgTriggerTunnel, ) (*types.MsgTriggerTunnelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -193,7 +193,7 @@ func (ms msgServer) TriggerTunnel( return nil, types.ErrInactiveTunnel.Wrapf("tunnelID %d", msg.TunnelID) } - ok, err := ms.Keeper.HasEnoughFundToCreatePacket(ctx, tunnel.ID) + ok, err := k.Keeper.HasEnoughFundToCreatePacket(ctx, tunnel.ID) if err != nil { return nil, err } @@ -203,20 +203,20 @@ func (ms msgServer) TriggerTunnel( } signalIDs := tunnel.GetSignalIDs() - prices := ms.Keeper.feedsKeeper.GetPrices(ctx, signalIDs) + prices := k.Keeper.feedsKeeper.GetPrices(ctx, signalIDs) // create a new packet - packet, err := ms.CreatePacket(ctx, tunnel.ID, prices) + packet, err := k.Keeper.CreatePacket(ctx, tunnel.ID, prices) if err != nil { return nil, err } // send packet - if err := ms.SendPacket(ctx, packet); err != nil { + if err := k.Keeper.SendPacket(ctx, packet); err != nil { return nil, sdkerrors.Wrapf(err, "failed to create packet for tunnel %d", tunnel.ID) } - latestPrices, err := ms.GetLatestPrices(ctx, tunnel.ID) + latestPrices, err := k.Keeper.GetLatestPrices(ctx, tunnel.ID) if err != nil { return nil, err } @@ -224,7 +224,7 @@ func (ms msgServer) TriggerTunnel( // update latest price info. latestPrices.LastInterval = ctx.BlockTime().Unix() latestPrices.UpdatePrices(packet.Prices) - ms.SetLatestPrices(ctx, latestPrices) + k.Keeper.SetLatestPrices(ctx, latestPrices) ctx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeTriggerTunnel, @@ -236,7 +236,7 @@ func (ms msgServer) TriggerTunnel( } // DepositToTunnel adds deposit to the tunnel. -func (ms msgServer) DepositToTunnel( +func (k msgServer) DepositToTunnel( goCtx context.Context, msg *types.MsgDepositToTunnel, ) (*types.MsgDepositToTunnelResponse, error) { @@ -247,7 +247,7 @@ func (ms msgServer) DepositToTunnel( return nil, err } - if err := ms.Keeper.DepositToTunnel(ctx, msg.TunnelID, depositor, msg.Amount); err != nil { + if err := k.Keeper.DepositToTunnel(ctx, msg.TunnelID, depositor, msg.Amount); err != nil { return nil, err } @@ -255,7 +255,7 @@ func (ms msgServer) DepositToTunnel( } // WithdrawFromTunnel withdraws deposit from the tunnel. -func (ms msgServer) WithdrawFromTunnel( +func (k msgServer) WithdrawFromTunnel( goCtx context.Context, msg *types.MsgWithdrawFromTunnel, ) (*types.MsgWithdrawFromTunnelResponse, error) { @@ -267,7 +267,7 @@ func (ms msgServer) WithdrawFromTunnel( } // Withdraw the deposit from the tunnel - if err := ms.Keeper.WithdrawFromTunnel(ctx, msg.TunnelID, msg.Amount, withdrawer); err != nil { + if err := k.Keeper.WithdrawFromTunnel(ctx, msg.TunnelID, msg.Amount, withdrawer); err != nil { return nil, err } @@ -275,21 +275,21 @@ func (ms msgServer) WithdrawFromTunnel( } // UpdateParams updates the module params. -func (ms msgServer) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, msg *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if ms.authority != msg.Authority { + if k.Keeper.GetAuthority() != msg.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - ms.authority, + k.Keeper.GetAuthority(), msg.Authority, ) } - if err := ms.SetParams(ctx, msg.Params); err != nil { + if err := k.Keeper.SetParams(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/tunnel/testutil/expected_keepers_mocks.go b/x/tunnel/testutil/expected_keepers_mocks.go index 6f628647b..00ed28e3b 100644 --- a/x/tunnel/testutil/expected_keepers_mocks.go +++ b/x/tunnel/testutil/expected_keepers_mocks.go @@ -17,6 +17,8 @@ import ( types0 "github.com/bandprotocol/chain/v3/x/feeds/types" types1 "github.com/bandprotocol/chain/v3/x/tss/types" types2 "github.com/cosmos/cosmos-sdk/types" + types3 "github.com/cosmos/ibc-go/modules/capability/types" + types4 "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" gomock "go.uber.org/mock/gomock" ) @@ -204,6 +206,150 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) } +// MockICS4Wrapper is a mock of ICS4Wrapper interface. +type MockICS4Wrapper struct { + ctrl *gomock.Controller + recorder *MockICS4WrapperMockRecorder + isgomock struct{} +} + +// MockICS4WrapperMockRecorder is the mock recorder for MockICS4Wrapper. +type MockICS4WrapperMockRecorder struct { + mock *MockICS4Wrapper +} + +// NewMockICS4Wrapper creates a new mock instance. +func NewMockICS4Wrapper(ctrl *gomock.Controller) *MockICS4Wrapper { + mock := &MockICS4Wrapper{ctrl: ctrl} + mock.recorder = &MockICS4WrapperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockICS4Wrapper) EXPECT() *MockICS4WrapperMockRecorder { + return m.recorder +} + +// SendPacket mocks base method. +func (m *MockICS4Wrapper) SendPacket(ctx types2.Context, chanCap *types3.Capability, sourcePort, sourceChannel string, timeoutHeight types4.Height, timeoutTimestamp uint64, data []byte) (uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendPacket", ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SendPacket indicates an expected call of SendPacket. +func (mr *MockICS4WrapperMockRecorder) SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendPacket", reflect.TypeOf((*MockICS4Wrapper)(nil).SendPacket), ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) +} + +// MockPortKeeper is a mock of PortKeeper interface. +type MockPortKeeper struct { + ctrl *gomock.Controller + recorder *MockPortKeeperMockRecorder + isgomock struct{} +} + +// MockPortKeeperMockRecorder is the mock recorder for MockPortKeeper. +type MockPortKeeperMockRecorder struct { + mock *MockPortKeeper +} + +// NewMockPortKeeper creates a new mock instance. +func NewMockPortKeeper(ctrl *gomock.Controller) *MockPortKeeper { + mock := &MockPortKeeper{ctrl: ctrl} + mock.recorder = &MockPortKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPortKeeper) EXPECT() *MockPortKeeperMockRecorder { + return m.recorder +} + +// BindPort mocks base method. +func (m *MockPortKeeper) BindPort(ctx types2.Context, portID string) *types3.Capability { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BindPort", ctx, portID) + ret0, _ := ret[0].(*types3.Capability) + return ret0 +} + +// BindPort indicates an expected call of BindPort. +func (mr *MockPortKeeperMockRecorder) BindPort(ctx, portID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindPort", reflect.TypeOf((*MockPortKeeper)(nil).BindPort), ctx, portID) +} + +// MockScopedKeeper is a mock of ScopedKeeper interface. +type MockScopedKeeper struct { + ctrl *gomock.Controller + recorder *MockScopedKeeperMockRecorder + isgomock struct{} +} + +// MockScopedKeeperMockRecorder is the mock recorder for MockScopedKeeper. +type MockScopedKeeperMockRecorder struct { + mock *MockScopedKeeper +} + +// NewMockScopedKeeper creates a new mock instance. +func NewMockScopedKeeper(ctrl *gomock.Controller) *MockScopedKeeper { + mock := &MockScopedKeeper{ctrl: ctrl} + mock.recorder = &MockScopedKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockScopedKeeper) EXPECT() *MockScopedKeeperMockRecorder { + return m.recorder +} + +// AuthenticateCapability mocks base method. +func (m *MockScopedKeeper) AuthenticateCapability(ctx types2.Context, cap *types3.Capability, name string) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AuthenticateCapability", ctx, cap, name) + ret0, _ := ret[0].(bool) + return ret0 +} + +// AuthenticateCapability indicates an expected call of AuthenticateCapability. +func (mr *MockScopedKeeperMockRecorder) AuthenticateCapability(ctx, cap, name any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthenticateCapability", reflect.TypeOf((*MockScopedKeeper)(nil).AuthenticateCapability), ctx, cap, name) +} + +// ClaimCapability mocks base method. +func (m *MockScopedKeeper) ClaimCapability(ctx types2.Context, cap *types3.Capability, name string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ClaimCapability", ctx, cap, name) + ret0, _ := ret[0].(error) + return ret0 +} + +// ClaimCapability indicates an expected call of ClaimCapability. +func (mr *MockScopedKeeperMockRecorder) ClaimCapability(ctx, cap, name any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClaimCapability", reflect.TypeOf((*MockScopedKeeper)(nil).ClaimCapability), ctx, cap, name) +} + +// GetCapability mocks base method. +func (m *MockScopedKeeper) GetCapability(ctx types2.Context, name string) (*types3.Capability, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCapability", ctx, name) + ret0, _ := ret[0].(*types3.Capability) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetCapability indicates an expected call of GetCapability. +func (mr *MockScopedKeeperMockRecorder) GetCapability(ctx, name any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCapability", reflect.TypeOf((*MockScopedKeeper)(nil).GetCapability), ctx, name) +} + // MockFeedsKeeper is a mock of FeedsKeeper interface. type MockFeedsKeeper struct { ctrl *gomock.Controller diff --git a/x/tunnel/types/codec.go b/x/tunnel/types/codec.go index c3d8d84b8..da8e3b7a8 100644 --- a/x/tunnel/types/codec.go +++ b/x/tunnel/types/codec.go @@ -29,8 +29,11 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*RouteI)(nil), nil) cdc.RegisterConcrete(&TSSRoute{}, "tunnel/TSSRoute", nil) + cdc.RegisterConcrete(&IBCRoute{}, "tunnel/IBCRoute", nil) + cdc.RegisterInterface((*PacketReceiptI)(nil), nil) cdc.RegisterConcrete(&TSSPacketReceipt{}, "tunnel/TSSPacketReceipt", nil) + cdc.RegisterConcrete(&IBCPacketReceipt{}, "tunnel/IBCPacketReceipt", nil) cdc.RegisterConcrete(Params{}, "tunnel/Params", nil) } @@ -53,6 +56,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { "tunnel.v1beta1.RouteI", (*RouteI)(nil), &TSSRoute{}, + &IBCRoute{}, ) registry.RegisterInterface( diff --git a/x/tunnel/types/errors.go b/x/tunnel/types/errors.go index badbb1605..365272d02 100644 --- a/x/tunnel/types/errors.go +++ b/x/tunnel/types/errors.go @@ -6,23 +6,26 @@ import ( // x/tunnel module sentinel errors var ( - ErrInvalidGenesis = errorsmod.Register(ModuleName, 2, "invalid genesis") - ErrMaxSignalsExceeded = errorsmod.Register(ModuleName, 3, "max signals exceeded") - ErrIntervalOutOfRange = errorsmod.Register(ModuleName, 4, "interval out of range") - ErrDeviationOutOfRange = errorsmod.Register(ModuleName, 5, "deviation out of range") - ErrTunnelNotFound = errorsmod.Register(ModuleName, 6, "tunnel not found") - ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 7, "latest prices not found") - ErrPacketNotFound = errorsmod.Register(ModuleName, 8, "packet not found") - ErrNoPacketReceipt = errorsmod.Register(ModuleName, 9, "no packet receipt") - ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 10, "invalid creator of the tunnel") - ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 11, "account already exist") - ErrInvalidRoute = errorsmod.Register(ModuleName, 12, "invalid tunnel route") - ErrInactiveTunnel = errorsmod.Register(ModuleName, 13, "inactive tunnel") - ErrAlreadyActive = errorsmod.Register(ModuleName, 14, "already active") - ErrAlreadyInactive = errorsmod.Register(ModuleName, 15, "already inactive") - ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 16, "invalid deposit denom") - ErrDepositNotFound = errorsmod.Register(ModuleName, 17, "deposit not found") - ErrInsufficientDeposit = errorsmod.Register(ModuleName, 18, "insufficient deposit") - ErrInsufficientFund = errorsmod.Register(ModuleName, 19, "insufficient fund") - ErrDeviationNotFound = errorsmod.Register(ModuleName, 20, "deviation not found") + ErrInvalidGenesis = errorsmod.Register(ModuleName, 2, "invalid genesis") + ErrMaxSignalsExceeded = errorsmod.Register(ModuleName, 3, "max signals exceeded") + ErrIntervalOutOfRange = errorsmod.Register(ModuleName, 4, "interval out of range") + ErrDeviationOutOfRange = errorsmod.Register(ModuleName, 5, "deviation out of range") + ErrTunnelNotFound = errorsmod.Register(ModuleName, 6, "tunnel not found") + ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 7, "latest prices not found") + ErrPacketNotFound = errorsmod.Register(ModuleName, 8, "packet not found") + ErrNoPacketReceipt = errorsmod.Register(ModuleName, 9, "no packet receipt") + ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 10, "invalid creator of the tunnel") + ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 11, "account already exist") + ErrInvalidRoute = errorsmod.Register(ModuleName, 12, "invalid tunnel route") + ErrInactiveTunnel = errorsmod.Register(ModuleName, 13, "inactive tunnel") + ErrAlreadyActive = errorsmod.Register(ModuleName, 14, "already active") + ErrAlreadyInactive = errorsmod.Register(ModuleName, 15, "already inactive") + ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 16, "invalid deposit denom") + ErrDepositNotFound = errorsmod.Register(ModuleName, 17, "deposit not found") + ErrInsufficientDeposit = errorsmod.Register(ModuleName, 18, "insufficient deposit") + ErrInsufficientFund = errorsmod.Register(ModuleName, 19, "insufficient fund") + ErrDeviationNotFound = errorsmod.Register(ModuleName, 20, "deviation not found") + ErrInvalidVersion = errorsmod.Register(ModuleName, 21, "invalid version") + ErrChannelCapabilityNotFound = errorsmod.Register(ModuleName, 22, "channel capability not found") + ErrMaxTunnelChannels = errorsmod.Register(ModuleName, 23, "max tunnel channels exceeded") ) diff --git a/x/tunnel/types/expected_keepers.go b/x/tunnel/types/expected_keepers.go index 8c814fd78..555edcf2a 100644 --- a/x/tunnel/types/expected_keepers.go +++ b/x/tunnel/types/expected_keepers.go @@ -3,6 +3,9 @@ package types import ( "context" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + sdk "github.com/cosmos/cosmos-sdk/types" bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" @@ -39,6 +42,28 @@ type BankKeeper interface { ) error } +type ICS4Wrapper interface { + SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight ibcclienttypes.Height, + timeoutTimestamp uint64, + data []byte, + ) (sequence uint64, err error) +} + +type PortKeeper interface { + BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability +} + +type ScopedKeeper interface { + GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) + AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool + ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error +} + type FeedsKeeper interface { GetAllPrices(ctx sdk.Context) (prices []feedstypes.Price) GetPrices(ctx sdk.Context, signalIDs []string) (prices []feedstypes.Price) diff --git a/x/tunnel/types/keys.go b/x/tunnel/types/keys.go index a2b8dca32..736f69215 100644 --- a/x/tunnel/types/keys.go +++ b/x/tunnel/types/keys.go @@ -42,6 +42,9 @@ var ( // params store keys ParamsKey = []byte{0x90} + + // PortKey defines the key to store the port ID in store + PortKey = []byte{0xf0} ) // TunnelStoreKey returns the key to retrieve a specific tunnel from the store. diff --git a/x/tunnel/types/msgs.go b/x/tunnel/types/msgs.go index 74d61931e..ca1cf347d 100644 --- a/x/tunnel/types/msgs.go +++ b/x/tunnel/types/msgs.go @@ -66,6 +66,24 @@ func NewMsgCreateTSSTunnel( return m, nil } +// NewMsgCreateTunnel creates a new MsgCreateTunnel instance. +func NewMsgCreateIBCTunnel( + signalDeviations []SignalDeviation, + interval uint64, + channelID string, + encoder feedstypes.Encoder, + deposit sdk.Coins, + creator sdk.AccAddress, +) (*MsgCreateTunnel, error) { + r := NewIBCRoute(channelID) + m, err := NewMsgCreateTunnel(signalDeviations, interval, r, encoder, deposit, creator) + if err != nil { + return nil, err + } + + return m, nil +} + // GetRouteValue returns the route of the tunnel. func (m MsgCreateTunnel) GetRouteValue() (RouteI, error) { r, ok := m.Route.GetCachedValue().(RouteI) diff --git a/x/tunnel/types/route.pb.go b/x/tunnel/types/route.pb.go index d9e9e683f..fede1d5b9 100644 --- a/x/tunnel/types/route.pb.go +++ b/x/tunnel/types/route.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" github_com_bandprotocol_chain_v3_x_bandtss_types "github.com/bandprotocol/chain/v3/x/bandtss/types" + types "github.com/bandprotocol/chain/v3/x/feeds/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -126,37 +127,216 @@ func (m *TSSPacketReceipt) GetSigningID() github_com_bandprotocol_chain_v3_x_ban return 0 } +// IBCRoute is the type for an IBC route +type IBCRoute struct { + // channel_id is the IBC channel ID + ChannelID string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *IBCRoute) Reset() { *m = IBCRoute{} } +func (m *IBCRoute) String() string { return proto.CompactTextString(m) } +func (*IBCRoute) ProtoMessage() {} +func (*IBCRoute) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{2} +} +func (m *IBCRoute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCRoute.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IBCRoute) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCRoute.Merge(m, src) +} +func (m *IBCRoute) XXX_Size() int { + return m.Size() +} +func (m *IBCRoute) XXX_DiscardUnknown() { + xxx_messageInfo_IBCRoute.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCRoute proto.InternalMessageInfo + +func (m *IBCRoute) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +// IBCPacketReceipt represents a receipt for a IBC packet and implements the PacketReceiptI interface. +type IBCPacketReceipt struct { + // sequence is representing the sequence of the IBC packet. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *IBCPacketReceipt) Reset() { *m = IBCPacketReceipt{} } +func (m *IBCPacketReceipt) String() string { return proto.CompactTextString(m) } +func (*IBCPacketReceipt) ProtoMessage() {} +func (*IBCPacketReceipt) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{3} +} +func (m *IBCPacketReceipt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCPacketReceipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCPacketReceipt.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IBCPacketReceipt) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCPacketReceipt.Merge(m, src) +} +func (m *IBCPacketReceipt) XXX_Size() int { + return m.Size() +} +func (m *IBCPacketReceipt) XXX_DiscardUnknown() { + xxx_messageInfo_IBCPacketReceipt.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCPacketReceipt proto.InternalMessageInfo + +func (m *IBCPacketReceipt) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +// TunnelPricesPacketData represents the IBC packet payload for the tunnel packet. +type TunnelPricesPacketData struct { + // tunnel_id is the tunnel ID + TunnelID uint64 `protobuf:"varint,1,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` + // sequence is representing the sequence of the tunnel packet. + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // prices is the list of prices information from feeds module. + Prices []types.Price `protobuf:"bytes,3,rep,name=prices,proto3" json:"prices"` + // created_at is the timestamp when the packet is created + CreatedAt int64 `protobuf:"varint,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (m *TunnelPricesPacketData) Reset() { *m = TunnelPricesPacketData{} } +func (m *TunnelPricesPacketData) String() string { return proto.CompactTextString(m) } +func (*TunnelPricesPacketData) ProtoMessage() {} +func (*TunnelPricesPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{4} +} +func (m *TunnelPricesPacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TunnelPricesPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TunnelPricesPacketData.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TunnelPricesPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_TunnelPricesPacketData.Merge(m, src) +} +func (m *TunnelPricesPacketData) XXX_Size() int { + return m.Size() +} +func (m *TunnelPricesPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_TunnelPricesPacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_TunnelPricesPacketData proto.InternalMessageInfo + +func (m *TunnelPricesPacketData) GetTunnelID() uint64 { + if m != nil { + return m.TunnelID + } + return 0 +} + +func (m *TunnelPricesPacketData) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *TunnelPricesPacketData) GetPrices() []types.Price { + if m != nil { + return m.Prices + } + return nil +} + +func (m *TunnelPricesPacketData) GetCreatedAt() int64 { + if m != nil { + return m.CreatedAt + } + return 0 +} + func init() { proto.RegisterType((*TSSRoute)(nil), "band.tunnel.v1beta1.TSSRoute") proto.RegisterType((*TSSPacketReceipt)(nil), "band.tunnel.v1beta1.TSSPacketReceipt") + proto.RegisterType((*IBCRoute)(nil), "band.tunnel.v1beta1.IBCRoute") + proto.RegisterType((*IBCPacketReceipt)(nil), "band.tunnel.v1beta1.IBCPacketReceipt") + proto.RegisterType((*TunnelPricesPacketData)(nil), "band.tunnel.v1beta1.TunnelPricesPacketData") } func init() { proto.RegisterFile("band/tunnel/v1beta1/route.proto", fileDescriptor_543238289d94b7a6) } var fileDescriptor_543238289d94b7a6 = []byte{ - // 351 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xbf, 0x4e, 0xeb, 0x30, - 0x14, 0xc6, 0xeb, 0xab, 0xab, 0xea, 0xd6, 0xc3, 0x15, 0x0a, 0x15, 0x2a, 0x15, 0x4a, 0x50, 0x27, - 0x96, 0xc6, 0xaa, 0xba, 0x75, 0x82, 0xd2, 0x81, 0x08, 0x21, 0xa1, 0xa4, 0x13, 0x4b, 0xe4, 0xd8, - 0x56, 0x6a, 0x68, 0xed, 0x2a, 0x76, 0x2b, 0x78, 0x0b, 0xc4, 0x23, 0x30, 0xf1, 0x00, 0x7d, 0x08, - 0xd4, 0xa9, 0x23, 0x53, 0x85, 0xd2, 0xb7, 0x60, 0x42, 0xb1, 0xc3, 0x9f, 0x32, 0xb1, 0xd9, 0xdf, - 0xf9, 0x9d, 0xef, 0x3b, 0xc7, 0x86, 0x5e, 0x82, 0x05, 0x45, 0x7a, 0x26, 0x04, 0x1b, 0xa3, 0x79, - 0x27, 0x61, 0x1a, 0x77, 0x50, 0x26, 0x67, 0x9a, 0xf9, 0xd3, 0x4c, 0x6a, 0xe9, 0xec, 0x16, 0x80, - 0x6f, 0x01, 0xbf, 0x04, 0x9a, 0xfb, 0x44, 0xaa, 0x89, 0x54, 0xb1, 0x41, 0x90, 0xbd, 0x58, 0xbe, - 0x59, 0x4f, 0x65, 0x2a, 0xad, 0x5e, 0x9c, 0xac, 0xda, 0x7a, 0x04, 0xf0, 0xdf, 0x30, 0x8a, 0xc2, - 0xc2, 0xd8, 0x39, 0x83, 0x75, 0xca, 0x94, 0xe6, 0x02, 0x6b, 0x2e, 0x45, 0x4c, 0x46, 0x98, 0x8b, - 0x98, 0xd3, 0x06, 0x38, 0x04, 0x47, 0xb5, 0xfe, 0x5e, 0xbe, 0xf6, 0x9c, 0xc1, 0x57, 0xfd, 0xb4, - 0x28, 0x07, 0x83, 0xd0, 0xa1, 0x3f, 0x35, 0xea, 0x1c, 0xc3, 0x83, 0x2d, 0x27, 0x29, 0x74, 0x86, - 0x89, 0x8e, 0x31, 0xa5, 0x19, 0x53, 0xaa, 0xf1, 0xa7, 0x70, 0x0c, 0x9b, 0xdf, 0x3b, 0x4b, 0xe4, - 0xc4, 0x12, 0x3d, 0xb8, 0x5c, 0xb4, 0xab, 0x66, 0xac, 0xa0, 0xf5, 0x00, 0xe0, 0xce, 0x30, 0x8a, - 0x2e, 0x31, 0xb9, 0x61, 0x3a, 0x64, 0x84, 0xf1, 0xa9, 0x76, 0xae, 0x21, 0x54, 0x3c, 0x15, 0x5c, - 0xa4, 0x1f, 0x23, 0xfe, 0xed, 0x9f, 0xe7, 0x6b, 0xaf, 0x16, 0x59, 0x35, 0x18, 0xbc, 0xad, 0xbd, - 0x5e, 0xca, 0xf5, 0x68, 0x96, 0xf8, 0x44, 0x4e, 0x50, 0xf1, 0x5e, 0x66, 0x69, 0x22, 0xc7, 0xc8, - 0xec, 0x86, 0xe6, 0x5d, 0x74, 0x6b, 0x74, 0xad, 0x14, 0xd2, 0x77, 0x53, 0xa6, 0xfc, 0xcf, 0xee, - 0xb0, 0x56, 0xda, 0x07, 0xb4, 0xe7, 0x2c, 0x17, 0xed, 0xff, 0x5b, 0xf1, 0x41, 0xff, 0xe2, 0x29, - 0x77, 0xc1, 0x73, 0xee, 0x82, 0x55, 0xee, 0x82, 0xd7, 0xdc, 0x05, 0xf7, 0x1b, 0xb7, 0xb2, 0xda, - 0xb8, 0x95, 0x97, 0x8d, 0x5b, 0xb9, 0x42, 0xbf, 0x08, 0x2e, 0x3f, 0xd7, 0xe4, 0x26, 0x55, 0x43, - 0x74, 0xdf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x96, 0xeb, 0xca, 0x84, 0xf8, 0x01, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xc1, 0x6e, 0x13, 0x3d, + 0x10, 0xc7, 0xb3, 0x4d, 0xbe, 0x28, 0xeb, 0x0f, 0x50, 0x65, 0xaa, 0x2a, 0x8d, 0x60, 0x37, 0xca, + 0x29, 0x48, 0x64, 0xad, 0xd2, 0x03, 0x52, 0x4e, 0x74, 0x93, 0x03, 0x16, 0x42, 0xaa, 0x36, 0x39, + 0x71, 0x89, 0x1c, 0xdb, 0x24, 0x0b, 0xad, 0x1d, 0xd6, 0x4e, 0x05, 0x6f, 0x81, 0x78, 0x04, 0x4e, + 0x3c, 0x40, 0x24, 0x5e, 0xa1, 0xca, 0xa9, 0x47, 0x4e, 0x11, 0xda, 0xbc, 0x05, 0x27, 0x64, 0x7b, + 0x49, 0xba, 0x9c, 0xb8, 0xad, 0xff, 0xf3, 0xf3, 0xfc, 0x67, 0xc6, 0xb3, 0x20, 0x9c, 0x12, 0xc1, + 0x90, 0x5e, 0x0a, 0xc1, 0x2f, 0xd1, 0xf5, 0xe9, 0x94, 0x6b, 0x72, 0x8a, 0x32, 0xb9, 0xd4, 0x3c, + 0x5a, 0x64, 0x52, 0x4b, 0xf8, 0xd0, 0x00, 0x91, 0x03, 0xa2, 0x02, 0x68, 0x9d, 0x50, 0xa9, 0xae, + 0xa4, 0x9a, 0x58, 0x04, 0xb9, 0x83, 0xe3, 0x5b, 0x47, 0x33, 0x39, 0x93, 0x4e, 0x37, 0x5f, 0x85, + 0x1a, 0x58, 0x9b, 0xb7, 0x9c, 0x33, 0xb5, 0x73, 0xb1, 0x27, 0x17, 0xef, 0x7c, 0xf5, 0x40, 0x63, + 0x3c, 0x1a, 0x25, 0xc6, 0x18, 0xbe, 0x04, 0x47, 0x8c, 0x2b, 0x9d, 0x0a, 0xa2, 0x53, 0x29, 0x26, + 0x74, 0x4e, 0x52, 0x31, 0x49, 0x59, 0xd3, 0x6b, 0x7b, 0x5d, 0x3f, 0x3e, 0xce, 0x37, 0x21, 0x1c, + 0xee, 0xe3, 0x03, 0x13, 0xc6, 0xc3, 0x04, 0xb2, 0xbf, 0x35, 0x06, 0x5f, 0x80, 0x47, 0xa5, 0x4c, + 0x52, 0xe8, 0x8c, 0x50, 0x3d, 0x21, 0x8c, 0x65, 0x5c, 0xa9, 0xe6, 0x81, 0xc9, 0x98, 0xb4, 0xee, + 0xde, 0x2c, 0x90, 0x73, 0x47, 0xf4, 0xc1, 0x7a, 0xd5, 0xab, 0xdb, 0xb2, 0x70, 0xe7, 0x8b, 0x07, + 0x0e, 0xc7, 0xa3, 0xd1, 0x05, 0xa1, 0xef, 0xb9, 0x4e, 0x38, 0xe5, 0xe9, 0x42, 0xc3, 0x77, 0x00, + 0xa8, 0x74, 0x26, 0x52, 0x31, 0xfb, 0x53, 0x62, 0x2d, 0x7e, 0x95, 0x6f, 0x42, 0x7f, 0xe4, 0x54, + 0x3c, 0xfc, 0xb5, 0x09, 0xfb, 0xb3, 0x54, 0xcf, 0x97, 0xd3, 0x88, 0xca, 0x2b, 0x64, 0x26, 0x61, + 0x9b, 0xa6, 0xf2, 0x12, 0xd9, 0xde, 0xd0, 0xf5, 0x19, 0xfa, 0x68, 0x75, 0xad, 0x14, 0xd2, 0x9f, + 0x16, 0x5c, 0x45, 0xbb, 0xdb, 0x89, 0x5f, 0xa4, 0xc7, 0xac, 0x0f, 0xd7, 0xab, 0xde, 0x83, 0x92, + 0x3d, 0xee, 0x0c, 0x40, 0x03, 0xc7, 0x03, 0x37, 0xb8, 0xa7, 0x00, 0xd0, 0x39, 0x31, 0x2f, 0xb5, + 0x1f, 0xd7, 0x7d, 0x53, 0xcb, 0xc0, 0xa9, 0x26, 0x5b, 0x01, 0x60, 0xd6, 0xf7, 0xd7, 0xab, 0xde, + 0x7f, 0xf6, 0x62, 0x27, 0x06, 0x87, 0x38, 0x1e, 0x94, 0x1b, 0x6b, 0x81, 0x86, 0xe2, 0x1f, 0x96, + 0x5c, 0x50, 0xee, 0xda, 0x4a, 0x76, 0xe7, 0xbb, 0x85, 0x98, 0x81, 0x71, 0xa1, 0x71, 0xe7, 0xbb, + 0x07, 0x8e, 0xc7, 0x76, 0x4d, 0x2e, 0xb2, 0x94, 0x72, 0xe5, 0xc2, 0x43, 0xa2, 0x09, 0x7c, 0x02, + 0x7c, 0xb7, 0x40, 0xfb, 0x11, 0xdd, 0xcb, 0x37, 0x61, 0xc3, 0xe1, 0x78, 0x98, 0x34, 0x5c, 0x18, + 0xb3, 0x92, 0xeb, 0x41, 0xd9, 0x15, 0x3e, 0x07, 0xf5, 0x85, 0x4d, 0xdd, 0xac, 0xb6, 0xab, 0xdd, + 0xff, 0x9f, 0x9d, 0x44, 0x76, 0x37, 0xdd, 0x1e, 0x15, 0x5b, 0x15, 0x59, 0xf3, 0xb8, 0x76, 0xb3, + 0x09, 0x2b, 0x49, 0x81, 0xc3, 0xc7, 0x00, 0xd0, 0x8c, 0x13, 0xcd, 0xd9, 0x84, 0xe8, 0x66, 0xad, + 0xed, 0x75, 0xab, 0x89, 0x5f, 0x28, 0xe7, 0x3a, 0x7e, 0xfd, 0x2d, 0x0f, 0xbc, 0x9b, 0x3c, 0xf0, + 0x6e, 0xf3, 0xc0, 0xfb, 0x99, 0x07, 0xde, 0xe7, 0x6d, 0x50, 0xb9, 0xdd, 0x06, 0x95, 0x1f, 0xdb, + 0xa0, 0xf2, 0x06, 0xfd, 0xc3, 0xdb, 0x15, 0xff, 0x8f, 0x7d, 0xba, 0x69, 0xdd, 0x12, 0x67, 0xbf, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x67, 0x73, 0xe8, 0xaf, 0x5b, 0x03, 0x00, 0x00, } func (this *TSSRoute) Equal(that interface{}) bool { @@ -210,6 +390,92 @@ func (this *TSSPacketReceipt) Equal(that interface{}) bool { } return true } +func (this *IBCRoute) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCRoute) + if !ok { + that2, ok := that.(IBCRoute) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ChannelID != that1.ChannelID { + return false + } + return true +} +func (this *IBCPacketReceipt) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCPacketReceipt) + if !ok { + that2, ok := that.(IBCPacketReceipt) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sequence != that1.Sequence { + return false + } + return true +} +func (this *TunnelPricesPacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TunnelPricesPacketData) + if !ok { + that2, ok := that.(TunnelPricesPacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TunnelID != that1.TunnelID { + return false + } + if this.Sequence != that1.Sequence { + return false + } + if len(this.Prices) != len(that1.Prices) { + return false + } + for i := range this.Prices { + if !this.Prices[i].Equal(&that1.Prices[i]) { + return false + } + } + if this.CreatedAt != that1.CreatedAt { + return false + } + return true +} func (m *TSSRoute) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -275,6 +541,116 @@ func (m *TSSPacketReceipt) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IBCRoute) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IBCRoute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintRoute(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *IBCPacketReceipt) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IBCPacketReceipt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCPacketReceipt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TunnelPricesPacketData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TunnelPricesPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TunnelPricesPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CreatedAt != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x20 + } + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRoute(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Sequence != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if m.TunnelID != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.TunnelID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintRoute(dAtA []byte, offset int, v uint64) int { offset -= sovRoute(v) base := offset @@ -315,15 +691,64 @@ func (m *TSSPacketReceipt) Size() (n int) { return n } -func sovRoute(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozRoute(x uint64) (n int) { - return sovRoute(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func (m *IBCRoute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovRoute(uint64(l)) + } + return n } -func (m *TSSRoute) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 + +func (m *IBCPacketReceipt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovRoute(uint64(m.Sequence)) + } + return n +} + +func (m *TunnelPricesPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TunnelID != 0 { + n += 1 + sovRoute(uint64(m.TunnelID)) + } + if m.Sequence != 0 { + n += 1 + sovRoute(uint64(m.Sequence)) + } + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovRoute(uint64(l)) + } + } + if m.CreatedAt != 0 { + n += 1 + sovRoute(uint64(m.CreatedAt)) + } + return n +} + +func sovRoute(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRoute(x uint64) (n int) { + return sovRoute(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TSSRoute) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 @@ -504,6 +929,298 @@ func (m *TSSPacketReceipt) Unmarshal(dAtA []byte) error { } return nil } +func (m *IBCRoute) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IBCRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCRoute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRoute + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRoute + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IBCPacketReceipt) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IBCPacketReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCPacketReceipt: 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 ErrIntOverflowRoute + } + 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 := skipRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TunnelPricesPacketData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TunnelPricesPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TunnelPricesPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TunnelID", wireType) + } + m.TunnelID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TunnelID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRoute + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRoute + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prices = append(m.Prices, types.Price{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipRoute(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tunnel/types/route_ibc.go b/x/tunnel/types/route_ibc.go new file mode 100644 index 000000000..49a5a2377 --- /dev/null +++ b/x/tunnel/types/route_ibc.go @@ -0,0 +1,57 @@ +package types + +import ( + "fmt" + + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" +) + +// IBCRoute defines the IBC route for the tunnel module +var _ RouteI = &IBCRoute{} + +// NewIBCRoute creates a new IBCRoute instance. +func NewIBCRoute(channelID string) *IBCRoute { + return &IBCRoute{ + ChannelID: channelID, + } +} + +// ValidateBasic validates the IBCRoute +func (r *IBCRoute) ValidateBasic() error { + // Validate the ChannelID format + if !channeltypes.IsChannelIDFormat(r.ChannelID) { + return fmt.Errorf("channel identifier is not in the format: `channel-{N}`") + } + return nil +} + +// NewIBCPacketReceipt creates a new IBCPacketReceipt instance. +func NewIBCPacketReceipt(sequence uint64) *IBCPacketReceipt { + return &IBCPacketReceipt{ + Sequence: sequence, + } +} + +// NewTunnelPricesPacketData creates a new TunnelPricesPacketData instance. +func NewTunnelPricesPacketData( + tunnelID uint64, + sequence uint64, + prices []feedstypes.Price, + createdAt int64, +) TunnelPricesPacketData { + return TunnelPricesPacketData{ + TunnelID: tunnelID, + Sequence: sequence, + Prices: prices, + CreatedAt: createdAt, + } +} + +// GetBytes is a helper for serialising +func (p TunnelPricesPacketData) GetBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&p)) +} diff --git a/x/tunnel/types/route_ibc_test.go b/x/tunnel/types/route_ibc_test.go new file mode 100644 index 000000000..26b91d30f --- /dev/null +++ b/x/tunnel/types/route_ibc_test.go @@ -0,0 +1,27 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func TestGetByteTunnelPricesPacketData(t *testing.T) { + packet := types.NewTunnelPricesPacketData( + 1, + 2, + []feedstypes.Price{{Status: feedstypes.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, SignalID: "BTC", Price: 50000}}, + 1633024800, + ) + + require.Equal( + t, + []byte( + `{"created_at":"1633024800","prices":[{"price":"50000","signal_id":"BTC","status":"PRICE_STATUS_NOT_IN_CURRENT_FEEDS","timestamp":"0"}],"sequence":"2","tunnel_id":"1"}`, + ), + packet.GetBytes(), + ) +}