From eeb7f5879276e0ebf474749bc1221450da60d30f Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:16:42 +0100 Subject: [PATCH 01/19] adding and generating proto --- proto/archway/cwregistry/v1/cwregistry.proto | 53 + proto/archway/cwregistry/v1/genesis.proto | 13 + proto/archway/cwregistry/v1/query.proto | 9 + proto/archway/cwregistry/v1/tx.proto | 63 + x/cwregistry/types/cwregistry.pb.go | 1097 ++++++++++++++ x/cwregistry/types/genesis.pb.go | 334 +++++ x/cwregistry/types/query.pb.go | 81 ++ x/cwregistry/types/tx.pb.go | 1344 ++++++++++++++++++ 8 files changed, 2994 insertions(+) create mode 100644 proto/archway/cwregistry/v1/cwregistry.proto create mode 100644 proto/archway/cwregistry/v1/genesis.proto create mode 100644 proto/archway/cwregistry/v1/query.proto create mode 100644 proto/archway/cwregistry/v1/tx.proto create mode 100644 x/cwregistry/types/cwregistry.pb.go create mode 100644 x/cwregistry/types/genesis.pb.go create mode 100644 x/cwregistry/types/query.pb.go create mode 100644 x/cwregistry/types/tx.pb.go diff --git a/proto/archway/cwregistry/v1/cwregistry.proto b/proto/archway/cwregistry/v1/cwregistry.proto new file mode 100644 index 00000000..a2f91d02 --- /dev/null +++ b/proto/archway/cwregistry/v1/cwregistry.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package archway.cwregistry.v1; + +option go_package = "github.com/archway-network/archway/x/cwregistry/types"; + +// CodeMetadata defines the metadata of a contract code +message CodeMetadata { + // The Code ID of the deployed contract + uint64 code_id = 1; + // The information regarding the contract source codebase + SourceMetadata source = 2; + // The information regarding the image used to build and optimize the contract binary + SourceBuilder source_builder = 3; + // The JSON schema which specifies the interaction endpoints of the contract + string schema = 4; + // The contacts of the developers or security incidence handlers + repeated string contacts = 5; +} + +// SourceMetadata defines the metadata of the source code of a contract +message SourceMetadata { + // The link to the code repository. e.g https://github.com/archway-network/archway + string repository = 1; + // The tag of the commit message at which the binary was built and deployed. e.g v1.0.2 + string tag = 2; + // The software license of the smart contract code. e.g Apache-2.0 + string license = 3; +} + +// SourceBuilder defines the metadata of the builder used to build the contract binary +message SourceBuilder { + // Docker image. e.g cosmwasm/rust-optimizer + string image = 1; + // Docker image tag. e.g 0.12.6 + string tag = 2; + // Name of the generated contract binary. e.g counter.wasm + string contract_name = 3; +} + + +// // Params defines the module parameters. +// message Params { +// // callback_gas_limit is the maximum gas that can be consumed by a callback. +// uint64 callback_gas_limit = 1; +// // max_block_reservation_limit is the maximum number of callbacks which can be registered in a given block. +// uint64 max_block_reservation_limit = 2; +// // max_future_reservation_limit is the maximum number of blocks in the future that a contract can request a callback in. +// uint64 max_future_reservation_limit = 3; +// // block_reservation_fee_multiplier is used to calculate a part of the reservation fees which will need to be paid when requesting the callback. +// string block_reservation_fee_multiplier = 4 [(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false]; +// // future_reservation_fee_multiplier is used to calculate a part of the reservation fees which will need to be paid while requesting the callback. +// string future_reservation_fee_multiplier = 5 [(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false]; +// } \ No newline at end of file diff --git a/proto/archway/cwregistry/v1/genesis.proto b/proto/archway/cwregistry/v1/genesis.proto new file mode 100644 index 00000000..98125514 --- /dev/null +++ b/proto/archway/cwregistry/v1/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package archway.cwregistry.v1; + +import "gogoproto/gogo.proto"; +import "archway/cwregistry/v1/cwregistry.proto"; + +option go_package = "github.com/archway-network/archway/x/cwregistry/types"; + +// GenesisState defines the cwregistry module's genesis state. +message GenesisState { + // code_metadata defines all the code metadata stored in the cwregistry module. + repeated CodeMetadata code_metadata = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/archway/cwregistry/v1/query.proto b/proto/archway/cwregistry/v1/query.proto new file mode 100644 index 00000000..1a3d5de7 --- /dev/null +++ b/proto/archway/cwregistry/v1/query.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package archway.cwregistry.v1; + +option go_package = "github.com/archway-network/archway/x/cwregistry/types"; + +// Query defines the gRPC querier service. +service Query { + +} \ No newline at end of file diff --git a/proto/archway/cwregistry/v1/tx.proto b/proto/archway/cwregistry/v1/tx.proto new file mode 100644 index 00000000..18c78f95 --- /dev/null +++ b/proto/archway/cwregistry/v1/tx.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package archway.cwregistry.v1; + +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "archway/cwregistry/v1/cwregistry.proto"; + +option go_package = "github.com/archway-network/archway/x/cwregistry/types"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + // RegisterContract registers a contract with the contract registry. + rpc RegisterContract(MsgRegisterContract) returns (MsgRegisterContractResponse) {} +// RegisterCode registers a contract code with the contract registry. + rpc RegisterCode(MsgRegisterCode) returns (MsgRegisterCodeResponse) {} +} + +// MsgRegisterContract registers a contract with the contract registry. +message MsgRegisterContract { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "sender"; + // sender is the bech32 address of the sender. + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // contract_address is the bech32 address of the contract. + string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // source_metadata is the metadata of the contract source. + SourceMetadata source_metadata = 3; + // source_builder is the builder image of the contract source. + SourceBuilder source_builder = 4; + // schema is the json schema of the contract. + string schema = 5; + // contacts is the list of dev contacts for the contract. + repeated string contacts = 6; +} + +// MsgRegisterContractResponse defines the Msg/RegisterContract response type. +message MsgRegisterContractResponse {} + +// MsgRegisterCode registers a contract code with the contract registry. +message MsgRegisterCode { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "sender"; + // sender is the bech32 address of the sender. + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // code_id is the id of the contract code. + uint64 code_id = 2; + // source_metadata is the metadata of the contract source. + SourceMetadata source_metadata = 3; + // source_builder is the builder image of the contract source. + SourceBuilder source_builder = 4; + // schema is the json schema of the contract. + string schema = 5; + // contacts is the list of dev contacts for the contract. + repeated string contacts = 6; +} + + message MsgRegisterCodeResponse {} diff --git a/x/cwregistry/types/cwregistry.pb.go b/x/cwregistry/types/cwregistry.pb.go new file mode 100644 index 00000000..5759bded --- /dev/null +++ b/x/cwregistry/types/cwregistry.pb.go @@ -0,0 +1,1097 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: archway/cwregistry/v1/cwregistry.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/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 + +// CodeMetadata defines the metadata of a contract code +type CodeMetadata struct { + // The Code ID of the deployed contract + CodeId uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // The information regarding the contract source codebase + Source *SourceMetadata `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` + // The information regarding the image used to build and optimize the contract binary + SourceBuilder *SourceBuilder `protobuf:"bytes,3,opt,name=source_builder,json=sourceBuilder,proto3" json:"source_builder,omitempty"` + // The JSON schema which specifies the interaction endpoints of the contract + Schema string `protobuf:"bytes,4,opt,name=schema,proto3" json:"schema,omitempty"` + // The contacts of the developers or security incidence handlers + Contacts []string `protobuf:"bytes,5,rep,name=contacts,proto3" json:"contacts,omitempty"` +} + +func (m *CodeMetadata) Reset() { *m = CodeMetadata{} } +func (m *CodeMetadata) String() string { return proto.CompactTextString(m) } +func (*CodeMetadata) ProtoMessage() {} +func (*CodeMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_2f25266653823114, []int{0} +} +func (m *CodeMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CodeMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CodeMetadata.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 *CodeMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_CodeMetadata.Merge(m, src) +} +func (m *CodeMetadata) XXX_Size() int { + return m.Size() +} +func (m *CodeMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_CodeMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_CodeMetadata proto.InternalMessageInfo + +func (m *CodeMetadata) GetCodeId() uint64 { + if m != nil { + return m.CodeId + } + return 0 +} + +func (m *CodeMetadata) GetSource() *SourceMetadata { + if m != nil { + return m.Source + } + return nil +} + +func (m *CodeMetadata) GetSourceBuilder() *SourceBuilder { + if m != nil { + return m.SourceBuilder + } + return nil +} + +func (m *CodeMetadata) GetSchema() string { + if m != nil { + return m.Schema + } + return "" +} + +func (m *CodeMetadata) GetContacts() []string { + if m != nil { + return m.Contacts + } + return nil +} + +// SourceMetadata defines the metadata of the source code of a contract +type SourceMetadata struct { + // The link to the code repository. e.g https://github.com/archway-network/archway + Repository string `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + // The tag of the commit message at which the binary was built and deployed. e.g v1.0.2 + Tag string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"` + // The software license of the smart contract code. e.g Apache-2.0 + License string `protobuf:"bytes,3,opt,name=license,proto3" json:"license,omitempty"` +} + +func (m *SourceMetadata) Reset() { *m = SourceMetadata{} } +func (m *SourceMetadata) String() string { return proto.CompactTextString(m) } +func (*SourceMetadata) ProtoMessage() {} +func (*SourceMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_2f25266653823114, []int{1} +} +func (m *SourceMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SourceMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SourceMetadata.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 *SourceMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_SourceMetadata.Merge(m, src) +} +func (m *SourceMetadata) XXX_Size() int { + return m.Size() +} +func (m *SourceMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_SourceMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_SourceMetadata proto.InternalMessageInfo + +func (m *SourceMetadata) GetRepository() string { + if m != nil { + return m.Repository + } + return "" +} + +func (m *SourceMetadata) GetTag() string { + if m != nil { + return m.Tag + } + return "" +} + +func (m *SourceMetadata) GetLicense() string { + if m != nil { + return m.License + } + return "" +} + +// SourceBuilder defines the metadata of the builder used to build the contract binary +type SourceBuilder struct { + // Docker image. e.g cosmwasm/rust-optimizer + Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` + // Docker image tag. e.g 0.12.6 + Tag string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"` + // Name of the generated contract binary. e.g counter.wasm + ContractName string `protobuf:"bytes,3,opt,name=contract_name,json=contractName,proto3" json:"contract_name,omitempty"` +} + +func (m *SourceBuilder) Reset() { *m = SourceBuilder{} } +func (m *SourceBuilder) String() string { return proto.CompactTextString(m) } +func (*SourceBuilder) ProtoMessage() {} +func (*SourceBuilder) Descriptor() ([]byte, []int) { + return fileDescriptor_2f25266653823114, []int{2} +} +func (m *SourceBuilder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SourceBuilder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SourceBuilder.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 *SourceBuilder) XXX_Merge(src proto.Message) { + xxx_messageInfo_SourceBuilder.Merge(m, src) +} +func (m *SourceBuilder) XXX_Size() int { + return m.Size() +} +func (m *SourceBuilder) XXX_DiscardUnknown() { + xxx_messageInfo_SourceBuilder.DiscardUnknown(m) +} + +var xxx_messageInfo_SourceBuilder proto.InternalMessageInfo + +func (m *SourceBuilder) GetImage() string { + if m != nil { + return m.Image + } + return "" +} + +func (m *SourceBuilder) GetTag() string { + if m != nil { + return m.Tag + } + return "" +} + +func (m *SourceBuilder) GetContractName() string { + if m != nil { + return m.ContractName + } + return "" +} + +func init() { + proto.RegisterType((*CodeMetadata)(nil), "archway.cwregistry.v1.CodeMetadata") + proto.RegisterType((*SourceMetadata)(nil), "archway.cwregistry.v1.SourceMetadata") + proto.RegisterType((*SourceBuilder)(nil), "archway.cwregistry.v1.SourceBuilder") +} + +func init() { + proto.RegisterFile("archway/cwregistry/v1/cwregistry.proto", fileDescriptor_2f25266653823114) +} + +var fileDescriptor_2f25266653823114 = []byte{ + // 359 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xcd, 0x6a, 0xea, 0x40, + 0x14, 0xc7, 0x9d, 0xab, 0xc6, 0x9b, 0x73, 0x55, 0x2e, 0x43, 0x3f, 0x42, 0x17, 0x21, 0xd8, 0x0f, + 0xb2, 0x69, 0x82, 0x2d, 0x5d, 0x76, 0x63, 0x57, 0xa5, 0xb4, 0x85, 0xe9, 0xae, 0x08, 0x32, 0x4e, + 0x86, 0x18, 0x6a, 0x32, 0x32, 0x33, 0x6a, 0xf3, 0x16, 0x7d, 0xac, 0x2e, 0x5d, 0x76, 0x59, 0x74, + 0xd1, 0xd7, 0x28, 0xc6, 0xa4, 0x44, 0x90, 0xee, 0xce, 0xef, 0xe4, 0xe4, 0xc7, 0xff, 0x0c, 0x07, + 0xce, 0xa8, 0x64, 0xa3, 0x39, 0x4d, 0x7d, 0x36, 0x97, 0x3c, 0x8c, 0x94, 0x96, 0xa9, 0x3f, 0xeb, + 0x96, 0xc8, 0x9b, 0x48, 0xa1, 0x05, 0xde, 0xcf, 0xe7, 0xbc, 0xd2, 0x97, 0x59, 0xb7, 0xf3, 0x85, + 0xa0, 0x79, 0x23, 0x02, 0x7e, 0xcf, 0x35, 0x0d, 0xa8, 0xa6, 0xf8, 0x10, 0x1a, 0x4c, 0x04, 0x7c, + 0x10, 0x05, 0x16, 0x72, 0x90, 0x5b, 0x23, 0xc6, 0x1a, 0x6f, 0x03, 0x7c, 0x0d, 0x86, 0x12, 0x53, + 0xc9, 0xb8, 0xf5, 0xc7, 0x41, 0xee, 0xbf, 0x8b, 0x53, 0x6f, 0xa7, 0xd1, 0x7b, 0xca, 0x86, 0x0a, + 0x1f, 0xc9, 0x7f, 0xc2, 0x77, 0xd0, 0xde, 0x54, 0x83, 0xe1, 0x34, 0x1a, 0x07, 0x5c, 0x5a, 0xd5, + 0x4c, 0x73, 0xf2, 0xab, 0xa6, 0xb7, 0x99, 0x25, 0x2d, 0x55, 0x46, 0x7c, 0x00, 0x86, 0x62, 0x23, + 0x1e, 0x53, 0xab, 0xe6, 0x20, 0xd7, 0x24, 0x39, 0xe1, 0x23, 0xf8, 0xcb, 0x44, 0xa2, 0x29, 0xd3, + 0xca, 0xaa, 0x3b, 0x55, 0xd7, 0x24, 0x3f, 0xdc, 0xe9, 0x43, 0x7b, 0x3b, 0x1a, 0xb6, 0x01, 0x24, + 0x9f, 0x08, 0x15, 0x69, 0x21, 0xd3, 0x6c, 0x5b, 0x93, 0x94, 0x3a, 0xf8, 0x3f, 0x54, 0x35, 0x0d, + 0xb3, 0x75, 0x4d, 0xb2, 0x2e, 0xb1, 0x05, 0x8d, 0x71, 0xc4, 0x78, 0xa2, 0x78, 0x96, 0xde, 0x24, + 0x05, 0x76, 0xfa, 0xd0, 0xda, 0x4a, 0x8c, 0xf7, 0xa0, 0x1e, 0xc5, 0x34, 0xe4, 0xb9, 0x77, 0x03, + 0x3b, 0x94, 0xc7, 0xd0, 0x5a, 0x47, 0x94, 0x94, 0xe9, 0x41, 0x42, 0xe3, 0x42, 0xdc, 0x2c, 0x9a, + 0x0f, 0x34, 0xe6, 0xbd, 0xc7, 0xf7, 0xa5, 0x8d, 0x16, 0x4b, 0x1b, 0x7d, 0x2e, 0x6d, 0xf4, 0xb6, + 0xb2, 0x2b, 0x8b, 0x95, 0x5d, 0xf9, 0x58, 0xd9, 0x95, 0xe7, 0xab, 0x30, 0xd2, 0xa3, 0xe9, 0xd0, + 0x63, 0x22, 0xf6, 0xf3, 0x87, 0x3c, 0x4f, 0xb8, 0x9e, 0x0b, 0xf9, 0x52, 0xb0, 0xff, 0x5a, 0xbe, + 0x0d, 0x9d, 0x4e, 0xb8, 0x1a, 0x1a, 0xd9, 0x51, 0x5c, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xc0, + 0xbd, 0x47, 0x9a, 0x3e, 0x02, 0x00, 0x00, +} + +func (m *CodeMetadata) 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 *CodeMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CodeMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Contacts) > 0 { + for iNdEx := len(m.Contacts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Contacts[iNdEx]) + copy(dAtA[i:], m.Contacts[iNdEx]) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.Contacts[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0x22 + } + if m.SourceBuilder != nil { + { + size, err := m.SourceBuilder.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCwregistry(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Source != nil { + { + size, err := m.Source.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCwregistry(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.CodeId != 0 { + i = encodeVarintCwregistry(dAtA, i, uint64(m.CodeId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SourceMetadata) 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 *SourceMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SourceMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.License) > 0 { + i -= len(m.License) + copy(dAtA[i:], m.License) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.License))) + i-- + dAtA[i] = 0x1a + } + if len(m.Tag) > 0 { + i -= len(m.Tag) + copy(dAtA[i:], m.Tag) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.Tag))) + i-- + dAtA[i] = 0x12 + } + if len(m.Repository) > 0 { + i -= len(m.Repository) + copy(dAtA[i:], m.Repository) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.Repository))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SourceBuilder) 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 *SourceBuilder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SourceBuilder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractName) > 0 { + i -= len(m.ContractName) + copy(dAtA[i:], m.ContractName) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.ContractName))) + i-- + dAtA[i] = 0x1a + } + if len(m.Tag) > 0 { + i -= len(m.Tag) + copy(dAtA[i:], m.Tag) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.Tag))) + i-- + dAtA[i] = 0x12 + } + if len(m.Image) > 0 { + i -= len(m.Image) + copy(dAtA[i:], m.Image) + i = encodeVarintCwregistry(dAtA, i, uint64(len(m.Image))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCwregistry(dAtA []byte, offset int, v uint64) int { + offset -= sovCwregistry(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *CodeMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeId != 0 { + n += 1 + sovCwregistry(uint64(m.CodeId)) + } + if m.Source != nil { + l = m.Source.Size() + n += 1 + l + sovCwregistry(uint64(l)) + } + if m.SourceBuilder != nil { + l = m.SourceBuilder.Size() + n += 1 + l + sovCwregistry(uint64(l)) + } + l = len(m.Schema) + if l > 0 { + n += 1 + l + sovCwregistry(uint64(l)) + } + if len(m.Contacts) > 0 { + for _, s := range m.Contacts { + l = len(s) + n += 1 + l + sovCwregistry(uint64(l)) + } + } + return n +} + +func (m *SourceMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Repository) + if l > 0 { + n += 1 + l + sovCwregistry(uint64(l)) + } + l = len(m.Tag) + if l > 0 { + n += 1 + l + sovCwregistry(uint64(l)) + } + l = len(m.License) + if l > 0 { + n += 1 + l + sovCwregistry(uint64(l)) + } + return n +} + +func (m *SourceBuilder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Image) + if l > 0 { + n += 1 + l + sovCwregistry(uint64(l)) + } + l = len(m.Tag) + if l > 0 { + n += 1 + l + sovCwregistry(uint64(l)) + } + l = len(m.ContractName) + if l > 0 { + n += 1 + l + sovCwregistry(uint64(l)) + } + return n +} + +func sovCwregistry(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCwregistry(x uint64) (n int) { + return sovCwregistry(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *CodeMetadata) 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 ErrIntOverflowCwregistry + } + 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: CodeMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CodeMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + m.CodeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCwregistry + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Source == nil { + m.Source = &SourceMetadata{} + } + if err := m.Source.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceBuilder", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCwregistry + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceBuilder == nil { + m.SourceBuilder = &SourceBuilder{} + } + if err := m.SourceBuilder.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Schema = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contacts", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contacts = append(m.Contacts, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCwregistry(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCwregistry + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SourceMetadata) 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 ErrIntOverflowCwregistry + } + 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: SourceMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SourceMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Repository", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Repository = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tag", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tag = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field License", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.License = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCwregistry(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCwregistry + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SourceBuilder) 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 ErrIntOverflowCwregistry + } + 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: SourceBuilder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SourceBuilder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Image = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tag", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tag = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCwregistry + } + 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 ErrInvalidLengthCwregistry + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCwregistry + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCwregistry(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCwregistry + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCwregistry(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, ErrIntOverflowCwregistry + } + 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, ErrIntOverflowCwregistry + } + 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, ErrIntOverflowCwregistry + } + 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, ErrInvalidLengthCwregistry + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCwregistry + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCwregistry + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCwregistry = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCwregistry = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCwregistry = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/cwregistry/types/genesis.pb.go b/x/cwregistry/types/genesis.pb.go new file mode 100644 index 00000000..b8b7db1d --- /dev/null +++ b/x/cwregistry/types/genesis.pb.go @@ -0,0 +1,334 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: archway/cwregistry/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// GenesisState defines the cwregistry module's genesis state. +type GenesisState struct { + // code_metadata defines all the code metadata stored in the cwregistry module. + CodeMetadata []CodeMetadata `protobuf:"bytes,1,rep,name=code_metadata,json=codeMetadata,proto3" json:"code_metadata"` +} + +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_c9855fc5c6f0c4fb, []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) GetCodeMetadata() []CodeMetadata { + if m != nil { + return m.CodeMetadata + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "archway.cwregistry.v1.GenesisState") +} + +func init() { + proto.RegisterFile("archway/cwregistry/v1/genesis.proto", fileDescriptor_c9855fc5c6f0c4fb) +} + +var fileDescriptor_c9855fc5c6f0c4fb = []byte{ + // 218 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0x2c, 0x4a, 0xce, + 0x28, 0x4f, 0xac, 0xd4, 0x4f, 0x2e, 0x2f, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0xaa, 0xd4, 0x2f, + 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x85, 0x2a, 0xd2, 0x43, 0x28, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, + 0xab, 0xd0, 0x07, 0xb1, 0x20, 0x8a, 0xa5, 0xd4, 0xb0, 0x9b, 0x88, 0xa4, 0x15, 0xac, 0x4e, 0x29, + 0x8e, 0x8b, 0xc7, 0x1d, 0x62, 0x4b, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, 0x1f, 0x17, 0x6f, 0x72, + 0x7e, 0x4a, 0x6a, 0x7c, 0x6e, 0x6a, 0x49, 0x62, 0x4a, 0x62, 0x49, 0xa2, 0x04, 0xa3, 0x02, 0xb3, + 0x06, 0xb7, 0x91, 0xb2, 0x1e, 0x56, 0xcb, 0xf5, 0x9c, 0xf3, 0x53, 0x52, 0x7d, 0xa1, 0x4a, 0x9d, + 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0xe2, 0x49, 0x46, 0x16, 0xf3, 0x3f, 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, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, + 0x5c, 0x7d, 0xa8, 0xe1, 0xba, 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0x30, 0xbe, 0x7e, 0x05, + 0xb2, 0xf3, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xee, 0x36, 0x06, 0x04, 0x00, 0x00, + 0xff, 0xff, 0x6d, 0xc3, 0xef, 0x43, 0x33, 0x01, 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.CodeMetadata) > 0 { + for iNdEx := len(m.CodeMetadata) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CodeMetadata[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.CodeMetadata) > 0 { + for _, e := range m.CodeMetadata { + 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 CodeMetadata", 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.CodeMetadata = append(m.CodeMetadata, CodeMetadata{}) + if err := m.CodeMetadata[len(m.CodeMetadata)-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/cwregistry/types/query.pb.go b/x/cwregistry/types/query.pb.go new file mode 100644 index 00000000..fa135e47 --- /dev/null +++ b/x/cwregistry/types/query.pb.go @@ -0,0 +1,81 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: archway/cwregistry/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// 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 + +func init() { proto.RegisterFile("archway/cwregistry/v1/query.proto", fileDescriptor_d970ba8222896566) } + +var fileDescriptor_d970ba8222896566 = []byte{ + // 143 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x2c, 0x4a, 0xce, + 0x28, 0x4f, 0xac, 0xd4, 0x4f, 0x2e, 0x2f, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0xaa, 0xd4, 0x2f, + 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x85, + 0x2a, 0xd1, 0x43, 0x28, 0xd1, 0x2b, 0x33, 0x34, 0x62, 0xe7, 0x62, 0x0d, 0x04, 0xa9, 0x72, 0xf2, + 0x3f, 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, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, + 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x21, 0xba, 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, + 0xd9, 0x30, 0xbe, 0x7e, 0x05, 0xb2, 0xcd, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x7b, + 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x05, 0x7c, 0xdd, 0x33, 0x9c, 0x00, 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 { +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +// QueryServer is the server API for Query service. +type QueryServer interface { +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "archway.cwregistry.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "archway/cwregistry/v1/query.proto", +} diff --git a/x/cwregistry/types/tx.pb.go b/x/cwregistry/types/tx.pb.go new file mode 100644 index 00000000..47f77780 --- /dev/null +++ b/x/cwregistry/types/tx.pb.go @@ -0,0 +1,1344 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: archway/cwregistry/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + 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" + 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 + +// MsgRegisterContract registers a contract with the contract registry. +type MsgRegisterContract struct { + // sender is the bech32 address of the sender. + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // contract_address is the bech32 address of the contract. + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + // source_metadata is the metadata of the contract source. + SourceMetadata *SourceMetadata `protobuf:"bytes,3,opt,name=source_metadata,json=sourceMetadata,proto3" json:"source_metadata,omitempty"` + // source_builder is the builder image of the contract source. + SourceBuilder *SourceBuilder `protobuf:"bytes,4,opt,name=source_builder,json=sourceBuilder,proto3" json:"source_builder,omitempty"` + // schema is the json schema of the contract. + Schema string `protobuf:"bytes,5,opt,name=schema,proto3" json:"schema,omitempty"` + // contacts is the list of dev contacts for the contract. + Contacts []string `protobuf:"bytes,6,rep,name=contacts,proto3" json:"contacts,omitempty"` +} + +func (m *MsgRegisterContract) Reset() { *m = MsgRegisterContract{} } +func (m *MsgRegisterContract) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterContract) ProtoMessage() {} +func (*MsgRegisterContract) Descriptor() ([]byte, []int) { + return fileDescriptor_553159f12499e254, []int{0} +} +func (m *MsgRegisterContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterContract.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 *MsgRegisterContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterContract.Merge(m, src) +} +func (m *MsgRegisterContract) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterContract proto.InternalMessageInfo + +// MsgRegisterContractResponse defines the Msg/RegisterContract response type. +type MsgRegisterContractResponse struct { +} + +func (m *MsgRegisterContractResponse) Reset() { *m = MsgRegisterContractResponse{} } +func (m *MsgRegisterContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterContractResponse) ProtoMessage() {} +func (*MsgRegisterContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_553159f12499e254, []int{1} +} +func (m *MsgRegisterContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterContractResponse.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 *MsgRegisterContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterContractResponse.Merge(m, src) +} +func (m *MsgRegisterContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterContractResponse proto.InternalMessageInfo + +// MsgRegisterCode registers a contract code with the contract registry. +type MsgRegisterCode struct { + // sender is the bech32 address of the sender. + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // code_id is the id of the contract code. + CodeId uint64 `protobuf:"varint,2,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // source_metadata is the metadata of the contract source. + SourceMetadata *SourceMetadata `protobuf:"bytes,3,opt,name=source_metadata,json=sourceMetadata,proto3" json:"source_metadata,omitempty"` + // source_builder is the builder image of the contract source. + SourceBuilder *SourceBuilder `protobuf:"bytes,4,opt,name=source_builder,json=sourceBuilder,proto3" json:"source_builder,omitempty"` + // schema is the json schema of the contract. + Schema string `protobuf:"bytes,5,opt,name=schema,proto3" json:"schema,omitempty"` + // contacts is the list of dev contacts for the contract. + Contacts []string `protobuf:"bytes,6,rep,name=contacts,proto3" json:"contacts,omitempty"` +} + +func (m *MsgRegisterCode) Reset() { *m = MsgRegisterCode{} } +func (m *MsgRegisterCode) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCode) ProtoMessage() {} +func (*MsgRegisterCode) Descriptor() ([]byte, []int) { + return fileDescriptor_553159f12499e254, []int{2} +} +func (m *MsgRegisterCode) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterCode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterCode.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 *MsgRegisterCode) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCode.Merge(m, src) +} +func (m *MsgRegisterCode) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterCode) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCode.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterCode proto.InternalMessageInfo + +type MsgRegisterCodeResponse struct { +} + +func (m *MsgRegisterCodeResponse) Reset() { *m = MsgRegisterCodeResponse{} } +func (m *MsgRegisterCodeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCodeResponse) ProtoMessage() {} +func (*MsgRegisterCodeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_553159f12499e254, []int{3} +} +func (m *MsgRegisterCodeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterCodeResponse.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 *MsgRegisterCodeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCodeResponse.Merge(m, src) +} +func (m *MsgRegisterCodeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterCodeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCodeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterCodeResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterContract)(nil), "archway.cwregistry.v1.MsgRegisterContract") + proto.RegisterType((*MsgRegisterContractResponse)(nil), "archway.cwregistry.v1.MsgRegisterContractResponse") + proto.RegisterType((*MsgRegisterCode)(nil), "archway.cwregistry.v1.MsgRegisterCode") + proto.RegisterType((*MsgRegisterCodeResponse)(nil), "archway.cwregistry.v1.MsgRegisterCodeResponse") +} + +func init() { proto.RegisterFile("archway/cwregistry/v1/tx.proto", fileDescriptor_553159f12499e254) } + +var fileDescriptor_553159f12499e254 = []byte{ + // 520 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x54, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xb6, 0x9b, 0xd6, 0xd0, 0xe3, 0x47, 0x8a, 0x5b, 0x88, 0x6b, 0xc0, 0x8d, 0x22, 0xa8, 0xa2, + 0x48, 0xf5, 0xd1, 0x20, 0x16, 0x36, 0xd2, 0x09, 0xa1, 0x80, 0xe4, 0x6e, 0x2c, 0xd6, 0xe5, 0x7c, + 0xba, 0x58, 0xd4, 0xbe, 0xe8, 0xde, 0xa5, 0x69, 0x36, 0xc4, 0xc4, 0xc8, 0x9f, 0xd0, 0x3f, 0xa1, + 0x03, 0x7f, 0x01, 0x13, 0x63, 0xc5, 0xc4, 0x88, 0x92, 0xa1, 0x0c, 0x4c, 0xfc, 0x05, 0xc8, 0xf6, + 0xa5, 0x4d, 0x20, 0x40, 0xc4, 0xca, 0x62, 0xf9, 0x7b, 0xdf, 0xf7, 0x9e, 0xdf, 0x7d, 0x9f, 0x75, + 0xc8, 0x23, 0x92, 0x76, 0x07, 0x64, 0x88, 0xe9, 0x40, 0x32, 0x1e, 0x83, 0x92, 0x43, 0x7c, 0xb8, + 0x8b, 0xd5, 0x91, 0xdf, 0x93, 0x42, 0x09, 0xfb, 0xa6, 0xe6, 0xfd, 0x0b, 0xde, 0x3f, 0xdc, 0x75, + 0x6f, 0x90, 0x24, 0x4e, 0x05, 0xce, 0x9f, 0x85, 0xd2, 0xad, 0x50, 0x01, 0x89, 0x00, 0x9c, 0x00, + 0xcf, 0x26, 0x24, 0xc0, 0x35, 0xb1, 0x59, 0x10, 0x61, 0x8e, 0x70, 0x01, 0x34, 0xb5, 0xc1, 0x05, + 0x17, 0x45, 0x3d, 0x7b, 0xd3, 0xd5, 0x3b, 0x5c, 0x08, 0x7e, 0xc0, 0x30, 0xe9, 0xc5, 0x98, 0xa4, + 0xa9, 0x50, 0x44, 0xc5, 0x22, 0x9d, 0xf4, 0x6c, 0xcf, 0xdf, 0x78, 0x6a, 0xbf, 0x5c, 0x57, 0xfb, + 0xbe, 0x84, 0xd6, 0xdb, 0xc0, 0x83, 0xbc, 0xca, 0xe4, 0x9e, 0x48, 0x95, 0x24, 0x54, 0xd9, 0x0f, + 0x90, 0x05, 0x2c, 0x8d, 0x98, 0x74, 0xcc, 0xaa, 0x59, 0x5f, 0x6d, 0x39, 0x9f, 0xde, 0xef, 0x6c, + 0xe8, 0xad, 0x9e, 0x44, 0x91, 0x64, 0x00, 0xfb, 0x4a, 0xc6, 0x29, 0x0f, 0xb4, 0xce, 0xde, 0x43, + 0x6b, 0x54, 0x77, 0x87, 0xa4, 0x50, 0x38, 0x4b, 0x7f, 0xe9, 0x2d, 0x4f, 0x3a, 0x74, 0xd9, 0x7e, + 0x8e, 0xca, 0x20, 0xfa, 0x92, 0xb2, 0x30, 0x61, 0x8a, 0x44, 0x44, 0x11, 0xa7, 0x54, 0x35, 0xeb, + 0x57, 0x9a, 0xf7, 0xfd, 0xb9, 0x16, 0xfb, 0xfb, 0xb9, 0xba, 0xad, 0xc5, 0xc1, 0x75, 0x98, 0xc1, + 0xf6, 0x33, 0xa4, 0x2b, 0x61, 0xa7, 0x1f, 0x1f, 0x64, 0xc7, 0x59, 0xce, 0xc7, 0xdd, 0xfb, 0xe3, + 0xb8, 0x56, 0xa1, 0x0d, 0xae, 0xc1, 0x34, 0xb4, 0x6f, 0x21, 0x0b, 0x68, 0x97, 0x25, 0xc4, 0x59, + 0xc9, 0xce, 0x15, 0x68, 0x64, 0xbb, 0xe8, 0x72, 0x76, 0x0e, 0x42, 0x15, 0x38, 0x56, 0xb5, 0x54, + 0x5f, 0x0d, 0xce, 0xf1, 0xe3, 0xf5, 0xb7, 0xc7, 0x5b, 0xc6, 0xd7, 0xe3, 0x2d, 0xe3, 0xcd, 0xd9, + 0x49, 0x43, 0x5b, 0x55, 0xbb, 0x8b, 0x6e, 0xcf, 0xf1, 0x3c, 0x60, 0xd0, 0x13, 0x29, 0xb0, 0xda, + 0x87, 0x25, 0x54, 0x9e, 0xe1, 0x23, 0xf6, 0x0f, 0x79, 0x54, 0xd0, 0x25, 0x2a, 0x22, 0x16, 0xc6, + 0x51, 0x1e, 0xc3, 0x72, 0x60, 0x65, 0xf0, 0x69, 0xf4, 0x9f, 0x78, 0xbc, 0x89, 0x2a, 0x3f, 0x79, + 0x38, 0xf1, 0xb7, 0xf9, 0xcd, 0x44, 0xa5, 0x36, 0x70, 0x5b, 0xa1, 0xb5, 0x5f, 0xfe, 0xfb, 0xc6, + 0x6f, 0x96, 0x9e, 0x93, 0x97, 0xdb, 0x5c, 0x5c, 0x7b, 0x9e, 0xad, 0x61, 0x77, 0xd1, 0xd5, 0x99, + 0x64, 0xb7, 0x17, 0x99, 0x12, 0x31, 0xd7, 0x5f, 0x4c, 0x77, 0xf1, 0x25, 0x77, 0xe5, 0xf5, 0xd9, + 0x49, 0xc3, 0x6c, 0xbd, 0xf8, 0x38, 0xf2, 0xcc, 0xd3, 0x91, 0x67, 0x7e, 0x19, 0x79, 0xe6, 0xbb, + 0xb1, 0x67, 0x9c, 0x8e, 0x3d, 0xe3, 0xf3, 0xd8, 0x33, 0x5e, 0x3e, 0xe2, 0xb1, 0xea, 0xf6, 0x3b, + 0x3e, 0x15, 0x09, 0xd6, 0xc3, 0x77, 0x52, 0xa6, 0x06, 0x42, 0xbe, 0x9a, 0x60, 0x7c, 0x34, 0x7d, + 0x83, 0xa8, 0x61, 0x8f, 0x41, 0xc7, 0xca, 0xaf, 0x8e, 0x87, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, + 0xa1, 0xe7, 0x1c, 0x12, 0x16, 0x05, 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 { + // RegisterContract registers a contract with the contract registry. + RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) + // RegisterCode registers a contract code with the contract registry. + RegisterCode(ctx context.Context, in *MsgRegisterCode, opts ...grpc.CallOption) (*MsgRegisterCodeResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) { + out := new(MsgRegisterContractResponse) + err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Msg/RegisterContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RegisterCode(ctx context.Context, in *MsgRegisterCode, opts ...grpc.CallOption) (*MsgRegisterCodeResponse, error) { + out := new(MsgRegisterCodeResponse) + err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Msg/RegisterCode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // RegisterContract registers a contract with the contract registry. + RegisterContract(context.Context, *MsgRegisterContract) (*MsgRegisterContractResponse, error) + // RegisterCode registers a contract code with the contract registry. + RegisterCode(context.Context, *MsgRegisterCode) (*MsgRegisterCodeResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterContract(ctx context.Context, req *MsgRegisterContract) (*MsgRegisterContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterContract not implemented") +} +func (*UnimplementedMsgServer) RegisterCode(ctx context.Context, req *MsgRegisterCode) (*MsgRegisterCodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterCode not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/archway.cwregistry.v1.Msg/RegisterContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterContract(ctx, req.(*MsgRegisterContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RegisterCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterCode) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterCode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/archway.cwregistry.v1.Msg/RegisterCode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterCode(ctx, req.(*MsgRegisterCode)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "archway.cwregistry.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterContract", + Handler: _Msg_RegisterContract_Handler, + }, + { + MethodName: "RegisterCode", + Handler: _Msg_RegisterCode_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "archway/cwregistry/v1/tx.proto", +} + +func (m *MsgRegisterContract) 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 *MsgRegisterContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Contacts) > 0 { + for iNdEx := len(m.Contacts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Contacts[iNdEx]) + copy(dAtA[i:], m.Contacts[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Contacts[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintTx(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0x2a + } + if m.SourceBuilder != nil { + { + size, err := m.SourceBuilder.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.SourceMetadata != nil { + { + size, err := m.SourceMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterContractResponse) 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 *MsgRegisterContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRegisterCode) 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 *MsgRegisterCode) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Contacts) > 0 { + for iNdEx := len(m.Contacts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Contacts[iNdEx]) + copy(dAtA[i:], m.Contacts[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Contacts[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintTx(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0x2a + } + if m.SourceBuilder != nil { + { + size, err := m.SourceBuilder.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.SourceMetadata != nil { + { + size, err := m.SourceMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.CodeId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.CodeId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterCodeResponse) 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 *MsgRegisterCodeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterCodeResponse) 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 *MsgRegisterContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.SourceMetadata != nil { + l = m.SourceMetadata.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.SourceBuilder != nil { + l = m.SourceBuilder.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Schema) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Contacts) > 0 { + for _, s := range m.Contacts { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgRegisterContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRegisterCode) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.CodeId != 0 { + n += 1 + sovTx(uint64(m.CodeId)) + } + if m.SourceMetadata != nil { + l = m.SourceMetadata.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.SourceBuilder != nil { + l = m.SourceBuilder.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Schema) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Contacts) > 0 { + for _, s := range m.Contacts { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgRegisterCodeResponse) 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 *MsgRegisterContract) 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: MsgRegisterContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceMetadata == nil { + m.SourceMetadata = &SourceMetadata{} + } + if err := m.SourceMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceBuilder", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceBuilder == nil { + m.SourceBuilder = &SourceBuilder{} + } + if err := m.SourceBuilder.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", 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.Schema = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contacts", 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.Contacts = append(m.Contacts, 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 *MsgRegisterContractResponse) 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: MsgRegisterContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterContractResponse: 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 *MsgRegisterCode) 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: MsgRegisterCode: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterCode: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + m.CodeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceMetadata == nil { + m.SourceMetadata = &SourceMetadata{} + } + if err := m.SourceMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceBuilder", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceBuilder == nil { + m.SourceBuilder = &SourceBuilder{} + } + if err := m.SourceBuilder.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", 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.Schema = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contacts", 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.Contacts = append(m.Contacts, 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 *MsgRegisterCodeResponse) 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: MsgRegisterCodeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterCodeResponse: 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 401a927cbc42a5c2c5bec8e0a5e8ab044ac5d4a0 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:50:56 +0100 Subject: [PATCH 02/19] adding defaults --- x/cwregistry/client/cli/query.go | 23 ++++ x/cwregistry/client/cli/tx.go | 21 ++++ x/cwregistry/genesis.go | 19 +++ x/cwregistry/keeper/grpc_query.go | 18 +++ x/cwregistry/keeper/keeper.go | 67 ++++++++++ x/cwregistry/keeper/msg_server.go | 29 +++++ x/cwregistry/module.go | 164 +++++++++++++++++++++++++ x/cwregistry/types/codec.go | 35 ++++++ x/cwregistry/types/errors.go | 10 ++ x/cwregistry/types/expected_keepers.go | 14 +++ x/cwregistry/types/genesis.go | 12 ++ x/cwregistry/types/keys.go | 21 ++++ x/cwregistry/types/msg.go | 10 ++ 13 files changed, 443 insertions(+) create mode 100644 x/cwregistry/client/cli/query.go create mode 100644 x/cwregistry/client/cli/tx.go create mode 100644 x/cwregistry/genesis.go create mode 100644 x/cwregistry/keeper/grpc_query.go create mode 100644 x/cwregistry/keeper/keeper.go create mode 100644 x/cwregistry/keeper/msg_server.go create mode 100644 x/cwregistry/module.go create mode 100644 x/cwregistry/types/codec.go create mode 100644 x/cwregistry/types/errors.go create mode 100644 x/cwregistry/types/expected_keepers.go create mode 100644 x/cwregistry/types/genesis.go create mode 100644 x/cwregistry/types/keys.go create mode 100644 x/cwregistry/types/msg.go diff --git a/x/cwregistry/client/cli/query.go b/x/cwregistry/client/cli/query.go new file mode 100644 index 00000000..77c243a8 --- /dev/null +++ b/x/cwregistry/client/cli/query.go @@ -0,0 +1,23 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + + "github.com/archway-network/archway/x/cwregistry/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 1, + RunE: client.ValidateCmd, + } + + return cmd +} diff --git a/x/cwregistry/client/cli/tx.go b/x/cwregistry/client/cli/tx.go new file mode 100644 index 00000000..7a559842 --- /dev/null +++ b/x/cwregistry/client/cli/tx.go @@ -0,0 +1,21 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + + "github.com/archway-network/archway/x/cwregistry/types" +) + +// GetTxCmd builds tx command group for the module. +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Transaction commands for the cwregistry module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + return cmd +} diff --git a/x/cwregistry/genesis.go b/x/cwregistry/genesis.go new file mode 100644 index 00000000..abd20e8a --- /dev/null +++ b/x/cwregistry/genesis.go @@ -0,0 +1,19 @@ +package cwica + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/archway-network/archway/x/cwregistry/keeper" + "github.com/archway-network/archway/x/cwregistry/types" +) + +// InitGenesis initializes the cwregistry module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + panic("unimplemented 👻") +} + +// ExportGenesis returns the cwregistry module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + panic("unimplemented 👻") +} diff --git a/x/cwregistry/keeper/grpc_query.go b/x/cwregistry/keeper/grpc_query.go new file mode 100644 index 00000000..ef8851a4 --- /dev/null +++ b/x/cwregistry/keeper/grpc_query.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "github.com/archway-network/archway/x/cwregistry/types" +) + +var _ types.QueryServer = &QueryServer{} + +type QueryServer struct { + keeper Keeper +} + +// NewQueryServer creates a new gRPC query server. +func NewQueryServer(keeper Keeper) *QueryServer { + return &QueryServer{ + keeper: keeper, + } +} diff --git a/x/cwregistry/keeper/keeper.go b/x/cwregistry/keeper/keeper.go new file mode 100644 index 00000000..ed9eae1b --- /dev/null +++ b/x/cwregistry/keeper/keeper.go @@ -0,0 +1,67 @@ +package keeper + +import ( + "cosmossdk.io/collections" + "cosmossdk.io/log" + + "github.com/archway-network/archway/internal/collcompat" + "github.com/archway-network/archway/x/cwregistry/types" + + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + Keeper struct { + Codec codec.BinaryCodec + storeKey storetypes.StoreKey + sudoKeeper types.WasmKeeper + logger log.Logger + Schema collections.Schema + + // CodeMetadata key: CodeMetadataKeyPrefix + codeID | value: CodeMetadata + CodeMetadata collections.Map[uint32, types.CodeMetadata] + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + sudoKeeper types.WasmKeeper, + logger log.Logger, +) Keeper { + sb := collections.NewSchemaBuilder(collcompat.NewKVStoreService(storeKey)) + + k := Keeper{ + Codec: cdc, + storeKey: storeKey, + sudoKeeper: sudoKeeper, + logger: logger.With("module", "x/"+types.ModuleName), + CodeMetadata: collections.NewMap( + sb, + types.CodeMetadataKeyPrefix, + "code_metadatas", + collections.Uint32Key, + collcompat.ProtoValue[types.CodeMetadata](cdc), + ), + } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + return k +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return k.logger +} + +// SetWasmKeeper sets the given wasm keeper. +// NOTE: Only for testing purposes +func (k *Keeper) SetWasmKeeper(wk types.WasmKeeper) { + k.sudoKeeper = wk +} diff --git a/x/cwregistry/keeper/msg_server.go b/x/cwregistry/keeper/msg_server.go new file mode 100644 index 00000000..4aa1a63f --- /dev/null +++ b/x/cwregistry/keeper/msg_server.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "context" + + "github.com/archway-network/archway/x/cwregistry/types" +) + +type msgServer struct { + Keeper +} + +var _ types.MsgServer = msgServer{} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +// RegisterCode implements types.MsgServer. +func (m msgServer) RegisterCode(context.Context, *types.MsgRegisterCode) (*types.MsgRegisterCodeResponse, error) { + panic("unimplemented") +} + +// RegisterContract implements types.MsgServer. +func (m msgServer) RegisterContract(context.Context, *types.MsgRegisterContract) (*types.MsgRegisterContractResponse, error) { + panic("unimplemented") +} diff --git a/x/cwregistry/module.go b/x/cwregistry/module.go new file mode 100644 index 00000000..ce03d0e6 --- /dev/null +++ b/x/cwregistry/module.go @@ -0,0 +1,164 @@ +package cwica + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + + "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/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/archway-network/archway/x/cwregistry/client/cli" + "github.com/archway-network/archway/x/cwregistry/keeper" + "github.com/archway-network/archway/x/cwregistry/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.HasGenesis = AppModule{} +) + +const ConsensusVersion = 1 + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + 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) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + return + } +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +var _ appmodule.AppModule = AppModule{} + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() { // marker +} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() { // marker +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) +} + +// ExportGenesis returns the capability 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 implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } diff --git a/x/cwregistry/types/codec.go b/x/cwregistry/types/codec.go new file mode 100644 index 00000000..795dd087 --- /dev/null +++ b/x/cwregistry/types/codec.go @@ -0,0 +1,35 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterCodec registers concrete types on the Amino codec +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRegisterContract{}, "/archway.cwregistry.v1.MsgRegisterContract", nil) + cdc.RegisterConcrete(&MsgRegisterCode{}, "/archway.cwregistry.v1.MsgRegisterCode", nil) +} + +// RegisterInterfaces registers the x/cwica interfaces types with the interface registry +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRegisterContract{}, + &MsgRegisterCode{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) + +func init() { + RegisterLegacyAminoCodec(legacy.Cdc) +} diff --git a/x/cwregistry/types/errors.go b/x/cwregistry/types/errors.go new file mode 100644 index 00000000..e5463f70 --- /dev/null +++ b/x/cwregistry/types/errors.go @@ -0,0 +1,10 @@ +package types + +import ( + "cosmossdk.io/errors" +) + +// x/cwregistry module sentinel errors +var ( + ErrNotContract = errors.Register(ModuleName, 1103, "not a contract") +) diff --git a/x/cwregistry/types/expected_keepers.go b/x/cwregistry/types/expected_keepers.go new file mode 100644 index 00000000..b906bba6 --- /dev/null +++ b/x/cwregistry/types/expected_keepers.go @@ -0,0 +1,14 @@ +package types + +import ( + context "context" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// WasmKeeper defines the expected interface needed to interact with the wasm module. +type WasmKeeper interface { + HasContractInfo(ctx context.Context, contractAddress sdk.AccAddress) bool + GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *wasmtypes.ContractInfo +} diff --git a/x/cwregistry/types/genesis.go b/x/cwregistry/types/genesis.go new file mode 100644 index 00000000..3b1af3b0 --- /dev/null +++ b/x/cwregistry/types/genesis.go @@ -0,0 +1,12 @@ +package types + +// DefaultGenesis returns the default Capability genesis state +func DefaultGenesis() *GenesisState { + panic("unimplemented 👻") +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + panic("unimplemented 👻") +} diff --git a/x/cwregistry/types/keys.go b/x/cwregistry/types/keys.go new file mode 100644 index 00000000..132a14c3 --- /dev/null +++ b/x/cwregistry/types/keys.go @@ -0,0 +1,21 @@ +package types + +import "cosmossdk.io/collections" + +const ( + // ModuleName defines the module name + ModuleName = "cwregistry" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName +) + +var ( + CodeMetadataKeyPrefix = collections.NewPrefix(1) +) diff --git a/x/cwregistry/types/msg.go b/x/cwregistry/types/msg.go new file mode 100644 index 00000000..8e4694bf --- /dev/null +++ b/x/cwregistry/types/msg.go @@ -0,0 +1,10 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = &MsgRegisterContract{} + _ sdk.Msg = &MsgRegisterCode{} +) From 53081f7e7cede1a645260d9c1a6870b1230bfb89 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:53:15 +0100 Subject: [PATCH 03/19] adding query proto --- proto/archway/cwregistry/v1/query.proto | 68 +- x/cwregistry/keeper/grpc_query.go | 22 + x/cwregistry/types/query.pb.go | 1668 ++++++++++++++++++++++- x/cwregistry/types/query.pb.gw.go | 420 ++++++ 4 files changed, 2164 insertions(+), 14 deletions(-) create mode 100644 x/cwregistry/types/query.pb.gw.go diff --git a/proto/archway/cwregistry/v1/query.proto b/proto/archway/cwregistry/v1/query.proto index 1a3d5de7..b8a969ab 100644 --- a/proto/archway/cwregistry/v1/query.proto +++ b/proto/archway/cwregistry/v1/query.proto @@ -1,9 +1,75 @@ syntax = "proto3"; package archway.cwregistry.v1; +import "gogoproto/gogo.proto"; +import "archway/cwregistry/v1/cwregistry.proto"; +import "google/api/annotations.proto"; + option go_package = "github.com/archway-network/archway/x/cwregistry/types"; -// Query defines the gRPC querier service. +// Query service for the cwregistry module. service Query { + rpc CodeMetadata(QueryCodeMetadataRequest) returns (QueryCodeMetadataResponse) { + option (google.api.http).get = "/archway/cwregistry/v1/code_metadata"; + } + + rpc ContractMetadata(QueryContractMetadataRequest) returns (QueryContractMetadataResponse) { + option (google.api.http).get = "/archway/cwregistry/v1/contract_metadata"; + } + + rpc CodeSchema(QueryCodeSchemaRequest) returns (QueryCodeSchemaResponse) { + option (google.api.http).get = "/archway/cwregistry/v1/code_schema"; + } + + rpc ContractSchema(QueryContractSchemaRequest) returns (QueryContractSchemaResponse) { + option (google.api.http).get = "/archway/cwregistry/v1/contract_schema"; + } +} + +// QueryCodeMetadataRequest is the request type for the Query/CodeMetadata RPC method. +message QueryCodeMetadataRequest { + // code_id is the contract code id to query metadata for. + uint64 code_id = 1; +} + +// QueryContractMetadataRequest is the request type for the Query/ContractMetadata RPC method. +message QueryCodeMetadataResponse { + // code_metadata is the metadata for the contract code. + CodeMetadata code_metadata = 1; +} + +// QueryContractMetadataRequest is the request type for the Query/ContractMetadata RPC method. +message QueryContractMetadataRequest { + // contract_address is the bech32 contract address to query metadata for. + string contract_address = 1; +} + +// QueryContractMetadataResponse is the response type for the Query/ContractMetadata RPC method. +message QueryContractMetadataResponse { + // contract_metadata is the metadata for the contract. + CodeMetadata code_metadata = 1; +} + +// QueryCodeSchemaRequest is the request type for the Query/CodeSchema RPC method. +message QueryCodeSchemaRequest { + // code_id is the contract code id to query schema for. + uint64 code_id = 1; +} + +// QueryCodeSchemaResponse is the response type for the Query/CodeSchema RPC method. +message QueryCodeSchemaResponse { + // code_schema is the schema for the contract code. + string schema = 1; +} + +// QueryContractSchemaRequest is the request type for the Query/ContractSchema RPC method. +message QueryContractSchemaRequest { + // contract_address is the bech32 contract address to query schema for. + string contract_address = 1; +} +// QueryContractSchemaResponse is the response type for the Query/ContractSchema RPC method. +message QueryContractSchemaResponse { + // contract_schema is the schema for the contract. + string schema = 1; } \ No newline at end of file diff --git a/x/cwregistry/keeper/grpc_query.go b/x/cwregistry/keeper/grpc_query.go index ef8851a4..24ae2079 100644 --- a/x/cwregistry/keeper/grpc_query.go +++ b/x/cwregistry/keeper/grpc_query.go @@ -1,6 +1,8 @@ package keeper import ( + "context" + "github.com/archway-network/archway/x/cwregistry/types" ) @@ -16,3 +18,23 @@ func NewQueryServer(keeper Keeper) *QueryServer { keeper: keeper, } } + +// CodeMetadata implements types.QueryServer. +func (q *QueryServer) CodeMetadata(context.Context, *types.QueryCodeMetadataRequest) (*types.QueryCodeMetadataResponse, error) { + panic("unimplemented") +} + +// CodeSchema implements types.QueryServer. +func (q *QueryServer) CodeSchema(context.Context, *types.QueryCodeSchemaRequest) (*types.QueryCodeSchemaResponse, error) { + panic("unimplemented") +} + +// ContractMetadata implements types.QueryServer. +func (q *QueryServer) ContractMetadata(context.Context, *types.QueryContractMetadataRequest) (*types.QueryContractMetadataResponse, error) { + panic("unimplemented") +} + +// ContractSchema implements types.QueryServer. +func (q *QueryServer) ContractSchema(context.Context, *types.QueryContractSchemaRequest) (*types.QueryContractSchemaResponse, error) { + panic("unimplemented") +} diff --git a/x/cwregistry/types/query.pb.go b/x/cwregistry/types/query.pb.go index fa135e47..8e8d5385 100644 --- a/x/cwregistry/types/query.pb.go +++ b/x/cwregistry/types/query.pb.go @@ -6,10 +6,16 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" 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" + 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. @@ -23,19 +29,421 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryCodeMetadataRequest is the request type for the Query/CodeMetadata RPC method. +type QueryCodeMetadataRequest struct { + // code_id is the contract code id to query metadata for. + CodeId uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` +} + +func (m *QueryCodeMetadataRequest) Reset() { *m = QueryCodeMetadataRequest{} } +func (m *QueryCodeMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCodeMetadataRequest) ProtoMessage() {} +func (*QueryCodeMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{0} +} +func (m *QueryCodeMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCodeMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCodeMetadataRequest.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 *QueryCodeMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCodeMetadataRequest.Merge(m, src) +} +func (m *QueryCodeMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCodeMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCodeMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCodeMetadataRequest proto.InternalMessageInfo + +func (m *QueryCodeMetadataRequest) GetCodeId() uint64 { + if m != nil { + return m.CodeId + } + return 0 +} + +// QueryContractMetadataRequest is the request type for the Query/ContractMetadata RPC method. +type QueryCodeMetadataResponse struct { + // code_metadata is the metadata for the contract code. + CodeMetadata *CodeMetadata `protobuf:"bytes,1,opt,name=code_metadata,json=codeMetadata,proto3" json:"code_metadata,omitempty"` +} + +func (m *QueryCodeMetadataResponse) Reset() { *m = QueryCodeMetadataResponse{} } +func (m *QueryCodeMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCodeMetadataResponse) ProtoMessage() {} +func (*QueryCodeMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{1} +} +func (m *QueryCodeMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCodeMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCodeMetadataResponse.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 *QueryCodeMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCodeMetadataResponse.Merge(m, src) +} +func (m *QueryCodeMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCodeMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCodeMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCodeMetadataResponse proto.InternalMessageInfo + +func (m *QueryCodeMetadataResponse) GetCodeMetadata() *CodeMetadata { + if m != nil { + return m.CodeMetadata + } + return nil +} + +// QueryContractMetadataRequest is the request type for the Query/ContractMetadata RPC method. +type QueryContractMetadataRequest struct { + // contract_address is the bech32 contract address to query metadata for. + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *QueryContractMetadataRequest) Reset() { *m = QueryContractMetadataRequest{} } +func (m *QueryContractMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryContractMetadataRequest) ProtoMessage() {} +func (*QueryContractMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{2} +} +func (m *QueryContractMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryContractMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractMetadataRequest.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 *QueryContractMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractMetadataRequest.Merge(m, src) +} +func (m *QueryContractMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryContractMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractMetadataRequest proto.InternalMessageInfo + +func (m *QueryContractMetadataRequest) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +// QueryContractMetadataResponse is the response type for the Query/ContractMetadata RPC method. +type QueryContractMetadataResponse struct { + // contract_metadata is the metadata for the contract. + CodeMetadata *CodeMetadata `protobuf:"bytes,1,opt,name=code_metadata,json=codeMetadata,proto3" json:"code_metadata,omitempty"` +} + +func (m *QueryContractMetadataResponse) Reset() { *m = QueryContractMetadataResponse{} } +func (m *QueryContractMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryContractMetadataResponse) ProtoMessage() {} +func (*QueryContractMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{3} +} +func (m *QueryContractMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryContractMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractMetadataResponse.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 *QueryContractMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractMetadataResponse.Merge(m, src) +} +func (m *QueryContractMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryContractMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractMetadataResponse proto.InternalMessageInfo + +func (m *QueryContractMetadataResponse) GetCodeMetadata() *CodeMetadata { + if m != nil { + return m.CodeMetadata + } + return nil +} + +// QueryCodeSchemaRequest is the request type for the Query/CodeSchema RPC method. +type QueryCodeSchemaRequest struct { + // code_id is the contract code id to query schema for. + CodeId uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` +} + +func (m *QueryCodeSchemaRequest) Reset() { *m = QueryCodeSchemaRequest{} } +func (m *QueryCodeSchemaRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCodeSchemaRequest) ProtoMessage() {} +func (*QueryCodeSchemaRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{4} +} +func (m *QueryCodeSchemaRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCodeSchemaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCodeSchemaRequest.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 *QueryCodeSchemaRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCodeSchemaRequest.Merge(m, src) +} +func (m *QueryCodeSchemaRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCodeSchemaRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCodeSchemaRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCodeSchemaRequest proto.InternalMessageInfo + +func (m *QueryCodeSchemaRequest) GetCodeId() uint64 { + if m != nil { + return m.CodeId + } + return 0 +} + +// QueryCodeSchemaResponse is the response type for the Query/CodeSchema RPC method. +type QueryCodeSchemaResponse struct { + // code_schema is the schema for the contract code. + Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"` +} + +func (m *QueryCodeSchemaResponse) Reset() { *m = QueryCodeSchemaResponse{} } +func (m *QueryCodeSchemaResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCodeSchemaResponse) ProtoMessage() {} +func (*QueryCodeSchemaResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{5} +} +func (m *QueryCodeSchemaResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCodeSchemaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCodeSchemaResponse.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 *QueryCodeSchemaResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCodeSchemaResponse.Merge(m, src) +} +func (m *QueryCodeSchemaResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCodeSchemaResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCodeSchemaResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCodeSchemaResponse proto.InternalMessageInfo + +func (m *QueryCodeSchemaResponse) GetSchema() string { + if m != nil { + return m.Schema + } + return "" +} + +// QueryContractSchemaRequest is the request type for the Query/ContractSchema RPC method. +type QueryContractSchemaRequest struct { + // contract_address is the bech32 contract address to query schema for. + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *QueryContractSchemaRequest) Reset() { *m = QueryContractSchemaRequest{} } +func (m *QueryContractSchemaRequest) String() string { return proto.CompactTextString(m) } +func (*QueryContractSchemaRequest) ProtoMessage() {} +func (*QueryContractSchemaRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{6} +} +func (m *QueryContractSchemaRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryContractSchemaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractSchemaRequest.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 *QueryContractSchemaRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractSchemaRequest.Merge(m, src) +} +func (m *QueryContractSchemaRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryContractSchemaRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractSchemaRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractSchemaRequest proto.InternalMessageInfo + +func (m *QueryContractSchemaRequest) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +// QueryContractSchemaResponse is the response type for the Query/ContractSchema RPC method. +type QueryContractSchemaResponse struct { + // contract_schema is the schema for the contract. + Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"` +} + +func (m *QueryContractSchemaResponse) Reset() { *m = QueryContractSchemaResponse{} } +func (m *QueryContractSchemaResponse) String() string { return proto.CompactTextString(m) } +func (*QueryContractSchemaResponse) ProtoMessage() {} +func (*QueryContractSchemaResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d970ba8222896566, []int{7} +} +func (m *QueryContractSchemaResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryContractSchemaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractSchemaResponse.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 *QueryContractSchemaResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractSchemaResponse.Merge(m, src) +} +func (m *QueryContractSchemaResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryContractSchemaResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractSchemaResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractSchemaResponse proto.InternalMessageInfo + +func (m *QueryContractSchemaResponse) GetSchema() string { + if m != nil { + return m.Schema + } + return "" +} + +func init() { + proto.RegisterType((*QueryCodeMetadataRequest)(nil), "archway.cwregistry.v1.QueryCodeMetadataRequest") + proto.RegisterType((*QueryCodeMetadataResponse)(nil), "archway.cwregistry.v1.QueryCodeMetadataResponse") + proto.RegisterType((*QueryContractMetadataRequest)(nil), "archway.cwregistry.v1.QueryContractMetadataRequest") + proto.RegisterType((*QueryContractMetadataResponse)(nil), "archway.cwregistry.v1.QueryContractMetadataResponse") + proto.RegisterType((*QueryCodeSchemaRequest)(nil), "archway.cwregistry.v1.QueryCodeSchemaRequest") + proto.RegisterType((*QueryCodeSchemaResponse)(nil), "archway.cwregistry.v1.QueryCodeSchemaResponse") + proto.RegisterType((*QueryContractSchemaRequest)(nil), "archway.cwregistry.v1.QueryContractSchemaRequest") + proto.RegisterType((*QueryContractSchemaResponse)(nil), "archway.cwregistry.v1.QueryContractSchemaResponse") +} + func init() { proto.RegisterFile("archway/cwregistry/v1/query.proto", fileDescriptor_d970ba8222896566) } var fileDescriptor_d970ba8222896566 = []byte{ - // 143 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x2c, 0x4a, 0xce, - 0x28, 0x4f, 0xac, 0xd4, 0x4f, 0x2e, 0x2f, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0xaa, 0xd4, 0x2f, - 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x85, - 0x2a, 0xd1, 0x43, 0x28, 0xd1, 0x2b, 0x33, 0x34, 0x62, 0xe7, 0x62, 0x0d, 0x04, 0xa9, 0x72, 0xf2, - 0x3f, 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, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, - 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x21, 0xba, 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, - 0xd9, 0x30, 0xbe, 0x7e, 0x05, 0xb2, 0xcd, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x7b, - 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x05, 0x7c, 0xdd, 0x33, 0x9c, 0x00, 0x00, 0x00, + // 500 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x6b, 0xc4, 0x8a, 0x78, 0x19, 0x30, 0x59, 0xb0, 0x8d, 0x30, 0x22, 0x08, 0x53, 0x55, + 0x26, 0x16, 0x2f, 0x2d, 0xfb, 0x00, 0xc0, 0x01, 0x76, 0x40, 0x88, 0x72, 0xe3, 0x32, 0x79, 0x8e, + 0x95, 0x46, 0xd0, 0xb8, 0xb3, 0xdd, 0x95, 0x5e, 0xf9, 0x04, 0x48, 0x1c, 0x38, 0xee, 0xc8, 0x91, + 0xaf, 0xc1, 0x71, 0x12, 0x17, 0x8e, 0xa8, 0xe5, 0x83, 0xa0, 0x3a, 0x5e, 0x97, 0x94, 0xa4, 0x7f, + 0x24, 0x6e, 0xb5, 0xfd, 0x3e, 0xcf, 0xfb, 0xf3, 0xf3, 0xba, 0x81, 0x07, 0x54, 0xb2, 0x76, 0x9f, + 0x0e, 0x08, 0xeb, 0x4b, 0x1e, 0xc5, 0x4a, 0xcb, 0x01, 0x39, 0x09, 0xc8, 0x71, 0x8f, 0xcb, 0x81, + 0xdf, 0x95, 0x42, 0x0b, 0x7c, 0xdb, 0x96, 0xf8, 0x17, 0x25, 0xfe, 0x49, 0xe0, 0xdc, 0x8a, 0x44, + 0x24, 0x4c, 0x05, 0x19, 0xff, 0x4a, 0x8b, 0x9d, 0x5a, 0xb1, 0x5f, 0x46, 0x9a, 0xd6, 0x6d, 0x45, + 0x42, 0x44, 0x1f, 0x38, 0xa1, 0xdd, 0x98, 0xd0, 0x24, 0x11, 0x9a, 0xea, 0x58, 0x24, 0x2a, 0x3d, + 0xf5, 0x9a, 0xb0, 0xf9, 0x66, 0x4c, 0xf0, 0x5c, 0x84, 0xfc, 0x15, 0xd7, 0x34, 0xa4, 0x9a, 0xb6, + 0xf8, 0x71, 0x8f, 0x2b, 0x8d, 0x37, 0xe0, 0x0a, 0x13, 0x21, 0x3f, 0x8c, 0xc3, 0x4d, 0x74, 0x1f, + 0xd5, 0x2f, 0xb7, 0xaa, 0xe3, 0xe5, 0x41, 0xe8, 0x71, 0xb8, 0x53, 0x20, 0x52, 0x5d, 0x91, 0x28, + 0x8e, 0x5f, 0xc2, 0x75, 0xa3, 0xea, 0xd8, 0x03, 0xa3, 0xbd, 0xd6, 0x78, 0xe8, 0x17, 0x5e, 0xce, + 0xcf, 0x79, 0xac, 0xb2, 0xcc, 0xca, 0x3b, 0x80, 0x2d, 0xdb, 0x26, 0xd1, 0x92, 0x32, 0x3d, 0xcd, + 0xf7, 0x08, 0xd6, 0x98, 0x3d, 0x3a, 0xa4, 0x61, 0x28, 0xb9, 0x52, 0xa6, 0xd9, 0xd5, 0xd6, 0xcd, + 0xf3, 0xfd, 0xa7, 0xe9, 0xb6, 0x17, 0xc3, 0xbd, 0x12, 0xab, 0xff, 0x4e, 0x1d, 0xc0, 0xfa, 0x24, + 0x9c, 0xb7, 0xac, 0xcd, 0x3b, 0xf3, 0xf3, 0x0c, 0x60, 0xe3, 0x1f, 0x89, 0xe5, 0x5a, 0x87, 0xaa, + 0x32, 0x3b, 0xf6, 0x66, 0x76, 0xe5, 0xbd, 0x00, 0x27, 0x77, 0xa1, 0x7c, 0xa7, 0x25, 0x92, 0xd9, + 0x87, 0xbb, 0x85, 0x46, 0xb3, 0xfb, 0x37, 0x4e, 0x57, 0x60, 0xc5, 0xe8, 0xf0, 0x29, 0x82, 0xd5, + 0x6c, 0x1c, 0x98, 0x94, 0x64, 0x56, 0xf6, 0xce, 0x9c, 0xbd, 0xc5, 0x05, 0x29, 0x95, 0xf7, 0xf8, + 0xd3, 0xcf, 0x3f, 0x5f, 0x2e, 0xd5, 0xf0, 0x36, 0x29, 0xf9, 0x13, 0x64, 0x47, 0x89, 0xbf, 0x23, + 0x58, 0x9b, 0x1e, 0x3c, 0x6e, 0xce, 0x6e, 0x5a, 0xf8, 0xe2, 0x9c, 0x27, 0xcb, 0x89, 0x2c, 0xed, + 0x9e, 0xa1, 0xdd, 0xc1, 0xf5, 0x52, 0x5a, 0x3b, 0xaa, 0x09, 0xf1, 0x57, 0x04, 0x70, 0xf1, 0x18, + 0xf0, 0xee, 0xbc, 0x80, 0x72, 0xd3, 0x77, 0xfc, 0x45, 0xcb, 0x2d, 0xdf, 0x8e, 0xe1, 0xdb, 0xc6, + 0xde, 0xac, 0x34, 0xd3, 0xb9, 0xe3, 0x6f, 0x08, 0x6e, 0xe4, 0x9f, 0x0a, 0x0e, 0x16, 0x09, 0x25, + 0x4f, 0xd8, 0x58, 0x46, 0x62, 0x29, 0x7d, 0x43, 0x59, 0xc7, 0xb5, 0x79, 0x29, 0xa6, 0xa4, 0xcf, + 0x5e, 0xff, 0x18, 0xba, 0xe8, 0x6c, 0xe8, 0xa2, 0xdf, 0x43, 0x17, 0x7d, 0x1e, 0xb9, 0x95, 0xb3, + 0x91, 0x5b, 0xf9, 0x35, 0x72, 0x2b, 0xef, 0xf6, 0xa3, 0x58, 0xb7, 0x7b, 0x47, 0x3e, 0x13, 0x9d, + 0x73, 0xaf, 0xdd, 0x84, 0xeb, 0xbe, 0x90, 0xef, 0x27, 0xde, 0x1f, 0xb3, 0xee, 0x7a, 0xd0, 0xe5, + 0xea, 0xa8, 0x6a, 0xbe, 0x98, 0xcd, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x79, 0x8e, 0xf5, 0x56, + 0xc9, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -50,6 +458,10 @@ 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 { + CodeMetadata(ctx context.Context, in *QueryCodeMetadataRequest, opts ...grpc.CallOption) (*QueryCodeMetadataResponse, error) + ContractMetadata(ctx context.Context, in *QueryContractMetadataRequest, opts ...grpc.CallOption) (*QueryContractMetadataResponse, error) + CodeSchema(ctx context.Context, in *QueryCodeSchemaRequest, opts ...grpc.CallOption) (*QueryCodeSchemaResponse, error) + ContractSchema(ctx context.Context, in *QueryContractSchemaRequest, opts ...grpc.CallOption) (*QueryContractSchemaResponse, error) } type queryClient struct { @@ -60,22 +472,1252 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) CodeMetadata(ctx context.Context, in *QueryCodeMetadataRequest, opts ...grpc.CallOption) (*QueryCodeMetadataResponse, error) { + out := new(QueryCodeMetadataResponse) + err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Query/CodeMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ContractMetadata(ctx context.Context, in *QueryContractMetadataRequest, opts ...grpc.CallOption) (*QueryContractMetadataResponse, error) { + out := new(QueryContractMetadataResponse) + err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Query/ContractMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CodeSchema(ctx context.Context, in *QueryCodeSchemaRequest, opts ...grpc.CallOption) (*QueryCodeSchemaResponse, error) { + out := new(QueryCodeSchemaResponse) + err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Query/CodeSchema", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ContractSchema(ctx context.Context, in *QueryContractSchemaRequest, opts ...grpc.CallOption) (*QueryContractSchemaResponse, error) { + out := new(QueryContractSchemaResponse) + err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Query/ContractSchema", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { + CodeMetadata(context.Context, *QueryCodeMetadataRequest) (*QueryCodeMetadataResponse, error) + ContractMetadata(context.Context, *QueryContractMetadataRequest) (*QueryContractMetadataResponse, error) + CodeSchema(context.Context, *QueryCodeSchemaRequest) (*QueryCodeSchemaResponse, error) + ContractSchema(context.Context, *QueryContractSchemaRequest) (*QueryContractSchemaResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) CodeMetadata(ctx context.Context, req *QueryCodeMetadataRequest) (*QueryCodeMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CodeMetadata not implemented") +} +func (*UnimplementedQueryServer) ContractMetadata(ctx context.Context, req *QueryContractMetadataRequest) (*QueryContractMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ContractMetadata not implemented") +} +func (*UnimplementedQueryServer) CodeSchema(ctx context.Context, req *QueryCodeSchemaRequest) (*QueryCodeSchemaResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CodeSchema not implemented") +} +func (*UnimplementedQueryServer) ContractSchema(ctx context.Context, req *QueryContractSchemaRequest) (*QueryContractSchemaResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ContractSchema not implemented") +} + func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_CodeMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCodeMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CodeMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/archway.cwregistry.v1.Query/CodeMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CodeMetadata(ctx, req.(*QueryCodeMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ContractMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryContractMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ContractMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/archway.cwregistry.v1.Query/ContractMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ContractMetadata(ctx, req.(*QueryContractMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CodeSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCodeSchemaRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CodeSchema(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/archway.cwregistry.v1.Query/CodeSchema", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CodeSchema(ctx, req.(*QueryCodeSchemaRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ContractSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryContractSchemaRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ContractSchema(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/archway.cwregistry.v1.Query/ContractSchema", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ContractSchema(ctx, req.(*QueryContractSchemaRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "archway.cwregistry.v1.Query", HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "archway/cwregistry/v1/query.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "CodeMetadata", + Handler: _Query_CodeMetadata_Handler, + }, + { + MethodName: "ContractMetadata", + Handler: _Query_ContractMetadata_Handler, + }, + { + MethodName: "CodeSchema", + Handler: _Query_CodeSchema_Handler, + }, + { + MethodName: "ContractSchema", + Handler: _Query_ContractSchema_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "archway/cwregistry/v1/query.proto", +} + +func (m *QueryCodeMetadataRequest) 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 *QueryCodeMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCodeMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CodeId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CodeId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryCodeMetadataResponse) 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 *QueryCodeMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCodeMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CodeMetadata != nil { + { + size, err := m.CodeMetadata.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 *QueryContractMetadataRequest) 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 *QueryContractMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryContractMetadataResponse) 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 *QueryContractMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CodeMetadata != nil { + { + size, err := m.CodeMetadata.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 *QueryCodeSchemaRequest) 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 *QueryCodeSchemaRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCodeSchemaRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CodeId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CodeId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryCodeSchemaResponse) 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 *QueryCodeSchemaResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCodeSchemaResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } + +func (m *QueryContractSchemaRequest) 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 *QueryContractSchemaRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractSchemaRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryContractSchemaResponse) 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 *QueryContractSchemaResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractSchemaResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Schema))) + 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 *QueryCodeMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeId != 0 { + n += 1 + sovQuery(uint64(m.CodeId)) + } + return n +} + +func (m *QueryCodeMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeMetadata != nil { + l = m.CodeMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryContractMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryContractMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeMetadata != nil { + l = m.CodeMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCodeSchemaRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeId != 0 { + n += 1 + sovQuery(uint64(m.CodeId)) + } + return n +} + +func (m *QueryCodeSchemaResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Schema) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryContractSchemaRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryContractSchemaResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Schema) + if l > 0 { + 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 *QueryCodeMetadataRequest) 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: QueryCodeMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCodeMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + m.CodeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryCodeMetadataResponse) 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: QueryCodeMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCodeMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeMetadata", 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.CodeMetadata == nil { + m.CodeMetadata = &CodeMetadata{} + } + if err := m.CodeMetadata.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 *QueryContractMetadataRequest) 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: QueryContractMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = 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 *QueryContractMetadataResponse) 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: QueryContractMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeMetadata", 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.CodeMetadata == nil { + m.CodeMetadata = &CodeMetadata{} + } + if err := m.CodeMetadata.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 *QueryCodeSchemaRequest) 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: QueryCodeSchemaRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCodeSchemaRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + m.CodeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryCodeSchemaResponse) 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: QueryCodeSchemaResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCodeSchemaResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", 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.Schema = 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 *QueryContractSchemaRequest) 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: QueryContractSchemaRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractSchemaRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = 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 *QueryContractSchemaResponse) 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: QueryContractSchemaResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractSchemaResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", 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.Schema = 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 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/cwregistry/types/query.pb.gw.go b/x/cwregistry/types/query.pb.gw.go new file mode 100644 index 00000000..64514719 --- /dev/null +++ b/x/cwregistry/types/query.pb.gw.go @@ -0,0 +1,420 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: archway/cwregistry/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +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_CodeMetadata_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_CodeMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCodeMetadataRequest + 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_CodeMetadata_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CodeMetadata(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CodeMetadata_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCodeMetadataRequest + 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_CodeMetadata_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CodeMetadata(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ContractMetadata_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_ContractMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractMetadataRequest + 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_ContractMetadata_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ContractMetadata(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ContractMetadata_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractMetadataRequest + 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_ContractMetadata_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ContractMetadata(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_CodeSchema_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_CodeSchema_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCodeSchemaRequest + 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_CodeSchema_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CodeSchema(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CodeSchema_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCodeSchemaRequest + 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_CodeSchema_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CodeSchema(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ContractSchema_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_ContractSchema_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractSchemaRequest + 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_ContractSchema_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ContractSchema(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ContractSchema_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractSchemaRequest + 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_ContractSchema_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ContractSchema(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_CodeMetadata_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_CodeMetadata_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_CodeMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ContractMetadata_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_ContractMetadata_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_ContractMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CodeSchema_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_CodeSchema_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_CodeSchema_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ContractSchema_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_ContractSchema_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_ContractSchema_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_CodeMetadata_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_CodeMetadata_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_CodeMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ContractMetadata_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_ContractMetadata_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_ContractMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CodeSchema_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_CodeSchema_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_CodeSchema_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ContractSchema_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_ContractSchema_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_ContractSchema_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_CodeMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "code_metadata"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ContractMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "contract_metadata"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_CodeSchema_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "code_schema"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ContractSchema_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "contract_schema"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_CodeMetadata_0 = runtime.ForwardResponseMessage + + forward_Query_ContractMetadata_0 = runtime.ForwardResponseMessage + + forward_Query_CodeSchema_0 = runtime.ForwardResponseMessage + + forward_Query_ContractSchema_0 = runtime.ForwardResponseMessage +) From 62cbe2bba96db98aa34d4638ea4b5b259c200614 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:56:06 +0100 Subject: [PATCH 04/19] adding mock keeper --- pkg/testutils/cwregistrykeeper.go | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 pkg/testutils/cwregistrykeeper.go diff --git a/pkg/testutils/cwregistrykeeper.go b/pkg/testutils/cwregistrykeeper.go new file mode 100644 index 00000000..e709f064 --- /dev/null +++ b/pkg/testutils/cwregistrykeeper.go @@ -0,0 +1,46 @@ +package testutils + +import ( + "testing" + + "cosmossdk.io/log" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/archway-network/archway/x/cwregistry/keeper" + "github.com/archway-network/archway/x/cwregistry/types" +) + +func CWRegistryKeeper(tb testing.TB) (keeper.Keeper, sdk.Context) { + tb.Helper() + storeKey := storetypes.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey("m_cwregistry") + tStoreKey := storetypes.NewTransientStoreKey("t_cwregistry") + + db := dbm.NewMemDB() + stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(tb), storemetrics.NewNoOpMetrics()) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + stateStore.MountStoreWithDB(tStoreKey, storetypes.StoreTypeTransient, db) + require.NoError(tb, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + k := keeper.NewKeeper( + cdc, + storeKey, + nil, + nil, + ) + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + return k, ctx +} From 05569e141fcd79850b98c0c97ff65af9a0542486 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 21 Jun 2024 20:58:25 +0100 Subject: [PATCH 05/19] implementing keeper --- x/cwregistry/keeper/code_metadata.go | 71 ++++++++++++++++++++++++++ x/cwregistry/keeper/keeper.go | 14 ++--- x/cwregistry/types/code_metadata.go | 49 ++++++++++++++++++ x/cwregistry/types/errors.go | 5 +- x/cwregistry/types/expected_keepers.go | 4 +- 5 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 x/cwregistry/keeper/code_metadata.go create mode 100644 x/cwregistry/types/code_metadata.go diff --git a/x/cwregistry/keeper/code_metadata.go b/x/cwregistry/keeper/code_metadata.go new file mode 100644 index 00000000..6f881276 --- /dev/null +++ b/x/cwregistry/keeper/code_metadata.go @@ -0,0 +1,71 @@ +package keeper + +import ( + "crypto/sha256" + "encoding/hex" + + "github.com/archway-network/archway/x/cwregistry/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetAllCallbacks returns all code metadata stored +func (k Keeper) GetAllCallbacks(ctx sdk.Context) (codeMetadata []types.CodeMetadata, err error) { + err = k.CodeMetadata.Walk(ctx, nil, func(key uint64, value types.CodeMetadata) (stop bool, err error) { + codeMetadata = append(codeMetadata, value) + return false, nil + }) + return codeMetadata, err +} + +// GetCodeMetadata returns the code metadata for the given codeID +func (k Keeper) GetCodeMetadata(ctx sdk.Context, codeID uint64) (types.CodeMetadata, error) { + return k.CodeMetadata.Get(ctx, codeID) +} + +// SetContractMetadata sets the metadata for the contract with the given address +func (k Keeper) SetContractMetadata(ctx sdk.Context, sender sdk.AccAddress, contractAddress sdk.AccAddress, codeMetadata types.CodeMetadata) error { + contractInfo := k.wasmKeeper.GetContractInfo(ctx, contractAddress) + if contractInfo == nil { + return types.ErrNoSuchContract + } + if contractInfo.Creator != sender.String() && contractInfo.Admin != sender.String() && sender.String() != contractAddress.String() { + return types.ErrUnauthorized + } + codeID := contractInfo.CodeID + codeMetadata.CodeId = codeID + return k.saveCodeMetadata(ctx, codeMetadata) +} + +// SetCodeMetadata sets the metadata for the code with the given codeID +func (k Keeper) SetCodeMetadata(ctx sdk.Context, sender sdk.AccAddress, codeID uint64, codeMetadata types.CodeMetadata) error { + codeInfo := k.wasmKeeper.GetCodeInfo(ctx, codeID) + if codeInfo == nil { + return types.ErrNoSuchCode + } + if codeInfo.Creator != sender.String() { + return types.ErrUnauthorized + } + codeMetadata.CodeId = codeID + return k.saveCodeMetadata(ctx, codeMetadata) +} + +// saveCodeMetadata saves the code metadata to the store +func (k Keeper) saveCodeMetadata(ctx sdk.Context, codeMetadata types.CodeMetadata) error { + schemaContent := codeMetadata.Schema + if len(schemaContent) > 255 { // we dont want to store large schemas in the store + // todo: save to fs + schemaHash := hash(schemaContent) + codeMetadata.Schema = schemaHash + } + if err := codeMetadata.Validate(); err != nil { + return err + } + return k.CodeMetadata.Set(ctx, codeMetadata.CodeId, codeMetadata) +} + +// hash returns the sha256 hash of the given schema +func hash(schemaContent string) string { + hasher := sha256.New() + hasher.Write([]byte(schemaContent)) + return hex.EncodeToString(hasher.Sum(nil)) +} diff --git a/x/cwregistry/keeper/keeper.go b/x/cwregistry/keeper/keeper.go index ed9eae1b..97a77192 100644 --- a/x/cwregistry/keeper/keeper.go +++ b/x/cwregistry/keeper/keeper.go @@ -16,19 +16,19 @@ type ( Keeper struct { Codec codec.BinaryCodec storeKey storetypes.StoreKey - sudoKeeper types.WasmKeeper + wasmKeeper types.WasmKeeper logger log.Logger Schema collections.Schema // CodeMetadata key: CodeMetadataKeyPrefix + codeID | value: CodeMetadata - CodeMetadata collections.Map[uint32, types.CodeMetadata] + CodeMetadata collections.Map[uint64, types.CodeMetadata] } ) func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, - sudoKeeper types.WasmKeeper, + wasmKeeper types.WasmKeeper, logger log.Logger, ) Keeper { sb := collections.NewSchemaBuilder(collcompat.NewKVStoreService(storeKey)) @@ -36,13 +36,13 @@ func NewKeeper( k := Keeper{ Codec: cdc, storeKey: storeKey, - sudoKeeper: sudoKeeper, + wasmKeeper: wasmKeeper, logger: logger.With("module", "x/"+types.ModuleName), CodeMetadata: collections.NewMap( sb, types.CodeMetadataKeyPrefix, - "code_metadatas", - collections.Uint32Key, + "code_metadata", + collections.Uint64Key, collcompat.ProtoValue[types.CodeMetadata](cdc), ), } @@ -63,5 +63,5 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // SetWasmKeeper sets the given wasm keeper. // NOTE: Only for testing purposes func (k *Keeper) SetWasmKeeper(wk types.WasmKeeper) { - k.sudoKeeper = wk + k.wasmKeeper = wk } diff --git a/x/cwregistry/types/code_metadata.go b/x/cwregistry/types/code_metadata.go new file mode 100644 index 00000000..61517cc4 --- /dev/null +++ b/x/cwregistry/types/code_metadata.go @@ -0,0 +1,49 @@ +package types + +import ( + "errors" + "net/url" +) + +func (c CodeMetadata) Validate() error { + if c.CodeId == 0 { + return ErrNoSuchCode + } + if len(c.Schema) > 255 { + return ErrSchemaTooLarge + } + for _, contact := range c.Contacts { + if len(contact) > 255 { + return errors.New("contact text is too long") + } + } + if c.SourceBuilder != nil { + if len(c.SourceBuilder.ContractName) > 255 { + return errors.New("contract name is too long") + } + if len(c.SourceBuilder.Image) > 255 { + return errors.New("image is too long") + } + if len(c.SourceBuilder.Tag) > 255 { + return errors.New("tag is too long") + } + } + if c.Source != nil { + if len(c.Source.Repository) > 255 { + return errors.New("repository url is too long") + } + if len(c.Source.Tag) > 255 { + return errors.New("description is too long") + } + if len(c.Source.License) > 255 { + return errors.New("license is too long") + } + if c.Source.Repository != "" { + _, err := url.ParseRequestURI(c.Source.Repository) + if err != nil { + return errors.New("repository is not a valid URL") + } + } + } + return nil +} diff --git a/x/cwregistry/types/errors.go b/x/cwregistry/types/errors.go index e5463f70..ce8dd941 100644 --- a/x/cwregistry/types/errors.go +++ b/x/cwregistry/types/errors.go @@ -6,5 +6,8 @@ import ( // x/cwregistry module sentinel errors var ( - ErrNotContract = errors.Register(ModuleName, 1103, "not a contract") + ErrUnauthorized = errors.Register(ModuleName, 1100, "sender unauthorized to set the metadata") + ErrNoSuchCode = errors.Register(ModuleName, 1104, "code with given id does not exist") + ErrNoSuchContract = errors.Register(ModuleName, 1105, "contract with given address does not exist") + ErrSchemaTooLarge = errors.Register(ModuleName, 1106, "schema cannot be larger than 255 bytes") ) diff --git a/x/cwregistry/types/expected_keepers.go b/x/cwregistry/types/expected_keepers.go index b906bba6..174baf65 100644 --- a/x/cwregistry/types/expected_keepers.go +++ b/x/cwregistry/types/expected_keepers.go @@ -9,6 +9,8 @@ import ( // WasmKeeper defines the expected interface needed to interact with the wasm module. type WasmKeeper interface { - HasContractInfo(ctx context.Context, contractAddress sdk.AccAddress) bool + // GetContractInfo returns the contract info for the given address GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *wasmtypes.ContractInfo + // GetCodeInfo returns the code info for the given codeID + GetCodeInfo(ctx context.Context, codeID uint64) *wasmtypes.CodeInfo } From c5466e3b5c667a940198bf24cd3d151a7bb3b325 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:05:08 +0100 Subject: [PATCH 06/19] implement msg server --- x/cwregistry/keeper/msg_server.go | 45 ++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/x/cwregistry/keeper/msg_server.go b/x/cwregistry/keeper/msg_server.go index 4aa1a63f..8e34acdd 100644 --- a/x/cwregistry/keeper/msg_server.go +++ b/x/cwregistry/keeper/msg_server.go @@ -4,6 +4,9 @@ import ( "context" "github.com/archway-network/archway/x/cwregistry/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) type msgServer struct { @@ -19,11 +22,45 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } // RegisterCode implements types.MsgServer. -func (m msgServer) RegisterCode(context.Context, *types.MsgRegisterCode) (*types.MsgRegisterCodeResponse, error) { - panic("unimplemented") +func (m msgServer) RegisterCode(c context.Context, req *types.MsgRegisterCode) (*types.MsgRegisterCodeResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + sender, err := sdk.AccAddressFromBech32(req.Sender) + if err != nil { + return nil, err + } + codeMetadata := types.CodeMetadata{ + Source: req.SourceMetadata, + SourceBuilder: req.SourceBuilder, + Schema: req.Schema, + Contacts: req.Contacts, + } + err = m.SetCodeMetadata(ctx, sender, req.CodeId, codeMetadata) + return &types.MsgRegisterCodeResponse{}, err } // RegisterContract implements types.MsgServer. -func (m msgServer) RegisterContract(context.Context, *types.MsgRegisterContract) (*types.MsgRegisterContractResponse, error) { - panic("unimplemented") +func (m msgServer) RegisterContract(c context.Context, req *types.MsgRegisterContract) (*types.MsgRegisterContractResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + sender, err := sdk.AccAddressFromBech32(req.Sender) + if err != nil { + return nil, err + } + contractAddress, err := sdk.AccAddressFromBech32(req.ContractAddress) + if err != nil { + return nil, err + } + codeMetadata := types.CodeMetadata{ + Source: req.SourceMetadata, + SourceBuilder: req.SourceBuilder, + Schema: req.Schema, + Contacts: req.Contacts, + } + err = m.SetContractMetadata(ctx, sender, contractAddress, codeMetadata) + return &types.MsgRegisterContractResponse{}, err } From 182e441f8f0b046a50b98a4f0386f613a6a75d45 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:17:19 +0100 Subject: [PATCH 07/19] implement grpc queries --- x/cwregistry/keeper/code_metadata.go | 9 +++++ x/cwregistry/keeper/code_schema.go | 15 ++++++++ x/cwregistry/keeper/grpc_query.go | 55 ++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 x/cwregistry/keeper/code_schema.go diff --git a/x/cwregistry/keeper/code_metadata.go b/x/cwregistry/keeper/code_metadata.go index 6f881276..2de7b12e 100644 --- a/x/cwregistry/keeper/code_metadata.go +++ b/x/cwregistry/keeper/code_metadata.go @@ -22,6 +22,15 @@ func (k Keeper) GetCodeMetadata(ctx sdk.Context, codeID uint64) (types.CodeMetad return k.CodeMetadata.Get(ctx, codeID) } +// HasCodeMetadata returns true if the code metadata for the given codeID exists +func (k Keeper) HasCodeMetadata(ctx sdk.Context, codeID uint64) bool { + has, err := k.CodeMetadata.Has(ctx, codeID) + if err != nil { + return false + } + return has +} + // SetContractMetadata sets the metadata for the contract with the given address func (k Keeper) SetContractMetadata(ctx sdk.Context, sender sdk.AccAddress, contractAddress sdk.AccAddress, codeMetadata types.CodeMetadata) error { contractInfo := k.wasmKeeper.GetContractInfo(ctx, contractAddress) diff --git a/x/cwregistry/keeper/code_schema.go b/x/cwregistry/keeper/code_schema.go new file mode 100644 index 00000000..eab546e0 --- /dev/null +++ b/x/cwregistry/keeper/code_schema.go @@ -0,0 +1,15 @@ +package keeper + +import sdk "github.com/cosmos/cosmos-sdk/types" + +func (k Keeper) GetSchema(ctx sdk.Context, codeID uint64) (string, error) { + return "", nil +} + +func (k Keeper) SetSchema(ctx sdk.Context, codeID uint64, schema string) error { + return nil +} + +func (k Keeper) HasSchema(ctx sdk.Context, codeID uint64) bool { + return false +} diff --git a/x/cwregistry/keeper/grpc_query.go b/x/cwregistry/keeper/grpc_query.go index 24ae2079..da6970b2 100644 --- a/x/cwregistry/keeper/grpc_query.go +++ b/x/cwregistry/keeper/grpc_query.go @@ -4,6 +4,9 @@ import ( "context" "github.com/archway-network/archway/x/cwregistry/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) var _ types.QueryServer = &QueryServer{} @@ -20,21 +23,57 @@ func NewQueryServer(keeper Keeper) *QueryServer { } // CodeMetadata implements types.QueryServer. -func (q *QueryServer) CodeMetadata(context.Context, *types.QueryCodeMetadataRequest) (*types.QueryCodeMetadataResponse, error) { - panic("unimplemented") +func (q *QueryServer) CodeMetadata(c context.Context, req *types.QueryCodeMetadataRequest) (*types.QueryCodeMetadataResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + codeMetadata, err := q.keeper.GetCodeMetadata(ctx, req.GetCodeId()) + return &types.QueryCodeMetadataResponse{CodeMetadata: &codeMetadata}, err } // CodeSchema implements types.QueryServer. -func (q *QueryServer) CodeSchema(context.Context, *types.QueryCodeSchemaRequest) (*types.QueryCodeSchemaResponse, error) { - panic("unimplemented") +func (q *QueryServer) CodeSchema(c context.Context, req *types.QueryCodeSchemaRequest) (*types.QueryCodeSchemaResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + if !q.keeper.HasCodeMetadata(ctx, req.GetCodeId()) { + return nil, status.Error(codes.NotFound, "code metadata not found") + } + schema, err := q.keeper.GetSchema(ctx, req.GetCodeId()) + return &types.QueryCodeSchemaResponse{Schema: schema}, err } // ContractMetadata implements types.QueryServer. -func (q *QueryServer) ContractMetadata(context.Context, *types.QueryContractMetadataRequest) (*types.QueryContractMetadataResponse, error) { - panic("unimplemented") +func (q *QueryServer) ContractMetadata(c context.Context, req *types.QueryContractMetadataRequest) (*types.QueryContractMetadataResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + contractAddr, err := sdk.AccAddressFromBech32(req.GetContractAddress()) + if err != nil { + return nil, err + } + codeInfo := q.keeper.wasmKeeper.GetContractInfo(ctx, contractAddr) + codeMetadata, err := q.keeper.GetCodeMetadata(ctx, codeInfo.CodeID) + return &types.QueryContractMetadataResponse{CodeMetadata: &codeMetadata}, err } // ContractSchema implements types.QueryServer. -func (q *QueryServer) ContractSchema(context.Context, *types.QueryContractSchemaRequest) (*types.QueryContractSchemaResponse, error) { - panic("unimplemented") +func (q *QueryServer) ContractSchema(c context.Context, req *types.QueryContractSchemaRequest) (*types.QueryContractSchemaResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + contractAddr, err := sdk.AccAddressFromBech32(req.GetContractAddress()) + if err != nil { + return nil, err + } + codeInfo := q.keeper.wasmKeeper.GetContractInfo(ctx, contractAddr) + if !q.keeper.HasCodeMetadata(ctx, codeInfo.CodeID) { + return nil, status.Error(codes.NotFound, "code metadata not found") + } + schema, err := q.keeper.GetSchema(ctx, codeInfo.CodeID) + return &types.QueryContractSchemaResponse{Schema: schema}, err } From 873704a9eff8e7cbce796a0f2f14e04fd222a270 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:24:43 +0100 Subject: [PATCH 08/19] implment genesis init export --- x/cwregistry/genesis.go | 15 +++++++++++++-- x/cwregistry/keeper/code_metadata.go | 10 ++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/x/cwregistry/genesis.go b/x/cwregistry/genesis.go index abd20e8a..12b70e9c 100644 --- a/x/cwregistry/genesis.go +++ b/x/cwregistry/genesis.go @@ -10,10 +10,21 @@ import ( // InitGenesis initializes the cwregistry module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - panic("unimplemented 👻") + codeMetadata := genState.CodeMetadata + for _, metadata := range codeMetadata { + if err := k.UnsafeSetCodeMetadata(ctx, metadata); err != nil { + panic(err) + } + } } // ExportGenesis returns the cwregistry module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - panic("unimplemented 👻") + codeMetadata, err := k.GetAllCallbacks(ctx) + if err != nil { + panic(err) + } + return &types.GenesisState{ + CodeMetadata: codeMetadata, + } } diff --git a/x/cwregistry/keeper/code_metadata.go b/x/cwregistry/keeper/code_metadata.go index 2de7b12e..2f7cbfb7 100644 --- a/x/cwregistry/keeper/code_metadata.go +++ b/x/cwregistry/keeper/code_metadata.go @@ -58,6 +58,16 @@ func (k Keeper) SetCodeMetadata(ctx sdk.Context, sender sdk.AccAddress, codeID u return k.saveCodeMetadata(ctx, codeMetadata) } +// UnsafeSetCodeMetadata sets the metadata for the code with the given codeID without checking permissions +// Should only be used in genesis +func (k Keeper) UnsafeSetCodeMetadata(ctx sdk.Context, codeMetadata types.CodeMetadata) error { + codeInfo := k.wasmKeeper.GetCodeInfo(ctx, codeMetadata.CodeId) + if codeInfo == nil { + return types.ErrNoSuchCode + } + return k.saveCodeMetadata(ctx, codeMetadata) +} + // saveCodeMetadata saves the code metadata to the store func (k Keeper) saveCodeMetadata(ctx sdk.Context, codeMetadata types.CodeMetadata) error { schemaContent := codeMetadata.Schema From 1f42aa83a6659739309e239dc0ff4e3d9b3d551b Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:22:10 +0100 Subject: [PATCH 09/19] adding tests --- pkg/testutils/cwregistrykeeper.go | 2 +- pkg/testutils/wasmd.go | 16 +++++ x/cwregistry/genesis.go | 2 +- x/cwregistry/genesis_test.go | 54 ++++++++++++++ x/cwregistry/keeper/code_metadata_test.go | 62 ++++++++++++++++ x/cwregistry/keeper/msg_server_test.go | 86 +++++++++++++++++++++++ x/cwregistry/module.go | 2 +- x/cwregistry/types/code_metadata.go | 3 - 8 files changed, 221 insertions(+), 6 deletions(-) create mode 100644 x/cwregistry/genesis_test.go create mode 100644 x/cwregistry/keeper/code_metadata_test.go create mode 100644 x/cwregistry/keeper/msg_server_test.go diff --git a/pkg/testutils/cwregistrykeeper.go b/pkg/testutils/cwregistrykeeper.go index e709f064..93d31197 100644 --- a/pkg/testutils/cwregistrykeeper.go +++ b/pkg/testutils/cwregistrykeeper.go @@ -38,7 +38,7 @@ func CWRegistryKeeper(tb testing.TB) (keeper.Keeper, sdk.Context) { cdc, storeKey, nil, - nil, + log.NewTestLogger(tb), ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/pkg/testutils/wasmd.go b/pkg/testutils/wasmd.go index 5a5f24fa..fdc097c3 100644 --- a/pkg/testutils/wasmd.go +++ b/pkg/testutils/wasmd.go @@ -15,6 +15,7 @@ var _ wasmKeeper.Messenger = (*MockMessenger)(nil) // Mock returns a contract info if admin is set. type MockContractViewer struct { contractAdminSet map[string]string // key: contractAddr, value: adminAddr + codeAdminSet map[uint64]string // key: codeID, value: adminAddr returnSudoError error } @@ -22,6 +23,7 @@ type MockContractViewer struct { func NewMockContractViewer() *MockContractViewer { return &MockContractViewer{ contractAdminSet: make(map[string]string), + codeAdminSet: make(map[uint64]string), returnSudoError: nil, } } @@ -31,6 +33,10 @@ func (v *MockContractViewer) AddContractAdmin(contractAddr, adminAddr string) { v.contractAdminSet[contractAddr] = adminAddr } +func (v *MockContractViewer) AddCodeAdmin(codeID uint64, adminAddr string) { + v.codeAdminSet[codeID] = adminAddr +} + // GetContractInfo returns a contract info if admin is set. func (v MockContractViewer) GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *wasmdTypes.ContractInfo { adminAddr, found := v.contractAdminSet[contractAddress.String()] @@ -49,6 +55,16 @@ func (v MockContractViewer) HasContractInfo(ctx context.Context, contractAddress return found } +func (v MockContractViewer) GetCodeInfo(ctx context.Context, codeID uint64) *wasmdTypes.CodeInfo { + _, found := v.codeAdminSet[codeID] + if !found { + return nil + } + return &wasmdTypes.CodeInfo{ + Creator: v.codeAdminSet[codeID], + } +} + // Sudo implements the wasmKeeper.ContractInfoViewer interface. func (v MockContractViewer) Sudo(ctx context.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) { return nil, v.returnSudoError diff --git a/x/cwregistry/genesis.go b/x/cwregistry/genesis.go index 12b70e9c..fae8d4c7 100644 --- a/x/cwregistry/genesis.go +++ b/x/cwregistry/genesis.go @@ -1,4 +1,4 @@ -package cwica +package cwregistry import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/cwregistry/genesis_test.go b/x/cwregistry/genesis_test.go new file mode 100644 index 00000000..d1576108 --- /dev/null +++ b/x/cwregistry/genesis_test.go @@ -0,0 +1,54 @@ +package cwregistry_test + +import ( + "testing" + + "github.com/archway-network/archway/pkg/testutils" + "github.com/archway-network/archway/x/cwregistry" + "github.com/archway-network/archway/x/cwregistry/types" + "github.com/stretchr/testify/require" +) + +func TestExportGenesis(t *testing.T) { + keeper, ctx := testutils.CWRegistryKeeper(t) + wasmKeeper := testutils.NewMockContractViewer() + keeper.SetWasmKeeper(wasmKeeper) + senderAddr := testutils.AccAddress() + wasmKeeper.AddCodeAdmin(1, senderAddr.String()) + wasmKeeper.AddCodeAdmin(2, senderAddr.String()) + err := keeper.SetCodeMetadata(ctx, senderAddr, 1, types.CodeMetadata{}) + require.NoError(t, err) + err = keeper.SetCodeMetadata(ctx, senderAddr, 2, types.CodeMetadata{}) + require.NoError(t, err) + + genState := cwregistry.ExportGenesis(ctx, keeper) + + require.Equal(t, 2, len(genState.CodeMetadata)) +} + +func TestInitGenesis(t *testing.T) { + keeper, ctx := testutils.CWRegistryKeeper(t) + wasmKeeper := testutils.NewMockContractViewer() + keeper.SetWasmKeeper(wasmKeeper) + senderAddr := testutils.AccAddress() + wasmKeeper.AddCodeAdmin(1, senderAddr.String()) + wasmKeeper.AddCodeAdmin(2, senderAddr.String()) + + genState := types.GenesisState{ + CodeMetadata: []types.CodeMetadata{ + { + CodeId: 1, + Schema: "test", + }, + { + CodeId: 2, + Schema: "test2", + }, + }, + } + cwregistry.InitGenesis(ctx, keeper, genState) + + c, err := keeper.GetAllCallbacks(ctx) + require.NoError(t, err) + require.Equal(t, 2, len(c)) +} diff --git a/x/cwregistry/keeper/code_metadata_test.go b/x/cwregistry/keeper/code_metadata_test.go new file mode 100644 index 00000000..4536fd06 --- /dev/null +++ b/x/cwregistry/keeper/code_metadata_test.go @@ -0,0 +1,62 @@ +package keeper_test + +import ( + "testing" + + e2eTesting "github.com/archway-network/archway/e2e/testing" + "github.com/archway-network/archway/pkg/testutils" + "github.com/archway-network/archway/x/cwregistry/types" + "github.com/stretchr/testify/require" +) + +func TestSetContractMetadata(t *testing.T) { + keeper, ctx := testutils.CWRegistryKeeper(t) + wasmKeeper := testutils.NewMockContractViewer() + keeper.SetWasmKeeper(wasmKeeper) + + contractAddr := e2eTesting.GenContractAddresses(1)[0] + + // TEST: No such contract exists + err := keeper.SetContractMetadata(ctx, testutils.AccAddress(), contractAddr, types.CodeMetadata{}) + require.Error(t, err) + require.ErrorIs(t, err, types.ErrNoSuchContract) + + // TEST: Unauthorized + contractAdminAcc := testutils.AccAddress() + wasmKeeper.AddContractAdmin( + contractAddr.String(), + contractAdminAcc.String(), + ) + wasmKeeper.AddCodeAdmin(1, contractAdminAcc.String()) + err = keeper.SetContractMetadata(ctx, testutils.AccAddress(), contractAddr, types.CodeMetadata{}) + require.Error(t, err) + require.ErrorIs(t, err, types.ErrUnauthorized) + + // TEST: Success + err = keeper.SetContractMetadata(ctx, contractAdminAcc, contractAddr, types.CodeMetadata{}) + require.NoError(t, err) + require.True(t, keeper.HasCodeMetadata(ctx, 0)) +} + +func TestSetCodeMetadata(t *testing.T) { + keeper, ctx := testutils.CWRegistryKeeper(t) + wasmKeeper := testutils.NewMockContractViewer() + keeper.SetWasmKeeper(wasmKeeper) + + // TEST: No such code exists + err := keeper.SetCodeMetadata(ctx, testutils.AccAddress(), 1, types.CodeMetadata{}) + require.Error(t, err) + require.ErrorIs(t, err, types.ErrNoSuchCode) + + // TEST: Unauthorized + codeAdminAcc := testutils.AccAddress() + wasmKeeper.AddCodeAdmin(1, codeAdminAcc.String()) + err = keeper.SetCodeMetadata(ctx, testutils.AccAddress(), 1, types.CodeMetadata{}) + require.Error(t, err) + require.ErrorIs(t, err, types.ErrUnauthorized) + + // TEST: Success + err = keeper.SetCodeMetadata(ctx, codeAdminAcc, 1, types.CodeMetadata{}) + require.NoError(t, err) + require.True(t, keeper.HasCodeMetadata(ctx, 1)) +} diff --git a/x/cwregistry/keeper/msg_server_test.go b/x/cwregistry/keeper/msg_server_test.go new file mode 100644 index 00000000..8a9d2293 --- /dev/null +++ b/x/cwregistry/keeper/msg_server_test.go @@ -0,0 +1,86 @@ +package keeper_test + +import ( + "testing" + + "github.com/archway-network/archway/pkg/testutils" + "github.com/archway-network/archway/x/cwregistry/keeper" + "github.com/archway-network/archway/x/cwregistry/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestRegisterCode(t *testing.T) { + k, ctx := testutils.CWRegistryKeeper(t) + wasmKeeper := testutils.NewMockContractViewer() + k.SetWasmKeeper(wasmKeeper) + msgSrvr := keeper.NewMsgServerImpl(k) + senderAddr := testutils.AccAddress().String() + wasmKeeper.AddCodeAdmin(1, senderAddr) + + // TEST: Empty + msg := types.MsgRegisterCode{} + _, err := msgSrvr.RegisterCode(ctx, &msg) + require.Error(t, err) + + // TEST Invalid sender + msg = types.MsgRegisterCode{ + Sender: "👻", + CodeId: 1, + Schema: "schema", + Contacts: []string{"contact1", "contact2"}, + } + _, err = msgSrvr.RegisterCode(ctx, &msg) + require.Error(t, err) + + // TEST: Success + msg = types.MsgRegisterCode{ + Sender: senderAddr, + CodeId: 1, + Schema: "schema", + Contacts: []string{"contact1", "contact2"}, + } + _, err = msgSrvr.RegisterCode(ctx, &msg) + require.NoError(t, err) + require.True(t, k.HasCodeMetadata(ctx, 1)) +} + +func TestRegisterContract(t *testing.T) { + k, ctx := testutils.CWRegistryKeeper(t) + wasmKeeper := testutils.NewMockContractViewer() + k.SetWasmKeeper(wasmKeeper) + msgSrvr := keeper.NewMsgServerImpl(k) + senderAddr := testutils.AccAddress().String() + wasmKeeper.AddContractAdmin(senderAddr, senderAddr) + wasmKeeper.AddCodeAdmin(1, senderAddr) + + // TEST: Empty + msg := types.MsgRegisterContract{} + _, err := msgSrvr.RegisterContract(sdk.WrapSDKContext(ctx), &msg) + require.Error(t, err) + + // TEST Invalid sender + msg = types.MsgRegisterContract{ + Sender: "👻", + ContractAddress: senderAddr, + } + _, err = msgSrvr.RegisterContract(ctx, &msg) + require.Error(t, err) + + // TEST Invalid contract addr + msg = types.MsgRegisterContract{ + Sender: senderAddr, + ContractAddress: "👻", + } + _, err = msgSrvr.RegisterContract(ctx, &msg) + require.Error(t, err) + + // TEST: Success + msg = types.MsgRegisterContract{ + Sender: senderAddr, + ContractAddress: senderAddr, + } + _, err = msgSrvr.RegisterContract(ctx, &msg) + require.NoError(t, err) + require.True(t, k.HasCodeMetadata(ctx, 0)) +} diff --git a/x/cwregistry/module.go b/x/cwregistry/module.go index ce03d0e6..fbfe391e 100644 --- a/x/cwregistry/module.go +++ b/x/cwregistry/module.go @@ -1,4 +1,4 @@ -package cwica +package cwregistry import ( "context" diff --git a/x/cwregistry/types/code_metadata.go b/x/cwregistry/types/code_metadata.go index 61517cc4..c6518e0e 100644 --- a/x/cwregistry/types/code_metadata.go +++ b/x/cwregistry/types/code_metadata.go @@ -6,9 +6,6 @@ import ( ) func (c CodeMetadata) Validate() error { - if c.CodeId == 0 { - return ErrNoSuchCode - } if len(c.Schema) > 255 { return ErrSchemaTooLarge } From 8bcd1e39bc23ce30b52e2899d5893fb345842d9d Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:10:47 +0100 Subject: [PATCH 10/19] adding schema storage --- pkg/testutils/cwregistrykeeper.go | 1 + x/cwregistry/keeper/code_schema.go | 19 ++++++++++++------- x/cwregistry/keeper/code_schema_test.go | 25 +++++++++++++++++++++++++ x/cwregistry/keeper/keeper.go | 11 ++++++++++- 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 x/cwregistry/keeper/code_schema_test.go diff --git a/pkg/testutils/cwregistrykeeper.go b/pkg/testutils/cwregistrykeeper.go index 93d31197..fb80ccc1 100644 --- a/pkg/testutils/cwregistrykeeper.go +++ b/pkg/testutils/cwregistrykeeper.go @@ -38,6 +38,7 @@ func CWRegistryKeeper(tb testing.TB) (keeper.Keeper, sdk.Context) { cdc, storeKey, nil, + tb.TempDir(), log.NewTestLogger(tb), ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/cwregistry/keeper/code_schema.go b/x/cwregistry/keeper/code_schema.go index eab546e0..bba893e6 100644 --- a/x/cwregistry/keeper/code_schema.go +++ b/x/cwregistry/keeper/code_schema.go @@ -1,15 +1,20 @@ package keeper -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + "fmt" + "path/filepath" + + "github.com/cometbft/cometbft/libs/os" + sdk "github.com/cosmos/cosmos-sdk/types" +) func (k Keeper) GetSchema(ctx sdk.Context, codeID uint64) (string, error) { - return "", nil + filePath := filepath.Join(k.dataRoot, fmt.Sprintf("%d", codeID)) + contents, err := os.ReadFile(filePath) + return string(contents), err } func (k Keeper) SetSchema(ctx sdk.Context, codeID uint64, schema string) error { - return nil -} - -func (k Keeper) HasSchema(ctx sdk.Context, codeID uint64) bool { - return false + filePath := filepath.Join(k.dataRoot, fmt.Sprintf("%d", codeID)) + return os.WriteFile(filePath, []byte(schema), 0644) } diff --git a/x/cwregistry/keeper/code_schema_test.go b/x/cwregistry/keeper/code_schema_test.go new file mode 100644 index 00000000..b8e6d3f4 --- /dev/null +++ b/x/cwregistry/keeper/code_schema_test.go @@ -0,0 +1,25 @@ +package keeper_test + +import ( + "testing" + + "github.com/archway-network/archway/pkg/testutils" + "github.com/stretchr/testify/require" +) + +func TestSetSchema(t *testing.T) { + keeper, ctx := testutils.CWRegistryKeeper(t) + + // Getting schema which doesn't exist + _, err := keeper.GetSchema(ctx, 1) + require.Error(t, err) + + // Saving schema + err = keeper.SetSchema(ctx, 1, "testContent") + require.NoError(t, err) + + // Getting schema which now exists + schema, err := keeper.GetSchema(ctx, 1) + require.NoError(t, err) + require.Equal(t, "testContent", schema) +} diff --git a/x/cwregistry/keeper/keeper.go b/x/cwregistry/keeper/keeper.go index 97a77192..3eba468d 100644 --- a/x/cwregistry/keeper/keeper.go +++ b/x/cwregistry/keeper/keeper.go @@ -1,11 +1,13 @@ package keeper import ( + "path/filepath" + "cosmossdk.io/collections" "cosmossdk.io/log" - "github.com/archway-network/archway/internal/collcompat" "github.com/archway-network/archway/x/cwregistry/types" + "github.com/cometbft/cometbft/libs/os" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" @@ -18,6 +20,7 @@ type ( storeKey storetypes.StoreKey wasmKeeper types.WasmKeeper logger log.Logger + dataRoot string Schema collections.Schema // CodeMetadata key: CodeMetadataKeyPrefix + codeID | value: CodeMetadata @@ -29,6 +32,7 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, wasmKeeper types.WasmKeeper, + homePath string, logger log.Logger, ) Keeper { sb := collections.NewSchemaBuilder(collcompat.NewKVStoreService(storeKey)) @@ -38,6 +42,7 @@ func NewKeeper( storeKey: storeKey, wasmKeeper: wasmKeeper, logger: logger.With("module", "x/"+types.ModuleName), + dataRoot: filepath.Join(homePath, "registry"), CodeMetadata: collections.NewMap( sb, types.CodeMetadataKeyPrefix, @@ -46,6 +51,10 @@ func NewKeeper( collcompat.ProtoValue[types.CodeMetadata](cdc), ), } + err := os.EnsureDir(k.dataRoot, 0755) + if err != nil { + panic(err) + } schema, err := sb.Build() if err != nil { From 82e699e6d835faf4102635dc67212a67ffb69423 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:54:55 +0100 Subject: [PATCH 11/19] adding snapshotter --- x/cwregistry/genesis.go | 2 +- x/cwregistry/genesis_test.go | 2 +- x/cwregistry/keeper/code_metadata.go | 4 +- x/cwregistry/keeper/code_schema.go | 5 +- x/cwregistry/keeper/code_schema_test.go | 8 +- x/cwregistry/keeper/grpc_query.go | 4 +- x/cwregistry/keeper/snapshotter.go | 97 +++++++++++++++++++++++++ x/cwregistry/types/errors.go | 2 + 8 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 x/cwregistry/keeper/snapshotter.go diff --git a/x/cwregistry/genesis.go b/x/cwregistry/genesis.go index fae8d4c7..ca5c46b7 100644 --- a/x/cwregistry/genesis.go +++ b/x/cwregistry/genesis.go @@ -20,7 +20,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // ExportGenesis returns the cwregistry module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - codeMetadata, err := k.GetAllCallbacks(ctx) + codeMetadata, err := k.GetAllCodeMetadata(ctx) if err != nil { panic(err) } diff --git a/x/cwregistry/genesis_test.go b/x/cwregistry/genesis_test.go index d1576108..0cc256a7 100644 --- a/x/cwregistry/genesis_test.go +++ b/x/cwregistry/genesis_test.go @@ -48,7 +48,7 @@ func TestInitGenesis(t *testing.T) { } cwregistry.InitGenesis(ctx, keeper, genState) - c, err := keeper.GetAllCallbacks(ctx) + c, err := keeper.GetAllCodeMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(c)) } diff --git a/x/cwregistry/keeper/code_metadata.go b/x/cwregistry/keeper/code_metadata.go index 2f7cbfb7..c9034fac 100644 --- a/x/cwregistry/keeper/code_metadata.go +++ b/x/cwregistry/keeper/code_metadata.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// GetAllCallbacks returns all code metadata stored -func (k Keeper) GetAllCallbacks(ctx sdk.Context) (codeMetadata []types.CodeMetadata, err error) { +// GetAllCodeMetadata returns all code metadata stored +func (k Keeper) GetAllCodeMetadata(ctx sdk.Context) (codeMetadata []types.CodeMetadata, err error) { err = k.CodeMetadata.Walk(ctx, nil, func(key uint64, value types.CodeMetadata) (stop bool, err error) { codeMetadata = append(codeMetadata, value) return false, nil diff --git a/x/cwregistry/keeper/code_schema.go b/x/cwregistry/keeper/code_schema.go index bba893e6..57f18022 100644 --- a/x/cwregistry/keeper/code_schema.go +++ b/x/cwregistry/keeper/code_schema.go @@ -5,16 +5,15 @@ import ( "path/filepath" "github.com/cometbft/cometbft/libs/os" - sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetSchema(ctx sdk.Context, codeID uint64) (string, error) { +func (k Keeper) GetSchema(codeID uint64) (string, error) { filePath := filepath.Join(k.dataRoot, fmt.Sprintf("%d", codeID)) contents, err := os.ReadFile(filePath) return string(contents), err } -func (k Keeper) SetSchema(ctx sdk.Context, codeID uint64, schema string) error { +func (k Keeper) SetSchema(codeID uint64, schema string) error { filePath := filepath.Join(k.dataRoot, fmt.Sprintf("%d", codeID)) return os.WriteFile(filePath, []byte(schema), 0644) } diff --git a/x/cwregistry/keeper/code_schema_test.go b/x/cwregistry/keeper/code_schema_test.go index b8e6d3f4..9a8457bd 100644 --- a/x/cwregistry/keeper/code_schema_test.go +++ b/x/cwregistry/keeper/code_schema_test.go @@ -8,18 +8,18 @@ import ( ) func TestSetSchema(t *testing.T) { - keeper, ctx := testutils.CWRegistryKeeper(t) + keeper, _ := testutils.CWRegistryKeeper(t) // Getting schema which doesn't exist - _, err := keeper.GetSchema(ctx, 1) + _, err := keeper.GetSchema(1) require.Error(t, err) // Saving schema - err = keeper.SetSchema(ctx, 1, "testContent") + err = keeper.SetSchema(1, "testContent") require.NoError(t, err) // Getting schema which now exists - schema, err := keeper.GetSchema(ctx, 1) + schema, err := keeper.GetSchema(1) require.NoError(t, err) require.Equal(t, "testContent", schema) } diff --git a/x/cwregistry/keeper/grpc_query.go b/x/cwregistry/keeper/grpc_query.go index da6970b2..483c5893 100644 --- a/x/cwregistry/keeper/grpc_query.go +++ b/x/cwregistry/keeper/grpc_query.go @@ -41,7 +41,7 @@ func (q *QueryServer) CodeSchema(c context.Context, req *types.QueryCodeSchemaRe if !q.keeper.HasCodeMetadata(ctx, req.GetCodeId()) { return nil, status.Error(codes.NotFound, "code metadata not found") } - schema, err := q.keeper.GetSchema(ctx, req.GetCodeId()) + schema, err := q.keeper.GetSchema(req.GetCodeId()) return &types.QueryCodeSchemaResponse{Schema: schema}, err } @@ -74,6 +74,6 @@ func (q *QueryServer) ContractSchema(c context.Context, req *types.QueryContract if !q.keeper.HasCodeMetadata(ctx, codeInfo.CodeID) { return nil, status.Error(codes.NotFound, "code metadata not found") } - schema, err := q.keeper.GetSchema(ctx, codeInfo.CodeID) + schema, err := q.keeper.GetSchema(codeInfo.CodeID) return &types.QueryContractSchemaResponse{Schema: schema}, err } diff --git a/x/cwregistry/keeper/snapshotter.go b/x/cwregistry/keeper/snapshotter.go new file mode 100644 index 00000000..cefd6b1d --- /dev/null +++ b/x/cwregistry/keeper/snapshotter.go @@ -0,0 +1,97 @@ +package keeper + +import ( + "fmt" + "io" + "math" + + "cosmossdk.io/log" + snapshot "cosmossdk.io/store/snapshots/types" + storetypes "cosmossdk.io/store/types" + "github.com/CosmWasm/wasmd/x/wasm/ioutils" + "github.com/archway-network/archway/x/cwregistry/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ snapshot.ExtensionSnapshotter = &CwRegistrySnapshotter{} + +// SnapshotFormat format 1 is just gzipped wasm byte code for each item payload. No protobuf envelope, no metadata. +const SnapshotFormat = 1 + +type CwRegistrySnapshotter struct { + registryKeeper *Keeper + cms storetypes.MultiStore +} + +func NewCwRegistrySnapshotter(k *Keeper, cms storetypes.MultiStore) *CwRegistrySnapshotter { + return &CwRegistrySnapshotter{ + registryKeeper: k, + cms: cms, + } +} + +func (s *CwRegistrySnapshotter) SnapshotName() string { + return types.ModuleName +} + +func (s *CwRegistrySnapshotter) SnapshotFormat() uint32 { + return SnapshotFormat +} + +func (s *CwRegistrySnapshotter) SupportedFormats() []uint32 { + return []uint32{SnapshotFormat} +} + +func (s *CwRegistrySnapshotter) SnapshotExtension(height uint64, payloadWriter snapshot.ExtensionPayloadWriter) error { + cacheMS, err := s.cms.CacheMultiStoreWithVersion(int64(height)) + if err != nil { + return err + } + ctx := sdk.NewContext(cacheMS, tmproto.Header{}, false, log.NewNopLogger()) + codeMetadata, err := s.registryKeeper.GetAllCodeMetadata(ctx) + if err != nil { + return err + } + for _, metadata := range codeMetadata { + schema, err := s.registryKeeper.GetSchema(metadata.CodeId) + if err != nil { + return err + } + compressedSchema, err := ioutils.GzipIt([]byte(schema)) + if err != nil { + return err + } + err = payloadWriter(compressedSchema) + if err != nil { + return err + } + } + return nil +} + +func (s *CwRegistrySnapshotter) RestoreExtension(height uint64, format uint32, payloadReader snapshot.ExtensionPayloadReader) error { + if format != SnapshotFormat { + return snapshot.ErrUnknownFormat + } + for { + payload, err := payloadReader() + switch { + case err == io.EOF: + return nil + case err != nil: + return fmt.Errorf("cannot read blob from the payload: %w", err) + } + if !ioutils.IsGzip(payload) { + return types.ErrInvalidSnapshotPayload + } + schema, err := ioutils.Uncompress(payload, math.MaxInt64) + if err != nil { + return err + } + err = s.registryKeeper.SetSchema(1, string(schema)) + if err != nil { + return err + } + } +} diff --git a/x/cwregistry/types/errors.go b/x/cwregistry/types/errors.go index ce8dd941..78c2b939 100644 --- a/x/cwregistry/types/errors.go +++ b/x/cwregistry/types/errors.go @@ -10,4 +10,6 @@ var ( ErrNoSuchCode = errors.Register(ModuleName, 1104, "code with given id does not exist") ErrNoSuchContract = errors.Register(ModuleName, 1105, "contract with given address does not exist") ErrSchemaTooLarge = errors.Register(ModuleName, 1106, "schema cannot be larger than 255 bytes") + // Snapshot related errors + ErrInvalidSnapshotPayload = errors.Register(ModuleName, 1107, "invalid snapshot payload") ) From 5d8cde58c878d12c476fcdd1f44fec3079fc65f2 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Sat, 29 Jun 2024 20:26:34 +0100 Subject: [PATCH 12/19] adding snapshot for schema files --- proto/archway/cwregistry/v1/snapshot.proto | 12 + x/cwregistry/keeper/snapshotter.go | 19 +- x/cwregistry/types/snapshot.go | 8 + x/cwregistry/types/snapshot.pb.go | 359 +++++++++++++++++++++ 4 files changed, 393 insertions(+), 5 deletions(-) create mode 100644 proto/archway/cwregistry/v1/snapshot.proto create mode 100644 x/cwregistry/types/snapshot.go create mode 100644 x/cwregistry/types/snapshot.pb.go diff --git a/proto/archway/cwregistry/v1/snapshot.proto b/proto/archway/cwregistry/v1/snapshot.proto new file mode 100644 index 00000000..27d0ba08 --- /dev/null +++ b/proto/archway/cwregistry/v1/snapshot.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package archway.cwregistry.v1; + +option go_package = "github.com/archway-network/archway/x/cwregistry/types"; + +// SnapshotPayload defines the payload of a snapshot +message SnapshotPayload { + // The Code ID of the contract whose snapshot is being shared + uint64 code_id = 1; + // schema is the gzipped JSON schema which specifies the interaction endpoints of the contract + bytes schema = 2; +} diff --git a/x/cwregistry/keeper/snapshotter.go b/x/cwregistry/keeper/snapshotter.go index cefd6b1d..ea3e6283 100644 --- a/x/cwregistry/keeper/snapshotter.go +++ b/x/cwregistry/keeper/snapshotter.go @@ -16,7 +16,6 @@ import ( var _ snapshot.ExtensionSnapshotter = &CwRegistrySnapshotter{} -// SnapshotFormat format 1 is just gzipped wasm byte code for each item payload. No protobuf envelope, no metadata. const SnapshotFormat = 1 type CwRegistrySnapshotter struct { @@ -62,7 +61,12 @@ func (s *CwRegistrySnapshotter) SnapshotExtension(height uint64, payloadWriter s if err != nil { return err } - err = payloadWriter(compressedSchema) + snapshotPayload := types.NewSnapshot(metadata.CodeId, compressedSchema) + payloadData, err := snapshotPayload.Marshal() + if err != nil { + return err + } + err = payloadWriter(payloadData) if err != nil { return err } @@ -82,14 +86,19 @@ func (s *CwRegistrySnapshotter) RestoreExtension(height uint64, format uint32, p case err != nil: return fmt.Errorf("cannot read blob from the payload: %w", err) } - if !ioutils.IsGzip(payload) { + var snapshotPayload types.SnapshotPayload + err = snapshotPayload.Unmarshal(payload) + if err != nil { + return err + } + if !ioutils.IsGzip(snapshotPayload.Schema) { return types.ErrInvalidSnapshotPayload } - schema, err := ioutils.Uncompress(payload, math.MaxInt64) + schema, err := ioutils.Uncompress(snapshotPayload.Schema, math.MaxInt64) if err != nil { return err } - err = s.registryKeeper.SetSchema(1, string(schema)) + err = s.registryKeeper.SetSchema(snapshotPayload.CodeId, string(schema)) if err != nil { return err } diff --git a/x/cwregistry/types/snapshot.go b/x/cwregistry/types/snapshot.go new file mode 100644 index 00000000..74365e39 --- /dev/null +++ b/x/cwregistry/types/snapshot.go @@ -0,0 +1,8 @@ +package types + +func NewSnapshot(codeId uint64, compressedSchema []byte) *SnapshotPayload { + return &SnapshotPayload{ + CodeId: codeId, + Schema: compressedSchema, + } +} diff --git a/x/cwregistry/types/snapshot.pb.go b/x/cwregistry/types/snapshot.pb.go new file mode 100644 index 00000000..f3813588 --- /dev/null +++ b/x/cwregistry/types/snapshot.pb.go @@ -0,0 +1,359 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: archway/cwregistry/v1/snapshot.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/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 + +// SnapshotPayload defines the payload of a snapshot +type SnapshotPayload struct { + // The Code ID of the contract whose snapshot is being shared + CodeId uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // schema is the gzipped JSON schema which specifies the interaction endpoints of the contract + Schema []byte `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` +} + +func (m *SnapshotPayload) Reset() { *m = SnapshotPayload{} } +func (m *SnapshotPayload) String() string { return proto.CompactTextString(m) } +func (*SnapshotPayload) ProtoMessage() {} +func (*SnapshotPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_57009e220a425163, []int{0} +} +func (m *SnapshotPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotPayload.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 *SnapshotPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotPayload.Merge(m, src) +} +func (m *SnapshotPayload) XXX_Size() int { + return m.Size() +} +func (m *SnapshotPayload) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotPayload proto.InternalMessageInfo + +func (m *SnapshotPayload) GetCodeId() uint64 { + if m != nil { + return m.CodeId + } + return 0 +} + +func (m *SnapshotPayload) GetSchema() []byte { + if m != nil { + return m.Schema + } + return nil +} + +func init() { + proto.RegisterType((*SnapshotPayload)(nil), "archway.cwregistry.v1.SnapshotPayload") +} + +func init() { + proto.RegisterFile("archway/cwregistry/v1/snapshot.proto", fileDescriptor_57009e220a425163) +} + +var fileDescriptor_57009e220a425163 = []byte{ + // 195 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0x2c, 0x4a, 0xce, + 0x28, 0x4f, 0xac, 0xd4, 0x4f, 0x2e, 0x2f, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0xaa, 0xd4, 0x2f, + 0x33, 0xd4, 0x2f, 0xce, 0x4b, 0x2c, 0x28, 0xce, 0xc8, 0x2f, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x85, 0xaa, 0xd2, 0x43, 0xa8, 0xd2, 0x2b, 0x33, 0x54, 0x72, 0xe2, 0xe2, 0x0f, 0x86, + 0x2a, 0x0c, 0x48, 0xac, 0xcc, 0xc9, 0x4f, 0x4c, 0x11, 0x12, 0xe7, 0x62, 0x4f, 0xce, 0x4f, 0x49, + 0x8d, 0xcf, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0x60, 0x09, 0x62, 0x03, 0x71, 0x3d, 0x53, 0x84, + 0xc4, 0xb8, 0xd8, 0x8a, 0x93, 0x33, 0x52, 0x73, 0x13, 0x25, 0x98, 0x14, 0x18, 0x35, 0x78, 0x82, + 0xa0, 0x3c, 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, 0x87, 0xda, 0xaf, 0x9b, 0x97, 0x5a, + 0x52, 0x9e, 0x5f, 0x94, 0x0d, 0xe3, 0xeb, 0x57, 0x20, 0xbb, 0xbb, 0xa4, 0xb2, 0x20, 0xb5, 0x38, + 0x89, 0x0d, 0xec, 0x64, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x7e, 0x47, 0xf4, 0xda, + 0x00, 0x00, 0x00, +} + +func (m *SnapshotPayload) 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 *SnapshotPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0x12 + } + if m.CodeId != 0 { + i = encodeVarintSnapshot(dAtA, i, uint64(m.CodeId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int { + offset -= sovSnapshot(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SnapshotPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeId != 0 { + n += 1 + sovSnapshot(uint64(m.CodeId)) + } + l = len(m.Schema) + if l > 0 { + n += 1 + l + sovSnapshot(uint64(l)) + } + return n +} + +func sovSnapshot(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSnapshot(x uint64) (n int) { + return sovSnapshot(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SnapshotPayload) 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 ErrIntOverflowSnapshot + } + 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: SnapshotPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SnapshotPayload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + m.CodeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Schema = append(m.Schema[:0], dAtA[iNdEx:postIndex]...) + if m.Schema == nil { + m.Schema = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSnapshot(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, ErrIntOverflowSnapshot + } + 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, ErrIntOverflowSnapshot + } + 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, ErrIntOverflowSnapshot + } + 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, ErrInvalidLengthSnapshot + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSnapshot + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSnapshot + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSnapshot = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSnapshot = fmt.Errorf("proto: unexpected end of group") +) From 5525c16ca4d41195db5795b49a6fe48c7a3600c8 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:40:12 +0100 Subject: [PATCH 13/19] app wiring --- app/app.go | 17 ++++++++++++++++- app/keepers/keepers.go | 14 ++++++++------ app/upgrades/latest/upgrades.go | 7 ++++++- x/cwregistry/types/genesis.go | 9 +++++++-- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/app/app.go b/app/app.go index 77ba573b..de00ece9 100644 --- a/app/app.go +++ b/app/app.go @@ -151,6 +151,10 @@ import ( cwicakeeper "github.com/archway-network/archway/x/cwica/keeper" cwicatypes "github.com/archway-network/archway/x/cwica/types" + cwregistry "github.com/archway-network/archway/x/cwregistry" + cwregistrykeeper "github.com/archway-network/archway/x/cwregistry/keeper" + cwregistryTypes "github.com/archway-network/archway/x/cwregistry/types" + extendedGov "github.com/archway-network/archway/x/gov" "github.com/CosmWasm/wasmd/x/wasm" @@ -225,6 +229,7 @@ var ( cwfees.AppModule{}, cwica.AppModuleBasic{}, cwerrors.AppModuleBasic{}, + cwregistry.AppModuleBasic{}, ) // module account permissions @@ -329,7 +334,7 @@ func NewArchwayApp( feegrant.StoreKey, authzkeeper.StoreKey, wasmdTypes.StoreKey, consensusparamtypes.StoreKey, icacontrollertypes.StoreKey, icahosttypes.StoreKey, ibcfeetypes.StoreKey, crisistypes.StoreKey, group.StoreKey, nftkeeper.StoreKey, cwicatypes.StoreKey, - trackingTypes.StoreKey, rewardsTypes.StoreKey, callbackTypes.StoreKey, cwfees.ModuleName, cwerrorsTypes.StoreKey, + trackingTypes.StoreKey, rewardsTypes.StoreKey, callbackTypes.StoreKey, cwfees.ModuleName, cwerrorsTypes.StoreKey, cwregistryTypes.StoreKey, ) tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, cwerrorsTypes.TStoreKey) memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -666,6 +671,14 @@ func NewArchwayApp( logger, ) + app.Keepers.CWRegistryKeeper = cwregistrykeeper.NewKeeper( + appCodec, + keys[cwregistryTypes.StoreKey], + app.Keepers.WASMKeeper, + homePath, + logger, + ) + var transferStack porttypes.IBCModule transferStack = transfer.NewIBCModule(app.Keepers.TransferKeeper) transferStack = ibcfee.NewIBCMiddleware(transferStack, app.Keepers.IBCFeeKeeper) @@ -747,6 +760,7 @@ func NewArchwayApp( callback.NewAppModule(app.appCodec, app.Keepers.CallbackKeeper, app.Keepers.WASMKeeper, app.Keepers.CWErrorsKeeper), cwica.NewAppModule(appCodec, app.Keepers.CWICAKeeper, app.Keepers.AccountKeeper), cwerrors.NewAppModule(app.appCodec, app.Keepers.CWErrorsKeeper, app.Keepers.WASMKeeper), + cwregistry.NewAppModule(app.appCodec, app.Keepers.CWRegistryKeeper), crisis.NewAppModule(&app.Keepers.CrisisKeeper, skipGenesisInvariants, app.getSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them ) @@ -876,6 +890,7 @@ func NewArchwayApp( genmsg.ModuleName, callbackTypes.ModuleName, cwerrorsTypes.ModuleName, + cwregistryTypes.ModuleName, // invariants checks are always the last to run crisistypes.ModuleName, cwicatypes.ModuleName, diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 0f2471b6..698b85e3 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -31,6 +31,7 @@ import ( callbackKeeper "github.com/archway-network/archway/x/callback/keeper" cwerrorsKeeper "github.com/archway-network/archway/x/cwerrors/keeper" cwicaKeeper "github.com/archway-network/archway/x/cwica/keeper" + cwregistryKeeper "github.com/archway-network/archway/x/cwregistry/keeper" rewardsKeeper "github.com/archway-network/archway/x/rewards/keeper" trackingKeeper "github.com/archway-network/archway/x/tracking/keeper" ) @@ -61,10 +62,11 @@ type ArchwayKeepers struct { WASMKeeper wasmkeeper.Keeper // Archway Keepers - TrackingKeeper trackingKeeper.Keeper - RewardsKeeper rewardsKeeper.Keeper - CWFeesKeeper cwfees.Keeper - CallbackKeeper callbackKeeper.Keeper - CWErrorsKeeper cwerrorsKeeper.Keeper - CWICAKeeper cwicaKeeper.Keeper + TrackingKeeper trackingKeeper.Keeper + RewardsKeeper rewardsKeeper.Keeper + CWFeesKeeper cwfees.Keeper + CallbackKeeper callbackKeeper.Keeper + CWErrorsKeeper cwerrorsKeeper.Keeper + CWICAKeeper cwicaKeeper.Keeper + CWRegistryKeeper cwregistryKeeper.Keeper } diff --git a/app/upgrades/latest/upgrades.go b/app/upgrades/latest/upgrades.go index 0fa354e8..1e71638b 100644 --- a/app/upgrades/latest/upgrades.go +++ b/app/upgrades/latest/upgrades.go @@ -10,6 +10,7 @@ import ( "github.com/archway-network/archway/app/keepers" "github.com/archway-network/archway/app/upgrades" + cwregistrytypes "github.com/archway-network/archway/x/cwregistry/types" ) // This upgrade handler is used for all the current changes to the protocol @@ -30,5 +31,9 @@ var Upgrade = upgrades.Upgrade{ return migrations, nil } }, - StoreUpgrades: storetypes.StoreUpgrades{}, + StoreUpgrades: storetypes.StoreUpgrades{ + Added: []string{ + cwregistrytypes.ModuleName, + }, + }, } diff --git a/x/cwregistry/types/genesis.go b/x/cwregistry/types/genesis.go index 3b1af3b0..2208e1ec 100644 --- a/x/cwregistry/types/genesis.go +++ b/x/cwregistry/types/genesis.go @@ -2,11 +2,16 @@ package types // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { - panic("unimplemented 👻") + return &GenesisState{} } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - panic("unimplemented 👻") + for _, meta := range gs.CodeMetadata { + if err := meta.Validate(); err != nil { + return err + } + } + return nil } From 743fc9fbdc1fe3141dc727815bb6d6b5820aae1c Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:39:29 +0100 Subject: [PATCH 14/19] adding cli --- proto/archway/cwregistry/v1/cwregistry.proto | 15 --- x/cwregistry/client/cli/flags.go | 98 +++++++++++++++ x/cwregistry/client/cli/query.go | 126 +++++++++++++++++++ x/cwregistry/client/cli/tx.go | 88 +++++++++++++ 4 files changed, 312 insertions(+), 15 deletions(-) create mode 100644 x/cwregistry/client/cli/flags.go diff --git a/proto/archway/cwregistry/v1/cwregistry.proto b/proto/archway/cwregistry/v1/cwregistry.proto index a2f91d02..963ff66d 100644 --- a/proto/archway/cwregistry/v1/cwregistry.proto +++ b/proto/archway/cwregistry/v1/cwregistry.proto @@ -36,18 +36,3 @@ message SourceBuilder { // Name of the generated contract binary. e.g counter.wasm string contract_name = 3; } - - -// // Params defines the module parameters. -// message Params { -// // callback_gas_limit is the maximum gas that can be consumed by a callback. -// uint64 callback_gas_limit = 1; -// // max_block_reservation_limit is the maximum number of callbacks which can be registered in a given block. -// uint64 max_block_reservation_limit = 2; -// // max_future_reservation_limit is the maximum number of blocks in the future that a contract can request a callback in. -// uint64 max_future_reservation_limit = 3; -// // block_reservation_fee_multiplier is used to calculate a part of the reservation fees which will need to be paid when requesting the callback. -// string block_reservation_fee_multiplier = 4 [(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false]; -// // future_reservation_fee_multiplier is used to calculate a part of the reservation fees which will need to be paid while requesting the callback. -// string future_reservation_fee_multiplier = 5 [(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false]; -// } \ No newline at end of file diff --git a/x/cwregistry/client/cli/flags.go b/x/cwregistry/client/cli/flags.go new file mode 100644 index 00000000..feb9d8c0 --- /dev/null +++ b/x/cwregistry/client/cli/flags.go @@ -0,0 +1,98 @@ +package cli + +import ( + "os" + + "github.com/archway-network/archway/x/cwregistry/types" + "github.com/spf13/cobra" +) + +const ( + // Source Metadata + flagSourceRepository = "source-repository" + flagSourceTag = "source-tag" + flagSourceLicense = "source-license" + // Source Builder + flagSourceImage = "source-image" + flagSourceImageTag = "source-image-tag" + flagSourceContractName = "source-contract-name" + + flagContacts = "contacts" + flagSchemaPath = "schema-path" +) + +func addFlags(cmd *cobra.Command) { + addContactsFlag(cmd) + addSchemaPathFlag(cmd) + addSourceRepositoryFlag(cmd) + addSourceTagFlag(cmd) + addSourceLicenseFlag(cmd) + addSourceImageFlag(cmd) + addSourceImageTagFlag(cmd) + addSourceContractNameFlag(cmd) +} + +func addSourceRepositoryFlag(cmd *cobra.Command) { + cmd.Flags().String(flagSourceRepository, "", "The link to the code repository. e.g https://github.com/archway-network/archway") +} + +func addSourceTagFlag(cmd *cobra.Command) { + cmd.Flags().String(flagSourceTag, "", "The tag of the code repository. e.g v0.1.0") +} + +func addSourceLicenseFlag(cmd *cobra.Command) { + cmd.Flags().String(flagSourceLicense, "", "The license of the code repository. e.g Apache-2.0") +} + +func addSourceImageFlag(cmd *cobra.Command) { + cmd.Flags().String(flagSourceImage, "", "The docker image of the contract. e.g cosmwasm/rust-optimizer") +} + +func addSourceImageTagFlag(cmd *cobra.Command) { + cmd.Flags().String(flagSourceImageTag, "", "The tag of the docker image. e.g 0.12.6") +} + +func addSourceContractNameFlag(cmd *cobra.Command) { + cmd.Flags().String(flagSourceContractName, "", "The name of the contract in the docker image. e.g counter.wasm") +} + +func addContactsFlag(cmd *cobra.Command) { + cmd.Flags().StringSlice(flagContacts, []string{}, "The list of contacts for the contract. e.g admin@dapp.com,security@dapp.com") +} + +func addSchemaPathFlag(cmd *cobra.Command) { + cmd.Flags().String(flagSchemaPath, "", "The path to the schema file. e.g ./schema.json") +} + +func parseSourceMetadata(cmd *cobra.Command) types.SourceMetadata { + repository, _ := cmd.Flags().GetString(flagSourceRepository) + tag, _ := cmd.Flags().GetString(flagSourceTag) + license, _ := cmd.Flags().GetString(flagSourceLicense) + sourceMetadata := types.SourceMetadata{ + Repository: repository, + Tag: tag, + License: license, + } + return sourceMetadata +} + +func parseSourceBuilder(cmd *cobra.Command) types.SourceBuilder { + image, _ := cmd.Flags().GetString(flagSourceImage) + imageTag, _ := cmd.Flags().GetString(flagSourceImageTag) + contractName, _ := cmd.Flags().GetString(flagSourceContractName) + sourceBuilder := types.SourceBuilder{ + Image: image, + Tag: imageTag, + ContractName: contractName, + } + return sourceBuilder +} + +func parseSchema(cmd *cobra.Command) string { + schemaPath, _ := cmd.Flags().GetString(flagSchemaPath) + fileContent, err := os.ReadFile(schemaPath) + if err != nil { + return "" + } + return string(fileContent) +} diff --git a/x/cwregistry/client/cli/query.go b/x/cwregistry/client/cli/query.go index 77c243a8..1e6d63dd 100644 --- a/x/cwregistry/client/cli/query.go +++ b/x/cwregistry/client/cli/query.go @@ -1,9 +1,12 @@ package cli import ( + "context" "fmt" + "strconv" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" "github.com/archway-network/archway/x/cwregistry/types" @@ -19,5 +22,128 @@ func GetQueryCmd(_ string) *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdQueryCodeMetadata()) + cmd.AddCommand(CmdQueryContractMetadata()) + cmd.AddCommand(CmdQueryCodeSchema()) + cmd.AddCommand(CmdQueryContractSchema()) + + return cmd +} + +func CmdQueryCodeMetadata() *cobra.Command { + cmd := &cobra.Command{ + Use: "code-metadata", + Short: "", + Long: "", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + codeID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + res, err := queryClient.CodeMetadata(context.Background(), &types.QueryCodeMetadataRequest{ + CodeId: codeID, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryContractMetadata() *cobra.Command { + cmd := &cobra.Command{ + Use: "contract-metadata", + Short: "", + Long: "", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + contractAddr := args[0] + res, err := queryClient.ContractMetadata(context.Background(), &types.QueryContractMetadataRequest{ + ContractAddress: contractAddr, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryCodeSchema() *cobra.Command { + cmd := &cobra.Command{ + Use: "code-schema", + Short: "", + Long: "", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + codeID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + res, err := queryClient.CodeSchema(context.Background(), &types.QueryCodeSchemaRequest{ + CodeId: codeID, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryContractSchema() *cobra.Command { + cmd := &cobra.Command{ + Use: "contract-schema", + Short: "", + Long: "", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + contractAddr := args[0] + res, err := queryClient.ContractSchema(context.Background(), &types.QueryContractSchemaRequest{ + ContractAddress: contractAddr, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd } diff --git a/x/cwregistry/client/cli/tx.go b/x/cwregistry/client/cli/tx.go index 7a559842..48103b6a 100644 --- a/x/cwregistry/client/cli/tx.go +++ b/x/cwregistry/client/cli/tx.go @@ -1,9 +1,14 @@ package cli import ( + "strconv" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" + "github.com/archway-network/archway/pkg" "github.com/archway-network/archway/x/cwregistry/types" ) @@ -17,5 +22,88 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdRegisterCode()) + cmd.AddCommand(CmdRegisterContract()) + + return cmd +} + +func CmdRegisterContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-contract [contract-address]", + Args: cobra.ExactArgs(1), + Short: "", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + senderAddr := clientCtx.GetFromAddress() + contractAddr := args[0] + + sourceMetadata := parseSourceMetadata(cmd) + sourceBuilder := parseSourceBuilder(cmd) + schema := parseSchema(cmd) + contacts, err := pkg.GetStringSliceFlag(cmd, flagContacts, true) + if err != nil { + return err + } + msg := types.MsgRegisterContract{ + Sender: senderAddr.String(), + ContractAddress: contractAddr, + SourceMetadata: &sourceMetadata, + SourceBuilder: &sourceBuilder, + Schema: schema, + Contacts: contacts, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + addFlags(cmd) + + return cmd +} + +func CmdRegisterCode() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-code [code-id]", + Args: cobra.ExactArgs(1), + Short: "", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + senderAddr := clientCtx.GetFromAddress() + codeID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + sourceMetadata := parseSourceMetadata(cmd) + sourceBuilder := parseSourceBuilder(cmd) + schema := parseSchema(cmd) + contacts, err := pkg.GetStringSliceFlag(cmd, flagContacts, true) + if err != nil { + return err + } + msg := types.MsgRegisterCode{ + Sender: senderAddr.String(), + CodeId: codeID, + SourceMetadata: &sourceMetadata, + SourceBuilder: &sourceBuilder, + Schema: schema, + Contacts: contacts, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + addFlags(cmd) + return cmd } From e537359d088d6dd07c259cc4151e09ab83a644a5 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:02:17 +0100 Subject: [PATCH 15/19] cleanup --- app/app.go | 1 - genesis.json | 0 pkg/testutils/cwregistrykeeper.go | 1 - proto/archway/cwregistry/v1/cwregistry.proto | 2 +- proto/archway/cwregistry/v1/query.proto | 32 - proto/archway/cwregistry/v1/snapshot.proto | 12 - proto/archway/cwregistry/v1/tx.proto | 24 - x/cwregistry/client/cli/flags.go | 8 +- x/cwregistry/client/cli/query.go | 61 -- x/cwregistry/client/cli/tx.go | 109 --- x/cwregistry/keeper/code_metadata.go | 30 - x/cwregistry/keeper/code_metadata_test.go | 30 - x/cwregistry/keeper/code_schema.go | 19 - x/cwregistry/keeper/code_schema_test.go | 25 - x/cwregistry/keeper/grpc_query.go | 31 - x/cwregistry/keeper/keeper.go | 10 - x/cwregistry/keeper/msg_server.go | 24 - x/cwregistry/keeper/msg_server_test.go | 41 - x/cwregistry/keeper/snapshotter.go | 106 --- x/cwregistry/module.go | 4 +- x/cwregistry/types/codec.go | 3 +- x/cwregistry/types/cwregistry.pb.go | 2 +- x/cwregistry/types/msg.go | 1 - x/cwregistry/types/query.pb.go | 803 +------------------ x/cwregistry/types/query.pb.gw.go | 166 ---- x/cwregistry/types/tx.pb.go | 638 +-------------- 26 files changed, 64 insertions(+), 2119 deletions(-) delete mode 100644 genesis.json delete mode 100644 proto/archway/cwregistry/v1/snapshot.proto delete mode 100644 x/cwregistry/client/cli/tx.go delete mode 100644 x/cwregistry/keeper/code_schema.go delete mode 100644 x/cwregistry/keeper/code_schema_test.go delete mode 100644 x/cwregistry/keeper/snapshotter.go diff --git a/app/app.go b/app/app.go index de00ece9..63b40e2c 100644 --- a/app/app.go +++ b/app/app.go @@ -675,7 +675,6 @@ func NewArchwayApp( appCodec, keys[cwregistryTypes.StoreKey], app.Keepers.WASMKeeper, - homePath, logger, ) diff --git a/genesis.json b/genesis.json deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/testutils/cwregistrykeeper.go b/pkg/testutils/cwregistrykeeper.go index fb80ccc1..93d31197 100644 --- a/pkg/testutils/cwregistrykeeper.go +++ b/pkg/testutils/cwregistrykeeper.go @@ -38,7 +38,6 @@ func CWRegistryKeeper(tb testing.TB) (keeper.Keeper, sdk.Context) { cdc, storeKey, nil, - tb.TempDir(), log.NewTestLogger(tb), ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/proto/archway/cwregistry/v1/cwregistry.proto b/proto/archway/cwregistry/v1/cwregistry.proto index 963ff66d..7209f0de 100644 --- a/proto/archway/cwregistry/v1/cwregistry.proto +++ b/proto/archway/cwregistry/v1/cwregistry.proto @@ -11,7 +11,7 @@ message CodeMetadata { SourceMetadata source = 2; // The information regarding the image used to build and optimize the contract binary SourceBuilder source_builder = 3; - // The JSON schema which specifies the interaction endpoints of the contract + // The JSON schema url which specifies the interaction endpoints of the contract string schema = 4; // The contacts of the developers or security incidence handlers repeated string contacts = 5; diff --git a/proto/archway/cwregistry/v1/query.proto b/proto/archway/cwregistry/v1/query.proto index b8a969ab..962fa0a0 100644 --- a/proto/archway/cwregistry/v1/query.proto +++ b/proto/archway/cwregistry/v1/query.proto @@ -16,14 +16,6 @@ service Query { rpc ContractMetadata(QueryContractMetadataRequest) returns (QueryContractMetadataResponse) { option (google.api.http).get = "/archway/cwregistry/v1/contract_metadata"; } - - rpc CodeSchema(QueryCodeSchemaRequest) returns (QueryCodeSchemaResponse) { - option (google.api.http).get = "/archway/cwregistry/v1/code_schema"; - } - - rpc ContractSchema(QueryContractSchemaRequest) returns (QueryContractSchemaResponse) { - option (google.api.http).get = "/archway/cwregistry/v1/contract_schema"; - } } // QueryCodeMetadataRequest is the request type for the Query/CodeMetadata RPC method. @@ -49,27 +41,3 @@ message QueryContractMetadataResponse { // contract_metadata is the metadata for the contract. CodeMetadata code_metadata = 1; } - -// QueryCodeSchemaRequest is the request type for the Query/CodeSchema RPC method. -message QueryCodeSchemaRequest { - // code_id is the contract code id to query schema for. - uint64 code_id = 1; -} - -// QueryCodeSchemaResponse is the response type for the Query/CodeSchema RPC method. -message QueryCodeSchemaResponse { - // code_schema is the schema for the contract code. - string schema = 1; -} - -// QueryContractSchemaRequest is the request type for the Query/ContractSchema RPC method. -message QueryContractSchemaRequest { - // contract_address is the bech32 contract address to query schema for. - string contract_address = 1; -} - -// QueryContractSchemaResponse is the response type for the Query/ContractSchema RPC method. -message QueryContractSchemaResponse { - // contract_schema is the schema for the contract. - string schema = 1; -} \ No newline at end of file diff --git a/proto/archway/cwregistry/v1/snapshot.proto b/proto/archway/cwregistry/v1/snapshot.proto deleted file mode 100644 index 27d0ba08..00000000 --- a/proto/archway/cwregistry/v1/snapshot.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; -package archway.cwregistry.v1; - -option go_package = "github.com/archway-network/archway/x/cwregistry/types"; - -// SnapshotPayload defines the payload of a snapshot -message SnapshotPayload { - // The Code ID of the contract whose snapshot is being shared - uint64 code_id = 1; - // schema is the gzipped JSON schema which specifies the interaction endpoints of the contract - bytes schema = 2; -} diff --git a/proto/archway/cwregistry/v1/tx.proto b/proto/archway/cwregistry/v1/tx.proto index 18c78f95..3682f4a8 100644 --- a/proto/archway/cwregistry/v1/tx.proto +++ b/proto/archway/cwregistry/v1/tx.proto @@ -13,34 +13,10 @@ option go_package = "github.com/archway-network/archway/x/cwregistry/types"; // Msg defines the Msg service. service Msg { option (cosmos.msg.v1.service) = true; - // RegisterContract registers a contract with the contract registry. - rpc RegisterContract(MsgRegisterContract) returns (MsgRegisterContractResponse) {} // RegisterCode registers a contract code with the contract registry. rpc RegisterCode(MsgRegisterCode) returns (MsgRegisterCodeResponse) {} } -// MsgRegisterContract registers a contract with the contract registry. -message MsgRegisterContract { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "sender"; - // sender is the bech32 address of the sender. - string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // contract_address is the bech32 address of the contract. - string contract_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // source_metadata is the metadata of the contract source. - SourceMetadata source_metadata = 3; - // source_builder is the builder image of the contract source. - SourceBuilder source_builder = 4; - // schema is the json schema of the contract. - string schema = 5; - // contacts is the list of dev contacts for the contract. - repeated string contacts = 6; -} - -// MsgRegisterContractResponse defines the Msg/RegisterContract response type. -message MsgRegisterContractResponse {} - // MsgRegisterCode registers a contract code with the contract registry. message MsgRegisterCode { option (gogoproto.equal) = false; diff --git a/x/cwregistry/client/cli/flags.go b/x/cwregistry/client/cli/flags.go index feb9d8c0..4d59b555 100644 --- a/x/cwregistry/client/cli/flags.go +++ b/x/cwregistry/client/cli/flags.go @@ -1,8 +1,6 @@ package cli import ( - "os" - "github.com/archway-network/archway/x/cwregistry/types" "github.com/spf13/cobra" ) @@ -90,9 +88,5 @@ func parseSourceBuilder(cmd *cobra.Command) types.SourceBuilder { func parseSchema(cmd *cobra.Command) string { schemaPath, _ := cmd.Flags().GetString(flagSchemaPath) - fileContent, err := os.ReadFile(schemaPath) - if err != nil { - return "" - } - return string(fileContent) + return schemaPath } diff --git a/x/cwregistry/client/cli/query.go b/x/cwregistry/client/cli/query.go index 1e6d63dd..e36d0f4e 100644 --- a/x/cwregistry/client/cli/query.go +++ b/x/cwregistry/client/cli/query.go @@ -24,8 +24,6 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdQueryCodeMetadata()) cmd.AddCommand(CmdQueryContractMetadata()) - cmd.AddCommand(CmdQueryCodeSchema()) - cmd.AddCommand(CmdQueryContractSchema()) return cmd } @@ -88,62 +86,3 @@ func CmdQueryContractMetadata() *cobra.Command { return cmd } - -func CmdQueryCodeSchema() *cobra.Command { - cmd := &cobra.Command{ - Use: "code-schema", - Short: "", - Long: "", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - codeID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - res, err := queryClient.CodeSchema(context.Background(), &types.QueryCodeSchemaRequest{ - CodeId: codeID, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryContractSchema() *cobra.Command { - cmd := &cobra.Command{ - Use: "contract-schema", - Short: "", - Long: "", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - contractAddr := args[0] - res, err := queryClient.ContractSchema(context.Background(), &types.QueryContractSchemaRequest{ - ContractAddress: contractAddr, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/cwregistry/client/cli/tx.go b/x/cwregistry/client/cli/tx.go deleted file mode 100644 index 48103b6a..00000000 --- a/x/cwregistry/client/cli/tx.go +++ /dev/null @@ -1,109 +0,0 @@ -package cli - -import ( - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/spf13/cobra" - - "github.com/archway-network/archway/pkg" - "github.com/archway-network/archway/x/cwregistry/types" -) - -// GetTxCmd builds tx command group for the module. -func GetTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: types.ModuleName, - Short: "Transaction commands for the cwregistry module", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand(CmdRegisterCode()) - cmd.AddCommand(CmdRegisterContract()) - - return cmd -} - -func CmdRegisterContract() *cobra.Command { - cmd := &cobra.Command{ - Use: "register-contract [contract-address]", - Args: cobra.ExactArgs(1), - Short: "", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - senderAddr := clientCtx.GetFromAddress() - contractAddr := args[0] - - sourceMetadata := parseSourceMetadata(cmd) - sourceBuilder := parseSourceBuilder(cmd) - schema := parseSchema(cmd) - contacts, err := pkg.GetStringSliceFlag(cmd, flagContacts, true) - if err != nil { - return err - } - msg := types.MsgRegisterContract{ - Sender: senderAddr.String(), - ContractAddress: contractAddr, - SourceMetadata: &sourceMetadata, - SourceBuilder: &sourceBuilder, - Schema: schema, - Contacts: contacts, - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - addFlags(cmd) - - return cmd -} - -func CmdRegisterCode() *cobra.Command { - cmd := &cobra.Command{ - Use: "register-code [code-id]", - Args: cobra.ExactArgs(1), - Short: "", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - senderAddr := clientCtx.GetFromAddress() - codeID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - sourceMetadata := parseSourceMetadata(cmd) - sourceBuilder := parseSourceBuilder(cmd) - schema := parseSchema(cmd) - contacts, err := pkg.GetStringSliceFlag(cmd, flagContacts, true) - if err != nil { - return err - } - msg := types.MsgRegisterCode{ - Sender: senderAddr.String(), - CodeId: codeID, - SourceMetadata: &sourceMetadata, - SourceBuilder: &sourceBuilder, - Schema: schema, - Contacts: contacts, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - addFlags(cmd) - - return cmd -} diff --git a/x/cwregistry/keeper/code_metadata.go b/x/cwregistry/keeper/code_metadata.go index c9034fac..cee8afb3 100644 --- a/x/cwregistry/keeper/code_metadata.go +++ b/x/cwregistry/keeper/code_metadata.go @@ -1,9 +1,6 @@ package keeper import ( - "crypto/sha256" - "encoding/hex" - "github.com/archway-network/archway/x/cwregistry/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -31,20 +28,6 @@ func (k Keeper) HasCodeMetadata(ctx sdk.Context, codeID uint64) bool { return has } -// SetContractMetadata sets the metadata for the contract with the given address -func (k Keeper) SetContractMetadata(ctx sdk.Context, sender sdk.AccAddress, contractAddress sdk.AccAddress, codeMetadata types.CodeMetadata) error { - contractInfo := k.wasmKeeper.GetContractInfo(ctx, contractAddress) - if contractInfo == nil { - return types.ErrNoSuchContract - } - if contractInfo.Creator != sender.String() && contractInfo.Admin != sender.String() && sender.String() != contractAddress.String() { - return types.ErrUnauthorized - } - codeID := contractInfo.CodeID - codeMetadata.CodeId = codeID - return k.saveCodeMetadata(ctx, codeMetadata) -} - // SetCodeMetadata sets the metadata for the code with the given codeID func (k Keeper) SetCodeMetadata(ctx sdk.Context, sender sdk.AccAddress, codeID uint64, codeMetadata types.CodeMetadata) error { codeInfo := k.wasmKeeper.GetCodeInfo(ctx, codeID) @@ -70,21 +53,8 @@ func (k Keeper) UnsafeSetCodeMetadata(ctx sdk.Context, codeMetadata types.CodeMe // saveCodeMetadata saves the code metadata to the store func (k Keeper) saveCodeMetadata(ctx sdk.Context, codeMetadata types.CodeMetadata) error { - schemaContent := codeMetadata.Schema - if len(schemaContent) > 255 { // we dont want to store large schemas in the store - // todo: save to fs - schemaHash := hash(schemaContent) - codeMetadata.Schema = schemaHash - } if err := codeMetadata.Validate(); err != nil { return err } return k.CodeMetadata.Set(ctx, codeMetadata.CodeId, codeMetadata) } - -// hash returns the sha256 hash of the given schema -func hash(schemaContent string) string { - hasher := sha256.New() - hasher.Write([]byte(schemaContent)) - return hex.EncodeToString(hasher.Sum(nil)) -} diff --git a/x/cwregistry/keeper/code_metadata_test.go b/x/cwregistry/keeper/code_metadata_test.go index 4536fd06..865ce83a 100644 --- a/x/cwregistry/keeper/code_metadata_test.go +++ b/x/cwregistry/keeper/code_metadata_test.go @@ -3,41 +3,11 @@ package keeper_test import ( "testing" - e2eTesting "github.com/archway-network/archway/e2e/testing" "github.com/archway-network/archway/pkg/testutils" "github.com/archway-network/archway/x/cwregistry/types" "github.com/stretchr/testify/require" ) -func TestSetContractMetadata(t *testing.T) { - keeper, ctx := testutils.CWRegistryKeeper(t) - wasmKeeper := testutils.NewMockContractViewer() - keeper.SetWasmKeeper(wasmKeeper) - - contractAddr := e2eTesting.GenContractAddresses(1)[0] - - // TEST: No such contract exists - err := keeper.SetContractMetadata(ctx, testutils.AccAddress(), contractAddr, types.CodeMetadata{}) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrNoSuchContract) - - // TEST: Unauthorized - contractAdminAcc := testutils.AccAddress() - wasmKeeper.AddContractAdmin( - contractAddr.String(), - contractAdminAcc.String(), - ) - wasmKeeper.AddCodeAdmin(1, contractAdminAcc.String()) - err = keeper.SetContractMetadata(ctx, testutils.AccAddress(), contractAddr, types.CodeMetadata{}) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrUnauthorized) - - // TEST: Success - err = keeper.SetContractMetadata(ctx, contractAdminAcc, contractAddr, types.CodeMetadata{}) - require.NoError(t, err) - require.True(t, keeper.HasCodeMetadata(ctx, 0)) -} - func TestSetCodeMetadata(t *testing.T) { keeper, ctx := testutils.CWRegistryKeeper(t) wasmKeeper := testutils.NewMockContractViewer() diff --git a/x/cwregistry/keeper/code_schema.go b/x/cwregistry/keeper/code_schema.go deleted file mode 100644 index 57f18022..00000000 --- a/x/cwregistry/keeper/code_schema.go +++ /dev/null @@ -1,19 +0,0 @@ -package keeper - -import ( - "fmt" - "path/filepath" - - "github.com/cometbft/cometbft/libs/os" -) - -func (k Keeper) GetSchema(codeID uint64) (string, error) { - filePath := filepath.Join(k.dataRoot, fmt.Sprintf("%d", codeID)) - contents, err := os.ReadFile(filePath) - return string(contents), err -} - -func (k Keeper) SetSchema(codeID uint64, schema string) error { - filePath := filepath.Join(k.dataRoot, fmt.Sprintf("%d", codeID)) - return os.WriteFile(filePath, []byte(schema), 0644) -} diff --git a/x/cwregistry/keeper/code_schema_test.go b/x/cwregistry/keeper/code_schema_test.go deleted file mode 100644 index 9a8457bd..00000000 --- a/x/cwregistry/keeper/code_schema_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/archway-network/archway/pkg/testutils" - "github.com/stretchr/testify/require" -) - -func TestSetSchema(t *testing.T) { - keeper, _ := testutils.CWRegistryKeeper(t) - - // Getting schema which doesn't exist - _, err := keeper.GetSchema(1) - require.Error(t, err) - - // Saving schema - err = keeper.SetSchema(1, "testContent") - require.NoError(t, err) - - // Getting schema which now exists - schema, err := keeper.GetSchema(1) - require.NoError(t, err) - require.Equal(t, "testContent", schema) -} diff --git a/x/cwregistry/keeper/grpc_query.go b/x/cwregistry/keeper/grpc_query.go index 483c5893..4cbb37a7 100644 --- a/x/cwregistry/keeper/grpc_query.go +++ b/x/cwregistry/keeper/grpc_query.go @@ -32,19 +32,6 @@ func (q *QueryServer) CodeMetadata(c context.Context, req *types.QueryCodeMetada return &types.QueryCodeMetadataResponse{CodeMetadata: &codeMetadata}, err } -// CodeSchema implements types.QueryServer. -func (q *QueryServer) CodeSchema(c context.Context, req *types.QueryCodeSchemaRequest) (*types.QueryCodeSchemaResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - ctx := sdk.UnwrapSDKContext(c) - if !q.keeper.HasCodeMetadata(ctx, req.GetCodeId()) { - return nil, status.Error(codes.NotFound, "code metadata not found") - } - schema, err := q.keeper.GetSchema(req.GetCodeId()) - return &types.QueryCodeSchemaResponse{Schema: schema}, err -} - // ContractMetadata implements types.QueryServer. func (q *QueryServer) ContractMetadata(c context.Context, req *types.QueryContractMetadataRequest) (*types.QueryContractMetadataResponse, error) { if req == nil { @@ -59,21 +46,3 @@ func (q *QueryServer) ContractMetadata(c context.Context, req *types.QueryContra codeMetadata, err := q.keeper.GetCodeMetadata(ctx, codeInfo.CodeID) return &types.QueryContractMetadataResponse{CodeMetadata: &codeMetadata}, err } - -// ContractSchema implements types.QueryServer. -func (q *QueryServer) ContractSchema(c context.Context, req *types.QueryContractSchemaRequest) (*types.QueryContractSchemaResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - ctx := sdk.UnwrapSDKContext(c) - contractAddr, err := sdk.AccAddressFromBech32(req.GetContractAddress()) - if err != nil { - return nil, err - } - codeInfo := q.keeper.wasmKeeper.GetContractInfo(ctx, contractAddr) - if !q.keeper.HasCodeMetadata(ctx, codeInfo.CodeID) { - return nil, status.Error(codes.NotFound, "code metadata not found") - } - schema, err := q.keeper.GetSchema(codeInfo.CodeID) - return &types.QueryContractSchemaResponse{Schema: schema}, err -} diff --git a/x/cwregistry/keeper/keeper.go b/x/cwregistry/keeper/keeper.go index 3eba468d..d91def17 100644 --- a/x/cwregistry/keeper/keeper.go +++ b/x/cwregistry/keeper/keeper.go @@ -1,13 +1,10 @@ package keeper import ( - "path/filepath" - "cosmossdk.io/collections" "cosmossdk.io/log" "github.com/archway-network/archway/internal/collcompat" "github.com/archway-network/archway/x/cwregistry/types" - "github.com/cometbft/cometbft/libs/os" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" @@ -20,7 +17,6 @@ type ( storeKey storetypes.StoreKey wasmKeeper types.WasmKeeper logger log.Logger - dataRoot string Schema collections.Schema // CodeMetadata key: CodeMetadataKeyPrefix + codeID | value: CodeMetadata @@ -32,7 +28,6 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, wasmKeeper types.WasmKeeper, - homePath string, logger log.Logger, ) Keeper { sb := collections.NewSchemaBuilder(collcompat.NewKVStoreService(storeKey)) @@ -42,7 +37,6 @@ func NewKeeper( storeKey: storeKey, wasmKeeper: wasmKeeper, logger: logger.With("module", "x/"+types.ModuleName), - dataRoot: filepath.Join(homePath, "registry"), CodeMetadata: collections.NewMap( sb, types.CodeMetadataKeyPrefix, @@ -51,10 +45,6 @@ func NewKeeper( collcompat.ProtoValue[types.CodeMetadata](cdc), ), } - err := os.EnsureDir(k.dataRoot, 0755) - if err != nil { - panic(err) - } schema, err := sb.Build() if err != nil { diff --git a/x/cwregistry/keeper/msg_server.go b/x/cwregistry/keeper/msg_server.go index 8e34acdd..9b7d67d7 100644 --- a/x/cwregistry/keeper/msg_server.go +++ b/x/cwregistry/keeper/msg_server.go @@ -40,27 +40,3 @@ func (m msgServer) RegisterCode(c context.Context, req *types.MsgRegisterCode) ( err = m.SetCodeMetadata(ctx, sender, req.CodeId, codeMetadata) return &types.MsgRegisterCodeResponse{}, err } - -// RegisterContract implements types.MsgServer. -func (m msgServer) RegisterContract(c context.Context, req *types.MsgRegisterContract) (*types.MsgRegisterContractResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - ctx := sdk.UnwrapSDKContext(c) - sender, err := sdk.AccAddressFromBech32(req.Sender) - if err != nil { - return nil, err - } - contractAddress, err := sdk.AccAddressFromBech32(req.ContractAddress) - if err != nil { - return nil, err - } - codeMetadata := types.CodeMetadata{ - Source: req.SourceMetadata, - SourceBuilder: req.SourceBuilder, - Schema: req.Schema, - Contacts: req.Contacts, - } - err = m.SetContractMetadata(ctx, sender, contractAddress, codeMetadata) - return &types.MsgRegisterContractResponse{}, err -} diff --git a/x/cwregistry/keeper/msg_server_test.go b/x/cwregistry/keeper/msg_server_test.go index 8a9d2293..408e630d 100644 --- a/x/cwregistry/keeper/msg_server_test.go +++ b/x/cwregistry/keeper/msg_server_test.go @@ -6,7 +6,6 @@ import ( "github.com/archway-network/archway/pkg/testutils" "github.com/archway-network/archway/x/cwregistry/keeper" "github.com/archway-network/archway/x/cwregistry/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) @@ -44,43 +43,3 @@ func TestRegisterCode(t *testing.T) { require.NoError(t, err) require.True(t, k.HasCodeMetadata(ctx, 1)) } - -func TestRegisterContract(t *testing.T) { - k, ctx := testutils.CWRegistryKeeper(t) - wasmKeeper := testutils.NewMockContractViewer() - k.SetWasmKeeper(wasmKeeper) - msgSrvr := keeper.NewMsgServerImpl(k) - senderAddr := testutils.AccAddress().String() - wasmKeeper.AddContractAdmin(senderAddr, senderAddr) - wasmKeeper.AddCodeAdmin(1, senderAddr) - - // TEST: Empty - msg := types.MsgRegisterContract{} - _, err := msgSrvr.RegisterContract(sdk.WrapSDKContext(ctx), &msg) - require.Error(t, err) - - // TEST Invalid sender - msg = types.MsgRegisterContract{ - Sender: "👻", - ContractAddress: senderAddr, - } - _, err = msgSrvr.RegisterContract(ctx, &msg) - require.Error(t, err) - - // TEST Invalid contract addr - msg = types.MsgRegisterContract{ - Sender: senderAddr, - ContractAddress: "👻", - } - _, err = msgSrvr.RegisterContract(ctx, &msg) - require.Error(t, err) - - // TEST: Success - msg = types.MsgRegisterContract{ - Sender: senderAddr, - ContractAddress: senderAddr, - } - _, err = msgSrvr.RegisterContract(ctx, &msg) - require.NoError(t, err) - require.True(t, k.HasCodeMetadata(ctx, 0)) -} diff --git a/x/cwregistry/keeper/snapshotter.go b/x/cwregistry/keeper/snapshotter.go deleted file mode 100644 index ea3e6283..00000000 --- a/x/cwregistry/keeper/snapshotter.go +++ /dev/null @@ -1,106 +0,0 @@ -package keeper - -import ( - "fmt" - "io" - "math" - - "cosmossdk.io/log" - snapshot "cosmossdk.io/store/snapshots/types" - storetypes "cosmossdk.io/store/types" - "github.com/CosmWasm/wasmd/x/wasm/ioutils" - "github.com/archway-network/archway/x/cwregistry/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ snapshot.ExtensionSnapshotter = &CwRegistrySnapshotter{} - -const SnapshotFormat = 1 - -type CwRegistrySnapshotter struct { - registryKeeper *Keeper - cms storetypes.MultiStore -} - -func NewCwRegistrySnapshotter(k *Keeper, cms storetypes.MultiStore) *CwRegistrySnapshotter { - return &CwRegistrySnapshotter{ - registryKeeper: k, - cms: cms, - } -} - -func (s *CwRegistrySnapshotter) SnapshotName() string { - return types.ModuleName -} - -func (s *CwRegistrySnapshotter) SnapshotFormat() uint32 { - return SnapshotFormat -} - -func (s *CwRegistrySnapshotter) SupportedFormats() []uint32 { - return []uint32{SnapshotFormat} -} - -func (s *CwRegistrySnapshotter) SnapshotExtension(height uint64, payloadWriter snapshot.ExtensionPayloadWriter) error { - cacheMS, err := s.cms.CacheMultiStoreWithVersion(int64(height)) - if err != nil { - return err - } - ctx := sdk.NewContext(cacheMS, tmproto.Header{}, false, log.NewNopLogger()) - codeMetadata, err := s.registryKeeper.GetAllCodeMetadata(ctx) - if err != nil { - return err - } - for _, metadata := range codeMetadata { - schema, err := s.registryKeeper.GetSchema(metadata.CodeId) - if err != nil { - return err - } - compressedSchema, err := ioutils.GzipIt([]byte(schema)) - if err != nil { - return err - } - snapshotPayload := types.NewSnapshot(metadata.CodeId, compressedSchema) - payloadData, err := snapshotPayload.Marshal() - if err != nil { - return err - } - err = payloadWriter(payloadData) - if err != nil { - return err - } - } - return nil -} - -func (s *CwRegistrySnapshotter) RestoreExtension(height uint64, format uint32, payloadReader snapshot.ExtensionPayloadReader) error { - if format != SnapshotFormat { - return snapshot.ErrUnknownFormat - } - for { - payload, err := payloadReader() - switch { - case err == io.EOF: - return nil - case err != nil: - return fmt.Errorf("cannot read blob from the payload: %w", err) - } - var snapshotPayload types.SnapshotPayload - err = snapshotPayload.Unmarshal(payload) - if err != nil { - return err - } - if !ioutils.IsGzip(snapshotPayload.Schema) { - return types.ErrInvalidSnapshotPayload - } - schema, err := ioutils.Uncompress(snapshotPayload.Schema, math.MaxInt64) - if err != nil { - return err - } - err = s.registryKeeper.SetSchema(snapshotPayload.CodeId, string(schema)) - if err != nil { - return err - } - } -} diff --git a/x/cwregistry/module.go b/x/cwregistry/module.go index fbfe391e..866d203e 100644 --- a/x/cwregistry/module.go +++ b/x/cwregistry/module.go @@ -85,12 +85,12 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r } } -// GetTxCmd returns the capability module's root tx command. +// GetTxCmd returns the cwregistry module's root tx command. func (a AppModuleBasic) GetTxCmd() *cobra.Command { return nil } -// GetQueryCmd returns the capability module's root query command. +// GetQueryCmd returns the cwregistry module's root query command. func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd(types.StoreKey) } diff --git a/x/cwregistry/types/codec.go b/x/cwregistry/types/codec.go index 795dd087..60a5ce2a 100644 --- a/x/cwregistry/types/codec.go +++ b/x/cwregistry/types/codec.go @@ -11,14 +11,13 @@ import ( // RegisterCodec registers concrete types on the Amino codec func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgRegisterContract{}, "/archway.cwregistry.v1.MsgRegisterContract", nil) cdc.RegisterConcrete(&MsgRegisterCode{}, "/archway.cwregistry.v1.MsgRegisterCode", nil) } // RegisterInterfaces registers the x/cwica interfaces types with the interface registry func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgRegisterContract{}, + &MsgRegisterCode{}, ) diff --git a/x/cwregistry/types/cwregistry.pb.go b/x/cwregistry/types/cwregistry.pb.go index 5759bded..243708d4 100644 --- a/x/cwregistry/types/cwregistry.pb.go +++ b/x/cwregistry/types/cwregistry.pb.go @@ -30,7 +30,7 @@ type CodeMetadata struct { Source *SourceMetadata `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` // The information regarding the image used to build and optimize the contract binary SourceBuilder *SourceBuilder `protobuf:"bytes,3,opt,name=source_builder,json=sourceBuilder,proto3" json:"source_builder,omitempty"` - // The JSON schema which specifies the interaction endpoints of the contract + // The JSON schema url which specifies the interaction endpoints of the contract Schema string `protobuf:"bytes,4,opt,name=schema,proto3" json:"schema,omitempty"` // The contacts of the developers or security incidence handlers Contacts []string `protobuf:"bytes,5,rep,name=contacts,proto3" json:"contacts,omitempty"` diff --git a/x/cwregistry/types/msg.go b/x/cwregistry/types/msg.go index 8e4694bf..f72b1c82 100644 --- a/x/cwregistry/types/msg.go +++ b/x/cwregistry/types/msg.go @@ -5,6 +5,5 @@ import ( ) var ( - _ sdk.Msg = &MsgRegisterContract{} _ sdk.Msg = &MsgRegisterCode{} ) diff --git a/x/cwregistry/types/query.pb.go b/x/cwregistry/types/query.pb.go index 8e8d5385..02c1be9c 100644 --- a/x/cwregistry/types/query.pb.go +++ b/x/cwregistry/types/query.pb.go @@ -213,237 +213,42 @@ func (m *QueryContractMetadataResponse) GetCodeMetadata() *CodeMetadata { return nil } -// QueryCodeSchemaRequest is the request type for the Query/CodeSchema RPC method. -type QueryCodeSchemaRequest struct { - // code_id is the contract code id to query schema for. - CodeId uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` -} - -func (m *QueryCodeSchemaRequest) Reset() { *m = QueryCodeSchemaRequest{} } -func (m *QueryCodeSchemaRequest) String() string { return proto.CompactTextString(m) } -func (*QueryCodeSchemaRequest) ProtoMessage() {} -func (*QueryCodeSchemaRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d970ba8222896566, []int{4} -} -func (m *QueryCodeSchemaRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCodeSchemaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCodeSchemaRequest.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 *QueryCodeSchemaRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCodeSchemaRequest.Merge(m, src) -} -func (m *QueryCodeSchemaRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryCodeSchemaRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCodeSchemaRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCodeSchemaRequest proto.InternalMessageInfo - -func (m *QueryCodeSchemaRequest) GetCodeId() uint64 { - if m != nil { - return m.CodeId - } - return 0 -} - -// QueryCodeSchemaResponse is the response type for the Query/CodeSchema RPC method. -type QueryCodeSchemaResponse struct { - // code_schema is the schema for the contract code. - Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"` -} - -func (m *QueryCodeSchemaResponse) Reset() { *m = QueryCodeSchemaResponse{} } -func (m *QueryCodeSchemaResponse) String() string { return proto.CompactTextString(m) } -func (*QueryCodeSchemaResponse) ProtoMessage() {} -func (*QueryCodeSchemaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d970ba8222896566, []int{5} -} -func (m *QueryCodeSchemaResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCodeSchemaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCodeSchemaResponse.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 *QueryCodeSchemaResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCodeSchemaResponse.Merge(m, src) -} -func (m *QueryCodeSchemaResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryCodeSchemaResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCodeSchemaResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCodeSchemaResponse proto.InternalMessageInfo - -func (m *QueryCodeSchemaResponse) GetSchema() string { - if m != nil { - return m.Schema - } - return "" -} - -// QueryContractSchemaRequest is the request type for the Query/ContractSchema RPC method. -type QueryContractSchemaRequest struct { - // contract_address is the bech32 contract address to query schema for. - ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` -} - -func (m *QueryContractSchemaRequest) Reset() { *m = QueryContractSchemaRequest{} } -func (m *QueryContractSchemaRequest) String() string { return proto.CompactTextString(m) } -func (*QueryContractSchemaRequest) ProtoMessage() {} -func (*QueryContractSchemaRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d970ba8222896566, []int{6} -} -func (m *QueryContractSchemaRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryContractSchemaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryContractSchemaRequest.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 *QueryContractSchemaRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryContractSchemaRequest.Merge(m, src) -} -func (m *QueryContractSchemaRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryContractSchemaRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryContractSchemaRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryContractSchemaRequest proto.InternalMessageInfo - -func (m *QueryContractSchemaRequest) GetContractAddress() string { - if m != nil { - return m.ContractAddress - } - return "" -} - -// QueryContractSchemaResponse is the response type for the Query/ContractSchema RPC method. -type QueryContractSchemaResponse struct { - // contract_schema is the schema for the contract. - Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"` -} - -func (m *QueryContractSchemaResponse) Reset() { *m = QueryContractSchemaResponse{} } -func (m *QueryContractSchemaResponse) String() string { return proto.CompactTextString(m) } -func (*QueryContractSchemaResponse) ProtoMessage() {} -func (*QueryContractSchemaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d970ba8222896566, []int{7} -} -func (m *QueryContractSchemaResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryContractSchemaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryContractSchemaResponse.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 *QueryContractSchemaResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryContractSchemaResponse.Merge(m, src) -} -func (m *QueryContractSchemaResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryContractSchemaResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryContractSchemaResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryContractSchemaResponse proto.InternalMessageInfo - -func (m *QueryContractSchemaResponse) GetSchema() string { - if m != nil { - return m.Schema - } - return "" -} - func init() { proto.RegisterType((*QueryCodeMetadataRequest)(nil), "archway.cwregistry.v1.QueryCodeMetadataRequest") proto.RegisterType((*QueryCodeMetadataResponse)(nil), "archway.cwregistry.v1.QueryCodeMetadataResponse") proto.RegisterType((*QueryContractMetadataRequest)(nil), "archway.cwregistry.v1.QueryContractMetadataRequest") proto.RegisterType((*QueryContractMetadataResponse)(nil), "archway.cwregistry.v1.QueryContractMetadataResponse") - proto.RegisterType((*QueryCodeSchemaRequest)(nil), "archway.cwregistry.v1.QueryCodeSchemaRequest") - proto.RegisterType((*QueryCodeSchemaResponse)(nil), "archway.cwregistry.v1.QueryCodeSchemaResponse") - proto.RegisterType((*QueryContractSchemaRequest)(nil), "archway.cwregistry.v1.QueryContractSchemaRequest") - proto.RegisterType((*QueryContractSchemaResponse)(nil), "archway.cwregistry.v1.QueryContractSchemaResponse") } func init() { proto.RegisterFile("archway/cwregistry/v1/query.proto", fileDescriptor_d970ba8222896566) } var fileDescriptor_d970ba8222896566 = []byte{ - // 500 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x6b, 0xc4, 0x8a, 0x78, 0x19, 0x30, 0x59, 0xb0, 0x8d, 0x30, 0x22, 0x08, 0x53, 0x55, - 0x26, 0x16, 0x2f, 0x2d, 0xfb, 0x00, 0xc0, 0x01, 0x76, 0x40, 0x88, 0x72, 0xe3, 0x32, 0x79, 0x8e, - 0x95, 0x46, 0xd0, 0xb8, 0xb3, 0xdd, 0x95, 0x5e, 0xf9, 0x04, 0x48, 0x1c, 0x38, 0xee, 0xc8, 0x91, - 0xaf, 0xc1, 0x71, 0x12, 0x17, 0x8e, 0xa8, 0xe5, 0x83, 0xa0, 0x3a, 0x5e, 0x97, 0x94, 0xa4, 0x7f, - 0x24, 0x6e, 0xb5, 0xfd, 0x3e, 0xcf, 0xfb, 0xf3, 0xf3, 0xba, 0x81, 0x07, 0x54, 0xb2, 0x76, 0x9f, - 0x0e, 0x08, 0xeb, 0x4b, 0x1e, 0xc5, 0x4a, 0xcb, 0x01, 0x39, 0x09, 0xc8, 0x71, 0x8f, 0xcb, 0x81, - 0xdf, 0x95, 0x42, 0x0b, 0x7c, 0xdb, 0x96, 0xf8, 0x17, 0x25, 0xfe, 0x49, 0xe0, 0xdc, 0x8a, 0x44, - 0x24, 0x4c, 0x05, 0x19, 0xff, 0x4a, 0x8b, 0x9d, 0x5a, 0xb1, 0x5f, 0x46, 0x9a, 0xd6, 0x6d, 0x45, - 0x42, 0x44, 0x1f, 0x38, 0xa1, 0xdd, 0x98, 0xd0, 0x24, 0x11, 0x9a, 0xea, 0x58, 0x24, 0x2a, 0x3d, - 0xf5, 0x9a, 0xb0, 0xf9, 0x66, 0x4c, 0xf0, 0x5c, 0x84, 0xfc, 0x15, 0xd7, 0x34, 0xa4, 0x9a, 0xb6, - 0xf8, 0x71, 0x8f, 0x2b, 0x8d, 0x37, 0xe0, 0x0a, 0x13, 0x21, 0x3f, 0x8c, 0xc3, 0x4d, 0x74, 0x1f, - 0xd5, 0x2f, 0xb7, 0xaa, 0xe3, 0xe5, 0x41, 0xe8, 0x71, 0xb8, 0x53, 0x20, 0x52, 0x5d, 0x91, 0x28, - 0x8e, 0x5f, 0xc2, 0x75, 0xa3, 0xea, 0xd8, 0x03, 0xa3, 0xbd, 0xd6, 0x78, 0xe8, 0x17, 0x5e, 0xce, - 0xcf, 0x79, 0xac, 0xb2, 0xcc, 0xca, 0x3b, 0x80, 0x2d, 0xdb, 0x26, 0xd1, 0x92, 0x32, 0x3d, 0xcd, - 0xf7, 0x08, 0xd6, 0x98, 0x3d, 0x3a, 0xa4, 0x61, 0x28, 0xb9, 0x52, 0xa6, 0xd9, 0xd5, 0xd6, 0xcd, - 0xf3, 0xfd, 0xa7, 0xe9, 0xb6, 0x17, 0xc3, 0xbd, 0x12, 0xab, 0xff, 0x4e, 0x1d, 0xc0, 0xfa, 0x24, - 0x9c, 0xb7, 0xac, 0xcd, 0x3b, 0xf3, 0xf3, 0x0c, 0x60, 0xe3, 0x1f, 0x89, 0xe5, 0x5a, 0x87, 0xaa, - 0x32, 0x3b, 0xf6, 0x66, 0x76, 0xe5, 0xbd, 0x00, 0x27, 0x77, 0xa1, 0x7c, 0xa7, 0x25, 0x92, 0xd9, - 0x87, 0xbb, 0x85, 0x46, 0xb3, 0xfb, 0x37, 0x4e, 0x57, 0x60, 0xc5, 0xe8, 0xf0, 0x29, 0x82, 0xd5, - 0x6c, 0x1c, 0x98, 0x94, 0x64, 0x56, 0xf6, 0xce, 0x9c, 0xbd, 0xc5, 0x05, 0x29, 0x95, 0xf7, 0xf8, - 0xd3, 0xcf, 0x3f, 0x5f, 0x2e, 0xd5, 0xf0, 0x36, 0x29, 0xf9, 0x13, 0x64, 0x47, 0x89, 0xbf, 0x23, - 0x58, 0x9b, 0x1e, 0x3c, 0x6e, 0xce, 0x6e, 0x5a, 0xf8, 0xe2, 0x9c, 0x27, 0xcb, 0x89, 0x2c, 0xed, - 0x9e, 0xa1, 0xdd, 0xc1, 0xf5, 0x52, 0x5a, 0x3b, 0xaa, 0x09, 0xf1, 0x57, 0x04, 0x70, 0xf1, 0x18, - 0xf0, 0xee, 0xbc, 0x80, 0x72, 0xd3, 0x77, 0xfc, 0x45, 0xcb, 0x2d, 0xdf, 0x8e, 0xe1, 0xdb, 0xc6, - 0xde, 0xac, 0x34, 0xd3, 0xb9, 0xe3, 0x6f, 0x08, 0x6e, 0xe4, 0x9f, 0x0a, 0x0e, 0x16, 0x09, 0x25, - 0x4f, 0xd8, 0x58, 0x46, 0x62, 0x29, 0x7d, 0x43, 0x59, 0xc7, 0xb5, 0x79, 0x29, 0xa6, 0xa4, 0xcf, - 0x5e, 0xff, 0x18, 0xba, 0xe8, 0x6c, 0xe8, 0xa2, 0xdf, 0x43, 0x17, 0x7d, 0x1e, 0xb9, 0x95, 0xb3, - 0x91, 0x5b, 0xf9, 0x35, 0x72, 0x2b, 0xef, 0xf6, 0xa3, 0x58, 0xb7, 0x7b, 0x47, 0x3e, 0x13, 0x9d, - 0x73, 0xaf, 0xdd, 0x84, 0xeb, 0xbe, 0x90, 0xef, 0x27, 0xde, 0x1f, 0xb3, 0xee, 0x7a, 0xd0, 0xe5, - 0xea, 0xa8, 0x6a, 0xbe, 0x98, 0xcd, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x79, 0x8e, 0xf5, 0x56, - 0xc9, 0x05, 0x00, 0x00, + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x2c, 0x4a, 0xce, + 0x28, 0x4f, 0xac, 0xd4, 0x4f, 0x2e, 0x2f, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0xaa, 0xd4, 0x2f, + 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x85, + 0x2a, 0xd1, 0x43, 0x28, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd0, + 0x07, 0xb1, 0x20, 0x8a, 0xa5, 0xd4, 0xb0, 0x9b, 0x87, 0xa4, 0x15, 0xa2, 0x4e, 0x26, 0x3d, 0x3f, + 0x3f, 0x3d, 0x27, 0x55, 0x3f, 0xb1, 0x20, 0x53, 0x3f, 0x31, 0x2f, 0x2f, 0xbf, 0x24, 0xb1, 0x24, + 0x33, 0x3f, 0xaf, 0x18, 0x22, 0xab, 0x64, 0xcc, 0x25, 0x11, 0x08, 0x72, 0x81, 0x73, 0x7e, 0x4a, + 0xaa, 0x6f, 0x6a, 0x49, 0x62, 0x4a, 0x62, 0x49, 0x62, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, + 0x90, 0x38, 0x17, 0x7b, 0x72, 0x7e, 0x4a, 0x6a, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, 0xa3, 0x06, + 0x4b, 0x10, 0x1b, 0x88, 0xeb, 0x99, 0xa2, 0x94, 0xca, 0x25, 0x89, 0x45, 0x53, 0x71, 0x41, 0x7e, + 0x5e, 0x71, 0xaa, 0x90, 0x07, 0x17, 0x2f, 0x58, 0x57, 0x2e, 0x54, 0x02, 0xac, 0x97, 0xdb, 0x48, + 0x59, 0x0f, 0xab, 0xe7, 0xf4, 0x50, 0xcc, 0xe0, 0x49, 0x46, 0xe2, 0x29, 0x79, 0x72, 0xc9, 0x40, + 0xad, 0xc9, 0x2b, 0x29, 0x4a, 0x4c, 0x2e, 0x41, 0x77, 0x9f, 0x26, 0x97, 0x40, 0x32, 0x54, 0x2a, + 0x3e, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x18, 0x6c, 0x19, 0x67, 0x10, 0x3f, 0x4c, 0xdc, 0x11, + 0x22, 0xac, 0x94, 0xc9, 0x25, 0x8b, 0xc3, 0x28, 0x6a, 0xbb, 0xda, 0xe8, 0x36, 0x13, 0x17, 0x2b, + 0xd8, 0x2e, 0xa1, 0xf9, 0x8c, 0x5c, 0x3c, 0xc8, 0x0a, 0x85, 0xf4, 0x71, 0x98, 0x86, 0x2b, 0x06, + 0xa4, 0x0c, 0x88, 0xd7, 0x00, 0xf1, 0x87, 0x92, 0x4e, 0xd3, 0xe5, 0x27, 0x93, 0x99, 0xd4, 0x84, + 0x54, 0xf4, 0x71, 0x24, 0x0f, 0x64, 0x4f, 0x0a, 0xad, 0x67, 0xe4, 0x12, 0x40, 0x0f, 0x12, 0x21, + 0x63, 0xfc, 0x96, 0x62, 0x8d, 0x0b, 0x29, 0x13, 0xd2, 0x34, 0x41, 0x5d, 0x6b, 0x00, 0x76, 0xad, + 0x96, 0x90, 0x06, 0x4e, 0xd7, 0x42, 0xa3, 0x17, 0xe6, 0x62, 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, 0x85, 0x99, 0xa6, 0x9b, 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0x0d, 0x37, 0xbd, 0x02, 0xd9, + 0xfc, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x3e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, + 0xff, 0x07, 0x04, 0x17, 0x3a, 0x9f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -460,8 +265,6 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { CodeMetadata(ctx context.Context, in *QueryCodeMetadataRequest, opts ...grpc.CallOption) (*QueryCodeMetadataResponse, error) ContractMetadata(ctx context.Context, in *QueryContractMetadataRequest, opts ...grpc.CallOption) (*QueryContractMetadataResponse, error) - CodeSchema(ctx context.Context, in *QueryCodeSchemaRequest, opts ...grpc.CallOption) (*QueryCodeSchemaResponse, error) - ContractSchema(ctx context.Context, in *QueryContractSchemaRequest, opts ...grpc.CallOption) (*QueryContractSchemaResponse, error) } type queryClient struct { @@ -490,30 +293,10 @@ func (c *queryClient) ContractMetadata(ctx context.Context, in *QueryContractMet return out, nil } -func (c *queryClient) CodeSchema(ctx context.Context, in *QueryCodeSchemaRequest, opts ...grpc.CallOption) (*QueryCodeSchemaResponse, error) { - out := new(QueryCodeSchemaResponse) - err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Query/CodeSchema", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ContractSchema(ctx context.Context, in *QueryContractSchemaRequest, opts ...grpc.CallOption) (*QueryContractSchemaResponse, error) { - out := new(QueryContractSchemaResponse) - err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Query/ContractSchema", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { CodeMetadata(context.Context, *QueryCodeMetadataRequest) (*QueryCodeMetadataResponse, error) ContractMetadata(context.Context, *QueryContractMetadataRequest) (*QueryContractMetadataResponse, error) - CodeSchema(context.Context, *QueryCodeSchemaRequest) (*QueryCodeSchemaResponse, error) - ContractSchema(context.Context, *QueryContractSchemaRequest) (*QueryContractSchemaResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -526,12 +309,6 @@ func (*UnimplementedQueryServer) CodeMetadata(ctx context.Context, req *QueryCod func (*UnimplementedQueryServer) ContractMetadata(ctx context.Context, req *QueryContractMetadataRequest) (*QueryContractMetadataResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ContractMetadata not implemented") } -func (*UnimplementedQueryServer) CodeSchema(ctx context.Context, req *QueryCodeSchemaRequest) (*QueryCodeSchemaResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CodeSchema not implemented") -} -func (*UnimplementedQueryServer) ContractSchema(ctx context.Context, req *QueryContractSchemaRequest) (*QueryContractSchemaResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ContractSchema not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -573,42 +350,6 @@ func _Query_ContractMetadata_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Query_CodeSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCodeSchemaRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).CodeSchema(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/archway.cwregistry.v1.Query/CodeSchema", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).CodeSchema(ctx, req.(*QueryCodeSchemaRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ContractSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryContractSchemaRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ContractSchema(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/archway.cwregistry.v1.Query/ContractSchema", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ContractSchema(ctx, req.(*QueryContractSchemaRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "archway.cwregistry.v1.Query", HandlerType: (*QueryServer)(nil), @@ -621,14 +362,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ContractMetadata", Handler: _Query_ContractMetadata_Handler, }, - { - MethodName: "CodeSchema", - Handler: _Query_CodeSchema_Handler, - }, - { - MethodName: "ContractSchema", - Handler: _Query_ContractSchema_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "archway/cwregistry/v1/query.proto", @@ -762,124 +495,6 @@ func (m *QueryContractMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryCodeSchemaRequest) 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 *QueryCodeSchemaRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCodeSchemaRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.CodeId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.CodeId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryCodeSchemaResponse) 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 *QueryCodeSchemaResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCodeSchemaResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Schema) > 0 { - i -= len(m.Schema) - copy(dAtA[i:], m.Schema) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Schema))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryContractSchemaRequest) 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 *QueryContractSchemaRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryContractSchemaRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ContractAddress) > 0 { - i -= len(m.ContractAddress) - copy(dAtA[i:], m.ContractAddress) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryContractSchemaResponse) 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 *QueryContractSchemaResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryContractSchemaResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Schema) > 0 { - i -= len(m.Schema) - copy(dAtA[i:], m.Schema) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Schema))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -942,57 +557,6 @@ func (m *QueryContractMetadataResponse) Size() (n int) { return n } -func (m *QueryCodeSchemaRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CodeId != 0 { - n += 1 + sovQuery(uint64(m.CodeId)) - } - return n -} - -func (m *QueryCodeSchemaResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Schema) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryContractSchemaRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ContractAddress) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryContractSchemaResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Schema) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1322,321 +886,6 @@ func (m *QueryContractMetadataResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryCodeSchemaRequest) 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: QueryCodeSchemaRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCodeSchemaRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) - } - m.CodeId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CodeId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *QueryCodeSchemaResponse) 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: QueryCodeSchemaResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCodeSchemaResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", 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.Schema = 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 *QueryContractSchemaRequest) 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: QueryContractSchemaRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryContractSchemaRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = 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 *QueryContractSchemaResponse) 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: QueryContractSchemaResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryContractSchemaResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", 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.Schema = 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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/cwregistry/types/query.pb.gw.go b/x/cwregistry/types/query.pb.gw.go index 64514719..1fa4d2f7 100644 --- a/x/cwregistry/types/query.pb.gw.go +++ b/x/cwregistry/types/query.pb.gw.go @@ -105,78 +105,6 @@ func local_request_Query_ContractMetadata_0(ctx context.Context, marshaler runti } -var ( - filter_Query_CodeSchema_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_CodeSchema_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCodeSchemaRequest - 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_CodeSchema_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.CodeSchema(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_CodeSchema_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCodeSchemaRequest - 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_CodeSchema_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.CodeSchema(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_ContractSchema_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_ContractSchema_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryContractSchemaRequest - 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_ContractSchema_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.ContractSchema(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ContractSchema_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryContractSchemaRequest - 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_ContractSchema_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.ContractSchema(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. @@ -229,52 +157,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_CodeSchema_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_CodeSchema_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_CodeSchema_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ContractSchema_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_ContractSchema_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_ContractSchema_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -356,46 +238,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_CodeSchema_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_CodeSchema_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_CodeSchema_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ContractSchema_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_ContractSchema_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_ContractSchema_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -403,18 +245,10 @@ var ( pattern_Query_CodeMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "code_metadata"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ContractMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "contract_metadata"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_CodeSchema_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "code_schema"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ContractSchema_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"archway", "cwregistry", "v1", "contract_schema"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_CodeMetadata_0 = runtime.ForwardResponseMessage forward_Query_ContractMetadata_0 = runtime.ForwardResponseMessage - - forward_Query_CodeSchema_0 = runtime.ForwardResponseMessage - - forward_Query_ContractSchema_0 = runtime.ForwardResponseMessage ) diff --git a/x/cwregistry/types/tx.pb.go b/x/cwregistry/types/tx.pb.go index 47f77780..a1fa6ade 100644 --- a/x/cwregistry/types/tx.pb.go +++ b/x/cwregistry/types/tx.pb.go @@ -32,92 +32,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgRegisterContract registers a contract with the contract registry. -type MsgRegisterContract struct { - // sender is the bech32 address of the sender. - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // contract_address is the bech32 address of the contract. - ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - // source_metadata is the metadata of the contract source. - SourceMetadata *SourceMetadata `protobuf:"bytes,3,opt,name=source_metadata,json=sourceMetadata,proto3" json:"source_metadata,omitempty"` - // source_builder is the builder image of the contract source. - SourceBuilder *SourceBuilder `protobuf:"bytes,4,opt,name=source_builder,json=sourceBuilder,proto3" json:"source_builder,omitempty"` - // schema is the json schema of the contract. - Schema string `protobuf:"bytes,5,opt,name=schema,proto3" json:"schema,omitempty"` - // contacts is the list of dev contacts for the contract. - Contacts []string `protobuf:"bytes,6,rep,name=contacts,proto3" json:"contacts,omitempty"` -} - -func (m *MsgRegisterContract) Reset() { *m = MsgRegisterContract{} } -func (m *MsgRegisterContract) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterContract) ProtoMessage() {} -func (*MsgRegisterContract) Descriptor() ([]byte, []int) { - return fileDescriptor_553159f12499e254, []int{0} -} -func (m *MsgRegisterContract) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterContract.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 *MsgRegisterContract) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterContract.Merge(m, src) -} -func (m *MsgRegisterContract) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterContract) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterContract.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterContract proto.InternalMessageInfo - -// MsgRegisterContractResponse defines the Msg/RegisterContract response type. -type MsgRegisterContractResponse struct { -} - -func (m *MsgRegisterContractResponse) Reset() { *m = MsgRegisterContractResponse{} } -func (m *MsgRegisterContractResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterContractResponse) ProtoMessage() {} -func (*MsgRegisterContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_553159f12499e254, []int{1} -} -func (m *MsgRegisterContractResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterContractResponse.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 *MsgRegisterContractResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterContractResponse.Merge(m, src) -} -func (m *MsgRegisterContractResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterContractResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterContractResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterContractResponse proto.InternalMessageInfo - // MsgRegisterCode registers a contract code with the contract registry. type MsgRegisterCode struct { // sender is the bech32 address of the sender. @@ -138,7 +52,7 @@ func (m *MsgRegisterCode) Reset() { *m = MsgRegisterCode{} } func (m *MsgRegisterCode) String() string { return proto.CompactTextString(m) } func (*MsgRegisterCode) ProtoMessage() {} func (*MsgRegisterCode) Descriptor() ([]byte, []int) { - return fileDescriptor_553159f12499e254, []int{2} + return fileDescriptor_553159f12499e254, []int{0} } func (m *MsgRegisterCode) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -174,7 +88,7 @@ func (m *MsgRegisterCodeResponse) Reset() { *m = MsgRegisterCodeResponse func (m *MsgRegisterCodeResponse) String() string { return proto.CompactTextString(m) } func (*MsgRegisterCodeResponse) ProtoMessage() {} func (*MsgRegisterCodeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_553159f12499e254, []int{3} + return fileDescriptor_553159f12499e254, []int{1} } func (m *MsgRegisterCodeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -204,8 +118,6 @@ func (m *MsgRegisterCodeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterCodeResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgRegisterContract)(nil), "archway.cwregistry.v1.MsgRegisterContract") - proto.RegisterType((*MsgRegisterContractResponse)(nil), "archway.cwregistry.v1.MsgRegisterContractResponse") proto.RegisterType((*MsgRegisterCode)(nil), "archway.cwregistry.v1.MsgRegisterCode") proto.RegisterType((*MsgRegisterCodeResponse)(nil), "archway.cwregistry.v1.MsgRegisterCodeResponse") } @@ -213,40 +125,36 @@ func init() { func init() { proto.RegisterFile("archway/cwregistry/v1/tx.proto", fileDescriptor_553159f12499e254) } var fileDescriptor_553159f12499e254 = []byte{ - // 520 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x54, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xb6, 0x9b, 0xd6, 0xd0, 0xe3, 0x47, 0x8a, 0x5b, 0x88, 0x6b, 0xc0, 0x8d, 0x22, 0xa8, 0xa2, - 0x48, 0xf5, 0xd1, 0x20, 0x16, 0x36, 0xd2, 0x09, 0xa1, 0x80, 0xe4, 0x6e, 0x2c, 0xd6, 0xe5, 0x7c, - 0xba, 0x58, 0xd4, 0xbe, 0xe8, 0xde, 0xa5, 0x69, 0x36, 0xc4, 0xc4, 0xc8, 0x9f, 0xd0, 0x3f, 0xa1, - 0x03, 0x7f, 0x01, 0x13, 0x63, 0xc5, 0xc4, 0x88, 0x92, 0xa1, 0x0c, 0x4c, 0xfc, 0x05, 0xc8, 0xf6, - 0xa5, 0x4d, 0x20, 0x40, 0xc4, 0xca, 0x62, 0xf9, 0x7b, 0xdf, 0xf7, 0x9e, 0xdf, 0x7d, 0x9f, 0x75, - 0xc8, 0x23, 0x92, 0x76, 0x07, 0x64, 0x88, 0xe9, 0x40, 0x32, 0x1e, 0x83, 0x92, 0x43, 0x7c, 0xb8, - 0x8b, 0xd5, 0x91, 0xdf, 0x93, 0x42, 0x09, 0xfb, 0xa6, 0xe6, 0xfd, 0x0b, 0xde, 0x3f, 0xdc, 0x75, - 0x6f, 0x90, 0x24, 0x4e, 0x05, 0xce, 0x9f, 0x85, 0xd2, 0xad, 0x50, 0x01, 0x89, 0x00, 0x9c, 0x00, - 0xcf, 0x26, 0x24, 0xc0, 0x35, 0xb1, 0x59, 0x10, 0x61, 0x8e, 0x70, 0x01, 0x34, 0xb5, 0xc1, 0x05, - 0x17, 0x45, 0x3d, 0x7b, 0xd3, 0xd5, 0x3b, 0x5c, 0x08, 0x7e, 0xc0, 0x30, 0xe9, 0xc5, 0x98, 0xa4, - 0xa9, 0x50, 0x44, 0xc5, 0x22, 0x9d, 0xf4, 0x6c, 0xcf, 0xdf, 0x78, 0x6a, 0xbf, 0x5c, 0x57, 0xfb, - 0xbe, 0x84, 0xd6, 0xdb, 0xc0, 0x83, 0xbc, 0xca, 0xe4, 0x9e, 0x48, 0x95, 0x24, 0x54, 0xd9, 0x0f, - 0x90, 0x05, 0x2c, 0x8d, 0x98, 0x74, 0xcc, 0xaa, 0x59, 0x5f, 0x6d, 0x39, 0x9f, 0xde, 0xef, 0x6c, - 0xe8, 0xad, 0x9e, 0x44, 0x91, 0x64, 0x00, 0xfb, 0x4a, 0xc6, 0x29, 0x0f, 0xb4, 0xce, 0xde, 0x43, - 0x6b, 0x54, 0x77, 0x87, 0xa4, 0x50, 0x38, 0x4b, 0x7f, 0xe9, 0x2d, 0x4f, 0x3a, 0x74, 0xd9, 0x7e, - 0x8e, 0xca, 0x20, 0xfa, 0x92, 0xb2, 0x30, 0x61, 0x8a, 0x44, 0x44, 0x11, 0xa7, 0x54, 0x35, 0xeb, - 0x57, 0x9a, 0xf7, 0xfd, 0xb9, 0x16, 0xfb, 0xfb, 0xb9, 0xba, 0xad, 0xc5, 0xc1, 0x75, 0x98, 0xc1, - 0xf6, 0x33, 0xa4, 0x2b, 0x61, 0xa7, 0x1f, 0x1f, 0x64, 0xc7, 0x59, 0xce, 0xc7, 0xdd, 0xfb, 0xe3, - 0xb8, 0x56, 0xa1, 0x0d, 0xae, 0xc1, 0x34, 0xb4, 0x6f, 0x21, 0x0b, 0x68, 0x97, 0x25, 0xc4, 0x59, - 0xc9, 0xce, 0x15, 0x68, 0x64, 0xbb, 0xe8, 0x72, 0x76, 0x0e, 0x42, 0x15, 0x38, 0x56, 0xb5, 0x54, - 0x5f, 0x0d, 0xce, 0xf1, 0xe3, 0xf5, 0xb7, 0xc7, 0x5b, 0xc6, 0xd7, 0xe3, 0x2d, 0xe3, 0xcd, 0xd9, - 0x49, 0x43, 0x5b, 0x55, 0xbb, 0x8b, 0x6e, 0xcf, 0xf1, 0x3c, 0x60, 0xd0, 0x13, 0x29, 0xb0, 0xda, - 0x87, 0x25, 0x54, 0x9e, 0xe1, 0x23, 0xf6, 0x0f, 0x79, 0x54, 0xd0, 0x25, 0x2a, 0x22, 0x16, 0xc6, - 0x51, 0x1e, 0xc3, 0x72, 0x60, 0x65, 0xf0, 0x69, 0xf4, 0x9f, 0x78, 0xbc, 0x89, 0x2a, 0x3f, 0x79, - 0x38, 0xf1, 0xb7, 0xf9, 0xcd, 0x44, 0xa5, 0x36, 0x70, 0x5b, 0xa1, 0xb5, 0x5f, 0xfe, 0xfb, 0xc6, - 0x6f, 0x96, 0x9e, 0x93, 0x97, 0xdb, 0x5c, 0x5c, 0x7b, 0x9e, 0xad, 0x61, 0x77, 0xd1, 0xd5, 0x99, - 0x64, 0xb7, 0x17, 0x99, 0x12, 0x31, 0xd7, 0x5f, 0x4c, 0x77, 0xf1, 0x25, 0x77, 0xe5, 0xf5, 0xd9, - 0x49, 0xc3, 0x6c, 0xbd, 0xf8, 0x38, 0xf2, 0xcc, 0xd3, 0x91, 0x67, 0x7e, 0x19, 0x79, 0xe6, 0xbb, - 0xb1, 0x67, 0x9c, 0x8e, 0x3d, 0xe3, 0xf3, 0xd8, 0x33, 0x5e, 0x3e, 0xe2, 0xb1, 0xea, 0xf6, 0x3b, - 0x3e, 0x15, 0x09, 0xd6, 0xc3, 0x77, 0x52, 0xa6, 0x06, 0x42, 0xbe, 0x9a, 0x60, 0x7c, 0x34, 0x7d, - 0x83, 0xa8, 0x61, 0x8f, 0x41, 0xc7, 0xca, 0xaf, 0x8e, 0x87, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, - 0xa1, 0xe7, 0x1c, 0x12, 0x16, 0x05, 0x00, 0x00, + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0xed, 0xa6, 0x35, 0xf4, 0xf8, 0x53, 0x61, 0x0a, 0x71, 0x2d, 0xe4, 0x46, 0x11, 0x54, + 0x51, 0xa5, 0xfa, 0x68, 0x11, 0x0b, 0x1b, 0x61, 0x42, 0x28, 0x20, 0xb9, 0x1b, 0x4b, 0x74, 0x39, + 0x9f, 0x2e, 0x16, 0xf5, 0xbd, 0xd6, 0xbd, 0x97, 0xa4, 0xd9, 0x10, 0x13, 0x23, 0x1f, 0xa1, 0x1f, + 0xa1, 0x03, 0x9f, 0x80, 0x89, 0xb1, 0x62, 0x62, 0x44, 0xc9, 0x50, 0x3e, 0x06, 0xb2, 0x7d, 0x81, + 0xb4, 0x2a, 0x88, 0xc5, 0xf2, 0xef, 0x7d, 0x1e, 0x3f, 0x7e, 0xee, 0xd5, 0x91, 0x88, 0x69, 0x3e, + 0x9c, 0xb0, 0x29, 0xe5, 0x13, 0x2d, 0x64, 0x86, 0x46, 0x4f, 0xe9, 0x78, 0x9f, 0x9a, 0xe3, 0xb8, + 0xd0, 0x60, 0xc0, 0xbf, 0x67, 0xf5, 0xf8, 0x8f, 0x1e, 0x8f, 0xf7, 0xc3, 0x3b, 0x2c, 0xcf, 0x14, + 0xd0, 0xea, 0x59, 0x3b, 0xc3, 0x26, 0x07, 0xcc, 0x01, 0x69, 0x8e, 0xb2, 0x4c, 0xc8, 0x51, 0x5a, + 0x61, 0xab, 0x16, 0xfa, 0x15, 0xd1, 0x1a, 0xac, 0xb4, 0x29, 0x41, 0x42, 0x3d, 0x2f, 0xdf, 0xec, + 0xf4, 0x81, 0x04, 0x90, 0x47, 0x82, 0xb2, 0x22, 0xa3, 0x4c, 0x29, 0x30, 0xcc, 0x64, 0xa0, 0x16, + 0xdf, 0xec, 0x5c, 0xdd, 0x78, 0xa9, 0x5f, 0xe5, 0x6b, 0x7f, 0x59, 0x21, 0x1b, 0x3d, 0x94, 0x49, + 0x35, 0x15, 0xfa, 0x05, 0xa4, 0xc2, 0x7f, 0x4c, 0x3c, 0x14, 0x2a, 0x15, 0x3a, 0x70, 0x5b, 0x6e, + 0x67, 0xbd, 0x1b, 0x7c, 0xfb, 0xbc, 0xb7, 0x69, 0x1b, 0x3d, 0x4f, 0x53, 0x2d, 0x10, 0x0f, 0x8d, + 0xce, 0x94, 0x4c, 0xac, 0xcf, 0x6f, 0x92, 0x6b, 0x1c, 0x52, 0xd1, 0xcf, 0xd2, 0x60, 0xa5, 0xe5, + 0x76, 0x56, 0x13, 0xaf, 0xc4, 0x97, 0xa9, 0xff, 0x9a, 0x6c, 0x20, 0x8c, 0x34, 0x17, 0xfd, 0x5c, + 0x18, 0x96, 0x32, 0xc3, 0x82, 0x46, 0xcb, 0xed, 0xdc, 0x38, 0x78, 0x14, 0x5f, 0xb9, 0xb2, 0xf8, + 0xb0, 0x72, 0xf7, 0xac, 0x39, 0xb9, 0x8d, 0x17, 0xd8, 0x7f, 0x45, 0xec, 0xa4, 0x3f, 0x18, 0x65, + 0x47, 0x65, 0xc5, 0xd5, 0x2a, 0xee, 0xe1, 0x3f, 0xe3, 0xba, 0xb5, 0x37, 0xb9, 0x85, 0xcb, 0xe8, + 0xdf, 0x27, 0x1e, 0xf2, 0xa1, 0xc8, 0x59, 0xb0, 0x56, 0x9e, 0x33, 0xb1, 0xe4, 0x87, 0xe4, 0x3a, + 0x07, 0x65, 0x18, 0x37, 0x18, 0x78, 0xad, 0x46, 0x67, 0x3d, 0xf9, 0xcd, 0xcf, 0xee, 0x7e, 0x3c, + 0xd9, 0x76, 0x7e, 0x9e, 0x6c, 0x3b, 0x1f, 0xce, 0x4f, 0x77, 0xed, 0xf1, 0xdb, 0x5b, 0xa4, 0x79, + 0x69, 0x87, 0x89, 0xc0, 0x02, 0x14, 0x8a, 0x83, 0x31, 0x69, 0xf4, 0x50, 0xfa, 0x43, 0x72, 0xf3, + 0xc2, 0x8a, 0x77, 0xfe, 0xd2, 0xf7, 0x52, 0x4c, 0x18, 0xff, 0x9f, 0x6f, 0xf1, 0xbb, 0xb6, 0x13, + 0xae, 0xbd, 0x3f, 0x3f, 0xdd, 0x75, 0xbb, 0x6f, 0xbe, 0xce, 0x22, 0xf7, 0x6c, 0x16, 0xb9, 0x3f, + 0x66, 0x91, 0xfb, 0x69, 0x1e, 0x39, 0x67, 0xf3, 0xc8, 0xf9, 0x3e, 0x8f, 0x9c, 0xb7, 0x4f, 0x65, + 0x66, 0x86, 0xa3, 0x41, 0xcc, 0x21, 0xa7, 0x36, 0x7c, 0x4f, 0x09, 0x33, 0x01, 0xfd, 0x6e, 0xc1, + 0xf4, 0x78, 0xf9, 0xda, 0x98, 0x69, 0x21, 0x70, 0xe0, 0x55, 0xf7, 0xe5, 0xc9, 0xaf, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xbb, 0xee, 0x56, 0x30, 0x0b, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -261,8 +169,6 @@ 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 { - // RegisterContract registers a contract with the contract registry. - RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) // RegisterCode registers a contract code with the contract registry. RegisterCode(ctx context.Context, in *MsgRegisterCode, opts ...grpc.CallOption) (*MsgRegisterCodeResponse, error) } @@ -275,15 +181,6 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) { - out := new(MsgRegisterContractResponse) - err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Msg/RegisterContract", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) RegisterCode(ctx context.Context, in *MsgRegisterCode, opts ...grpc.CallOption) (*MsgRegisterCodeResponse, error) { out := new(MsgRegisterCodeResponse) err := c.cc.Invoke(ctx, "/archway.cwregistry.v1.Msg/RegisterCode", in, out, opts...) @@ -295,8 +192,6 @@ func (c *msgClient) RegisterCode(ctx context.Context, in *MsgRegisterCode, opts // MsgServer is the server API for Msg service. type MsgServer interface { - // RegisterContract registers a contract with the contract registry. - RegisterContract(context.Context, *MsgRegisterContract) (*MsgRegisterContractResponse, error) // RegisterCode registers a contract code with the contract registry. RegisterCode(context.Context, *MsgRegisterCode) (*MsgRegisterCodeResponse, error) } @@ -305,9 +200,6 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) RegisterContract(ctx context.Context, req *MsgRegisterContract) (*MsgRegisterContractResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterContract not implemented") -} func (*UnimplementedMsgServer) RegisterCode(ctx context.Context, req *MsgRegisterCode) (*MsgRegisterCodeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterCode not implemented") } @@ -316,24 +208,6 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_RegisterContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRegisterContract) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterContract(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/archway.cwregistry.v1.Msg/RegisterContract", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterContract(ctx, req.(*MsgRegisterContract)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_RegisterCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgRegisterCode) if err := dec(in); err != nil { @@ -356,10 +230,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "archway.cwregistry.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "RegisterContract", - Handler: _Msg_RegisterContract_Handler, - }, { MethodName: "RegisterCode", Handler: _Msg_RegisterCode_Handler, @@ -369,106 +239,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "archway/cwregistry/v1/tx.proto", } -func (m *MsgRegisterContract) 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 *MsgRegisterContract) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Contacts) > 0 { - for iNdEx := len(m.Contacts) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Contacts[iNdEx]) - copy(dAtA[i:], m.Contacts[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Contacts[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.Schema) > 0 { - i -= len(m.Schema) - copy(dAtA[i:], m.Schema) - i = encodeVarintTx(dAtA, i, uint64(len(m.Schema))) - i-- - dAtA[i] = 0x2a - } - if m.SourceBuilder != nil { - { - size, err := m.SourceBuilder.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.SourceMetadata != nil { - { - size, err := m.SourceMetadata.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.ContractAddress) > 0 { - i -= len(m.ContractAddress) - copy(dAtA[i:], m.ContractAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRegisterContractResponse) 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 *MsgRegisterContractResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func (m *MsgRegisterCode) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -578,50 +348,6 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgRegisterContract) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ContractAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.SourceMetadata != nil { - l = m.SourceMetadata.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.SourceBuilder != nil { - l = m.SourceBuilder.Size() - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Schema) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Contacts) > 0 { - for _, s := range m.Contacts { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgRegisterContractResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgRegisterCode) Size() (n int) { if m == nil { return 0 @@ -671,306 +397,6 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgRegisterContract) 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: MsgRegisterContract: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterContract: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceMetadata", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SourceMetadata == nil { - m.SourceMetadata = &SourceMetadata{} - } - if err := m.SourceMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceBuilder", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SourceBuilder == nil { - m.SourceBuilder = &SourceBuilder{} - } - if err := m.SourceBuilder.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", 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.Schema = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Contacts", 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.Contacts = append(m.Contacts, 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 *MsgRegisterContractResponse) 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: MsgRegisterContractResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterContractResponse: 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 *MsgRegisterCode) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 14cba8be8799c71e5c5bb48636952c116eb72ed2 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:05:31 +0100 Subject: [PATCH 16/19] =?UTF-8?q?linting=20=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- x/cwregistry/client/cli/flags.go | 92 ----------------------- x/cwregistry/genesis_test.go | 3 +- x/cwregistry/keeper/code_metadata.go | 3 +- x/cwregistry/keeper/code_metadata_test.go | 3 +- x/cwregistry/keeper/grpc_query.go | 3 +- x/cwregistry/keeper/keeper.go | 1 + x/cwregistry/keeper/msg_server.go | 3 +- x/cwregistry/keeper/msg_server_test.go | 3 +- 8 files changed, 13 insertions(+), 98 deletions(-) delete mode 100644 x/cwregistry/client/cli/flags.go diff --git a/x/cwregistry/client/cli/flags.go b/x/cwregistry/client/cli/flags.go deleted file mode 100644 index 4d59b555..00000000 --- a/x/cwregistry/client/cli/flags.go +++ /dev/null @@ -1,92 +0,0 @@ -package cli - -import ( - "github.com/archway-network/archway/x/cwregistry/types" - "github.com/spf13/cobra" -) - -const ( - // Source Metadata - flagSourceRepository = "source-repository" - flagSourceTag = "source-tag" - flagSourceLicense = "source-license" - // Source Builder - flagSourceImage = "source-image" - flagSourceImageTag = "source-image-tag" - flagSourceContractName = "source-contract-name" - - flagContacts = "contacts" - flagSchemaPath = "schema-path" -) - -func addFlags(cmd *cobra.Command) { - addContactsFlag(cmd) - addSchemaPathFlag(cmd) - addSourceRepositoryFlag(cmd) - addSourceTagFlag(cmd) - addSourceLicenseFlag(cmd) - addSourceImageFlag(cmd) - addSourceImageTagFlag(cmd) - addSourceContractNameFlag(cmd) -} - -func addSourceRepositoryFlag(cmd *cobra.Command) { - cmd.Flags().String(flagSourceRepository, "", "The link to the code repository. e.g https://github.com/archway-network/archway") -} - -func addSourceTagFlag(cmd *cobra.Command) { - cmd.Flags().String(flagSourceTag, "", "The tag of the code repository. e.g v0.1.0") -} - -func addSourceLicenseFlag(cmd *cobra.Command) { - cmd.Flags().String(flagSourceLicense, "", "The license of the code repository. e.g Apache-2.0") -} - -func addSourceImageFlag(cmd *cobra.Command) { - cmd.Flags().String(flagSourceImage, "", "The docker image of the contract. e.g cosmwasm/rust-optimizer") -} - -func addSourceImageTagFlag(cmd *cobra.Command) { - cmd.Flags().String(flagSourceImageTag, "", "The tag of the docker image. e.g 0.12.6") -} - -func addSourceContractNameFlag(cmd *cobra.Command) { - cmd.Flags().String(flagSourceContractName, "", "The name of the contract in the docker image. e.g counter.wasm") -} - -func addContactsFlag(cmd *cobra.Command) { - cmd.Flags().StringSlice(flagContacts, []string{}, "The list of contacts for the contract. e.g admin@dapp.com,security@dapp.com") -} - -func addSchemaPathFlag(cmd *cobra.Command) { - cmd.Flags().String(flagSchemaPath, "", "The path to the schema file. e.g ./schema.json") -} - -func parseSourceMetadata(cmd *cobra.Command) types.SourceMetadata { - repository, _ := cmd.Flags().GetString(flagSourceRepository) - tag, _ := cmd.Flags().GetString(flagSourceTag) - license, _ := cmd.Flags().GetString(flagSourceLicense) - sourceMetadata := types.SourceMetadata{ - Repository: repository, - Tag: tag, - License: license, - } - return sourceMetadata -} - -func parseSourceBuilder(cmd *cobra.Command) types.SourceBuilder { - image, _ := cmd.Flags().GetString(flagSourceImage) - imageTag, _ := cmd.Flags().GetString(flagSourceImageTag) - contractName, _ := cmd.Flags().GetString(flagSourceContractName) - sourceBuilder := types.SourceBuilder{ - Image: image, - Tag: imageTag, - ContractName: contractName, - } - return sourceBuilder -} - -func parseSchema(cmd *cobra.Command) string { - schemaPath, _ := cmd.Flags().GetString(flagSchemaPath) - return schemaPath -} diff --git a/x/cwregistry/genesis_test.go b/x/cwregistry/genesis_test.go index 0cc256a7..df90bf44 100644 --- a/x/cwregistry/genesis_test.go +++ b/x/cwregistry/genesis_test.go @@ -3,10 +3,11 @@ package cwregistry_test import ( "testing" + "github.com/stretchr/testify/require" + "github.com/archway-network/archway/pkg/testutils" "github.com/archway-network/archway/x/cwregistry" "github.com/archway-network/archway/x/cwregistry/types" - "github.com/stretchr/testify/require" ) func TestExportGenesis(t *testing.T) { diff --git a/x/cwregistry/keeper/code_metadata.go b/x/cwregistry/keeper/code_metadata.go index cee8afb3..54ee0d2d 100644 --- a/x/cwregistry/keeper/code_metadata.go +++ b/x/cwregistry/keeper/code_metadata.go @@ -1,8 +1,9 @@ package keeper import ( - "github.com/archway-network/archway/x/cwregistry/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/archway-network/archway/x/cwregistry/types" ) // GetAllCodeMetadata returns all code metadata stored diff --git a/x/cwregistry/keeper/code_metadata_test.go b/x/cwregistry/keeper/code_metadata_test.go index 865ce83a..c00a8d7d 100644 --- a/x/cwregistry/keeper/code_metadata_test.go +++ b/x/cwregistry/keeper/code_metadata_test.go @@ -3,9 +3,10 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" + "github.com/archway-network/archway/pkg/testutils" "github.com/archway-network/archway/x/cwregistry/types" - "github.com/stretchr/testify/require" ) func TestSetCodeMetadata(t *testing.T) { diff --git a/x/cwregistry/keeper/grpc_query.go b/x/cwregistry/keeper/grpc_query.go index 4cbb37a7..d4318eed 100644 --- a/x/cwregistry/keeper/grpc_query.go +++ b/x/cwregistry/keeper/grpc_query.go @@ -3,10 +3,11 @@ package keeper import ( "context" - "github.com/archway-network/archway/x/cwregistry/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/archway-network/archway/x/cwregistry/types" ) var _ types.QueryServer = &QueryServer{} diff --git a/x/cwregistry/keeper/keeper.go b/x/cwregistry/keeper/keeper.go index d91def17..97a77192 100644 --- a/x/cwregistry/keeper/keeper.go +++ b/x/cwregistry/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "cosmossdk.io/collections" "cosmossdk.io/log" + "github.com/archway-network/archway/internal/collcompat" "github.com/archway-network/archway/x/cwregistry/types" diff --git a/x/cwregistry/keeper/msg_server.go b/x/cwregistry/keeper/msg_server.go index 9b7d67d7..1716c241 100644 --- a/x/cwregistry/keeper/msg_server.go +++ b/x/cwregistry/keeper/msg_server.go @@ -3,10 +3,11 @@ package keeper import ( "context" - "github.com/archway-network/archway/x/cwregistry/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/archway-network/archway/x/cwregistry/types" ) type msgServer struct { diff --git a/x/cwregistry/keeper/msg_server_test.go b/x/cwregistry/keeper/msg_server_test.go index 408e630d..603086e7 100644 --- a/x/cwregistry/keeper/msg_server_test.go +++ b/x/cwregistry/keeper/msg_server_test.go @@ -3,10 +3,11 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" + "github.com/archway-network/archway/pkg/testutils" "github.com/archway-network/archway/x/cwregistry/keeper" "github.com/archway-network/archway/x/cwregistry/types" - "github.com/stretchr/testify/require" ) func TestRegisterCode(t *testing.T) { From fd9860ce7a4c0a894bc7dd4f1d8cf6e82239ffdf Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:00:13 +0100 Subject: [PATCH 17/19] adding spec --- x/cwregistry/spec/01_state.md | 13 +++++++++++ x/cwregistry/spec/02_messages.md | 19 ++++++++++++++++ x/cwregistry/spec/README.md | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 x/cwregistry/spec/01_state.md create mode 100644 x/cwregistry/spec/02_messages.md create mode 100644 x/cwregistry/spec/README.md diff --git a/x/cwregistry/spec/01_state.md b/x/cwregistry/spec/01_state.md new file mode 100644 index 00000000..3fc8abb6 --- /dev/null +++ b/x/cwregistry/spec/01_state.md @@ -0,0 +1,13 @@ +# State + +Section describes all stored by the module objects and their storage keys. + +Refer to the [cwregistry.proto](../../../proto/archway/cwregistry/v1/cwregistry.proto) for objects fields description. + + +## CodeMetadata + +[CodeMetadata](../../../proto/archway/cwregistry/v1/cwregistry.proto#L7) object is used to store the metadata regarding a contract binary which has been uploaded. + +Storage keys: +* CodeMetadata: `CodeMetadataKeyPrefix | CodeID -> ProtocolBuffer(CodeMetadata)` \ No newline at end of file diff --git a/x/cwregistry/spec/02_messages.md b/x/cwregistry/spec/02_messages.md new file mode 100644 index 00000000..e783173c --- /dev/null +++ b/x/cwregistry/spec/02_messages.md @@ -0,0 +1,19 @@ +# Messages + +Section describes the processing of the module messages + + +## MsgRegisterCode + +Contract code metadata can be registered by the [MsgRegisterCode](../../../proto/archway/cwregistry/v1/tx.proto#L21) message. + +On success: +* The provided code metadata is stored or updated + +This message is expected to fail if: +* Sender address is invalid +* Given Code ID is nto valid +* The sender is not the address who uploaded the contract binary +* Any of the fields are longer than 255 characters. +* The source code repository is now a valid URL + \ No newline at end of file diff --git a/x/cwregistry/spec/README.md b/x/cwregistry/spec/README.md new file mode 100644 index 00000000..5f207e69 --- /dev/null +++ b/x/cwregistry/spec/README.md @@ -0,0 +1,37 @@ +# CWRegistry + +This module can be used by contract deployers to provide metadata about their contracts. The module stores contract metadata such as source code, schema, developer contact info. + +## Concepts + +Cosmwasm does not provide any way for a Cosmwasm smart contract developer to provide any metadata regarding their contracts. This has been explored in `x/wasm` before [^1], where during contract binary upload, a developer could provide the source code url. This feature was deprecated by Confio due to +1. Field was often unfilled or had erroneous values +2. No tooling to verify the contracts match the given information +Due to the nature of wasm, it is also not possible to take a look at the source code of a deployed contract. + +Once a contract is deployed, it is not easy for external parties to get the contract schema and endpoints[^2], especially so in the case when the contract is closed source or source URL not available. Having this information available on chain would enable the following +1. Make third party tooling of contracts easier to develop, such as code gen for UI +2. General purpose contract interaction tools +3. Indexers and block exploreres could use this information to better display the contract state. +4. CW based multisigs and DAOs can perform contract interactions knowing what the contarct expects. + +Currently, there is no way for a user/another developer to know who deployed a contract. In case they would like to contact the developer, there isnt any way to do it beyond the deployer address. Adding a field for security contact would help others report issues. + +Most of the Cosmwasm chains run as permissioned Cosmwasm, which allows for the contract source to be connected to the binary in the governance proposal. However, in the permissionless approach of Archway, there is no builtin way to establish this connection. + +## Contents + +1. [State](./01_state.md) +2. [Messages](./02_messages.md) + + +## References + +[RFC - x/cw-registry module](https://github.com/orgs/archway-network/discussions/16) + + + + +[^1]: [Question: Why was StoreCode.url removed from the tx msg?](https://github.com/CosmWasm/wasmd/issues/742) + +[^2]: [Upload JSON schema alongside code contract](https://github.com/CosmWasm/wasmd/issues/241) \ No newline at end of file From 2cf8ad83cef414e24ddfe59623820650d90e265b Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:16:37 +0100 Subject: [PATCH 18/19] fixing upgrade handler --- app/app_upgrades.go | 3 +++ app/upgrades/8_0_0/upgrades.go | 5 +---- app/upgrades/latest/upgrades.go | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 app/upgrades/latest/upgrades.go diff --git a/app/app_upgrades.go b/app/app_upgrades.go index 43b6c744..5aa7a2a4 100644 --- a/app/app_upgrades.go +++ b/app/app_upgrades.go @@ -15,6 +15,7 @@ import ( upgrade6_0_0 "github.com/archway-network/archway/app/upgrades/6_0_0" upgrade7_0_0 "github.com/archway-network/archway/app/upgrades/7_0_0" upgrade8_0_0 "github.com/archway-network/archway/app/upgrades/8_0_0" + upgradelatest "github.com/archway-network/archway/app/upgrades/latest" ) // UPGRADES @@ -29,6 +30,8 @@ var Upgrades = []upgrades.Upgrade{ upgrade6_0_0.Upgrade, // v6.0.0 upgrade7_0_0.Upgrade, // v7.0.0 upgrade8_0_0.Upgrade, // v8.0.0 + + upgradelatest.Upgrade, // latest } func (app *ArchwayApp) RegisterUpgradeHandlers() { diff --git a/app/upgrades/8_0_0/upgrades.go b/app/upgrades/8_0_0/upgrades.go index a2592a96..7f1d8138 100644 --- a/app/upgrades/8_0_0/upgrades.go +++ b/app/upgrades/8_0_0/upgrades.go @@ -10,7 +10,6 @@ import ( "github.com/archway-network/archway/app/keepers" "github.com/archway-network/archway/app/upgrades" - cwregistrytypes "github.com/archway-network/archway/x/cwregistry/types" ) const Name = "v8.0.0" @@ -37,8 +36,6 @@ var Upgrade = upgrades.Upgrade{ } }, StoreUpgrades: storetypes.StoreUpgrades{ - Added: []string{ - cwregistrytypes.ModuleName, - }, + Added: []string{}, }, } diff --git a/app/upgrades/latest/upgrades.go b/app/upgrades/latest/upgrades.go new file mode 100644 index 00000000..e8d200fb --- /dev/null +++ b/app/upgrades/latest/upgrades.go @@ -0,0 +1,37 @@ +package upgradelatest + +import ( + "context" + + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/archway-network/archway/app/keepers" + "github.com/archway-network/archway/app/upgrades" + cwregistrytypes "github.com/archway-network/archway/x/cwregistry/types" +) + +const Name = "latest" +const NameAsciiArt = "" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: Name, + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, keepers keepers.ArchwayKeepers) upgradetypes.UpgradeHandler { + return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + migrations, err := mm.RunMigrations(ctx, cfg, fromVM) + if err != nil { + return nil, err + } + + sdk.UnwrapSDKContext(ctx).Logger().Info(upgrades.ArchwayLogo + NameAsciiArt) + return migrations, nil + } + }, + StoreUpgrades: storetypes.StoreUpgrades{ + Added: []string{ + cwregistrytypes.ModuleName, + }, + }, +} From a5e7c6dd369d8da985baef8a77cc0a847b3c2d05 Mon Sep 17 00:00:00 2001 From: Spoorthi <9302666+spoo-bar@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:18:04 +0100 Subject: [PATCH 19/19] updating changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3f47a7..e5671068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,11 @@ Contains bug fixes. Contains all the PRs that improved the code without changing the behaviors. --> +## [Unreleased] + +### Added +- [#578](https://github.com/archway-network/archway/pull/578) - Adding x/cwregistry module + ## [v8.0.0](https://github.com/archway-network/archway/releases/tag/v8.0.0)