diff --git a/api/band/tunnel/v1beta1/route.pulsar.go b/api/band/tunnel/v1beta1/route.pulsar.go index 7ed04b57f..c22fc2455 100644 --- a/api/band/tunnel/v1beta1/route.pulsar.go +++ b/api/band/tunnel/v1beta1/route.pulsar.go @@ -2365,6 +2365,894 @@ func (x *fastReflection_IBCPacket) ProtoMethods() *protoiface.Methods { } } +var ( + md_IBCHookRoute protoreflect.MessageDescriptor + fd_IBCHookRoute_channel_id protoreflect.FieldDescriptor + fd_IBCHookRoute_destination_contract_address protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_IBCHookRoute = File_band_tunnel_v1beta1_route_proto.Messages().ByName("IBCHookRoute") + fd_IBCHookRoute_channel_id = md_IBCHookRoute.Fields().ByName("channel_id") + fd_IBCHookRoute_destination_contract_address = md_IBCHookRoute.Fields().ByName("destination_contract_address") +} + +var _ protoreflect.Message = (*fastReflection_IBCHookRoute)(nil) + +type fastReflection_IBCHookRoute IBCHookRoute + +func (x *IBCHookRoute) ProtoReflect() protoreflect.Message { + return (*fastReflection_IBCHookRoute)(x) +} + +func (x *IBCHookRoute) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[5] + 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_IBCHookRoute_messageType fastReflection_IBCHookRoute_messageType +var _ protoreflect.MessageType = fastReflection_IBCHookRoute_messageType{} + +type fastReflection_IBCHookRoute_messageType struct{} + +func (x fastReflection_IBCHookRoute_messageType) Zero() protoreflect.Message { + return (*fastReflection_IBCHookRoute)(nil) +} +func (x fastReflection_IBCHookRoute_messageType) New() protoreflect.Message { + return new(fastReflection_IBCHookRoute) +} +func (x fastReflection_IBCHookRoute_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_IBCHookRoute +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_IBCHookRoute) Descriptor() protoreflect.MessageDescriptor { + return md_IBCHookRoute +} + +// 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_IBCHookRoute) Type() protoreflect.MessageType { + return _fastReflection_IBCHookRoute_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_IBCHookRoute) New() protoreflect.Message { + return new(fastReflection_IBCHookRoute) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_IBCHookRoute) Interface() protoreflect.ProtoMessage { + return (*IBCHookRoute)(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_IBCHookRoute) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ChannelId != "" { + value := protoreflect.ValueOfString(x.ChannelId) + if !f(fd_IBCHookRoute_channel_id, value) { + return + } + } + if x.DestinationContractAddress != "" { + value := protoreflect.ValueOfString(x.DestinationContractAddress) + if !f(fd_IBCHookRoute_destination_contract_address, 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_IBCHookRoute) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookRoute.channel_id": + return x.ChannelId != "" + case "band.tunnel.v1beta1.IBCHookRoute.destination_contract_address": + return x.DestinationContractAddress != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookRoute 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_IBCHookRoute) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookRoute.channel_id": + x.ChannelId = "" + case "band.tunnel.v1beta1.IBCHookRoute.destination_contract_address": + x.DestinationContractAddress = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookRoute 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_IBCHookRoute) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.IBCHookRoute.channel_id": + value := x.ChannelId + return protoreflect.ValueOfString(value) + case "band.tunnel.v1beta1.IBCHookRoute.destination_contract_address": + value := x.DestinationContractAddress + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookRoute 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_IBCHookRoute) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookRoute.channel_id": + x.ChannelId = value.Interface().(string) + case "band.tunnel.v1beta1.IBCHookRoute.destination_contract_address": + x.DestinationContractAddress = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookRoute 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_IBCHookRoute) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookRoute.channel_id": + panic(fmt.Errorf("field channel_id of message band.tunnel.v1beta1.IBCHookRoute is not mutable")) + case "band.tunnel.v1beta1.IBCHookRoute.destination_contract_address": + panic(fmt.Errorf("field destination_contract_address of message band.tunnel.v1beta1.IBCHookRoute is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookRoute 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_IBCHookRoute) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookRoute.channel_id": + return protoreflect.ValueOfString("") + case "band.tunnel.v1beta1.IBCHookRoute.destination_contract_address": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookRoute 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_IBCHookRoute) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.IBCHookRoute", 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_IBCHookRoute) 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_IBCHookRoute) 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_IBCHookRoute) 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_IBCHookRoute) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*IBCHookRoute) + 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)) + } + l = len(x.DestinationContractAddress) + 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().(*IBCHookRoute) + 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.DestinationContractAddress) > 0 { + i -= len(x.DestinationContractAddress) + copy(dAtA[i:], x.DestinationContractAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.DestinationContractAddress))) + i-- + dAtA[i] = 0x12 + } + 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().(*IBCHookRoute) + 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: IBCHookRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCHookRoute: 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 + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DestinationContractAddress", 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.DestinationContractAddress = 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_IBCHookPacketReceipt protoreflect.MessageDescriptor + fd_IBCHookPacketReceipt_sequence protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_IBCHookPacketReceipt = File_band_tunnel_v1beta1_route_proto.Messages().ByName("IBCHookPacketReceipt") + fd_IBCHookPacketReceipt_sequence = md_IBCHookPacketReceipt.Fields().ByName("sequence") +} + +var _ protoreflect.Message = (*fastReflection_IBCHookPacketReceipt)(nil) + +type fastReflection_IBCHookPacketReceipt IBCHookPacketReceipt + +func (x *IBCHookPacketReceipt) ProtoReflect() protoreflect.Message { + return (*fastReflection_IBCHookPacketReceipt)(x) +} + +func (x *IBCHookPacketReceipt) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[6] + 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_IBCHookPacketReceipt_messageType fastReflection_IBCHookPacketReceipt_messageType +var _ protoreflect.MessageType = fastReflection_IBCHookPacketReceipt_messageType{} + +type fastReflection_IBCHookPacketReceipt_messageType struct{} + +func (x fastReflection_IBCHookPacketReceipt_messageType) Zero() protoreflect.Message { + return (*fastReflection_IBCHookPacketReceipt)(nil) +} +func (x fastReflection_IBCHookPacketReceipt_messageType) New() protoreflect.Message { + return new(fastReflection_IBCHookPacketReceipt) +} +func (x fastReflection_IBCHookPacketReceipt_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_IBCHookPacketReceipt +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_IBCHookPacketReceipt) Descriptor() protoreflect.MessageDescriptor { + return md_IBCHookPacketReceipt +} + +// 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_IBCHookPacketReceipt) Type() protoreflect.MessageType { + return _fastReflection_IBCHookPacketReceipt_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_IBCHookPacketReceipt) New() protoreflect.Message { + return new(fastReflection_IBCHookPacketReceipt) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_IBCHookPacketReceipt) Interface() protoreflect.ProtoMessage { + return (*IBCHookPacketReceipt)(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_IBCHookPacketReceipt) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sequence != uint64(0) { + value := protoreflect.ValueOfUint64(x.Sequence) + if !f(fd_IBCHookPacketReceipt_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_IBCHookPacketReceipt) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookPacketReceipt.sequence": + return x.Sequence != uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookPacketReceipt 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_IBCHookPacketReceipt) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookPacketReceipt.sequence": + x.Sequence = uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookPacketReceipt 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_IBCHookPacketReceipt) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.IBCHookPacketReceipt.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.IBCHookPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookPacketReceipt 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_IBCHookPacketReceipt) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookPacketReceipt.sequence": + x.Sequence = value.Uint() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookPacketReceipt 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_IBCHookPacketReceipt) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookPacketReceipt.sequence": + panic(fmt.Errorf("field sequence of message band.tunnel.v1beta1.IBCHookPacketReceipt is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookPacketReceipt 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_IBCHookPacketReceipt) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCHookPacketReceipt.sequence": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCHookPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCHookPacketReceipt 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_IBCHookPacketReceipt) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.IBCHookPacketReceipt", 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_IBCHookPacketReceipt) 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_IBCHookPacketReceipt) 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_IBCHookPacketReceipt) 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_IBCHookPacketReceipt) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*IBCHookPacketReceipt) + 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().(*IBCHookPacketReceipt) + 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().(*IBCHookPacketReceipt) + 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: IBCHookPacketReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCHookPacketReceipt: 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, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -2599,6 +3487,89 @@ func (x *IBCPacket) GetCreatedAt() int64 { return 0 } +// IBCHookRoute is the type for an IBC hook route +type IBCHookRoute 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"` + // destination_contract_address is the destination contract address + DestinationContractAddress string `protobuf:"bytes,2,opt,name=destination_contract_address,json=destinationContractAddress,proto3" json:"destination_contract_address,omitempty"` +} + +func (x *IBCHookRoute) Reset() { + *x = IBCHookRoute{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IBCHookRoute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IBCHookRoute) ProtoMessage() {} + +// Deprecated: Use IBCHookRoute.ProtoReflect.Descriptor instead. +func (*IBCHookRoute) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{5} +} + +func (x *IBCHookRoute) GetChannelId() string { + if x != nil { + return x.ChannelId + } + return "" +} + +func (x *IBCHookRoute) GetDestinationContractAddress() string { + if x != nil { + return x.DestinationContractAddress + } + return "" +} + +// IBCHookPacketReceipt represents a receipt for a IBC hook packet and implements the PacketReceiptI interface. +type IBCHookPacketReceipt 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 *IBCHookPacketReceipt) Reset() { + *x = IBCHookPacketReceipt{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IBCHookPacketReceipt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IBCHookPacketReceipt) ProtoMessage() {} + +// Deprecated: Use IBCHookPacketReceipt.ProtoReflect.Descriptor instead. +func (*IBCHookPacketReceipt) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{6} +} + +func (x *IBCHookPacketReceipt) GetSequence() uint64 { + if x != nil { + return x.Sequence + } + return 0 +} + var File_band_tunnel_v1beta1_route_proto protoreflect.FileDescriptor var file_band_tunnel_v1beta1_route_proto_rawDesc = []byte{ @@ -2649,22 +3620,35 @@ var file_band_tunnel_v1beta1_route_proto_rawDesc = []byte{ 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, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x49, 0x42, 0x43, 0x48, + 0x6f, 0x6f, 0x6b, 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, 0x12, 0x40, 0x0a, 0x1c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x64, 0x65, + 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, + 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x09, 0xca, 0xb4, 0x2d, 0x05, 0x52, 0x6f, + 0x75, 0x74, 0x65, 0x22, 0x46, 0x0a, 0x14, 0x49, 0x42, 0x43, 0x48, 0x6f, 0x6f, 0x6b, 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, 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 ( @@ -2679,17 +3663,19 @@ 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, 5) +var file_band_tunnel_v1beta1_route_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_band_tunnel_v1beta1_route_proto_goTypes = []interface{}{ - (*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 - (*IBCPacket)(nil), // 4: band.tunnel.v1beta1.IBCPacket - (*v1beta1.Price)(nil), // 5: band.feeds.v1beta1.Price + (*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 + (*IBCPacket)(nil), // 4: band.tunnel.v1beta1.IBCPacket + (*IBCHookRoute)(nil), // 5: band.tunnel.v1beta1.IBCHookRoute + (*IBCHookPacketReceipt)(nil), // 6: band.tunnel.v1beta1.IBCHookPacketReceipt + (*v1beta1.Price)(nil), // 7: band.feeds.v1beta1.Price } var file_band_tunnel_v1beta1_route_proto_depIdxs = []int32{ - 5, // 0: band.tunnel.v1beta1.IBCPacket.prices:type_name -> band.feeds.v1beta1.Price + 7, // 0: band.tunnel.v1beta1.IBCPacket.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 @@ -2763,6 +3749,30 @@ func file_band_tunnel_v1beta1_route_proto_init() { return nil } } + file_band_tunnel_v1beta1_route_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IBCHookRoute); 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[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IBCHookPacketReceipt); 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{ @@ -2770,7 +3780,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: 5, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index c7d973ee8..f6df9d40e 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -504,6 +504,7 @@ func NewAppKeeper( appKeepers.IBCFeeKeeper, appKeepers.IBCKeeper.PortKeeper, appKeepers.ScopedTunnelKeeper, + appKeepers.TransferKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) diff --git a/proto/band/tunnel/v1beta1/route.proto b/proto/band/tunnel/v1beta1/route.proto index 6c65ddfbc..62da299a1 100644 --- a/proto/band/tunnel/v1beta1/route.proto +++ b/proto/band/tunnel/v1beta1/route.proto @@ -57,3 +57,21 @@ message IBCPacket { // created_at is the timestamp when the packet is created int64 created_at = 4; } + +// IBCHookRoute is the type for an IBC hook route +message IBCHookRoute { + option (cosmos_proto.implements_interface) = "Route"; + + // channel_id is the IBC channel ID + string channel_id = 1 [(gogoproto.customname) = "ChannelID"]; + // destination_contract_address is the destination contract address + string destination_contract_address = 2; +} + +// IBCHookPacketReceipt represents a receipt for a IBC hook packet and implements the PacketReceiptI interface. +message IBCHookPacketReceipt { + option (cosmos_proto.implements_interface) = "PacketContentI"; + + // sequence is representing the sequence of the IBC packet. + uint64 sequence = 1; +} diff --git a/scripts/tunnel/create_ibc_hook_tunnel.sh b/scripts/tunnel/create_ibc_hook_tunnel.sh new file mode 100644 index 000000000..0881dd2b1 --- /dev/null +++ b/scripts/tunnel/create_ibc_hook_tunnel.sh @@ -0,0 +1 @@ +bandd tx tunnel create-tunnel ibc-hook channel-0 wasm1vjq0k3fj47s8wns4a7zw5c4lsjd8l6r2kzzlpk 1 1uband 10 ./scripts/tunnel/signal_deviations.json --from requester --keyring-backend test --gas-prices 0.0025uband -y --chain-id bandchain diff --git a/x/tunnel/client/cli/tx.go b/x/tunnel/client/cli/tx.go index 31f89a11f..70c0116f1 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(), GetTxCmdCreateIBCTunnel()) + txCmd.AddCommand(GetTxCmdCreateTSSTunnel(), GetTxCmdCreateIBCTunnel(), GetTxCmdCreateIBCHookTunnel()) return txCmd } @@ -155,6 +155,61 @@ func GetTxCmdCreateIBCTunnel() *cobra.Command { return cmd } +func GetTxCmdCreateIBCHookTunnel() *cobra.Command { + cmd := &cobra.Command{ + Use: "ibc-hook [channel-id] [destination-contract-address] [encoder] [initial-deposit] [interval] [signalInfos-json-file]", + Short: "Create a new IBC hook tunnel", + Args: cobra.ExactArgs(6), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + channelID := args[0] + destinationContractAddress := args[1] + + encoder, err := strconv.ParseInt(args[2], 10, 32) + if err != nil { + return err + } + + initialDeposit, err := sdk.ParseCoinsNormalized(args[3]) + if err != nil { + return err + } + + interval, err := strconv.ParseUint(args[4], 10, 64) + if err != nil { + return err + } + + signalInfos, err := parseSignalDeviations(args[5]) + if err != nil { + return err + } + + msg, err := types.NewMsgCreateIBCHookTunnel( + signalInfos.ToSignalDeviations(), + interval, + channelID, + destinationContractAddress, + 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/keeper/keeper.go b/x/tunnel/keeper/keeper.go index 208e9d09b..86a51d345 100644 --- a/x/tunnel/keeper/keeper.go +++ b/x/tunnel/keeper/keeper.go @@ -19,13 +19,14 @@ type Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey - authKeeper types.AccountKeeper - bankKeeper types.BankKeeper - feedsKeeper types.FeedsKeeper - bandtssKeeper types.BandtssKeeper - ics4Wrapper types.ICS4Wrapper - portKeeper types.PortKeeper - scopedKeeper types.ScopedKeeper + authKeeper types.AccountKeeper + bankKeeper types.BankKeeper + feedsKeeper types.FeedsKeeper + bandtssKeeper types.BandtssKeeper + ics4Wrapper types.ICS4Wrapper + portKeeper types.PortKeeper + scopedKeeper types.ScopedKeeper + transferKeeper types.TransferKeeper authority string } @@ -41,6 +42,7 @@ func NewKeeper( ics4Wrapper types.ICS4Wrapper, portKeeper types.PortKeeper, scopedKeeper types.ScopedKeeper, + transferKeeper types.TransferKeeper, authority string, ) Keeper { // ensure tunnel module account is set @@ -54,16 +56,17 @@ func NewKeeper( } return Keeper{ - cdc: cdc, - storeKey: key, - authKeeper: authKeeper, - bankKeeper: bankKeeper, - feedsKeeper: feedsKeeper, - bandtssKeeper: bandtssKeeper, - ics4Wrapper: ics4Wrapper, - portKeeper: portKeeper, - scopedKeeper: scopedKeeper, - authority: authority, + cdc: cdc, + storeKey: key, + authKeeper: authKeeper, + bankKeeper: bankKeeper, + feedsKeeper: feedsKeeper, + bandtssKeeper: bandtssKeeper, + ics4Wrapper: ics4Wrapper, + portKeeper: portKeeper, + scopedKeeper: scopedKeeper, + transferKeeper: transferKeeper, + authority: authority, } } diff --git a/x/tunnel/keeper/keeper_packet.go b/x/tunnel/keeper/keeper_packet.go index 6f443c33e..7e6d1ce47 100644 --- a/x/tunnel/keeper/keeper_packet.go +++ b/x/tunnel/keeper/keeper_packet.go @@ -215,6 +215,8 @@ func (k Keeper) SendPacket(ctx sdk.Context, packet types.Packet) error { receipt, err = k.SendTSSPacket(ctx, r, packet) case *types.IBCRoute: receipt, err = k.SendIBCPacket(ctx, r, packet) + case *types.IBCHookRoute: + receipt, err = k.SendIBCHookPacket(ctx, r, packet, sdk.MustAccAddressFromBech32(tunnel.FeePayer)) default: return types.ErrInvalidRoute.Wrapf("no route found for tunnel ID: %d", tunnel.ID) } diff --git a/x/tunnel/keeper/keeper_paclet_ibc_hook.go b/x/tunnel/keeper/keeper_paclet_ibc_hook.go new file mode 100644 index 000000000..845ab9e7d --- /dev/null +++ b/x/tunnel/keeper/keeper_paclet_ibc_hook.go @@ -0,0 +1,51 @@ +package keeper + +import ( + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +// SendIBCHookPacket sends a packet to the destination chain using IBC Hook +func (k Keeper) SendIBCHookPacket( + ctx sdk.Context, + route *types.IBCHookRoute, + packet types.Packet, + feePayer sdk.AccAddress, +) (types.PacketReceiptI, error) { + // create memo string for ibc transfer + memoStr, err := types.NewIBCHookMemo( + route.DestinationContractAddress, + packet.TunnelID, + packet.Sequence, + packet.Prices, + packet.CreatedAt, + ).String() + if err != nil { + return nil, err + } + + // create ibc transfer message + msg := ibctransfertypes.NewMsgTransfer( + ibctransfertypes.PortID, + route.ChannelID, + // TODO: align the token to send with msg transfer + sdk.NewInt64Coin("uband", 1), + feePayer.String(), + route.DestinationContractAddress, + clienttypes.ZeroHeight(), + uint64(ctx.BlockTime().UnixNano()+packetExpireTime), + memoStr, + ) + + // send packet + res, err := k.transferKeeper.Transfer(ctx, msg) + if err != nil { + return nil, err + } + + return types.NewIBCHookPacketReceipt(res.Sequence), nil +} diff --git a/x/tunnel/keeper/keeper_paclet_ibc_hook_test.go b/x/tunnel/keeper/keeper_paclet_ibc_hook_test.go new file mode 100644 index 000000000..c2651d0b8 --- /dev/null +++ b/x/tunnel/keeper/keeper_paclet_ibc_hook_test.go @@ -0,0 +1,50 @@ +package keeper_test + +import ( + "time" + + "go.uber.org/mock/gomock" + + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func (s *KeeperTestSuite) TestSendRouterPacket() { + ctx, k := s.ctx, s.keeper + + route := &types.IBCHookRoute{ + ChannelID: "channel-0", + DestinationContractAddress: "wasm1vjq0k3fj47s8wns4a7zw5c4lsjd8l6r2kzzlpk", + } + + packet := types.Packet{ + TunnelID: 1, + Sequence: 1, + Prices: []feedstypes.Price{}, + CreatedAt: time.Now().Unix(), + } + + expectedPacketReceipt := types.IBCHookPacketReceipt{ + Sequence: 1, + } + + s.transferKeeper.EXPECT().Transfer(ctx, gomock.Any()).Return(&ibctransfertypes.MsgTransferResponse{ + Sequence: 1, + }, nil) + + content, err := k.SendIBCHookPacket( + ctx, + route, + packet, + sdk.AccAddress("feePayer"), + ) + s.Require().NoError(err) + + receipt, ok := content.(*types.IBCHookPacketReceipt) + s.Require().True(ok) + s.Require().Equal(expectedPacketReceipt, *receipt) +} diff --git a/x/tunnel/keeper/keeper_test.go b/x/tunnel/keeper/keeper_test.go index 07fc7d12e..1bb1dbb74 100644 --- a/x/tunnel/keeper/keeper_test.go +++ b/x/tunnel/keeper/keeper_test.go @@ -37,13 +37,14 @@ type KeeperTestSuite struct { queryServer types.QueryServer msgServer types.MsgServer - accountKeeper *testutil.MockAccountKeeper - bankKeeper *testutil.MockBankKeeper - feedsKeeper *testutil.MockFeedsKeeper - bandtssKeeper *testutil.MockBandtssKeeper - icsWrapper *testutil.MockICS4Wrapper - portKeeper *testutil.MockPortKeeper - scopedKeeper *testutil.MockScopedKeeper + accountKeeper *testutil.MockAccountKeeper + bankKeeper *testutil.MockBankKeeper + feedsKeeper *testutil.MockFeedsKeeper + bandtssKeeper *testutil.MockBandtssKeeper + icsWrapper *testutil.MockICS4Wrapper + portKeeper *testutil.MockPortKeeper + scopedKeeper *testutil.MockScopedKeeper + transferKeeper *testutil.MockTransferKeeper ctx sdk.Context authority sdk.AccAddress @@ -66,6 +67,7 @@ func (s *KeeperTestSuite) reset() { icsWrapper := testutil.NewMockICS4Wrapper(ctrl) portKeeper := testutil.NewMockPortKeeper(ctrl) scopedKeeper := testutil.NewMockScopedKeeper(ctrl) + transferKeeper := testutil.NewMockTransferKeeper(ctrl) authority := authtypes.NewModuleAddress(govtypes.ModuleName) @@ -81,6 +83,7 @@ func (s *KeeperTestSuite) reset() { icsWrapper, portKeeper, scopedKeeper, + transferKeeper, authority.String(), ) s.queryServer = keeper.NewQueryServer(s.keeper) @@ -92,6 +95,7 @@ func (s *KeeperTestSuite) reset() { s.icsWrapper = icsWrapper s.portKeeper = portKeeper s.scopedKeeper = scopedKeeper + s.transferKeeper = transferKeeper s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now().UTC()}) s.authority = authority diff --git a/x/tunnel/testutil/expected_keepers_mocks.go b/x/tunnel/testutil/expected_keepers_mocks.go index 00ed28e3b..4ddc3721d 100644 --- a/x/tunnel/testutil/expected_keepers_mocks.go +++ b/x/tunnel/testutil/expected_keepers_mocks.go @@ -18,7 +18,8 @@ import ( 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" + types4 "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + types5 "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" gomock "go.uber.org/mock/gomock" ) @@ -26,7 +27,6 @@ import ( type MockAccountKeeper struct { ctrl *gomock.Controller recorder *MockAccountKeeperMockRecorder - isgomock struct{} } // MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. @@ -130,7 +130,6 @@ func (mr *MockAccountKeeperMockRecorder) SetModuleAccount(ctx, moduleAccount any type MockBankKeeper struct { ctrl *gomock.Controller recorder *MockBankKeeperMockRecorder - isgomock struct{} } // MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. @@ -210,7 +209,6 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr any) *gomock.Call type MockICS4Wrapper struct { ctrl *gomock.Controller recorder *MockICS4WrapperMockRecorder - isgomock struct{} } // MockICS4WrapperMockRecorder is the mock recorder for MockICS4Wrapper. @@ -231,7 +229,7 @@ func (m *MockICS4Wrapper) EXPECT() *MockICS4WrapperMockRecorder { } // 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) { +func (m *MockICS4Wrapper) SendPacket(ctx types2.Context, chanCap *types3.Capability, sourcePort, sourceChannel string, timeoutHeight types5.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) @@ -249,7 +247,6 @@ func (mr *MockICS4WrapperMockRecorder) SendPacket(ctx, chanCap, sourcePort, sour type MockPortKeeper struct { ctrl *gomock.Controller recorder *MockPortKeeperMockRecorder - isgomock struct{} } // MockPortKeeperMockRecorder is the mock recorder for MockPortKeeper. @@ -287,7 +284,6 @@ func (mr *MockPortKeeperMockRecorder) BindPort(ctx, portID any) *gomock.Call { type MockScopedKeeper struct { ctrl *gomock.Controller recorder *MockScopedKeeperMockRecorder - isgomock struct{} } // MockScopedKeeperMockRecorder is the mock recorder for MockScopedKeeper. @@ -350,11 +346,48 @@ func (mr *MockScopedKeeperMockRecorder) GetCapability(ctx, name any) *gomock.Cal return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCapability", reflect.TypeOf((*MockScopedKeeper)(nil).GetCapability), ctx, name) } +// MockTransferKeeper is a mock of TransferKeeper interface. +type MockTransferKeeper struct { + ctrl *gomock.Controller + recorder *MockTransferKeeperMockRecorder +} + +// MockTransferKeeperMockRecorder is the mock recorder for MockTransferKeeper. +type MockTransferKeeperMockRecorder struct { + mock *MockTransferKeeper +} + +// NewMockTransferKeeper creates a new mock instance. +func NewMockTransferKeeper(ctrl *gomock.Controller) *MockTransferKeeper { + mock := &MockTransferKeeper{ctrl: ctrl} + mock.recorder = &MockTransferKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTransferKeeper) EXPECT() *MockTransferKeeperMockRecorder { + return m.recorder +} + +// Transfer mocks base method. +func (m *MockTransferKeeper) Transfer(goCtx context.Context, msg *types4.MsgTransfer) (*types4.MsgTransferResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Transfer", goCtx, msg) + ret0, _ := ret[0].(*types4.MsgTransferResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Transfer indicates an expected call of Transfer. +func (mr *MockTransferKeeperMockRecorder) Transfer(goCtx, msg any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Transfer", reflect.TypeOf((*MockTransferKeeper)(nil).Transfer), goCtx, msg) +} + // MockFeedsKeeper is a mock of FeedsKeeper interface. type MockFeedsKeeper struct { ctrl *gomock.Controller recorder *MockFeedsKeeperMockRecorder - isgomock struct{} } // MockFeedsKeeperMockRecorder is the mock recorder for MockFeedsKeeper. @@ -406,7 +439,6 @@ func (mr *MockFeedsKeeperMockRecorder) GetPrices(ctx, signalIDs any) *gomock.Cal type MockBandtssKeeper struct { ctrl *gomock.Controller recorder *MockBandtssKeeperMockRecorder - isgomock struct{} } // MockBandtssKeeperMockRecorder is the mock recorder for MockBandtssKeeper. diff --git a/x/tunnel/types/codec.go b/x/tunnel/types/codec.go index da8e3b7a8..552d7471c 100644 --- a/x/tunnel/types/codec.go +++ b/x/tunnel/types/codec.go @@ -30,10 +30,12 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*RouteI)(nil), nil) cdc.RegisterConcrete(&TSSRoute{}, "tunnel/TSSRoute", nil) cdc.RegisterConcrete(&IBCRoute{}, "tunnel/IBCRoute", nil) + cdc.RegisterConcrete(&IBCHookRoute{}, "tunnel/IBCHookRoute", nil) cdc.RegisterInterface((*PacketReceiptI)(nil), nil) cdc.RegisterConcrete(&TSSPacketReceipt{}, "tunnel/TSSPacketReceipt", nil) cdc.RegisterConcrete(&IBCPacketReceipt{}, "tunnel/IBCPacketReceipt", nil) + cdc.RegisterConcrete(&IBCHookPacketReceipt{}, "tunnel/IBCHookPacketReceipt", nil) cdc.RegisterConcrete(Params{}, "tunnel/Params", nil) } @@ -57,12 +59,14 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*RouteI)(nil), &TSSRoute{}, &IBCRoute{}, + &IBCHookRoute{}, ) registry.RegisterInterface( "tunnel.v1beta1.PacketReceiptI", (*PacketReceiptI)(nil), &TSSPacketReceipt{}, + &IBCPacketReceipt{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/tunnel/types/expected_keepers.go b/x/tunnel/types/expected_keepers.go index 555edcf2a..3450eacea 100644 --- a/x/tunnel/types/expected_keepers.go +++ b/x/tunnel/types/expected_keepers.go @@ -4,6 +4,7 @@ import ( "context" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -64,6 +65,11 @@ type ScopedKeeper interface { ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error } +// TransferKeeper defines the expected IBC transfer keeper +type TransferKeeper interface { + Transfer(goCtx context.Context, msg *ibctransfertypes.MsgTransfer) (*ibctransfertypes.MsgTransferResponse, 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/memo_ibc_hook.go b/x/tunnel/types/memo_ibc_hook.go new file mode 100644 index 000000000..46463dbcb --- /dev/null +++ b/x/tunnel/types/memo_ibc_hook.go @@ -0,0 +1,63 @@ +package types + +import ( + "encoding/json" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" +) + +// ReceiveBandData represents the data structure of the IBC hook message. +type ReceiveBandData struct { + TunnelID uint64 `json:"tunnel_id"` + Sequence uint64 `json:"sequence"` + Prices []feedstypes.Price `json:"prices"` + CreatedAt int64 `json:"created_at"` +} + +// IBCHookMsg represents the message structure of the IBC hook message. +type IBCHookMsg struct { + ReceiveBandData ReceiveBandData `json:"receive_band_data"` +} + +// IBCHookWasm represents the WASM contract and its associated message. +type IBCHookWasm struct { + Contract string `json:"contract"` + Msg IBCHookMsg `json:"msg"` +} + +// IBCHookMemo represents the IBC hook memo structure. +type IBCHookMemo struct { + Wasm IBCHookWasm `json:"wasm"` +} + +// NewIBCHookMemo creates a new IBCHookMemo instance. +func NewIBCHookMemo( + contract string, + tunnelID uint64, + sequence uint64, + prices []feedstypes.Price, + createdAt int64, +) IBCHookMemo { + return IBCHookMemo{ + Wasm: IBCHookWasm{ + Contract: contract, + Msg: IBCHookMsg{ + ReceiveBandData: ReceiveBandData{ + TunnelID: tunnelID, + Sequence: sequence, + Prices: prices, + CreatedAt: createdAt, + }, + }, + }, + } +} + +// String marshals the IBCHookMemo into a JSON string. +func (r IBCHookMemo) String() (string, error) { + j, err := json.Marshal(r) + if err != nil { + return "", err + } + return string(j), nil +} diff --git a/x/tunnel/types/memo_ibc_hook_test.go b/x/tunnel/types/memo_ibc_hook_test.go new file mode 100644 index 000000000..102a5a56d --- /dev/null +++ b/x/tunnel/types/memo_ibc_hook_test.go @@ -0,0 +1,30 @@ +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 TestStringIBCHookMemo(t *testing.T) { + memo := types.NewIBCHookMemo( + "wasm1vjq0k3fj47s8wns4a7zw5c4lsjd8l6r2kzzlpk", + 1, + 2, + []feedstypes.Price{ + {Status: feedstypes.PRICE_STATUS_AVAILABLE, SignalID: "signal1", Price: 200}, + {Status: feedstypes.PRICE_STATUS_AVAILABLE, SignalID: "signal2", Price: 300}, + }, + 1610000000, + ) + memoStr, err := memo.String() + require.NoError(t, err) + require.Equal( + t, + `{"wasm":{"contract":"wasm1vjq0k3fj47s8wns4a7zw5c4lsjd8l6r2kzzlpk","msg":{"receive_band_data":{"tunnel_id":1,"sequence":2,"prices":[{"status":3,"signal_id":"signal1","price":200},{"status":3,"signal_id":"signal2","price":300}],"created_at":1610000000}}}}`, + memoStr, + ) +} diff --git a/x/tunnel/types/msgs.go b/x/tunnel/types/msgs.go index ca1cf347d..ce4cfbca2 100644 --- a/x/tunnel/types/msgs.go +++ b/x/tunnel/types/msgs.go @@ -84,6 +84,25 @@ func NewMsgCreateIBCTunnel( return m, nil } +// NewMsgCreateIBCHookTunnel creates a new MsgCreateTunnel instance for IBC hook tunnel. +func NewMsgCreateIBCHookTunnel( + signalDeviations []SignalDeviation, + interval uint64, + channelID string, + destinationContractAddress string, + encoder feedstypes.Encoder, + deposit sdk.Coins, + creator sdk.AccAddress, +) (*MsgCreateTunnel, error) { + r := NewIBCHookRoute(channelID, destinationContractAddress) + 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 a808f2871..6016ba241 100644 --- a/x/tunnel/types/route.pb.go +++ b/x/tunnel/types/route.pb.go @@ -292,51 +292,155 @@ func (m *IBCPacket) GetCreatedAt() int64 { return 0 } +// IBCHookRoute is the type for an IBC hook route +type IBCHookRoute struct { + // channel_id is the IBC channel ID + ChannelID string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // destination_contract_address is the destination contract address + DestinationContractAddress string `protobuf:"bytes,2,opt,name=destination_contract_address,json=destinationContractAddress,proto3" json:"destination_contract_address,omitempty"` +} + +func (m *IBCHookRoute) Reset() { *m = IBCHookRoute{} } +func (m *IBCHookRoute) String() string { return proto.CompactTextString(m) } +func (*IBCHookRoute) ProtoMessage() {} +func (*IBCHookRoute) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{5} +} +func (m *IBCHookRoute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCHookRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCHookRoute.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 *IBCHookRoute) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCHookRoute.Merge(m, src) +} +func (m *IBCHookRoute) XXX_Size() int { + return m.Size() +} +func (m *IBCHookRoute) XXX_DiscardUnknown() { + xxx_messageInfo_IBCHookRoute.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCHookRoute proto.InternalMessageInfo + +func (m *IBCHookRoute) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *IBCHookRoute) GetDestinationContractAddress() string { + if m != nil { + return m.DestinationContractAddress + } + return "" +} + +// IBCHookPacketReceipt represents a receipt for a IBC hook packet and implements the PacketReceiptI interface. +type IBCHookPacketReceipt struct { + // sequence is representing the sequence of the IBC packet. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *IBCHookPacketReceipt) Reset() { *m = IBCHookPacketReceipt{} } +func (m *IBCHookPacketReceipt) String() string { return proto.CompactTextString(m) } +func (*IBCHookPacketReceipt) ProtoMessage() {} +func (*IBCHookPacketReceipt) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{6} +} +func (m *IBCHookPacketReceipt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCHookPacketReceipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCHookPacketReceipt.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 *IBCHookPacketReceipt) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCHookPacketReceipt.Merge(m, src) +} +func (m *IBCHookPacketReceipt) XXX_Size() int { + return m.Size() +} +func (m *IBCHookPacketReceipt) XXX_DiscardUnknown() { + xxx_messageInfo_IBCHookPacketReceipt.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCHookPacketReceipt proto.InternalMessageInfo + +func (m *IBCHookPacketReceipt) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + 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((*IBCPacket)(nil), "band.tunnel.v1beta1.IBCPacket") + proto.RegisterType((*IBCHookRoute)(nil), "band.tunnel.v1beta1.IBCHookRoute") + proto.RegisterType((*IBCHookPacketReceipt)(nil), "band.tunnel.v1beta1.IBCHookPacketReceipt") } func init() { proto.RegisterFile("band/tunnel/v1beta1/route.proto", fileDescriptor_543238289d94b7a6) } var fileDescriptor_543238289d94b7a6 = []byte{ - // 515 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xbd, 0x8e, 0x13, 0x31, - 0x10, 0xc7, 0xb3, 0x97, 0x10, 0x65, 0xcd, 0x87, 0x4e, 0xcb, 0x09, 0xe5, 0x22, 0xd8, 0x8d, 0x52, - 0x05, 0x89, 0xac, 0x75, 0x5c, 0x81, 0x94, 0x8a, 0xdb, 0xa4, 0xc0, 0x42, 0x48, 0xa7, 0x4d, 0x2a, - 0x9a, 0xc8, 0xb1, 0x4d, 0xb2, 0x70, 0x67, 0x87, 0xb5, 0x73, 0x82, 0xb7, 0x40, 0x3c, 0x02, 0x15, - 0xa2, 0xce, 0x43, 0x9c, 0x52, 0x5d, 0x49, 0x15, 0xa1, 0xcd, 0x5b, 0x50, 0x21, 0x7f, 0x90, 0xdc, - 0x52, 0xd1, 0xad, 0xff, 0xf3, 0xf3, 0xfc, 0x67, 0xc6, 0xb3, 0x20, 0x9a, 0x62, 0x4e, 0xa1, 0x5a, - 0x72, 0xce, 0x2e, 0xe0, 0xd5, 0xc9, 0x94, 0x29, 0x7c, 0x02, 0x73, 0xb1, 0x54, 0x2c, 0x5e, 0xe4, - 0x42, 0x89, 0xe0, 0xa1, 0x06, 0x62, 0x0b, 0xc4, 0x0e, 0x68, 0x1d, 0x13, 0x21, 0x2f, 0x85, 0x9c, - 0x18, 0x04, 0xda, 0x83, 0xe5, 0x5b, 0x47, 0x33, 0x31, 0x13, 0x56, 0xd7, 0x5f, 0x4e, 0x0d, 0x8d, - 0xcd, 0x3b, 0xc6, 0xa8, 0xdc, 0xb9, 0x98, 0x93, 0x8d, 0x77, 0xbe, 0x79, 0xa0, 0x31, 0x1e, 0x8d, - 0x52, 0x6d, 0x1c, 0xbc, 0x02, 0x47, 0x94, 0x49, 0x95, 0x71, 0xac, 0x32, 0xc1, 0x27, 0x64, 0x8e, - 0x33, 0x3e, 0xc9, 0x68, 0xd3, 0x6b, 0x7b, 0x5d, 0x3f, 0x79, 0x54, 0x6c, 0xa2, 0x60, 0xb8, 0x8f, - 0x0f, 0x74, 0x18, 0x0d, 0xd3, 0x80, 0xfe, 0xab, 0xd1, 0xe0, 0x25, 0x78, 0x5c, 0xca, 0x24, 0xb8, - 0xca, 0x31, 0x51, 0x13, 0x4c, 0x69, 0xce, 0xa4, 0x6c, 0x1e, 0xe8, 0x8c, 0x69, 0xeb, 0xf6, 0x4d, - 0x87, 0x9c, 0x59, 0xa2, 0x0f, 0xd6, 0xab, 0x5e, 0xdd, 0x94, 0x85, 0x3a, 0x5f, 0x3d, 0x70, 0x38, - 0x1e, 0x8d, 0xce, 0x31, 0xf9, 0xc0, 0x54, 0xca, 0x08, 0xcb, 0x16, 0x2a, 0x78, 0x0f, 0x80, 0xcc, - 0x66, 0x3c, 0xe3, 0xb3, 0xbf, 0x25, 0xd6, 0x92, 0xd7, 0xc5, 0x26, 0xf2, 0x47, 0x56, 0x45, 0xc3, - 0xdf, 0x9b, 0xa8, 0x3f, 0xcb, 0xd4, 0x7c, 0x39, 0x8d, 0x89, 0xb8, 0x84, 0x7a, 0x12, 0xa6, 0x69, - 0x22, 0x2e, 0xa0, 0xe9, 0x0d, 0x5e, 0x9d, 0xc2, 0x4f, 0x46, 0x57, 0x52, 0x42, 0xf5, 0x79, 0xc1, - 0x64, 0xbc, 0xbb, 0x9d, 0xfa, 0x2e, 0x3d, 0xa2, 0xfd, 0x60, 0xbd, 0xea, 0x3d, 0x28, 0xd9, 0xa3, - 0xce, 0x00, 0x34, 0x50, 0x32, 0xb0, 0x83, 0x7b, 0x06, 0x00, 0x99, 0x63, 0xfd, 0x52, 0xfb, 0x71, - 0xdd, 0xd7, 0xb5, 0x0c, 0xac, 0xaa, 0xb3, 0x39, 0x00, 0xd1, 0xbe, 0xbf, 0x5e, 0xf5, 0xee, 0x98, - 0x8b, 0x9d, 0x04, 0x1c, 0xa2, 0x64, 0x50, 0x6e, 0xac, 0x05, 0x1a, 0x92, 0x7d, 0x5c, 0x32, 0x4e, - 0x98, 0x6d, 0x2b, 0xdd, 0x9d, 0x6f, 0x17, 0xa2, 0x07, 0xc6, 0xb8, 0x42, 0x9d, 0x1f, 0x1e, 0xf0, - 0x77, 0x49, 0x82, 0xa7, 0xc0, 0xb7, 0x3b, 0xb3, 0x9f, 0xca, 0xbd, 0x62, 0x13, 0x35, 0xc6, 0x4b, - 0x57, 0x48, 0xc3, 0x86, 0x11, 0x2d, 0x19, 0x1d, 0x94, 0x8d, 0x82, 0x17, 0xa0, 0xbe, 0xc8, 0x33, - 0xc2, 0x64, 0xb3, 0xda, 0xae, 0x76, 0xef, 0x3e, 0x3f, 0x8e, 0xcd, 0x3a, 0xda, 0xd5, 0x71, 0x8b, - 0x14, 0x9f, 0x6b, 0x22, 0xa9, 0x5d, 0x6f, 0xa2, 0x4a, 0xea, 0xf0, 0xe0, 0x09, 0x00, 0x24, 0x67, - 0x58, 0x31, 0x3a, 0xc1, 0xaa, 0x59, 0x6b, 0x7b, 0xdd, 0x6a, 0xea, 0x3b, 0xe5, 0x4c, 0x25, 0x6f, - 0xbe, 0x17, 0xa1, 0x77, 0x5d, 0x84, 0xde, 0x4d, 0x11, 0x7a, 0xbf, 0x8a, 0xd0, 0xfb, 0xb2, 0x0d, - 0x2b, 0x37, 0xdb, 0xb0, 0xf2, 0x73, 0x1b, 0x56, 0xde, 0xc2, 0xff, 0x78, 0x2e, 0xf7, 0xcb, 0x98, - 0xd7, 0x9a, 0xd6, 0x0d, 0x71, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x20, 0x56, 0xad, 0x4e, - 0x03, 0x00, 0x00, + // 543 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0x9b, 0x10, 0xc5, 0x43, 0x41, 0x95, 0x89, 0x50, 0x1a, 0x81, 0x1d, 0x79, 0x15, 0x24, + 0x62, 0xab, 0x74, 0x81, 0x94, 0x15, 0xb5, 0x23, 0xd4, 0x11, 0x42, 0xaa, 0x9c, 0xac, 0xd8, 0x44, + 0xce, 0xcc, 0x90, 0x98, 0xb6, 0x33, 0xc1, 0x33, 0xa9, 0xe0, 0x13, 0xd8, 0x21, 0x3e, 0x81, 0x15, + 0x62, 0x9d, 0x8f, 0xa8, 0xb2, 0xea, 0x92, 0x55, 0x84, 0x9c, 0xbf, 0x60, 0x85, 0xe6, 0x41, 0x1e, + 0xac, 0x10, 0xb0, 0xf3, 0x9c, 0x7b, 0xe6, 0xde, 0x73, 0xcf, 0x1c, 0x19, 0x78, 0xa3, 0x94, 0xe2, + 0x50, 0xcc, 0x28, 0x25, 0x17, 0xe1, 0xd5, 0xd1, 0x88, 0x88, 0xf4, 0x28, 0xcc, 0xd9, 0x4c, 0x90, + 0x60, 0x9a, 0x33, 0xc1, 0x9c, 0x7b, 0x92, 0x10, 0x68, 0x42, 0x60, 0x08, 0xcd, 0x43, 0xc4, 0xf8, + 0x25, 0xe3, 0x43, 0x45, 0x09, 0xf5, 0x41, 0xf3, 0x9b, 0xf5, 0x31, 0x1b, 0x33, 0x8d, 0xcb, 0x2f, + 0x83, 0xba, 0x6a, 0xcc, 0x6b, 0x42, 0x30, 0x5f, 0x4f, 0x51, 0x27, 0x5d, 0xf7, 0x3f, 0x5b, 0xa0, + 0x36, 0xe8, 0xf7, 0x13, 0x39, 0xd8, 0x39, 0x05, 0x75, 0x4c, 0xb8, 0xc8, 0x68, 0x2a, 0x32, 0x46, + 0x87, 0x68, 0x92, 0x66, 0x74, 0x98, 0xe1, 0x86, 0xd5, 0xb2, 0xda, 0x76, 0x74, 0xbf, 0x58, 0x7a, + 0x4e, 0x6f, 0x53, 0x8f, 0x65, 0x19, 0xf6, 0x12, 0x07, 0xff, 0x8e, 0x61, 0xe7, 0x19, 0x78, 0xb0, + 0xd3, 0x89, 0x51, 0x91, 0xa7, 0x48, 0x0c, 0x53, 0x8c, 0x73, 0xc2, 0x79, 0x63, 0x4f, 0x76, 0x4c, + 0x9a, 0xdb, 0x37, 0x0d, 0xe5, 0x44, 0x33, 0xba, 0x60, 0x31, 0xef, 0x54, 0x95, 0x2c, 0xe8, 0x7f, + 0xb2, 0xc0, 0xc1, 0xa0, 0xdf, 0x3f, 0x4b, 0xd1, 0x39, 0x11, 0x09, 0x41, 0x24, 0x9b, 0x0a, 0xe7, + 0x0d, 0x00, 0x3c, 0x1b, 0xd3, 0x8c, 0x8e, 0x7f, 0x49, 0xac, 0x44, 0x2f, 0x8a, 0xa5, 0x67, 0xf7, + 0x35, 0x0a, 0x7b, 0x3f, 0x96, 0x5e, 0x77, 0x9c, 0x89, 0xc9, 0x6c, 0x14, 0x20, 0x76, 0x19, 0x4a, + 0x27, 0xd4, 0xd2, 0x88, 0x5d, 0x84, 0x6a, 0xb7, 0xf0, 0xea, 0x38, 0x7c, 0xa7, 0x70, 0xc1, 0x79, + 0x28, 0xde, 0x4f, 0x09, 0x0f, 0xd6, 0xb7, 0x13, 0xdb, 0xb4, 0x87, 0xb8, 0xeb, 0x2c, 0xe6, 0x9d, + 0xbb, 0x3b, 0xe3, 0xa1, 0x1f, 0x83, 0x1a, 0x8c, 0x62, 0x6d, 0xdc, 0x63, 0x00, 0xd0, 0x24, 0x95, + 0x2f, 0xb5, 0xb1, 0xeb, 0x8e, 0xd4, 0x12, 0x6b, 0x54, 0x76, 0x33, 0x04, 0x88, 0xbb, 0xf6, 0x62, + 0xde, 0xb9, 0xa5, 0x2e, 0xfa, 0x11, 0x38, 0x80, 0x51, 0xbc, 0xbb, 0x58, 0x13, 0xd4, 0x38, 0x79, + 0x3b, 0x23, 0x14, 0x11, 0xbd, 0x56, 0xb2, 0x3e, 0x6f, 0x0b, 0x91, 0x86, 0x11, 0x2a, 0xa0, 0xff, + 0xd5, 0x02, 0xf6, 0xba, 0x89, 0xf3, 0x08, 0xd8, 0x3a, 0x33, 0x1b, 0x57, 0xf6, 0x8b, 0xa5, 0x57, + 0x1b, 0xcc, 0x8c, 0x90, 0x9a, 0x2e, 0x43, 0xbc, 0x33, 0x68, 0x6f, 0x77, 0x90, 0xf3, 0x14, 0x54, + 0xa7, 0x79, 0x86, 0x08, 0x6f, 0x94, 0x5b, 0xe5, 0xf6, 0xed, 0x27, 0x87, 0x81, 0x8a, 0xa3, 0x8e, + 0x8e, 0x09, 0x52, 0x70, 0x26, 0x19, 0x51, 0xe5, 0x7a, 0xe9, 0x95, 0x12, 0x43, 0x77, 0x1e, 0x02, + 0x80, 0x72, 0x92, 0x0a, 0x82, 0x87, 0xa9, 0x68, 0x54, 0x5a, 0x56, 0xbb, 0x9c, 0xd8, 0x06, 0x39, + 0x11, 0xfe, 0x07, 0x0b, 0xec, 0xc3, 0x28, 0x3e, 0x65, 0xec, 0xfc, 0x2f, 0xac, 0xfb, 0x0f, 0xb9, + 0xda, 0x32, 0xff, 0x39, 0xa8, 0x1b, 0x29, 0xff, 0xf4, 0x00, 0xd1, 0xcb, 0x2f, 0x85, 0x6b, 0x5d, + 0x17, 0xae, 0x75, 0x53, 0xb8, 0xd6, 0xf7, 0xc2, 0xb5, 0x3e, 0xae, 0xdc, 0xd2, 0xcd, 0xca, 0x2d, + 0x7d, 0x5b, 0xb9, 0xa5, 0x57, 0xe1, 0x1f, 0x44, 0xd0, 0xfc, 0x06, 0x54, 0x02, 0x47, 0x55, 0xc5, + 0x38, 0xfe, 0x19, 0x00, 0x00, 0xff, 0xff, 0x79, 0x34, 0x5f, 0x42, 0x22, 0x04, 0x00, 0x00, } func (this *TSSRoute) Equal(that interface{}) bool { @@ -476,6 +580,57 @@ func (this *IBCPacket) Equal(that interface{}) bool { } return true } +func (this *IBCHookRoute) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCHookRoute) + if !ok { + that2, ok := that.(IBCHookRoute) + 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 + } + if this.DestinationContractAddress != that1.DestinationContractAddress { + return false + } + return true +} +func (this *IBCHookPacketReceipt) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCHookPacketReceipt) + if !ok { + that2, ok := that.(IBCHookPacketReceipt) + 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 (m *TSSRoute) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -651,6 +806,71 @@ func (m *IBCPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IBCHookRoute) 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 *IBCHookRoute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCHookRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DestinationContractAddress) > 0 { + i -= len(m.DestinationContractAddress) + copy(dAtA[i:], m.DestinationContractAddress) + i = encodeVarintRoute(dAtA, i, uint64(len(m.DestinationContractAddress))) + i-- + dAtA[i] = 0x12 + } + 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 *IBCHookPacketReceipt) 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 *IBCHookPacketReceipt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCHookPacketReceipt) 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 encodeVarintRoute(dAtA []byte, offset int, v uint64) int { offset -= sovRoute(v) base := offset @@ -740,6 +960,35 @@ func (m *IBCPacket) Size() (n int) { return n } +func (m *IBCHookRoute) 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)) + } + l = len(m.DestinationContractAddress) + if l > 0 { + n += 1 + l + sovRoute(uint64(l)) + } + return n +} + +func (m *IBCHookPacketReceipt) 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 sovRoute(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1221,6 +1470,189 @@ func (m *IBCPacket) Unmarshal(dAtA []byte) error { } return nil } +func (m *IBCHookRoute) 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: IBCHookRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCHookRoute: 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationContractAddress", 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.DestinationContractAddress = 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 *IBCHookPacketReceipt) 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: IBCHookPacketReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCHookPacketReceipt: 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 skipRoute(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tunnel/types/route_ibc_hook.go b/x/tunnel/types/route_ibc_hook.go new file mode 100644 index 000000000..5665335c5 --- /dev/null +++ b/x/tunnel/types/route_ibc_hook.go @@ -0,0 +1,32 @@ +package types + +import ( + "fmt" +) + +// IBCRoute defines the IBC route for the tunnel module +var _ RouteI = &IBCHookRoute{} + +// NewIBCHookRoute creates a new IBCHookRoute instance. It is used to create the IBC hook route data +func NewIBCHookRoute(channelID, destinationContractAddress string) *IBCHookRoute { + return &IBCHookRoute{ + ChannelID: channelID, + DestinationContractAddress: destinationContractAddress, + } +} + +// Route defines the IBC route for the tunnel module +func (r *IBCHookRoute) ValidateBasic() error { + // Validate the ChannelID format + if !IsChannelIDFormat(r.ChannelID) { + return fmt.Errorf("channel identifier is not in the format: `channel-{N}`") + } + return nil +} + +// NewIBCHookPacketReceipt creates a new IBCHookPacketReceipt instance. It is used to create the IBC hook packet receipt data +func NewIBCHookPacketReceipt(sequence uint64) *IBCHookPacketReceipt { + return &IBCHookPacketReceipt{ + Sequence: sequence, + } +} diff --git a/x/tunnel/types/route_ibc_hook_test.go b/x/tunnel/types/route_ibc_hook_test.go new file mode 100644 index 000000000..36cab22a0 --- /dev/null +++ b/x/tunnel/types/route_ibc_hook_test.go @@ -0,0 +1,54 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func TestIBCHookRoute_ValidateBasic(t *testing.T) { + tests := []struct { + name string + route types.IBCHookRoute + expErr bool + errMsg string + }{ + { + name: "invalid channel ID", + route: types.IBCHookRoute{ + ChannelID: "invalid-channel", + }, + expErr: true, + errMsg: "channel identifier is not in the format: `channel-{N}`", + }, + { + name: "empty channel ID", + route: types.IBCHookRoute{ + ChannelID: "", + }, + expErr: true, + errMsg: "channel identifier is not in the format: `channel-{N}`", + }, + { + name: "all good", + route: types.IBCHookRoute{ + ChannelID: "channel-1", + }, + expErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.route.ValidateBasic() + if tt.expErr { + require.Error(t, err) + require.Equal(t, tt.errMsg, err.Error()) + } else { + require.NoError(t, err) + } + }) + } +}