From a8bcd0e3a5c3f8361d16f7257fe83deba763eb97 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 13 Mar 2024 11:31:26 -0500 Subject: [PATCH 01/28] Initial proto --- proto/addressmap/v1/addressmap.proto | 10 ++++++ proto/addressmap/v1/genesis.proto | 10 ++++++ proto/addressmap/v1/query.proto | 50 ++++++++++++++++++++++++++++ proto/addressmap/v1/tx.proto | 22 ++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 proto/addressmap/v1/addressmap.proto create mode 100644 proto/addressmap/v1/genesis.proto create mode 100644 proto/addressmap/v1/query.proto create mode 100644 proto/addressmap/v1/tx.proto diff --git a/proto/addressmap/v1/addressmap.proto b/proto/addressmap/v1/addressmap.proto new file mode 100644 index 00000000..9e603cb5 --- /dev/null +++ b/proto/addressmap/v1/addressmap.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package addressmap.v1; + +option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; + +message AddressMapping { + string cosmos_address = 1; + string evm_address = 2; +} + diff --git a/proto/addressmap/v1/genesis.proto b/proto/addressmap/v1/genesis.proto new file mode 100644 index 00000000..bc7113b1 --- /dev/null +++ b/proto/addressmap/v1/genesis.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package addressmap.v1; + +option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; + +import "addressmap/v1/addressmap.proto"; + +message GenesisState { + repeated AddressMapping address_mappings = 1; +} diff --git a/proto/addressmap/v1/query.proto b/proto/addressmap/v1/query.proto new file mode 100644 index 00000000..d7f48f82 --- /dev/null +++ b/proto/addressmap/v1/query.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package addressmap.v1; + +import "addressmap/v1/addressmap.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + + +option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; + +service Query { + rpc QueryAddressMappings(QueryAddressMappingsRequest) returns (QueryAddressMappingsResponse) { + option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings/{?pagination.limit,pagination.offset,pagination.count_total}"; + } + + rpc QueryAddressMappingByEVMAddress(QueryAddressMappingByEVMAddressRequest) returns (QueryAddressMappingByEVMAddressResponse) { + option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings/evm/{evm_address}"; + } + + rpc QueryAddressMappingByCosmosAddress(QueryAddressMappingByCosmosAddressRequest) returns (QueryAddressMappingByCosmosAddressResponse) { + option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings/cosmos/{cosmos_address}"; + } +} + +message QueryAddressMappingsRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1 [ (gogoproto.nullable) = false ]; +} + +message QueryAddressMappingsResponse { + repeated AddressMapping address_mappings = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2 [ (gogoproto.nullable) = false ]; +} + +message QueryAddressMappingByEVMAddressRequest { + string evm_address = 1; +} + +message QueryAddressMappingByEVMAddressResponse { + AddressMapping address_mapping = 1; +} + +message QueryAddressMappingByCosmosAddressRequest { + string cosmos_address = 1; +} + +message QueryAddressMappingByCosmosAddressResponse { + AddressMapping address_mapping = 1; +} diff --git a/proto/addressmap/v1/tx.proto b/proto/addressmap/v1/tx.proto new file mode 100644 index 00000000..73c3878f --- /dev/null +++ b/proto/addressmap/v1/tx.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package addressmap.v1; + +option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; + +service Msg { + // Adds a mapping between the cosmos address of the sender and the provided EVM address + rpc AddAddressMapping (MsgSetAddressMappingRequest) returns (MsgSetAddressMappingResponse); + // Removes the mapping containing the cosmos address of the sender + rpc RemoveAddressMapping (MsgRemoveAddressMappingRequest) returns (MsgRemoveAddressMappingResponse); +} + +message MsgAddAddressMappingRequest { + string evm_address = 1; +} + +message MsgAddAddressMappingResponse {} + +message MsgRemoveAddressMappingRequest {} + +message MsgRemoveAddressMappingResponse {} + From 1814cf11bd1acb0141de06dc26dbe5c6d4cce401 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 13 Mar 2024 12:49:02 -0500 Subject: [PATCH 02/28] Generate addressmap proto bindings --- proto/addressmap/v1/addressmap.proto | 4 +- proto/addressmap/v1/query.proto | 2 +- proto/addressmap/v1/tx.proto | 2 +- proto/buf.lock | 4 +- x/addressmap/types/v1/addressmap.pb.go | 367 ++++++ x/addressmap/types/v1/genesis.pb.go | 328 ++++++ x/addressmap/types/v1/query.pb.go | 1445 ++++++++++++++++++++++++ x/addressmap/types/v1/query.pb.gw.go | 373 ++++++ x/addressmap/types/v1/tx.pb.go | 803 +++++++++++++ 9 files changed, 3322 insertions(+), 6 deletions(-) create mode 100644 x/addressmap/types/v1/addressmap.pb.go create mode 100644 x/addressmap/types/v1/genesis.pb.go create mode 100644 x/addressmap/types/v1/query.pb.go create mode 100644 x/addressmap/types/v1/query.pb.gw.go create mode 100644 x/addressmap/types/v1/tx.pb.go diff --git a/proto/addressmap/v1/addressmap.proto b/proto/addressmap/v1/addressmap.proto index 9e603cb5..04ae6279 100644 --- a/proto/addressmap/v1/addressmap.proto +++ b/proto/addressmap/v1/addressmap.proto @@ -4,7 +4,7 @@ package addressmap.v1; option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; message AddressMapping { - string cosmos_address = 1; - string evm_address = 2; + string cosmos_address = 1; + string evm_address = 2; } diff --git a/proto/addressmap/v1/query.proto b/proto/addressmap/v1/query.proto index d7f48f82..2ff997db 100644 --- a/proto/addressmap/v1/query.proto +++ b/proto/addressmap/v1/query.proto @@ -12,7 +12,7 @@ option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; service Query { rpc QueryAddressMappings(QueryAddressMappingsRequest) returns (QueryAddressMappingsResponse) { - option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings/{?pagination.limit,pagination.offset,pagination.count_total}"; + option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings"; } rpc QueryAddressMappingByEVMAddress(QueryAddressMappingByEVMAddressRequest) returns (QueryAddressMappingByEVMAddressResponse) { diff --git a/proto/addressmap/v1/tx.proto b/proto/addressmap/v1/tx.proto index 73c3878f..9f556579 100644 --- a/proto/addressmap/v1/tx.proto +++ b/proto/addressmap/v1/tx.proto @@ -5,7 +5,7 @@ option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; service Msg { // Adds a mapping between the cosmos address of the sender and the provided EVM address - rpc AddAddressMapping (MsgSetAddressMappingRequest) returns (MsgSetAddressMappingResponse); + rpc AddAddressMapping (MsgAddAddressMappingRequest) returns (MsgAddAddressMappingResponse); // Removes the mapping containing the cosmos address of the sender rpc RemoveAddressMapping (MsgRemoveAddressMappingRequest) returns (MsgRemoveAddressMappingResponse); } diff --git a/proto/buf.lock b/proto/buf.lock index 3fa18eb3..9ba5b6fd 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -14,5 +14,5 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 7e6f6e774e29406da95bd61cdcdbc8bc - digest: shake256:fe43dd2265ea0c07d76bd925eeba612667cf4c948d2ce53d6e367e1b4b3cb5fa69a51e6acb1a6a50d32f894f054a35e6c0406f6808a483f2752e10c866ffbf73 + commit: ee48893a270147348e3edc6c1a03de0e + digest: shake256:a35b0576a2b55dad72747e786af05c03539c2b96be236c9de39fe10d551931ac252eb68445c0cef6bbd27fa20e8c26eee5b8a9fe9c2fde6f63a03e18f8cf980d diff --git a/x/addressmap/types/v1/addressmap.pb.go b/x/addressmap/types/v1/addressmap.pb.go new file mode 100644 index 00000000..740f291b --- /dev/null +++ b/x/addressmap/types/v1/addressmap.pb.go @@ -0,0 +1,367 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: addressmap/v1/addressmap.proto + +package v1 + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type AddressMapping struct { + CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty"` + EvmAddress string `protobuf:"bytes,2,opt,name=evm_address,json=evmAddress,proto3" json:"evm_address,omitempty"` +} + +func (m *AddressMapping) Reset() { *m = AddressMapping{} } +func (m *AddressMapping) String() string { return proto.CompactTextString(m) } +func (*AddressMapping) ProtoMessage() {} +func (*AddressMapping) Descriptor() ([]byte, []int) { + return fileDescriptor_8c4a56c34c721369, []int{0} +} +func (m *AddressMapping) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddressMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddressMapping.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 *AddressMapping) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddressMapping.Merge(m, src) +} +func (m *AddressMapping) XXX_Size() int { + return m.Size() +} +func (m *AddressMapping) XXX_DiscardUnknown() { + xxx_messageInfo_AddressMapping.DiscardUnknown(m) +} + +var xxx_messageInfo_AddressMapping proto.InternalMessageInfo + +func (m *AddressMapping) GetCosmosAddress() string { + if m != nil { + return m.CosmosAddress + } + return "" +} + +func (m *AddressMapping) GetEvmAddress() string { + if m != nil { + return m.EvmAddress + } + return "" +} + +func init() { + proto.RegisterType((*AddressMapping)(nil), "addressmap.v1.AddressMapping") +} + +func init() { proto.RegisterFile("addressmap/v1/addressmap.proto", fileDescriptor_8c4a56c34c721369) } + +var fileDescriptor_8c4a56c34c721369 = []byte{ + // 190 bytes of a gzipped FileD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0xff, 0xff, 0xfe, 0x2f, 0x02, 0x17, 0xe2, 0x00, 0x00, 0x00, +} + +func (m *AddressMapping) 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 *AddressMapping) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddressMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EvmAddress) > 0 { + i -= len(m.EvmAddress) + copy(dAtA[i:], m.EvmAddress) + i = encodeVarintAddressmap(dAtA, i, uint64(len(m.EvmAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.CosmosAddress) > 0 { + i -= len(m.CosmosAddress) + copy(dAtA[i:], m.CosmosAddress) + i = encodeVarintAddressmap(dAtA, i, uint64(len(m.CosmosAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAddressmap(dAtA []byte, offset int, v uint64) int { + offset -= sovAddressmap(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AddressMapping) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CosmosAddress) + if l > 0 { + n += 1 + l + sovAddressmap(uint64(l)) + } + l = len(m.EvmAddress) + if l > 0 { + n += 1 + l + sovAddressmap(uint64(l)) + } + return n +} + +func sovAddressmap(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAddressmap(x uint64) (n int) { + return sovAddressmap(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AddressMapping) 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 ErrIntOverflowAddressmap + } + 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: AddressMapping: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddressMapping: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CosmosAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAddressmap + } + 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 ErrInvalidLengthAddressmap + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAddressmap + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CosmosAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAddressmap + } + 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 ErrInvalidLengthAddressmap + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAddressmap + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EvmAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAddressmap(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAddressmap + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAddressmap(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAddressmap + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAddressmap + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAddressmap + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAddressmap + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAddressmap + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAddressmap + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAddressmap = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAddressmap = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAddressmap = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/addressmap/types/v1/genesis.pb.go b/x/addressmap/types/v1/genesis.pb.go new file mode 100644 index 00000000..2deaee9e --- /dev/null +++ b/x/addressmap/types/v1/genesis.pb.go @@ -0,0 +1,328 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: addressmap/v1/genesis.proto + +package v1 + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type GenesisState struct { + AddressMappings []*AddressMapping `protobuf:"bytes,1,rep,name=address_mappings,json=addressMappings,proto3" json:"address_mappings,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_3992e7d923039b68, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetAddressMappings() []*AddressMapping { + if m != nil { + return m.AddressMappings + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "addressmap.v1.GenesisState") +} + +func init() { proto.RegisterFile("addressmap/v1/genesis.proto", fileDescriptor_3992e7d923039b68) } + +var fileDescriptor_3992e7d923039b68 = []byte{ + // 198 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0x4c, 0x49, 0x29, + 0x4a, 0x2d, 0x2e, 0xce, 0x4d, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, + 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x45, 0x48, 0xea, 0x95, 0x19, 0x4a, 0xc9, + 0xa1, 0xaa, 0x45, 0x92, 0x04, 0x2b, 0x57, 0x8a, 0xe0, 0xe2, 0x71, 0x87, 0xe8, 0x0f, 0x2e, 0x49, + 0x2c, 0x49, 0x15, 0xf2, 0xe0, 0x12, 0x80, 0xaa, 0x89, 0xcf, 0x4d, 0x2c, 0x28, 0xc8, 0xcc, 0x4b, + 0x2f, 0x96, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xd5, 0x43, 0x31, 0x59, 0xcf, 0x11, 0xc2, + 0xf3, 0x85, 0xa8, 0x0a, 0xe2, 0x4f, 0x44, 0xe1, 0x17, 0x3b, 0xf9, 0x9f, 0x78, 0x24, 0xc7, 0x78, + 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, + 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x69, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, + 0xae, 0x7e, 0x41, 0x6a, 0x7a, 0x7a, 0x65, 0x56, 0x99, 0x7e, 0x71, 0x7e, 0x6e, 0x6e, 0x6a, 0x4e, + 0x66, 0x6a, 0x91, 0x7e, 0x99, 0xb9, 0x7e, 0x05, 0x92, 0x3b, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, + 0xf5, 0xcb, 0x0c, 0x93, 0xd8, 0xc0, 0x2e, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x98, + 0x89, 0xb6, 0xff, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AddressMappings) > 0 { + for iNdEx := len(m.AddressMappings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AddressMappings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AddressMappings) > 0 { + for _, e := range m.AddressMappings { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AddressMappings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AddressMappings = append(m.AddressMappings, &AddressMapping{}) + if err := m.AddressMappings[len(m.AddressMappings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/addressmap/types/v1/query.pb.go b/x/addressmap/types/v1/query.pb.go new file mode 100644 index 00000000..d17a083d --- /dev/null +++ b/x/addressmap/types/v1/query.pb.go @@ -0,0 +1,1445 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: addressmap/v1/query.proto + +package v1 + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryAddressMappingsRequest struct { + Pagination query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination"` +} + +func (m *QueryAddressMappingsRequest) Reset() { *m = QueryAddressMappingsRequest{} } +func (m *QueryAddressMappingsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAddressMappingsRequest) ProtoMessage() {} +func (*QueryAddressMappingsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fcb6bf708b3e1cf3, []int{0} +} +func (m *QueryAddressMappingsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAddressMappingsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAddressMappingsRequest.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 *QueryAddressMappingsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAddressMappingsRequest.Merge(m, src) +} +func (m *QueryAddressMappingsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAddressMappingsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAddressMappingsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAddressMappingsRequest proto.InternalMessageInfo + +func (m *QueryAddressMappingsRequest) GetPagination() query.PageRequest { + if m != nil { + return m.Pagination + } + return query.PageRequest{} +} + +type QueryAddressMappingsResponse struct { + AddressMappings []*AddressMapping `protobuf:"bytes,1,rep,name=address_mappings,json=addressMappings,proto3" json:"address_mappings,omitempty"` + Pagination query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination"` +} + +func (m *QueryAddressMappingsResponse) Reset() { *m = QueryAddressMappingsResponse{} } +func (m *QueryAddressMappingsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAddressMappingsResponse) ProtoMessage() {} +func (*QueryAddressMappingsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fcb6bf708b3e1cf3, []int{1} +} +func (m *QueryAddressMappingsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAddressMappingsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAddressMappingsResponse.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 *QueryAddressMappingsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAddressMappingsResponse.Merge(m, src) +} +func (m *QueryAddressMappingsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAddressMappingsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAddressMappingsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAddressMappingsResponse proto.InternalMessageInfo + +func (m *QueryAddressMappingsResponse) GetAddressMappings() []*AddressMapping { + if m != nil { + return m.AddressMappings + } + return nil +} + +func (m *QueryAddressMappingsResponse) GetPagination() query.PageResponse { + if m != nil { + return m.Pagination + } + return query.PageResponse{} +} + +type QueryAddressMappingByEVMAddressRequest struct { + EvmAddress string `protobuf:"bytes,1,opt,name=evm_address,json=evmAddress,proto3" json:"evm_address,omitempty"` +} + +func (m *QueryAddressMappingByEVMAddressRequest) Reset() { + *m = QueryAddressMappingByEVMAddressRequest{} +} +func (m *QueryAddressMappingByEVMAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAddressMappingByEVMAddressRequest) ProtoMessage() {} +func (*QueryAddressMappingByEVMAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fcb6bf708b3e1cf3, []int{2} +} +func (m *QueryAddressMappingByEVMAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAddressMappingByEVMAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAddressMappingByEVMAddressRequest.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 *QueryAddressMappingByEVMAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAddressMappingByEVMAddressRequest.Merge(m, src) +} +func (m *QueryAddressMappingByEVMAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAddressMappingByEVMAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAddressMappingByEVMAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAddressMappingByEVMAddressRequest proto.InternalMessageInfo + +func (m *QueryAddressMappingByEVMAddressRequest) GetEvmAddress() string { + if m != nil { + return m.EvmAddress + } + return "" +} + +type QueryAddressMappingByEVMAddressResponse struct { + AddressMapping *AddressMapping `protobuf:"bytes,1,opt,name=address_mapping,json=addressMapping,proto3" json:"address_mapping,omitempty"` +} + +func (m *QueryAddressMappingByEVMAddressResponse) Reset() { + *m = QueryAddressMappingByEVMAddressResponse{} +} +func (m *QueryAddressMappingByEVMAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAddressMappingByEVMAddressResponse) ProtoMessage() {} +func (*QueryAddressMappingByEVMAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fcb6bf708b3e1cf3, []int{3} +} +func (m *QueryAddressMappingByEVMAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAddressMappingByEVMAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAddressMappingByEVMAddressResponse.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 *QueryAddressMappingByEVMAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAddressMappingByEVMAddressResponse.Merge(m, src) +} +func (m *QueryAddressMappingByEVMAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAddressMappingByEVMAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAddressMappingByEVMAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAddressMappingByEVMAddressResponse proto.InternalMessageInfo + +func (m *QueryAddressMappingByEVMAddressResponse) GetAddressMapping() *AddressMapping { + if m != nil { + return m.AddressMapping + } + return nil +} + +type QueryAddressMappingByCosmosAddressRequest struct { + CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty"` +} + +func (m *QueryAddressMappingByCosmosAddressRequest) Reset() { + *m = QueryAddressMappingByCosmosAddressRequest{} +} +func (m *QueryAddressMappingByCosmosAddressRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryAddressMappingByCosmosAddressRequest) ProtoMessage() {} +func (*QueryAddressMappingByCosmosAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fcb6bf708b3e1cf3, []int{4} +} +func (m *QueryAddressMappingByCosmosAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAddressMappingByCosmosAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAddressMappingByCosmosAddressRequest.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 *QueryAddressMappingByCosmosAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAddressMappingByCosmosAddressRequest.Merge(m, src) +} +func (m *QueryAddressMappingByCosmosAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAddressMappingByCosmosAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAddressMappingByCosmosAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAddressMappingByCosmosAddressRequest proto.InternalMessageInfo + +func (m *QueryAddressMappingByCosmosAddressRequest) GetCosmosAddress() string { + if m != nil { + return m.CosmosAddress + } + return "" +} + +type QueryAddressMappingByCosmosAddressResponse struct { + AddressMapping *AddressMapping `protobuf:"bytes,1,opt,name=address_mapping,json=addressMapping,proto3" json:"address_mapping,omitempty"` +} + +func (m *QueryAddressMappingByCosmosAddressResponse) Reset() { + *m = QueryAddressMappingByCosmosAddressResponse{} +} +func (m *QueryAddressMappingByCosmosAddressResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryAddressMappingByCosmosAddressResponse) ProtoMessage() {} +func (*QueryAddressMappingByCosmosAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fcb6bf708b3e1cf3, []int{5} +} +func (m *QueryAddressMappingByCosmosAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAddressMappingByCosmosAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAddressMappingByCosmosAddressResponse.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 *QueryAddressMappingByCosmosAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAddressMappingByCosmosAddressResponse.Merge(m, src) +} +func (m *QueryAddressMappingByCosmosAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAddressMappingByCosmosAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAddressMappingByCosmosAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAddressMappingByCosmosAddressResponse proto.InternalMessageInfo + +func (m *QueryAddressMappingByCosmosAddressResponse) GetAddressMapping() *AddressMapping { + if m != nil { + return m.AddressMapping + } + return nil +} + +func init() { + proto.RegisterType((*QueryAddressMappingsRequest)(nil), "addressmap.v1.QueryAddressMappingsRequest") + proto.RegisterType((*QueryAddressMappingsResponse)(nil), "addressmap.v1.QueryAddressMappingsResponse") + proto.RegisterType((*QueryAddressMappingByEVMAddressRequest)(nil), "addressmap.v1.QueryAddressMappingByEVMAddressRequest") + proto.RegisterType((*QueryAddressMappingByEVMAddressResponse)(nil), "addressmap.v1.QueryAddressMappingByEVMAddressResponse") + proto.RegisterType((*QueryAddressMappingByCosmosAddressRequest)(nil), "addressmap.v1.QueryAddressMappingByCosmosAddressRequest") + proto.RegisterType((*QueryAddressMappingByCosmosAddressResponse)(nil), "addressmap.v1.QueryAddressMappingByCosmosAddressResponse") +} + +func init() { proto.RegisterFile("addressmap/v1/query.proto", fileDescriptor_fcb6bf708b3e1cf3) } + +var fileDescriptor_fcb6bf708b3e1cf3 = []byte{ + // 545 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xce, 0xd4, 0x2a, 0xf8, 0x86, 0xb6, 0x32, 0xf4, 0x50, 0x63, 0xdd, 0x94, 0x05, 0xfb, 0x91, + 0xc2, 0x0e, 0x1b, 0xa9, 0x1f, 0x88, 0x87, 0x26, 0x28, 0x16, 0x0c, 0xea, 0x1e, 0x3c, 0x78, 0x29, + 0x93, 0x74, 0x18, 0x57, 0xbb, 0x3b, 0x93, 0xcc, 0x66, 0x31, 0x94, 0x5e, 0xfc, 0x05, 0x82, 0xff, + 0xc0, 0x3f, 0xe1, 0x5f, 0xe8, 0xb1, 0x20, 0x82, 0x27, 0x91, 0xa4, 0x37, 0xff, 0x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8f, 0xf1, 0x19, 0x02, 0xbb, 0xf8, 0xf6, 0xf1, + 0xbd, 0x32, 0x1a, 0xf3, 0x96, 0xb0, 0x76, 0xff, 0x3f, 0x3a, 0x8d, 0xc1, 0x3d, 0x6d, 0xb0, 0x8d, + 0x77, 0xcb, 0x1b, 0x34, 0xef, 0xe5, 0x51, 0x76, 0xef, 0x8f, 0x5b, 0xcf, 0x4e, 0xc6, 0x16, 0x3a, + 0x1d, 0x5b, 0xe8, 0xc7, 0xd8, 0x42, 0x1f, 0x26, 0x56, 0xe5, 0x74, 0x62, 0x55, 0xbe, 0x4d, 0xac, + 0xca, 0xab, 0x1d, 0xee, 0x47, 0xaf, 0x87, 0x5d, 0xa7, 0x27, 0x02, 0x22, 0x19, 0xe7, 0xa3, 0x37, + 0x71, 0x6a, 0x5c, 0x7c, 0x97, 0xbc, 0x4b, 0xcf, 0x8c, 0x46, 0x92, 0xa9, 0xe9, 0x1b, 0x7c, 0x45, + 0x3f, 0xba, 0xb7, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x03, 0xde, 0x09, 0x20, 0x06, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + QueryAddressMappings(ctx context.Context, in *QueryAddressMappingsRequest, opts ...grpc.CallOption) (*QueryAddressMappingsResponse, error) + QueryAddressMappingByEVMAddress(ctx context.Context, in *QueryAddressMappingByEVMAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByEVMAddressResponse, error) + QueryAddressMappingByCosmosAddress(ctx context.Context, in *QueryAddressMappingByCosmosAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByCosmosAddressResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) QueryAddressMappings(ctx context.Context, in *QueryAddressMappingsRequest, opts ...grpc.CallOption) (*QueryAddressMappingsResponse, error) { + out := new(QueryAddressMappingsResponse) + err := c.cc.Invoke(ctx, "/addressmap.v1.Query/QueryAddressMappings", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryAddressMappingByEVMAddress(ctx context.Context, in *QueryAddressMappingByEVMAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByEVMAddressResponse, error) { + out := new(QueryAddressMappingByEVMAddressResponse) + err := c.cc.Invoke(ctx, "/addressmap.v1.Query/QueryAddressMappingByEVMAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryAddressMappingByCosmosAddress(ctx context.Context, in *QueryAddressMappingByCosmosAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByCosmosAddressResponse, error) { + out := new(QueryAddressMappingByCosmosAddressResponse) + err := c.cc.Invoke(ctx, "/addressmap.v1.Query/QueryAddressMappingByCosmosAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + QueryAddressMappings(context.Context, *QueryAddressMappingsRequest) (*QueryAddressMappingsResponse, error) + QueryAddressMappingByEVMAddress(context.Context, *QueryAddressMappingByEVMAddressRequest) (*QueryAddressMappingByEVMAddressResponse, error) + QueryAddressMappingByCosmosAddress(context.Context, *QueryAddressMappingByCosmosAddressRequest) (*QueryAddressMappingByCosmosAddressResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) QueryAddressMappings(ctx context.Context, req *QueryAddressMappingsRequest) (*QueryAddressMappingsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAddressMappings not implemented") +} +func (*UnimplementedQueryServer) QueryAddressMappingByEVMAddress(ctx context.Context, req *QueryAddressMappingByEVMAddressRequest) (*QueryAddressMappingByEVMAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAddressMappingByEVMAddress not implemented") +} +func (*UnimplementedQueryServer) QueryAddressMappingByCosmosAddress(ctx context.Context, req *QueryAddressMappingByCosmosAddressRequest) (*QueryAddressMappingByCosmosAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAddressMappingByCosmosAddress not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_QueryAddressMappings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAddressMappingsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryAddressMappings(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/addressmap.v1.Query/QueryAddressMappings", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryAddressMappings(ctx, req.(*QueryAddressMappingsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryAddressMappingByEVMAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAddressMappingByEVMAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryAddressMappingByEVMAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/addressmap.v1.Query/QueryAddressMappingByEVMAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryAddressMappingByEVMAddress(ctx, req.(*QueryAddressMappingByEVMAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryAddressMappingByCosmosAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAddressMappingByCosmosAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryAddressMappingByCosmosAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/addressmap.v1.Query/QueryAddressMappingByCosmosAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryAddressMappingByCosmosAddress(ctx, req.(*QueryAddressMappingByCosmosAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "addressmap.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "QueryAddressMappings", + Handler: _Query_QueryAddressMappings_Handler, + }, + { + MethodName: "QueryAddressMappingByEVMAddress", + Handler: _Query_QueryAddressMappingByEVMAddress_Handler, + }, + { + MethodName: "QueryAddressMappingByCosmosAddress", + Handler: _Query_QueryAddressMappingByCosmosAddress_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "addressmap/v1/query.proto", +} + +func (m *QueryAddressMappingsRequest) 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 *QueryAddressMappingsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAddressMappingsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAddressMappingsResponse) 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 *QueryAddressMappingsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAddressMappingsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.AddressMappings) > 0 { + for iNdEx := len(m.AddressMappings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AddressMappings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryAddressMappingByEVMAddressRequest) 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 *QueryAddressMappingByEVMAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAddressMappingByEVMAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EvmAddress) > 0 { + i -= len(m.EvmAddress) + copy(dAtA[i:], m.EvmAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.EvmAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAddressMappingByEVMAddressResponse) 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 *QueryAddressMappingByEVMAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAddressMappingByEVMAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AddressMapping != nil { + { + size, err := m.AddressMapping.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAddressMappingByCosmosAddressRequest) 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 *QueryAddressMappingByCosmosAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAddressMappingByCosmosAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CosmosAddress) > 0 { + i -= len(m.CosmosAddress) + copy(dAtA[i:], m.CosmosAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CosmosAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAddressMappingByCosmosAddressResponse) 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 *QueryAddressMappingByCosmosAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAddressMappingByCosmosAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AddressMapping != nil { + { + size, err := m.AddressMapping.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryAddressMappingsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAddressMappingsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AddressMappings) > 0 { + for _, e := range m.AddressMappings { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAddressMappingByEVMAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.EvmAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAddressMappingByEVMAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AddressMapping != nil { + l = m.AddressMapping.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAddressMappingByCosmosAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CosmosAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAddressMappingByCosmosAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AddressMapping != nil { + l = m.AddressMapping.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryAddressMappingsRequest) 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 ErrIntOverflowQuery + } + 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: QueryAddressMappingsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAddressMappingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAddressMappingsResponse) 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 ErrIntOverflowQuery + } + 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: QueryAddressMappingsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAddressMappingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AddressMappings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AddressMappings = append(m.AddressMappings, &AddressMapping{}) + if err := m.AddressMappings[len(m.AddressMappings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAddressMappingByEVMAddressRequest) 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 ErrIntOverflowQuery + } + 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: QueryAddressMappingByEVMAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAddressMappingByEVMAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EvmAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAddressMappingByEVMAddressResponse) 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 ErrIntOverflowQuery + } + 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: QueryAddressMappingByEVMAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAddressMappingByEVMAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AddressMapping", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AddressMapping == nil { + m.AddressMapping = &AddressMapping{} + } + if err := m.AddressMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAddressMappingByCosmosAddressRequest) 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 ErrIntOverflowQuery + } + 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: QueryAddressMappingByCosmosAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAddressMappingByCosmosAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CosmosAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CosmosAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAddressMappingByCosmosAddressResponse) 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 ErrIntOverflowQuery + } + 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: QueryAddressMappingByCosmosAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAddressMappingByCosmosAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AddressMapping", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AddressMapping == nil { + m.AddressMapping = &AddressMapping{} + } + if err := m.AddressMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/addressmap/types/v1/query.pb.gw.go b/x/addressmap/types/v1/query.pb.gw.go new file mode 100644 index 00000000..60d4ab84 --- /dev/null +++ b/x/addressmap/types/v1/query.pb.gw.go @@ -0,0 +1,373 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: addressmap/v1/query.proto + +/* +Package v1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v1 + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Query_QueryAddressMappings_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_QueryAddressMappings_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAddressMappingsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAddressMappings_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryAddressMappings(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryAddressMappings_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAddressMappingsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAddressMappings_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryAddressMappings(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryAddressMappingByEVMAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAddressMappingByEVMAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["evm_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "evm_address") + } + + protoReq.EvmAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "evm_address", err) + } + + msg, err := client.QueryAddressMappingByEVMAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryAddressMappingByEVMAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAddressMappingByEVMAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["evm_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "evm_address") + } + + protoReq.EvmAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "evm_address", err) + } + + msg, err := server.QueryAddressMappingByEVMAddress(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryAddressMappingByCosmosAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAddressMappingByCosmosAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["cosmos_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "cosmos_address") + } + + protoReq.CosmosAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "cosmos_address", err) + } + + msg, err := client.QueryAddressMappingByCosmosAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryAddressMappingByCosmosAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAddressMappingByCosmosAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["cosmos_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "cosmos_address") + } + + protoReq.CosmosAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "cosmos_address", err) + } + + msg, err := server.QueryAddressMappingByCosmosAddress(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_QueryAddressMappings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryAddressMappings_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAddressMappings_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryAddressMappingByEVMAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryAddressMappingByEVMAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAddressMappingByEVMAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryAddressMappingByCosmosAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryAddressMappingByCosmosAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAddressMappingByCosmosAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_QueryAddressMappings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryAddressMappings_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAddressMappings_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryAddressMappingByEVMAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryAddressMappingByEVMAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAddressMappingByEVMAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryAddressMappingByCosmosAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryAddressMappingByCosmosAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAddressMappingByCosmosAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_QueryAddressMappings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sommelier", "addressmap", "v1", "address_mappings"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryAddressMappingByEVMAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sommelier", "addressmap", "v1", "address_mappings", "evm", "evm_address"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryAddressMappingByCosmosAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sommelier", "addressmap", "v1", "address_mappings", "cosmos", "cosmos_address"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_QueryAddressMappings_0 = runtime.ForwardResponseMessage + + forward_Query_QueryAddressMappingByEVMAddress_0 = runtime.ForwardResponseMessage + + forward_Query_QueryAddressMappingByCosmosAddress_0 = runtime.ForwardResponseMessage +) diff --git a/x/addressmap/types/v1/tx.pb.go b/x/addressmap/types/v1/tx.pb.go new file mode 100644 index 00000000..fc912072 --- /dev/null +++ b/x/addressmap/types/v1/tx.pb.go @@ -0,0 +1,803 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: addressmap/v1/tx.proto + +package v1 + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgAddAddressMappingRequest struct { + EvmAddress string `protobuf:"bytes,1,opt,name=evm_address,json=evmAddress,proto3" json:"evm_address,omitempty"` +} + +func (m *MsgAddAddressMappingRequest) Reset() { *m = MsgAddAddressMappingRequest{} } +func (m *MsgAddAddressMappingRequest) String() string { return proto.CompactTextString(m) } +func (*MsgAddAddressMappingRequest) ProtoMessage() {} +func (*MsgAddAddressMappingRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2212ffde55545bd7, []int{0} +} +func (m *MsgAddAddressMappingRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddAddressMappingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddAddressMappingRequest.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 *MsgAddAddressMappingRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddAddressMappingRequest.Merge(m, src) +} +func (m *MsgAddAddressMappingRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgAddAddressMappingRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddAddressMappingRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddAddressMappingRequest proto.InternalMessageInfo + +func (m *MsgAddAddressMappingRequest) GetEvmAddress() string { + if m != nil { + return m.EvmAddress + } + return "" +} + +type MsgAddAddressMappingResponse struct { +} + +func (m *MsgAddAddressMappingResponse) Reset() { *m = MsgAddAddressMappingResponse{} } +func (m *MsgAddAddressMappingResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddAddressMappingResponse) ProtoMessage() {} +func (*MsgAddAddressMappingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2212ffde55545bd7, []int{1} +} +func (m *MsgAddAddressMappingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddAddressMappingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddAddressMappingResponse.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 *MsgAddAddressMappingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddAddressMappingResponse.Merge(m, src) +} +func (m *MsgAddAddressMappingResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddAddressMappingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddAddressMappingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddAddressMappingResponse proto.InternalMessageInfo + +type MsgRemoveAddressMappingRequest struct { +} + +func (m *MsgRemoveAddressMappingRequest) Reset() { *m = MsgRemoveAddressMappingRequest{} } +func (m *MsgRemoveAddressMappingRequest) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveAddressMappingRequest) ProtoMessage() {} +func (*MsgRemoveAddressMappingRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2212ffde55545bd7, []int{2} +} +func (m *MsgRemoveAddressMappingRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveAddressMappingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveAddressMappingRequest.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 *MsgRemoveAddressMappingRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveAddressMappingRequest.Merge(m, src) +} +func (m *MsgRemoveAddressMappingRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveAddressMappingRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveAddressMappingRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveAddressMappingRequest proto.InternalMessageInfo + +type MsgRemoveAddressMappingResponse struct { +} + +func (m *MsgRemoveAddressMappingResponse) Reset() { *m = MsgRemoveAddressMappingResponse{} } +func (m *MsgRemoveAddressMappingResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveAddressMappingResponse) ProtoMessage() {} +func (*MsgRemoveAddressMappingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2212ffde55545bd7, []int{3} +} +func (m *MsgRemoveAddressMappingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveAddressMappingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveAddressMappingResponse.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 *MsgRemoveAddressMappingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveAddressMappingResponse.Merge(m, src) +} +func (m *MsgRemoveAddressMappingResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveAddressMappingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveAddressMappingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveAddressMappingResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgAddAddressMappingRequest)(nil), "addressmap.v1.MsgAddAddressMappingRequest") + proto.RegisterType((*MsgAddAddressMappingResponse)(nil), "addressmap.v1.MsgAddAddressMappingResponse") + proto.RegisterType((*MsgRemoveAddressMappingRequest)(nil), "addressmap.v1.MsgRemoveAddressMappingRequest") + proto.RegisterType((*MsgRemoveAddressMappingResponse)(nil), "addressmap.v1.MsgRemoveAddressMappingResponse") +} + +func init() { proto.RegisterFile("addressmap/v1/tx.proto", fileDescriptor_2212ffde55545bd7) } + +var fileDescriptor_2212ffde55545bd7 = []byte{ + // 270 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0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0x63, 0x9c, + 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd3, 0x33, + 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, 0x52, 0xd3, 0xd3, 0x2b, 0xb3, 0xca, + 0xf4, 0x8b, 0xf3, 0x73, 0x73, 0x53, 0x73, 0x32, 0x53, 0x8b, 0xf4, 0xcb, 0xcc, 0xf5, 0x2b, 0xf4, + 0x91, 0x22, 0xbd, 0xa4, 0xb2, 0x20, 0xb5, 0x58, 0xbf, 0xcc, 0x30, 0x89, 0x0d, 0x1c, 0xf1, 0xc6, + 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x68, 0x6f, 0xd2, 0x24, 0x12, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // Adds a mapping between the cosmos address of the sender and the provided EVM address + AddAddressMapping(ctx context.Context, in *MsgAddAddressMappingRequest, opts ...grpc.CallOption) (*MsgAddAddressMappingResponse, error) + // Removes the mapping containing the cosmos address of the sender + RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddressMappingRequest, opts ...grpc.CallOption) (*MsgRemoveAddressMappingResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) AddAddressMapping(ctx context.Context, in *MsgAddAddressMappingRequest, opts ...grpc.CallOption) (*MsgAddAddressMappingResponse, error) { + out := new(MsgAddAddressMappingResponse) + err := c.cc.Invoke(ctx, "/addressmap.v1.Msg/AddAddressMapping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddressMappingRequest, opts ...grpc.CallOption) (*MsgRemoveAddressMappingResponse, error) { + out := new(MsgRemoveAddressMappingResponse) + err := c.cc.Invoke(ctx, "/addressmap.v1.Msg/RemoveAddressMapping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // Adds a mapping between the cosmos address of the sender and the provided EVM address + AddAddressMapping(context.Context, *MsgAddAddressMappingRequest) (*MsgAddAddressMappingResponse, error) + // Removes the mapping containing the cosmos address of the sender + RemoveAddressMapping(context.Context, *MsgRemoveAddressMappingRequest) (*MsgRemoveAddressMappingResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) AddAddressMapping(ctx context.Context, req *MsgAddAddressMappingRequest) (*MsgAddAddressMappingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddAddressMapping not implemented") +} +func (*UnimplementedMsgServer) RemoveAddressMapping(ctx context.Context, req *MsgRemoveAddressMappingRequest) (*MsgRemoveAddressMappingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveAddressMapping not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_AddAddressMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddAddressMappingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddAddressMapping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/addressmap.v1.Msg/AddAddressMapping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddAddressMapping(ctx, req.(*MsgAddAddressMappingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RemoveAddressMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveAddressMappingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveAddressMapping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/addressmap.v1.Msg/RemoveAddressMapping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveAddressMapping(ctx, req.(*MsgRemoveAddressMappingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "addressmap.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddAddressMapping", + Handler: _Msg_AddAddressMapping_Handler, + }, + { + MethodName: "RemoveAddressMapping", + Handler: _Msg_RemoveAddressMapping_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "addressmap/v1/tx.proto", +} + +func (m *MsgAddAddressMappingRequest) 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 *MsgAddAddressMappingRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddAddressMappingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EvmAddress) > 0 { + i -= len(m.EvmAddress) + copy(dAtA[i:], m.EvmAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.EvmAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddAddressMappingResponse) 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 *MsgAddAddressMappingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddAddressMappingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRemoveAddressMappingRequest) 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 *MsgRemoveAddressMappingRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveAddressMappingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRemoveAddressMappingResponse) 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 *MsgRemoveAddressMappingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveAddressMappingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgAddAddressMappingRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.EvmAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAddAddressMappingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRemoveAddressMappingRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRemoveAddressMappingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgAddAddressMappingRequest) 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 ErrIntOverflowTx + } + 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: MsgAddAddressMappingRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddAddressMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EvmAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAddAddressMappingResponse) 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 ErrIntOverflowTx + } + 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: MsgAddAddressMappingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddAddressMappingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveAddressMappingRequest) 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 ErrIntOverflowTx + } + 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: MsgRemoveAddressMappingRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveAddressMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveAddressMappingResponse) 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 ErrIntOverflowTx + } + 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: MsgRemoveAddressMappingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveAddressMappingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 6bc712c2c5274a567cee7e7a068ac14c530cbc05 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 13 Mar 2024 13:22:46 -0500 Subject: [PATCH 03/28] Change module name to addresses to avoid key prefix collision --- .../v1/addresses.proto} | 4 +- proto/addresses/v1/genesis.proto | 10 ++ .../{addressmap => addresses}/v1/query.proto | 12 +- proto/{addressmap => addresses}/v1/tx.proto | 4 +- proto/addressmap/v1/genesis.proto | 10 -- .../types/v1/addresses.pb.go} | 92 ++++++------- .../types/v1/genesis.pb.go | 38 +++--- .../types/v1/query.pb.go | 123 +++++++++--------- .../types/v1/query.pb.gw.go | 8 +- x/{addressmap => addresses}/types/v1/tx.pb.go | 76 +++++------ 10 files changed, 188 insertions(+), 189 deletions(-) rename proto/{addressmap/v1/addressmap.proto => addresses/v1/addresses.proto} (51%) create mode 100644 proto/addresses/v1/genesis.proto rename proto/{addressmap => addresses}/v1/query.proto (73%) rename proto/{addressmap => addresses}/v1/tx.proto (85%) delete mode 100644 proto/addressmap/v1/genesis.proto rename x/{addressmap/types/v1/addressmap.pb.go => addresses/types/v1/addresses.pb.go} (70%) rename x/{addressmap => addresses}/types/v1/genesis.pb.go (82%) rename x/{addressmap => addresses}/types/v1/query.pb.go (88%) rename x/{addressmap => addresses}/types/v1/query.pb.gw.go (97%) rename x/{addressmap => addresses}/types/v1/tx.pb.go (89%) diff --git a/proto/addressmap/v1/addressmap.proto b/proto/addresses/v1/addresses.proto similarity index 51% rename from proto/addressmap/v1/addressmap.proto rename to proto/addresses/v1/addresses.proto index 04ae6279..57cab9e8 100644 --- a/proto/addressmap/v1/addressmap.proto +++ b/proto/addresses/v1/addresses.proto @@ -1,7 +1,7 @@ syntax = "proto3"; -package addressmap.v1; +package addresses.v1; -option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; message AddressMapping { string cosmos_address = 1; diff --git a/proto/addresses/v1/genesis.proto b/proto/addresses/v1/genesis.proto new file mode 100644 index 00000000..0a4c231e --- /dev/null +++ b/proto/addresses/v1/genesis.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package addresses.v1; + +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; + +import "addresses/v1/addresses.proto"; + +message GenesisState { + repeated AddressMapping address_mappings = 1; +} diff --git a/proto/addressmap/v1/query.proto b/proto/addresses/v1/query.proto similarity index 73% rename from proto/addressmap/v1/query.proto rename to proto/addresses/v1/query.proto index 2ff997db..ceccb132 100644 --- a/proto/addressmap/v1/query.proto +++ b/proto/addresses/v1/query.proto @@ -1,26 +1,26 @@ syntax = "proto3"; -package addressmap.v1; +package addresses.v1; -import "addressmap/v1/addressmap.proto"; +import "addresses/v1/addresses.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; service Query { rpc QueryAddressMappings(QueryAddressMappingsRequest) returns (QueryAddressMappingsResponse) { - option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings"; + option (google.api.http).get = "/sommelier/addresses/v1/address_mappings"; } rpc QueryAddressMappingByEVMAddress(QueryAddressMappingByEVMAddressRequest) returns (QueryAddressMappingByEVMAddressResponse) { - option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings/evm/{evm_address}"; + option (google.api.http).get = "/sommelier/addresses/v1/address_mappings/evm/{evm_address}"; } rpc QueryAddressMappingByCosmosAddress(QueryAddressMappingByCosmosAddressRequest) returns (QueryAddressMappingByCosmosAddressResponse) { - option (google.api.http).get = "/sommelier/addressmap/v1/address_mappings/cosmos/{cosmos_address}"; + option (google.api.http).get = "/sommelier/addresses/v1/address_mappings/cosmos/{cosmos_address}"; } } diff --git a/proto/addressmap/v1/tx.proto b/proto/addresses/v1/tx.proto similarity index 85% rename from proto/addressmap/v1/tx.proto rename to proto/addresses/v1/tx.proto index 9f556579..9c89479c 100644 --- a/proto/addressmap/v1/tx.proto +++ b/proto/addresses/v1/tx.proto @@ -1,7 +1,7 @@ syntax = "proto3"; -package addressmap.v1; +package addresses.v1; -option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; service Msg { // Adds a mapping between the cosmos address of the sender and the provided EVM address diff --git a/proto/addressmap/v1/genesis.proto b/proto/addressmap/v1/genesis.proto deleted file mode 100644 index bc7113b1..00000000 --- a/proto/addressmap/v1/genesis.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; -package addressmap.v1; - -option go_package = "github.com/peggyjv/sommelier/v7/x/addressmap/types/v1"; - -import "addressmap/v1/addressmap.proto"; - -message GenesisState { - repeated AddressMapping address_mappings = 1; -} diff --git a/x/addressmap/types/v1/addressmap.pb.go b/x/addresses/types/v1/addresses.pb.go similarity index 70% rename from x/addressmap/types/v1/addressmap.pb.go rename to x/addresses/types/v1/addresses.pb.go index 740f291b..f1d625b2 100644 --- a/x/addressmap/types/v1/addressmap.pb.go +++ b/x/addresses/types/v1/addresses.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: addressmap/v1/addressmap.proto +// source: addresses/v1/addresses.proto package v1 @@ -31,7 +31,7 @@ func (m *AddressMapping) Reset() { *m = AddressMapping{} } func (m *AddressMapping) String() string { return proto.CompactTextString(m) } func (*AddressMapping) ProtoMessage() {} func (*AddressMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_8c4a56c34c721369, []int{0} + return fileDescriptor_f62edfd8f2ffb6f4, []int{0} } func (m *AddressMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -75,25 +75,25 @@ func (m *AddressMapping) GetEvmAddress() string { } func init() { - proto.RegisterType((*AddressMapping)(nil), "addressmap.v1.AddressMapping") + proto.RegisterType((*AddressMapping)(nil), "addresses.v1.AddressMapping") } -func init() { proto.RegisterFile("addressmap/v1/addressmap.proto", fileDescriptor_8c4a56c34c721369) } +func init() { proto.RegisterFile("addresses/v1/addresses.proto", fileDescriptor_f62edfd8f2ffb6f4) } -var fileDescriptor_8c4a56c34c721369 = []byte{ - // 190 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0x4c, 0x49, 0x29, - 0x4a, 0x2d, 0x2e, 0xce, 0x4d, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x47, 0xf0, 0xf4, 0x0a, 0x8a, 0xf2, - 0x4b, 0xf2, 0x85, 0x78, 0x91, 0x44, 0xca, 0x0c, 0x95, 0x22, 0xb8, 0xf8, 0x1c, 0x21, 0x02, 0xbe, - 0x89, 0x05, 0x05, 0x99, 0x79, 0xe9, 0x42, 0xaa, 0x5c, 0x7c, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, - 0xf1, 0x50, 0x95, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0xbc, 0x10, 0x51, 0xa8, 0x6a, 0x21, - 0x79, 0x2e, 0xee, 0xd4, 0xb2, 0x5c, 0xb8, 0x1a, 0x26, 0xb0, 0x1a, 0xae, 0xd4, 0xb2, 0x5c, 0xa8, - 0x02, 0x27, 0xff, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, - 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4d, 0xcf, - 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x2f, 0x48, 0x4d, 0x4f, 0xaf, 0xcc, 0x2a, - 0xd3, 0x2f, 0xce, 0xcf, 0xcd, 0x4d, 0xcd, 0xc9, 0x4c, 0x2d, 0xd2, 0x2f, 0x33, 0xd7, 0xaf, 0x40, - 0x72, 0xb6, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0xb1, 0x7e, 0x99, 0x61, 0x12, 0x1b, 0xd8, 0x03, 0xc6, - 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x2f, 0x02, 0x17, 0xe2, 0x00, 0x00, 0x00, +var fileDescriptor_f62edfd8f2ffb6f4 = []byte{ + // 186 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0x4c, 0x49, 0x29, + 0x4a, 0x2d, 0x2e, 0x4e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x87, 0x73, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, + 0xf2, 0x85, 0x78, 0x10, 0x02, 0x65, 0x86, 0x4a, 0x11, 0x5c, 0x7c, 0x8e, 0x10, 0xbe, 0x6f, 0x62, + 0x41, 0x41, 0x66, 0x5e, 0xba, 0x90, 0x2a, 0x17, 0x5f, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x3c, + 0x54, 0xa1, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x2f, 0x44, 0x14, 0xaa, 0x5a, 0x48, 0x9e, + 0x8b, 0x3b, 0xb5, 0x2c, 0x17, 0xae, 0x86, 0x09, 0xac, 0x86, 0x2b, 0xb5, 0x2c, 0x17, 0xaa, 0xc0, + 0xc9, 0xef, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, + 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd2, 0x33, 0x4b, + 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, 0x52, 0xd3, 0xd3, 0x2b, 0xb3, 0xca, 0xf4, + 0x8b, 0xf3, 0x73, 0x73, 0x53, 0x73, 0x32, 0x53, 0x8b, 0xf4, 0xcb, 0xcc, 0xf5, 0x2b, 0x10, 0x8e, + 0xd6, 0x2f, 0xa9, 0x2c, 0x00, 0xfb, 0x23, 0x89, 0x0d, 0xec, 0x7c, 0x63, 0x40, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x69, 0x6f, 0x22, 0xea, 0xde, 0x00, 0x00, 0x00, } func (m *AddressMapping) Marshal() (dAtA []byte, err error) { @@ -119,22 +119,22 @@ func (m *AddressMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EvmAddress) > 0 { i -= len(m.EvmAddress) copy(dAtA[i:], m.EvmAddress) - i = encodeVarintAddressmap(dAtA, i, uint64(len(m.EvmAddress))) + i = encodeVarintAddresses(dAtA, i, uint64(len(m.EvmAddress))) i-- dAtA[i] = 0x12 } if len(m.CosmosAddress) > 0 { i -= len(m.CosmosAddress) copy(dAtA[i:], m.CosmosAddress) - i = encodeVarintAddressmap(dAtA, i, uint64(len(m.CosmosAddress))) + i = encodeVarintAddresses(dAtA, i, uint64(len(m.CosmosAddress))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintAddressmap(dAtA []byte, offset int, v uint64) int { - offset -= sovAddressmap(v) +func encodeVarintAddresses(dAtA []byte, offset int, v uint64) int { + offset -= sovAddresses(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -152,20 +152,20 @@ func (m *AddressMapping) Size() (n int) { _ = l l = len(m.CosmosAddress) if l > 0 { - n += 1 + l + sovAddressmap(uint64(l)) + n += 1 + l + sovAddresses(uint64(l)) } l = len(m.EvmAddress) if l > 0 { - n += 1 + l + sovAddressmap(uint64(l)) + n += 1 + l + sovAddresses(uint64(l)) } return n } -func sovAddressmap(x uint64) (n int) { +func sovAddresses(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozAddressmap(x uint64) (n int) { - return sovAddressmap(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozAddresses(x uint64) (n int) { + return sovAddresses(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *AddressMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -175,7 +175,7 @@ func (m *AddressMapping) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAddressmap + return ErrIntOverflowAddresses } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -203,7 +203,7 @@ func (m *AddressMapping) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAddressmap + return ErrIntOverflowAddresses } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -217,11 +217,11 @@ func (m *AddressMapping) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAddressmap + return ErrInvalidLengthAddresses } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAddressmap + return ErrInvalidLengthAddresses } if postIndex > l { return io.ErrUnexpectedEOF @@ -235,7 +235,7 @@ func (m *AddressMapping) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAddressmap + return ErrIntOverflowAddresses } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -249,11 +249,11 @@ func (m *AddressMapping) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAddressmap + return ErrInvalidLengthAddresses } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAddressmap + return ErrInvalidLengthAddresses } if postIndex > l { return io.ErrUnexpectedEOF @@ -262,12 +262,12 @@ func (m *AddressMapping) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipAddressmap(dAtA[iNdEx:]) + skippy, err := skipAddresses(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAddressmap + return ErrInvalidLengthAddresses } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -281,7 +281,7 @@ func (m *AddressMapping) Unmarshal(dAtA []byte) error { } return nil } -func skipAddressmap(dAtA []byte) (n int, err error) { +func skipAddresses(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -289,7 +289,7 @@ func skipAddressmap(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAddressmap + return 0, ErrIntOverflowAddresses } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -306,7 +306,7 @@ func skipAddressmap(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAddressmap + return 0, ErrIntOverflowAddresses } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -322,7 +322,7 @@ func skipAddressmap(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAddressmap + return 0, ErrIntOverflowAddresses } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -335,14 +335,14 @@ func skipAddressmap(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthAddressmap + return 0, ErrInvalidLengthAddresses } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAddressmap + return 0, ErrUnexpectedEndOfGroupAddresses } depth-- case 5: @@ -351,7 +351,7 @@ func skipAddressmap(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthAddressmap + return 0, ErrInvalidLengthAddresses } if depth == 0 { return iNdEx, nil @@ -361,7 +361,7 @@ func skipAddressmap(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthAddressmap = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAddressmap = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAddressmap = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthAddresses = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAddresses = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAddresses = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/addressmap/types/v1/genesis.pb.go b/x/addresses/types/v1/genesis.pb.go similarity index 82% rename from x/addressmap/types/v1/genesis.pb.go rename to x/addresses/types/v1/genesis.pb.go index 2deaee9e..9d3c867d 100644 --- a/x/addressmap/types/v1/genesis.pb.go +++ b/x/addresses/types/v1/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: addressmap/v1/genesis.proto +// source: addresses/v1/genesis.proto package v1 @@ -30,7 +30,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_3992e7d923039b68, []int{0} + return fileDescriptor_b55f1bec9bbe9669, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -67,26 +67,26 @@ func (m *GenesisState) GetAddressMappings() []*AddressMapping { } func init() { - proto.RegisterType((*GenesisState)(nil), "addressmap.v1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "addresses.v1.GenesisState") } -func init() { proto.RegisterFile("addressmap/v1/genesis.proto", fileDescriptor_3992e7d923039b68) } +func init() { proto.RegisterFile("addresses/v1/genesis.proto", fileDescriptor_b55f1bec9bbe9669) } -var fileDescriptor_3992e7d923039b68 = []byte{ - // 198 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0x4c, 0x49, 0x29, - 0x4a, 0x2d, 0x2e, 0xce, 0x4d, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, - 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x45, 0x48, 0xea, 0x95, 0x19, 0x4a, 0xc9, - 0xa1, 0xaa, 0x45, 0x92, 0x04, 0x2b, 0x57, 0x8a, 0xe0, 0xe2, 0x71, 0x87, 0xe8, 0x0f, 0x2e, 0x49, - 0x2c, 0x49, 0x15, 0xf2, 0xe0, 0x12, 0x80, 0xaa, 0x89, 0xcf, 0x4d, 0x2c, 0x28, 0xc8, 0xcc, 0x4b, - 0x2f, 0x96, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xd5, 0x43, 0x31, 0x59, 0xcf, 0x11, 0xc2, - 0xf3, 0x85, 0xa8, 0x0a, 0xe2, 0x4f, 0x44, 0xe1, 0x17, 0x3b, 0xf9, 0x9f, 0x78, 0x24, 0xc7, 0x78, - 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, - 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x69, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, - 0xae, 0x7e, 0x41, 0x6a, 0x7a, 0x7a, 0x65, 0x56, 0x99, 0x7e, 0x71, 0x7e, 0x6e, 0x6e, 0x6a, 0x4e, - 0x66, 0x6a, 0x91, 0x7e, 0x99, 0xb9, 0x7e, 0x05, 0x92, 0x3b, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, - 0xf5, 0xcb, 0x0c, 0x93, 0xd8, 0xc0, 0x2e, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x98, - 0x89, 0xb6, 0xff, 0x00, 0x00, 0x00, +var fileDescriptor_b55f1bec9bbe9669 = []byte{ + // 194 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x4c, 0x49, 0x29, + 0x4a, 0x2d, 0x2e, 0x4e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, + 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x81, 0xcb, 0xe9, 0x95, 0x19, 0x4a, 0xc9, 0xa0, + 0xa8, 0x44, 0x48, 0x81, 0xd5, 0x2a, 0x85, 0x73, 0xf1, 0xb8, 0x43, 0x34, 0x07, 0x97, 0x24, 0x96, + 0xa4, 0x0a, 0xb9, 0x73, 0x09, 0x40, 0x95, 0xc4, 0xe7, 0x26, 0x16, 0x14, 0x64, 0xe6, 0xa5, 0x17, + 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xc9, 0xe8, 0x21, 0x1b, 0xab, 0xe7, 0x08, 0xe1, 0xf8, + 0x42, 0x14, 0x05, 0xf1, 0x27, 0xa2, 0xf0, 0x8b, 0x9d, 0xfc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, + 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, + 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x24, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, + 0xbf, 0x20, 0x35, 0x3d, 0xbd, 0x32, 0xab, 0x4c, 0xbf, 0x38, 0x3f, 0x37, 0x37, 0x35, 0x27, 0x33, + 0xb5, 0x48, 0xbf, 0xcc, 0x5c, 0xbf, 0x02, 0xe1, 0x4a, 0xfd, 0x92, 0xca, 0x02, 0xb0, 0xc3, 0x93, + 0xd8, 0xc0, 0xee, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xe1, 0x57, 0x03, 0xf9, 0x00, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/addressmap/types/v1/query.pb.go b/x/addresses/types/v1/query.pb.go similarity index 88% rename from x/addressmap/types/v1/query.pb.go rename to x/addresses/types/v1/query.pb.go index d17a083d..e744f2e6 100644 --- a/x/addressmap/types/v1/query.pb.go +++ b/x/addresses/types/v1/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: addressmap/v1/query.proto +// source: addresses/v1/query.proto package v1 @@ -38,7 +38,7 @@ func (m *QueryAddressMappingsRequest) Reset() { *m = QueryAddressMapping func (m *QueryAddressMappingsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingsRequest) ProtoMessage() {} func (*QueryAddressMappingsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_fcb6bf708b3e1cf3, []int{0} + return fileDescriptor_ebe10bad8a6f145d, []int{0} } func (m *QueryAddressMappingsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -83,7 +83,7 @@ func (m *QueryAddressMappingsResponse) Reset() { *m = QueryAddressMappin func (m *QueryAddressMappingsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingsResponse) ProtoMessage() {} func (*QueryAddressMappingsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fcb6bf708b3e1cf3, []int{1} + return fileDescriptor_ebe10bad8a6f145d, []int{1} } func (m *QueryAddressMappingsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -136,7 +136,7 @@ func (m *QueryAddressMappingByEVMAddressRequest) Reset() { func (m *QueryAddressMappingByEVMAddressRequest) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingByEVMAddressRequest) ProtoMessage() {} func (*QueryAddressMappingByEVMAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_fcb6bf708b3e1cf3, []int{2} + return fileDescriptor_ebe10bad8a6f145d, []int{2} } func (m *QueryAddressMappingByEVMAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -182,7 +182,7 @@ func (m *QueryAddressMappingByEVMAddressResponse) Reset() { func (m *QueryAddressMappingByEVMAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingByEVMAddressResponse) ProtoMessage() {} func (*QueryAddressMappingByEVMAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fcb6bf708b3e1cf3, []int{3} + return fileDescriptor_ebe10bad8a6f145d, []int{3} } func (m *QueryAddressMappingByEVMAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -230,7 +230,7 @@ func (m *QueryAddressMappingByCosmosAddressRequest) String() string { } func (*QueryAddressMappingByCosmosAddressRequest) ProtoMessage() {} func (*QueryAddressMappingByCosmosAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_fcb6bf708b3e1cf3, []int{4} + return fileDescriptor_ebe10bad8a6f145d, []int{4} } func (m *QueryAddressMappingByCosmosAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -278,7 +278,7 @@ func (m *QueryAddressMappingByCosmosAddressResponse) String() string { } func (*QueryAddressMappingByCosmosAddressResponse) ProtoMessage() {} func (*QueryAddressMappingByCosmosAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_fcb6bf708b3e1cf3, []int{5} + return fileDescriptor_ebe10bad8a6f145d, []int{5} } func (m *QueryAddressMappingByCosmosAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -315,53 +315,52 @@ func (m *QueryAddressMappingByCosmosAddressResponse) GetAddressMapping() *Addres } func init() { - proto.RegisterType((*QueryAddressMappingsRequest)(nil), "addressmap.v1.QueryAddressMappingsRequest") - proto.RegisterType((*QueryAddressMappingsResponse)(nil), "addressmap.v1.QueryAddressMappingsResponse") - proto.RegisterType((*QueryAddressMappingByEVMAddressRequest)(nil), "addressmap.v1.QueryAddressMappingByEVMAddressRequest") - proto.RegisterType((*QueryAddressMappingByEVMAddressResponse)(nil), "addressmap.v1.QueryAddressMappingByEVMAddressResponse") - proto.RegisterType((*QueryAddressMappingByCosmosAddressRequest)(nil), "addressmap.v1.QueryAddressMappingByCosmosAddressRequest") - proto.RegisterType((*QueryAddressMappingByCosmosAddressResponse)(nil), "addressmap.v1.QueryAddressMappingByCosmosAddressResponse") -} - -func init() { proto.RegisterFile("addressmap/v1/query.proto", fileDescriptor_fcb6bf708b3e1cf3) } - -var fileDescriptor_fcb6bf708b3e1cf3 = []byte{ - // 545 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x6b, 0x13, 0x41, - 0x18, 0xce, 0xd4, 0x2a, 0xf8, 0x86, 0xb6, 0x32, 0xf4, 0x50, 0x63, 0xdd, 0x94, 0x05, 0xfb, 0x91, - 0xc2, 0x0e, 0x1b, 0xa9, 0x1f, 0x88, 0x87, 0x26, 0x28, 0x16, 0x0c, 0xea, 0x1e, 0x3c, 0x78, 0x29, - 0x93, 0x74, 0x18, 0x57, 0xbb, 0x3b, 0x93, 0xcc, 0x66, 0x31, 0x94, 0x5e, 0xfc, 0x05, 0x82, 0xff, - 0xc0, 0x3f, 0xe1, 0x5f, 0xe8, 0xb1, 0x20, 0x82, 0x27, 0x91, 0xa4, 0x37, 0xff, 0x84, 0x64, 0x76, - 0xb4, 0xbb, 0x61, 0x71, 0x57, 0xe9, 0x6d, 0x99, 0xf7, 0x79, 0x9f, 0xf7, 0x79, 0x9e, 0x79, 0x77, - 0xe0, 0x3a, 0x3d, 0x38, 0x18, 0x30, 0xa5, 0x02, 0x2a, 0x49, 0xec, 0x92, 0xfe, 0x90, 0x0d, 0x46, - 0x8e, 0x1c, 0x88, 0x48, 0xe0, 0x85, 0xf3, 0x92, 0x13, 0xbb, 0x35, 0x2b, 0x8b, 0x4c, 0x15, 0x35, - 0xbc, 0xb6, 0xcc, 0x05, 0x17, 0xfa, 0x93, 0x4c, 0xbf, 0xcc, 0xe9, 0x2a, 0x17, 0x82, 0x1f, 0x32, - 0x42, 0xa5, 0x4f, 0x68, 0x18, 0x8a, 0x88, 0x46, 0xbe, 0x08, 0x95, 0xa9, 0x36, 0x7a, 0x42, 0x05, - 0x42, 0x91, 0x2e, 0x55, 0x2c, 0x99, 0x4d, 0x62, 0xb7, 0xcb, 0x22, 0xea, 0x12, 0x49, 0xb9, 0x1f, - 0x6a, 0x70, 0x82, 0xb5, 0xdf, 0xc2, 0x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0x00, + proto.RegisterType((*QueryAddressMappingsRequest)(nil), "addresses.v1.QueryAddressMappingsRequest") + proto.RegisterType((*QueryAddressMappingsResponse)(nil), "addresses.v1.QueryAddressMappingsResponse") + proto.RegisterType((*QueryAddressMappingByEVMAddressRequest)(nil), "addresses.v1.QueryAddressMappingByEVMAddressRequest") + proto.RegisterType((*QueryAddressMappingByEVMAddressResponse)(nil), "addresses.v1.QueryAddressMappingByEVMAddressResponse") + proto.RegisterType((*QueryAddressMappingByCosmosAddressRequest)(nil), "addresses.v1.QueryAddressMappingByCosmosAddressRequest") + proto.RegisterType((*QueryAddressMappingByCosmosAddressResponse)(nil), "addresses.v1.QueryAddressMappingByCosmosAddressResponse") +} + +func init() { proto.RegisterFile("addresses/v1/query.proto", fileDescriptor_ebe10bad8a6f145d) } + +var fileDescriptor_ebe10bad8a6f145d = []byte{ + // 538 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6e, 0xd3, 0x30, + 0x18, 0xaf, 0xc7, 0x40, 0xe2, 0x2b, 0x6c, 0xc8, 0xda, 0xa1, 0x2a, 0x55, 0x3a, 0x45, 0x62, 0xeb, + 0x7a, 0x88, 0x69, 0x19, 0x1a, 0x42, 0x1c, 0x20, 0x68, 0x02, 0x24, 0x8a, 0x20, 0x07, 0x0e, 0x5c, + 0x26, 0xb7, 0xb3, 0x4c, 0x60, 0x89, 0xbd, 0x3a, 0x8d, 0xa8, 0xa6, 0x5d, 0x78, 0x02, 0x24, 0x1e, + 0x80, 0xb7, 0xe0, 0x19, 0x76, 0x9c, 0xe0, 0xc2, 0x09, 0x41, 0xcb, 0x83, 0xa0, 0x3a, 0xde, 0x96, + 0x54, 0xd1, 0x92, 0x49, 0xbb, 0x45, 0xf1, 0xef, 0xfb, 0xfd, 0xf3, 0x97, 0x40, 0x8d, 0xee, 0xee, + 0x0e, 0x99, 0x52, 0x4c, 0x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47, + 0x1e, 0x64, 0xb7, 0xfd, 0xd0, 0x7d, 0x75, 0x34, 0xb1, 0xd0, 0xf1, 0xc4, 0x42, 0x7f, 0x26, 0x16, + 0xfa, 0x32, 0xb5, 0x2a, 0xc7, 0x53, 0xab, 0xf2, 0x6b, 0x6a, 0x55, 0xde, 0x6d, 0x72, 0x3f, 0x7a, + 0x3f, 0xea, 0x3b, 0x03, 0x11, 0x10, 0xc9, 0x38, 0x1f, 0x7f, 0x88, 0x53, 0x6a, 0xf1, 0x16, 0xf9, + 0x94, 0x92, 0x8c, 0xc6, 0x52, 0x0b, 0xf7, 0xaf, 0xe9, 0xff, 0xec, 0xbd, 0xff, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x03, 0x21, 0xa1, 0x43, 0x0f, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -391,7 +390,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) QueryAddressMappings(ctx context.Context, in *QueryAddressMappingsRequest, opts ...grpc.CallOption) (*QueryAddressMappingsResponse, error) { out := new(QueryAddressMappingsResponse) - err := c.cc.Invoke(ctx, "/addressmap.v1.Query/QueryAddressMappings", in, out, opts...) + err := c.cc.Invoke(ctx, "/addresses.v1.Query/QueryAddressMappings", in, out, opts...) if err != nil { return nil, err } @@ -400,7 +399,7 @@ func (c *queryClient) QueryAddressMappings(ctx context.Context, in *QueryAddress func (c *queryClient) QueryAddressMappingByEVMAddress(ctx context.Context, in *QueryAddressMappingByEVMAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByEVMAddressResponse, error) { out := new(QueryAddressMappingByEVMAddressResponse) - err := c.cc.Invoke(ctx, "/addressmap.v1.Query/QueryAddressMappingByEVMAddress", in, out, opts...) + err := c.cc.Invoke(ctx, "/addresses.v1.Query/QueryAddressMappingByEVMAddress", in, out, opts...) if err != nil { return nil, err } @@ -409,7 +408,7 @@ func (c *queryClient) QueryAddressMappingByEVMAddress(ctx context.Context, in *Q func (c *queryClient) QueryAddressMappingByCosmosAddress(ctx context.Context, in *QueryAddressMappingByCosmosAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByCosmosAddressResponse, error) { out := new(QueryAddressMappingByCosmosAddressResponse) - err := c.cc.Invoke(ctx, "/addressmap.v1.Query/QueryAddressMappingByCosmosAddress", in, out, opts...) + err := c.cc.Invoke(ctx, "/addresses.v1.Query/QueryAddressMappingByCosmosAddress", in, out, opts...) if err != nil { return nil, err } @@ -451,7 +450,7 @@ func _Query_QueryAddressMappings_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/addressmap.v1.Query/QueryAddressMappings", + FullMethod: "/addresses.v1.Query/QueryAddressMappings", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueryAddressMappings(ctx, req.(*QueryAddressMappingsRequest)) @@ -469,7 +468,7 @@ func _Query_QueryAddressMappingByEVMAddress_Handler(srv interface{}, ctx context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/addressmap.v1.Query/QueryAddressMappingByEVMAddress", + FullMethod: "/addresses.v1.Query/QueryAddressMappingByEVMAddress", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueryAddressMappingByEVMAddress(ctx, req.(*QueryAddressMappingByEVMAddressRequest)) @@ -487,7 +486,7 @@ func _Query_QueryAddressMappingByCosmosAddress_Handler(srv interface{}, ctx cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/addressmap.v1.Query/QueryAddressMappingByCosmosAddress", + FullMethod: "/addresses.v1.Query/QueryAddressMappingByCosmosAddress", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueryAddressMappingByCosmosAddress(ctx, req.(*QueryAddressMappingByCosmosAddressRequest)) @@ -496,7 +495,7 @@ func _Query_QueryAddressMappingByCosmosAddress_Handler(srv interface{}, ctx cont } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "addressmap.v1.Query", + ServiceName: "addresses.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -513,7 +512,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "addressmap/v1/query.proto", + Metadata: "addresses/v1/query.proto", } func (m *QueryAddressMappingsRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/addressmap/types/v1/query.pb.gw.go b/x/addresses/types/v1/query.pb.gw.go similarity index 97% rename from x/addressmap/types/v1/query.pb.gw.go rename to x/addresses/types/v1/query.pb.gw.go index 60d4ab84..d7fbefd9 100644 --- a/x/addressmap/types/v1/query.pb.gw.go +++ b/x/addresses/types/v1/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: addressmap/v1/query.proto +// source: addresses/v1/query.proto /* Package v1 is a reverse proxy. @@ -357,11 +357,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_QueryAddressMappings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sommelier", "addressmap", "v1", "address_mappings"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAddressMappings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sommelier", "addresses", "v1", "address_mappings"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAddressMappingByEVMAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sommelier", "addressmap", "v1", "address_mappings", "evm", "evm_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAddressMappingByEVMAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sommelier", "addresses", "v1", "address_mappings", "evm", "evm_address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAddressMappingByCosmosAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sommelier", "addressmap", "v1", "address_mappings", "cosmos", "cosmos_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAddressMappingByCosmosAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sommelier", "addresses", "v1", "address_mappings", "cosmos", "cosmos_address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/addressmap/types/v1/tx.pb.go b/x/addresses/types/v1/tx.pb.go similarity index 89% rename from x/addressmap/types/v1/tx.pb.go rename to x/addresses/types/v1/tx.pb.go index fc912072..723d876a 100644 --- a/x/addressmap/types/v1/tx.pb.go +++ b/x/addresses/types/v1/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: addressmap/v1/tx.proto +// source: addresses/v1/tx.proto package v1 @@ -35,7 +35,7 @@ func (m *MsgAddAddressMappingRequest) Reset() { *m = MsgAddAddressMappin func (m *MsgAddAddressMappingRequest) String() string { return proto.CompactTextString(m) } func (*MsgAddAddressMappingRequest) ProtoMessage() {} func (*MsgAddAddressMappingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2212ffde55545bd7, []int{0} + return fileDescriptor_dbc33d4b2b06ba95, []int{0} } func (m *MsgAddAddressMappingRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,7 +78,7 @@ func (m *MsgAddAddressMappingResponse) Reset() { *m = MsgAddAddressMappi func (m *MsgAddAddressMappingResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddAddressMappingResponse) ProtoMessage() {} func (*MsgAddAddressMappingResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2212ffde55545bd7, []int{1} + return fileDescriptor_dbc33d4b2b06ba95, []int{1} } func (m *MsgAddAddressMappingResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -114,7 +114,7 @@ func (m *MsgRemoveAddressMappingRequest) Reset() { *m = MsgRemoveAddress func (m *MsgRemoveAddressMappingRequest) String() string { return proto.CompactTextString(m) } func (*MsgRemoveAddressMappingRequest) ProtoMessage() {} func (*MsgRemoveAddressMappingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2212ffde55545bd7, []int{2} + return fileDescriptor_dbc33d4b2b06ba95, []int{2} } func (m *MsgRemoveAddressMappingRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -150,7 +150,7 @@ func (m *MsgRemoveAddressMappingResponse) Reset() { *m = MsgRemoveAddres func (m *MsgRemoveAddressMappingResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveAddressMappingResponse) ProtoMessage() {} func (*MsgRemoveAddressMappingResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2212ffde55545bd7, []int{3} + return fileDescriptor_dbc33d4b2b06ba95, []int{3} } func (m *MsgRemoveAddressMappingResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -180,33 +180,33 @@ func (m *MsgRemoveAddressMappingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveAddressMappingResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgAddAddressMappingRequest)(nil), "addressmap.v1.MsgAddAddressMappingRequest") - proto.RegisterType((*MsgAddAddressMappingResponse)(nil), "addressmap.v1.MsgAddAddressMappingResponse") - proto.RegisterType((*MsgRemoveAddressMappingRequest)(nil), "addressmap.v1.MsgRemoveAddressMappingRequest") - proto.RegisterType((*MsgRemoveAddressMappingResponse)(nil), "addressmap.v1.MsgRemoveAddressMappingResponse") -} - -func init() { proto.RegisterFile("addressmap/v1/tx.proto", fileDescriptor_2212ffde55545bd7) } - -var fileDescriptor_2212ffde55545bd7 = []byte{ - // 270 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0x4c, 0x49, 0x29, - 0x4a, 0x2d, 0x2e, 0xce, 0x4d, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0xe2, 0x45, 0x88, 0xeb, 0x95, 0x19, 0x2a, 0xd9, 0x71, 0x49, 0xfb, 0x16, 0xa7, - 0x3b, 0xa6, 0xa4, 0x38, 0x42, 0x84, 0x7d, 0x13, 0x0b, 0x0a, 0x32, 0xf3, 0xd2, 0x83, 0x52, 0x0b, - 0x4b, 0x53, 0x8b, 0x4b, 0x84, 0xe4, 0xb9, 0xb8, 0x53, 0xcb, 0x72, 0xe3, 0xa1, 0x7a, 0x24, 0x18, - 0x15, 0x18, 0x35, 0x38, 0x83, 0xb8, 0x52, 0xcb, 0x72, 0xa1, 0xca, 0x95, 0xe4, 0xb8, 0x64, 0xb0, - 0xeb, 0x2f, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0x52, 0xe0, 0x92, 0xf3, 0x2d, 0x4e, 0x0f, 0x4a, - 0xcd, 0xcd, 0x2f, 0x4b, 0xc5, 0x6a, 0x85, 0x92, 0x22, 0x97, 0x3c, 0x4e, 0x15, 0x10, 0x43, 0x8c, - 0x5e, 0x31, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0xe5, 0x70, 0x09, 0x62, 0xd8, 0x24, 0xa4, 0xa5, - 0x87, 0xe2, 0x23, 0x3d, 0x3c, 0xde, 0x91, 0xd2, 0x26, 0x4a, 0x2d, 0xc4, 0x56, 0xa1, 0x52, 0x2e, - 0x11, 0x6c, 0xae, 0x12, 0xd2, 0xc5, 0x34, 0x04, 0x8f, 0xff, 0xa4, 0xf4, 0x88, 0x55, 0x0e, 0xb1, - 0xd6, 0xc9, 0xff, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, - 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd3, 0x33, - 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, 0x52, 0xd3, 0xd3, 0x2b, 0xb3, 0xca, - 0xf4, 0x8b, 0xf3, 0x73, 0x73, 0x53, 0x73, 0x32, 0x53, 0x8b, 0xf4, 0xcb, 0xcc, 0xf5, 0x2b, 0xf4, - 0x91, 0x22, 0xbd, 0xa4, 0xb2, 0x20, 0xb5, 0x58, 0xbf, 0xcc, 0x30, 0x89, 0x0d, 0x1c, 0xf1, 0xc6, - 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x68, 0x6f, 0xd2, 0x24, 0x12, 0x02, 0x00, 0x00, + proto.RegisterType((*MsgAddAddressMappingRequest)(nil), "addresses.v1.MsgAddAddressMappingRequest") + proto.RegisterType((*MsgAddAddressMappingResponse)(nil), "addresses.v1.MsgAddAddressMappingResponse") + proto.RegisterType((*MsgRemoveAddressMappingRequest)(nil), "addresses.v1.MsgRemoveAddressMappingRequest") + proto.RegisterType((*MsgRemoveAddressMappingResponse)(nil), "addresses.v1.MsgRemoveAddressMappingResponse") +} + +func init() { proto.RegisterFile("addresses/v1/tx.proto", fileDescriptor_dbc33d4b2b06ba95) } + +var fileDescriptor_dbc33d4b2b06ba95 = []byte{ + // 266 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x4c, 0x49, 0x29, + 0x4a, 0x2d, 0x2e, 0x4e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x2f,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, + 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, 0x52, 0xd3, 0xd3, 0x2b, 0xb3, 0xca, 0xf4, + 0x8b, 0xf3, 0x73, 0x73, 0x53, 0x73, 0x32, 0x53, 0x8b, 0xf4, 0xcb, 0xcc, 0xf5, 0x2b, 0xf4, 0x11, + 0xd1, 0x5d, 0x52, 0x59, 0x00, 0x8e, 0xf4, 0x24, 0x36, 0x70, 0x94, 0x1b, 0x03, 0x02, 0x00, 0x00, + 0xff, 0xff, 0x98, 0xd6, 0x54, 0xe5, 0x0b, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -237,7 +237,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) AddAddressMapping(ctx context.Context, in *MsgAddAddressMappingRequest, opts ...grpc.CallOption) (*MsgAddAddressMappingResponse, error) { out := new(MsgAddAddressMappingResponse) - err := c.cc.Invoke(ctx, "/addressmap.v1.Msg/AddAddressMapping", in, out, opts...) + err := c.cc.Invoke(ctx, "/addresses.v1.Msg/AddAddressMapping", in, out, opts...) if err != nil { return nil, err } @@ -246,7 +246,7 @@ func (c *msgClient) AddAddressMapping(ctx context.Context, in *MsgAddAddressMapp func (c *msgClient) RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddressMappingRequest, opts ...grpc.CallOption) (*MsgRemoveAddressMappingResponse, error) { out := new(MsgRemoveAddressMappingResponse) - err := c.cc.Invoke(ctx, "/addressmap.v1.Msg/RemoveAddressMapping", in, out, opts...) + err := c.cc.Invoke(ctx, "/addresses.v1.Msg/RemoveAddressMapping", in, out, opts...) if err != nil { return nil, err } @@ -286,7 +286,7 @@ func _Msg_AddAddressMapping_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/addressmap.v1.Msg/AddAddressMapping", + FullMethod: "/addresses.v1.Msg/AddAddressMapping", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).AddAddressMapping(ctx, req.(*MsgAddAddressMappingRequest)) @@ -304,7 +304,7 @@ func _Msg_RemoveAddressMapping_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/addressmap.v1.Msg/RemoveAddressMapping", + FullMethod: "/addresses.v1.Msg/RemoveAddressMapping", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).RemoveAddressMapping(ctx, req.(*MsgRemoveAddressMappingRequest)) @@ -313,7 +313,7 @@ func _Msg_RemoveAddressMapping_Handler(srv interface{}, ctx context.Context, dec } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "addressmap.v1.Msg", + ServiceName: "addresses.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -326,7 +326,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "addressmap/v1/tx.proto", + Metadata: "addresses/v1/tx.proto", } func (m *MsgAddAddressMappingRequest) Marshal() (dAtA []byte, err error) { From 8d368996ba4e9e5b021591399b4ac3053784fccb Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Thu, 14 Mar 2024 10:13:50 -0500 Subject: [PATCH 04/28] WIP - addresses module --- proto/addresses/v1/genesis.proto | 1 + proto/addresses/v1/query.proto | 6 +- proto/addresses/v1/tx.proto | 11 +- x/addresses/client/cli/query.go | 31 +++ x/addresses/client/cli/query_params.go | 34 ++++ x/addresses/client/cli/tx.go | 36 ++++ x/addresses/keeper/keeper.go | 115 ++++++++++++ x/addresses/keeper/msg_server.go | 45 +++++ x/addresses/keeper/query_server.go | 99 ++++++++++ x/addresses/module.go | 161 ++++++++++++++++ x/addresses/types/codec.go | 23 +++ x/addresses/types/errors.go | 9 + x/addresses/types/expected_keepers.go | 18 ++ x/addresses/types/keys.go | 42 +++++ x/addresses/types/params.go | 39 ++++ x/addresses/types/v1/genesis.go | 21 +++ x/addresses/types/v1/genesis_test.go | 41 ++++ x/addresses/types/v1/msgs.go | 114 +++++++++++ x/addresses/types/v1/query.pb.go | 248 ++++++++++++++++-------- x/addresses/types/v1/tx.pb.go | 249 +++++++++++++++++-------- 20 files changed, 1182 insertions(+), 161 deletions(-) create mode 100644 x/addresses/client/cli/query.go create mode 100644 x/addresses/client/cli/query_params.go create mode 100644 x/addresses/client/cli/tx.go create mode 100644 x/addresses/keeper/keeper.go create mode 100644 x/addresses/keeper/msg_server.go create mode 100644 x/addresses/keeper/query_server.go create mode 100644 x/addresses/module.go create mode 100644 x/addresses/types/codec.go create mode 100644 x/addresses/types/errors.go create mode 100644 x/addresses/types/expected_keepers.go create mode 100644 x/addresses/types/keys.go create mode 100644 x/addresses/types/params.go create mode 100644 x/addresses/types/v1/genesis.go create mode 100644 x/addresses/types/v1/genesis_test.go create mode 100644 x/addresses/types/v1/msgs.go diff --git a/proto/addresses/v1/genesis.proto b/proto/addresses/v1/genesis.proto index 0a4c231e..69e67ea8 100644 --- a/proto/addresses/v1/genesis.proto +++ b/proto/addresses/v1/genesis.proto @@ -8,3 +8,4 @@ import "addresses/v1/addresses.proto"; message GenesisState { repeated AddressMapping address_mappings = 1; } + diff --git a/proto/addresses/v1/query.proto b/proto/addresses/v1/query.proto index ceccb132..dc921e59 100644 --- a/proto/addresses/v1/query.proto +++ b/proto/addresses/v1/query.proto @@ -38,7 +38,8 @@ message QueryAddressMappingByEVMAddressRequest { } message QueryAddressMappingByEVMAddressResponse { - AddressMapping address_mapping = 1; + string cosmos_address = 1; + string evm_address = 2; } message QueryAddressMappingByCosmosAddressRequest { @@ -46,5 +47,6 @@ message QueryAddressMappingByCosmosAddressRequest { } message QueryAddressMappingByCosmosAddressResponse { - AddressMapping address_mapping = 1; + string cosmos_address = 1; + string evm_address = 2; } diff --git a/proto/addresses/v1/tx.proto b/proto/addresses/v1/tx.proto index 9c89479c..4585cb9f 100644 --- a/proto/addresses/v1/tx.proto +++ b/proto/addresses/v1/tx.proto @@ -5,18 +5,21 @@ option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; service Msg { // Adds a mapping between the cosmos address of the sender and the provided EVM address - rpc AddAddressMapping (MsgAddAddressMappingRequest) returns (MsgAddAddressMappingResponse); + rpc AddAddressMapping (MsgAddAddressMapping) returns (MsgAddAddressMappingResponse); // Removes the mapping containing the cosmos address of the sender - rpc RemoveAddressMapping (MsgRemoveAddressMappingRequest) returns (MsgRemoveAddressMappingResponse); + rpc RemoveAddressMapping (MsgRemoveAddressMapping) returns (MsgRemoveAddressMappingResponse); } -message MsgAddAddressMappingRequest { +message MsgAddAddressMapping { string evm_address = 1; + string signer = 2; } message MsgAddAddressMappingResponse {} -message MsgRemoveAddressMappingRequest {} +message MsgRemoveAddressMapping { + string signer = 1; +} message MsgRemoveAddressMappingResponse {} diff --git a/x/addresses/client/cli/query.go b/x/addresses/client/cli/query.go new file mode 100644 index 00000000..79022d47 --- /dev/null +++ b/x/addresses/client/cli/query.go @@ -0,0 +1,31 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group addresses queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/addresses/client/cli/query_params.go b/x/addresses/client/cli/query_params.go new file mode 100644 index 00000000..ce87ae87 --- /dev/null +++ b/x/addresses/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/peggyjv/sommelier/v7/x/addresses/types" + "github.com/spf13/cobra" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/addresses/client/cli/tx.go b/x/addresses/client/cli/tx.go new file mode 100644 index 00000000..be5a5687 --- /dev/null +++ b/x/addresses/client/cli/tx.go @@ -0,0 +1,36 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/addresses/keeper/keeper.go b/x/addresses/keeper/keeper.go new file mode 100644 index 00000000..9af540c3 --- /dev/null +++ b/x/addresses/keeper/keeper.go @@ -0,0 +1,115 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +/////////////////////// +/// AddressMappings /// +/////////////////////// + +// SetAddressMapping stores the mapping between the cosmos and evm addresses +func (k Keeper) SetAddressMapping(ctx sdk.Context, cosmosAddr []byte, evmAddr []byte) { + k.SetCosmosToEvmMapping(ctx, cosmosAddr, evmAddr) + k.SetEvmToCosmosMapping(ctx, evmAddr, cosmosAddr) +} + +func (k Keeper) SetCosmosToEvmMapping(ctx sdk.Context, cosmosAddr []byte, evmAddr []byte) { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetCosmosToEvmMapKey(cosmosAddr), evmAddr) +} + +func (k Keeper) SetEvmToCosmosMapping(ctx sdk.Context, evmAddr []byte, cosmosAddr []byte) { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetEvmToCosmosMapKey(evmAddr), cosmosAddr) +} + +// DeleteAddressMapping deletes the mapping between the cosmos and evm addresses +func (k Keeper) DeleteAddressMapping(ctx sdk.Context, cosmosAddr []byte) { + if cosmosAddr == nil { + return + } + + evmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) + if evmAddr == nil { + return + } + + k.DeleteEvmToCosmosMapping(ctx, evmAddr) + k.DeleteCosmosToEvmMapping(ctx, cosmosAddr) +} + +func (k Keeper) DeleteCosmosToEvmMapping(ctx sdk.Context, cosmosAddr []byte) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetCosmosToEvmMapKey(cosmosAddr)) +} + +func (k Keeper) DeleteEvmToCosmosMapping(ctx sdk.Context, evmAddr []byte) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetEvmToCosmosMapKey(evmAddr)) +} + +func (k Keeper) GetCosmosAddressByEvmAddress(ctx sdk.Context, evmAddr []byte) []byte { + store := ctx.KVStore(k.storeKey) + return store.Get(types.GetEvmToCosmosMapKey(evmAddr)) +} + +func (k Keeper) GetEvmAddressByCosmosAddress(ctx sdk.Context, cosmosAddr []byte) []byte { + store := ctx.KVStore(k.storeKey) + return store.Get(types.GetCosmosToEvmMapKey(cosmosAddr)) +} + +// IterateAddressMappings iterates over all Cosmos to EVM address mappings +func (k Keeper) IterateAddressMappings(ctx sdk.Context, cb func(cosmosAddr []byte, evmAddr []byte) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.GetCosmosToEvmMapPrefix()) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + cosmosAddr := iterator.Key()[1:] + evmAddr := iterator.Value() + if cb(cosmosAddr, evmAddr) { + break + } + } +} diff --git a/x/addresses/keeper/msg_server.go b/x/addresses/keeper/msg_server.go new file mode 100644 index 00000000..3e95566a --- /dev/null +++ b/x/addresses/keeper/msg_server.go @@ -0,0 +1,45 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ typesv1.MsgServer = Keeper{} + +func (k Keeper) AddAddressMapping(c context.Context, req *typesv1.MsgAddAddressMapping) (*typesv1.MsgAddAddressMappingResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + signer, err := sdk.AccAddressFromBech32(req.GetSigner()) + if err != nil { + return &typesv1.MsgAddAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid signer address %s", req.GetSigner()) + } + + if !common.IsHexAddress(req.EvmAddress) { + return &typesv1.MsgAddAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", req.EvmAddress) + } + + evmAddr := common.Hex2Bytes(req.EvmAddress) + + k.SetAddressMapping(ctx, signer.Bytes(), evmAddr) + + return &typesv1.MsgAddAddressMappingResponse{}, nil +} + +func (k Keeper) RemoveAddressMapping(c context.Context, req *typesv1.MsgRemoveAddressMapping) (*typesv1.MsgRemoveAddressMappingResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + signer, err := sdk.AccAddressFromBech32(req.GetSigner()) + if err != nil { + return &typesv1.MsgRemoveAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid signer address %s", req.GetSigner()) + } + + k.DeleteAddressMapping(ctx, signer.Bytes()) + + return &typesv1.MsgRemoveAddressMappingResponse{}, nil +} diff --git a/x/addresses/keeper/query_server.go b/x/addresses/keeper/query_server.go new file mode 100644 index 00000000..caae789c --- /dev/null +++ b/x/addresses/keeper/query_server.go @@ -0,0 +1,99 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/cosmos-sdk/types/bech32" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/ethereum/go-ethereum/common" + "github.com/peggyjv/sommelier/v7/x/addresses/types" + typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ typesv1.QueryServer = Keeper{} + +func (k Keeper) QueryAddressMappings(c context.Context, request *typesv1.QueryAddressMappingsRequest) (*typesv1.QueryAddressMappingsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + var mappings []*typesv1.AddressMapping + var err error + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.GetCosmosToEvmMapPrefix()) + + pageRes, err := query.FilteredPaginate( + prefixStore, + &request.Pagination, + func(key []byte, value []byte, accumulate bool) (bool, error) { + cosmosAddr := sdk.MustBech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), key) + evmAddr := common.BytesToAddress(value).Hex() + mapping := typesv1.AddressMapping{ + CosmosAddress: cosmosAddr, + EvmAddress: evmAddr, + } + + if accumulate { + mappings = append(mappings, &mapping) + } + return true, nil + }, + ) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &typesv1.QueryAddressMappingsResponse{AddressMappings: mappings, Pagination: *pageRes}, nil +} + +func (k Keeper) QueryAddressMappingByCosmosAddress(c context.Context, request *typesv1.QueryAddressMappingByCosmosAddressRequest) (*typesv1.QueryAddressMappingByCosmosAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + _, cosmosAddr, err := bech32.DecodeAndConvert(request.GetCosmosAddress()) + if err != nil { + return &typesv1.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.InvalidArgument, "failed to parse cosmos address %s as bech32", request.GetCosmosAddress()) + } + + rawEvmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) + + if rawEvmAddr == nil { + return &typesv1.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.NotFound, "no EVM address mappings for cosmos address %s", request.GetCosmosAddress()) + } + + evmAddr := common.BytesToAddress(rawEvmAddr) + + return &typesv1.QueryAddressMappingByCosmosAddressResponse{ + CosmosAddress: request.GetCosmosAddress(), + EvmAddress: evmAddr.Hex(), + }, nil +} + +func (k Keeper) QueryAddressMappingByEVMAddress(c context.Context, request *typesv1.QueryAddressMappingByEVMAddressRequest) (*typesv1.QueryAddressMappingByEVMAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + if !common.IsHexAddress(request.GetEvmAddress()) { + return &typesv1.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", request.GetEvmAddress()) + } + + evmAddr := common.Hex2Bytes(request.GetEvmAddress()) + rawCosmosAddr := k.GetCosmosAddressByEvmAddress(ctx, evmAddr) + + if rawCosmosAddr == nil { + return &typesv1.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.NotFound, "no cosmos address mapping for EVM address %s", request.GetEvmAddress()) + } + + prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() + cosmosAddr, err := sdk.Bech32ifyAddressBytes(prefix, rawCosmosAddr) + if err != nil { + return &typesv1.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.Internal, "failed to convert cosmos address to bech32: %s", err) + } + + return &typesv1.QueryAddressMappingByEVMAddressResponse{ + CosmosAddress: cosmosAddr, + EvmAddress: request.GetEvmAddress(), + }, nil +} diff --git a/x/addresses/module.go b/x/addresses/module.go new file mode 100644 index 00000000..4fe519ec --- /dev/null +++ b/x/addresses/module.go @@ -0,0 +1,161 @@ +package addresses + +import ( + "context" + "encoding/json" + "fmt" + + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/peggyjv/sommelier/v7/x/addresses/client/cli" + "github.com/peggyjv/sommelier/v7/x/addresses/keeper" + "github.com/peggyjv/sommelier/v7/x/addresses/types" + typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(typesv1.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState typesv1.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + typesv1.RegisterQueryHandlerClient(context.Background(), mux, typesv1.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// Deprecated: use RegisterServices +func (am AppModule) Route() sdk.Route { return sdk.Route{} } + +// Deprecated: use RegisterServices +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// Deprecated: use RegisterServices +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + typesv1.RegisterMsgServer(cfg.MsgServer(), am.keeper) + typesv1.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState typesv1.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/addresses/types/codec.go b/x/addresses/types/codec.go new file mode 100644 index 00000000..844157a8 --- /dev/null +++ b/x/addresses/types/codec.go @@ -0,0 +1,23 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/addresses/types/errors.go b/x/addresses/types/errors.go new file mode 100644 index 00000000..d0747eb0 --- /dev/null +++ b/x/addresses/types/errors.go @@ -0,0 +1,9 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + ErrInvalidEvmAddress = sdkerrors.Register(ModuleName, 2, "invalid evm address") +) diff --git a/x/addresses/types/expected_keepers.go b/x/addresses/types/expected_keepers.go new file mode 100644 index 00000000..6aa6e977 --- /dev/null +++ b/x/addresses/types/expected_keepers.go @@ -0,0 +1,18 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} diff --git a/x/addresses/types/keys.go b/x/addresses/types/keys.go new file mode 100644 index 00000000..036d9f98 --- /dev/null +++ b/x/addresses/types/keys.go @@ -0,0 +1,42 @@ +package types + +import "bytes" + +const ( + // ModuleName defines the module name + ModuleName = "addresses" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_addresses" +) +const ( + _ = byte(iota) + + // + CosmosToEvmMapPrefix + + // + EvmToCosmosMapPrefix +) + +func GetCosmosToEvmMapPrefix() []byte { + return []byte{CosmosToEvmMapPrefix} +} + +func GetCosmosToEvmMapKey(cosmosAddr []byte) []byte { + return bytes.Join([][]byte{{CosmosToEvmMapPrefix}, cosmosAddr}, []byte{}) +} + +func GetEvmToCosmosMapPrefix() []byte { + return []byte{EvmToCosmosMapPrefix} +} + +func GetEvmToCosmosMapKey(evmAddr []byte) []byte { + return bytes.Join([][]byte{{EvmToCosmosMapPrefix}, evmAddr}, []byte{}) +} diff --git a/x/addresses/types/params.go b/x/addresses/types/params.go new file mode 100644 index 00000000..357196ad --- /dev/null +++ b/x/addresses/types/params.go @@ -0,0 +1,39 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/addresses/types/v1/genesis.go b/x/addresses/types/v1/genesis.go new file mode 100644 index 00000000..f0dad8c6 --- /dev/null +++ b/x/addresses/types/v1/genesis.go @@ -0,0 +1,21 @@ +package v1 + +// this line is used by starport scaffolding # genesis/types/import + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return nil +} diff --git a/x/addresses/types/v1/genesis_test.go b/x/addresses/types/v1/genesis_test.go new file mode 100644 index 00000000..530e1228 --- /dev/null +++ b/x/addresses/types/v1/genesis_test.go @@ -0,0 +1,41 @@ +package v1 + +import ( + "testing" + + "github.com/peggyjv/sommelier/v7/x/addresses/types" + typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *typesv1.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &typesv1.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/addresses/types/v1/msgs.go b/x/addresses/types/v1/msgs.go new file mode 100644 index 00000000..c796fafa --- /dev/null +++ b/x/addresses/types/v1/msgs.go @@ -0,0 +1,114 @@ +package v1 + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +var ( + _ sdk.Msg = &MsgAddAddressMapping{} + _ sdk.Msg = &MsgRemoveAddressMapping{} +) + +const ( + TypeMsgAddAddressMapping = "submit_bid" + TypeMsgRemoveAddressMapping = "remove_bid" +) + +////////////////////////// +// MsgAddAddressMapping // +////////////////////////// + +// NewMsgAddAddressMapping return a new MsgAddAddressMapping +func NewMsgAddAddressMapping(evmAddres common.Address, signer sdk.AccAddress) (*MsgAddAddressMapping, error) { + return &MsgAddAddressMapping{ + EvmAddress: evmAddres.Hex(), + Signer: signer.String(), + }, nil +} + +// Route implements sdk.Msg +func (m *MsgAddAddressMapping) Route() string { return types.ModuleName } + +// Type implements sdk.Msg +func (m *MsgAddAddressMapping) Type() string { return TypeMsgAddAddressMapping } + +// ValidateBasic implements sdk.Msg +func (m *MsgAddAddressMapping) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, err.Error()) + } + + if !common.IsHexAddress(m.EvmAddress) { + return errorsmod.Wrapf(types.ErrInvalidEvmAddress, "%s is not a valid hex address", m.EvmAddress) + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (m *MsgAddAddressMapping) GetSignBytes() []byte { + return sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(m)) +} + +// GetSigners implements sdk.Msg +func (m *MsgAddAddressMapping) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{m.MustGetSigner()} +} + +// MustGetSigner returns the signer address (which is also the bidder) +func (m *MsgAddAddressMapping) MustGetSigner() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + panic(err) + } + return addr +} + +///////////////////////////// +// MsgRemoveAddressMapping // +///////////////////////////// + +// NewMsgRemoveAddressMapping return a new MsgRemoveAddressMapping +func NewMsgRemoveAddressMapping(evmAddres common.Address, signer sdk.AccAddress) (*MsgRemoveAddressMapping, error) { + return &MsgRemoveAddressMapping{ + Signer: signer.String(), + }, nil +} + +// Route implements sdk.Msg +func (m *MsgRemoveAddressMapping) Route() string { return types.ModuleName } + +// Type implements sdk.Msg +func (m *MsgRemoveAddressMapping) Type() string { return TypeMsgRemoveAddressMapping } + +// ValidateBasic implements sdk.Msg +func (m *MsgRemoveAddressMapping) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, err.Error()) + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (m *MsgRemoveAddressMapping) GetSignBytes() []byte { + return sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(m)) +} + +// GetSigners implements sdk.Msg +func (m *MsgRemoveAddressMapping) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{m.MustGetSigner()} +} + +// MustGetSigner returns the signer address (which is also the bidder) +func (m *MsgRemoveAddressMapping) MustGetSigner() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + panic(err) + } + return addr +} diff --git a/x/addresses/types/v1/query.pb.go b/x/addresses/types/v1/query.pb.go index e744f2e6..7ed3ad4e 100644 --- a/x/addresses/types/v1/query.pb.go +++ b/x/addresses/types/v1/query.pb.go @@ -173,7 +173,8 @@ func (m *QueryAddressMappingByEVMAddressRequest) GetEvmAddress() string { } type QueryAddressMappingByEVMAddressResponse struct { - AddressMapping *AddressMapping `protobuf:"bytes,1,opt,name=address_mapping,json=addressMapping,proto3" json:"address_mapping,omitempty"` + CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty"` + EvmAddress string `protobuf:"bytes,2,opt,name=evm_address,json=evmAddress,proto3" json:"evm_address,omitempty"` } func (m *QueryAddressMappingByEVMAddressResponse) Reset() { @@ -211,11 +212,18 @@ func (m *QueryAddressMappingByEVMAddressResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAddressMappingByEVMAddressResponse proto.InternalMessageInfo -func (m *QueryAddressMappingByEVMAddressResponse) GetAddressMapping() *AddressMapping { +func (m *QueryAddressMappingByEVMAddressResponse) GetCosmosAddress() string { if m != nil { - return m.AddressMapping + return m.CosmosAddress } - return nil + return "" +} + +func (m *QueryAddressMappingByEVMAddressResponse) GetEvmAddress() string { + if m != nil { + return m.EvmAddress + } + return "" } type QueryAddressMappingByCosmosAddressRequest struct { @@ -267,7 +275,8 @@ func (m *QueryAddressMappingByCosmosAddressRequest) GetCosmosAddress() string { } type QueryAddressMappingByCosmosAddressResponse struct { - AddressMapping *AddressMapping `protobuf:"bytes,1,opt,name=address_mapping,json=addressMapping,proto3" json:"address_mapping,omitempty"` + CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty"` + EvmAddress string `protobuf:"bytes,2,opt,name=evm_address,json=evmAddress,proto3" json:"evm_address,omitempty"` } func (m *QueryAddressMappingByCosmosAddressResponse) Reset() { @@ -307,11 +316,18 @@ func (m *QueryAddressMappingByCosmosAddressResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAddressMappingByCosmosAddressResponse proto.InternalMessageInfo -func (m *QueryAddressMappingByCosmosAddressResponse) GetAddressMapping() *AddressMapping { +func (m *QueryAddressMappingByCosmosAddressResponse) GetCosmosAddress() string { if m != nil { - return m.AddressMapping + return m.CosmosAddress } - return nil + return "" +} + +func (m *QueryAddressMappingByCosmosAddressResponse) GetEvmAddress() string { + if m != nil { + return m.EvmAddress + } + return "" } func init() { @@ -326,41 +342,41 @@ func init() { func init() { proto.RegisterFile("addresses/v1/query.proto", fileDescriptor_ebe10bad8a6f145d) } var fileDescriptor_ebe10bad8a6f145d = []byte{ - // 538 bytes of a gzipped FileDescriptorProto + // 533 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6e, 0xd3, 0x30, - 0x18,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0x28, 0xd8, 0x31, 0xeb, 0xf6, 0x92, 0x55, 0x26, 0x82, + 0xab, 0x22, 0xdc, 0x43, 0x77, 0xab, 0x46, 0x20, 0x2c, 0x09, 0xc8, 0x41, 0x66, 0x22, 0x87, 0xe8, + 0x17, 0x80, 0x4e, 0xf9, 0xdc, 0xd1, 0x76, 0x05, 0x87, 0x45, 0xdb, 0x67, 0xdd, 0x59, 0xbe, 0xd0, + 0xa4, 0x7b, 0xa2, 0xd2, 0xb9, 0xe8, 0x7e, 0xe5, 0x74, 0xe6, 0x95, 0x3c, 0xc8, 0x6f, 0xe6, 0xa1, + 0xfb, 0xfc, 0x28, 0xb5, 0xc1, 0x71, 0x6a, 0x83, 0x9f, 0xa9, 0x0d, 0x3e, 0xce, 0xec, 0xda, 0xf1, + 0xcc, 0xae, 0x7d, 0x9f, 0xd9, 0xb5, 0xd7, 0x5b, 0xdc, 0x8f, 0xdf, 0x4c, 0x86, 0x78, 0x57, 0x04, + 0x24, 0x62, 0x9c, 0x4f, 0xdf, 0x26, 0x19, 0xb5, 0x64, 0x9b, 0xbc, 0xcf, 0x48, 0xc6, 0xd3, 0x48, + 0x09, 0x0f, 0x2f, 0xa8, 0x97, 0xf6, 0xd6, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0x59, 0x34, + 0x97, 0x11, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -645,15 +661,17 @@ func (m *QueryAddressMappingByEVMAddressResponse) MarshalToSizedBuffer(dAtA []by _ = i var l int _ = l - if m.AddressMapping != nil { - { - size, err := m.AddressMapping.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.EvmAddress) > 0 { + i -= len(m.EvmAddress) + copy(dAtA[i:], m.EvmAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.EvmAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.CosmosAddress) > 0 { + i -= len(m.CosmosAddress) + copy(dAtA[i:], m.CosmosAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CosmosAddress))) i-- dAtA[i] = 0xa } @@ -710,15 +728,17 @@ func (m *QueryAddressMappingByCosmosAddressResponse) MarshalToSizedBuffer(dAtA [ _ = i var l int _ = l - if m.AddressMapping != nil { - { - size, err := m.AddressMapping.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.EvmAddress) > 0 { + i -= len(m.EvmAddress) + copy(dAtA[i:], m.EvmAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.EvmAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.CosmosAddress) > 0 { + i -= len(m.CosmosAddress) + copy(dAtA[i:], m.CosmosAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CosmosAddress))) i-- dAtA[i] = 0xa } @@ -783,8 +803,12 @@ func (m *QueryAddressMappingByEVMAddressResponse) Size() (n int) { } var l int _ = l - if m.AddressMapping != nil { - l = m.AddressMapping.Size() + l = len(m.CosmosAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.EvmAddress) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n @@ -809,8 +833,12 @@ func (m *QueryAddressMappingByCosmosAddressResponse) Size() (n int) { } var l int _ = l - if m.AddressMapping != nil { - l = m.AddressMapping.Size() + l = len(m.CosmosAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.EvmAddress) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n @@ -1135,9 +1163,9 @@ func (m *QueryAddressMappingByEVMAddressResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AddressMapping", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CosmosAddress", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1147,27 +1175,55 @@ func (m *QueryAddressMappingByEVMAddressResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.AddressMapping == nil { - m.AddressMapping = &AddressMapping{} + m.CosmosAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery } - if err := m.AddressMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.EvmAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1303,9 +1359,9 @@ func (m *QueryAddressMappingByCosmosAddressResponse) Unmarshal(dAtA []byte) erro switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AddressMapping", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CosmosAddress", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1315,27 +1371,55 @@ func (m *QueryAddressMappingByCosmosAddressResponse) Unmarshal(dAtA []byte) erro } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.AddressMapping == nil { - m.AddressMapping = &AddressMapping{} + m.CosmosAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmAddress", wireType) } - if err := m.AddressMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EvmAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/addresses/types/v1/tx.pb.go b/x/addresses/types/v1/tx.pb.go index 723d876a..2bce70a6 100644 --- a/x/addresses/types/v1/tx.pb.go +++ b/x/addresses/types/v1/tx.pb.go @@ -27,22 +27,23 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type MsgAddAddressMappingRequest struct { +type MsgAddAddressMapping struct { EvmAddress string `protobuf:"bytes,1,opt,name=evm_address,json=evmAddress,proto3" json:"evm_address,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` } -func (m *MsgAddAddressMappingRequest) Reset() { *m = MsgAddAddressMappingRequest{} } -func (m *MsgAddAddressMappingRequest) String() string { return proto.CompactTextString(m) } -func (*MsgAddAddressMappingRequest) ProtoMessage() {} -func (*MsgAddAddressMappingRequest) Descriptor() ([]byte, []int) { +func (m *MsgAddAddressMapping) Reset() { *m = MsgAddAddressMapping{} } +func (m *MsgAddAddressMapping) String() string { return proto.CompactTextString(m) } +func (*MsgAddAddressMapping) ProtoMessage() {} +func (*MsgAddAddressMapping) Descriptor() ([]byte, []int) { return fileDescriptor_dbc33d4b2b06ba95, []int{0} } -func (m *MsgAddAddressMappingRequest) XXX_Unmarshal(b []byte) error { +func (m *MsgAddAddressMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddAddressMappingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgAddAddressMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddAddressMappingRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgAddAddressMapping.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -52,25 +53,32 @@ func (m *MsgAddAddressMappingRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgAddAddressMappingRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddAddressMappingRequest.Merge(m, src) +func (m *MsgAddAddressMapping) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddAddressMapping.Merge(m, src) } -func (m *MsgAddAddressMappingRequest) XXX_Size() int { +func (m *MsgAddAddressMapping) XXX_Size() int { return m.Size() } -func (m *MsgAddAddressMappingRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddAddressMappingRequest.DiscardUnknown(m) +func (m *MsgAddAddressMapping) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddAddressMapping.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddAddressMappingRequest proto.InternalMessageInfo +var xxx_messageInfo_MsgAddAddressMapping proto.InternalMessageInfo -func (m *MsgAddAddressMappingRequest) GetEvmAddress() string { +func (m *MsgAddAddressMapping) GetEvmAddress() string { if m != nil { return m.EvmAddress } return "" } +func (m *MsgAddAddressMapping) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + type MsgAddAddressMappingResponse struct { } @@ -107,21 +115,22 @@ func (m *MsgAddAddressMappingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAddAddressMappingResponse proto.InternalMessageInfo -type MsgRemoveAddressMappingRequest struct { +type MsgRemoveAddressMapping struct { + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` } -func (m *MsgRemoveAddressMappingRequest) Reset() { *m = MsgRemoveAddressMappingRequest{} } -func (m *MsgRemoveAddressMappingRequest) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveAddressMappingRequest) ProtoMessage() {} -func (*MsgRemoveAddressMappingRequest) Descriptor() ([]byte, []int) { +func (m *MsgRemoveAddressMapping) Reset() { *m = MsgRemoveAddressMapping{} } +func (m *MsgRemoveAddressMapping) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveAddressMapping) ProtoMessage() {} +func (*MsgRemoveAddressMapping) Descriptor() ([]byte, []int) { return fileDescriptor_dbc33d4b2b06ba95, []int{2} } -func (m *MsgRemoveAddressMappingRequest) XXX_Unmarshal(b []byte) error { +func (m *MsgRemoveAddressMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRemoveAddressMappingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRemoveAddressMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRemoveAddressMappingRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRemoveAddressMapping.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -131,17 +140,24 @@ func (m *MsgRemoveAddressMappingRequest) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *MsgRemoveAddressMappingRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveAddressMappingRequest.Merge(m, src) +func (m *MsgRemoveAddressMapping) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveAddressMapping.Merge(m, src) } -func (m *MsgRemoveAddressMappingRequest) XXX_Size() int { +func (m *MsgRemoveAddressMapping) XXX_Size() int { return m.Size() } -func (m *MsgRemoveAddressMappingRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveAddressMappingRequest.DiscardUnknown(m) +func (m *MsgRemoveAddressMapping) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveAddressMapping.DiscardUnknown(m) } -var xxx_messageInfo_MsgRemoveAddressMappingRequest proto.InternalMessageInfo +var xxx_messageInfo_MsgRemoveAddressMapping proto.InternalMessageInfo + +func (m *MsgRemoveAddressMapping) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} type MsgRemoveAddressMappingResponse struct { } @@ -180,33 +196,34 @@ func (m *MsgRemoveAddressMappingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveAddressMappingResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgAddAddressMappingRequest)(nil), "addresses.v1.MsgAddAddressMappingRequest") + proto.RegisterType((*MsgAddAddressMapping)(nil), "addresses.v1.MsgAddAddressMapping") proto.RegisterType((*MsgAddAddressMappingResponse)(nil), "addresses.v1.MsgAddAddressMappingResponse") - proto.RegisterType((*MsgRemoveAddressMappingRequest)(nil), "addresses.v1.MsgRemoveAddressMappingRequest") + proto.RegisterType((*MsgRemoveAddressMapping)(nil), "addresses.v1.MsgRemoveAddressMapping") proto.RegisterType((*MsgRemoveAddressMappingResponse)(nil), "addresses.v1.MsgRemoveAddressMappingResponse") } func init() { proto.RegisterFile("addresses/v1/tx.proto", fileDescriptor_dbc33d4b2b06ba95) } var fileDescriptor_dbc33d4b2b06ba95 = []byte{ - // 266 bytes of a gzipped FileDescriptorProto + // 279 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x4e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0xe2, 0x81, 0x0b, 0xeb, 0x95, 0x19, 0x2a, 0xd9, 0x71, 0x49, 0xfb, 0x16, 0xa7, 0x3b, - 0xa6, 0xa4, 0x38, 0x42, 0x44, 0x7d, 0x13, 0x0b, 0x0a, 0x32, 0xf3, 0xd2, 0x83, 0x52, 0x0b, 0x4b, - 0x53, 0x8b, 0x4b, 0x84, 0xe4, 0xb9, 0xb8, 0x53, 0xcb, 0x72, 0xe3, 0xa1, 0x5a, 0x24, 0x18, 0x15, - 0x18, 0x35, 0x38, 0x83, 0xb8, 0x52, 0xcb, 0x72, 0xa1, 0xca, 0x95, 0xe4, 0xb8, 0x64, 0xb0, 0xeb, - 0x2f, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0x52, 0xe0, 0x92, 0xf3, 0x2d, 0x4e, 0x0f, 0x4a, 0xcd, - 0xcd, 0x2f, 0x4b, 0xc5, 0x6a, 0x85, 0x92, 0x22, 0x97, 0x3c, 0x4e, 0x15, 0x10, 0x43, 0x8c, 0x9e, - 0x31, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x65, 0x71, 0x09, 0x62, 0xd8, 0x24, 0xa4, 0xa9, 0x87, - 0xec, 0x21, 0x3d, 0x3c, 0xbe, 0x91, 0xd2, 0x22, 0x46, 0x29, 0xc4, 0x4e, 0xa1, 0x62, 0x2e, 0x11, - 0x6c, 0x6e, 0x12, 0xd2, 0xc1, 0x30, 0x03, 0x8f, 0xe7, 0xa4, 0x74, 0x89, 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 0x52, 0x73, 0xf3, 0xcb, 0x52, 0xd1, 0xec, + 0x44, 0x18, 0xc9, 0x88, 0x62, 0xa4, 0x22, 0x97, 0x3c, 0x0e, 0x2d, 0x30, 0x53, 0x8d, 0x6e, 0x30, + 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x25, 0x73, 0x09, 0x62, 0xfa, 0x45, 0x49, 0x0f, 0xd9, 0xcb, + 0x7a, 0xd8, 0x9c, 0x27, 0xa5, 0x45, 0x58, 0x0d, 0xcc, 0x32, 0xa1, 0x1c, 0x2e, 0x11, 0xac, 0xee, + 0x57, 0xc5, 0x30, 0x03, 0x9b, 0x32, 0x29, 0x5d, 0xa2, 0x94, 0xc1, 0x6c, 0x73, 0xf2, 0x3b, 0xf1, + 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, + 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, + 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0x82, 0xd4, 0xf4, 0xf4, 0xca, 0xac, 0x32, 0xfd, 0xe2, 0xfc, 0xdc, + 0xdc, 0xd4, 0x9c, 0xcc, 0xd4, 0x22, 0xfd, 0x32, 0x73, 0xfd, 0x0a, 0x7d, 0x44, 0x12, 0x28, 0xa9, + 0x2c, 0x00, 0x27, 0x84, 0x24, 0x36, 0x70, 0x32, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x27, + 0x72, 0x09, 0x80, 0x1f, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -222,9 +239,9 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { // Adds a mapping between the cosmos address of the sender and the provided EVM address - AddAddressMapping(ctx context.Context, in *MsgAddAddressMappingRequest, opts ...grpc.CallOption) (*MsgAddAddressMappingResponse, error) + AddAddressMapping(ctx context.Context, in *MsgAddAddressMapping, opts ...grpc.CallOption) (*MsgAddAddressMappingResponse, error) // Removes the mapping containing the cosmos address of the sender - RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddressMappingRequest, opts ...grpc.CallOption) (*MsgRemoveAddressMappingResponse, error) + RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddressMapping, opts ...grpc.CallOption) (*MsgRemoveAddressMappingResponse, error) } type msgClient struct { @@ -235,7 +252,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) AddAddressMapping(ctx context.Context, in *MsgAddAddressMappingRequest, opts ...grpc.CallOption) (*MsgAddAddressMappingResponse, error) { +func (c *msgClient) AddAddressMapping(ctx context.Context, in *MsgAddAddressMapping, opts ...grpc.CallOption) (*MsgAddAddressMappingResponse, error) { out := new(MsgAddAddressMappingResponse) err := c.cc.Invoke(ctx, "/addresses.v1.Msg/AddAddressMapping", in, out, opts...) if err != nil { @@ -244,7 +261,7 @@ func (c *msgClient) AddAddressMapping(ctx context.Context, in *MsgAddAddressMapp return out, nil } -func (c *msgClient) RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddressMappingRequest, opts ...grpc.CallOption) (*MsgRemoveAddressMappingResponse, error) { +func (c *msgClient) RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddressMapping, opts ...grpc.CallOption) (*MsgRemoveAddressMappingResponse, error) { out := new(MsgRemoveAddressMappingResponse) err := c.cc.Invoke(ctx, "/addresses.v1.Msg/RemoveAddressMapping", in, out, opts...) if err != nil { @@ -256,19 +273,19 @@ func (c *msgClient) RemoveAddressMapping(ctx context.Context, in *MsgRemoveAddre // MsgServer is the server API for Msg service. type MsgServer interface { // Adds a mapping between the cosmos address of the sender and the provided EVM address - AddAddressMapping(context.Context, *MsgAddAddressMappingRequest) (*MsgAddAddressMappingResponse, error) + AddAddressMapping(context.Context, *MsgAddAddressMapping) (*MsgAddAddressMappingResponse, error) // Removes the mapping containing the cosmos address of the sender - RemoveAddressMapping(context.Context, *MsgRemoveAddressMappingRequest) (*MsgRemoveAddressMappingResponse, error) + RemoveAddressMapping(context.Context, *MsgRemoveAddressMapping) (*MsgRemoveAddressMappingResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) AddAddressMapping(ctx context.Context, req *MsgAddAddressMappingRequest) (*MsgAddAddressMappingResponse, error) { +func (*UnimplementedMsgServer) AddAddressMapping(ctx context.Context, req *MsgAddAddressMapping) (*MsgAddAddressMappingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddAddressMapping not implemented") } -func (*UnimplementedMsgServer) RemoveAddressMapping(ctx context.Context, req *MsgRemoveAddressMappingRequest) (*MsgRemoveAddressMappingResponse, error) { +func (*UnimplementedMsgServer) RemoveAddressMapping(ctx context.Context, req *MsgRemoveAddressMapping) (*MsgRemoveAddressMappingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RemoveAddressMapping not implemented") } @@ -277,7 +294,7 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { } func _Msg_AddAddressMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddAddressMappingRequest) + in := new(MsgAddAddressMapping) if err := dec(in); err != nil { return nil, err } @@ -289,13 +306,13 @@ func _Msg_AddAddressMapping_Handler(srv interface{}, ctx context.Context, dec fu FullMethod: "/addresses.v1.Msg/AddAddressMapping", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddAddressMapping(ctx, req.(*MsgAddAddressMappingRequest)) + return srv.(MsgServer).AddAddressMapping(ctx, req.(*MsgAddAddressMapping)) } return interceptor(ctx, in, info, handler) } func _Msg_RemoveAddressMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRemoveAddressMappingRequest) + in := new(MsgRemoveAddressMapping) if err := dec(in); err != nil { return nil, err } @@ -307,7 +324,7 @@ func _Msg_RemoveAddressMapping_Handler(srv interface{}, ctx context.Context, dec FullMethod: "/addresses.v1.Msg/RemoveAddressMapping", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RemoveAddressMapping(ctx, req.(*MsgRemoveAddressMappingRequest)) + return srv.(MsgServer).RemoveAddressMapping(ctx, req.(*MsgRemoveAddressMapping)) } return interceptor(ctx, in, info, handler) } @@ -329,7 +346,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "addresses/v1/tx.proto", } -func (m *MsgAddAddressMappingRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgAddAddressMapping) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -339,16 +356,23 @@ func (m *MsgAddAddressMappingRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddAddressMappingRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddAddressMapping) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddAddressMappingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddAddressMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } if len(m.EvmAddress) > 0 { i -= len(m.EvmAddress) copy(dAtA[i:], m.EvmAddress) @@ -382,7 +406,7 @@ func (m *MsgAddAddressMappingResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *MsgRemoveAddressMappingRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveAddressMapping) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -392,16 +416,23 @@ func (m *MsgRemoveAddressMappingRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRemoveAddressMappingRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveAddressMapping) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRemoveAddressMappingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveAddressMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -439,7 +470,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgAddAddressMappingRequest) Size() (n int) { +func (m *MsgAddAddressMapping) Size() (n int) { if m == nil { return 0 } @@ -449,6 +480,10 @@ func (m *MsgAddAddressMappingRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -461,12 +496,16 @@ func (m *MsgAddAddressMappingResponse) Size() (n int) { return n } -func (m *MsgRemoveAddressMappingRequest) Size() (n int) { +func (m *MsgRemoveAddressMapping) Size() (n int) { if m == nil { return 0 } var l int _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -485,7 +524,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgAddAddressMappingRequest) Unmarshal(dAtA []byte) error { +func (m *MsgAddAddressMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -508,10 +547,10 @@ func (m *MsgAddAddressMappingRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddAddressMappingRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddAddressMapping: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddAddressMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddAddressMapping: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -546,6 +585,38 @@ func (m *MsgAddAddressMappingRequest) Unmarshal(dAtA []byte) error { } m.EvmAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -617,7 +688,7 @@ func (m *MsgAddAddressMappingResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRemoveAddressMappingRequest) Unmarshal(dAtA []byte) error { +func (m *MsgRemoveAddressMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -640,12 +711,44 @@ func (m *MsgRemoveAddressMappingRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRemoveAddressMappingRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRemoveAddressMapping: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveAddressMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRemoveAddressMapping: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 4b374a103a9ec4ffc28ea5efbec8944568ed51f6 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Thu, 14 Mar 2024 13:25:31 -0500 Subject: [PATCH 05/28] WIP - address module builds --- app/app.go | 17 + proto/addresses/v1/addresses.proto | 2 +- proto/addresses/v1/genesis.proto | 8 +- proto/addresses/v1/query.proto | 13 +- proto/addresses/v1/tx.proto | 2 +- x/addresses/client/cli/query.go | 26 ++ x/addresses/client/cli/query_params.go | 34 -- x/addresses/keeper/genesis.go | 48 +++ x/addresses/keeper/keeper.go | 24 +- x/addresses/keeper/msg_server.go | 18 +- x/addresses/keeper/query_server.go | 38 +- x/addresses/module.go | 49 ++- x/addresses/types/addresses.go | 19 + x/addresses/types/{v1 => }/addresses.pb.go | 12 +- x/addresses/types/codec.go | 7 +- x/addresses/types/errors.go | 3 +- x/addresses/types/expected_keepers.go | 6 - x/addresses/types/{v1 => }/genesis.go | 13 +- x/addresses/types/{v1 => }/genesis.pb.go | 212 ++++++++++- x/addresses/types/{v1 => }/genesis_test.go | 16 +- x/addresses/types/{v1 => }/msgs.go | 13 +- x/addresses/types/params.go | 9 +- x/addresses/types/{v1 => }/query.pb.go | 422 +++++++++++++++++++-- x/addresses/types/{v1 => }/query.pb.gw.go | 69 +++- x/addresses/types/{v1 => }/tx.pb.go | 10 +- 25 files changed, 896 insertions(+), 194 deletions(-) delete mode 100644 x/addresses/client/cli/query_params.go create mode 100644 x/addresses/keeper/genesis.go create mode 100644 x/addresses/types/addresses.go rename x/addresses/types/{v1 => }/addresses.pb.go (96%) rename x/addresses/types/{v1 => }/genesis.go (63%) rename x/addresses/types/{v1 => }/genesis.pb.go (55%) rename x/addresses/types/{v1 => }/genesis_test.go (53%) rename x/addresses/types/{v1 => }/msgs.go (86%) rename x/addresses/types/{v1 => }/query.pb.go (77%) rename x/addresses/types/{v1 => }/query.pb.gw.go (83%) rename x/addresses/types/{v1 => }/tx.pb.go (98%) diff --git a/app/app.go b/app/app.go index b2d478e4..c786a124 100644 --- a/app/app.go +++ b/app/app.go @@ -100,6 +100,9 @@ import ( v5 "github.com/peggyjv/sommelier/v7/app/upgrades/v5" v6 "github.com/peggyjv/sommelier/v7/app/upgrades/v6" v7 "github.com/peggyjv/sommelier/v7/app/upgrades/v7" + "github.com/peggyjv/sommelier/v7/x/addresses" + addresseskeeper "github.com/peggyjv/sommelier/v7/x/addresses/keeper" + addressestypes "github.com/peggyjv/sommelier/v7/x/addresses/types" "github.com/peggyjv/sommelier/v7/x/auction" auctionclient "github.com/peggyjv/sommelier/v7/x/auction/client" auctionkeeper "github.com/peggyjv/sommelier/v7/x/auction/keeper" @@ -199,6 +202,7 @@ var ( incentives.AppModuleBasic{}, auction.AppModuleBasic{}, pubsub.AppModuleBasic{}, + addresses.AppModuleBasic{}, ) // module account permissions @@ -217,6 +221,7 @@ var ( axelarcorktypes.ModuleName: nil, auctiontypes.ModuleName: nil, pubsubtypes.ModuleName: nil, + addressestypes.ModuleName: nil, } // module accounts that are allowed to receive tokens @@ -272,6 +277,7 @@ type SommelierApp struct { IncentivesKeeper incentiveskeeper.Keeper AuctionKeeper auctionkeeper.Keeper PubsubKeeper pubsubkeeper.Keeper + AddressesKeeper addresseskeeper.Keeper // make capability scoped keepers public for test purposes (IBC only) ScopedAxelarCorkKeeper capabilitykeeper.ScopedKeeper @@ -336,6 +342,7 @@ func NewSommelierApp( auctiontypes.StoreKey, cellarfeestypes.StoreKey, pubsubtypes.StoreKey, + addressestypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -509,6 +516,10 @@ func NewSommelierApp( app.CellarFeesKeeper.Hooks(), )) + app.AddressesKeeper = *addresseskeeper.NewKeeper( + appCodec, keys[addressestypes.StoreKey], app.GetSubspace(addressestypes.ModuleName), + ) + // register the proposal types govRouter := govtypesv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler). @@ -581,6 +592,7 @@ func NewSommelierApp( cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.GravityKeeper, app.AuctionKeeper), auction.NewAppModule(app.AuctionKeeper, app.BankKeeper, app.AccountKeeper, appCodec), pubsub.NewAppModule(appCodec, app.PubsubKeeper, app.StakingKeeper, app.GravityKeeper), + addresses.NewAppModule(appCodec, app.AddressesKeeper, app.AccountKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -615,6 +627,7 @@ func NewSommelierApp( cellarfeestypes.ModuleName, auctiontypes.ModuleName, pubsubtypes.ModuleName, + addressestypes.ModuleName, ) // NOTE gov must come before staking @@ -645,6 +658,7 @@ func NewSommelierApp( cellarfeestypes.ModuleName, auctiontypes.ModuleName, pubsubtypes.ModuleName, + addressestypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -683,6 +697,7 @@ func NewSommelierApp( cellarfeestypes.ModuleName, auctiontypes.ModuleName, pubsubtypes.ModuleName, + addressestypes.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -716,6 +731,7 @@ func NewSommelierApp( cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.GravityKeeper, app.AuctionKeeper), auction.NewAppModule(app.AuctionKeeper, app.BankKeeper, app.AccountKeeper, appCodec), pubsub.NewAppModule(appCodec, app.PubsubKeeper, app.StakingKeeper, app.GravityKeeper), + addresses.NewAppModule(appCodec, app.AddressesKeeper, app.AccountKeeper), ) app.sm.RegisterStoreDecoders() @@ -953,6 +969,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(incentivestypes.ModuleName) paramsKeeper.Subspace(auctiontypes.ModuleName) paramsKeeper.Subspace(pubsubtypes.ModuleName) + paramsKeeper.Subspace(addressestypes.ModuleName) return paramsKeeper } diff --git a/proto/addresses/v1/addresses.proto b/proto/addresses/v1/addresses.proto index 57cab9e8..d5c0dce4 100644 --- a/proto/addresses/v1/addresses.proto +++ b/proto/addresses/v1/addresses.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package addresses.v1; -option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types"; message AddressMapping { string cosmos_address = 1; diff --git a/proto/addresses/v1/genesis.proto b/proto/addresses/v1/genesis.proto index 69e67ea8..429874f5 100644 --- a/proto/addresses/v1/genesis.proto +++ b/proto/addresses/v1/genesis.proto @@ -1,11 +1,15 @@ syntax = "proto3"; package addresses.v1; -option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types"; import "addresses/v1/addresses.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; message GenesisState { - repeated AddressMapping address_mappings = 1; + Params params = 1 [ (gogoproto.nullable) = false ]; + repeated AddressMapping address_mappings = 2; } +message Params {} diff --git a/proto/addresses/v1/query.proto b/proto/addresses/v1/query.proto index dc921e59..e54f354e 100644 --- a/proto/addresses/v1/query.proto +++ b/proto/addresses/v1/query.proto @@ -3,14 +3,19 @@ syntax = "proto3"; package addresses.v1; import "addresses/v1/addresses.proto"; +import "addresses/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types"; service Query { + rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/sommelier/addresses/v1/params"; + } + rpc QueryAddressMappings(QueryAddressMappingsRequest) returns (QueryAddressMappingsResponse) { option (google.api.http).get = "/sommelier/addresses/v1/address_mappings"; } @@ -24,6 +29,12 @@ service Query { } } +message QueryParamsRequest {} + +message QueryParamsResponse { + Params params = 1; +} + message QueryAddressMappingsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/addresses/v1/tx.proto b/proto/addresses/v1/tx.proto index 4585cb9f..05726a86 100644 --- a/proto/addresses/v1/tx.proto +++ b/proto/addresses/v1/tx.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package addresses.v1; -option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types/v1"; +option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types"; service Msg { // Adds a mapping between the cosmos address of the sender and the provided EVM address diff --git a/x/addresses/client/cli/query.go b/x/addresses/client/cli/query.go index 79022d47..2c5edee1 100644 --- a/x/addresses/client/cli/query.go +++ b/x/addresses/client/cli/query.go @@ -1,12 +1,14 @@ package cli import ( + "context" "fmt" // "strings" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" // "github.com/cosmos/cosmos-sdk/client/flags" // sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,3 +31,27 @@ func GetQueryCmd(queryRoute string) *cobra.Command { return cmd } + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryParams(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/addresses/client/cli/query_params.go b/x/addresses/client/cli/query_params.go deleted file mode 100644 index ce87ae87..00000000 --- a/x/addresses/client/cli/query_params.go +++ /dev/null @@ -1,34 +0,0 @@ -package cli - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/peggyjv/sommelier/v7/x/addresses/types" - "github.com/spf13/cobra" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/addresses/keeper/genesis.go b/x/addresses/keeper/genesis.go new file mode 100644 index 00000000..cdc769e0 --- /dev/null +++ b/x/addresses/keeper/genesis.go @@ -0,0 +1,48 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +// InitGenesis initializes the module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { + panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) + } + + k.setParams(ctx, gs.Params) + + for _, mapping := range gs.AddressMappings { + cosmosAcc, err := sdk.AccAddressFromBech32(mapping.CosmosAddress) + if err != nil { + panic(err) + } + + if !common.IsHexAddress(mapping.EvmAddress) { + panic(fmt.Sprintf("invalid EVM address %s", mapping.EvmAddress)) + } + + evmAddr := common.Hex2Bytes(mapping.EvmAddress) + + k.SetAddressMapping(ctx, cosmosAcc.Bytes(), evmAddr) + } +} + +// ExportGenesis returns the module's exported genesis. +func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState { + var mappings []*types.AddressMapping + k.IterateAddressMappings(ctx, func(cosmosAddr []byte, evmAddr []byte) bool { + mappings = append(mappings, &types.AddressMapping{ + CosmosAddress: sdk.AccAddress(cosmosAddr).String(), + EvmAddress: common.Bytes2Hex(evmAddr), + }) + return false + }) + + return types.GenesisState{AddressMappings: mappings} +} diff --git a/x/addresses/keeper/keeper.go b/x/addresses/keeper/keeper.go index 9af540c3..d5507461 100644 --- a/x/addresses/keeper/keeper.go +++ b/x/addresses/keeper/keeper.go @@ -16,17 +16,14 @@ type ( Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey - memKey storetypes.StoreKey paramstore paramtypes.Subspace } ) func NewKeeper( cdc codec.BinaryCodec, - storeKey, - memKey storetypes.StoreKey, + key storetypes.StoreKey, ps paramtypes.Subspace, - ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -35,8 +32,7 @@ func NewKeeper( return &Keeper{ cdc: cdc, - storeKey: storeKey, - memKey: memKey, + storeKey: key, paramstore: ps, } } @@ -45,6 +41,22 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } +//////////// +// Params // +//////////// + +// GetParamSet returns the vote period from the parameters +func (k Keeper) GetParamSet(ctx sdk.Context) types.Params { + var p types.Params + k.paramstore.GetParamSet(ctx, &p) + return p +} + +// setParams sets the parameters in the store +func (k Keeper) setParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} + /////////////////////// /// AddressMappings /// /////////////////////// diff --git a/x/addresses/keeper/msg_server.go b/x/addresses/keeper/msg_server.go index 3e95566a..5b81641f 100644 --- a/x/addresses/keeper/msg_server.go +++ b/x/addresses/keeper/msg_server.go @@ -5,41 +5,41 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" + "github.com/peggyjv/sommelier/v7/x/addresses/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -var _ typesv1.MsgServer = Keeper{} +var _ types.MsgServer = Keeper{} -func (k Keeper) AddAddressMapping(c context.Context, req *typesv1.MsgAddAddressMapping) (*typesv1.MsgAddAddressMappingResponse, error) { +func (k Keeper) AddAddressMapping(c context.Context, req *types.MsgAddAddressMapping) (*types.MsgAddAddressMappingResponse, error) { ctx := sdk.UnwrapSDKContext(c) signer, err := sdk.AccAddressFromBech32(req.GetSigner()) if err != nil { - return &typesv1.MsgAddAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid signer address %s", req.GetSigner()) + return &types.MsgAddAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid signer address %s", req.GetSigner()) } if !common.IsHexAddress(req.EvmAddress) { - return &typesv1.MsgAddAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", req.EvmAddress) + return &types.MsgAddAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", req.EvmAddress) } evmAddr := common.Hex2Bytes(req.EvmAddress) k.SetAddressMapping(ctx, signer.Bytes(), evmAddr) - return &typesv1.MsgAddAddressMappingResponse{}, nil + return &types.MsgAddAddressMappingResponse{}, nil } -func (k Keeper) RemoveAddressMapping(c context.Context, req *typesv1.MsgRemoveAddressMapping) (*typesv1.MsgRemoveAddressMappingResponse, error) { +func (k Keeper) RemoveAddressMapping(c context.Context, req *types.MsgRemoveAddressMapping) (*types.MsgRemoveAddressMappingResponse, error) { ctx := sdk.UnwrapSDKContext(c) signer, err := sdk.AccAddressFromBech32(req.GetSigner()) if err != nil { - return &typesv1.MsgRemoveAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid signer address %s", req.GetSigner()) + return &types.MsgRemoveAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid signer address %s", req.GetSigner()) } k.DeleteAddressMapping(ctx, signer.Bytes()) - return &typesv1.MsgRemoveAddressMappingResponse{}, nil + return &types.MsgRemoveAddressMappingResponse{}, nil } diff --git a/x/addresses/keeper/query_server.go b/x/addresses/keeper/query_server.go index caae789c..e64ebb54 100644 --- a/x/addresses/keeper/query_server.go +++ b/x/addresses/keeper/query_server.go @@ -10,17 +10,25 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/ethereum/go-ethereum/common" "github.com/peggyjv/sommelier/v7/x/addresses/types" - typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -var _ typesv1.QueryServer = Keeper{} +var _ types.QueryServer = Keeper{} -func (k Keeper) QueryAddressMappings(c context.Context, request *typesv1.QueryAddressMappingsRequest) (*typesv1.QueryAddressMappingsResponse, error) { +// QueryParams implements QueryServer +func (k Keeper) QueryParams(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + params := k.GetParamSet(sdk.UnwrapSDKContext(c)) + + return &types.QueryParamsResponse{ + Params: ¶ms, + }, nil +} + +func (k Keeper) QueryAddressMappings(c context.Context, request *types.QueryAddressMappingsRequest) (*types.QueryAddressMappingsResponse, error) { ctx := sdk.UnwrapSDKContext(c) - var mappings []*typesv1.AddressMapping + var mappings []*types.AddressMapping var err error store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, types.GetCosmosToEvmMapPrefix()) @@ -31,7 +39,7 @@ func (k Keeper) QueryAddressMappings(c context.Context, request *typesv1.QueryAd func(key []byte, value []byte, accumulate bool) (bool, error) { cosmosAddr := sdk.MustBech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), key) evmAddr := common.BytesToAddress(value).Hex() - mapping := typesv1.AddressMapping{ + mapping := types.AddressMapping{ CosmosAddress: cosmosAddr, EvmAddress: evmAddr, } @@ -47,52 +55,52 @@ func (k Keeper) QueryAddressMappings(c context.Context, request *typesv1.QueryAd return nil, status.Error(codes.Internal, err.Error()) } - return &typesv1.QueryAddressMappingsResponse{AddressMappings: mappings, Pagination: *pageRes}, nil + return &types.QueryAddressMappingsResponse{AddressMappings: mappings, Pagination: *pageRes}, nil } -func (k Keeper) QueryAddressMappingByCosmosAddress(c context.Context, request *typesv1.QueryAddressMappingByCosmosAddressRequest) (*typesv1.QueryAddressMappingByCosmosAddressResponse, error) { +func (k Keeper) QueryAddressMappingByCosmosAddress(c context.Context, request *types.QueryAddressMappingByCosmosAddressRequest) (*types.QueryAddressMappingByCosmosAddressResponse, error) { ctx := sdk.UnwrapSDKContext(c) _, cosmosAddr, err := bech32.DecodeAndConvert(request.GetCosmosAddress()) if err != nil { - return &typesv1.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.InvalidArgument, "failed to parse cosmos address %s as bech32", request.GetCosmosAddress()) + return &types.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.InvalidArgument, "failed to parse cosmos address %s as bech32", request.GetCosmosAddress()) } rawEvmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) if rawEvmAddr == nil { - return &typesv1.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.NotFound, "no EVM address mappings for cosmos address %s", request.GetCosmosAddress()) + return &types.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.NotFound, "no EVM address mappings for cosmos address %s", request.GetCosmosAddress()) } evmAddr := common.BytesToAddress(rawEvmAddr) - return &typesv1.QueryAddressMappingByCosmosAddressResponse{ + return &types.QueryAddressMappingByCosmosAddressResponse{ CosmosAddress: request.GetCosmosAddress(), EvmAddress: evmAddr.Hex(), }, nil } -func (k Keeper) QueryAddressMappingByEVMAddress(c context.Context, request *typesv1.QueryAddressMappingByEVMAddressRequest) (*typesv1.QueryAddressMappingByEVMAddressResponse, error) { +func (k Keeper) QueryAddressMappingByEVMAddress(c context.Context, request *types.QueryAddressMappingByEVMAddressRequest) (*types.QueryAddressMappingByEVMAddressResponse, error) { ctx := sdk.UnwrapSDKContext(c) if !common.IsHexAddress(request.GetEvmAddress()) { - return &typesv1.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", request.GetEvmAddress()) + return &types.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", request.GetEvmAddress()) } evmAddr := common.Hex2Bytes(request.GetEvmAddress()) rawCosmosAddr := k.GetCosmosAddressByEvmAddress(ctx, evmAddr) if rawCosmosAddr == nil { - return &typesv1.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.NotFound, "no cosmos address mapping for EVM address %s", request.GetEvmAddress()) + return &types.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.NotFound, "no cosmos address mapping for EVM address %s", request.GetEvmAddress()) } prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() cosmosAddr, err := sdk.Bech32ifyAddressBytes(prefix, rawCosmosAddr) if err != nil { - return &typesv1.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.Internal, "failed to convert cosmos address to bech32: %s", err) + return &types.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.Internal, "failed to convert cosmos address to bech32: %s", err) } - return &typesv1.QueryAddressMappingByEVMAddressResponse{ + return &types.QueryAddressMappingByEVMAddressResponse{ CosmosAddress: cosmosAddr, EvmAddress: request.GetEvmAddress(), }, nil diff --git a/x/addresses/module.go b/x/addresses/module.go index 4fe519ec..3b039cfa 100644 --- a/x/addresses/module.go +++ b/x/addresses/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "math/rand" // this line is used by starport scaffolding # 1 @@ -17,10 +18,10 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + sim "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/peggyjv/sommelier/v7/x/addresses/client/cli" "github.com/peggyjv/sommelier/v7/x/addresses/keeper" "github.com/peggyjv/sommelier/v7/x/addresses/types" - typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" ) var ( @@ -58,12 +59,12 @@ func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { // DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(typesv1.DefaultGenesis()) + return cdc.MustMarshalJSON(types.DefaultGenesis()) } // ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var genState typesv1.GenesisState + var genState types.GenesisState if err := cdc.UnmarshalJSON(bz, &genState); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } @@ -72,7 +73,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - typesv1.RegisterQueryHandlerClient(context.Background(), mux, typesv1.NewQueryClient(clientCtx)) + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module @@ -95,20 +96,17 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper } func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, accountKeeper: accountKeeper, - bankKeeper: bankKeeper, } } @@ -125,8 +123,8 @@ func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { - typesv1.RegisterMsgServer(cfg.MsgServer(), am.keeper) - typesv1.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) @@ -134,24 +132,28 @@ func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // InitGenesis performs the module's genesis initialization. It returns no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { - var genState typesv1.GenesisState + var genState types.GenesisState // Initialize global index to index in genesis state cdc.MustUnmarshalJSON(gs, &genState) - InitGenesis(ctx, am.keeper, genState) + keeper.InitGenesis(ctx, am.keeper, genState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the module's exported genesis state as raw JSON bytes. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := ExportGenesis(ctx, am.keeper) - return cdc.MustMarshalJSON(genState) + genState := keeper.ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(&genState) } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 func (AppModule) ConsensusVersion() uint64 { return 1 } +func (am AppModule) WeightedOperations(simState module.SimulationState) []sim.WeightedOperation { + return nil +} + // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} @@ -159,3 +161,24 @@ func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the distribution module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +} + +// ProposalContents returns all the distribution content functions used to +// simulate governance proposals. +func (am AppModule) ProposalContents(_ module.SimulationState) []sim.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized distribution param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []sim.ParamChange { + return nil +} + +// RegisterStoreDecoder registers a decoder for distribution module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +} diff --git a/x/addresses/types/addresses.go b/x/addresses/types/addresses.go new file mode 100644 index 00000000..510e178f --- /dev/null +++ b/x/addresses/types/addresses.go @@ -0,0 +1,19 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" +) + +func (am AddressMapping) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(am.CosmosAddress); err != nil { + return sdkerrors.Wrapf(ErrInvalidCosmosAddress, "%s is not a valid cosmos address", am.CosmosAddress) + } + + if !common.IsHexAddress(am.EvmAddress) { + return sdkerrors.Wrapf(ErrInvalidEvmAddress, "%s is not a valid EVM address", am.EvmAddress) + } + + return nil +} diff --git a/x/addresses/types/v1/addresses.pb.go b/x/addresses/types/addresses.pb.go similarity index 96% rename from x/addresses/types/v1/addresses.pb.go rename to x/addresses/types/addresses.pb.go index f1d625b2..f6bafe42 100644 --- a/x/addresses/types/v1/addresses.pb.go +++ b/x/addresses/types/addresses.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: addresses/v1/addresses.proto -package v1 +package types import ( fmt "fmt" @@ -81,19 +81,19 @@ func init() { func init() { proto.RegisterFile("addresses/v1/addresses.proto", fileDescriptor_f62edfd8f2ffb6f4) } var fileDescriptor_f62edfd8f2ffb6f4 = []byte{ - // 186 bytes of a gzipped FileDescriptorProto + // 185 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x4e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x87, 0x73, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x78, 0x10, 0x02, 0x65, 0x86, 0x4a, 0x11, 0x5c, 0x7c, 0x8e, 0x10, 0xbe, 0x6f, 0x62, 0x41, 0x41, 0x66, 0x5e, 0xba, 0x90, 0x2a, 0x17, 0x5f, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x3c, 0x54, 0xa1, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x2f, 0x44, 0x14, 0xaa, 0x5a, 0x48, 0x9e, 0x8b, 0x3b, 0xb5, 0x2c, 0x17, 0xae, 0x86, 0x09, 0xac, 0x86, 0x2b, 0xb5, 0x2c, 0x17, 0xaa, 0xc0, - 0xc9, 0xef, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, - 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd2, 0x33, 0x4b, + 0xc9, 0xfb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, + 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, 0x52, 0xd3, 0xd3, 0x2b, 0xb3, 0xca, 0xf4, 0x8b, 0xf3, 0x73, 0x73, 0x53, 0x73, 0x32, 0x53, 0x8b, 0xf4, 0xcb, 0xcc, 0xf5, 0x2b, 0x10, 0x8e, - 0xd6, 0x2f, 0xa9, 0x2c, 0x00, 0xfb, 0x23, 0x89, 0x0d, 0xec, 0x7c, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x69, 0x6f, 0x22, 0xea, 0xde, 0x00, 0x00, 0x00, + 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xbb, 0xdd, 0x18, 0x10, 0x00, 0x00, 0xff, + 0xff, 0x88, 0x59, 0xca, 0xf1, 0xdb, 0x00, 0x00, 0x00, } func (m *AddressMapping) Marshal() (dAtA []byte, err error) { diff --git a/x/addresses/types/codec.go b/x/addresses/types/codec.go index 844157a8..4e1cb5f6 100644 --- a/x/addresses/types/codec.go +++ b/x/addresses/types/codec.go @@ -3,17 +3,16 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { - // this line is used by starport scaffolding # 2 + cdc.RegisterConcrete(&MsgAddAddressMapping{}, "addresses/MsgAddAddressMapping", nil) + cdc.RegisterConcrete(&MsgRemoveAddressMapping{}, "addresses/MsgRemoveAddressMapping", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // this line is used by starport scaffolding # 3 - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/addresses/types/errors.go b/x/addresses/types/errors.go index d0747eb0..618933ef 100644 --- a/x/addresses/types/errors.go +++ b/x/addresses/types/errors.go @@ -5,5 +5,6 @@ import ( ) var ( - ErrInvalidEvmAddress = sdkerrors.Register(ModuleName, 2, "invalid evm address") + ErrInvalidEvmAddress = sdkerrors.Register(ModuleName, 2, "invalid evm address") + ErrInvalidCosmosAddress = sdkerrors.Register(ModuleName, 3, "invalid cosmos address") ) diff --git a/x/addresses/types/expected_keepers.go b/x/addresses/types/expected_keepers.go index 6aa6e977..20eea16d 100644 --- a/x/addresses/types/expected_keepers.go +++ b/x/addresses/types/expected_keepers.go @@ -10,9 +10,3 @@ type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI // Methods imported from account should be defined here } - -// BankKeeper defines the expected interface needed to retrieve account balances. -type BankKeeper interface { - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - // Methods imported from bank should be defined here -} diff --git a/x/addresses/types/v1/genesis.go b/x/addresses/types/genesis.go similarity index 63% rename from x/addresses/types/v1/genesis.go rename to x/addresses/types/genesis.go index f0dad8c6..30a4438b 100644 --- a/x/addresses/types/v1/genesis.go +++ b/x/addresses/types/genesis.go @@ -1,4 +1,4 @@ -package v1 +package types // this line is used by starport scaffolding # genesis/types/import @@ -8,14 +8,21 @@ const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + AddressMappings: []*AddressMapping{}, } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # genesis/types/validate + gs.Params.ValidateBasic() + + for _, mapping := range gs.AddressMappings { + if err := mapping.ValidateBasic(); err != nil { + return err + } + } return nil } diff --git a/x/addresses/types/v1/genesis.pb.go b/x/addresses/types/genesis.pb.go similarity index 55% rename from x/addresses/types/v1/genesis.pb.go rename to x/addresses/types/genesis.pb.go index 9d3c867d..e3eca233 100644 --- a/x/addresses/types/v1/genesis.pb.go +++ b/x/addresses/types/genesis.pb.go @@ -1,11 +1,13 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: addresses/v1/genesis.proto -package v1 +package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" io "io" math "math" math_bits "math/bits" @@ -23,7 +25,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { - AddressMappings []*AddressMapping `protobuf:"bytes,1,rep,name=address_mappings,json=addressMappings,proto3" json:"address_mappings,omitempty"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + AddressMappings []*AddressMapping `protobuf:"bytes,2,rep,name=address_mappings,json=addressMappings,proto3" json:"address_mappings,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -59,6 +62,13 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func (m *GenesisState) GetAddressMappings() []*AddressMapping { if m != nil { return m.AddressMappings @@ -66,27 +76,68 @@ func (m *GenesisState) GetAddressMappings() []*AddressMapping { return nil } +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_b55f1bec9bbe9669, []int{1} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + func init() { proto.RegisterType((*GenesisState)(nil), "addresses.v1.GenesisState") + proto.RegisterType((*Params)(nil), "addresses.v1.Params") } func init() { proto.RegisterFile("addresses/v1/genesis.proto", fileDescriptor_b55f1bec9bbe9669) } var fileDescriptor_b55f1bec9bbe9669 = []byte{ - // 194 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x4c, 0x49, 0x29, - 0x4a, 0x2d, 0x2e, 0x4e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, - 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x81, 0xcb, 0xe9, 0x95, 0x19, 0x4a, 0xc9, 0xa0, - 0xa8, 0x44, 0x48, 0x81, 0xd5, 0x2a, 0x85, 0x73, 0xf1, 0xb8, 0x43, 0x34, 0x07, 0x97, 0x24, 0x96, - 0xa4, 0x0a, 0xb9, 0x73, 0x09, 0x40, 0x95, 0xc4, 0xe7, 0x26, 0x16, 0x14, 0x64, 0xe6, 0xa5, 0x17, - 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xc9, 0xe8, 0x21, 0x1b, 0xab, 0xe7, 0x08, 0xe1, 0xf8, - 0x42, 0x14, 0x05, 0xf1, 0x27, 0xa2, 0xf0, 0x8b, 0x9d, 0xfc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, - 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, - 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x24, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, - 0xbf, 0x20, 0x35, 0x3d, 0xbd, 0x32, 0xab, 0x4c, 0xbf, 0x38, 0x3f, 0x37, 0x37, 0x35, 0x27, 0x33, - 0xb5, 0x48, 0xbf, 0xcc, 0x5c, 0xbf, 0x02, 0xe1, 0x4a, 0xfd, 0x92, 0xca, 0x02, 0xb0, 0xc3, 0x93, - 0xd8, 0xc0, 0xee, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xe1, 0x57, 0x03, 0xf9, 0x00, - 0x00, 0x00, + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x31, 0x4b, 0xc3, 0x40, + 0x1c, 0xc5, 0x73, 0x2a, 0x41, 0xd2, 0x82, 0x12, 0x3a, 0x94, 0x10, 0xce, 0xd2, 0xa9, 0x53, 0x8e, + 0xc4, 0xc1, 0x59, 0x97, 0x0e, 0x22, 0x48, 0xdd, 0x5c, 0xe4, 0x6a, 0xff, 0x9c, 0x27, 0x4d, 0xfe, + 0x47, 0xfe, 0x67, 0xb0, 0x9f, 0xc1, 0xc5, 0x8f, 0xd5, 0xb1, 0xa3, 0x93, 0x48, 0xf2, 0x45, 0xc4, + 0xe4, 0xb0, 0xcd, 0xf6, 0xde, 0xbd, 0xdf, 0xe3, 0xdd, 0x5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x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x37, 0x46, 0xa8, 0x48, 0x69, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -120,9 +171,42 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 } } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l return len(dAtA) - i, nil } @@ -143,6 +227,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) if len(m.AddressMappings) > 0 { for _, e := range m.AddressMappings { l = e.Size() @@ -152,6 +238,15 @@ func (m *GenesisState) Size() (n int) { return n } +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -188,6 +283,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AddressMappings", wireType) } @@ -242,6 +370,56 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } +func (m *Params) 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 ErrIntOverflowGenesis + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/addresses/types/v1/genesis_test.go b/x/addresses/types/genesis_test.go similarity index 53% rename from x/addresses/types/v1/genesis_test.go rename to x/addresses/types/genesis_test.go index 530e1228..a4ffcd32 100644 --- a/x/addresses/types/v1/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -1,33 +1,27 @@ -package v1 +package types import ( "testing" - "github.com/peggyjv/sommelier/v7/x/addresses/types" - typesv1 "github.com/peggyjv/sommelier/v7/x/addresses/types/v1" "github.com/stretchr/testify/require" ) func TestGenesisState_Validate(t *testing.T) { for _, tc := range []struct { desc string - genState *typesv1.GenesisState + genState *GenesisState valid bool }{ { desc: "default is valid", - genState: types.DefaultGenesis(), + genState: DefaultGenesis(), valid: true, }, { desc: "valid genesis state", - genState: &typesv1.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, + genState: &GenesisState{}, + valid: true, }, - // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/addresses/types/v1/msgs.go b/x/addresses/types/msgs.go similarity index 86% rename from x/addresses/types/v1/msgs.go rename to x/addresses/types/msgs.go index c796fafa..d1b34ac2 100644 --- a/x/addresses/types/v1/msgs.go +++ b/x/addresses/types/msgs.go @@ -1,11 +1,10 @@ -package v1 +package types import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" - "github.com/peggyjv/sommelier/v7/x/addresses/types" ) var ( @@ -31,7 +30,7 @@ func NewMsgAddAddressMapping(evmAddres common.Address, signer sdk.AccAddress) (* } // Route implements sdk.Msg -func (m *MsgAddAddressMapping) Route() string { return types.ModuleName } +func (m *MsgAddAddressMapping) Route() string { return ModuleName } // Type implements sdk.Msg func (m *MsgAddAddressMapping) Type() string { return TypeMsgAddAddressMapping } @@ -43,7 +42,7 @@ func (m *MsgAddAddressMapping) ValidateBasic() error { } if !common.IsHexAddress(m.EvmAddress) { - return errorsmod.Wrapf(types.ErrInvalidEvmAddress, "%s is not a valid hex address", m.EvmAddress) + return errorsmod.Wrapf(ErrInvalidEvmAddress, "%s is not a valid hex address", m.EvmAddress) } return nil @@ -51,7 +50,7 @@ func (m *MsgAddAddressMapping) ValidateBasic() error { // GetSignBytes implements sdk.Msg func (m *MsgAddAddressMapping) GetSignBytes() []byte { - return sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) } // GetSigners implements sdk.Msg @@ -80,7 +79,7 @@ func NewMsgRemoveAddressMapping(evmAddres common.Address, signer sdk.AccAddress) } // Route implements sdk.Msg -func (m *MsgRemoveAddressMapping) Route() string { return types.ModuleName } +func (m *MsgRemoveAddressMapping) Route() string { return ModuleName } // Type implements sdk.Msg func (m *MsgRemoveAddressMapping) Type() string { return TypeMsgRemoveAddressMapping } @@ -96,7 +95,7 @@ func (m *MsgRemoveAddressMapping) ValidateBasic() error { // GetSignBytes implements sdk.Msg func (m *MsgRemoveAddressMapping) GetSignBytes() []byte { - return sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) } // GetSigners implements sdk.Msg diff --git a/x/addresses/types/params.go b/x/addresses/types/params.go index 357196ad..6b375754 100644 --- a/x/addresses/types/params.go +++ b/x/addresses/types/params.go @@ -2,7 +2,6 @@ package types import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "gopkg.in/yaml.v2" ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -28,12 +27,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } // Validate validates the set of params -func (p Params) Validate() error { +func (p Params) ValidateBasic() error { return nil } - -// String implements the Stringer interface. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} diff --git a/x/addresses/types/v1/query.pb.go b/x/addresses/types/query.pb.go similarity index 77% rename from x/addresses/types/v1/query.pb.go rename to x/addresses/types/query.pb.go index 7ed3ad4e..67744b95 100644 --- a/x/addresses/types/v1/query.pb.go +++ b/x/addresses/types/query.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: addresses/v1/query.proto -package v1 +package types import ( context "context" @@ -30,6 +30,86 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_ebe10bad8a6f145d, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +type QueryParamsResponse struct { + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ebe10bad8a6f145d, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + type QueryAddressMappingsRequest struct { Pagination query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination"` } @@ -38,7 +118,7 @@ func (m *QueryAddressMappingsRequest) Reset() { *m = QueryAddressMapping func (m *QueryAddressMappingsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingsRequest) ProtoMessage() {} func (*QueryAddressMappingsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ebe10bad8a6f145d, []int{0} + return fileDescriptor_ebe10bad8a6f145d, []int{2} } func (m *QueryAddressMappingsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -83,7 +163,7 @@ func (m *QueryAddressMappingsResponse) Reset() { *m = QueryAddressMappin func (m *QueryAddressMappingsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingsResponse) ProtoMessage() {} func (*QueryAddressMappingsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ebe10bad8a6f145d, []int{1} + return fileDescriptor_ebe10bad8a6f145d, []int{3} } func (m *QueryAddressMappingsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -136,7 +216,7 @@ func (m *QueryAddressMappingByEVMAddressRequest) Reset() { func (m *QueryAddressMappingByEVMAddressRequest) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingByEVMAddressRequest) ProtoMessage() {} func (*QueryAddressMappingByEVMAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ebe10bad8a6f145d, []int{2} + return fileDescriptor_ebe10bad8a6f145d, []int{4} } func (m *QueryAddressMappingByEVMAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -183,7 +263,7 @@ func (m *QueryAddressMappingByEVMAddressResponse) Reset() { func (m *QueryAddressMappingByEVMAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryAddressMappingByEVMAddressResponse) ProtoMessage() {} func (*QueryAddressMappingByEVMAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ebe10bad8a6f145d, []int{3} + return fileDescriptor_ebe10bad8a6f145d, []int{5} } func (m *QueryAddressMappingByEVMAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -238,7 +318,7 @@ func (m *QueryAddressMappingByCosmosAddressRequest) String() string { } func (*QueryAddressMappingByCosmosAddressRequest) ProtoMessage() {} func (*QueryAddressMappingByCosmosAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ebe10bad8a6f145d, []int{4} + return fileDescriptor_ebe10bad8a6f145d, []int{6} } func (m *QueryAddressMappingByCosmosAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -287,7 +367,7 @@ func (m *QueryAddressMappingByCosmosAddressResponse) String() string { } func (*QueryAddressMappingByCosmosAddressResponse) ProtoMessage() {} func (*QueryAddressMappingByCosmosAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ebe10bad8a6f145d, []int{5} + return fileDescriptor_ebe10bad8a6f145d, []int{7} } func (m *QueryAddressMappingByCosmosAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -331,6 +411,8 @@ func (m *QueryAddressMappingByCosmosAddressResponse) GetEvmAddress() string { } func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "addresses.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "addresses.v1.QueryParamsResponse") proto.RegisterType((*QueryAddressMappingsRequest)(nil), "addresses.v1.QueryAddressMappingsRequest") proto.RegisterType((*QueryAddressMappingsResponse)(nil), "addresses.v1.QueryAddressMappingsResponse") proto.RegisterType((*QueryAddressMappingByEVMAddressRequest)(nil), "addresses.v1.QueryAddressMappingByEVMAddressRequest") @@ -342,41 +424,45 @@ func init() { func init() { proto.RegisterFile("addresses/v1/query.proto", fileDescriptor_ebe10bad8a6f145d) } var fileDescriptor_ebe10bad8a6f145d = []byte{ - // 533 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6e, 0xd3, 0x30, - 0x18, 0xaf, 0xcb, 0x40, 0xc2, 0xe5, 0x9f, 0xac, 0x1d, 0xaa, 0x50, 0xa5, 0x53, 0x24, 0xb6, 0xae, - 0x07, 0x9b, 0x96, 0xa1, 0x21, 0xc4, 0x01, 0x82, 0x10, 0x20, 0x51, 0x04, 0x39, 0x70, 0xe0, 0x32, - 0xb9, 0x9b, 0x65, 0x02, 0x4b, 0x9c, 0xd6, 0x69, 0x44, 0x35, 0xed, 0xc2, 0x13, 0x20, 0xf1, 0x00, - 0xbc, 0x05, 0xcf, 0xb0, 0xe3, 0x04, 0x17, 0x4e, 0x08, 0x52, 0x1e, 0x04, 0xd5, 0x76, 0xb7, 0x64, - 0x44, 0x24, 0x95, 0xb8, 0x45, 0xf6, 0xef, 0xfb, 0xfd, 0xf9, 0xbe, 0x2f, 0x86, 0x4d, 0xba, 0xb7, - 0x37, 0x66, 0x52, 0x32, 0x49, 0x92, 0x1e, 0x19, 0x4d, 0xd8, 0x78, 0x8a, 0xa3, 0xb1, 0x88, 0x05, - 0xba, 0x74, 0x72, 0x83, 0x93, 0x9e, 0xd5, 0xca, 0xe1, 0x4e, 0xaf, 0x14, 0xd6, 0x5a, 0xe5, 0x82, - 0x0b, 0xf5, 0x49, 0xe6, 0x5f, 0xe6, 0xb4, 0xc5, 0x85, 0xe0, 0xfb, 0x8c, 0xd0, 0xc8, 0x27, 0x34, - 0x0c, 0x45, 0x4c, 0x63, 0x5f, 0x84, 0x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2f, 0xa8, 0x97, 0xf6, 0xd6, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0x59, 0x34, - 0x97, 0x11, 0x06, 0x00, 0x00, + // 600 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x6e, 0xd3, 0x40, + 0x14, 0xc6, 0xe3, 0x42, 0x2b, 0xf1, 0xc2, 0x3f, 0x0d, 0x59, 0x44, 0x26, 0x72, 0x82, 0x25, 0xd2, + 0x34, 0x42, 0x1e, 0x12, 0x40, 0x45, 0x88, 0x05, 0xa4, 0x42, 0x80, 0x20, 0x52, 0xc9, 0x82, 0x05, + 0x9b, 0x6a, 0xd2, 0x8e, 0x06, 0x43, 0xed, 0x71, 0x32, 0x8e, 0x45, 0xa8, 0xba, 0xe1, 0x04, 0x48, + 0x1c, 0x80, 0x5b, 0x70, 0x86, 0x2e, 0x2b, 0xd8, 0xb0, 0xaa, 0x20, 0xe1, 0x20, 0x28, 0xe3, 0x09, + 0xf5, 0xa4, 0x06, 0xbb, 0x12, 0x3b, 0x6b, 0xe6, 0x7b, 0xef, 0xfb, 0x7d, 0xa3, 0xf7, 0x12, 0x28, + 0x93, 0x9d, 0x9d, 0x21, 0x15, 0x82, 0x0a, 0x1c, 0xb5, 0xf0, 0x60, 0x44, 0x87, 0x63, 0x27, 0x18, + 0xf2, 0x90, 0xa3, 0xf3, 0x7f, 0x6e, 0x9c, 0xa8, 0x65, 0x56, 0x34, 0xdd, 0xf1, 0x95, 0xd4, 0x9a, + 0xa6, 0x76, 0xcb, 0xa8, 0x4f, 0x85, 0x3b, 0xbf, 0x2b, 0x31, 0xce, 0xb8, 0xfc, 0xc4, 0xb3, 0x2f, + 0x75, 0x5a, 0x61, 0x9c, 0xb3, 0x5d, 0x8a, 0x49, 0xe0, 0x62, 0xe2, 0xfb, 0x3c, 0x24, 0xa1, 0xcb, + 0xfd, 0x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7, 0x7f, 0x4f, + 0xdf, 0x8a, 0xfd, 0xce, 0xb3, 0x83, 0x89, 0x65, 0x1c, 0x4e, 0x2c, 0xe3, 0xc7, 0xc4, 0x32, 0x3e, + 0x4e, 0xad, 0xc2, 0xe1, 0xd4, 0x2a, 0x7c, 0x9f, 0x5a, 0x85, 0x57, 0x2d, 0xe6, 0x86, 0xaf, 0x47, + 0x7d, 0x67, 0x9b, 0x7b, 0x38, 0xa0, 0x8c, 0x8d, 0xdf, 0x44, 0x09, 0xb7, 0x68, 0x1d, 0xbf, 0x4b, + 0x58, 0x86, 0xe3, 0x80, 0x8a, 0xfe, 0x8a, 0xfc, 0xf7, 0xb8, 0xf5, 0x3b, 0x00, 0x00, 0xff, 0xff, + 0xac, 0x9f, 0x00, 0x3a, 0x01, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -391,6 +477,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) QueryAddressMappings(ctx context.Context, in *QueryAddressMappingsRequest, opts ...grpc.CallOption) (*QueryAddressMappingsResponse, error) QueryAddressMappingByEVMAddress(ctx context.Context, in *QueryAddressMappingByEVMAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByEVMAddressResponse, error) QueryAddressMappingByCosmosAddress(ctx context.Context, in *QueryAddressMappingByCosmosAddressRequest, opts ...grpc.CallOption) (*QueryAddressMappingByCosmosAddressResponse, error) @@ -404,6 +491,15 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/addresses.v1.Query/QueryParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) QueryAddressMappings(ctx context.Context, in *QueryAddressMappingsRequest, opts ...grpc.CallOption) (*QueryAddressMappingsResponse, error) { out := new(QueryAddressMappingsResponse) err := c.cc.Invoke(ctx, "/addresses.v1.Query/QueryAddressMappings", in, out, opts...) @@ -433,6 +529,7 @@ func (c *queryClient) QueryAddressMappingByCosmosAddress(ctx context.Context, in // QueryServer is the server API for Query service. type QueryServer interface { + QueryParams(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) QueryAddressMappings(context.Context, *QueryAddressMappingsRequest) (*QueryAddressMappingsResponse, error) QueryAddressMappingByEVMAddress(context.Context, *QueryAddressMappingByEVMAddressRequest) (*QueryAddressMappingByEVMAddressResponse, error) QueryAddressMappingByCosmosAddress(context.Context, *QueryAddressMappingByCosmosAddressRequest) (*QueryAddressMappingByCosmosAddressResponse, error) @@ -442,6 +539,9 @@ type QueryServer interface { type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) QueryParams(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryParams not implemented") +} func (*UnimplementedQueryServer) QueryAddressMappings(ctx context.Context, req *QueryAddressMappingsRequest) (*QueryAddressMappingsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryAddressMappings not implemented") } @@ -456,6 +556,24 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_QueryParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/addresses.v1.Query/QueryParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryParams(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_QueryAddressMappings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryAddressMappingsRequest) if err := dec(in); err != nil { @@ -514,6 +632,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "addresses.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "QueryParams", + Handler: _Query_QueryParams_Handler, + }, { MethodName: "QueryAddressMappings", Handler: _Query_QueryAddressMappings_Handler, @@ -531,6 +653,64 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "addresses/v1/query.proto", } +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *QueryAddressMappingsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -756,6 +936,28 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryAddressMappingsRequest) Size() (n int) { if m == nil { return 0 @@ -850,6 +1052,142 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryAddressMappingsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/addresses/types/v1/query.pb.gw.go b/x/addresses/types/query.pb.gw.go similarity index 83% rename from x/addresses/types/v1/query.pb.gw.go rename to x/addresses/types/query.pb.gw.go index d7fbefd9..9761538a 100644 --- a/x/addresses/types/v1/query.pb.gw.go +++ b/x/addresses/types/query.pb.gw.go @@ -2,11 +2,11 @@ // source: addresses/v1/query.proto /* -Package v1 is a reverse proxy. +Package types is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package v1 +package types import ( "context" @@ -33,6 +33,24 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +func request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.QueryParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.QueryParams(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_QueryAddressMappings_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -183,6 +201,29 @@ func local_request_Query_QueryAddressMappingByCosmosAddress_0(ctx context.Contex // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryParams_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryAddressMappings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -293,6 +334,26 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryParams_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryAddressMappings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -357,6 +418,8 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( + pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sommelier", "addresses", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAddressMappings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sommelier", "addresses", "v1", "address_mappings"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryAddressMappingByEVMAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sommelier", "addresses", "v1", "address_mappings", "evm", "evm_address"}, "", runtime.AssumeColonVerbOpt(false))) @@ -365,6 +428,8 @@ var ( ) var ( + forward_Query_QueryParams_0 = runtime.ForwardResponseMessage + forward_Query_QueryAddressMappings_0 = runtime.ForwardResponseMessage forward_Query_QueryAddressMappingByEVMAddress_0 = runtime.ForwardResponseMessage diff --git a/x/addresses/types/v1/tx.pb.go b/x/addresses/types/tx.pb.go similarity index 98% rename from x/addresses/types/v1/tx.pb.go rename to x/addresses/types/tx.pb.go index 2bce70a6..0f66c0fc 100644 --- a/x/addresses/types/v1/tx.pb.go +++ b/x/addresses/types/tx.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: addresses/v1/tx.proto -package v1 +package types import ( context "context" @@ -217,13 +217,13 @@ var fileDescriptor_dbc33d4b2b06ba95 = []byte{ 0x44, 0x18, 0xc9, 0x88, 0x62, 0xa4, 0x22, 0x97, 0x3c, 0x0e, 0x2d, 0x30, 0x53, 0x8d, 0x6e, 0x30, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x25, 0x73, 0x09, 0x62, 0xfa, 0x45, 0x49, 0x0f, 0xd9, 0xcb, 0x7a, 0xd8, 0x9c, 0x27, 0xa5, 0x45, 0x58, 0x0d, 0xcc, 0x32, 0xa1, 0x1c, 0x2e, 0x11, 0xac, 0xee, - 0x57, 0xc5, 0x30, 0x03, 0x9b, 0x32, 0x29, 0x5d, 0xa2, 0x94, 0xc1, 0x6c, 0x73, 0xf2, 0x3b, 0xf1, + 0x57, 0xc5, 0x30, 0x03, 0x9b, 0x32, 0x29, 0x5d, 0xa2, 0x94, 0xc1, 0x6c, 0x73, 0xf2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, - 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, + 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0x82, 0xd4, 0xf4, 0xf4, 0xca, 0xac, 0x32, 0xfd, 0xe2, 0xfc, 0xdc, 0xdc, 0xd4, 0x9c, 0xcc, 0xd4, 0x22, 0xfd, 0x32, 0x73, 0xfd, 0x0a, 0x7d, 0x44, 0x12, 0x28, 0xa9, - 0x2c, 0x00, 0x27, 0x84, 0x24, 0x36, 0x70, 0x32, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x27, - 0x72, 0x09, 0x80, 0x1f, 0x02, 0x00, 0x00, + 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xa7, 0x01, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf4, + 0x8e, 0x56, 0x3c, 0x1c, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From d4157596e6285ceb62f8a1126ec699ea613d0a8c Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 12:53:05 -0500 Subject: [PATCH 06/28] Unit tests and refactoring --- app/app.go | 4 +- x/addresses/keeper/genesis.go | 7 +- x/addresses/keeper/genesis_test.go | 29 +++ x/addresses/keeper/keeper_test.go | 322 ++++++++++++++++++++++++ x/addresses/keeper/msg_server.go | 2 +- x/addresses/keeper/msg_server_test.go | 87 +++++++ x/addresses/keeper/query_server.go | 17 +- x/addresses/keeper/query_server_test.go | 92 +++++++ x/addresses/module.go | 10 +- x/addresses/types/expected_keepers.go | 12 - x/addresses/types/genesis.go | 6 +- x/addresses/types/genesis_test.go | 3 +- x/addresses/types/msgs.go | 2 +- x/addresses/types/msgs_test.go | 126 ++++++++++ 14 files changed, 683 insertions(+), 36 deletions(-) create mode 100644 x/addresses/keeper/genesis_test.go create mode 100644 x/addresses/keeper/keeper_test.go create mode 100644 x/addresses/keeper/msg_server_test.go create mode 100644 x/addresses/keeper/query_server_test.go delete mode 100644 x/addresses/types/expected_keepers.go create mode 100644 x/addresses/types/msgs_test.go diff --git a/app/app.go b/app/app.go index c786a124..1a436002 100644 --- a/app/app.go +++ b/app/app.go @@ -592,7 +592,7 @@ func NewSommelierApp( cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.GravityKeeper, app.AuctionKeeper), auction.NewAppModule(app.AuctionKeeper, app.BankKeeper, app.AccountKeeper, appCodec), pubsub.NewAppModule(appCodec, app.PubsubKeeper, app.StakingKeeper, app.GravityKeeper), - addresses.NewAppModule(appCodec, app.AddressesKeeper, app.AccountKeeper), + addresses.NewAppModule(appCodec, app.AddressesKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -731,7 +731,7 @@ func NewSommelierApp( cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.GravityKeeper, app.AuctionKeeper), auction.NewAppModule(app.AuctionKeeper, app.BankKeeper, app.AccountKeeper, appCodec), pubsub.NewAppModule(appCodec, app.PubsubKeeper, app.StakingKeeper, app.GravityKeeper), - addresses.NewAppModule(appCodec, app.AddressesKeeper, app.AccountKeeper), + addresses.NewAppModule(appCodec, app.AddressesKeeper), ) app.sm.RegisterStoreDecoders() diff --git a/x/addresses/keeper/genesis.go b/x/addresses/keeper/genesis.go index cdc769e0..86dfa4c2 100644 --- a/x/addresses/keeper/genesis.go +++ b/x/addresses/keeper/genesis.go @@ -27,7 +27,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) { panic(fmt.Sprintf("invalid EVM address %s", mapping.EvmAddress)) } - evmAddr := common.Hex2Bytes(mapping.EvmAddress) + evmAddr := common.HexToAddress(mapping.EvmAddress).Bytes() k.SetAddressMapping(ctx, cosmosAcc.Bytes(), evmAddr) } @@ -35,12 +35,13 @@ func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) { // ExportGenesis returns the module's exported genesis. func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState { - var mappings []*types.AddressMapping + mappings := []*types.AddressMapping{} k.IterateAddressMappings(ctx, func(cosmosAddr []byte, evmAddr []byte) bool { mappings = append(mappings, &types.AddressMapping{ CosmosAddress: sdk.AccAddress(cosmosAddr).String(), - EvmAddress: common.Bytes2Hex(evmAddr), + EvmAddress: common.BytesToAddress(evmAddr).Hex(), }) + return false }) diff --git a/x/addresses/keeper/genesis_test.go b/x/addresses/keeper/genesis_test.go new file mode 100644 index 00000000..71fdf8f7 --- /dev/null +++ b/x/addresses/keeper/genesis_test.go @@ -0,0 +1,29 @@ +package keeper + +import "github.com/peggyjv/sommelier/v7/x/addresses/types" + +func (suite *KeeperTestSuite) TestImportExportGenesis() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + expectedGenesis := types.DefaultGenesis() + + InitGenesis(ctx, addressesKeeper, expectedGenesis) + + actualGenesis := ExportGenesis(ctx, addressesKeeper) + require.Equal(expectedGenesis, actualGenesis) +} + +func (suite *KeeperTestSuite) TestGenesisValidation() { + require := suite.Require() + + genesis := types.DefaultGenesis() + require.NoError(genesis.Validate()) + + genesis.AddressMappings = append(genesis.AddressMappings, &types.AddressMapping{CosmosAddress: "sldjflslkfjsdf", EvmAddress: "0x0000000000000000000000000000000000000000"}) + require.Error(genesis.Validate()) + + genesis.AddressMappings = types.DefaultGenesis().AddressMappings + genesis.AddressMappings = append(genesis.AddressMappings, &types.AddressMapping{CosmosAddress: "cosmos1l8n6v5f4j5s8j5l8n6v5f4j5s8j5l8n6v5f4j", EvmAddress: "zzzz"}) + require.Error(genesis.Validate()) +} diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go new file mode 100644 index 00000000..5e9d3acf --- /dev/null +++ b/x/addresses/keeper/keeper_test.go @@ -0,0 +1,322 @@ +package keeper + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/testutil" + "github.com/ethereum/go-ethereum/common" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + + moduletestutil "github.com/peggyjv/sommelier/v7/testutil" + addressTypes "github.com/peggyjv/sommelier/v7/x/addresses/types" + + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmtime "github.com/tendermint/tendermint/types/time" +) + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + addressesKeeper Keeper + + queryClient addressTypes.QueryClient + + encCfg moduletestutil.TestEncodingConfig +} + +func (suite *KeeperTestSuite) SetupTest() { + key := sdk.NewKVStoreKey(addressTypes.StoreKey) + tkey := sdk.NewTransientStoreKey("transient_test") + testCtx := testutil.DefaultContext(key, tkey) + ctx := testCtx.WithBlockHeader(tmproto.Header{Height: 5, Time: tmtime.Now()}) + encCfg := moduletestutil.MakeTestEncodingConfig() + + // gomock initializations + ctrl := gomock.NewController(suite.T()) + defer ctrl.Finish() + + suite.ctx = ctx + + params := paramskeeper.NewKeeper( + encCfg.Codec, + codec.NewLegacyAmino(), + key, + tkey, + ) + + params.Subspace(addressTypes.ModuleName) + subSpace, found := params.GetSubspace(addressTypes.ModuleName) + suite.Assertions.True(found) + + suite.addressesKeeper = *NewKeeper( + encCfg.Codec, + key, + subSpace, + ) + + addressTypes.RegisterInterfaces(encCfg.InterfaceRegistry) + + queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry) + addressTypes.RegisterQueryServer(queryHelper, suite.addressesKeeper) + queryClient := addressTypes.NewQueryClient(queryHelper) + + suite.queryClient = queryClient + suite.encCfg = encCfg +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (suite *KeeperTestSuite) TestSetGetDeleteParams() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + params := addressTypes.DefaultParams() + addressesKeeper.setParams(ctx, params) + + retrievedParams := addressesKeeper.GetParamSet(ctx) + require.Equal(params, retrievedParams) +} + +func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + evmAddrString := "0x1111111111111111111111111111111111111111" + require.Equal(42, len(evmAddrString)) + evmAddr := common.HexToAddress(evmAddrString).Bytes() + + cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + acc, err := sdk.AccAddressFromBech32(cosmosAddrString) + require.NoError(err) + + cosmosAddr := acc.Bytes() + + // Set + addressesKeeper.SetAddressMapping(ctx, cosmosAddr, evmAddr) + + // Get + cosmosResult := addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + require.Equal(cosmosAddr, cosmosResult) + + evmResult := addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) + require.Equal(evmAddr, evmResult) + + // Iterate + var mappings []*addressTypes.AddressMapping + addressesKeeper.IterateAddressMappings(ctx, func(cosmosAddr []byte, evmAddr []byte) (stop bool) { + mapping := addressTypes.AddressMapping{ + CosmosAddress: sdk.MustBech32ifyAddressBytes("cosmos", cosmosAddr), + EvmAddress: common.BytesToAddress(evmAddr).Hex(), + } + mappings = append(mappings, &mapping) + + return false + }) + + // Delete + addressesKeeper.DeleteAddressMapping(ctx, cosmosAddr) + + cosmosResult = addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + require.Nil(cosmosResult) + evmResult = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) + require.Nil(evmResult) +} + +//// Unhappy path tests for BeginAuction +//func (suite *KeeperTestSuite) TestUnhappyPathsForBeginAuction() { +// ctx, addressesKeeper := suite.ctx, suite.addressesKeeper +// require := suite.Require() +// +// // Define basic param(s) +// addressesParams := addressTypes.DefaultParams() +// addressesKeeper.setParams(ctx, addressesParams) +// +// // Setup some token prices +// sommPrice := addressTypes.TokenPrice{Denom: params.BaseCoinUnit, Exponent: 6, UsdPrice: sdk.MustNewDecFromStr("0.01"), LastUpdatedBlock: 2} +// +// /* #nosec */ +// saleToken := "gravity0xaaaebe6fe48e54f431b0c390cfaf0b017d09d42d" +// saleTokenPrice := addressTypes.TokenPrice{Denom: saleToken, Exponent: 6, UsdPrice: sdk.MustNewDecFromStr("0.01"), LastUpdatedBlock: 5} +// addressesedSaleTokens := sdk.NewCoin(saleToken, sdk.NewInt(10000)) +// +// tests := []struct { +// name string +// beginAuctionRequest BeginAuctionRequest +// expectedError error +// runsBefore runsBeforeWrapper +// }{ +// { +// name: "Unpermissioned funder module account", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx, +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: "cork", +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrapf(addressTypes.ErrUnauthorizedFundingModule, "Module Account: cork"), +// runsBefore: func() {}, +// }, +// { +// name: "Unpermissioned proceeds module account", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx, +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: "gravity", +// }, +// expectedError: errorsmod.Wrapf(addressTypes.ErrUnauthorizedProceedsModule, "Module Account: gravity"), +// runsBefore: func() {}, +// }, +// { +// name: "Starting denom price not found", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx, +// startingTokensForSale: sdk.NewCoin("anvil", sdk.NewInt(7)), +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrapf(addressTypes.ErrCouldNotFindSaleTokenPrice, "starting amount denom: anvil"), +// runsBefore: func() {}, +// }, +// { +// name: "Starting denom price update too old", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx.WithBlockHeight(int64(saleTokenPrice.LastUpdatedBlock) + int64(addressesParams.PriceMaxBlockAge) + 1), +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrapf(addressTypes.ErrLastSaleTokenPriceTooOld, "starting amount denom: %s", saleToken), +// runsBefore: func() { +// addressesKeeper.setTokenPrice(ctx, saleTokenPrice) +// }, +// }, +// { +// name: "Usomm price not found", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx, +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrap(addressTypes.ErrCouldNotFindSommTokenPrice, params.BaseCoinUnit), +// runsBefore: func() {}, +// }, +// { +// name: "Usomm price update too old", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx.WithBlockHeight(int64(sommPrice.LastUpdatedBlock) + int64(addressesParams.PriceMaxBlockAge) + 1), +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrap(addressTypes.ErrLastSommTokenPriceTooOld, params.BaseCoinUnit), +// runsBefore: func() { +// addressesKeeper.setTokenPrice(ctx, sommPrice) +// }, +// }, +// { +// name: "Validate basic canary 1 -- invalid initialPriceDecreaseRate lower bound", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx, +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.0"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrapf(addressTypes.ErrInvalidInitialDecreaseRate, "Initial price decrease rate 0.000000000000000000"), +// runsBefore: func() {}, +// }, +// { +// name: "Validate basic canary 2 -- invalid initialPriceDecreaseRate upper bound", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx, +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("1.0"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrapf(addressTypes.ErrInvalidInitialDecreaseRate, "Initial price decrease rate 1.000000000000000000"), +// runsBefore: func() {}, +// }, +// { +// name: "Cannot have 2 ongoing addressess for the same denom", +// beginAuctionRequest: BeginAuctionRequest{ +// ctx: ctx, +// startingTokensForSale: addressesedSaleTokens, +// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), +// priceDecreaseBlockInterval: uint64(10), +// fundingModuleAccount: permissionedFunder.GetName(), +// proceedsModuleAccount: permissionedReciever.GetName(), +// }, +// expectedError: errorsmod.Wrapf(addressTypes.ErrCannotStartTwoAuctionsForSameDenomSimultaneously, "Denom: %s", addressesedSaleTokens.Denom), +// runsBefore: func() { +// // Mock initial bank keeper fund transfer +// suite.mockSendCoinsFromModuleToModule(ctx, permissionedFunder.GetName(), addressTypes.ModuleName, sdk.NewCoins(addressesedSaleTokens)) +// +// // Start addresses +// decreaseRate := sdk.MustNewDecFromStr("0.05") +// blockDecreaseInterval := uint64(5) +// err := addressesKeeper.BeginAuction(ctx, addressesedSaleTokens, decreaseRate, blockDecreaseInterval, permissionedFunder.GetName(), permissionedReciever.GetName()) +// require.Nil(err) +// +// // Verify addresses got added to active addresses store +// addressesID := uint32(1) +// createdAuction, found := addressesKeeper.GetActiveAuctionByID(ctx, addressesID) +// require.True(found) +// }, +// }, +// } +// +// for _, tc := range tests { +// tc := tc // Redefine variable here due to passing it to function literal below (scopelint) +// suite.T().Run(fmt.Sprint(tc.name), func(t *testing.T) { +// // Run expected bank keeper functions, if any +// tc.runsBefore() +// +// call := func() error { +// return addressesKeeper.BeginAuction( +// tc.beginAuctionRequest.ctx, +// tc.beginAuctionRequest.startingTokensForSale, +// tc.beginAuctionRequest.initialPriceDecreaseRate, +// tc.beginAuctionRequest.priceDecreaseBlockInterval, +// tc.beginAuctionRequest.fundingModuleAccount, +// tc.beginAuctionRequest.proceedsModuleAccount, +// ) +// } +// +// if tc.name[0:14] == "Validate basic" { +// require.Panics(func() { call() }) +// return +// } +// +// err := call() +// +// // Verify errors are as expected +// require.Equal(tc.expectedError.Error(), err.Error()) +// }) +// } +//} diff --git a/x/addresses/keeper/msg_server.go b/x/addresses/keeper/msg_server.go index 5b81641f..d9610165 100644 --- a/x/addresses/keeper/msg_server.go +++ b/x/addresses/keeper/msg_server.go @@ -24,7 +24,7 @@ func (k Keeper) AddAddressMapping(c context.Context, req *types.MsgAddAddressMap return &types.MsgAddAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", req.EvmAddress) } - evmAddr := common.Hex2Bytes(req.EvmAddress) + evmAddr := common.HexToAddress(req.EvmAddress).Bytes() k.SetAddressMapping(ctx, signer.Bytes(), evmAddr) diff --git a/x/addresses/keeper/msg_server_test.go b/x/addresses/keeper/msg_server_test.go new file mode 100644 index 00000000..162327de --- /dev/null +++ b/x/addresses/keeper/msg_server_test.go @@ -0,0 +1,87 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +func (suite *KeeperTestSuite) TestHappyPathsForMsgServer() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + // Test AddAddressMapping + evmAddrString := "0x1111111111111111111111111111111111111111" + require.Equal(42, len(evmAddrString)) + cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + _, err := sdk.AccAddressFromBech32(cosmosAddrString) + require.NoError(err) + + _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: evmAddrString}) + require.NoError(err) + + evmAddr := common.HexToAddress(evmAddrString).Bytes() + + result := addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + require.NotNil(result) + actualCosmosAddrString := sdk.AccAddress(result).String() + require.Equal(cosmosAddrString, actualCosmosAddrString) + + result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, sdk.AccAddress(result).Bytes()) + require.NotNil(result) + + actualEvmAddrString := common.BytesToAddress(result).Hex() + require.Equal(evmAddrString, actualEvmAddrString) + + // Test RemoveAddressMapping + _, err = addressesKeeper.RemoveAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgRemoveAddressMapping{Signer: cosmosAddrString}) + require.NoError(err) + + result = addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + require.Nil(result) + + result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, sdk.AccAddress(result).Bytes()) + require.Nil(result) +} + +func (suite *KeeperTestSuite) TestUnhappyPathsForMsgServer() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + // Test AddAddressMapping + // too long evm address + evmAddrString := "0x11111111111111111111111111111111111111111" + /// invalid checksum cosmos address + cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" + _, err := sdk.AccAddressFromBech32(cosmosAddrString) + require.Error(err) + + _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: evmAddrString}) + require.Error(err) + require.Contains(err.Error(), "invalid signer address") + + cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + _, err = sdk.AccAddressFromBech32(cosmosAddrString) + require.NoError(err) + evmAddr := common.HexToAddress(evmAddrString).Bytes() + + _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: evmAddrString}) + require.Error(err) + require.Contains(err.Error(), "invalid EVM address") + + result := addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + require.Nil(result) + + result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, sdk.AccAddress(result).Bytes()) + require.Nil(result) + + // Test RemoveAddressMapping + // invalid checksum + cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" + _, err = sdk.AccAddressFromBech32(cosmosAddrString) + require.Error(err) + + _, err = addressesKeeper.RemoveAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgRemoveAddressMapping{Signer: cosmosAddrString}) + require.Error(err) + require.Contains(err.Error(), "invalid signer address") +} diff --git a/x/addresses/keeper/query_server.go b/x/addresses/keeper/query_server.go index e64ebb54..8425625d 100644 --- a/x/addresses/keeper/query_server.go +++ b/x/addresses/keeper/query_server.go @@ -37,7 +37,11 @@ func (k Keeper) QueryAddressMappings(c context.Context, request *types.QueryAddr prefixStore, &request.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - cosmosAddr := sdk.MustBech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), key) + cosmosAddr, err := sdk.Bech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), key) + if err != nil { + return false, err + } + evmAddr := common.BytesToAddress(value).Hex() mapping := types.AddressMapping{ CosmosAddress: cosmosAddr, @@ -52,7 +56,9 @@ func (k Keeper) QueryAddressMappings(c context.Context, request *types.QueryAddr ) if err != nil { - return nil, status.Error(codes.Internal, err.Error()) + // this shouldn't be possible if the msg server is doing proper validation + k.Logger(ctx).Error("failed to paginate cosmos to evm address mappings", "error", err) + return nil, status.Error(codes.Internal, "error during pagination") } return &types.QueryAddressMappingsResponse{AddressMappings: mappings, Pagination: *pageRes}, nil @@ -68,8 +74,8 @@ func (k Keeper) QueryAddressMappingByCosmosAddress(c context.Context, request *t rawEvmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) - if rawEvmAddr == nil { - return &types.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.NotFound, "no EVM address mappings for cosmos address %s", request.GetCosmosAddress()) + if rawEvmAddr == nil || len(rawEvmAddr) == 0 { + return &types.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.NotFound, "no EVM address mapping for cosmos address %s", request.GetCosmosAddress()) } evmAddr := common.BytesToAddress(rawEvmAddr) @@ -87,7 +93,7 @@ func (k Keeper) QueryAddressMappingByEVMAddress(c context.Context, request *type return &types.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.InvalidArgument, "invalid EVM address %s", request.GetEvmAddress()) } - evmAddr := common.Hex2Bytes(request.GetEvmAddress()) + evmAddr := common.HexToAddress(request.GetEvmAddress()).Bytes() rawCosmosAddr := k.GetCosmosAddressByEvmAddress(ctx, evmAddr) if rawCosmosAddr == nil { @@ -97,6 +103,7 @@ func (k Keeper) QueryAddressMappingByEVMAddress(c context.Context, request *type prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() cosmosAddr, err := sdk.Bech32ifyAddressBytes(prefix, rawCosmosAddr) if err != nil { + // this shouldn't happen if msg server is doing proper validation return &types.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.Internal, "failed to convert cosmos address to bech32: %s", err) } diff --git a/x/addresses/keeper/query_server_test.go b/x/addresses/keeper/query_server_test.go new file mode 100644 index 00000000..efe9b849 --- /dev/null +++ b/x/addresses/keeper/query_server_test.go @@ -0,0 +1,92 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +// Happy path test for query server functions +func (suite *KeeperTestSuite) TestHappyPathsForQueryServer() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + params := types.DefaultParams() + addressesKeeper.setParams(ctx, params) + + evmAddrString := "0x1111111111111111111111111111111111111111" + require.Equal(42, len(evmAddrString)) + evmAddr := common.HexToAddress(evmAddrString).Bytes() + cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + acc, err := sdk.AccAddressFromBech32(cosmosAddrString) + require.NoError(err) + + cosmosAddr := acc.Bytes() + + addressesKeeper.SetAddressMapping(ctx, cosmosAddr, evmAddr) + + // Test QueryParams + queryParams, err := addressesKeeper.QueryParams(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{}) + require.NoError(err) + require.Equal(¶ms, queryParams.Params) + + // Test QueryAddressMappingByEvmAddress + addressMappingByEvmAddress, err := addressesKeeper.QueryAddressMappingByEVMAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddrString}) + require.NoError(err) + require.Equal(cosmosAddrString, addressMappingByEvmAddress.CosmosAddress) + + // Test QueryAddressMappingByCosmosAddress + addressMappingByCosmosAddress, err := addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddrString}) + require.NoError(err) + require.Equal(evmAddrString, addressMappingByCosmosAddress.EvmAddress) + + // Test QueryAddressMappings + addressMappings, err := addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 1) + require.Equal(cosmosAddrString, addressMappings.AddressMappings[0].CosmosAddress) + require.Equal(evmAddrString, addressMappings.AddressMappings[0].EvmAddress) +} + +// Unhappy path test for query server functions +func (suite *KeeperTestSuite) TestUnhappyPathsForQueryServer() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + params := types.DefaultParams() + addressesKeeper.setParams(ctx, params) + + // invalid length evm address + evmAddrString := "0x11111111111111111111111111111111111111111" + // invalid checksum cosmos address + cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" + _, err := sdk.AccAddressFromBech32(cosmosAddrString) + require.Error(err) + + // Test QueryParams + queryParams, err := addressesKeeper.QueryParams(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{}) + require.NoError(err) + require.Equal(¶ms, queryParams.Params) + + // Test QueryAddressMappingByEvmAddress + _, err = addressesKeeper.QueryAddressMappingByEVMAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddrString}) + require.Error(err) + require.Contains(err.Error(), "invalid EVM address") + + // valid evm address + evmAddrString = "0x1111111111111111111111111111111111111111" + _, err = addressesKeeper.QueryAddressMappingByEVMAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddrString}) + require.Error(err) + require.Contains(err.Error(), "no cosmos address mapping for EVM address") + + // Test QueryAddressMappingByCosmosAddress + _, err = addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddrString}) + require.Error(err) + require.Contains(err.Error(), "failed to parse cosmos address") + + // valid cosmos address + cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + _, err = addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddrString}) + require.Error(err) + require.Contains(err.Error(), "no EVM address mapping for cosmos address") +} diff --git a/x/addresses/module.go b/x/addresses/module.go index 3b039cfa..fd6fc8b4 100644 --- a/x/addresses/module.go +++ b/x/addresses/module.go @@ -6,8 +6,6 @@ import ( "fmt" "math/rand" - // this line is used by starport scaffolding # 1 - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -59,7 +57,8 @@ func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { // DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) + gs := types.DefaultGenesis() + return cdc.MustMarshalJSON(&gs) } // ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form @@ -94,19 +93,16 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper keeper.Keeper - accountKeeper types.AccountKeeper + keeper keeper.Keeper } func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, - accountKeeper types.AccountKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, - accountKeeper: accountKeeper, } } diff --git a/x/addresses/types/expected_keepers.go b/x/addresses/types/expected_keepers.go deleted file mode 100644 index 20eea16d..00000000 --- a/x/addresses/types/expected_keepers.go +++ /dev/null @@ -1,12 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" -) - -// AccountKeeper defines the expected account keeper used for simulations (noalias) -type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI - // Methods imported from account should be defined here -} diff --git a/x/addresses/types/genesis.go b/x/addresses/types/genesis.go index 30a4438b..5417197f 100644 --- a/x/addresses/types/genesis.go +++ b/x/addresses/types/genesis.go @@ -1,13 +1,11 @@ package types -// this line is used by starport scaffolding # genesis/types/import - // DefaultIndex is the default global index const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state -func DefaultGenesis() *GenesisState { - return &GenesisState{ +func DefaultGenesis() GenesisState { + return GenesisState{ Params: DefaultParams(), AddressMappings: []*AddressMapping{}, } diff --git a/x/addresses/types/genesis_test.go b/x/addresses/types/genesis_test.go index a4ffcd32..7e07ace3 100644 --- a/x/addresses/types/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -7,6 +7,7 @@ import ( ) func TestGenesisState_Validate(t *testing.T) { + def := DefaultGenesis() for _, tc := range []struct { desc string genState *GenesisState @@ -14,7 +15,7 @@ func TestGenesisState_Validate(t *testing.T) { }{ { desc: "default is valid", - genState: DefaultGenesis(), + genState: &def, valid: true, }, { diff --git a/x/addresses/types/msgs.go b/x/addresses/types/msgs.go index d1b34ac2..78f796f0 100644 --- a/x/addresses/types/msgs.go +++ b/x/addresses/types/msgs.go @@ -72,7 +72,7 @@ func (m *MsgAddAddressMapping) MustGetSigner() sdk.AccAddress { ///////////////////////////// // NewMsgRemoveAddressMapping return a new MsgRemoveAddressMapping -func NewMsgRemoveAddressMapping(evmAddres common.Address, signer sdk.AccAddress) (*MsgRemoveAddressMapping, error) { +func NewMsgRemoveAddressMapping(signer sdk.AccAddress) (*MsgRemoveAddressMapping, error) { return &MsgRemoveAddressMapping{ Signer: signer.String(), }, nil diff --git a/x/addresses/types/msgs_test.go b/x/addresses/types/msgs_test.go new file mode 100644 index 00000000..3d3da94a --- /dev/null +++ b/x/addresses/types/msgs_test.go @@ -0,0 +1,126 @@ +package types + +import ( + "testing" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" +) + +const ( + evmAddress1 = "0x1111111111111111111111111111111111111111" + cosmosAddress1 = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" +) + +func TestNewMsgAddAddressMappingFormatting(t *testing.T) { + expectedMsg := &MsgAddAddressMapping{ + EvmAddress: evmAddress1, + Signer: cosmosAddress1, + } + + cosmosAccount1, err := sdk.AccAddressFromBech32(cosmosAddress1) + require.NoError(t, err) + createdMsg, err := NewMsgAddAddressMapping(common.HexToAddress(evmAddress1), cosmosAccount1) + require.Nil(t, err) + require.Equal(t, expectedMsg, createdMsg) +} + +func TestMsgAddAddressMappingValidate(t *testing.T) { + testCases := []struct { + name string + msgAddAddressMapping MsgAddAddressMapping + expPass bool + err error + }{ + { + name: "Happy path", + msgAddAddressMapping: MsgAddAddressMapping{ + EvmAddress: evmAddress1, + Signer: cosmosAddress1, + }, + expPass: true, + err: nil, + }, + { + name: "Invalid signer address", + msgAddAddressMapping: MsgAddAddressMapping{ + EvmAddress: evmAddress1, + Signer: "sladjflaksjfd", + }, + expPass: false, + err: errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "decoding bech32 failed: invalid separator index -1"), + }, + { + name: "Invalid EVM address", + msgAddAddressMapping: MsgAddAddressMapping{ + EvmAddress: "lasjfdlsdf", + Signer: cosmosAddress1, + }, + expPass: false, + err: errorsmod.Wrap(ErrInvalidEvmAddress, "lasjfdlsdf is not a valid hex address"), + }, + } + + for _, tc := range testCases { + err := tc.msgAddAddressMapping.ValidateBasic() + if tc.expPass { + require.NoError(t, err, tc.name) + require.Nil(t, err) + } else { + require.Error(t, err, tc.name) + require.Equal(t, tc.err.Error(), err.Error()) + } + } +} + +func TestNewMsgRemoveAddressMappingFormatting(t *testing.T) { + expectedMsg := &MsgRemoveAddressMapping{ + Signer: cosmosAddress1, + } + + cosmosAccount1, err := sdk.AccAddressFromBech32(cosmosAddress1) + require.NoError(t, err) + createdMsg, err := NewMsgRemoveAddressMapping(cosmosAccount1) + require.Nil(t, err) + require.Equal(t, expectedMsg, createdMsg) +} + +func TestMsgRemoveAddressMappingValidate(t *testing.T) { + testCases := []struct { + name string + msgRemoveAddressMapping MsgRemoveAddressMapping + expPass bool + err error + }{ + { + name: "Happy path", + msgRemoveAddressMapping: MsgRemoveAddressMapping{ + Signer: cosmosAddress1, + }, + expPass: true, + err: nil, + }, + { + name: "Invalid signer address", + msgRemoveAddressMapping: MsgRemoveAddressMapping{ + Signer: "sladjflaksjfd", + }, + expPass: false, + err: errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "decoding bech32 failed: invalid separator index -1"), + }, + } + + for _, tc := range testCases { + err := tc.msgRemoveAddressMapping.ValidateBasic() + if tc.expPass { + require.NoError(t, err, tc.name) + require.Nil(t, err) + } else { + require.Error(t, err, tc.name) + require.Equal(t, tc.err.Error(), err.Error()) + } + } +} From c62622e91632a693a76c37cfa1c185b63f76c8b4 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 12:53:31 -0500 Subject: [PATCH 07/28] CLI queries and tests --- x/addresses/client/cli/query.go | 81 ++++++++++++++++++- x/addresses/client/cli/query_test.go | 116 +++++++++++++++++++++++++++ 2 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 x/addresses/client/cli/query_test.go diff --git a/x/addresses/client/cli/query.go b/x/addresses/client/cli/query.go index 2c5edee1..d2992d3f 100644 --- a/x/addresses/client/cli/query.go +++ b/x/addresses/client/cli/query.go @@ -3,12 +3,14 @@ package cli import ( "context" "fmt" + // "strings" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + // "github.com/cosmos/cosmos-sdk/client/flags" // sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,7 +29,9 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) - // this line is used by starport scaffolding # 1 + cmd.AddCommand(CmdQueryAddressMappings()) + cmd.AddCommand(CmdQueryAddressMappingByCosmosAddress()) + cmd.AddCommand(CmdQueryAddressMappingByEVMAddress()) return cmd } @@ -55,3 +59,78 @@ func CmdQueryParams() *cobra.Command { return cmd } + +func CmdQueryAddressMappings() *cobra.Command { + cmd := &cobra.Command{ + Use: "address-mappings", + Aliases: []string{"am"}, + Short: "shows the address mappings", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryAddressMappingByCosmosAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "address-mapping-by-cosmos-address [cosmos-address]", + Aliases: []string{"ambca"}, + Short: "shows evm address that maps to the provided cosmos address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryAddressMappingByCosmosAddress(context.Background(), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryAddressMappingByEVMAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "address-mapping-by-evm-address [evm-address]", + Aliases: []string{"ambea"}, + Short: "shows cosmos address that maps to the provided evm address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryAddressMappingByEVMAddress(context.Background(), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/addresses/client/cli/query_test.go b/x/addresses/client/cli/query_test.go new file mode 100644 index 00000000..ef4a39e5 --- /dev/null +++ b/x/addresses/client/cli/query_test.go @@ -0,0 +1,116 @@ +package cli + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestQueryParamsCmd(t *testing.T) { + testCases := []struct { + name string + args []string + err error + }{ + { + name: "Does not accept args", + args: []string{ + "1", + }, + err: fmt.Errorf("unknown command \"1\" for \"params\""), + }, + } + + for _, tc := range testCases { + cmd := *CmdQueryParams() + cmd.SetArgs(tc.args) + err := cmd.Execute() + + require.Equal(t, tc.err.Error(), err.Error()) + } +} + +func TestQueryAddressMappings(t *testing.T) { + testCases := []struct { + name string + args []string + err error + }{ + { + name: "Does not accept args", + args: []string{ + "1", + }, + err: fmt.Errorf("unknown command \"1\" for \"address-mappings\""), + }, + } + + for _, tc := range testCases { + cmd := *CmdQueryAddressMappings() + cmd.SetArgs(tc.args) + err := cmd.Execute() + + require.Equal(t, tc.err.Error(), err.Error()) + } +} + +func TestQueryAddressMappingByCosmosAddress(t *testing.T) { + testCases := []struct { + name string + args []string + err error + }{ + { + name: "Insufficient args", + args: []string{}, + err: fmt.Errorf("accepts 1 arg(s), received 0"), + }, + { + name: "Too many args", + args: []string{ + "1", + "2", + }, + err: fmt.Errorf("accepts 1 arg(s), received 2"), + }, + } + + for _, tc := range testCases { + cmd := *CmdQueryAddressMappingByCosmosAddress() + cmd.SetArgs(tc.args) + err := cmd.Execute() + + require.Equal(t, tc.err.Error(), err.Error()) + } +} + +func TestAddressMappingByEVMAddressCmd(t *testing.T) { + testCases := []struct { + name string + args []string + err error + }{ + { + name: "Insufficient args", + args: []string{}, + err: fmt.Errorf("accepts 1 arg(s), received 0"), + }, + { + name: "Too many args", + args: []string{ + "1", + "2", + }, + err: fmt.Errorf("accepts 1 arg(s), received 2"), + }, + } + + for _, tc := range testCases { + cmd := *CmdQueryAddressMappingByEVMAddress() + cmd.SetArgs(tc.args) + err := cmd.Execute() + + require.Equal(t, tc.err.Error(), err.Error()) + } +} From 3ed4f5880eaf84544fcd9ae22da4d11eec769ab7 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 13:20:48 -0500 Subject: [PATCH 08/28] tx CLI commands and unit tests --- x/addresses/client/cli/tx.go | 87 ++++++++++++++++++++++++++++++- x/addresses/client/cli/tx_test.go | 60 +++++++++++++++++++++ 2 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 x/addresses/client/cli/tx_test.go diff --git a/x/addresses/client/cli/tx.go b/x/addresses/client/cli/tx.go index be5a5687..768ae4b9 100644 --- a/x/addresses/client/cli/tx.go +++ b/x/addresses/client/cli/tx.go @@ -2,11 +2,17 @@ package cli import ( "fmt" + "strings" "time" + "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" + // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/peggyjv/sommelier/v7/x/addresses/types" ) @@ -30,7 +36,86 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - // this line is used by starport scaffolding # 1 + cmd.AddCommand([]*cobra.Command{ + GetCmdAddAddressMapping(), + GetCmdRemoveAddressMapping(), + }...) + + return cmd +} + +// GetCmdAddAddressMapping implements the command to submit a token price set proposal +func GetCmdAddAddressMapping() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-address-mapping [evm-address]", + Args: cobra.ExactArgs(1), + Short: "Add a mapping from your signer address to an EVM address", + Long: strings.TrimSpace( + fmt.Sprintf(`Add a mapping from your Cosmos (signer) address to an EVM address. + +Example: +$ %s tx addresses add-address-mapping 0x1111111111111111111111111111111111111111 --from= +`, + version.AppName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + if !common.IsHexAddress(args[0]) { + return fmt.Errorf("%s is not a valid EVM address", args[0]) + } + + evmAddress := common.HexToAddress(args[0]) + + from := clientCtx.GetFromAddress() + msg, err := types.NewMsgAddAddressMapping(evmAddress, from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// GetCmdRemoveAddressMapping implements the command to submit a token price set proposal +func GetCmdRemoveAddressMapping() *cobra.Command { + cmd := &cobra.Command{ + Use: "remove-address-mapping", + Args: cobra.NoArgs, + Short: "Remove the mapping from your signer address to an EVM address", + Long: strings.TrimSpace( + fmt.Sprintf(`Remove the mapping from your Cosmos (signer) address to an EVM address. + +Example: +$ %s tx addresses remove-address-mapping --from= +`, + version.AppName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + from := clientCtx.GetFromAddress() + msg, err := types.NewMsgRemoveAddressMapping(from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) return cmd } diff --git a/x/addresses/client/cli/tx_test.go b/x/addresses/client/cli/tx_test.go new file mode 100644 index 00000000..391360dc --- /dev/null +++ b/x/addresses/client/cli/tx_test.go @@ -0,0 +1,60 @@ +package cli + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAddAddressMapping(t *testing.T) { + testCases := []struct { + name string + args []string + err error + }{ + { + name: "Valid cmd", + args: []string{ + "0xdac17f958d2ee523a2206206994597c13d831ec7", + fmt.Sprintf("--%s=%s", "from", "cosmos16zrkzad482haunrn25ywvwy6fclh3vh7r0hcny"), + }, + err: fmt.Errorf("key with address cosmos16zrkzad482haunrn25ywvwy6fclh3vh7r0hcny not found: key not found"), // Expect key not found error since this is just a mock request + }, + { + name: "Insufficient args", + args: []string{}, + err: fmt.Errorf("accepts 1 arg(s), received 0"), + }, + { + name: "Too many args", + args: []string{ + "1", + "2", + }, + err: fmt.Errorf("accepts 1 arg(s), received 2"), + }, + { + name: "Missing 'from' field", + args: []string{ + "0xdac17f958d2ee523a2206206994597c13d831ec7", + }, + err: fmt.Errorf("empty address string is not allowed: invalid address"), + }, + { + name: "Invalid EVM address", + args: []string{ + "sdlkfjlskdjfsld", + }, + err: fmt.Errorf("sdlkfjlskdjfsld is not a valid EVM address"), + }, + } + + for _, tc := range testCases { + cmd := GetCmdAddAddressMapping() + cmd.SetArgs(tc.args) + err := cmd.Execute() + + require.Equal(t, tc.err.Error(), err.Error()) + } +} From 1dbb93cc32422a46e3938282caa0366b5fc8f1ee Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 13:56:10 -0500 Subject: [PATCH 09/28] Add addresses gen state to setup_test --- integration_tests/addresses_test.go | 0 integration_tests/setup_test.go | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 integration_tests/addresses_test.go diff --git a/integration_tests/addresses_test.go b/integration_tests/addresses_test.go new file mode 100644 index 00000000..e69de29b diff --git a/integration_tests/setup_test.go b/integration_tests/setup_test.go index 47dac1a0..b821d83b 100644 --- a/integration_tests/setup_test.go +++ b/integration_tests/setup_test.go @@ -19,6 +19,7 @@ import ( govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types" "github.com/peggyjv/sommelier/v7/app/params" + addressestypes "github.com/peggyjv/sommelier/v7/x/addresses/types" auctiontypes "github.com/peggyjv/sommelier/v7/x/auction/types" axelarcorktypes "github.com/peggyjv/sommelier/v7/x/axelarcork/types" cellarfeestypes "github.com/peggyjv/sommelier/v7/x/cellarfees/types" @@ -490,6 +491,11 @@ func (s *IntegrationTestSuite) initGenesis() { s.Require().NoError(err) appGenState[pubsubtypes.ModuleName] = bz + // set addresses gen state + addressesGenState := addressestypes.DefaultGenesis() + s.Require().NoError(cdc.UnmarshalJSON(appGenState[addressestypes.ModuleName], &addressesGenState)) + appGenState[addressestypes.ModuleName] = cdc.MustMarshalJSON(&addressesGenState) + // generate genesis txs genTxs := make([]json.RawMessage, len(s.chain.validators)) for i, val := range s.chain.validators { From abe2f3724064fce866a26f623f14c53e80566fad Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 14:23:28 -0500 Subject: [PATCH 10/28] Rename default genesis state method --- integration_tests/setup_test.go | 8 ++++---- x/addresses/keeper/genesis_test.go | 6 +++--- x/addresses/module.go | 2 +- x/addresses/types/genesis.go | 2 +- x/addresses/types/genesis_test.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/integration_tests/setup_test.go b/integration_tests/setup_test.go index b821d83b..0da4cc5c 100644 --- a/integration_tests/setup_test.go +++ b/integration_tests/setup_test.go @@ -491,10 +491,10 @@ func (s *IntegrationTestSuite) initGenesis() { s.Require().NoError(err) appGenState[pubsubtypes.ModuleName] = bz - // set addresses gen state - addressesGenState := addressestypes.DefaultGenesis() - s.Require().NoError(cdc.UnmarshalJSON(appGenState[addressestypes.ModuleName], &addressesGenState)) - appGenState[addressestypes.ModuleName] = cdc.MustMarshalJSON(&addressesGenState) + // set addresses gen state + addressesGenState := addressestypes.DefaultGenesisState() + s.Require().NoError(cdc.UnmarshalJSON(appGenState[addressestypes.ModuleName], &addressesGenState)) + appGenState[addressestypes.ModuleName] = cdc.MustMarshalJSON(&addressesGenState) // generate genesis txs genTxs := make([]json.RawMessage, len(s.chain.validators)) diff --git a/x/addresses/keeper/genesis_test.go b/x/addresses/keeper/genesis_test.go index 71fdf8f7..b0614249 100644 --- a/x/addresses/keeper/genesis_test.go +++ b/x/addresses/keeper/genesis_test.go @@ -6,7 +6,7 @@ func (suite *KeeperTestSuite) TestImportExportGenesis() { ctx, addressesKeeper := suite.ctx, suite.addressesKeeper require := suite.Require() - expectedGenesis := types.DefaultGenesis() + expectedGenesis := types.DefaultGenesisState() InitGenesis(ctx, addressesKeeper, expectedGenesis) @@ -17,13 +17,13 @@ func (suite *KeeperTestSuite) TestImportExportGenesis() { func (suite *KeeperTestSuite) TestGenesisValidation() { require := suite.Require() - genesis := types.DefaultGenesis() + genesis := types.DefaultGenesisState() require.NoError(genesis.Validate()) genesis.AddressMappings = append(genesis.AddressMappings, &types.AddressMapping{CosmosAddress: "sldjflslkfjsdf", EvmAddress: "0x0000000000000000000000000000000000000000"}) require.Error(genesis.Validate()) - genesis.AddressMappings = types.DefaultGenesis().AddressMappings + genesis.AddressMappings = types.DefaultGenesisState().AddressMappings genesis.AddressMappings = append(genesis.AddressMappings, &types.AddressMapping{CosmosAddress: "cosmos1l8n6v5f4j5s8j5l8n6v5f4j5s8j5l8n6v5f4j", EvmAddress: "zzzz"}) require.Error(genesis.Validate()) } diff --git a/x/addresses/module.go b/x/addresses/module.go index fd6fc8b4..a78b35c2 100644 --- a/x/addresses/module.go +++ b/x/addresses/module.go @@ -57,7 +57,7 @@ func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { // DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - gs := types.DefaultGenesis() + gs := types.DefaultGenesisState() return cdc.MustMarshalJSON(&gs) } diff --git a/x/addresses/types/genesis.go b/x/addresses/types/genesis.go index 5417197f..cd40dc80 100644 --- a/x/addresses/types/genesis.go +++ b/x/addresses/types/genesis.go @@ -4,7 +4,7 @@ package types const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state -func DefaultGenesis() GenesisState { +func DefaultGenesisState() GenesisState { return GenesisState{ Params: DefaultParams(), AddressMappings: []*AddressMapping{}, diff --git a/x/addresses/types/genesis_test.go b/x/addresses/types/genesis_test.go index 7e07ace3..2205156d 100644 --- a/x/addresses/types/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -7,7 +7,7 @@ import ( ) func TestGenesisState_Validate(t *testing.T) { - def := DefaultGenesis() + def := DefaultGenesisState() for _, tc := range []struct { desc string genState *GenesisState From 87e5901a9d6b24c1931e6d4784dde18584b7dc3e Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 14:48:01 -0500 Subject: [PATCH 11/28] Addresses integration test --- .github/workflows/integration-tests.yml | 1 + Makefile | 3 ++ integration_tests/addresses_test.go | 62 +++++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 2a2f44d6..fca4900a 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -126,6 +126,7 @@ jobs: "CellarFees", "Incentives", "Pubsub", + "Addresses", ] steps: - name: Set up Go 1.19 diff --git a/Makefile b/Makefile index 45eb7906..a2af3a59 100644 --- a/Makefile +++ b/Makefile @@ -385,6 +385,9 @@ e2e_incentives_test: e2e_clean_slate e2e_pubsub_test: e2e_clean_slate @E2E_SKIP_CLEANUP=true integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m TestPubsub || make -s fail +e2e_addresses_test: e2e_clean_slate + @E2E_SKIP_CLEANUP=true integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m TestAddresses || make -s fail + fail: @echo 'test failed; dumping container logs into ./testlogs for review' @docker logs ethereum > testlogs/ethereum.log 2>&1 || true diff --git a/integration_tests/addresses_test.go b/integration_tests/addresses_test.go index e69de29b..9961fcab 100644 --- a/integration_tests/addresses_test.go +++ b/integration_tests/addresses_test.go @@ -0,0 +1,62 @@ +package integration_tests + +import ( + "context" + + "github.com/ethereum/go-ethereum/common" + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) + +func (s *IntegrationTestSuite) TestAddresses() { + s.Run("Bring up chain, submit, query, and remove address mappings", func() { + s.T().Log("Starting x/addresses tests") + val := s.chain.validators[0] + kb, err := val.keyring() + s.Require().NoError(err) + val0ClientCtx, err := s.chain.clientContext("tcp://localhost:26657", &kb, "val", val.address()) + s.Require().NoError(err) + addressesQueryClient := types.NewQueryClient(val0ClientCtx) + + orch := s.chain.orchestrators[0] + orchClientCtx, err := s.chain.clientContext("tcp://localhost:26657", orch.keyring, "orch", orch.address()) + s.Require().NoError(err) + + evmAddress := common.HexToAddress("0x1234567890123456789012345678901234567890") + cosmosAddress := orch.address() + + addAddressMappingMsg, err := types.NewMsgAddAddressMapping(evmAddress, cosmosAddress) + s.Require().NoError(err) + + s.T().Logf("Submitting mapping from %s to %s", evmAddress.Hex(), cosmosAddress.String()) + _, err = s.chain.sendMsgs(*orchClientCtx, addAddressMappingMsg) + s.Require().NoError(err) + + s.T().Log("Testing queries return expected addresses") + queryRes, err := addressesQueryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) + s.Require().NoError(err) + s.Require().Len(queryRes.AddressMappings, 1, "There should be one address mapping") + s.Require().Equal(evmAddress.Hex(), queryRes.AddressMappings[0].EvmAddress, "EVM address does not match") + + queryByEvmRes, err := addressesQueryClient.QueryAddressMappingByEVMAddress(context.Background(), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddress.Hex()}) + s.Require().NoError(err) + s.Require().Equal(cosmosAddress.String(), queryByEvmRes.CosmosAddress, "Cosmos address does not match") + s.Require().Equal(evmAddress.Hex(), queryByEvmRes.EvmAddress, "EVM address does not match") + + queryByCosmosRes, err := addressesQueryClient.QueryAddressMappingByCosmosAddress(context.Background(), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddress.String()}) + s.Require().NoError(err) + s.Require().Equal(cosmosAddress.String(), queryByCosmosRes.CosmosAddress, "Cosmos address does not match") + s.Require().Equal(evmAddress.Hex(), queryByCosmosRes.EvmAddress, "EVM address does not match") + + s.T().Log("Removing address mapping") + removeAddressMappingMsg, err := types.NewMsgRemoveAddressMapping(cosmosAddress) + s.Require().NoError(err) + + _, err = s.chain.sendMsgs(*orchClientCtx, removeAddressMappingMsg) + s.Require().NoError(err) + + s.T().Log("Testing mappings query returns no addresses") + queryRes, err = addressesQueryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) + s.Require().NoError(err) + s.Require().Len(queryRes.AddressMappings, 0, "There should be no address mappings") + }) +} From 19729af4be49f73171ebd5f56b6d15dc191cd3bd Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 15:09:10 -0500 Subject: [PATCH 12/28] Fixing linting errors --- x/addresses/keeper/genesis_test.go | 2 +- x/addresses/keeper/keeper_test.go | 6 +++++- x/addresses/keeper/msg_server_test.go | 20 ++++++++------------ x/addresses/keeper/query_server.go | 4 ++-- x/addresses/keeper/query_server_test.go | 14 +++++--------- x/addresses/types/addresses.go | 6 +++--- x/addresses/types/errors.go | 8 +++----- 7 files changed, 27 insertions(+), 33 deletions(-) diff --git a/x/addresses/keeper/genesis_test.go b/x/addresses/keeper/genesis_test.go index b0614249..a9c8b3bf 100644 --- a/x/addresses/keeper/genesis_test.go +++ b/x/addresses/keeper/genesis_test.go @@ -24,6 +24,6 @@ func (suite *KeeperTestSuite) TestGenesisValidation() { require.Error(genesis.Validate()) genesis.AddressMappings = types.DefaultGenesisState().AddressMappings - genesis.AddressMappings = append(genesis.AddressMappings, &types.AddressMapping{CosmosAddress: "cosmos1l8n6v5f4j5s8j5l8n6v5f4j5s8j5l8n6v5f4j", EvmAddress: "zzzz"}) + genesis.AddressMappings = append(genesis.AddressMappings, &types.AddressMapping{CosmosAddress: cosmosAddrString, EvmAddress: "zzzz"}) require.Error(genesis.Validate()) } diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index 5e9d3acf..8fa023e4 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -20,6 +20,11 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" ) +const ( + cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + evmAddrString = "0x1111111111111111111111111111111111111111" +) + type KeeperTestSuite struct { suite.Suite @@ -94,7 +99,6 @@ func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() { require.Equal(42, len(evmAddrString)) evmAddr := common.HexToAddress(evmAddrString).Bytes() - cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" acc, err := sdk.AccAddressFromBech32(cosmosAddrString) require.NoError(err) diff --git a/x/addresses/keeper/msg_server_test.go b/x/addresses/keeper/msg_server_test.go index 162327de..6b67f319 100644 --- a/x/addresses/keeper/msg_server_test.go +++ b/x/addresses/keeper/msg_server_test.go @@ -11,9 +11,6 @@ func (suite *KeeperTestSuite) TestHappyPathsForMsgServer() { require := suite.Require() // Test AddAddressMapping - evmAddrString := "0x1111111111111111111111111111111111111111" - require.Equal(42, len(evmAddrString)) - cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" _, err := sdk.AccAddressFromBech32(cosmosAddrString) require.NoError(err) @@ -50,22 +47,21 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForMsgServer() { // Test AddAddressMapping // too long evm address - evmAddrString := "0x11111111111111111111111111111111111111111" + evmAddrStringInvalid := "0x11111111111111111111111111111111111111111" /// invalid checksum cosmos address - cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" - _, err := sdk.AccAddressFromBech32(cosmosAddrString) + cosmosAddrStringInvalid := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" + _, err := sdk.AccAddressFromBech32(cosmosAddrStringInvalid) require.Error(err) - _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: evmAddrString}) + _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrStringInvalid, EvmAddress: evmAddrString}) require.Error(err) require.Contains(err.Error(), "invalid signer address") - cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" _, err = sdk.AccAddressFromBech32(cosmosAddrString) require.NoError(err) evmAddr := common.HexToAddress(evmAddrString).Bytes() - _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: evmAddrString}) + _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: evmAddrStringInvalid}) require.Error(err) require.Contains(err.Error(), "invalid EVM address") @@ -77,11 +73,11 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForMsgServer() { // Test RemoveAddressMapping // invalid checksum - cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" - _, err = sdk.AccAddressFromBech32(cosmosAddrString) + cosmosAddrStringInvalid = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" + _, err = sdk.AccAddressFromBech32(cosmosAddrStringInvalid) require.Error(err) - _, err = addressesKeeper.RemoveAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgRemoveAddressMapping{Signer: cosmosAddrString}) + _, err = addressesKeeper.RemoveAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgRemoveAddressMapping{Signer: cosmosAddrStringInvalid}) require.Error(err) require.Contains(err.Error(), "invalid signer address") } diff --git a/x/addresses/keeper/query_server.go b/x/addresses/keeper/query_server.go index 8425625d..db931d1e 100644 --- a/x/addresses/keeper/query_server.go +++ b/x/addresses/keeper/query_server.go @@ -74,7 +74,7 @@ func (k Keeper) QueryAddressMappingByCosmosAddress(c context.Context, request *t rawEvmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) - if rawEvmAddr == nil || len(rawEvmAddr) == 0 { + if len(rawEvmAddr) == 0 { return &types.QueryAddressMappingByCosmosAddressResponse{}, status.Errorf(codes.NotFound, "no EVM address mapping for cosmos address %s", request.GetCosmosAddress()) } @@ -96,7 +96,7 @@ func (k Keeper) QueryAddressMappingByEVMAddress(c context.Context, request *type evmAddr := common.HexToAddress(request.GetEvmAddress()).Bytes() rawCosmosAddr := k.GetCosmosAddressByEvmAddress(ctx, evmAddr) - if rawCosmosAddr == nil { + if len(rawCosmosAddr) == 0 { return &types.QueryAddressMappingByEVMAddressResponse{}, status.Errorf(codes.NotFound, "no cosmos address mapping for EVM address %s", request.GetEvmAddress()) } diff --git a/x/addresses/keeper/query_server_test.go b/x/addresses/keeper/query_server_test.go index efe9b849..ed0d66ce 100644 --- a/x/addresses/keeper/query_server_test.go +++ b/x/addresses/keeper/query_server_test.go @@ -14,10 +14,8 @@ func (suite *KeeperTestSuite) TestHappyPathsForQueryServer() { params := types.DefaultParams() addressesKeeper.setParams(ctx, params) - evmAddrString := "0x1111111111111111111111111111111111111111" require.Equal(42, len(evmAddrString)) evmAddr := common.HexToAddress(evmAddrString).Bytes() - cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" acc, err := sdk.AccAddressFromBech32(cosmosAddrString) require.NoError(err) @@ -57,10 +55,10 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForQueryServer() { addressesKeeper.setParams(ctx, params) // invalid length evm address - evmAddrString := "0x11111111111111111111111111111111111111111" + evmAddrStringInvalid := "0x11111111111111111111111111111111111111111" // invalid checksum cosmos address - cosmosAddrString := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" - _, err := sdk.AccAddressFromBech32(cosmosAddrString) + cosmosAddrStringInvalid := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" + _, err := sdk.AccAddressFromBech32(cosmosAddrStringInvalid) require.Error(err) // Test QueryParams @@ -69,23 +67,21 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForQueryServer() { require.Equal(¶ms, queryParams.Params) // Test QueryAddressMappingByEvmAddress - _, err = addressesKeeper.QueryAddressMappingByEVMAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddrString}) + _, err = addressesKeeper.QueryAddressMappingByEVMAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddrStringInvalid}) require.Error(err) require.Contains(err.Error(), "invalid EVM address") // valid evm address - evmAddrString = "0x1111111111111111111111111111111111111111" _, err = addressesKeeper.QueryAddressMappingByEVMAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddrString}) require.Error(err) require.Contains(err.Error(), "no cosmos address mapping for EVM address") // Test QueryAddressMappingByCosmosAddress - _, err = addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddrString}) + _, err = addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddrStringInvalid}) require.Error(err) require.Contains(err.Error(), "failed to parse cosmos address") // valid cosmos address - cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" _, err = addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddrString}) require.Error(err) require.Contains(err.Error(), "no EVM address mapping for cosmos address") diff --git a/x/addresses/types/addresses.go b/x/addresses/types/addresses.go index 510e178f..403c19c7 100644 --- a/x/addresses/types/addresses.go +++ b/x/addresses/types/addresses.go @@ -1,18 +1,18 @@ package types import ( + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" ) func (am AddressMapping) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(am.CosmosAddress); err != nil { - return sdkerrors.Wrapf(ErrInvalidCosmosAddress, "%s is not a valid cosmos address", am.CosmosAddress) + return errorsmod.Wrapf(ErrInvalidCosmosAddress, "%s is not a valid cosmos address", am.CosmosAddress) } if !common.IsHexAddress(am.EvmAddress) { - return sdkerrors.Wrapf(ErrInvalidEvmAddress, "%s is not a valid EVM address", am.EvmAddress) + return errorsmod.Wrapf(ErrInvalidEvmAddress, "%s is not a valid EVM address", am.EvmAddress) } return nil diff --git a/x/addresses/types/errors.go b/x/addresses/types/errors.go index 618933ef..67fa24e4 100644 --- a/x/addresses/types/errors.go +++ b/x/addresses/types/errors.go @@ -1,10 +1,8 @@ package types -import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) +import errorsmod "cosmossdk.io/errors" var ( - ErrInvalidEvmAddress = sdkerrors.Register(ModuleName, 2, "invalid evm address") - ErrInvalidCosmosAddress = sdkerrors.Register(ModuleName, 3, "invalid cosmos address") + ErrInvalidEvmAddress = errorsmod.Register(ModuleName, 2, "invalid evm address") + ErrInvalidCosmosAddress = errorsmod.Register(ModuleName, 3, "invalid cosmos address") ) From 426819d453057e581def3d2d0e32bd625be6970e Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 15:26:57 -0500 Subject: [PATCH 13/28] More linting fixes --- x/addresses/client/cli/tx.go | 10 ---------- x/addresses/keeper/keeper_test.go | 5 +++-- x/addresses/keeper/msg_server_test.go | 4 ---- x/addresses/keeper/query_server_test.go | 3 --- x/addresses/types/genesis_test.go | 6 ++++-- x/addresses/types/params.go | 1 + 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/x/addresses/client/cli/tx.go b/x/addresses/client/cli/tx.go index 768ae4b9..211a19b3 100644 --- a/x/addresses/client/cli/tx.go +++ b/x/addresses/client/cli/tx.go @@ -3,7 +3,6 @@ package cli import ( "fmt" "strings" - "time" "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" @@ -17,15 +16,6 @@ import ( "github.com/peggyjv/sommelier/v7/x/addresses/types" ) -var ( - DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -) - -const ( - flagPacketTimeoutTimestamp = "packet-timeout-timestamp" - listSeparator = "," -) - // GetTxCmd returns the transaction commands for this module func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index 8fa023e4..d512c90f 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -21,8 +21,9 @@ import ( ) const ( - cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" - evmAddrString = "0x1111111111111111111111111111111111111111" + cosmosAddrString = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + cosmosAddrStringInvalid = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" + evmAddrString = "0x1111111111111111111111111111111111111111" ) type KeeperTestSuite struct { diff --git a/x/addresses/keeper/msg_server_test.go b/x/addresses/keeper/msg_server_test.go index 6b67f319..952bd64a 100644 --- a/x/addresses/keeper/msg_server_test.go +++ b/x/addresses/keeper/msg_server_test.go @@ -48,8 +48,6 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForMsgServer() { // Test AddAddressMapping // too long evm address evmAddrStringInvalid := "0x11111111111111111111111111111111111111111" - /// invalid checksum cosmos address - cosmosAddrStringInvalid := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" _, err := sdk.AccAddressFromBech32(cosmosAddrStringInvalid) require.Error(err) @@ -72,8 +70,6 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForMsgServer() { require.Nil(result) // Test RemoveAddressMapping - // invalid checksum - cosmosAddrStringInvalid = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" _, err = sdk.AccAddressFromBech32(cosmosAddrStringInvalid) require.Error(err) diff --git a/x/addresses/keeper/query_server_test.go b/x/addresses/keeper/query_server_test.go index ed0d66ce..44b2c172 100644 --- a/x/addresses/keeper/query_server_test.go +++ b/x/addresses/keeper/query_server_test.go @@ -14,7 +14,6 @@ func (suite *KeeperTestSuite) TestHappyPathsForQueryServer() { params := types.DefaultParams() addressesKeeper.setParams(ctx, params) - require.Equal(42, len(evmAddrString)) evmAddr := common.HexToAddress(evmAddrString).Bytes() acc, err := sdk.AccAddressFromBech32(cosmosAddrString) require.NoError(err) @@ -56,8 +55,6 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForQueryServer() { // invalid length evm address evmAddrStringInvalid := "0x11111111111111111111111111111111111111111" - // invalid checksum cosmos address - cosmosAddrStringInvalid := "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje41" _, err := sdk.AccAddressFromBech32(cosmosAddrStringInvalid) require.Error(err) diff --git a/x/addresses/types/genesis_test.go b/x/addresses/types/genesis_test.go index 2205156d..354428ff 100644 --- a/x/addresses/types/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -8,7 +8,7 @@ import ( func TestGenesisState_Validate(t *testing.T) { def := DefaultGenesisState() - for _, tc := range []struct { + testCases := []struct { desc string genState *GenesisState valid bool @@ -23,7 +23,9 @@ func TestGenesisState_Validate(t *testing.T) { genState: &GenesisState{}, valid: true, }, - } { + } + + for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { diff --git a/x/addresses/types/params.go b/x/addresses/types/params.go index 6b375754..7cfc4e7f 100644 --- a/x/addresses/types/params.go +++ b/x/addresses/types/params.go @@ -1,3 +1,4 @@ +//nolint:all package types import ( From f1f06a842b855fbbc3e80797ae8fa399dd93dbfc Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 15:44:56 -0500 Subject: [PATCH 14/28] More linting --- x/addresses/keeper/keeper_test.go | 190 ------------------------------ x/addresses/types/genesis.go | 2 +- x/addresses/types/genesis_test.go | 14 +-- x/addresses/types/params.go | 6 +- 4 files changed, 10 insertions(+), 202 deletions(-) diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index d512c90f..7bfcbd9e 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -135,193 +135,3 @@ func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() { evmResult = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) require.Nil(evmResult) } - -//// Unhappy path tests for BeginAuction -//func (suite *KeeperTestSuite) TestUnhappyPathsForBeginAuction() { -// ctx, addressesKeeper := suite.ctx, suite.addressesKeeper -// require := suite.Require() -// -// // Define basic param(s) -// addressesParams := addressTypes.DefaultParams() -// addressesKeeper.setParams(ctx, addressesParams) -// -// // Setup some token prices -// sommPrice := addressTypes.TokenPrice{Denom: params.BaseCoinUnit, Exponent: 6, UsdPrice: sdk.MustNewDecFromStr("0.01"), LastUpdatedBlock: 2} -// -// /* #nosec */ -// saleToken := "gravity0xaaaebe6fe48e54f431b0c390cfaf0b017d09d42d" -// saleTokenPrice := addressTypes.TokenPrice{Denom: saleToken, Exponent: 6, UsdPrice: sdk.MustNewDecFromStr("0.01"), LastUpdatedBlock: 5} -// addressesedSaleTokens := sdk.NewCoin(saleToken, sdk.NewInt(10000)) -// -// tests := []struct { -// name string -// beginAuctionRequest BeginAuctionRequest -// expectedError error -// runsBefore runsBeforeWrapper -// }{ -// { -// name: "Unpermissioned funder module account", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx, -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: "cork", -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrapf(addressTypes.ErrUnauthorizedFundingModule, "Module Account: cork"), -// runsBefore: func() {}, -// }, -// { -// name: "Unpermissioned proceeds module account", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx, -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: "gravity", -// }, -// expectedError: errorsmod.Wrapf(addressTypes.ErrUnauthorizedProceedsModule, "Module Account: gravity"), -// runsBefore: func() {}, -// }, -// { -// name: "Starting denom price not found", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx, -// startingTokensForSale: sdk.NewCoin("anvil", sdk.NewInt(7)), -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrapf(addressTypes.ErrCouldNotFindSaleTokenPrice, "starting amount denom: anvil"), -// runsBefore: func() {}, -// }, -// { -// name: "Starting denom price update too old", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx.WithBlockHeight(int64(saleTokenPrice.LastUpdatedBlock) + int64(addressesParams.PriceMaxBlockAge) + 1), -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrapf(addressTypes.ErrLastSaleTokenPriceTooOld, "starting amount denom: %s", saleToken), -// runsBefore: func() { -// addressesKeeper.setTokenPrice(ctx, saleTokenPrice) -// }, -// }, -// { -// name: "Usomm price not found", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx, -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrap(addressTypes.ErrCouldNotFindSommTokenPrice, params.BaseCoinUnit), -// runsBefore: func() {}, -// }, -// { -// name: "Usomm price update too old", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx.WithBlockHeight(int64(sommPrice.LastUpdatedBlock) + int64(addressesParams.PriceMaxBlockAge) + 1), -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrap(addressTypes.ErrLastSommTokenPriceTooOld, params.BaseCoinUnit), -// runsBefore: func() { -// addressesKeeper.setTokenPrice(ctx, sommPrice) -// }, -// }, -// { -// name: "Validate basic canary 1 -- invalid initialPriceDecreaseRate lower bound", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx, -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.0"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrapf(addressTypes.ErrInvalidInitialDecreaseRate, "Initial price decrease rate 0.000000000000000000"), -// runsBefore: func() {}, -// }, -// { -// name: "Validate basic canary 2 -- invalid initialPriceDecreaseRate upper bound", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx, -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("1.0"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrapf(addressTypes.ErrInvalidInitialDecreaseRate, "Initial price decrease rate 1.000000000000000000"), -// runsBefore: func() {}, -// }, -// { -// name: "Cannot have 2 ongoing addressess for the same denom", -// beginAuctionRequest: BeginAuctionRequest{ -// ctx: ctx, -// startingTokensForSale: addressesedSaleTokens, -// initialPriceDecreaseRate: sdk.MustNewDecFromStr("0.05"), -// priceDecreaseBlockInterval: uint64(10), -// fundingModuleAccount: permissionedFunder.GetName(), -// proceedsModuleAccount: permissionedReciever.GetName(), -// }, -// expectedError: errorsmod.Wrapf(addressTypes.ErrCannotStartTwoAuctionsForSameDenomSimultaneously, "Denom: %s", addressesedSaleTokens.Denom), -// runsBefore: func() { -// // Mock initial bank keeper fund transfer -// suite.mockSendCoinsFromModuleToModule(ctx, permissionedFunder.GetName(), addressTypes.ModuleName, sdk.NewCoins(addressesedSaleTokens)) -// -// // Start addresses -// decreaseRate := sdk.MustNewDecFromStr("0.05") -// blockDecreaseInterval := uint64(5) -// err := addressesKeeper.BeginAuction(ctx, addressesedSaleTokens, decreaseRate, blockDecreaseInterval, permissionedFunder.GetName(), permissionedReciever.GetName()) -// require.Nil(err) -// -// // Verify addresses got added to active addresses store -// addressesID := uint32(1) -// createdAuction, found := addressesKeeper.GetActiveAuctionByID(ctx, addressesID) -// require.True(found) -// }, -// }, -// } -// -// for _, tc := range tests { -// tc := tc // Redefine variable here due to passing it to function literal below (scopelint) -// suite.T().Run(fmt.Sprint(tc.name), func(t *testing.T) { -// // Run expected bank keeper functions, if any -// tc.runsBefore() -// -// call := func() error { -// return addressesKeeper.BeginAuction( -// tc.beginAuctionRequest.ctx, -// tc.beginAuctionRequest.startingTokensForSale, -// tc.beginAuctionRequest.initialPriceDecreaseRate, -// tc.beginAuctionRequest.priceDecreaseBlockInterval, -// tc.beginAuctionRequest.fundingModuleAccount, -// tc.beginAuctionRequest.proceedsModuleAccount, -// ) -// } -// -// if tc.name[0:14] == "Validate basic" { -// require.Panics(func() { call() }) -// return -// } -// -// err := call() -// -// // Verify errors are as expected -// require.Equal(tc.expectedError.Error(), err.Error()) -// }) -// } -//} diff --git a/x/addresses/types/genesis.go b/x/addresses/types/genesis.go index cd40dc80..370b5f07 100644 --- a/x/addresses/types/genesis.go +++ b/x/addresses/types/genesis.go @@ -14,7 +14,7 @@ func DefaultGenesisState() GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - gs.Params.ValidateBasic() + // gs.Params.ValidateBasic() for _, mapping := range gs.AddressMappings { if err := mapping.ValidateBasic(); err != nil { diff --git a/x/addresses/types/genesis_test.go b/x/addresses/types/genesis_test.go index 354428ff..8a14134b 100644 --- a/x/addresses/types/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -26,13 +26,11 @@ func TestGenesisState_Validate(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } } } diff --git a/x/addresses/types/params.go b/x/addresses/types/params.go index 7cfc4e7f..e61c8c15 100644 --- a/x/addresses/types/params.go +++ b/x/addresses/types/params.go @@ -28,6 +28,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } // Validate validates the set of params -func (p Params) ValidateBasic() error { - return nil -} +// func (p Params) ValidateBasic() error { +// return nil +// } From 8a6e97a0dbe0dcadb365ffc1560dcd541873c622 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Fri, 15 Mar 2024 16:29:05 -0500 Subject: [PATCH 15/28] A few tweaks --- x/addresses/keeper/genesis.go | 5 +++- x/addresses/keeper/keeper.go | 39 +++++++++++++++++++++---------- x/addresses/keeper/keeper_test.go | 3 +++ x/addresses/keeper/msg_server.go | 10 ++++++-- x/addresses/types/errors.go | 2 ++ 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/x/addresses/keeper/genesis.go b/x/addresses/keeper/genesis.go index 86dfa4c2..849ad6e3 100644 --- a/x/addresses/keeper/genesis.go +++ b/x/addresses/keeper/genesis.go @@ -45,5 +45,8 @@ func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState { return false }) - return types.GenesisState{AddressMappings: mappings} + return types.GenesisState{ + Params: k.GetParamSet(ctx), + AddressMappings: mappings, + } } diff --git a/x/addresses/keeper/keeper.go b/x/addresses/keeper/keeper.go index d5507461..f9e2570d 100644 --- a/x/addresses/keeper/keeper.go +++ b/x/addresses/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -62,42 +63,56 @@ func (k Keeper) setParams(ctx sdk.Context, params types.Params) { /////////////////////// // SetAddressMapping stores the mapping between the cosmos and evm addresses -func (k Keeper) SetAddressMapping(ctx sdk.Context, cosmosAddr []byte, evmAddr []byte) { - k.SetCosmosToEvmMapping(ctx, cosmosAddr, evmAddr) - k.SetEvmToCosmosMapping(ctx, evmAddr, cosmosAddr) +func (k Keeper) SetAddressMapping(ctx sdk.Context, cosmosAddr []byte, evmAddr []byte) error { + // sanity check, shouldn't be possible with proper validation in the message handler + if cosmosAddr == nil { + return errorsmod.Wrapf(types.ErrNilCosmosAddress, "cosmos address cannot be nil") + } + + if evmAddr == nil { + return errorsmod.Wrapf(types.ErrNilEvmAddress, "evm address cannot be nil") + } + + k.setCosmosToEvmMapping(ctx, cosmosAddr, evmAddr) + k.setEvmToCosmosMapping(ctx, evmAddr, cosmosAddr) + + return nil } -func (k Keeper) SetCosmosToEvmMapping(ctx sdk.Context, cosmosAddr []byte, evmAddr []byte) { +func (k Keeper) setCosmosToEvmMapping(ctx sdk.Context, cosmosAddr []byte, evmAddr []byte) { store := ctx.KVStore(k.storeKey) store.Set(types.GetCosmosToEvmMapKey(cosmosAddr), evmAddr) } -func (k Keeper) SetEvmToCosmosMapping(ctx sdk.Context, evmAddr []byte, cosmosAddr []byte) { +func (k Keeper) setEvmToCosmosMapping(ctx sdk.Context, evmAddr []byte, cosmosAddr []byte) { store := ctx.KVStore(k.storeKey) store.Set(types.GetEvmToCosmosMapKey(evmAddr), cosmosAddr) } // DeleteAddressMapping deletes the mapping between the cosmos and evm addresses -func (k Keeper) DeleteAddressMapping(ctx sdk.Context, cosmosAddr []byte) { +func (k Keeper) DeleteAddressMapping(ctx sdk.Context, cosmosAddr []byte) error { + // sanity check, shouldn't be possible with proper validation in the message handler if cosmosAddr == nil { - return + return errorsmod.Wrapf(types.ErrNilCosmosAddress, "cosmos address cannot be nil") } evmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) if evmAddr == nil { - return + return errorsmod.Wrapf(types.ErrNilEvmAddress, "evm address cannot be nil") } - k.DeleteEvmToCosmosMapping(ctx, evmAddr) - k.DeleteCosmosToEvmMapping(ctx, cosmosAddr) + k.deleteEvmToCosmosMapping(ctx, evmAddr) + k.deleteCosmosToEvmMapping(ctx, cosmosAddr) + + return nil } -func (k Keeper) DeleteCosmosToEvmMapping(ctx sdk.Context, cosmosAddr []byte) { +func (k Keeper) deleteCosmosToEvmMapping(ctx sdk.Context, cosmosAddr []byte) { store := ctx.KVStore(k.storeKey) store.Delete(types.GetCosmosToEvmMapKey(cosmosAddr)) } -func (k Keeper) DeleteEvmToCosmosMapping(ctx sdk.Context, evmAddr []byte) { +func (k Keeper) deleteEvmToCosmosMapping(ctx sdk.Context, evmAddr []byte) { store := ctx.KVStore(k.storeKey) store.Delete(types.GetEvmToCosmosMapKey(evmAddr)) } diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index 7bfcbd9e..646bdb73 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -134,4 +134,7 @@ func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() { require.Nil(cosmosResult) evmResult = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) require.Nil(evmResult) + + // Invalid input + addressesKeeper.SetAddressMapping(ctx, nil, evmAddr) } diff --git a/x/addresses/keeper/msg_server.go b/x/addresses/keeper/msg_server.go index d9610165..4007b0b1 100644 --- a/x/addresses/keeper/msg_server.go +++ b/x/addresses/keeper/msg_server.go @@ -26,7 +26,10 @@ func (k Keeper) AddAddressMapping(c context.Context, req *types.MsgAddAddressMap evmAddr := common.HexToAddress(req.EvmAddress).Bytes() - k.SetAddressMapping(ctx, signer.Bytes(), evmAddr) + err = k.SetAddressMapping(ctx, signer.Bytes(), evmAddr) + if err != nil { + return &types.MsgAddAddressMappingResponse{}, status.Errorf(codes.Internal, "failed to set address mapping: %s", err) + } return &types.MsgAddAddressMappingResponse{}, nil } @@ -39,7 +42,10 @@ func (k Keeper) RemoveAddressMapping(c context.Context, req *types.MsgRemoveAddr return &types.MsgRemoveAddressMappingResponse{}, status.Errorf(codes.InvalidArgument, "invalid signer address %s", req.GetSigner()) } - k.DeleteAddressMapping(ctx, signer.Bytes()) + err = k.DeleteAddressMapping(ctx, signer.Bytes()) + if err != nil { + return &types.MsgRemoveAddressMappingResponse{}, status.Errorf(codes.Internal, "failed to remove address mapping: %s", err) + } return &types.MsgRemoveAddressMappingResponse{}, nil } diff --git a/x/addresses/types/errors.go b/x/addresses/types/errors.go index 67fa24e4..1067b1a4 100644 --- a/x/addresses/types/errors.go +++ b/x/addresses/types/errors.go @@ -5,4 +5,6 @@ import errorsmod "cosmossdk.io/errors" var ( ErrInvalidEvmAddress = errorsmod.Register(ModuleName, 2, "invalid evm address") ErrInvalidCosmosAddress = errorsmod.Register(ModuleName, 3, "invalid cosmos address") + ErrNilCosmosAddress = errorsmod.Register(ModuleName, 4, "cosmos address cannot be nil") + ErrNilEvmAddress = errorsmod.Register(ModuleName, 5, "evm address cannot be nil") ) From 9cffc230cde933acff3fefa0fc3065f8285b0918 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Mon, 18 Mar 2024 11:39:02 -0500 Subject: [PATCH 16/28] Test pagination in query unit test --- x/addresses/keeper/query_server_test.go | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/x/addresses/keeper/query_server_test.go b/x/addresses/keeper/query_server_test.go index 44b2c172..f4c7f10e 100644 --- a/x/addresses/keeper/query_server_test.go +++ b/x/addresses/keeper/query_server_test.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + query "github.com/cosmos/cosmos-sdk/types/query" "github.com/ethereum/go-ethereum/common" "github.com/peggyjv/sommelier/v7/x/addresses/types" ) @@ -43,6 +44,50 @@ func (suite *KeeperTestSuite) TestHappyPathsForQueryServer() { require.Len(addressMappings.AddressMappings, 1) require.Equal(cosmosAddrString, addressMappings.AddressMappings[0].CosmosAddress) require.Equal(evmAddrString, addressMappings.AddressMappings[0].EvmAddress) + + // Test QueryAddressMappings with pagination + addressMappings, err = addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{Pagination: query.PageRequest{Limit: 1}}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 1) + require.Equal(cosmosAddrString, addressMappings.AddressMappings[0].CosmosAddress) + require.Equal(evmAddrString, addressMappings.AddressMappings[0].EvmAddress) + + evmAddrString2 := "0x2222222222222222222222222222222222222222" + // keys stored in ascending order, so this one will be stored before the previous value (cosmos15...) + cosmosAddrString2 := "cosmos1y6d5kasehecexf09ka6y0ggl0pxzt6dgk0gnl9" + evmAddr2 := common.HexToAddress(evmAddrString2).Bytes() + acc2, err := sdk.AccAddressFromBech32(cosmosAddrString2) + require.NoError(err) + + cosmosAddr2 := acc2.Bytes() + + addressesKeeper.SetAddressMapping(ctx, cosmosAddr2, evmAddr2) + + addressMappings, err = addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{Pagination: query.PageRequest{Limit: 1, Offset: 1}}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 1) + require.Equal(cosmosAddrString, addressMappings.AddressMappings[0].CosmosAddress) + require.Equal(evmAddrString, addressMappings.AddressMappings[0].EvmAddress) + + addressMappings, err = addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{Pagination: query.PageRequest{Limit: 1}}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 1) + require.Equal(cosmosAddrString2, addressMappings.AddressMappings[0].CosmosAddress) + require.Equal(evmAddrString2, addressMappings.AddressMappings[0].EvmAddress) + + addressMappings, err = addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{Pagination: query.PageRequest{Key: addressMappings.Pagination.NextKey}}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 1) + require.Equal(cosmosAddrString, addressMappings.AddressMappings[0].CosmosAddress) + require.Equal(evmAddrString, addressMappings.AddressMappings[0].EvmAddress) + + addressMappings, err = addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{Pagination: query.PageRequest{Limit: 2}}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 2) + require.Equal(cosmosAddrString, addressMappings.AddressMappings[1].CosmosAddress) + require.Equal(evmAddrString, addressMappings.AddressMappings[1].EvmAddress) + require.Equal(cosmosAddrString2, addressMappings.AddressMappings[0].CosmosAddress) + require.Equal(evmAddrString2, addressMappings.AddressMappings[0].EvmAddress) } // Unhappy path test for query server functions From 7b51fab9c11c3996b6f3b82b0a0047e00b0e60d9 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Mon, 18 Mar 2024 17:04:38 -0500 Subject: [PATCH 17/28] Review items --- x/addresses/keeper/keeper.go | 16 ++++++++-------- x/addresses/types/msgs.go | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/x/addresses/keeper/keeper.go b/x/addresses/keeper/keeper.go index f9e2570d..20c89244 100644 --- a/x/addresses/keeper/keeper.go +++ b/x/addresses/keeper/keeper.go @@ -65,12 +65,12 @@ func (k Keeper) setParams(ctx sdk.Context, params types.Params) { // SetAddressMapping stores the mapping between the cosmos and evm addresses func (k Keeper) SetAddressMapping(ctx sdk.Context, cosmosAddr []byte, evmAddr []byte) error { // sanity check, shouldn't be possible with proper validation in the message handler - if cosmosAddr == nil { - return errorsmod.Wrapf(types.ErrNilCosmosAddress, "cosmos address cannot be nil") + if len(cosmosAddr) == 0 { + return errorsmod.Wrap(types.ErrNilCosmosAddress, "cosmos address cannot be empty") } - if evmAddr == nil { - return errorsmod.Wrapf(types.ErrNilEvmAddress, "evm address cannot be nil") + if len(evmAddr) == 0 { + return errorsmod.Wrap(types.ErrNilEvmAddress, "evm address cannot be empty") } k.setCosmosToEvmMapping(ctx, cosmosAddr, evmAddr) @@ -92,13 +92,13 @@ func (k Keeper) setEvmToCosmosMapping(ctx sdk.Context, evmAddr []byte, cosmosAdd // DeleteAddressMapping deletes the mapping between the cosmos and evm addresses func (k Keeper) DeleteAddressMapping(ctx sdk.Context, cosmosAddr []byte) error { // sanity check, shouldn't be possible with proper validation in the message handler - if cosmosAddr == nil { - return errorsmod.Wrapf(types.ErrNilCosmosAddress, "cosmos address cannot be nil") + if len(cosmosAddr) == 0 { + return errorsmod.Wrap(types.ErrNilCosmosAddress, "cosmos address cannot be empty") } evmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) - if evmAddr == nil { - return errorsmod.Wrapf(types.ErrNilEvmAddress, "evm address cannot be nil") + if len(evmAddr) == 0 { + return errorsmod.Wrap(types.ErrNilEvmAddress, "evm address cannot be empty") } k.deleteEvmToCosmosMapping(ctx, evmAddr) diff --git a/x/addresses/types/msgs.go b/x/addresses/types/msgs.go index 78f796f0..7b991e79 100644 --- a/x/addresses/types/msgs.go +++ b/x/addresses/types/msgs.go @@ -13,8 +13,8 @@ var ( ) const ( - TypeMsgAddAddressMapping = "submit_bid" - TypeMsgRemoveAddressMapping = "remove_bid" + TypeMsgAddAddressMapping = "add_address_mapping" + TypeMsgRemoveAddressMapping = "remove_address_mapping" ) ////////////////////////// From b6f11d5354d349ba302272740e70527ddf6ee25f Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 7 Aug 2024 12:01:53 -0500 Subject: [PATCH 18/28] Compiler errors, proto errors. WIP - need to bump go version to 1.22 --- go.mod | 4 ++-- x/addresses/keeper/keeper.go | 2 +- x/addresses/keeper/keeper_test.go | 4 ++-- x/addresses/module.go | 16 +--------------- x/addresses/types/addresses.pb.go | 2 +- x/addresses/types/genesis.pb.go | 2 +- x/addresses/types/query.pb.go | 4 ++-- x/addresses/types/tx.pb.go | 4 ++-- 8 files changed, 12 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 31f0a13b..9c1c1e80 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,10 @@ module github.com/peggyjv/sommelier/v7 go 1.22 -toolchain go1.22.2 +toolchain go1.22.1 require ( + cosmossdk.io/api v0.3.1 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 github.com/cometbft/cometbft v0.37.4 @@ -40,7 +41,6 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.5 // indirect cloud.google.com/go/storage v1.35.1 // indirect - cosmossdk.io/api v0.3.1 // indirect cosmossdk.io/core v0.5.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/log v1.3.1 // indirect diff --git a/x/addresses/keeper/keeper.go b/x/addresses/keeper/keeper.go index 20c89244..c8530ca0 100644 --- a/x/addresses/keeper/keeper.go +++ b/x/addresses/keeper/keeper.go @@ -4,11 +4,11 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/tendermint/tendermint/libs/log" "github.com/peggyjv/sommelier/v7/x/addresses/types" ) diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index 646bdb73..69cef53e 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -15,9 +15,9 @@ import ( moduletestutil "github.com/peggyjv/sommelier/v7/testutil" addressTypes "github.com/peggyjv/sommelier/v7/x/addresses/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmtime "github.com/cometbft/cometbft/types/time" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" ) const ( diff --git a/x/addresses/module.go b/x/addresses/module.go index a78b35c2..8d87b815 100644 --- a/x/addresses/module.go +++ b/x/addresses/module.go @@ -4,12 +4,11 @@ import ( "context" "encoding/json" "fmt" - "math/rand" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -106,17 +105,9 @@ func NewAppModule( } } -// Deprecated: use RegisterServices -func (am AppModule) Route() sdk.Route { return sdk.Route{} } - // Deprecated: use RegisterServices func (AppModule) QuerierRoute() string { return types.RouterKey } -// Deprecated: use RegisterServices -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return nil -} - // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), am.keeper) @@ -170,11 +161,6 @@ func (am AppModule) ProposalContents(_ module.SimulationState) []sim.WeightedPro return nil } -// RandomizedParams creates randomized distribution param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []sim.ParamChange { - return nil -} - // RegisterStoreDecoder registers a decoder for distribution module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { } diff --git a/x/addresses/types/addresses.pb.go b/x/addresses/types/addresses.pb.go index f6bafe42..fa24cd7a 100644 --- a/x/addresses/types/addresses.pb.go +++ b/x/addresses/types/addresses.pb.go @@ -5,7 +5,7 @@ package types import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" + proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" diff --git a/x/addresses/types/genesis.pb.go b/x/addresses/types/genesis.pb.go index e3eca233..d4b76da4 100644 --- a/x/addresses/types/genesis.pb.go +++ b/x/addresses/types/genesis.pb.go @@ -6,7 +6,7 @@ package types import ( fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/gogo/protobuf/proto" + proto "github.com/cosmos/gogoproto/proto" _ "google.golang.org/genproto/googleapis/api/annotations" io "io" math "math" diff --git a/x/addresses/types/query.pb.go b/x/addresses/types/query.pb.go index 67744b95..7086a905 100644 --- a/x/addresses/types/query.pb.go +++ b/x/addresses/types/query.pb.go @@ -8,8 +8,8 @@ import ( fmt "fmt" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" diff --git a/x/addresses/types/tx.pb.go b/x/addresses/types/tx.pb.go index 0f66c0fc..7a9d43ee 100644 --- a/x/addresses/types/tx.pb.go +++ b/x/addresses/types/tx.pb.go @@ -6,8 +6,8 @@ package types import ( context "context" fmt "fmt" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" From 5e35ce0d799dd7614b3514881896012f52bd85bb Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 7 Aug 2024 12:20:27 -0500 Subject: [PATCH 19/28] Fix addresses test --- integration_tests/addresses_test.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/integration_tests/addresses_test.go b/integration_tests/addresses_test.go index 9961fcab..f9c9a5d4 100644 --- a/integration_tests/addresses_test.go +++ b/integration_tests/addresses_test.go @@ -2,6 +2,7 @@ package integration_tests import ( "context" + "time" "github.com/ethereum/go-ethereum/common" "github.com/peggyjv/sommelier/v7/x/addresses/types" @@ -32,10 +33,15 @@ func (s *IntegrationTestSuite) TestAddresses() { s.Require().NoError(err) s.T().Log("Testing queries return expected addresses") - queryRes, err := addressesQueryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) - s.Require().NoError(err) - s.Require().Len(queryRes.AddressMappings, 1, "There should be one address mapping") - s.Require().Equal(evmAddress.Hex(), queryRes.AddressMappings[0].EvmAddress, "EVM address does not match") + s.Require().Eventually(func() bool { + queryRes, err := addressesQueryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) + if err != nil { + s.T().Logf("Error querying address mappings: %s", err) + return false + } + + return len(queryRes.AddressMappings) == 1 && evmAddress.Hex() == queryRes.AddressMappings[0].EvmAddress + }, 20*time.Second, 4*time.Second, "address mapping never found") queryByEvmRes, err := addressesQueryClient.QueryAddressMappingByEVMAddress(context.Background(), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddress.Hex()}) s.Require().NoError(err) @@ -55,8 +61,14 @@ func (s *IntegrationTestSuite) TestAddresses() { s.Require().NoError(err) s.T().Log("Testing mappings query returns no addresses") - queryRes, err = addressesQueryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) - s.Require().NoError(err) - s.Require().Len(queryRes.AddressMappings, 0, "There should be no address mappings") + s.Require().Eventually(func() bool { + queryRes, err := addressesQueryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) + if err != nil { + s.T().Logf("Error querying address mappings: %s", err) + return false + } + + return len(queryRes.AddressMappings) == 0 + }, 20*time.Second, 4*time.Second, "address mapping not deleted") }) } From 113970c98f8726eda72421edae2588a0b8e195c0 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 7 Aug 2024 13:04:08 -0500 Subject: [PATCH 20/28] Fix addresses test --- integration_tests/addresses_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/integration_tests/addresses_test.go b/integration_tests/addresses_test.go index f9c9a5d4..fdc7da6b 100644 --- a/integration_tests/addresses_test.go +++ b/integration_tests/addresses_test.go @@ -70,5 +70,13 @@ func (s *IntegrationTestSuite) TestAddresses() { return len(queryRes.AddressMappings) == 0 }, 20*time.Second, 4*time.Second, "address mapping not deleted") + + _, err = addressesQueryClient.QueryAddressMappingByEVMAddress(context.Background(), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: evmAddress.Hex()}) + s.Require().Error(err) + s.Require().Contains(err.Error(), "code = NotFound") + + _, err = addressesQueryClient.QueryAddressMappingByCosmosAddress(context.Background(), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddress.String()}) + s.Require().Error(err) + s.Require().Contains(err.Error(), "code = NotFound") }) } From 7e89e5e90f2952e9e593e5e759819864ce918f8a Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Mon, 19 Aug 2024 14:34:08 -0500 Subject: [PATCH 21/28] Make linter happy --- x/addresses/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/addresses/module.go b/x/addresses/module.go index 8d87b815..cc2edc9a 100644 --- a/x/addresses/module.go +++ b/x/addresses/module.go @@ -157,7 +157,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { // ProposalContents returns all the distribution content functions used to // simulate governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []sim.WeightedProposalContent { +func (am AppModule) ProposalContents(_ module.SimulationState) []sim.WeightedProposalMsg { return nil } From 8e3d78f6a064fadfa66cf710dc94a55252376738 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 25 Sep 2024 13:59:09 -0500 Subject: [PATCH 22/28] Unhappy path integration tests for x/addresses --- integration_tests/addresses_test.go | 62 +++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/integration_tests/addresses_test.go b/integration_tests/addresses_test.go index fdc7da6b..3dc245fa 100644 --- a/integration_tests/addresses_test.go +++ b/integration_tests/addresses_test.go @@ -78,5 +78,67 @@ func (s *IntegrationTestSuite) TestAddresses() { _, err = addressesQueryClient.QueryAddressMappingByCosmosAddress(context.Background(), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddress.String()}) s.Require().Error(err) s.Require().Contains(err.Error(), "code = NotFound") + + // Test error cases + + // Test adding multiple mappings + s.T().Log("Adding multiple mappings") + evmAddress2 := common.HexToAddress("0x2345678901234567890123456789012345678901") + cosmosAddress2 := s.chain.orchestrators[1].address() + orch1 := s.chain.orchestrators[1] + orch1ClientCtx, err := s.chain.clientContext("tcp://localhost:26657", orch1.keyring, "orch", orch1.address()) + s.Require().NoError(err) + + addAddressMappingMsg2, err := types.NewMsgAddAddressMapping(evmAddress2, cosmosAddress2) + s.Require().NoError(err) + + _, err = s.chain.sendMsgs(*orchClientCtx, addAddressMappingMsg) + s.Require().NoError(err) + _, err = s.chain.sendMsgs(*orch1ClientCtx, addAddressMappingMsg2) + s.Require().NoError(err) + + // Query multiple mappings + s.T().Log("Querying multiple mappings") + s.Require().Eventually(func() bool { + queryRes, err := addressesQueryClient.QueryAddressMappings(context.Background(), &types.QueryAddressMappingsRequest{}) + if err != nil { + s.T().Logf("Error querying address mappings: %s", err) + return false + } + + return len(queryRes.AddressMappings) == 2 + }, 20*time.Second, 4*time.Second, "expected two address mappings") + + // Test adding a duplicate mapping + s.T().Log("Adding a duplicate mapping") + duplicateMsg, err := types.NewMsgAddAddressMapping(evmAddress, cosmosAddress) + s.Require().NoError(err) + + _, err = s.chain.sendMsgs(*orchClientCtx, duplicateMsg) + s.Require().NoError(err) + _, err = s.chain.sendMsgs(*orchClientCtx, duplicateMsg) + s.Require().NoError(err) + + // Test removing a non-existent mapping + s.T().Log("Removing a non-existent mapping") + nonExistentAddress := s.chain.orchestrators[2].address() + orch2 := s.chain.orchestrators[2] + orch2ClientCtx, err := s.chain.clientContext("tcp://localhost:26657", orch2.keyring, "orch", orch2.address()) + removeNonExistentMsg, err := types.NewMsgRemoveAddressMapping(nonExistentAddress) + s.Require().NoError(err) + + _, err = s.chain.sendMsgs(*orch2ClientCtx, removeNonExistentMsg) + s.Require().NoError(err) + + // Test querying with invalid addresses + s.T().Log("Querying with invalid addresses") + _, err = addressesQueryClient.QueryAddressMappingByEVMAddress(context.Background(), &types.QueryAddressMappingByEVMAddressRequest{EvmAddress: "invalid"}) + s.Require().Error(err) + s.Require().Contains(err.Error(), "invalid EVM address") + + s.T().Log("Querying with invalid cosmos address") + _, err = addressesQueryClient.QueryAddressMappingByCosmosAddress(context.Background(), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: "invalid"}) + s.Require().Error(err) + s.Require().Contains(err.Error(), "failed to parse cosmos address") }) } From 34fdfc0fe8efee613d2c93b8a28e6032a087b154 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 25 Sep 2024 13:59:25 -0500 Subject: [PATCH 23/28] Unhandled error --- integration_tests/addresses_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integration_tests/addresses_test.go b/integration_tests/addresses_test.go index 3dc245fa..e6688590 100644 --- a/integration_tests/addresses_test.go +++ b/integration_tests/addresses_test.go @@ -124,6 +124,7 @@ func (s *IntegrationTestSuite) TestAddresses() { nonExistentAddress := s.chain.orchestrators[2].address() orch2 := s.chain.orchestrators[2] orch2ClientCtx, err := s.chain.clientContext("tcp://localhost:26657", orch2.keyring, "orch", orch2.address()) + s.Require().NoError(err) removeNonExistentMsg, err := types.NewMsgRemoveAddressMapping(nonExistentAddress) s.Require().NoError(err) From 1673648096f1733e95a538da717e412a8e709eb6 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 25 Sep 2024 16:10:25 -0500 Subject: [PATCH 24/28] Improved keeper unit tests --- x/addresses/keeper/genesis_test.go | 53 ++++++++++++++++++++- x/addresses/keeper/keeper.go | 3 +- x/addresses/keeper/keeper_test.go | 62 +++++++++++++++++++++---- x/addresses/keeper/msg_server_test.go | 11 +++++ x/addresses/keeper/query_server_test.go | 35 ++++++++++++++ x/addresses/types/genesis.go | 14 +++++- x/addresses/types/params.go | 6 +-- 7 files changed, 170 insertions(+), 14 deletions(-) diff --git a/x/addresses/keeper/genesis_test.go b/x/addresses/keeper/genesis_test.go index a9c8b3bf..67ff6d90 100644 --- a/x/addresses/keeper/genesis_test.go +++ b/x/addresses/keeper/genesis_test.go @@ -1,6 +1,10 @@ package keeper -import "github.com/peggyjv/sommelier/v7/x/addresses/types" +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/peggyjv/sommelier/v7/x/addresses/types" +) func (suite *KeeperTestSuite) TestImportExportGenesis() { ctx, addressesKeeper := suite.ctx, suite.addressesKeeper @@ -26,4 +30,51 @@ func (suite *KeeperTestSuite) TestGenesisValidation() { genesis.AddressMappings = types.DefaultGenesisState().AddressMappings genesis.AddressMappings = append(genesis.AddressMappings, &types.AddressMapping{CosmosAddress: cosmosAddrString, EvmAddress: "zzzz"}) require.Error(genesis.Validate()) + + // Test with invalid EVM address + genesis.AddressMappings = []*types.AddressMapping{ + {CosmosAddress: cosmosAddrString, EvmAddress: "invalid_evm_address"}, + } + require.Error(genesis.Validate()) + + // Test with duplicate mappings + genesis.AddressMappings = []*types.AddressMapping{ + {CosmosAddress: cosmosAddrString, EvmAddress: evmAddrString}, + {CosmosAddress: cosmosAddrString, EvmAddress: evmAddrString}, + } + require.Error(genesis.Validate()) + + // Test with empty mappings + genesis.AddressMappings = []*types.AddressMapping{} + require.NoError(genesis.Validate()) +} + +// Add a new test function for InitGenesis +func (suite *KeeperTestSuite) TestInitGenesis() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + genesis := types.GenesisState{ + Params: types.DefaultParams(), + AddressMappings: []*types.AddressMapping{ + {CosmosAddress: cosmosAddrString, EvmAddress: evmAddrString}, + }, + } + + InitGenesis(ctx, addressesKeeper, genesis) + + // Verify that the address mapping was set + evmAddr := common.HexToAddress(evmAddrString).Bytes() + cosmosAddr, err := sdk.AccAddressFromBech32(cosmosAddrString) + require.NoError(err) + + result := addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + require.Equal(cosmosAddr.Bytes(), result) + + result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr.Bytes()) + require.Equal(evmAddr, result) + + // Verify that params were set + params := addressesKeeper.GetParamSet(ctx) + require.Equal(genesis.Params, params) } diff --git a/x/addresses/keeper/keeper.go b/x/addresses/keeper/keeper.go index c8530ca0..c798e086 100644 --- a/x/addresses/keeper/keeper.go +++ b/x/addresses/keeper/keeper.go @@ -97,8 +97,9 @@ func (k Keeper) DeleteAddressMapping(ctx sdk.Context, cosmosAddr []byte) error { } evmAddr := k.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) + if len(evmAddr) == 0 { - return errorsmod.Wrap(types.ErrNilEvmAddress, "evm address cannot be empty") + return nil } k.deleteEvmToCosmosMapping(ctx, evmAddr) diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index 69cef53e..f16ad6e7 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -13,6 +13,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/peggyjv/sommelier/v7/testutil" + "github.com/peggyjv/sommelier/v7/x/addresses/types" addressTypes "github.com/peggyjv/sommelier/v7/x/addresses/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -106,7 +107,8 @@ func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() { cosmosAddr := acc.Bytes() // Set - addressesKeeper.SetAddressMapping(ctx, cosmosAddr, evmAddr) + err = addressesKeeper.SetAddressMapping(ctx, cosmosAddr, evmAddr) + require.NoError(err) // Get cosmosResult := addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) @@ -127,14 +129,58 @@ func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() { return false }) - // Delete - addressesKeeper.DeleteAddressMapping(ctx, cosmosAddr) + // Invalid input + err = addressesKeeper.SetAddressMapping(ctx, nil, evmAddr) + require.Error(err) + + // Test setting multiple mappings + evmAddr2 := common.HexToAddress("0x2222222222222222222222222222222222222222").Bytes() + cosmosAddr2, _ := sdk.AccAddressFromBech32("cosmos1y6d5kasehecexf09ka6y0ggl0pxzt6dgk0gnl9") + + err = addressesKeeper.SetAddressMapping(ctx, cosmosAddr2, evmAddr2) + require.NoError(err) + + // Verify second mapping exists + result := addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr2) + require.Equal(cosmosAddr2.Bytes(), result) + + result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr2) + require.Equal(evmAddr2, result) + + // Test deleting one mapping + err = addressesKeeper.DeleteAddressMapping(ctx, cosmosAddr) + require.NoError(err) - cosmosResult = addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + // Verify the deleted mapping is gone but the other remains + result = addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr) + require.Nil(result) + result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) + require.Nil(result) + + result = addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr2) + require.Equal(cosmosAddr2.Bytes(), result) + result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr2) + require.Equal(evmAddr2, result) + + // Test IterateAddressMappings + var mappings2 []*types.AddressMapping + addressesKeeper.IterateAddressMappings(ctx, func(cosmosAddr []byte, evmAddr []byte) bool { + mappings2 = append(mappings2, &types.AddressMapping{ + CosmosAddress: sdk.AccAddress(cosmosAddr).String(), + EvmAddress: common.BytesToAddress(evmAddr).Hex(), + }) + return false + }) + require.Len(mappings2, 1) + require.Equal(cosmosAddr2.String(), mappings2[0].CosmosAddress) + require.Equal(common.BytesToAddress(evmAddr2).Hex(), mappings2[0].EvmAddress) + + // Delete second mapping + err = addressesKeeper.DeleteAddressMapping(ctx, cosmosAddr2) + require.NoError(err) + + cosmosResult = addressesKeeper.GetCosmosAddressByEvmAddress(ctx, evmAddr2) require.Nil(cosmosResult) - evmResult = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr) + evmResult = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, cosmosAddr2) require.Nil(evmResult) - - // Invalid input - addressesKeeper.SetAddressMapping(ctx, nil, evmAddr) } diff --git a/x/addresses/keeper/msg_server_test.go b/x/addresses/keeper/msg_server_test.go index 952bd64a..9f363b36 100644 --- a/x/addresses/keeper/msg_server_test.go +++ b/x/addresses/keeper/msg_server_test.go @@ -69,6 +69,17 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForMsgServer() { result = addressesKeeper.GetEvmAddressByCosmosAddress(ctx, sdk.AccAddress(result).Bytes()) require.Nil(result) + // Test adding a mapping for an already mapped Cosmos address + _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: evmAddrString}) + require.NoError(err) + + _, err = addressesKeeper.AddAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgAddAddressMapping{Signer: cosmosAddrString, EvmAddress: "0x2222222222222222222222222222222222222222"}) + require.NoError(err) + + // Test removing a non-existent mapping + _, err = addressesKeeper.RemoveAddressMapping(sdk.WrapSDKContext(ctx), &types.MsgRemoveAddressMapping{Signer: "cosmos1y6d5kasehecexf09ka6y0ggl0pxzt6dgk0gnl9"}) + require.NoError(err) + // Test RemoveAddressMapping _, err = sdk.AccAddressFromBech32(cosmosAddrStringInvalid) require.Error(err) diff --git a/x/addresses/keeper/query_server_test.go b/x/addresses/keeper/query_server_test.go index f4c7f10e..2367c2b0 100644 --- a/x/addresses/keeper/query_server_test.go +++ b/x/addresses/keeper/query_server_test.go @@ -1,6 +1,9 @@ package keeper import ( + "fmt" + "strings" + sdk "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" "github.com/ethereum/go-ethereum/common" @@ -127,4 +130,36 @@ func (suite *KeeperTestSuite) TestUnhappyPathsForQueryServer() { _, err = addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: cosmosAddrString}) require.Error(err) require.Contains(err.Error(), "no EVM address mapping for cosmos address") + + // Test QueryAddressMappings with invalid pagination + _, err = addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{Pagination: query.PageRequest{Limit: 0, Offset: 1}}) + require.NoError(err) + + // Test QueryAddressMappings with no results + addressMappings, err := addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 0) +} + +// Edge cases test for query server functions +func (suite *KeeperTestSuite) TestQueryServerEdgeCases() { + ctx, addressesKeeper := suite.ctx, suite.addressesKeeper + require := suite.Require() + + // Test with maximum number of address mappings + for i := 0; i < 1000; i++ { + cosmosAddr := sdk.AccAddress([]byte(fmt.Sprintf("cosmos%d", i))) + evmAddr := common.HexToAddress(fmt.Sprintf("0x%040d", i)) + addressesKeeper.SetAddressMapping(ctx, cosmosAddr, evmAddr.Bytes()) + } + + addressMappings, err := addressesKeeper.QueryAddressMappings(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingsRequest{Pagination: query.PageRequest{Limit: 1000}}) + require.NoError(err) + require.Len(addressMappings.AddressMappings, 1000) + + // Test with very long Cosmos address (edge case, might not be valid in practice) + longCosmosAddr := "cosmos" + strings.Repeat("1", 100) + _, err = addressesKeeper.QueryAddressMappingByCosmosAddress(sdk.WrapSDKContext(ctx), &types.QueryAddressMappingByCosmosAddressRequest{CosmosAddress: longCosmosAddr}) + require.Error(err) + require.Contains(err.Error(), "failed to parse cosmos address") } diff --git a/x/addresses/types/genesis.go b/x/addresses/types/genesis.go index 370b5f07..13ce6932 100644 --- a/x/addresses/types/genesis.go +++ b/x/addresses/types/genesis.go @@ -1,5 +1,7 @@ package types +import fmt "fmt" + // DefaultIndex is the default global index const DefaultIndex uint64 = 1 @@ -14,12 +16,22 @@ func DefaultGenesisState() GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // gs.Params.ValidateBasic() + if err := gs.Params.ValidateBasic(); err != nil { + return err + } + seenMappings := make(map[string]string) for _, mapping := range gs.AddressMappings { if err := mapping.ValidateBasic(); err != nil { return err } + + // Check for duplicate mappings + key := mapping.CosmosAddress + "|" + mapping.EvmAddress + if _, exists := seenMappings[key]; exists { + return fmt.Errorf("duplicate address mapping found: %s", key) + } + seenMappings[key] = "" } return nil diff --git a/x/addresses/types/params.go b/x/addresses/types/params.go index e61c8c15..7cfc4e7f 100644 --- a/x/addresses/types/params.go +++ b/x/addresses/types/params.go @@ -28,6 +28,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } // Validate validates the set of params -// func (p Params) ValidateBasic() error { -// return nil -// } +func (p Params) ValidateBasic() error { + return nil +} From 8ac8e30160e44dc0e16172825c6b0e2fa8e80389 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Wed, 25 Sep 2024 16:38:16 -0500 Subject: [PATCH 25/28] More unit tests --- x/addresses/types/addresses_test.go | 59 +++++++++ x/addresses/types/genesis_test.go | 178 +++++++++++++++++++++++++++- x/addresses/types/msgs.go | 20 +++- x/addresses/types/msgs_test.go | 106 ++++++++++++++++- 4 files changed, 347 insertions(+), 16 deletions(-) create mode 100644 x/addresses/types/addresses_test.go diff --git a/x/addresses/types/addresses_test.go b/x/addresses/types/addresses_test.go new file mode 100644 index 00000000..8acf6f66 --- /dev/null +++ b/x/addresses/types/addresses_test.go @@ -0,0 +1,59 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAddressMapping_ValidateBasic(t *testing.T) { + tests := []struct { + name string + mapping AddressMapping + wantErr bool + }{ + { + name: "valid mapping", + mapping: AddressMapping{ + CosmosAddress: "cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu", + EvmAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", + }, + wantErr: false, + }, + { + name: "invalid cosmos address", + mapping: AddressMapping{ + CosmosAddress: "invalid", + EvmAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", + }, + wantErr: true, + }, + { + name: "invalid evm address", + mapping: AddressMapping{ + CosmosAddress: "cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu", + EvmAddress: "invalid", + }, + wantErr: true, + }, + { + name: "both addresses invalid", + mapping: AddressMapping{ + CosmosAddress: "invalid", + EvmAddress: "invalid", + }, + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.mapping.ValidateBasic() + if tt.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/addresses/types/genesis_test.go b/x/addresses/types/genesis_test.go index 8a14134b..deb163e1 100644 --- a/x/addresses/types/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -23,14 +23,180 @@ func TestGenesisState_Validate(t *testing.T) { genState: &GenesisState{}, valid: true, }, + { + desc: "invalid address mapping - invalid cosmos address", + genState: &GenesisState{ + AddressMappings: []*AddressMapping{ + { + CosmosAddress: "invalid_cosmos_address", + EvmAddress: "0x1234567890123456789012345678901234567890", + }, + }, + }, + valid: false, + }, + { + desc: "invalid address mapping - invalid evm address", + genState: &GenesisState{ + AddressMappings: []*AddressMapping{ + { + CosmosAddress: cosmosAddress1, + EvmAddress: "invalid_evm_address", + }, + }, + }, + valid: false, + }, + { + desc: "duplicate address mappings", + genState: &GenesisState{ + AddressMappings: []*AddressMapping{ + { + CosmosAddress: cosmosAddress1, + EvmAddress: "0x1234567890123456789012345678901234567890", + }, + { + CosmosAddress: cosmosAddress1, + EvmAddress: "0x1234567890123456789012345678901234567890", + }, + }, + }, + valid: false, + }, + { + desc: "duplicate cosmos address", + genState: &GenesisState{ + AddressMappings: []*AddressMapping{ + { + CosmosAddress: cosmosAddress1, + EvmAddress: "0x1234567890123456789012345678901234567890", + }, + { + CosmosAddress: cosmosAddress1, + EvmAddress: "0x0987654321098765432109876543210987654321", + }, + }, + }, + valid: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} + +func TestValidateGenesis(t *testing.T) { + testCases := []struct { + desc string + genState GenesisState + valid bool + }{ + { + desc: "default genesis state", + genState: DefaultGenesisState(), + valid: true, + }, + { + desc: "custom genesis state", + genState: GenesisState{ + Params: DefaultParams(), + AddressMappings: []*AddressMapping{ + { + CosmosAddress: "cosmos1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnrql8a", + EvmAddress: "0x1234567890123456789012345678901234567890", + }, + }, + }, + valid: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} + +func TestDefaultGenesisState(t *testing.T) { + defaultGenesis := DefaultGenesisState() + require.NotNil(t, defaultGenesis.Params) + require.Equal(t, DefaultParams(), defaultGenesis.Params) + require.Empty(t, defaultGenesis.AddressMappings) +} + +func TestGenesisState_ValidateAddressMappings(t *testing.T) { + testCases := []struct { + desc string + mappings []*AddressMapping + valid bool + }{ + { + desc: "empty mappings", + mappings: []*AddressMapping{}, + valid: true, + }, + { + desc: "valid mappings", + mappings: []*AddressMapping{ + { + CosmosAddress: cosmosAddress1, + EvmAddress: "0x1234567890123456789012345678901234567890", + }, + { + CosmosAddress: cosmosAddress2, + EvmAddress: "0x0987654321098765432109876543210987654321", + }, + }, + valid: true, + }, + { + desc: "invalid cosmos address", + mappings: []*AddressMapping{ + { + CosmosAddress: "invalid_cosmos_address", + EvmAddress: "0x1234567890123456789012345678901234567890", + }, + }, + valid: false, + }, + { + desc: "invalid evm address", + mappings: []*AddressMapping{ + { + CosmosAddress: cosmosAddress1, + EvmAddress: "invalid_evm_address", + }, + }, + valid: false, + }, } for _, tc := range testCases { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } + t.Run(tc.desc, func(t *testing.T) { + genState := GenesisState{ + Params: DefaultParams(), + AddressMappings: tc.mappings, + } + err := genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) } } diff --git a/x/addresses/types/msgs.go b/x/addresses/types/msgs.go index 7b991e79..c54f0361 100644 --- a/x/addresses/types/msgs.go +++ b/x/addresses/types/msgs.go @@ -23,10 +23,16 @@ const ( // NewMsgAddAddressMapping return a new MsgAddAddressMapping func NewMsgAddAddressMapping(evmAddres common.Address, signer sdk.AccAddress) (*MsgAddAddressMapping, error) { - return &MsgAddAddressMapping{ + msg := &MsgAddAddressMapping{ EvmAddress: evmAddres.Hex(), Signer: signer.String(), - }, nil + } + + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + + return msg, nil } // Route implements sdk.Msg @@ -73,9 +79,15 @@ func (m *MsgAddAddressMapping) MustGetSigner() sdk.AccAddress { // NewMsgRemoveAddressMapping return a new MsgRemoveAddressMapping func NewMsgRemoveAddressMapping(signer sdk.AccAddress) (*MsgRemoveAddressMapping, error) { - return &MsgRemoveAddressMapping{ + msg := &MsgRemoveAddressMapping{ Signer: signer.String(), - }, nil + } + + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + + return msg, nil } // Route implements sdk.Msg diff --git a/x/addresses/types/msgs_test.go b/x/addresses/types/msgs_test.go index 3d3da94a..b0848ab8 100644 --- a/x/addresses/types/msgs_test.go +++ b/x/addresses/types/msgs_test.go @@ -13,6 +13,8 @@ import ( const ( evmAddress1 = "0x1111111111111111111111111111111111111111" cosmosAddress1 = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" + evmAddress2 = "0x2222222222222222222222222222222222222222" + cosmosAddress2 = "cosmos1y6d5kasehecexf09ka6y0ggl0pxzt6dgk0gnl9" ) func TestNewMsgAddAddressMappingFormatting(t *testing.T) { @@ -24,8 +26,13 @@ func TestNewMsgAddAddressMappingFormatting(t *testing.T) { cosmosAccount1, err := sdk.AccAddressFromBech32(cosmosAddress1) require.NoError(t, err) createdMsg, err := NewMsgAddAddressMapping(common.HexToAddress(evmAddress1), cosmosAccount1) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, expectedMsg, createdMsg) + + // Test with nil Cosmos address + _, err = NewMsgAddAddressMapping(common.HexToAddress(evmAddress1), nil) + require.Error(t, err) + require.Contains(t, err.Error(), "invalid address") } func TestMsgAddAddressMappingValidate(t *testing.T) { @@ -62,16 +69,33 @@ func TestMsgAddAddressMappingValidate(t *testing.T) { expPass: false, err: errorsmod.Wrap(ErrInvalidEvmAddress, "lasjfdlsdf is not a valid hex address"), }, + { + name: "Empty EVM address", + msgAddAddressMapping: MsgAddAddressMapping{ + EvmAddress: "", + Signer: cosmosAddress1, + }, + expPass: false, + err: errorsmod.Wrap(ErrInvalidEvmAddress, " is not a valid hex address"), + }, + { + name: "Empty signer address", + msgAddAddressMapping: MsgAddAddressMapping{ + EvmAddress: evmAddress1, + Signer: "", + }, + expPass: false, + err: errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "empty address string is not allowed"), + }, } for _, tc := range testCases { err := tc.msgAddAddressMapping.ValidateBasic() if tc.expPass { require.NoError(t, err, tc.name) - require.Nil(t, err) } else { require.Error(t, err, tc.name) - require.Equal(t, tc.err.Error(), err.Error()) + require.Equal(t, tc.err.Error(), err.Error(), tc.name) } } } @@ -84,8 +108,13 @@ func TestNewMsgRemoveAddressMappingFormatting(t *testing.T) { cosmosAccount1, err := sdk.AccAddressFromBech32(cosmosAddress1) require.NoError(t, err) createdMsg, err := NewMsgRemoveAddressMapping(cosmosAccount1) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, expectedMsg, createdMsg) + + // Test with nil Cosmos address + _, err = NewMsgRemoveAddressMapping(nil) + require.Error(t, err) + require.Contains(t, err.Error(), "invalid address") } func TestMsgRemoveAddressMappingValidate(t *testing.T) { @@ -111,16 +140,81 @@ func TestMsgRemoveAddressMappingValidate(t *testing.T) { expPass: false, err: errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "decoding bech32 failed: invalid separator index -1"), }, + { + name: "Empty signer address", + msgRemoveAddressMapping: MsgRemoveAddressMapping{ + Signer: "", + }, + expPass: false, + err: errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "empty address string is not allowed"), + }, } for _, tc := range testCases { err := tc.msgRemoveAddressMapping.ValidateBasic() if tc.expPass { require.NoError(t, err, tc.name) - require.Nil(t, err) } else { require.Error(t, err, tc.name) - require.Equal(t, tc.err.Error(), err.Error()) + require.Equal(t, tc.err.Error(), err.Error(), tc.name) } } } + +func TestMsgAddAddressMappingGetSigners(t *testing.T) { + msg := MsgAddAddressMapping{ + EvmAddress: evmAddress1, + Signer: cosmosAddress1, + } + + signers := msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, cosmosAddress1, signers[0].String()) + + // Test with invalid signer address + msg.Signer = "invalid_address" + require.Panics(t, func() { msg.GetSigners() }) +} + +func TestMsgRemoveAddressMappingGetSigners(t *testing.T) { + msg := MsgRemoveAddressMapping{ + Signer: cosmosAddress1, + } + + signers := msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, cosmosAddress1, signers[0].String()) + + // Test with invalid signer address + msg.Signer = "invalid_address" + require.Panics(t, func() { msg.GetSigners() }) +} + +func TestMsgAddAddressMappingType(t *testing.T) { + msg := MsgAddAddressMapping{} + require.Equal(t, "add_address_mapping", msg.Type()) +} + +func TestMsgRemoveAddressMappingType(t *testing.T) { + msg := MsgRemoveAddressMapping{} + require.Equal(t, "remove_address_mapping", msg.Type()) +} + +func TestMsgAddAddressMappingGetSignBytes(t *testing.T) { + msg := MsgAddAddressMapping{ + EvmAddress: evmAddress1, + Signer: cosmosAddress1, + } + + signBytes := msg.GetSignBytes() + require.NotEmpty(t, signBytes) +} + +func TestMsgRemoveAddressMappingGetSignBytes(t *testing.T) { + msg := MsgRemoveAddressMapping{ + Signer: cosmosAddress1, + } + + signBytes := msg.GetSignBytes() + require.NotEmpty(t, signBytes) +} From eb632ddb3ef09af357894da51f655b6d3737f02f Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Thu, 26 Sep 2024 08:13:35 -0500 Subject: [PATCH 26/28] Make CI linter happy --- x/addresses/keeper/keeper_test.go | 21 +++++++++---------- x/addresses/types/genesis_test.go | 3 +++ x/addresses/types/msgs_test.go | 35 ++++++++++++++++++------------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/x/addresses/keeper/keeper_test.go b/x/addresses/keeper/keeper_test.go index f16ad6e7..9a4b8f34 100644 --- a/x/addresses/keeper/keeper_test.go +++ b/x/addresses/keeper/keeper_test.go @@ -14,7 +14,6 @@ import ( moduletestutil "github.com/peggyjv/sommelier/v7/testutil" "github.com/peggyjv/sommelier/v7/x/addresses/types" - addressTypes "github.com/peggyjv/sommelier/v7/x/addresses/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtime "github.com/cometbft/cometbft/types/time" @@ -33,13 +32,13 @@ type KeeperTestSuite struct { ctx sdk.Context addressesKeeper Keeper - queryClient addressTypes.QueryClient + queryClient types.QueryClient encCfg moduletestutil.TestEncodingConfig } func (suite *KeeperTestSuite) SetupTest() { - key := sdk.NewKVStoreKey(addressTypes.StoreKey) + key := sdk.NewKVStoreKey(types.StoreKey) tkey := sdk.NewTransientStoreKey("transient_test") testCtx := testutil.DefaultContext(key, tkey) ctx := testCtx.WithBlockHeader(tmproto.Header{Height: 5, Time: tmtime.Now()}) @@ -58,8 +57,8 @@ func (suite *KeeperTestSuite) SetupTest() { tkey, ) - params.Subspace(addressTypes.ModuleName) - subSpace, found := params.GetSubspace(addressTypes.ModuleName) + params.Subspace(types.ModuleName) + subSpace, found := params.GetSubspace(types.ModuleName) suite.Assertions.True(found) suite.addressesKeeper = *NewKeeper( @@ -68,11 +67,11 @@ func (suite *KeeperTestSuite) SetupTest() { subSpace, ) - addressTypes.RegisterInterfaces(encCfg.InterfaceRegistry) + types.RegisterInterfaces(encCfg.InterfaceRegistry) queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry) - addressTypes.RegisterQueryServer(queryHelper, suite.addressesKeeper) - queryClient := addressTypes.NewQueryClient(queryHelper) + types.RegisterQueryServer(queryHelper, suite.addressesKeeper) + queryClient := types.NewQueryClient(queryHelper) suite.queryClient = queryClient suite.encCfg = encCfg @@ -86,7 +85,7 @@ func (suite *KeeperTestSuite) TestSetGetDeleteParams() { ctx, addressesKeeper := suite.ctx, suite.addressesKeeper require := suite.Require() - params := addressTypes.DefaultParams() + params := types.DefaultParams() addressesKeeper.setParams(ctx, params) retrievedParams := addressesKeeper.GetParamSet(ctx) @@ -118,9 +117,9 @@ func (suite *KeeperTestSuite) TestSetGetDeleteAddressMappings() { require.Equal(evmAddr, evmResult) // Iterate - var mappings []*addressTypes.AddressMapping + var mappings []*types.AddressMapping addressesKeeper.IterateAddressMappings(ctx, func(cosmosAddr []byte, evmAddr []byte) (stop bool) { - mapping := addressTypes.AddressMapping{ + mapping := types.AddressMapping{ CosmosAddress: sdk.MustBech32ifyAddressBytes("cosmos", cosmosAddr), EvmAddress: common.BytesToAddress(evmAddr).Hex(), } diff --git a/x/addresses/types/genesis_test.go b/x/addresses/types/genesis_test.go index deb163e1..9a66fc58 100644 --- a/x/addresses/types/genesis_test.go +++ b/x/addresses/types/genesis_test.go @@ -82,6 +82,7 @@ func TestGenesisState_Validate(t *testing.T) { } for _, tc := range testCases { + tc := tc // create a local copy t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { @@ -120,6 +121,7 @@ func TestValidateGenesis(t *testing.T) { } for _, tc := range testCases { + tc := tc // create a local copy t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { @@ -186,6 +188,7 @@ func TestGenesisState_ValidateAddressMappings(t *testing.T) { } for _, tc := range testCases { + tc := tc // create a local copy t.Run(tc.desc, func(t *testing.T) { genState := GenesisState{ Params: DefaultParams(), diff --git a/x/addresses/types/msgs_test.go b/x/addresses/types/msgs_test.go index b0848ab8..f763d99d 100644 --- a/x/addresses/types/msgs_test.go +++ b/x/addresses/types/msgs_test.go @@ -13,7 +13,6 @@ import ( const ( evmAddress1 = "0x1111111111111111111111111111111111111111" cosmosAddress1 = "cosmos154d0p9xhrruhxvazumej9nq29afeura2alje4u" - evmAddress2 = "0x2222222222222222222222222222222222222222" cosmosAddress2 = "cosmos1y6d5kasehecexf09ka6y0ggl0pxzt6dgk0gnl9" ) @@ -90,13 +89,16 @@ func TestMsgAddAddressMappingValidate(t *testing.T) { } for _, tc := range testCases { - err := tc.msgAddAddressMapping.ValidateBasic() - if tc.expPass { - require.NoError(t, err, tc.name) - } else { - require.Error(t, err, tc.name) - require.Equal(t, tc.err.Error(), err.Error(), tc.name) - } + tc := tc // create a local copy + t.Run(tc.name, func(t *testing.T) { + err := tc.msgAddAddressMapping.ValidateBasic() + if tc.expPass { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + require.Equal(t, tc.err.Error(), err.Error(), tc.name) + } + }) } } @@ -151,13 +153,16 @@ func TestMsgRemoveAddressMappingValidate(t *testing.T) { } for _, tc := range testCases { - err := tc.msgRemoveAddressMapping.ValidateBasic() - if tc.expPass { - require.NoError(t, err, tc.name) - } else { - require.Error(t, err, tc.name) - require.Equal(t, tc.err.Error(), err.Error(), tc.name) - } + tc := tc // create a local copy + t.Run(tc.name, func(t *testing.T) { + err := tc.msgRemoveAddressMapping.ValidateBasic() + if tc.expPass { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + require.Equal(t, tc.err.Error(), err.Error(), tc.name) + } + }) } } From 31434447e95d8dabd1e5e2ead49f7982c57b0f9a Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Thu, 26 Sep 2024 08:46:56 -0500 Subject: [PATCH 27/28] more linter stuff --- x/addresses/types/addresses_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/x/addresses/types/addresses_test.go b/x/addresses/types/addresses_test.go index 8acf6f66..15e45ced 100644 --- a/x/addresses/types/addresses_test.go +++ b/x/addresses/types/addresses_test.go @@ -44,9 +44,34 @@ func TestAddressMapping_ValidateBasic(t *testing.T) { }, wantErr: true, }, + { + name: "empty cosmos address", + mapping: AddressMapping{ + CosmosAddress: "", + EvmAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", + }, + wantErr: true, + }, + { + name: "empty evm address", + mapping: AddressMapping{ + CosmosAddress: "cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu", + EvmAddress: "", + }, + wantErr: true, + }, + { + name: "both addresses empty", + mapping: AddressMapping{ + CosmosAddress: "", + EvmAddress: "", + }, + wantErr: true, + }, } for _, tt := range tests { + tt := tt // create a local copy t.Run(tt.name, func(t *testing.T) { err := tt.mapping.ValidateBasic() if tt.wantErr { From cf334d542a121329f1cbeee51d254de7857bb7c4 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Mon, 7 Oct 2024 14:07:28 -0500 Subject: [PATCH 28/28] Update proto-builder image version, and add missing directives to x/addresses protos --- Makefile | 4 +- proto/addresses/v1/query.proto | 6 ++- proto/addresses/v1/tx.proto | 8 ++++ proto/buf.lock | 4 +- x/addresses/types/query.pb.go | 80 ++++++++++++++++--------------- x/addresses/types/tx.pb.go | 38 ++++++++------- x/auction/types/query.pb.go | 1 + x/auction/types/tx.pb.go | 1 + x/axelarcork/types/query.pb.go | 1 + x/axelarcork/types/tx.pb.go | 1 + x/cellarfees/types/v1/query.pb.go | 1 + x/cellarfees/types/v2/query.pb.go | 1 + x/cork/types/v2/query.pb.go | 1 + x/cork/types/v2/tx.pb.go | 1 + x/incentives/types/query.pb.go | 1 + x/pubsub/types/query.pb.go | 1 + x/pubsub/types/tx.pb.go | 1 + 17 files changed, 90 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index 7e343072..314f45e1 100644 --- a/Makefile +++ b/Makefile @@ -211,12 +211,12 @@ test-docker-push: test-docker ############################################################################### ### Protobuf ### ############################################################################### -protoVer=0.13.1 +protoVer=0.15.1 protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) proto-all: proto-format proto-lint proto-gen - + proto-gen: @echo "Generating Protobuf files" # todo: figure out why this old method was failing diff --git a/proto/addresses/v1/query.proto b/proto/addresses/v1/query.proto index e54f354e..f85fe617 100644 --- a/proto/addresses/v1/query.proto +++ b/proto/addresses/v1/query.proto @@ -7,24 +7,28 @@ import "addresses/v1/genesis.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; - +import "cosmos/query/v1/query.proto"; option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types"; service Query { rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) { + option (cosmos.query.v1.module_query_safe) = true; option (google.api.http).get = "/sommelier/addresses/v1/params"; } rpc QueryAddressMappings(QueryAddressMappingsRequest) returns (QueryAddressMappingsResponse) { + option (cosmos.query.v1.module_query_safe) = true; option (google.api.http).get = "/sommelier/addresses/v1/address_mappings"; } rpc QueryAddressMappingByEVMAddress(QueryAddressMappingByEVMAddressRequest) returns (QueryAddressMappingByEVMAddressResponse) { + option (cosmos.query.v1.module_query_safe) = true; option (google.api.http).get = "/sommelier/addresses/v1/address_mappings/evm/{evm_address}"; } rpc QueryAddressMappingByCosmosAddress(QueryAddressMappingByCosmosAddressRequest) returns (QueryAddressMappingByCosmosAddressResponse) { + option (cosmos.query.v1.module_query_safe) = true; option (google.api.http).get = "/sommelier/addresses/v1/address_mappings/cosmos/{cosmos_address}"; } } diff --git a/proto/addresses/v1/tx.proto b/proto/addresses/v1/tx.proto index 05726a86..fe5c9733 100644 --- a/proto/addresses/v1/tx.proto +++ b/proto/addresses/v1/tx.proto @@ -1,9 +1,13 @@ syntax = "proto3"; package addresses.v1; +import "cosmos/msg/v1/msg.proto"; + option go_package = "github.com/peggyjv/sommelier/v7/x/addresses/types"; service Msg { + option (cosmos.msg.v1.service) = true; + // Adds a mapping between the cosmos address of the sender and the provided EVM address rpc AddAddressMapping (MsgAddAddressMapping) returns (MsgAddAddressMappingResponse); // Removes the mapping containing the cosmos address of the sender @@ -11,6 +15,8 @@ service Msg { } message MsgAddAddressMapping { + option (cosmos.msg.v1.signer) = "signer"; + string evm_address = 1; string signer = 2; } @@ -18,6 +24,8 @@ message MsgAddAddressMapping { message MsgAddAddressMappingResponse {} message MsgRemoveAddressMapping { + option (cosmos.msg.v1.signer) = "signer"; + string signer = 1; } diff --git a/proto/buf.lock b/proto/buf.lock index 225c0038..1c91f923 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -19,5 +19,5 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 8bc2c51e08c447cd8886cdea48a73e14 - digest: shake256:a969155953a5cedc5b2df5b42c368f2bc66ff8ce1804bc96e0f14ff2ee8a893687963058909df844d1643cdbc98ff099d2daa6bc9f9f5b8886c49afdc60e19af + commit: e7f8d366f5264595bcc4cd4139af9973 + digest: shake256:e5e5f1c12f82e028ea696faa43b4f9dc6258a6d1226282962a8c8b282e10946281d815884f574bd279ebd9cd7588629beb3db17b892af6c33b56f92f8f67f509 diff --git a/x/addresses/types/query.pb.go b/x/addresses/types/query.pb.go index 7086a905..19a761cb 100644 --- a/x/addresses/types/query.pb.go +++ b/x/addresses/types/query.pb.go @@ -424,45 +424,46 @@ func init() { func init() { proto.RegisterFile("addresses/v1/query.proto", fileDescriptor_ebe10bad8a6f145d) } var fileDescriptor_ebe10bad8a6f145d = []byte{ - // 600 bytes of a gzipped FileDescriptorProto - 0x1f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e1, 0xd4, 0x2a, 0x7c, 0x9f, 0x5a, 0x85, 0x57, 0x2d, 0xe6, 0x86, 0xaf, 0x47, - 0x7d, 0x67, 0x9b, 0x7b, 0x38, 0xa0, 0x8c, 0x8d, 0xdf, 0x44, 0x09, 0xb7, 0x68, 0x1d, 0xbf, 0x4b, - 0x58, 0x86, 0xe3, 0x80, 0x8a, 0xfe, 0x8a, 0xfc, 0xf7, 0xb8, 0xf5, 0x3b, 0x00, 0x00, 0xff, 0xff, - 0xac, 0x9f, 0x00, 0x3a, 0x01, 0x07, 0x00, 0x00, + // 618 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x6b, 0x13, 0x41, + 0x18, 0xc6, 0x33, 0xd1, 0x16, 0x7c, 0xe3, 0x3f, 0xc6, 0x1c, 0xc2, 0x36, 0x6c, 0xe2, 0x82, 0x6d, + 0x1a, 0x65, 0x87, 0x44, 0x4b, 0x45, 0x3c, 0x68, 0x8a, 0x14, 0xd1, 0x40, 0xcd, 0xc1, 0x83, 0x97, + 0x32, 0x69, 0x87, 0x71, 0xb5, 0xbb, 0xb3, 0xc9, 0x6c, 0x16, 0x43, 0x29, 0x82, 0x27, 0x8f, 0x82, + 0x5f, 0xc1, 0x0f, 0xe0, 0xc9, 0xcf, 0xd0, 0x63, 0xc1, 0x83, 0x9e, 0x44, 0x12, 0xd1, 0xbb, 0x9f, + 0x40, 0xb2, 0x3b, 0x6b, 0x76, 0xd3, 0xd5, 0x6c, 0xa1, 0xb7, 0xcd, 0xcc, 0x33, 0xef, 0xf3, 0x7b, + 0x86, 0xf7, 0xcd, 0x40, 0x89, 0xee, 0xee, 0xf6, 0x99, 0x94, 0x4c, 0x12, 0xbf, 0x41, 0x7a, 0x03, + 0xd6, 0x1f, 0x9a, 0x6e, 0x5f, 0x78, 0x02, 0x9f, 0xff, 0xbb, 0x63, 0xfa, 0x0d, 0xad, 0x9c, 0xd0, + 0x4d, 0xb7, 0x02, 0xad, 0xa6, 0x25, 0x76, 0x39, 0x73, 0x98, 0xb4, 0xa2, 0xbd, 0x22, 0x17, 0x5c, + 0x04, 0x9f, 0x64, 0xf2, 0xa5, 0x56, 0xcb, 0x5c, 0x08, 0xbe, 0xc7, 0x08, 0x75, 0x2d, 0x42, 0x1d, + 0x47, 0x78, 0xd4, 0xb3, 0x84, 0x13, 0x9d, 0xa9, 0xef, 0x08, 0x69, 0x0b, 0x49, 0xba, 0x54, 0xb2, + 0x10, 0x8a, 0xf8, 0x8d, 0x2e, 0xf3, 0x68, 0x83, 0xb8, 0x94, 0x5b, 0x4e, 0x20, 0x56, 0xda, 0x25, + 0xa5, 0x8d, 0x64, 0xf1, 0x10, 0x46, 0x11, 0xf0, 0x93, 0xc9, 0xcf, 0x2d, 0xda, 0xa7, 0xb6, 0xec, + 0xb0, 0xde, 0x80, 0x49, 0xcf, 0xd8, 0x80, 0x2b, 0x89, 0x55, 0xe9, 0x0a, 0x47, 0x32, 0x7c, 0x03, + 0x16, 0xdd, 0x60, 0xa5, 0x84, 0xaa, 0xa8, 0x56, 0x68, 0x16, 0xcd, 0xf8, 0x15, 0x98, 0x4a, 0xad, + 0x34, 0xc6, 0x4b, 0x58, 0x0a, 0x8a, 0xdc, 0x0f, 0x35, 0x6d, 0xea, 0xba, 0x96, 0xc3, 0x23, 0x0f, + 0xfc, 0x18, 0x60, 0x8a, 0xaa, 0x0a, 0x2e, 0x9b, 0x21, 0xab, 0x39, 0xc9, 0x65, 0x86, 0x9c, 0x2a, + 0x97, 0xb9, 0x45, 0x39, 0x53, 0x67, 0x5b, 0x67, 0x0f, 0xbf, 0x55, 0x72, 0x9d, 0xd8, 0x79, 0xe3, + 0x13, 0x82, 0x72, 0xba, 0x9b, 0x62, 0xdf, 0x84, 0xcb, 0x0a, 0x76, 0xdb, 0x56, 0x7b, 0x25, 0x54, + 0x3d, 0x53, 0x2b, 0x34, 0xcb, 0xc9, 0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74, 0x6d, 0xed, + 0x84, 0xa7, 0x54, 0x8e, 0xcd, 0x69, 0x8e, 0xbb, 0xf8, 0x4e, 0xd6, 0x1c, 0x84, 0xf9, 0x36, 0xd9, + 0x8f, 0x35, 0xc7, 0x01, 0xfe, 0x89, 0xc0, 0x98, 0xdf, 0x82, 0x78, 0x3d, 0x03, 0x66, 0xda, 0x20, + 0x68, 0xb7, 0x4f, 0x7e, 0x50, 0x45, 0x6c, 0x4f, 0x23, 0xb6, 0xf0, 0xbd, 0xcc, 0x11, 0xd5, 0x0b, + 0xb0, 0x9f, 0x9c, 0x94, 0x83, 0xd6, 0xa3, 0xc3, 0x91, 0x8e, 0x8e, 0x46, 0x3a, 0xfa, 0x3e, 0xd2, + 0xd1, 0xbb, 0xb1, 0x9e, 0x3b, 0x1a, 0xeb, 0xb9, 0xaf, 0x63, 0x3d, 0xf7, 0xac, 0xc1, 0x2d, 0xef, + 0xf9, 0xa0, 0x6b, 0xee, 0x08, 0x9b, 0xb8, 0x8c, 0xf3, 0xe1, 0x0b, 0x3f, 0xe6, 0xe6, 0xaf, 0x93, + 0x57, 0x31, 0x4b, 0x6f, 0xe8, 0x32, 0xd9, 0x5d, 0x0c, 0x5e, 0x94, 0x9b, 0x7f, 0x02, 0x00, 0x00, + 0xff, 0xff, 0x2e, 0xfa, 0x78, 0x5a, 0x32, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -628,6 +629,7 @@ func _Query_QueryAddressMappingByCosmosAddress_Handler(srv interface{}, ctx cont return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "addresses.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/addresses/types/tx.pb.go b/x/addresses/types/tx.pb.go index 7a9d43ee..a189e6aa 100644 --- a/x/addresses/types/tx.pb.go +++ b/x/addresses/types/tx.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" @@ -205,25 +206,27 @@ func init() { func init() { proto.RegisterFile("addresses/v1/tx.proto", fileDescriptor_dbc33d4b2b06ba95) } var fileDescriptor_dbc33d4b2b06ba95 = []byte{ - // 279 bytes of a gzipped FileDescriptorProto + // 313 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x4e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0xe2, 0x81, 0x0b, 0xeb, 0x95, 0x19, 0x2a, 0xf9, 0x73, 0x89, 0xf8, 0x16, 0xa7, 0x3b, - 0xa6, 0xa4, 0x38, 0x42, 0x44, 0x7d, 0x13, 0x0b, 0x0a, 0x32, 0xf3, 0xd2, 0x85, 0xe4, 0xb9, 0xb8, - 0x53, 0xcb, 0x72, 0xe3, 0xa1, 0x6a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xb8, 0x52, 0xcb, - 0x72, 0xa1, 0xea, 0x84, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, 0x8b, 0x24, 0x98, 0xc0, - 0x72, 0x50, 0x9e, 0x92, 0x1c, 0x97, 0x0c, 0x36, 0x03, 0x83, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, - 0x53, 0x95, 0x0c, 0xb9, 0xc4, 0x7d, 0x8b, 0xd3, 0x83, 0x52, 0x73, 0xf3, 0xcb, 0x52, 0xd1, 0xec, - 0x44, 0x18, 0xc9, 0x88, 0x62, 0xa4, 0x22, 0x97, 0x3c, 0x0e, 0x2d, 0x30, 0x53, 0x8d, 0x6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xae, 0x7e, 0x41, 0x6a, 0x7a, 0x7a, 0x65, 0x56, 0x99, 0x7e, + 0x71, 0x7e, 0x6e, 0x6e, 0x6a, 0x4e, 0x66, 0x6a, 0x91, 0x7e, 0x99, 0xb9, 0x7e, 0x85, 0x3e, 0x22, + 0xf1, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x93, 0x85, 0x31, 0x20, 0x00, 0x00, 0xff, + 0xff, 0xc4, 0xe4, 0x89, 0xa0, 0x56, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -329,6 +332,7 @@ func _Msg_RemoveAddressMapping_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "addresses.v1.Msg", HandlerType: (*MsgServer)(nil), diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go index 0f784ead..e21782a1 100644 --- a/x/auction/types/query.pb.go +++ b/x/auction/types/query.pb.go @@ -1239,6 +1239,7 @@ func _Query_QueryTokenPrices_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "auction.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go index 61451994..b507eda5 100644 --- a/x/auction/types/tx.pb.go +++ b/x/auction/types/tx.pb.go @@ -248,6 +248,7 @@ func _Msg_SubmitBid_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "auction.v1.Msg", HandlerType: (*MsgServer)(nil), diff --git a/x/axelarcork/types/query.pb.go b/x/axelarcork/types/query.pb.go index 4711a6b9..4c71c01b 100644 --- a/x/axelarcork/types/query.pb.go +++ b/x/axelarcork/types/query.pb.go @@ -1896,6 +1896,7 @@ func _Query_QueryWinningAxelarCorks_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "axelarcork.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/axelarcork/types/tx.pb.go b/x/axelarcork/types/tx.pb.go index db693630..101a0d2b 100644 --- a/x/axelarcork/types/tx.pb.go +++ b/x/axelarcork/types/tx.pb.go @@ -779,6 +779,7 @@ func _Msg_CancelScheduledCork_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "axelarcork.v1.Msg", HandlerType: (*MsgServer)(nil), diff --git a/x/cellarfees/types/v1/query.pb.go b/x/cellarfees/types/v1/query.pb.go index 788633d2..782936e6 100644 --- a/x/cellarfees/types/v1/query.pb.go +++ b/x/cellarfees/types/v1/query.pb.go @@ -677,6 +677,7 @@ func _Query_QueryAPY_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cellarfees.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/cellarfees/types/v2/query.pb.go b/x/cellarfees/types/v2/query.pb.go index 873e8d16..88d832eb 100644 --- a/x/cellarfees/types/v2/query.pb.go +++ b/x/cellarfees/types/v2/query.pb.go @@ -806,6 +806,7 @@ func _Query_QueryFeeTokenBalance_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cellarfees.v2.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/cork/types/v2/query.pb.go b/x/cork/types/v2/query.pb.go index 23068177..89999d5b 100644 --- a/x/cork/types/v2/query.pb.go +++ b/x/cork/types/v2/query.pb.go @@ -1088,6 +1088,7 @@ func _Query_QueryCorkResults_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cork.v2.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/cork/types/v2/tx.pb.go b/x/cork/types/v2/tx.pb.go index afe04923..87dbddc9 100644 --- a/x/cork/types/v2/tx.pb.go +++ b/x/cork/types/v2/tx.pb.go @@ -237,6 +237,7 @@ func _Msg_ScheduleCork_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cork.v2.Msg", HandlerType: (*MsgServer)(nil), diff --git a/x/incentives/types/query.pb.go b/x/incentives/types/query.pb.go index 258e630d..46f1b1a7 100644 --- a/x/incentives/types/query.pb.go +++ b/x/incentives/types/query.pb.go @@ -334,6 +334,7 @@ func _Query_QueryAPY_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "incentives.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/pubsub/types/query.pb.go b/x/pubsub/types/query.pb.go index 9d477c93..76ad699c 100644 --- a/x/pubsub/types/query.pb.go +++ b/x/pubsub/types/query.pb.go @@ -2230,6 +2230,7 @@ func _Query_QueryDefaultSubscriptions_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "pubsub.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/pubsub/types/tx.pb.go b/x/pubsub/types/tx.pb.go index 0975322c..2f4829fb 100644 --- a/x/pubsub/types/tx.pb.go +++ b/x/pubsub/types/tx.pb.go @@ -984,6 +984,7 @@ func _Msg_RemoveSubscriberIntent_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "pubsub.v1.Msg", HandlerType: (*MsgServer)(nil),