diff --git a/.github/workflows/interchaintest-e2e.yml b/.github/workflows/interchaintest-e2e.yml index faf90c18..0d80913e 100644 --- a/.github/workflows/interchaintest-e2e.yml +++ b/.github/workflows/interchaintest-e2e.yml @@ -2,12 +2,20 @@ name: ictest E2E on: pull_request: + branches: + - main + - master + branches-ignore: + - "mvp/**" + push: tags: - "**" branches: - - "main" - - "master" + - main + - master + branches-ignore: + - "mvp/**" permissions: contents: read diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 219868f9..feb5c59d 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -26,6 +26,8 @@ import ( "github.com/bitsongofficial/go-bitsong/x/fantoken" fantokenkeeper "github.com/bitsongofficial/go-bitsong/x/fantoken/keeper" fantokentypes "github.com/bitsongofficial/go-bitsong/x/fantoken/types" + nftkeeper "github.com/bitsongofficial/go-bitsong/x/nft/keeper" + nfttypes "github.com/bitsongofficial/go-bitsong/x/nft/types" "github.com/bitsongofficial/go-bitsong/x/smart-account/authenticator" smartaccountkeeper "github.com/bitsongofficial/go-bitsong/x/smart-account/keeper" smartaccounttypes "github.com/bitsongofficial/go-bitsong/x/smart-account/types" @@ -149,6 +151,7 @@ type AppKeepers struct { ICQKeeper *icqkeeper.Keeper EvidenceKeeper evidencekeeper.Keeper FanTokenKeeper fantokenkeeper.Keeper + NftKeeper nftkeeper.Keeper WasmKeeper wasmkeeper.Keeper CadenceKeeper cadencekeeper.Keeper IBCFeeKeeper ibcfeekeeper.Keeper @@ -406,6 +409,14 @@ func NewAppKeepers( BlockedAddrs(), ) + appKeepers.NftKeeper = nftkeeper.NewKeeper( + appCodec, + keys[nfttypes.StoreKey], + runtime.NewKVStoreService(appKeepers.keys[nfttypes.StoreKey]), + appKeepers.AccountKeeper, + bApp.Logger(), + ) + // Stargate Queries acceptedStargateQueries := wasmkeeper.AcceptedQueries{ // ibc diff --git a/app/keepers/keys.go b/app/keepers/keys.go index 38128e93..d5091ce5 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -2,6 +2,7 @@ package keepers import ( storetypes "cosmossdk.io/store/types" + nfttypes "github.com/bitsongofficial/go-bitsong/x/nft/types" "cosmossdk.io/x/feegrant" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" @@ -57,6 +58,7 @@ func (appKeepers *AppKeepers) GenerateKeys() { wasmtypes.StoreKey, icqtypes.StoreKey, fantokentypes.StoreKey, + nfttypes.StoreKey, cadencetypes.StoreKey, smartaccounttypes.StoreKey, protocolpooltypes.StoreKey, diff --git a/proto/bitsong/drop/v1beta1/drop.proto b/proto/bitsong/drop/v1beta1/drop.proto new file mode 100644 index 00000000..81031cab --- /dev/null +++ b/proto/bitsong/drop/v1beta1/drop.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package bitsong.drop.v1beta1; + +option go_package = "github.com/bitsongofficial/go-bitsong/x/drop/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "amino/amino.proto"; + +message Template { + option (gogoproto.goproto_getters) = false; + + string name = 1; + string uri = 2; +} + +message Rule { + option (gogoproto.goproto_getters) = false; + + uint64 id = 1; + + google.protobuf.Timestamp start_time = 2 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + google.protobuf.Timestamp end_time = 3 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +message Drop { + option (gogoproto.goproto_getters) = false; + + string collection = 1; + + uint64 max_available = 2; + + Template template = 3; + + // Template hidden_template + // bool is_hidden +} \ No newline at end of file diff --git a/proto/bitsong/nft/v1beta1/nft.proto b/proto/bitsong/nft/v1beta1/nft.proto new file mode 100644 index 00000000..fe4fcb34 --- /dev/null +++ b/proto/bitsong/nft/v1beta1/nft.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package bitsong.nft.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/bitsongofficial/go-bitsong/x/nft/types"; + +message Collection { + option (gogoproto.goproto_getters) = false; + + string denom = 1; + + string symbol = 2; + string name = 3; + string uri = 5; + + string creator = 6; + string minter = 7; // who can mint new nfts, if not set no one can mint + string authority = 8; // who can update name and uri, if not set no one can update, this is valid for the all nfts in this collection + + uint64 num_tokens = 9; +} + +message Nft { + option (gogoproto.goproto_getters) = false; + + string collection = 1; + string token_id = 2; + + string name = 3; + string uri = 5; + + string owner = 6; + // string authority = 7; // who can update name, description and uri, if not set no one can update + + // TODO: add max_editions + // uint64 max_editions = 8; // max number of printed editions, 0 means no limit + uint64 editions = 7; // number of printed editions + + // seller_fee_bps + // payment_address +} + +message Edition { + option (gogoproto.goproto_getters) = false; + + string collection = 1; + string token_id = 2; + + uint64 seq = 3; // seq is the edition number + + string owner = 4; +} \ No newline at end of file diff --git a/proto/bitsong/nft/v1beta1/query.proto b/proto/bitsong/nft/v1beta1/query.proto new file mode 100644 index 00000000..a0f770fa --- /dev/null +++ b/proto/bitsong/nft/v1beta1/query.proto @@ -0,0 +1,128 @@ +syntax = "proto3"; +package bitsong.nft.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/query/v1/query.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "bitsong/nft/v1beta1/nft.proto"; + +option go_package = "github.com/bitsongofficial/go-bitsong/x/nft/types"; + +service Query { + rpc Collection(QueryCollectionRequest) returns (QueryCollectionResponse) { + option (cosmos.query.v1.module_query_safe) = true; + option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}"; + } + + // TODO: rpc AllCollections(QueryAllCollectionsRequest) returns (QueryAllCollectionsResponse)..... + + rpc OwnerOf(QueryOwnerOfRequest) returns (QueryOwnerOfResponse) { + option (cosmos.query.v1.module_query_safe) = true; + option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}/{token_id}/owner"; + } + + rpc NftInfo(QueryNftInfoRequest) returns (QueryNftInfoResponse) { + option (cosmos.query.v1.module_query_safe) = true; + option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}/{token_id}"; + } + + rpc Nfts(QueryNftsRequest) returns (QueryNftsResponse) { + option (cosmos.query.v1.module_query_safe) = true; + option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}/nfts"; + } + + rpc AllNftsByOwner(QueryAllNftsByOwnerRequest) returns (QueryAllNftsByOwnerResponse) { + option (cosmos.query.v1.module_query_safe) = true; + option (google.api.http).get = "/bitsong/nft/v1beta1/nfts_by_owner/{owner}"; + } + + // Edition returns a specific edition of an nft + // OwnerOfEdition returns the owner of a specific edition + // NftEditions returns all editions of a specific nft + // AllNftEditionsByOwner returns all nft editions owned by the owner +} + +message QueryCollectionRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string collection = 1; +} + +message QueryCollectionResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + bitsong.nft.v1beta1.Collection collection = 1; +} + +message QueryOwnerOfRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string collection = 1; + string token_id = 2; +} + +message QueryOwnerOfResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string owner = 1; +} + +message QueryNftInfoRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string collection = 1; + string token_id = 2; +} + +message QueryNftInfoResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + bitsong.nft.v1beta1.Nft nft = 1; +} + +message QueryNftsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string collection = 1; + + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryNftsResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + repeated bitsong.nft.v1beta1.Nft nfts = 1 [ + (gogoproto.nullable) = false + ]; + + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryAllNftsByOwnerRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string owner = 1; + + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryAllNftsByOwnerResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + repeated bitsong.nft.v1beta1.Nft nfts = 1 [ + (gogoproto.nullable) = false + ]; + + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} \ No newline at end of file diff --git a/proto/bitsong/nft/v1beta1/tx.proto b/proto/bitsong/nft/v1beta1/tx.proto new file mode 100644 index 00000000..07b9c6d5 --- /dev/null +++ b/proto/bitsong/nft/v1beta1/tx.proto @@ -0,0 +1,95 @@ +syntax = "proto3";; +package bitsong.nft.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/bitsongofficial/go-bitsong/x/nft/types"; + +service Msg { + option (cosmos.msg.v1.service) = true; + + rpc CreateCollection(MsgCreateCollection) returns (MsgCreateCollectionResponse); + rpc MintNFT(MsgMintNFT) returns (MsgMintNFTResponse); + rpc SendNFT(MsgSendNFT) returns (MsgSendNFTResponse); + rpc PrintEdition(MsgPrintEdition) returns (MsgPrintEditionResponse); +} + +message MsgCreateCollection { + option (cosmos.msg.v1.signer) = "creator"; + option (amino.name) = "cosmos-sdk/nft/MsgCreateCollection"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string symbol = 1; + string name = 2; + string uri = 3; + + string creator = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string minter = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgCreateCollectionResponse { + string denom = 1; +} + +message MsgMintNFT { + option (cosmos.msg.v1.signer) = "minter"; + option (amino.name) = "cosmos-sdk/nft/MsgMintNFT"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string collection = 1; + string token_id = 2; + string name = 3; + string uri = 4; + + string minter = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string recipient = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgMintNFTResponse { + string collection = 1; + string token_id = 2; +} + +message MsgSendNFT { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "cosmos-sdk/nft/MsgSendNFT"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string collection = 1; + string token_id = 2; + + string sender = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string recipient = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgSendNFTResponse {} + +message MsgPrintEdition { + option (cosmos.msg.v1.signer) = "minter"; + option (amino.name) = "cosmos-sdk/nft/MsgPrintEdition"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string collection = 1; + string token_id = 2; + + string minter = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string recipient = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgPrintEditionResponse { + string collection = 1; + string token_id = 2; + uint64 seq = 3; +} \ No newline at end of file diff --git a/proto/buf.yaml b/proto/buf.yaml index 0d6465bd..cc5ff316 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -5,9 +5,12 @@ deps: - buf.build/cosmos/cosmos-proto - buf.build/cosmos/gogo-proto - buf.build/googleapis/googleapis + - buf.build/protocolbuffers/wellknowntypes breaking: use: - FILE + ignore: + - testpb lint: use: - STANDARD diff --git a/third_party/proto/amino/amino.proto b/third_party/proto/amino/amino.proto new file mode 100644 index 00000000..fb099b8e --- /dev/null +++ b/third_party/proto/amino/amino.proto @@ -0,0 +1,84 @@ +syntax = "proto3"; + +package amino; + +import "google/protobuf/descriptor.proto"; + +// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated. +// We need this right now because gogoproto codegen needs to import the extension. +option go_package = "github.com/cosmos/cosmos-sdk/types/tx/amino"; + +extend google.protobuf.MessageOptions { + // name is the string used when registering a concrete + // type into the Amino type registry, via the Amino codec's + // `RegisterConcrete()` method. This string MUST be at most 39 + // characters long, or else the message will be rejected by the + // Ledger hardware device. + string name = 11110001; + + // encoding describes the encoding format used by Amino for the given + // message. The field type is chosen to be a string for + // flexibility, but it should ideally be short and expected to be + // machine-readable, for example "base64" or "utf8_json". We + // highly recommend to use underscores for word separation instead of spaces. + // + // If left empty, then the Amino encoding is expected to be the same as the + // Protobuf one. + // + // This annotation should not be confused with the `encoding` + // one which operates on the field level. + string message_encoding = 11110002; +} + +extend google.protobuf.FieldOptions { + // encoding describes the encoding format used by Amino for + // the given field. The field type is chosen to be a string for + // flexibility, but it should ideally be short and expected to be + // machine-readable, for example "base64" or "utf8_json". We + // highly recommend to use underscores for word separation instead of spaces. + // + // If left empty, then the Amino encoding is expected to be the same as the + // Protobuf one. + // + // This annotation should not be confused with the + // `message_encoding` one which operates on the message level. + string encoding = 11110003; + + // field_name sets a different field name (i.e. key name) in + // the amino JSON object for the given field. + // + // Example: + // + // message Foo { + // string bar = 1 [(amino.field_name) = "baz"]; + // } + // + // Then the Amino encoding of Foo will be: + // `{"baz":"some value"}` + string field_name = 11110004; + + // dont_omitempty sets the field in the JSON object even if + // its value is empty, i.e. equal to the Golang zero value. To learn what + // the zero values are, see https://go.dev/ref/spec#The_zero_value. + // + // Fields default to `omitempty`, which is the default behavior when this + // annotation is unset. When set to true, then the field value in the + // JSON object will be set, i.e. not `undefined`. + // + // Example: + // + // message Foo { + // string bar = 1; + // string baz = 2 [(amino.dont_omitempty) = true]; + // } + // + // f := Foo{}; + // out := AminoJSONEncoder(&f); + // out == {"baz":""} + bool dont_omitempty = 11110005; + + // oneof_name sets the type name for the given field oneof field. This is used + // by the Amino JSON encoder to encode the type of the oneof field, and must be the same string in + // the RegisterConcrete() method usage used to register the concrete type. + string oneof_name = 11110006; +} \ No newline at end of file diff --git a/third_party/proto/cosmos/msg/v1/msg.proto b/third_party/proto/cosmos/msg/v1/msg.proto new file mode 100644 index 00000000..5f26d4c8 --- /dev/null +++ b/third_party/proto/cosmos/msg/v1/msg.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package cosmos.msg.v1; + +import "google/protobuf/descriptor.proto"; + +// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated. +// We need this right now because gogoproto codegen needs to import the extension. +option go_package = "github.com/cosmos/cosmos-sdk/types/msgservice"; + +extend google.protobuf.ServiceOptions { + // service indicates that the service is a Msg service and that requests + // must be transported via blockchain transactions rather than gRPC. + // Tooling can use this annotation to distinguish between Msg services and + // other types of services via reflection. + bool service = 11110000; +} + +extend google.protobuf.MessageOptions { + // signer must be used in cosmos messages in order + // to signal to external clients which fields in a + // given cosmos message must be filled with signer + // information (address). + // The field must be the protobuf name of the message + // field extended with this MessageOption. + // The field must either be of string kind, or of message + // kind in case the signer information is contained within + // a message inside the cosmos message. + repeated string signer = 11110000; +} \ No newline at end of file diff --git a/third_party/proto/cosmos/query/v1/query.proto b/third_party/proto/cosmos/query/v1/query.proto new file mode 100644 index 00000000..e42e73d7 --- /dev/null +++ b/third_party/proto/cosmos/query/v1/query.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +package cosmos.query.v1; + +import "google/protobuf/descriptor.proto"; + +// TODO: once we fully migrate to protov2 the go_package needs to be updated. +// We need this right now because gogoproto codegen needs to import the extension. +option go_package = "github.com/cosmos/cosmos-sdk/types/query"; + +extend google.protobuf.MethodOptions { + // module_query_safe is set to true when the query is safe to be called from + // within the state machine, for example from another module's Keeper, via + // ADR-033 calls or from CosmWasm contracts. + // Concretely, it means that the query is: + // 1. deterministic: given a block height, returns the exact same response + // upon multiple calls; and doesn't introduce any state-machine-breaking + // changes across SDK patch version. + // 2. consumes gas correctly. + // + // If you are a module developer and want to add this annotation to one of + // your own queries, please make sure that the corresponding query: + // 1. is deterministic and won't introduce state-machine-breaking changes + // without a coordinated upgrade path, + // 2. has its gas tracked, to avoid the attack vector where no gas is + // accounted for on potentially high-computation queries. + // + // For queries that potentially consume a large amount of gas (for example + // those with pagination, if the pagination field is incorrectly set), we + // also recommend adding Protobuf comments to warn module developers + // consuming these queries. + // + // When set to true, the query can safely be called + bool module_query_safe = 11110001; +} \ No newline at end of file diff --git a/third_party/proto/cosmos_proto/cosmos.proto b/third_party/proto/cosmos_proto/cosmos.proto index 167b1707..ef8a95af 100644 --- a/third_party/proto/cosmos_proto/cosmos.proto +++ b/third_party/proto/cosmos_proto/cosmos.proto @@ -3,14 +3,110 @@ package cosmos_proto; import "google/protobuf/descriptor.proto"; -option go_package = "github.com/regen-network/cosmos-proto"; +option go_package = "github.com/cosmos/cosmos-proto;cosmos_proto"; + +extend google.protobuf.MethodOptions { + + // method_added_in is used to indicate from which version the method was added. + string method_added_in = 93001; +} extend google.protobuf.MessageOptions { - string interface_type = 93001; - string implements_interface = 93002; + // implements_interface is used to indicate the type name of the interface + // that a message implements so that it can be used in google.protobuf.Any + // fields that accept that interface. A message can implement multiple + // interfaces. Interfaces should be declared using a declare_interface + // file option. + repeated string implements_interface = 93001; + + // message_added_in is used to indicate from which version the message was added. + string message_added_in = 93002; } extend google.protobuf.FieldOptions { - string accepts_interface = 93001; + + // accepts_interface is used to annotate that a google.protobuf.Any + // field accepts messages that implement the specified interface. + // Interfaces should be declared using a declare_interface file option. + string accepts_interface = 93001; + + // scalar is used to indicate that this field follows the formatting defined + // by the named scalar which should be declared with declare_scalar. Code + // generators may choose to use this information to map this field to a + // language-specific type representing the scalar. + string scalar = 93002; + + // field_added_in is used to indicate from which version the field was added. + string field_added_in = 93003; +} + +extend google.protobuf.FileOptions { + + // declare_interface declares an interface type to be used with + // accepts_interface and implements_interface. Interface names are + // expected to follow the following convention such that their declaration + // can be discovered by tools: for a given interface type a.b.C, it is + // expected that the declaration will be found in a protobuf file named + // a/b/interfaces.proto in the file descriptor set. + repeated InterfaceDescriptor declare_interface = 793021; + + // declare_scalar declares a scalar type to be used with + // the scalar field option. Scalar names are + // expected to follow the following convention such that their declaration + // can be discovered by tools: for a given scalar type a.b.C, it is + // expected that the declaration will be found in a protobuf file named + // a/b/scalars.proto in the file descriptor set. + repeated ScalarDescriptor declare_scalar = 793022; + + // file_added_in is used to indicate from which the version the file was added. + string file_added_in = 793023; +} + +// InterfaceDescriptor describes an interface type to be used with +// accepts_interface and implements_interface and declared by declare_interface. +message InterfaceDescriptor { + + // name is the name of the interface. It should be a short-name (without + // a period) such that the fully qualified name of the interface will be + // package.name, ex. for the package a.b and interface named C, the + // fully-qualified name will be a.b.C. + string name = 1; + + // description is a human-readable description of the interface and its + // purpose. + string description = 2; } + +// ScalarDescriptor describes an scalar type to be used with +// the scalar field option and declared by declare_scalar. +// Scalars extend simple protobuf built-in types with additional +// syntax and semantics, for instance to represent big integers. +// Scalars should ideally define an encoding such that there is only one +// valid syntactical representation for a given semantic meaning, +// i.e. the encoding should be deterministic. +message ScalarDescriptor { + + // name is the name of the scalar. It should be a short-name (without + // a period) such that the fully qualified name of the scalar will be + // package.name, ex. for the package a.b and scalar named C, the + // fully-qualified name will be a.b.C. + string name = 1; + + // description is a human-readable description of the scalar and its + // encoding format. For instance a big integer or decimal scalar should + // specify precisely the expected encoding format. + string description = 2; + + // field_type is the type of field with which this scalar can be used. + // Scalars can be used with one and only one type of field so that + // encoding standards and simple and clear. Currently only string and + // bytes fields are supported for scalars. + repeated ScalarType field_type = 3; +} + +enum ScalarType { + SCALAR_TYPE_UNSPECIFIED = 0; + SCALAR_TYPE_STRING = 1; + SCALAR_TYPE_BYTES = 2; +} \ No newline at end of file diff --git a/x/drop/keeper/drop.go b/x/drop/keeper/drop.go new file mode 100644 index 00000000..0df59412 --- /dev/null +++ b/x/drop/keeper/drop.go @@ -0,0 +1,66 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/math" + "github.com/bitsongofficial/go-bitsong/x/drop/types" + + nfttypes "github.com/bitsongofficial/go-bitsong/x/nft/types" +) + +func (k Keeper) CreateDrop( + ctx context.Context, + collectionDenom string, + maxAvailable uint64, + rules []types.Rule, +) error { + // 1. check if collections is not in our drop store + hasDrop, err := k.HasDrop(ctx, collectionDenom) + if err != nil { + return fmt.Errorf("failed to check drop existence: %w", err) + } + + if hasDrop { + return fmt.Errorf("drop already exists for collection %s", collectionDenom) + } + + // 2. check if collections has nfts, if yes return error, only empty collections can be dropped + collSupply := k.nftKeeper.GetSupply(ctx, collectionDenom) + + if collSupply.GT(math.ZeroInt()) { + return fmt.Errorf("collection %s is not empty, cannot create drop", collectionDenom) + } + + // 3. check drop max available (max is MaxNftsInCollection) + if math.NewUint(maxAvailable).GT(math.NewUint(nfttypes.MaxNftsInCollection)) { + return fmt.Errorf("max available %d exceeds max allowed %d", maxAvailable, nfttypes.MaxNftsInCollection) + } + + // 4. check max rules (5) + if len(rules) > types.MaxRulesPerDrop { + return fmt.Errorf("number of rules %d exceeds max allowed %d", len(rules), types.MaxRulesPerDrop) + } + + if err := k.validateRules(rules); err != nil { + return err + } + + // store drop + // store rules + + return nil +} + +func (k Keeper) GetDrop(ctx context.Context, collectionDenom string) (types.Drop, error) { + return k.Drops.Get(ctx, collectionDenom) +} + +func (k Keeper) HasDrop(ctx context.Context, collectionDenom string) (bool, error) { + return k.Drops.Has(ctx, collectionDenom) +} + +func (k Keeper) validateRules(rules []types.Rule) error { + return nil +} diff --git a/x/drop/keeper/keeper.go b/x/drop/keeper/keeper.go new file mode 100644 index 00000000..589ee748 --- /dev/null +++ b/x/drop/keeper/keeper.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "cosmossdk.io/collections" + "cosmossdk.io/core/store" + "cosmossdk.io/log" + nftkeeper "github.com/bitsongofficial/go-bitsong/x/nft/keeper" + + storetypes "cosmossdk.io/store/types" + "github.com/bitsongofficial/go-bitsong/x/drop/types" + "github.com/cosmos/cosmos-sdk/codec" +) + +type Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + storeService store.KVStoreService + logger log.Logger + + nftKeeper *nftkeeper.Keeper + + Schema collections.Schema + Drops collections.Map[string, types.Drop] // (collectionDenom) -> Drop + Rules collections.Map[collections.Pair[string, string], types.Rule] // (collectionDenom, ruleId) -> Rule +} + +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, storeService store.KVStoreService, nftKeeper *nftkeeper.Keeper, logger log.Logger) Keeper { + logger = logger.With(log.ModuleKey, "x/"+types.ModuleName) + + sb := collections.NewSchemaBuilder(storeService) + + k := Keeper{ + cdc: cdc, + storeKey: key, + storeService: storeService, + logger: logger, + nftKeeper: nftKeeper, + Drops: collections.NewMap( + sb, + types.DropsPrefix, + "drops", + collections.StringKey, codec.CollValue[types.Drop](cdc), + ), + Rules: collections.NewMap( + sb, + types.RulesPrefix, + "rules", + collections.PairKeyCodec(collections.StringKey, collections.StringKey), + codec.CollValue[types.Rule](cdc), + ), + } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + return k +} diff --git a/x/drop/rules/end_time.go b/x/drop/rules/end_time.go new file mode 100644 index 00000000..d3ed90d9 --- /dev/null +++ b/x/drop/rules/end_time.go @@ -0,0 +1,22 @@ +package rules + +import ( + "fmt" + "time" +) + +type EndTimeRule struct { + EndTime time.Time +} + +func (r *EndTimeRule) Name() string { + return "end_time" +} + +func (r *EndTimeRule) Validate(req *RuleEngineRequest) error { + if req.currentTime.After(r.EndTime) { + return fmt.Errorf("current time %s is after end time %s", req.currentTime, r.EndTime) + } + + return nil +} diff --git a/x/drop/rules/engine.go b/x/drop/rules/engine.go new file mode 100644 index 00000000..38e83878 --- /dev/null +++ b/x/drop/rules/engine.go @@ -0,0 +1,78 @@ +package rules + +import ( + "fmt" + "time" + + "github.com/bitsongofficial/go-bitsong/x/drop/types" +) + +type RuleEngineRequest struct { + currentTime time.Time +} + +type RuleI interface { + Name() string + Validate(req *RuleEngineRequest) error +} + +type RuleEngine struct { + rules map[string]RuleI +} + +func NewRuleEngine() *RuleEngine { + return &RuleEngine{ + rules: make(map[string]RuleI), + } +} + +func (e *RuleEngine) Register(rule RuleI) error { + name := rule.Name() + if _, exists := e.rules[name]; exists { + return nil + } + + e.rules[name] = rule + return nil +} + +func (e *RuleEngine) Validate(req *RuleEngineRequest) error { + for name, rule := range e.rules { + if err := rule.Validate(req); err != nil { + return fmt.Errorf("rule %s validation failed: %w", name, err) + } + } + + return nil +} + +func NewRuleEngineFromRule(rule types.Rule) (*RuleEngine, error) { + engine := NewRuleEngine() + + if !rule.StartTime.IsZero() { + err := engine.Register(&StartTimeRule{ + StartTime: rule.StartTime, + }) + if err != nil { + return nil, fmt.Errorf("failed to register start time rule: %w", err) + } + } + + if !rule.EndTime.IsZero() { + err := engine.Register(&EndTimeRule{ + EndTime: rule.EndTime, + }) + if err != nil { + return nil, fmt.Errorf("failed to register end time rule: %w", err) + } + } else { + err := engine.Register(&EndTimeRule{ + EndTime: rule.StartTime.Add(7 * 24 * time.Hour), + }) + if err != nil { + return nil, fmt.Errorf("failed to register default end time rule: %w", err) + } + } + + return engine, nil +} diff --git a/x/drop/rules/engine_test.go b/x/drop/rules/engine_test.go new file mode 100644 index 00000000..94ce8fd1 --- /dev/null +++ b/x/drop/rules/engine_test.go @@ -0,0 +1,32 @@ +package rules + +import ( + "testing" + "time" + + "github.com/bitsongofficial/go-bitsong/x/drop/types" +) + +func TestRulesEngine(t *testing.T) { + startTime := time.Now().Add(-1 * time.Hour) + endTime := startTime.Add(24 * time.Hour) + + rules := types.Rule{ + StartTime: startTime, + EndTime: endTime, + } + + engine, err := NewRuleEngineFromRule(rules) + if err != nil { + t.Fatalf("failed to create rules engine: %v", err) + } + + req := &RuleEngineRequest{ + currentTime: time.Now(), + } + + err = engine.Validate(req) + if err != nil { + t.Fatalf("rules validation failed: %v", err) + } +} diff --git a/x/drop/rules/start_time.go b/x/drop/rules/start_time.go new file mode 100644 index 00000000..7e12e6f8 --- /dev/null +++ b/x/drop/rules/start_time.go @@ -0,0 +1,22 @@ +package rules + +import ( + "fmt" + "time" +) + +type StartTimeRule struct { + StartTime time.Time +} + +func (r *StartTimeRule) Name() string { + return "start_time" +} + +func (r *StartTimeRule) Validate(req *RuleEngineRequest) error { + if req.currentTime.Before(r.StartTime) { + return fmt.Errorf("current time %s is before start time %s", req.currentTime, r.StartTime) + } + + return nil +} diff --git a/x/drop/types/drop.pb.go b/x/drop/types/drop.pb.go new file mode 100644 index 00000000..56affafd --- /dev/null +++ b/x/drop/types/drop.pb.go @@ -0,0 +1,867 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: bitsong/drop/v1beta1/drop.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Template struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"` +} + +func (m *Template) Reset() { *m = Template{} } +func (m *Template) String() string { return proto.CompactTextString(m) } +func (*Template) ProtoMessage() {} +func (*Template) Descriptor() ([]byte, []int) { + return fileDescriptor_3bbfac863f8f1f74, []int{0} +} +func (m *Template) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Template) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Template.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 *Template) XXX_Merge(src proto.Message) { + xxx_messageInfo_Template.Merge(m, src) +} +func (m *Template) XXX_Size() int { + return m.Size() +} +func (m *Template) XXX_DiscardUnknown() { + xxx_messageInfo_Template.DiscardUnknown(m) +} + +var xxx_messageInfo_Template proto.InternalMessageInfo + +type Rule struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` + EndTime time.Time `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` +} + +func (m *Rule) Reset() { *m = Rule{} } +func (m *Rule) String() string { return proto.CompactTextString(m) } +func (*Rule) ProtoMessage() {} +func (*Rule) Descriptor() ([]byte, []int) { + return fileDescriptor_3bbfac863f8f1f74, []int{1} +} +func (m *Rule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Rule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Rule.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 *Rule) XXX_Merge(src proto.Message) { + xxx_messageInfo_Rule.Merge(m, src) +} +func (m *Rule) XXX_Size() int { + return m.Size() +} +func (m *Rule) XXX_DiscardUnknown() { + xxx_messageInfo_Rule.DiscardUnknown(m) +} + +var xxx_messageInfo_Rule proto.InternalMessageInfo + +type Drop struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + MaxAvailable uint64 `protobuf:"varint,2,opt,name=max_available,json=maxAvailable,proto3" json:"max_available,omitempty"` + Template *Template `protobuf:"bytes,3,opt,name=template,proto3" json:"template,omitempty"` +} + +func (m *Drop) Reset() { *m = Drop{} } +func (m *Drop) String() string { return proto.CompactTextString(m) } +func (*Drop) ProtoMessage() {} +func (*Drop) Descriptor() ([]byte, []int) { + return fileDescriptor_3bbfac863f8f1f74, []int{2} +} +func (m *Drop) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Drop) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Drop.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 *Drop) XXX_Merge(src proto.Message) { + xxx_messageInfo_Drop.Merge(m, src) +} +func (m *Drop) XXX_Size() int { + return m.Size() +} +func (m *Drop) XXX_DiscardUnknown() { + xxx_messageInfo_Drop.DiscardUnknown(m) +} + +var xxx_messageInfo_Drop proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Template)(nil), "bitsong.drop.v1beta1.Template") + proto.RegisterType((*Rule)(nil), "bitsong.drop.v1beta1.Rule") + proto.RegisterType((*Drop)(nil), "bitsong.drop.v1beta1.Drop") +} + +func init() { proto.RegisterFile("bitsong/drop/v1beta1/drop.proto", fileDescriptor_3bbfac863f8f1f74) } + +var fileDescriptor_3bbfac863f8f1f74 = []byte{ + // 388 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x31, 0x8f, 0xd3, 0x30, + 0x14, 0x8e, 0xdb, 0x08, 0x5a, 0x43, 0x11, 0x58, 0x1d, 0xaa, 0x0c, 0x0e, 0x2a, 0x0b, 0x42, 0xc2, + 0x56, 0x8b, 0xc4, 0xd0, 0x8d, 0xaa, 0x03, 0x03, 0x53, 0xd4, 0x89, 0xa5, 0x72, 0x12, 0x37, 0x58, + 0xb2, 0xe3, 0x28, 0x71, 0xaa, 0xf2, 0x0f, 0x58, 0x90, 0xfa, 0x13, 0x18, 0x19, 0x18, 0xf8, 0x19, + 0x1d, 0x3b, 0x32, 0x71, 0xa7, 0x76, 0xb8, 0xbf, 0x71, 0x8a, 0xe3, 0x9c, 0x6e, 0xb8, 0xe5, 0x16, + 0xeb, 0xbd, 0xef, 0x7d, 0xef, 0xf3, 0xe7, 0xe7, 0x07, 0xc3, 0x58, 0x98, 0x4a, 0xe7, 0x19, 0x4d, + 0x4b, 0x5d, 0xd0, 0xdd, 0x2c, 0xe6, 0x86, 0xcd, 0x6c, 0x42, 0x8a, 0x52, 0x1b, 0x8d, 0xc6, 0x8e, + 0x40, 0x2c, 0xe6, 0x08, 0xc1, 0x38, 0xd3, 0x99, 0xb6, 0x04, 0xda, 0x44, 0x2d, 0x37, 0x08, 0x33, + 0xad, 0x33, 0xc9, 0xa9, 0xcd, 0xe2, 0x7a, 0x4b, 0x8d, 0x50, 0xbc, 0x32, 0x4c, 0x39, 0xb1, 0xe0, + 0x15, 0x53, 0x22, 0xd7, 0xd4, 0x9e, 0x2d, 0x34, 0xfd, 0x08, 0x07, 0x6b, 0xae, 0x0a, 0xc9, 0x0c, + 0x47, 0x08, 0xfa, 0x39, 0x53, 0x7c, 0x02, 0x5e, 0x83, 0xb7, 0xc3, 0xc8, 0xc6, 0xe8, 0x25, 0xec, + 0xd7, 0xa5, 0x98, 0xf4, 0x2c, 0xd4, 0x84, 0x0b, 0xff, 0xc7, 0xaf, 0xd0, 0x9b, 0xfe, 0x01, 0xd0, + 0x8f, 0x6a, 0xc9, 0xd1, 0x0b, 0xd8, 0x13, 0xa9, 0x6b, 0xe9, 0x89, 0x14, 0x7d, 0x86, 0xb0, 0x32, + 0xac, 0x34, 0x9b, 0xe6, 0x72, 0xdb, 0xf7, 0x6c, 0x1e, 0x90, 0xd6, 0x19, 0xe9, 0x9c, 0x91, 0x75, + 0xe7, 0x6c, 0x39, 0x3a, 0xfe, 0x0f, 0xbd, 0xc3, 0x55, 0x08, 0x7e, 0xdf, 0xfc, 0x7d, 0x07, 0xa2, + 0xa1, 0x6d, 0x6e, 0xca, 0x68, 0x05, 0x07, 0x3c, 0x4f, 0x5b, 0x9d, 0xfe, 0x63, 0x75, 0x9e, 0xf2, + 0x3c, 0x6d, 0x8a, 0xce, 0xee, 0x4f, 0x00, 0xfd, 0x55, 0xa9, 0x0b, 0x84, 0x21, 0x4c, 0xb4, 0x94, + 0x3c, 0x31, 0x42, 0xe7, 0xce, 0xf6, 0x3d, 0x04, 0xbd, 0x81, 0x23, 0xc5, 0xf6, 0x1b, 0xb6, 0x63, + 0x42, 0xb2, 0x58, 0xb6, 0x2f, 0xf0, 0xa3, 0xe7, 0x8a, 0xed, 0x3f, 0x75, 0x18, 0x5a, 0xc0, 0x81, + 0x71, 0x43, 0x73, 0xce, 0x30, 0x79, 0xe8, 0x9f, 0x48, 0x37, 0xda, 0xe8, 0x8e, 0xdf, 0xfa, 0x59, + 0x7e, 0x39, 0x9e, 0x31, 0x38, 0x9d, 0x31, 0xb8, 0x3e, 0x63, 0x70, 0xb8, 0x60, 0xef, 0x74, 0xc1, + 0xde, 0xbf, 0x0b, 0xf6, 0xbe, 0xce, 0x33, 0x61, 0xbe, 0xd5, 0x31, 0x49, 0xb4, 0xa2, 0x4e, 0x53, + 0x6f, 0xb7, 0x22, 0x11, 0x4c, 0xd2, 0x4c, 0xbf, 0xef, 0xf6, 0x65, 0xdf, 0x6e, 0x8c, 0xf9, 0x5e, + 0xf0, 0x2a, 0x7e, 0x62, 0xe7, 0xf1, 0xe1, 0x36, 0x00, 0x00, 0xff, 0xff, 0x83, 0x90, 0xe8, 0x08, + 0x4e, 0x02, 0x00, 0x00, +} + +func (m *Template) 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 *Template) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Template) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintDrop(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintDrop(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Rule) 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 *Rule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Rule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintDrop(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x1a + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintDrop(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x12 + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintDrop(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Drop) 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 *Drop) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Drop) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Template != nil { + { + size, err := m.Template.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDrop(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.MaxAvailable != 0 { + i = encodeVarintDrop(dAtA, i, uint64(m.MaxAvailable)) + i-- + dAtA[i] = 0x10 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintDrop(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDrop(dAtA []byte, offset int, v uint64) int { + offset -= sovDrop(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Template) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovDrop(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovDrop(uint64(l)) + } + return n +} + +func (m *Rule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovDrop(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovDrop(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovDrop(uint64(l)) + return n +} + +func (m *Drop) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovDrop(uint64(l)) + } + if m.MaxAvailable != 0 { + n += 1 + sovDrop(uint64(m.MaxAvailable)) + } + if m.Template != nil { + l = m.Template.Size() + n += 1 + l + sovDrop(uint64(l)) + } + return n +} + +func sovDrop(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDrop(x uint64) (n int) { + return sovDrop(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Template) 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 ErrIntOverflowDrop + } + 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: Template: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Template: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDrop(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDrop + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Rule) 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 ErrIntOverflowDrop + } + 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: Rule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Rule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDrop + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDrop + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDrop(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDrop + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Drop) 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 ErrIntOverflowDrop + } + 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: Drop: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Drop: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAvailable", wireType) + } + m.MaxAvailable = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxAvailable |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Template", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDrop + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Template == nil { + m.Template = &Template{} + } + if err := m.Template.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDrop(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDrop + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDrop(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, ErrIntOverflowDrop + } + 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, ErrIntOverflowDrop + } + 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, ErrIntOverflowDrop + } + 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, ErrInvalidLengthDrop + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDrop + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDrop + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDrop = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDrop = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDrop = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/drop/types/keys.go b/x/drop/types/keys.go new file mode 100644 index 00000000..772ba76a --- /dev/null +++ b/x/drop/types/keys.go @@ -0,0 +1,17 @@ +package types + +import "cosmossdk.io/collections" + +const ( + ModuleName = "drop" + StoreKey = ModuleName + RouterKey = ModuleName + + MaxRulesPerDrop = 5 + MaxRuleIDLength = 20 +) + +var ( + DropsPrefix = collections.NewPrefix(0) + RulesPrefix = collections.NewPrefix(1) +) diff --git a/x/nft/keeper/collection.go b/x/nft/keeper/collection.go new file mode 100644 index 00000000..95745590 --- /dev/null +++ b/x/nft/keeper/collection.go @@ -0,0 +1,265 @@ +package keeper + +import ( + "context" + "fmt" + "strings" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "github.com/bitsongofficial/go-bitsong/x/nft/types" + tmcrypto "github.com/cometbft/cometbft/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (k Keeper) CreateCollection( + ctx sdk.Context, + creator, + minter, + authority, + symbol, + name, + uri string, +) (denom string, err error) { + creatorAddr, err := k.ac.StringToBytes(creator) + if err != nil { + return "", errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address: %s", err) + } + + denom, err = k.validateCollectionDenom(ctx, creatorAddr, symbol) + if err != nil { + return "", err + } + + // TODO: charge fee + + if err := k.validateCollectionMetadata(name, uri); err != nil { + return "", err + } + + coll := types.Collection{ + Denom: denom, + Symbol: symbol, + Name: name, + Uri: uri, + Creator: creator, + } + + if minter != "" { + _, err = k.ac.StringToBytes(minter) + if err != nil { + return "", errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid minter address: %s", err) + } + + coll.Minter = minter + } + + if authority != "" { + _, err = k.ac.StringToBytes(authority) + if err != nil { + return "", errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address: %s", err) + } + + coll.Authority = authority + } + + if err := k.setCollection(ctx, coll); err != nil { + return "", err + } + + return denom, nil +} + +func (k Keeper) SetCollectionName(ctx context.Context, authority sdk.AccAddress, denom, name string) error { + coll, err := k.GetCollection(ctx, denom) + if err != nil { + return err + } + + if coll.Authority != authority.String() { + return fmt.Errorf("only the collection authority can change the name") + } + + if err := k.validateCollectionMetadata(name, coll.Uri); err != nil { + return err + } + + coll.Name = name + + return k.setCollection(ctx, coll) +} + +func (k Keeper) SetCollectionUri(ctx context.Context, authority sdk.AccAddress, denom, uri string) error { + coll, err := k.GetCollection(ctx, denom) + if err != nil { + return err + } + + if coll.Authority != authority.String() { + return fmt.Errorf("only the collection authority can change the uri") + } + + if err := k.validateCollectionMetadata(coll.Name, uri); err != nil { + return err + } + + coll.Uri = uri + + return k.setCollection(ctx, coll) +} + +func (k Keeper) SetMinter(ctx context.Context, oldMinter sdk.AccAddress, newMinter *sdk.AccAddress, denom string) error { + coll, err := k.GetCollection(ctx, denom) + if err != nil { + return err + } + + if coll.Minter == "" { + return fmt.Errorf("minting disabled for this collection") + } + + if coll.Minter != oldMinter.String() { + return fmt.Errorf("only the current minter can change the minter") + } + + if newMinter != nil { + coll.Minter = newMinter.String() + } else { + coll.Minter = "" + } + + return k.setCollection(ctx, coll) +} + +func (k Keeper) SetAuthority(ctx context.Context, oldAuthority sdk.AccAddress, newAuthority *sdk.AccAddress, denom string) error { + coll, err := k.GetCollection(ctx, denom) + if err != nil { + return err + } + + if coll.Authority != oldAuthority.String() { + return fmt.Errorf("only the current authority can change the authority") + } + + if newAuthority != nil { + coll.Authority = newAuthority.String() + } else { + coll.Authority = "" + } + + return k.setCollection(ctx, coll) +} + +func (k Keeper) GetMinter(ctx context.Context, denom string) (sdk.AccAddress, error) { + coll, err := k.Collections.Get(ctx, denom) + if err != nil { + return nil, types.ErrCollectionNotFound + } + + if coll.Minter == "" { + return nil, fmt.Errorf("minting disabled for this collection") + } + + return sdk.AccAddressFromBech32(coll.Minter) +} + +func (k Keeper) GetAuthority(ctx context.Context, denom string) (sdk.AccAddress, error) { + coll, err := k.Collections.Get(ctx, denom) + if err != nil { + return nil, types.ErrCollectionNotFound + } + + if coll.Authority == "" { + return nil, fmt.Errorf("no authority set for this collection") + } + + return sdk.AccAddressFromBech32(coll.Authority) +} + +func (k Keeper) GetSupply(ctx context.Context, denom string) math.Int { + supply, err := k.Supply.Get(ctx, denom) + if err != nil { + return math.ZeroInt() + } + + return supply +} + +func (k Keeper) HasSupply(ctx context.Context, denom string) bool { + has, err := k.Supply.Has(ctx, denom) + return has && err == nil +} + +func (k Keeper) HasCollection(ctx context.Context, denom string) bool { + has, err := k.Collections.Has(ctx, denom) + return has && err == nil +} + +func (k Keeper) GetCollection(ctx context.Context, denom string) (types.Collection, error) { + coll, err := k.Collections.Get(ctx, denom) + if err != nil { + return types.Collection{}, types.ErrCollectionNotFound + } + + return coll, nil +} + +func (k Keeper) setSupply(ctx context.Context, denom string, supply math.Int) error { + return k.Supply.Set(ctx, denom, supply) +} + +func (k Keeper) incrementSupply(ctx context.Context, denom string) error { + supply := k.GetSupply(ctx, denom) + supply = supply.Add(math.NewInt(1)) + + return k.setSupply(ctx, denom, supply) +} + +func (k Keeper) createCollectionDenom(creator sdk.AccAddress, symbol string) (string, error) { + // TODO: if necessary add a salt field + + if strings.TrimSpace(symbol) == "" { + return "", fmt.Errorf("symbol cannot be empty") + } + + if len(symbol) > types.MaxSymbolLength { + return "", fmt.Errorf("symbol cannot be longer than %d characters", types.MaxSymbolLength) + } + + bz := []byte(fmt.Sprintf("%s/%s", creator.String(), symbol)) + return fmt.Sprintf("nft%x", tmcrypto.AddressHash(bz)), nil +} + +func (k Keeper) validateCollectionDenom(ctx context.Context, creator sdk.AccAddress, symbol string) (string, error) { + denom, err := k.createCollectionDenom(creator, symbol) + if err != nil { + return "", err + } + + if err := sdk.ValidateDenom(denom); err != nil { + return "", err + } + + if k.HasCollection(ctx, denom) { + return "", types.ErrCollectionAlreadyExists + } + + return denom, nil +} + +func (k Keeper) setCollection(ctx context.Context, coll types.Collection) error { + return k.Collections.Set(ctx, coll.Denom, coll) +} + +func (k Keeper) validateCollectionMetadata(name, uri string) error { + if len(name) > types.MaxNameLength { + return fmt.Errorf("name cannot be longer than %d characters", types.MaxNameLength) + } + + if len(uri) > types.MaxURILength { + return fmt.Errorf("uri cannot be longer than %d characters", types.MaxURILength) + } + + return nil +} diff --git a/x/nft/keeper/collection_test.go b/x/nft/keeper/collection_test.go new file mode 100644 index 00000000..0a90dd02 --- /dev/null +++ b/x/nft/keeper/collection_test.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "testing" + + "github.com/cometbft/cometbft/crypto/tmhash" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func TestKeeper_createCollectionDenom(t *testing.T) { + creator := sdk.AccAddress(tmhash.SumTruncated([]byte("creator1"))) + symbol := "MYNFT" + + expectedDenom := "nft9436DDD23FB751AEA7BC6C767F20F943DD735E06" + k := Keeper{} + + denom, err := k.createCollectionDenom(creator, symbol) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if denom != expectedDenom { + t.Errorf("expected %s, got %s", expectedDenom, denom) + } +} diff --git a/x/nft/keeper/edition.go b/x/nft/keeper/edition.go new file mode 100644 index 00000000..432a0f8a --- /dev/null +++ b/x/nft/keeper/edition.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/collections" + "github.com/bitsongofficial/go-bitsong/x/nft/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) PrintEdition( + ctx context.Context, + minter, + owner sdk.AccAddress, + collectionDenom, + tokenId string, +) (uint64, error) { + // TODO: this is temporary, must be improved! + + nft, err := k.GetNft(ctx, collectionDenom, tokenId) + if err != nil { + return 0, err + } + if nft == nil { + return 0, fmt.Errorf("NFT with token ID %s does not exist in collection %s", tokenId, collectionDenom) + } + + collectionMinter, err := k.GetMinter(ctx, collectionDenom) + if err != nil { + return 0, err + } + + if !minter.Equals(collectionMinter) { + return 0, fmt.Errorf("only the collection minter can print editions") + } + + // TODO: Charge fee if necessary + + if nft.Editions == types.MaxEditions { + return 0, fmt.Errorf("max editions reached for NFT %s in collection %s", tokenId, collectionDenom) + } + + edition := types.Edition{ + Collection: collectionDenom, + TokenId: tokenId, + Seq: nft.Editions + 1, + Owner: owner.String(), + } + + if err := k.setEdition(ctx, edition); err != nil { + return 0, fmt.Errorf("failed to set edition: %w", err) + } + + if err := k.incrementEdition(ctx, collectionDenom, tokenId); err != nil { + return 0, fmt.Errorf("failed to increment edition: %w", err) + } + + return edition.Seq, nil +} + +func (k Keeper) setEdition(ctx context.Context, edition types.Edition) error { + editionKey := collections.Join3(edition.Collection, edition.TokenId, edition.Seq) + return k.Editions.Set(ctx, editionKey, edition) +} diff --git a/x/nft/keeper/edition_test.go b/x/nft/keeper/edition_test.go new file mode 100644 index 00000000..03645a54 --- /dev/null +++ b/x/nft/keeper/edition_test.go @@ -0,0 +1,55 @@ +package keeper_test + +func (suite *KeeperTestSuite) TestPrintEdition() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + edition, err := suite.keeper.PrintEdition( + suite.ctx, + minter1, + owner1, + collectionDenom, + "1", + ) + suite.NoError(err) + suite.Equal(uint64(1), edition) + + edition, err = suite.keeper.PrintEdition( + suite.ctx, + minter1, + owner1, + collectionDenom, + "1", + ) + suite.NoError(err) + suite.Equal(uint64(2), edition) + + edition, err = suite.keeper.PrintEdition( + suite.ctx, + minter1, + owner1, + collectionDenom, + "1", + ) + suite.NoError(err) + suite.Equal(uint64(3), edition) +} diff --git a/x/nft/keeper/grpc_query.go b/x/nft/keeper/grpc_query.go new file mode 100644 index 00000000..0cc9d5b3 --- /dev/null +++ b/x/nft/keeper/grpc_query.go @@ -0,0 +1,189 @@ +package keeper + +import ( + "context" + "errors" + + "cosmossdk.io/collections" + "cosmossdk.io/store/prefix" + "github.com/bitsongofficial/go-bitsong/x/nft/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) Collection(ctx context.Context, req *types.QueryCollectionRequest) (*types.QueryCollectionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + if req.Collection == "" { + return nil, status.Error(codes.InvalidArgument, "collection cannot be empty") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + coll, err := k.Collections.Get(sdkCtx, req.Collection) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + return nil, status.Errorf(codes.NotFound, "collection %s not found", req.Collection) + } + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryCollectionResponse{ + Collection: &coll, + }, nil +} + +func (k Keeper) OwnerOf(ctx context.Context, req *types.QueryOwnerOfRequest) (*types.QueryOwnerOfResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + if req.Collection == "" { + return nil, status.Error(codes.InvalidArgument, "collection cannot be empty") + } + if req.TokenId == "" { + return nil, status.Error(codes.InvalidArgument, "token_id cannot be empty") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + nft, err := k.NFTs.Get(sdkCtx, collections.Join(req.Collection, req.TokenId)) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + return nil, status.Errorf(codes.NotFound, "nft with collection %s and token_id %s not found", req.Collection, req.TokenId) + } + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryOwnerOfResponse{ + Owner: nft.Owner, + }, nil +} + +func (k Keeper) NftInfo(ctx context.Context, req *types.QueryNftInfoRequest) (*types.QueryNftInfoResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + if req.Collection == "" { + return nil, status.Error(codes.InvalidArgument, "collection cannot be empty") + } + if req.TokenId == "" { + return nil, status.Error(codes.InvalidArgument, "token_id cannot be empty") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + nft, err := k.NFTs.Get(sdkCtx, collections.Join(req.Collection, req.TokenId)) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + return nil, status.Errorf(codes.NotFound, "nft with collection %s and token_id %s not found", req.Collection, req.TokenId) + } + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryNftInfoResponse{ + Nft: &nft, + }, nil +} + +func (k Keeper) Nfts(ctx context.Context, req *types.QueryNftsRequest) (*types.QueryNftsResponse, error) { + if req == nil || req.Collection == "" { + return nil, status.Error(codes.InvalidArgument, "collection cannot be empty") + } + + nfts, pageRes, err := query.CollectionPaginate( + ctx, + k.NFTs, + req.Pagination, + func(key collections.Pair[string, string], value types.Nft) (types.Nft, error) { + return value, nil + }, + query.WithCollectionPaginationPairPrefix[string, string](req.Collection), + ) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryNftsResponse{ + Nfts: nfts, + Pagination: pageRes, + }, nil +} + +func (k Keeper) GetNftsByOwner(ctx context.Context, owner sdk.AccAddress, pagination *query.PageRequest) ([]types.Nft, *query.PageResponse, error) { + var nfts []types.Nft + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := prefix.NewStore( + sdkCtx.KVStore(k.storeKey), + append(types.NFTsByOwnerPrefix, address.MustLengthPrefix(owner)...), + ) + + pageRes, err := query.Paginate(store, pagination, func(key []byte, value []byte) error { + denom, tokenId := types.MustSplitNftLengthPrefixedKey(key) + + nft, err := k.NFTs.Get(ctx, collections.Join(string(denom), string(tokenId))) + if err != nil { + return err + } + + nfts = append(nfts, nft) + + return nil + }) + + if err != nil { + return nil, nil, err + } + + return nfts, pageRes, nil +} + +func (k Keeper) AllNftsByOwner(ctx context.Context, req *types.QueryAllNftsByOwnerRequest) (*types.QueryAllNftsByOwnerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + owner, err := sdk.AccAddressFromBech32(req.Owner) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid owner address: %s", err.Error()) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := prefix.NewStore( + sdkCtx.KVStore(k.storeKey), + append(types.NFTsByOwnerPrefix, address.MustLengthPrefix(owner)...), + ) + + var nfts []types.Nft + + pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error { + denom, tokenId := types.MustSplitNftLengthPrefixedKey(key) + + nft, err := k.NFTs.Get(ctx, collections.Join(string(denom), string(tokenId))) + if err != nil { + return err + } + + nfts = append(nfts, nft) + + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllNftsByOwnerResponse{ + Nfts: nfts, + Pagination: pageRes, + }, nil +} diff --git a/x/nft/keeper/grpc_query_test.go b/x/nft/keeper/grpc_query_test.go new file mode 100644 index 00000000..adf38b14 --- /dev/null +++ b/x/nft/keeper/grpc_query_test.go @@ -0,0 +1,205 @@ +package keeper_test + +import ( + "github.com/bitsongofficial/go-bitsong/x/nft/types" +) + +func (suite *KeeperTestSuite) TestQueryCollection() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + res, err := suite.keeper.Collection(suite.ctx, &types.QueryCollectionRequest{ + Collection: collectionDenom, + }) + suite.NoError(err) + suite.Equal(testCollection1.Name, res.Collection.Name) + suite.Equal(testCollection1.Symbol, res.Collection.Symbol) + suite.Equal(testCollection1.Uri, res.Collection.Uri) + suite.Equal(testCollection1.Minter, res.Collection.Minter) +} + +func (suite *KeeperTestSuite) TestQueryOwnerOf() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + res, err := suite.keeper.OwnerOf(suite.ctx, &types.QueryOwnerOfRequest{ + Collection: collectionDenom, + TokenId: "1", + }) + suite.NoError(err) + suite.Equal(owner1.String(), res.Owner) +} + +func (suite *KeeperTestSuite) TestQueryNftInfo() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + res, err := suite.keeper.NftInfo(suite.ctx, &types.QueryNftInfoRequest{ + Collection: collectionDenom, + TokenId: testNft1.TokenId, + }) + suite.NoError(err) + suite.Equal(testNft1.TokenId, res.Nft.TokenId) + suite.Equal(testNft1.Name, res.Nft.Name) + suite.Equal(testNft1.Uri, res.Nft.Uri) + suite.Equal(collectionDenom, res.Nft.Collection) + suite.Equal(owner1.String(), res.Nft.Owner) +} + +func (suite *KeeperTestSuite) TestQueryNftsOfOwner() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft2.TokenId, + testNft2.Name, + testNft2.Uri, + ) + suite.NoError(err) + + res, err := suite.keeper.Nfts(suite.ctx, &types.QueryNftsRequest{ + Collection: collectionDenom, + }) + suite.NoError(err) + suite.Len(res.Nfts, 2) + suite.Equal(testNft1.TokenId, res.Nfts[0].TokenId) + suite.Equal(testNft2.TokenId, res.Nfts[1].TokenId) +} + +func (suite *KeeperTestSuite) TestQueryNftsByOwner() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft2.TokenId, + testNft2.Name, + testNft2.Uri, + ) + suite.NoError(err) + + res, err := suite.keeper.AllNftsByOwner(suite.ctx, &types.QueryAllNftsByOwnerRequest{ + Owner: owner1.String(), + }) + suite.NoError(err) + suite.Len(res.Nfts, 2) + suite.Equal(testNft1.TokenId, res.Nfts[0].TokenId) + suite.Equal(uint64(0), res.Nfts[0].Editions) + suite.Equal(testNft2.TokenId, res.Nfts[1].TokenId) + suite.Equal(uint64(0), res.Nfts[1].Editions) + + res, err = suite.keeper.AllNftsByOwner(suite.ctx, &types.QueryAllNftsByOwnerRequest{ + Owner: owner2.String(), + }) + suite.NoError(err) + suite.Len(res.Nfts, 0) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner2, + collectionDenom, + testNft3.TokenId, + testNft3.Name, + testNft3.Uri, + ) + suite.NoError(err) + + res, err = suite.keeper.AllNftsByOwner(suite.ctx, &types.QueryAllNftsByOwnerRequest{ + Owner: owner2.String(), + }) + suite.NoError(err) + suite.Len(res.Nfts, 1) + suite.Equal(testNft3.TokenId, res.Nfts[0].TokenId) +} diff --git a/x/nft/keeper/keeper.go b/x/nft/keeper/keeper.go new file mode 100644 index 00000000..9103ebd0 --- /dev/null +++ b/x/nft/keeper/keeper.go @@ -0,0 +1,123 @@ +package keeper + +import ( + "cosmossdk.io/collections" + "cosmossdk.io/collections/indexes" + "cosmossdk.io/core/address" + "cosmossdk.io/core/store" + "cosmossdk.io/log" + "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + "github.com/bitsongofficial/go-bitsong/x/nft/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type NFTIndexes struct { + Collection *indexes.Multi[string, collections.Pair[string, string], types.Nft] + Owner *indexes.Multi[sdk.AccAddress, collections.Pair[string, string], types.Nft] +} + +func newNFTIndexes(sb *collections.SchemaBuilder) NFTIndexes { + return NFTIndexes{ + Collection: indexes.NewMulti( + sb, + types.NFTsByCollectionPrefix, + "nfts_by_collection", + collections.StringKey, + collections.PairKeyCodec(collections.StringKey, collections.StringKey), + func(pk collections.Pair[string, string], v types.Nft) (string, error) { + return v.Collection, nil + }, + ), + Owner: indexes.NewMulti( + sb, + types.NFTsByOwnerPrefix, + "nfts_by_owner", + sdk.AccAddressKey, + collections.PairKeyCodec(collections.StringKey, collections.StringKey), + func(pk collections.Pair[string, string], v types.Nft) (sdk.AccAddress, error) { + return sdk.AccAddressFromBech32(v.Owner) + }, + ), + } +} + +func (i NFTIndexes) IndexesList() []collections.Index[collections.Pair[string, string], types.Nft] { + return []collections.Index[collections.Pair[string, string], types.Nft]{ + i.Collection, + i.Owner, + } +} + +type Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + storeService store.KVStoreService + ak types.AccountKeeper + ac address.Codec + logger log.Logger + + Schema collections.Schema + Collections collections.Map[string, types.Collection] // (collectionDenom) -> Collection + Supply collections.Map[string, math.Int] + NFTs *collections.IndexedMap[collections.Pair[string, string], types.Nft, NFTIndexes] // (collectionDenom, tokenId) -> NFT + Editions collections.Map[collections.Triple[string, string, uint64], types.Edition] // (collectionDenom, tokenId, edition) -> Edition +} + +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, storeService store.KVStoreService, ak types.AccountKeeper, logger log.Logger) Keeper { + /*if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { + panic("the " + types.ModuleName + " module account has not been set") + }*/ + + // TODO: validate all metadata length + + logger = logger.With(log.ModuleKey, "x/"+types.ModuleName) + + sb := collections.NewSchemaBuilder(storeService) + + k := Keeper{ + cdc: cdc, + storeKey: key, + storeService: storeService, + ak: ak, + ac: ak.AddressCodec(), + logger: logger, + // TODO: fix the store once we add queries + Collections: collections.NewMap( + sb, + types.CollectionsPrefix, + "collections", + collections.StringKey, codec.CollValue[types.Collection](cdc), + ), + Supply: collections.NewMap( + sb, + types.SupplyPrefix, + "supply", + collections.StringKey, + sdk.IntValue, + ), + NFTs: collections.NewIndexedMap( + sb, + types.NFTsPrefix, + "nfts", + collections.PairKeyCodec(collections.StringKey, collections.StringKey), + codec.CollValue[types.Nft](cdc), + newNFTIndexes(sb), + ), + Editions: collections.NewMap( + sb, + types.EditionsPrefix, + "editions", + collections.TripleKeyCodec(collections.StringKey, collections.StringKey, collections.Uint64Key), + codec.CollValue[types.Edition](cdc), + ), + } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + return k +} diff --git a/x/nft/keeper/keeper_test.go b/x/nft/keeper/keeper_test.go new file mode 100644 index 00000000..1f7ae191 --- /dev/null +++ b/x/nft/keeper/keeper_test.go @@ -0,0 +1,588 @@ +package keeper_test + +import ( + "strings" + "testing" + + "cosmossdk.io/collections" + "cosmossdk.io/math" + simapp "github.com/bitsongofficial/go-bitsong/app" + apptesting "github.com/bitsongofficial/go-bitsong/app/testing" + "github.com/bitsongofficial/go-bitsong/x/nft/keeper" + "github.com/bitsongofficial/go-bitsong/x/nft/types" + "github.com/cometbft/cometbft/crypto/tmhash" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" +) + +var ( + creator1 = sdk.AccAddress(tmhash.SumTruncated([]byte("creator1"))) + creator2 = sdk.AccAddress(tmhash.SumTruncated([]byte("creator2"))) + + minter1 = sdk.AccAddress(tmhash.SumTruncated([]byte("minter1"))) + minter2 = sdk.AccAddress(tmhash.SumTruncated([]byte("minter2"))) + + owner1 = sdk.AccAddress(tmhash.SumTruncated([]byte("owner1"))) + owner2 = sdk.AccAddress(tmhash.SumTruncated([]byte("owner2"))) + + authority1 = sdk.AccAddress(tmhash.SumTruncated([]byte("authority1"))) + authority2 = sdk.AccAddress(tmhash.SumTruncated([]byte("authority2"))) + + testCollection1 = types.Collection{ + Name: "My NFT Collection", + Symbol: "MYNFT", + Uri: "ipfs://my-nft-collection-metadata.json", + Minter: minter1.String(), + } + expectedDenom1 = "nft9436DDD23FB751AEA7BC6C767F20F943DD735E06" + + testCollection2 = types.Collection{ + Name: "My Second NFT Collection", + Symbol: "MYNFT2", + Uri: "ipfs://my-nft-collection-metadata.json", + Minter: minter1.String(), + } + expectedDenom2 = "nft6C5B4EC9EA22932F217B0A0CDCA3A987B8271CD0" + + testNft1 = types.Nft{ + TokenId: "1", + Name: "My First NFT", + Uri: "ipfs://my-first-nft-metadata.json", + } + + testNft2 = types.Nft{ + TokenId: "2", + Name: "My Second NFT", + Uri: "ipfs://my-second-nft-metadata.json", + } + + testNft3 = types.Nft{ + TokenId: "3", + Name: "My Third NFT", + Uri: "ipfs://my-third-nft-metadata.json", + } +) + +type KeeperTestSuite struct { + apptesting.KeeperTestHelper + + ctx sdk.Context + keeper keeper.Keeper + + msgServer types.MsgServer + + app *simapp.BitsongApp +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.Setup() + + app := suite.App + suite.keeper = app.NftKeeper + suite.App = app + suite.ctx = suite.Ctx + + suite.msgServer = keeper.NewMsgServerImpl(suite.keeper) +} + +func TestKeeperSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (suite *KeeperTestSuite) TestCreateCollection() { + denom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + suite.Equal(expectedDenom1, denom) + + _, err = suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.Error(err) + + denom, err = suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection2.Symbol, + testCollection2.Name, + testCollection2.Uri, + ) + suite.NoError(err) + suite.Equal(expectedDenom2, denom) +} + +func (suite *KeeperTestSuite) TestSetCollectionName() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + suite.Equal(expectedDenom1, collectionDenom) + + err = suite.keeper.SetCollectionName(suite.ctx, authority1, collectionDenom, "New Collection Name") + suite.NoError(err) + + collection, err := suite.keeper.GetCollection(suite.ctx, collectionDenom) + suite.NoError(err) + suite.Equal("New Collection Name", collection.Name) + + err = suite.keeper.SetCollectionName(suite.ctx, creator2, collectionDenom, "Another Collection Name") + suite.Error(err) + + err = suite.keeper.SetCollectionName(suite.ctx, creator1, collectionDenom, strings.Repeat("a", 65)) + suite.Error(err) + + // test setting name on a collection without authority + collectionDenom2, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter2.String(), + "", + testCollection2.Symbol, + testCollection2.Name, + testCollection2.Uri, + ) + suite.NoError(err) + suite.Equal(expectedDenom2, collectionDenom2) + + err = suite.keeper.SetCollectionName(suite.ctx, creator1, collectionDenom2, "New Collection Name") + suite.Error(err) + suite.Contains(err.Error(), "only the collection authority can change the name") + + // create a collection without minter and authority + _, err = suite.keeper.CreateCollection( + suite.ctx, + creator2.String(), + "", + "", + "COLL3", + "Collection 3", + "ipfs://collection-3-metadata.json", + ) + suite.NoError(err) +} + +func (suite *KeeperTestSuite) TestSetCollectionUri() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + suite.Equal(expectedDenom1, collectionDenom) + + err = suite.keeper.SetCollectionUri(suite.ctx, authority1, collectionDenom, "ipfs://new-uri.json") + suite.NoError(err) + + collection, err := suite.keeper.GetCollection(suite.ctx, collectionDenom) + suite.NoError(err) + suite.Equal("ipfs://new-uri.json", collection.Uri) + + err = suite.keeper.SetCollectionUri(suite.ctx, creator2, collectionDenom, "ipfs://another-uri.json") + suite.Error(err) + + err = suite.keeper.SetCollectionUri(suite.ctx, authority1, collectionDenom, strings.Repeat("a", 165)) + suite.Error(err) + + // test setting uri on a collection without authority + collectionDenom2, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter2.String(), + "", + testCollection2.Symbol, + testCollection2.Name, + testCollection2.Uri, + ) + suite.NoError(err) + suite.Equal(expectedDenom2, collectionDenom2) + + err = suite.keeper.SetCollectionUri(suite.ctx, creator1, collectionDenom2, "ipfs://new-uri.json") + suite.Error(err) + suite.Contains(err.Error(), "only the collection authority can change the uri") +} + +func (suite *KeeperTestSuite) TestMintNFT() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + suite.Equal(expectedDenom1, collectionDenom) + + supply := suite.keeper.GetSupply(suite.ctx, collectionDenom) + suite.Equal(math.NewInt(0), supply) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + supply = suite.keeper.GetSupply(suite.ctx, collectionDenom) + suite.Equal(math.NewInt(1), supply) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft2.TokenId, + testNft2.Name, + testNft2.Uri, + ) + suite.NoError(err) + + supply = suite.keeper.GetSupply(suite.ctx, collectionDenom) + suite.Equal(math.NewInt(2), supply) + + // collection with no minter + collectionDenom2, err := suite.keeper.CreateCollection( + suite.ctx, + creator2.String(), + "", + "", + testCollection2.Symbol, + testCollection2.Name, + testCollection2.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + creator2, + owner2, + collectionDenom2, + testNft3.TokenId, + testNft3.Name, + testNft3.Uri, + ) + suite.Error(err) + suite.Contains(err.Error(), "minting disabled for this collection") +} + +func (suite *KeeperTestSuite) TestSetMinter() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.SetMinter(suite.ctx, minter1, &minter2, collectionDenom) + suite.NoError(err) + + minter, err := suite.keeper.GetMinter(suite.ctx, collectionDenom) + suite.NoError(err) + suite.Equal(minter2.String(), minter.String()) + + err = suite.keeper.SetMinter(suite.ctx, minter1, &minter1, collectionDenom) + suite.Error(err) + + err = suite.keeper.SetMinter(suite.ctx, minter2, nil, collectionDenom) + suite.NoError(err) + + _, err = suite.keeper.GetMinter(suite.ctx, collectionDenom) + suite.Error(err) + suite.Contains(err.Error(), "minting disabled for this collection") + + err = suite.keeper.SetMinter(suite.ctx, minter2, &minter1, collectionDenom) + suite.Error(err) + suite.Contains(err.Error(), "minting disabled for this collection") +} + +func (suite *KeeperTestSuite) TestSetAuthority() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.SetAuthority(suite.ctx, authority1, &authority2, collectionDenom) + suite.NoError(err) + + collection, err := suite.keeper.GetCollection(suite.ctx, collectionDenom) + suite.NoError(err) + suite.Equal(authority2.String(), collection.Authority) + + err = suite.keeper.SetAuthority(suite.ctx, authority1, &creator2, collectionDenom) + suite.Error(err) + suite.Contains(err.Error(), "only the current authority can change the authority") + + err = suite.keeper.SetAuthority(suite.ctx, authority2, nil, collectionDenom) + suite.NoError(err) + + collection, err = suite.keeper.GetCollection(suite.ctx, collectionDenom) + suite.NoError(err) + suite.Equal("", collection.Authority) + + err = suite.keeper.SetAuthority(suite.ctx, authority2, &creator2, collectionDenom) + suite.Error(err) + suite.Contains(err.Error(), "only the current authority can change the authority") +} + +func (suite *KeeperTestSuite) TestSendNFT() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + "", + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + res, err := suite.keeper.AllNftsByOwner(suite.ctx, &types.QueryAllNftsByOwnerRequest{ + Owner: owner1.String(), + }) + suite.NoError(err) + suite.Len(res.Nfts, 1) + suite.Equal(testNft1.TokenId, res.Nfts[0].TokenId) + + res, err = suite.keeper.AllNftsByOwner(suite.ctx, &types.QueryAllNftsByOwnerRequest{ + Owner: owner2.String(), + }) + suite.NoError(err) + suite.Len(res.Nfts, 0) + + err = suite.keeper.SendNFT(suite.ctx, owner1, owner2, collectionDenom, "1") + suite.NoError(err) + + res, err = suite.keeper.AllNftsByOwner(suite.ctx, &types.QueryAllNftsByOwnerRequest{ + Owner: owner2.String(), + }) + suite.NoError(err) + suite.Len(res.Nfts, 1) + suite.Equal(testNft1.TokenId, res.Nfts[0].TokenId) + + res, err = suite.keeper.AllNftsByOwner(suite.ctx, &types.QueryAllNftsByOwnerRequest{ + Owner: owner1.String(), + }) + suite.NoError(err) + suite.Len(res.Nfts, 0) + + nft, err := suite.keeper.NFTs.Get(suite.ctx, collections.Join(collectionDenom, "1")) + suite.NoError(err) + suite.Equal(owner2.String(), nft.Owner) +} + +func (suite *KeeperTestSuite) TestSetNFTName() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.SetNFTName(suite.ctx, authority1, collectionDenom, testNft1.TokenId, "New NFT Name") + suite.NoError(err) + + nft, err := suite.keeper.NFTs.Get(suite.ctx, collections.Join(collectionDenom, testNft1.TokenId)) + suite.NoError(err) + suite.Equal("New NFT Name", nft.Name) + + err = suite.keeper.SetNFTName(suite.ctx, owner2, collectionDenom, testNft1.TokenId, "Another NFT Name") + suite.Error(err) + suite.Contains(err.Error(), "only the collection authority can set NFT name") + + err = suite.keeper.SetNFTName(suite.ctx, authority1, collectionDenom, testNft1.TokenId, strings.Repeat("a", 165)) + suite.Error(err) + suite.Contains(err.Error(), "name length exceeds maximum") + + // test setting name on a collection without authority + collectionDenom2, err := suite.keeper.CreateCollection( + suite.ctx, + creator2.String(), + minter2.String(), + "", + testCollection2.Symbol, + testCollection2.Name, + testCollection2.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter2, + owner2, + collectionDenom2, + testNft2.TokenId, + testNft2.Name, + testNft2.Uri, + ) + suite.NoError(err) + + err = suite.keeper.SetNFTName(suite.ctx, owner2, collectionDenom2, testNft2.TokenId, "New NFT Name") + suite.Error(err) + suite.Contains(err.Error(), "no authority, cannot set NFT name") + + // create a collection with authority + collectionDenom3, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection1.Symbol+"3", + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom3, + testNft3.TokenId, + testNft3.Name, + testNft3.Uri, + ) + suite.NoError(err) + + err = suite.keeper.SetNFTName(suite.ctx, owner1, collectionDenom3, testNft3.TokenId, "New NFT Name") + suite.Error(err) + suite.Contains(err.Error(), "only the collection authority can set NFT name") + + err = suite.keeper.SetNFTName(suite.ctx, authority1, collectionDenom3, testNft3.TokenId, "New NFT Name") + suite.NoError(err) + + nft, err = suite.keeper.NFTs.Get(suite.ctx, collections.Join(collectionDenom3, testNft3.TokenId)) + suite.NoError(err) + suite.Equal("New NFT Name", nft.Name) +} + +func (suite *KeeperTestSuite) TestSetNFTUri() { + collectionDenom, err := suite.keeper.CreateCollection( + suite.ctx, + creator1.String(), + minter1.String(), + authority1.String(), + testCollection1.Symbol, + testCollection1.Name, + testCollection1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter1, + owner1, + collectionDenom, + testNft1.TokenId, + testNft1.Name, + testNft1.Uri, + ) + suite.NoError(err) + + err = suite.keeper.SetNFTUri(suite.ctx, authority1, collectionDenom, testNft1.TokenId, "ipfs://new-uri.json") + suite.NoError(err) + + nft, err := suite.keeper.NFTs.Get(suite.ctx, collections.Join(collectionDenom, testNft1.TokenId)) + suite.NoError(err) + suite.Equal("ipfs://new-uri.json", nft.Uri) + + err = suite.keeper.SetNFTUri(suite.ctx, owner2, collectionDenom, testNft1.TokenId, "ipfs://another-uri.json") + suite.Error(err) + suite.Contains(err.Error(), "only the collection authority can set NFT uri") + + err = suite.keeper.SetNFTUri(suite.ctx, authority1, collectionDenom, testNft1.TokenId, strings.Repeat("a", 165)) + suite.Error(err) + suite.Contains(err.Error(), "URI length exceeds maximum") + + // test setting uri on a collection without authority + collectionDenom2, err := suite.keeper.CreateCollection( + suite.ctx, + creator2.String(), + minter2.String(), + "", + testCollection2.Symbol, + testCollection2.Name, + testCollection2.Uri, + ) + suite.NoError(err) + + err = suite.keeper.MintNFT( + suite.ctx, + minter2, + owner2, + collectionDenom2, + testNft2.TokenId, + testNft2.Name, + testNft2.Uri, + ) + suite.NoError(err) + + err = suite.keeper.SetNFTUri(suite.ctx, owner2, collectionDenom2, testNft2.TokenId, "ipfs://new-uri.json") + suite.Error(err) + suite.Contains(err.Error(), "no authority, cannot set NFT uri") +} diff --git a/x/nft/keeper/msg_server.go b/x/nft/keeper/msg_server.go new file mode 100644 index 00000000..1847e463 --- /dev/null +++ b/x/nft/keeper/msg_server.go @@ -0,0 +1,103 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + "github.com/bitsongofficial/go-bitsong/x/nft/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +type msgServer struct { + Keeper +} + +var _ types.MsgServer = msgServer{} + +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return msgServer{Keeper: keeper} +} + +func (k msgServer) CreateCollection(goCtx context.Context, msg *types.MsgCreateCollection) (*types.MsgCreateCollectionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + denom, err := k.Keeper.CreateCollection(ctx, msg.Creator, msg.Minter, msg.Authority, msg.Symbol, msg.Name, msg.Uri) + if err != nil { + return nil, err + } + + return &types.MsgCreateCollectionResponse{ + Denom: denom, + }, nil +} + +func (k msgServer) MintNFT(goCtx context.Context, msg *types.MsgMintNFT) (*types.MsgMintNFTResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + minter, err := k.ac.StringToBytes(msg.Minter) + if err != nil { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid minter address: %s", err) + } + + recipient, err := k.ac.StringToBytes(msg.Recipient) + if err != nil { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) + } + + err = k.Keeper.MintNFT(ctx, minter, recipient, msg.Collection, msg.TokenId, msg.Name, msg.Uri) + if err != nil { + return nil, err + } + + return &types.MsgMintNFTResponse{ + Collection: msg.Collection, + TokenId: msg.TokenId, + }, nil +} + +func (k msgServer) SendNFT(goCtx context.Context, msg *types.MsgSendNFT) (*types.MsgSendNFTResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + sender, err := k.ac.StringToBytes(msg.Sender) + if err != nil { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) + } + + recipient, err := k.ac.StringToBytes(msg.Recipient) + if err != nil { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) + } + + err = k.Keeper.SendNFT(ctx, sender, recipient, msg.Collection, msg.TokenId) + if err != nil { + return nil, err + } + + return &types.MsgSendNFTResponse{}, nil +} + +func (k msgServer) PrintEdition(goCtx context.Context, msg *types.MsgPrintEdition) (*types.MsgPrintEditionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + minter, err := k.ac.StringToBytes(msg.Minter) + if err != nil { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid minter address: %s", err) + } + + recipient, err := k.ac.StringToBytes(msg.Recipient) + if err != nil { + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) + } + + seq, err := k.Keeper.PrintEdition(ctx, minter, recipient, msg.Collection, msg.TokenId) + if err != nil { + return nil, err + } + + return &types.MsgPrintEditionResponse{ + Collection: msg.Collection, + TokenId: msg.TokenId, + Seq: seq, + }, nil +} diff --git a/x/nft/keeper/msg_server_test.go b/x/nft/keeper/msg_server_test.go new file mode 100644 index 00000000..87e5a4de --- /dev/null +++ b/x/nft/keeper/msg_server_test.go @@ -0,0 +1,524 @@ +package keeper_test + +import ( + "github.com/bitsongofficial/go-bitsong/x/nft/types" +) + +func (suite *KeeperTestSuite) TestMsgCreateCollection() { + testCases := []struct { + name string + msg *types.MsgCreateCollection + expectError bool + expectedErrorMsg string + }{ + { + name: "valid message", + msg: &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol + "0", + Uri: testCollection1.Uri, + }, + }, + { + name: "invalid creator address", + msg: &types.MsgCreateCollection{ + Creator: "invalid_address", + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + }, + expectError: true, + expectedErrorMsg: "invalid creator address: decoding bech32 failed", + }, + { + name: "should fail on empty creator address", + msg: &types.MsgCreateCollection{ + Creator: "", + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + }, + expectError: true, + expectedErrorMsg: "invalid creator address: empty address string", + }, + { + name: "invalid minter address", + msg: &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: "invalid_address", + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + }, + expectError: true, + expectedErrorMsg: "invalid minter address: decoding bech32 failed", + }, + { + name: "valid empty minter address", + msg: &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: "", + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + }, + }, + { + name: "should fail on empty symbol", + msg: &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: "", + Uri: testCollection1.Uri, + }, + expectError: true, + expectedErrorMsg: "symbol cannot be empty", + }, + { + name: "valid on empty name", + msg: &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: "", + Symbol: testCollection1.Symbol + "1", + Uri: testCollection1.Uri, + }, + }, + { + name: "valid on empty uri", + msg: &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol + "2", + Uri: "", + }, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + _, err := suite.msgServer.CreateCollection(suite.ctx, tc.msg) + if tc.expectError { + suite.Require().Error(err) + if tc.expectedErrorMsg != "" { + suite.Require().Contains(err.Error(), tc.expectedErrorMsg) + } + } else { + suite.Require().NoError(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestMsgMintNFT() { + // first create a collection to mint into + createCollectionMsg := &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + } + res, err := suite.msgServer.CreateCollection(suite.ctx, createCollectionMsg) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().NotEmpty(res.Denom) + + testCases := []struct { + name string + msg *types.MsgMintNFT + expectError bool + expectedErrorMsg string + }{ + { + name: "valid message", + msg: &types.MsgMintNFT{ + Minter: minter1.String(), + Recipient: owner1.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + Name: testNft1.Name, + Uri: testNft1.Uri, + }, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + _, err := suite.msgServer.MintNFT(suite.ctx, tc.msg) + if tc.expectError { + suite.Require().Error(err) + if tc.expectedErrorMsg != "" { + suite.Require().Contains(err.Error(), tc.expectedErrorMsg) + } + } else { + suite.Require().NoError(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestMsgMintNFT_MaxLimit() { + createCollectionMsg := &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + } + res, err := suite.msgServer.CreateCollection(suite.ctx, createCollectionMsg) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().NotEmpty(res.Denom) + + for i := 0; i < types.MaxNftsInCollection; i++ { + mintMsg := &types.MsgMintNFT{ + Minter: minter1.String(), + Recipient: owner1.String(), + Collection: res.Denom, + TokenId: "token" + string(rune(i)), + Name: "Token " + string(rune(i)), + Uri: "http://example.com/token" + string(rune(i)), + } + _, err := suite.msgServer.MintNFT(suite.ctx, mintMsg) + suite.Require().NoError(err) + } + + // attempt to mint one more NFT beyond the limit + mintMsg := &types.MsgMintNFT{ + Minter: minter1.String(), + Recipient: owner1.String(), + Collection: res.Denom, + TokenId: "token_overflow", + Name: "Token Overflow", + Uri: "http://example.com/token_overflow", + } + _, err = suite.msgServer.MintNFT(suite.ctx, mintMsg) + suite.Require().Error(err) + suite.Require().Contains(err.Error(), "max supply reached") +} + +func (suite *KeeperTestSuite) TestMsgSendNFT() { + createCollectionMsg := &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + } + res, err := suite.msgServer.CreateCollection(suite.ctx, createCollectionMsg) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().NotEmpty(res.Denom) + + mintMsg := &types.MsgMintNFT{ + Minter: minter1.String(), + Recipient: owner1.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + Name: testNft1.Name, + Uri: testNft1.Uri, + } + _, err = suite.msgServer.MintNFT(suite.ctx, mintMsg) + suite.Require().NoError(err) + + testCases := []struct { + name string + msg *types.MsgSendNFT + expectError bool + expectedErrorMsg string + }{ + { + name: "valid message", + msg: &types.MsgSendNFT{ + Sender: owner1.String(), + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + }, + { + name: "should fail on same sender and recipient", + msg: &types.MsgSendNFT{ + Sender: owner1.String(), + Recipient: owner1.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "cannot transfer NFT to the same owner", + }, + { + name: "invalid sender address", + msg: &types.MsgSendNFT{ + Sender: "invalid_address", + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid sender address: decoding bech32 failed", + }, + { + name: "should fail on empty sender address", + msg: &types.MsgSendNFT{ + Sender: "", + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid sender address: empty address string", + }, + { + name: "invalid recipient address", + msg: &types.MsgSendNFT{ + Sender: owner1.String(), + Recipient: "invalid_address", + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid recipient address: decoding bech32 failed", + }, + { + name: "should fail on empty recipient address", + msg: &types.MsgSendNFT{ + Sender: owner1.String(), + Recipient: "", + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid recipient address: empty address string", + }, + { + name: "should fail on non existing collection", + msg: &types.MsgSendNFT{ + Sender: owner1.String(), + Recipient: owner2.String(), + Collection: "non_existing_collection", + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "collection or token_id does not exist", + }, + { + name: "should fail on non existing token", + msg: &types.MsgSendNFT{ + Sender: owner1.String(), + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: "non_existing_token", + }, + expectError: true, + expectedErrorMsg: "collection or token_id does not exist", + }, + { + name: "should fail when sender is not the owner", + msg: &types.MsgSendNFT{ + Sender: owner1.String(), + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "only the owner can transfer the NFT", + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + _, err := suite.msgServer.SendNFT(suite.ctx, tc.msg) + if tc.expectError { + suite.Require().Error(err) + if tc.expectedErrorMsg != "" { + suite.Require().Contains(err.Error(), tc.expectedErrorMsg) + } + } else { + suite.Require().NoError(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestMsgPrintEdition() { + createCollectionMsg := &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol + "3", + Uri: testCollection1.Uri, + } + res, err := suite.msgServer.CreateCollection(suite.ctx, createCollectionMsg) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().NotEmpty(res.Denom) + + mintMsg := &types.MsgMintNFT{ + Minter: minter1.String(), + Recipient: owner1.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + Name: testNft1.Name, + Uri: testNft1.Uri, + } + _, err = suite.msgServer.MintNFT(suite.ctx, mintMsg) + suite.Require().NoError(err) + + testCases := []struct { + name string + msg *types.MsgPrintEdition + expectError bool + expectedErrorMsg string + }{ + { + name: "valid message", + msg: &types.MsgPrintEdition{ + Minter: minter1.String(), + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + }, + { + name: "invalid minter address", + msg: &types.MsgPrintEdition{ + Minter: "invalid_address", + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid minter address: decoding bech32 failed", + }, + { + name: "should fail on empty minter address", + msg: &types.MsgPrintEdition{ + Minter: "", + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid minter address: empty address string", + }, + { + name: "invalid recipient address", + msg: &types.MsgPrintEdition{ + Minter: minter1.String(), + Recipient: "invalid_address", + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid recipient address: decoding bech32 failed", + }, + { + name: "should fail on empty recipient address", + msg: &types.MsgPrintEdition{ + Minter: minter1.String(), + Recipient: "", + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "invalid recipient address: empty address string", + }, + { + name: "should fail on non existing collection", + msg: &types.MsgPrintEdition{ + Minter: minter1.String(), + Recipient: owner2.String(), + Collection: "non_existing_collection", + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "NFT with token ID", + }, + { + name: "should fail on non existing token", + msg: &types.MsgPrintEdition{ + Minter: minter1.String(), + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: "non_existing_token", + }, + expectError: true, + expectedErrorMsg: "NFT with token ID", + }, + { + name: "should fail when minter is not the collection minter", + msg: &types.MsgPrintEdition{ + Minter: creator1.String(), + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + }, + expectError: true, + expectedErrorMsg: "only the collection minter can print editions", + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + _, err := suite.msgServer.PrintEdition(suite.ctx, tc.msg) + if tc.expectError { + suite.Require().Error(err) + if tc.expectedErrorMsg != "" { + suite.Require().Contains(err.Error(), tc.expectedErrorMsg) + } + } else { + suite.Require().NoError(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestMsgPrintNFT_MaxLimit() { + createCollectionMsg := &types.MsgCreateCollection{ + Creator: creator1.String(), + Minter: minter1.String(), + Name: testCollection1.Name, + Symbol: testCollection1.Symbol, + Uri: testCollection1.Uri, + } + res, err := suite.msgServer.CreateCollection(suite.ctx, createCollectionMsg) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().NotEmpty(res.Denom) + + mintMsg := &types.MsgMintNFT{ + Minter: minter1.String(), + Recipient: owner1.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + Name: testNft1.Name, + Uri: testNft1.Uri, + } + _, err = suite.msgServer.MintNFT(suite.ctx, mintMsg) + suite.Require().NoError(err) + + printEditionMsg := &types.MsgPrintEdition{ + Minter: minter1.String(), + Recipient: owner2.String(), + Collection: res.Denom, + TokenId: testNft1.TokenId, + } + + for i := 0; i < types.MaxEditions; i++ { + _, err := suite.msgServer.PrintEdition(suite.ctx, printEditionMsg) + suite.Require().NoError(err) + } + + // attempt to print one more edition beyond the limit + _, err = suite.msgServer.PrintEdition(suite.ctx, printEditionMsg) + suite.Require().Error(err) + suite.Require().Contains(err.Error(), "max editions reached") +} diff --git a/x/nft/keeper/nft.go b/x/nft/keeper/nft.go new file mode 100644 index 00000000..0423db60 --- /dev/null +++ b/x/nft/keeper/nft.go @@ -0,0 +1,270 @@ +package keeper + +import ( + "context" + "fmt" + "strings" + + "cosmossdk.io/collections" + "cosmossdk.io/math" + "github.com/bitsongofficial/go-bitsong/x/nft/types" + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) MintNFT( + ctx context.Context, + minter sdk.AccAddress, + owner sdk.AccAddress, + collectionDenom, + tokenId, + name, + uri string, +) error { + if err := k.validateNftMetadata(tokenId, name, uri); err != nil { + return err + } + + nftKey := collections.Join(collectionDenom, tokenId) + has, err := k.NFTs.Has(ctx, nftKey) + if err != nil { + return fmt.Errorf("failed to check NFT: %w", err) + } + if has { + return fmt.Errorf("NFT with token ID %s already exists in collection %s", tokenId, collectionDenom) + } + + coll, err := k.Collections.Get(ctx, collectionDenom) + if err != nil { + return types.ErrCollectionNotFound + } + + if coll.Minter == "" { + return fmt.Errorf("minting disabled for this collection") + } + + collectionMinter, err := sdk.AccAddressFromBech32(coll.Minter) + if err != nil { + return fmt.Errorf("invalid minter address: %w", err) + } + + if !minter.Equals(collectionMinter) { + return fmt.Errorf("only the collection minter can mint NFTs") + } + + supply := k.GetSupply(ctx, collectionDenom) + if supply.Equal(math.NewInt(types.MaxNftsInCollection)) { + return fmt.Errorf("max supply reached for collection %s", collectionDenom) + } + + // TODO: Charge fee if necessary + + nft := types.Nft{ + Collection: collectionDenom, + TokenId: tokenId, + Name: name, + Uri: uri, + Owner: owner.String(), + Editions: 0, + } + + if err := k.setNft(ctx, nft); err != nil { + return fmt.Errorf("failed to set NFT: %w", err) + } + + // TODO: add events + + return k.incrementSupply(ctx, collectionDenom) +} + +func (k Keeper) SendNFT(ctx context.Context, fromAddr, toAddr sdk.AccAddress, collectionDenom, tokenId string) error { + err := k.changeNftOwner(ctx, fromAddr, toAddr, collectionDenom, tokenId) + if err != nil { + return err + } + + // Same as https://github.com/cosmos/cosmos-sdk/blob/v0.53.4/x/bank/keeper/send.go + // Create account if recipient does not exist. + // + // NOTE: This should ultimately be removed in favor a more flexible approach + // such as delegated fee messages. + accExists := k.ak.HasAccount(ctx, toAddr) + if !accExists { + defer telemetry.IncrCounter(1, "new", "account") + k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, toAddr)) + } + + // Same as https://github.com/cosmos/cosmos-sdk/blob/v0.53.4/x/bank/keeper/send.go + // bech32 encoding is expensive! Only do it once for fromAddr + fromAddrString := fromAddr.String() + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeTransferNft, + sdk.NewAttribute(types.AttributeKeyReceiver, toAddr.String()), + sdk.NewAttribute(types.AttributeKeySender, fromAddrString), + sdk.NewAttribute(types.AttributeKeyCollection, collectionDenom), + sdk.NewAttribute(types.AttributeKeyTokenId, tokenId), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(types.AttributeKeySender, fromAddrString), + ), + }) + + return nil +} + +func (k Keeper) SetNFTName(ctx context.Context, authority sdk.AccAddress, collectionDenom, tokenId, name string) error { + coll, err := k.Collections.Get(ctx, collectionDenom) + if err != nil { + return types.ErrCollectionNotFound + } + + if coll.Authority == "" { + return fmt.Errorf("no authority, cannot set NFT name") + } + + collectionAuthority, err := sdk.AccAddressFromBech32(coll.Authority) + if err != nil { + return fmt.Errorf("invalid authority address: %w", err) + } + + if !authority.Equals(collectionAuthority) { + return fmt.Errorf("only the collection authority can set NFT name") + } + + nft, err := k.GetNft(ctx, collectionDenom, tokenId) + if err != nil { + return err + } + + err = k.validateNftMetadata(tokenId, name, nft.Uri) + if err != nil { + return err + } + + nft.Name = name + return k.setNft(ctx, *nft) +} + +func (k Keeper) SetNFTUri(ctx context.Context, authority sdk.AccAddress, collectionDenom, tokenId, uri string) error { + coll, err := k.Collections.Get(ctx, collectionDenom) + if err != nil { + return types.ErrCollectionNotFound + } + + if coll.Authority == "" { + return fmt.Errorf("no authority, cannot set NFT uri") + } + + collectionAuthority, err := sdk.AccAddressFromBech32(coll.Authority) + if err != nil { + return fmt.Errorf("invalid authority address: %w", err) + } + + if !authority.Equals(collectionAuthority) { + return fmt.Errorf("only the collection authority can set NFT uri") + } + + nft, err := k.GetNft(ctx, collectionDenom, tokenId) + if err != nil { + return err + } + + err = k.validateNftMetadata(tokenId, nft.Name, uri) + if err != nil { + return err + } + + nft.Uri = uri + return k.setNft(ctx, *nft) +} + +func (k Keeper) GetNft(ctx context.Context, collectionDenom, tokenId string) (*types.Nft, error) { + nftKey := collections.Join(collectionDenom, tokenId) + has, err := k.NFTs.Has(ctx, nftKey) + if err != nil { + return nil, fmt.Errorf("failed to check NFT: %w", err) + } + if !has { + return nil, fmt.Errorf("NFT with token ID %s does not exist in collection %s", tokenId, collectionDenom) + } + + nft, err := k.NFTs.Get(ctx, nftKey) + if err != nil { + return nil, fmt.Errorf("failed to get NFT: %w", err) + } + + return &nft, nil +} + +func (k Keeper) validateNftMetadata(tokenId, name, uri string) error { + if strings.TrimSpace(tokenId) == "" { + return fmt.Errorf("token ID cannot be empty") + } + + if len(tokenId) > types.MaxTokenIdLength { + return fmt.Errorf("token ID length exceeds maximum of %d", types.MaxTokenIdLength) + } + + if len(name) > types.MaxNameLength { + return fmt.Errorf("name length exceeds maximum of %d", types.MaxNameLength) + + } + + if len(uri) > types.MaxURILength { + return fmt.Errorf("URI length exceeds maximum of %d", types.MaxURILength) + } + + return nil +} + +func (k Keeper) createNftDenom(ctx context.Context, collectionDenom string) string { + supply := k.GetSupply(ctx, collectionDenom) + return fmt.Sprintf("%s-%d", collectionDenom, supply.Uint64()+1) +} + +func (k Keeper) setNft(ctx context.Context, nft types.Nft) error { + pk := collections.Join(nft.Collection, nft.TokenId) + return k.NFTs.Set(ctx, pk, nft) +} + +func (k Keeper) changeNftOwner(ctx context.Context, oldOwner, newOwner sdk.AccAddress, collectionDenom string, tokenId string) error { + if oldOwner.Equals(newOwner) { + return fmt.Errorf("cannot transfer NFT to the same owner") + } + + nft, err := k.NFTs.Get(ctx, collections.Join(collectionDenom, tokenId)) + if err != nil { + return fmt.Errorf("collection or token_id does not exist") + } + + if nft.Owner != oldOwner.String() { + return fmt.Errorf("only the owner can transfer the NFT") + } + + nft.Owner = newOwner.String() + err = k.setNft(ctx, nft) + if err != nil { + return fmt.Errorf("failed to set NFT Owner: %w", err) + } + + // emit nft received event + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvent( + types.NewNftReceivedEvent(newOwner, collectionDenom, tokenId), + ) + + return nil +} + +func (k Keeper) incrementEdition(ctx context.Context, collectionDenom, tokenId string) error { + nft, err := k.NFTs.Get(ctx, collections.Join(collectionDenom, tokenId)) + if err != nil { + return fmt.Errorf("failed to get NFT: %w", err) + } + + nft.Editions += 1 + return k.setNft(ctx, nft) +} diff --git a/x/nft/types/errors.go b/x/nft/types/errors.go new file mode 100644 index 00000000..7ba37f21 --- /dev/null +++ b/x/nft/types/errors.go @@ -0,0 +1,8 @@ +package types + +import sdkerrors "cosmossdk.io/errors" + +var ( + ErrCollectionAlreadyExists = sdkerrors.Register(ModuleName, 1, "invalid collection: already exists") + ErrCollectionNotFound = sdkerrors.Register(ModuleName, 2, "invalid collection: not found") +) diff --git a/x/nft/types/events.go b/x/nft/types/events.go new file mode 100644 index 00000000..f8c85f16 --- /dev/null +++ b/x/nft/types/events.go @@ -0,0 +1,23 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +const ( + EventTypeTransferNft = "transfer_nft" + EventTypeNftReceived = "nft_received" + + AttributeKeySender = "sender" + AttributeKeyReceiver = "receiver" + + AttributeKeyCollection = "collection" + AttributeKeyTokenId = "token_id" +) + +func NewNftReceivedEvent(receiver sdk.AccAddress, collection string, tokenId string) sdk.Event { + return sdk.NewEvent( + EventTypeNftReceived, + sdk.NewAttribute(AttributeKeyReceiver, receiver.String()), + sdk.NewAttribute(AttributeKeyCollection, collection), + sdk.NewAttribute(AttributeKeyTokenId, tokenId), + ) +} diff --git a/x/nft/types/expected_keeper.go b/x/nft/types/expected_keeper.go new file mode 100644 index 00000000..b816d2c6 --- /dev/null +++ b/x/nft/types/expected_keeper.go @@ -0,0 +1,17 @@ +package types + +import ( + "context" + + "cosmossdk.io/core/address" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type AccountKeeper interface { + GetModuleAddress(moduleName string) sdk.AccAddress + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + AddressCodec() address.Codec + HasAccount(ctx context.Context, addr sdk.AccAddress) bool + SetAccount(ctx context.Context, acc sdk.AccountI) + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI +} diff --git a/x/nft/types/keys.go b/x/nft/types/keys.go new file mode 100644 index 00000000..816b570f --- /dev/null +++ b/x/nft/types/keys.go @@ -0,0 +1,67 @@ +package types + +import ( + "bytes" + "fmt" + + "cosmossdk.io/collections" + "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + ModuleName = "nft" + StoreKey = ModuleName + RouterKey = ModuleName + + MaxDenomLength = 43 + + MaxTokenIdLength = 20 + MaxSymbolLength = 15 + MaxNameLength = 128 + MaxURILength = 150 + + // TODO: move these to params + MaxNftsInCollection = 100 + MaxEditions = 1000 +) + +var ( + CollectionsPrefix = collections.NewPrefix(0) + SupplyPrefix = collections.NewPrefix(1) + NFTsPrefix = collections.NewPrefix(2) + NFTsByCollectionPrefix = collections.NewPrefix(3) + NFTsByOwnerPrefix = collections.NewPrefix(4) + EditionsPrefix = collections.NewPrefix(5) +) + +func SplitNftLengthPrefixedKey(key []byte) (denom, tokenId []byte, err error) { + parts := bytes.SplitN(key, []byte{0}, 2) + if len(parts) != 2 { + return nil, nil, fmt.Errorf("invalid composite key format: expected 2 parts, got %d", len(parts)) + } + + denomLen := len(parts[0]) + + if denomLen > MaxDenomLength { + return nil, nil, errors.Wrapf(sdkerrors.ErrInvalidType, "decoded denom key length %d exceeds max allowed length %d", denomLen, MaxDenomLength) + } + + if len(key)-1 < denomLen { + return nil, nil, fmt.Errorf("key is malformed: length prefix %d is greater than tokenId bytes %d", denomLen, len(key)-1) + } + + denom = parts[0] + tokenId = parts[1] + + return denom, tokenId, nil +} + +func MustSplitNftLengthPrefixedKey(key []byte) (denom, tokenId []byte) { + denom, tokenId, err := SplitNftLengthPrefixedKey(key) + if err != nil { + panic(err) + } + + return denom, tokenId +} diff --git a/x/nft/types/keys_test.go b/x/nft/types/keys_test.go new file mode 100644 index 00000000..c73217c6 --- /dev/null +++ b/x/nft/types/keys_test.go @@ -0,0 +1,19 @@ +package types_test + +import ( + "testing" + + "github.com/bitsongofficial/go-bitsong/x/nft/types" + "github.com/stretchr/testify/require" +) + +func TestSplitNftLengthPrefixedKey(t *testing.T) { + denom := "nft653AF6715F0C4EE2E24A54B191EBD0AD5DB33723" + tokenId := "1" + + keyBz := append(append([]byte(denom), 0), []byte(tokenId)...) + + denomBz, tokenIdBz := types.MustSplitNftLengthPrefixedKey(keyBz) + require.Equal(t, denom, string(denomBz)) + require.Equal(t, tokenId, string(tokenIdBz)) +} diff --git a/x/nft/types/nft.pb.go b/x/nft/types/nft.pb.go new file mode 100644 index 00000000..0a113944 --- /dev/null +++ b/x/nft/types/nft.pb.go @@ -0,0 +1,1262 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: bitsong/nft/v1beta1/nft.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 + +type Collection struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + Symbol string `protobuf:"bytes,2,opt,name=symbol,proto3" json:"symbol,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"` + Creator string `protobuf:"bytes,6,opt,name=creator,proto3" json:"creator,omitempty"` + Minter string `protobuf:"bytes,7,opt,name=minter,proto3" json:"minter,omitempty"` + Authority string `protobuf:"bytes,8,opt,name=authority,proto3" json:"authority,omitempty"` + NumTokens uint64 `protobuf:"varint,9,opt,name=num_tokens,json=numTokens,proto3" json:"num_tokens,omitempty"` +} + +func (m *Collection) Reset() { *m = Collection{} } +func (m *Collection) String() string { return proto.CompactTextString(m) } +func (*Collection) ProtoMessage() {} +func (*Collection) Descriptor() ([]byte, []int) { + return fileDescriptor_51b0314c164430ab, []int{0} +} +func (m *Collection) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Collection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Collection.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 *Collection) XXX_Merge(src proto.Message) { + xxx_messageInfo_Collection.Merge(m, src) +} +func (m *Collection) XXX_Size() int { + return m.Size() +} +func (m *Collection) XXX_DiscardUnknown() { + xxx_messageInfo_Collection.DiscardUnknown(m) +} + +var xxx_messageInfo_Collection proto.InternalMessageInfo + +type Nft struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"` + Owner string `protobuf:"bytes,6,opt,name=owner,proto3" json:"owner,omitempty"` + // TODO: add max_editions + // uint64 max_editions = 8; // max number of printed editions, 0 means no limit + Editions uint64 `protobuf:"varint,7,opt,name=editions,proto3" json:"editions,omitempty"` +} + +func (m *Nft) Reset() { *m = Nft{} } +func (m *Nft) String() string { return proto.CompactTextString(m) } +func (*Nft) ProtoMessage() {} +func (*Nft) Descriptor() ([]byte, []int) { + return fileDescriptor_51b0314c164430ab, []int{1} +} +func (m *Nft) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Nft) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Nft.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 *Nft) XXX_Merge(src proto.Message) { + xxx_messageInfo_Nft.Merge(m, src) +} +func (m *Nft) XXX_Size() int { + return m.Size() +} +func (m *Nft) XXX_DiscardUnknown() { + xxx_messageInfo_Nft.DiscardUnknown(m) +} + +var xxx_messageInfo_Nft proto.InternalMessageInfo + +type Edition struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + Seq uint64 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *Edition) Reset() { *m = Edition{} } +func (m *Edition) String() string { return proto.CompactTextString(m) } +func (*Edition) ProtoMessage() {} +func (*Edition) Descriptor() ([]byte, []int) { + return fileDescriptor_51b0314c164430ab, []int{2} +} +func (m *Edition) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Edition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Edition.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 *Edition) XXX_Merge(src proto.Message) { + xxx_messageInfo_Edition.Merge(m, src) +} +func (m *Edition) XXX_Size() int { + return m.Size() +} +func (m *Edition) XXX_DiscardUnknown() { + xxx_messageInfo_Edition.DiscardUnknown(m) +} + +var xxx_messageInfo_Edition proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Collection)(nil), "bitsong.nft.v1beta1.Collection") + proto.RegisterType((*Nft)(nil), "bitsong.nft.v1beta1.Nft") + proto.RegisterType((*Edition)(nil), "bitsong.nft.v1beta1.Edition") +} + +func init() { proto.RegisterFile("bitsong/nft/v1beta1/nft.proto", fileDescriptor_51b0314c164430ab) } + +var fileDescriptor_51b0314c164430ab = []byte{ + // 382 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xbd, 0x6a, 0xe3, 0x40, + 0x14, 0x85, 0x35, 0x2b, 0xd9, 0xb2, 0x6e, 0x65, 0x66, 0xcd, 0x32, 0x6b, 0xd6, 0x5a, 0xe3, 0xca, + 0xcd, 0x5a, 0x98, 0xed, 0xb6, 0xdc, 0x65, 0x8b, 0x65, 0x21, 0x85, 0x48, 0x95, 0xc6, 0xe8, 0x67, + 0x24, 0x0f, 0x91, 0xe6, 0x3a, 0xd2, 0x28, 0x89, 0xdf, 0x20, 0x65, 0x9e, 0x20, 0xe4, 0x71, 0x52, + 0xba, 0x09, 0xa4, 0x0c, 0xf6, 0x8b, 0x04, 0x8d, 0xe4, 0x9f, 0x32, 0x90, 0xee, 0x9c, 0xef, 0x0e, + 0x77, 0xce, 0x81, 0x0b, 0xa3, 0x50, 0xa8, 0x12, 0x65, 0xea, 0xc9, 0x44, 0x79, 0xd7, 0xf3, 0x90, + 0xab, 0x60, 0x5e, 0xeb, 0xd9, 0xaa, 0x40, 0x85, 0xf4, 0x73, 0x3b, 0x9e, 0xd5, 0xa8, 0x1d, 0x0f, + 0x07, 0x29, 0xa6, 0xa8, 0xe7, 0x5e, 0xad, 0x9a, 0xa7, 0x93, 0x67, 0x02, 0xf0, 0x07, 0xb3, 0x8c, + 0x47, 0x4a, 0xa0, 0xa4, 0x03, 0xe8, 0xc4, 0x5c, 0x62, 0xce, 0xc8, 0x98, 0x4c, 0x1d, 0xbf, 0x31, + 0xf4, 0x0b, 0x74, 0xcb, 0x75, 0x1e, 0x62, 0xc6, 0x3e, 0x69, 0xdc, 0x3a, 0x4a, 0xc1, 0x92, 0x41, + 0xce, 0x99, 0xa9, 0xa9, 0xd6, 0xb4, 0x0f, 0x66, 0x55, 0x08, 0xd6, 0xd1, 0xa8, 0x96, 0x94, 0x81, + 0x1d, 0x15, 0x3c, 0x50, 0x58, 0xb0, 0xae, 0xa6, 0x7b, 0x5b, 0xef, 0xcd, 0x85, 0x54, 0xbc, 0x60, + 0x76, 0xb3, 0xb7, 0x71, 0xf4, 0x1b, 0x38, 0x41, 0xa5, 0x96, 0x58, 0x08, 0xb5, 0x66, 0x3d, 0x3d, + 0x3a, 0x02, 0x3a, 0x02, 0x90, 0x55, 0xbe, 0x50, 0x78, 0xc9, 0x65, 0xc9, 0x9c, 0x31, 0x99, 0x5a, + 0xbe, 0x23, 0xab, 0xfc, 0x5c, 0x83, 0x5f, 0xd6, 0xdd, 0xe3, 0x77, 0x63, 0xf2, 0x40, 0xc0, 0x3c, + 0x4b, 0x14, 0x75, 0x01, 0xa2, 0x43, 0xbd, 0xb6, 0xd5, 0x09, 0xa1, 0x5f, 0xa1, 0xa7, 0x17, 0x2d, + 0x44, 0xdc, 0x96, 0xb3, 0xb5, 0xff, 0x17, 0xbf, 0xb3, 0xdd, 0x00, 0x3a, 0x78, 0x23, 0xf9, 0xbe, + 0x5b, 0x63, 0xe8, 0x10, 0x7a, 0x3c, 0x16, 0xf5, 0x0f, 0xa5, 0xee, 0x66, 0xf9, 0x07, 0xdf, 0x06, + 0x2c, 0xc0, 0xfe, 0xdb, 0x90, 0x8f, 0x64, 0xec, 0x83, 0x59, 0xf2, 0x2b, 0x1d, 0xd1, 0xf2, 0x6b, + 0x79, 0xcc, 0x63, 0x9d, 0xe4, 0x69, 0xfe, 0xfc, 0xfd, 0xff, 0x69, 0xeb, 0x92, 0xcd, 0xd6, 0x25, + 0xaf, 0x5b, 0x97, 0xdc, 0xef, 0x5c, 0x63, 0xb3, 0x73, 0x8d, 0x97, 0x9d, 0x6b, 0x5c, 0xcc, 0x53, + 0xa1, 0x96, 0x55, 0x38, 0x8b, 0x30, 0xf7, 0xda, 0xe3, 0xc1, 0x24, 0x11, 0x91, 0x08, 0x32, 0x2f, + 0xc5, 0x1f, 0xfb, 0x73, 0xbb, 0xd5, 0x07, 0xa7, 0xd6, 0x2b, 0x5e, 0x86, 0x5d, 0x7d, 0x40, 0x3f, + 0xdf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x51, 0x12, 0x7d, 0x2e, 0x8c, 0x02, 0x00, 0x00, +} + +func (m *Collection) 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 *Collection) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Collection) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumTokens != 0 { + i = encodeVarintNft(dAtA, i, uint64(m.NumTokens)) + i-- + dAtA[i] = 0x48 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintNft(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x42 + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintNft(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0x3a + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintNft(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x32 + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintNft(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x2a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintNft(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintNft(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0x12 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintNft(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Nft) 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 *Nft) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Nft) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Editions != 0 { + i = encodeVarintNft(dAtA, i, uint64(m.Editions)) + i-- + dAtA[i] = 0x38 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintNft(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x32 + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintNft(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x2a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintNft(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintNft(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintNft(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Edition) 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 *Edition) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Edition) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintNft(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if m.Seq != 0 { + i = encodeVarintNft(dAtA, i, uint64(m.Seq)) + i-- + dAtA[i] = 0x18 + } + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintNft(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintNft(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintNft(dAtA []byte, offset int, v uint64) int { + offset -= sovNft(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Collection) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + if m.NumTokens != 0 { + n += 1 + sovNft(uint64(m.NumTokens)) + } + return n +} + +func (m *Nft) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + if m.Editions != 0 { + n += 1 + sovNft(uint64(m.Editions)) + } + return n +} + +func (m *Edition) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + if m.Seq != 0 { + n += 1 + sovNft(uint64(m.Seq)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + return n +} + +func sovNft(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozNft(x uint64) (n int) { + return sovNft(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Collection) 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 ErrIntOverflowNft + } + 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: Collection: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Collection: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumTokens", wireType) + } + m.NumTokens = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumTokens |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipNft(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNft + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Nft) 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 ErrIntOverflowNft + } + 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: Nft: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Nft: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Editions", wireType) + } + m.Editions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Editions |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipNft(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNft + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Edition) 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 ErrIntOverflowNft + } + 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: Edition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Edition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Seq", wireType) + } + m.Seq = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Seq |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + 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 ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNft(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNft + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipNft(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, ErrIntOverflowNft + } + 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, ErrIntOverflowNft + } + 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, ErrIntOverflowNft + } + 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, ErrInvalidLengthNft + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupNft + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthNft + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthNft = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowNft = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupNft = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/nft/types/query.pb.go b/x/nft/types/query.pb.go new file mode 100644 index 00000000..a3023e79 --- /dev/null +++ b/x/nft/types/query.pb.go @@ -0,0 +1,2381 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: bitsong/nft/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "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 + +type QueryCollectionRequest struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` +} + +func (m *QueryCollectionRequest) Reset() { *m = QueryCollectionRequest{} } +func (m *QueryCollectionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCollectionRequest) ProtoMessage() {} +func (*QueryCollectionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{0} +} +func (m *QueryCollectionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCollectionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCollectionRequest.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 *QueryCollectionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCollectionRequest.Merge(m, src) +} +func (m *QueryCollectionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCollectionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCollectionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCollectionRequest proto.InternalMessageInfo + +type QueryCollectionResponse struct { + Collection *Collection `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` +} + +func (m *QueryCollectionResponse) Reset() { *m = QueryCollectionResponse{} } +func (m *QueryCollectionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCollectionResponse) ProtoMessage() {} +func (*QueryCollectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{1} +} +func (m *QueryCollectionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCollectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCollectionResponse.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 *QueryCollectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCollectionResponse.Merge(m, src) +} +func (m *QueryCollectionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCollectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCollectionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCollectionResponse proto.InternalMessageInfo + +type QueryOwnerOfRequest struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` +} + +func (m *QueryOwnerOfRequest) Reset() { *m = QueryOwnerOfRequest{} } +func (m *QueryOwnerOfRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOwnerOfRequest) ProtoMessage() {} +func (*QueryOwnerOfRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{2} +} +func (m *QueryOwnerOfRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOwnerOfRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOwnerOfRequest.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 *QueryOwnerOfRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOwnerOfRequest.Merge(m, src) +} +func (m *QueryOwnerOfRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryOwnerOfRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOwnerOfRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOwnerOfRequest proto.InternalMessageInfo + +type QueryOwnerOfResponse struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *QueryOwnerOfResponse) Reset() { *m = QueryOwnerOfResponse{} } +func (m *QueryOwnerOfResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOwnerOfResponse) ProtoMessage() {} +func (*QueryOwnerOfResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{3} +} +func (m *QueryOwnerOfResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOwnerOfResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOwnerOfResponse.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 *QueryOwnerOfResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOwnerOfResponse.Merge(m, src) +} +func (m *QueryOwnerOfResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryOwnerOfResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOwnerOfResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOwnerOfResponse proto.InternalMessageInfo + +type QueryNftInfoRequest struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` +} + +func (m *QueryNftInfoRequest) Reset() { *m = QueryNftInfoRequest{} } +func (m *QueryNftInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNftInfoRequest) ProtoMessage() {} +func (*QueryNftInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{4} +} +func (m *QueryNftInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNftInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNftInfoRequest.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 *QueryNftInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNftInfoRequest.Merge(m, src) +} +func (m *QueryNftInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNftInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNftInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNftInfoRequest proto.InternalMessageInfo + +type QueryNftInfoResponse struct { + Nft *Nft `protobuf:"bytes,1,opt,name=nft,proto3" json:"nft,omitempty"` +} + +func (m *QueryNftInfoResponse) Reset() { *m = QueryNftInfoResponse{} } +func (m *QueryNftInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNftInfoResponse) ProtoMessage() {} +func (*QueryNftInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{5} +} +func (m *QueryNftInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNftInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNftInfoResponse.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 *QueryNftInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNftInfoResponse.Merge(m, src) +} +func (m *QueryNftInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNftInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNftInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNftInfoResponse proto.InternalMessageInfo + +type QueryNftsRequest struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryNftsRequest) Reset() { *m = QueryNftsRequest{} } +func (m *QueryNftsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNftsRequest) ProtoMessage() {} +func (*QueryNftsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{6} +} +func (m *QueryNftsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNftsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNftsRequest.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 *QueryNftsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNftsRequest.Merge(m, src) +} +func (m *QueryNftsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNftsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNftsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNftsRequest proto.InternalMessageInfo + +type QueryNftsResponse struct { + Nfts []Nft `protobuf:"bytes,1,rep,name=nfts,proto3" json:"nfts"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryNftsResponse) Reset() { *m = QueryNftsResponse{} } +func (m *QueryNftsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNftsResponse) ProtoMessage() {} +func (*QueryNftsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{7} +} +func (m *QueryNftsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNftsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNftsResponse.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 *QueryNftsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNftsResponse.Merge(m, src) +} +func (m *QueryNftsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNftsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNftsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNftsResponse proto.InternalMessageInfo + +type QueryAllNftsByOwnerRequest struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllNftsByOwnerRequest) Reset() { *m = QueryAllNftsByOwnerRequest{} } +func (m *QueryAllNftsByOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllNftsByOwnerRequest) ProtoMessage() {} +func (*QueryAllNftsByOwnerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{8} +} +func (m *QueryAllNftsByOwnerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllNftsByOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllNftsByOwnerRequest.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 *QueryAllNftsByOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllNftsByOwnerRequest.Merge(m, src) +} +func (m *QueryAllNftsByOwnerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllNftsByOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllNftsByOwnerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllNftsByOwnerRequest proto.InternalMessageInfo + +type QueryAllNftsByOwnerResponse struct { + Nfts []Nft `protobuf:"bytes,1,rep,name=nfts,proto3" json:"nfts"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllNftsByOwnerResponse) Reset() { *m = QueryAllNftsByOwnerResponse{} } +func (m *QueryAllNftsByOwnerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllNftsByOwnerResponse) ProtoMessage() {} +func (*QueryAllNftsByOwnerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d20ffbceb85197, []int{9} +} +func (m *QueryAllNftsByOwnerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllNftsByOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllNftsByOwnerResponse.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 *QueryAllNftsByOwnerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllNftsByOwnerResponse.Merge(m, src) +} +func (m *QueryAllNftsByOwnerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllNftsByOwnerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllNftsByOwnerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllNftsByOwnerResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryCollectionRequest)(nil), "bitsong.nft.v1beta1.QueryCollectionRequest") + proto.RegisterType((*QueryCollectionResponse)(nil), "bitsong.nft.v1beta1.QueryCollectionResponse") + proto.RegisterType((*QueryOwnerOfRequest)(nil), "bitsong.nft.v1beta1.QueryOwnerOfRequest") + proto.RegisterType((*QueryOwnerOfResponse)(nil), "bitsong.nft.v1beta1.QueryOwnerOfResponse") + proto.RegisterType((*QueryNftInfoRequest)(nil), "bitsong.nft.v1beta1.QueryNftInfoRequest") + proto.RegisterType((*QueryNftInfoResponse)(nil), "bitsong.nft.v1beta1.QueryNftInfoResponse") + proto.RegisterType((*QueryNftsRequest)(nil), "bitsong.nft.v1beta1.QueryNftsRequest") + proto.RegisterType((*QueryNftsResponse)(nil), "bitsong.nft.v1beta1.QueryNftsResponse") + proto.RegisterType((*QueryAllNftsByOwnerRequest)(nil), "bitsong.nft.v1beta1.QueryAllNftsByOwnerRequest") + proto.RegisterType((*QueryAllNftsByOwnerResponse)(nil), "bitsong.nft.v1beta1.QueryAllNftsByOwnerResponse") +} + +func init() { proto.RegisterFile("bitsong/nft/v1beta1/query.proto", fileDescriptor_c3d20ffbceb85197) } + +var fileDescriptor_c3d20ffbceb85197 = []byte{ + // 689 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0xcf, 0x4f, 0x13, 0x41, + 0x14, 0xc7, 0x3b, 0xfc, 0xf6, 0x91, 0x18, 0x1d, 0x88, 0xd6, 0x45, 0xb7, 0xa4, 0x89, 0x88, 0x15, + 0x76, 0xa4, 0x1a, 0x35, 0x1c, 0x44, 0x6b, 0xd4, 0x10, 0x0c, 0x68, 0x8f, 0x5c, 0xc8, 0xb6, 0xec, + 0xae, 0x1b, 0x97, 0x99, 0xc2, 0x0c, 0x28, 0x21, 0x5c, 0x0c, 0x07, 0x8e, 0x26, 0x26, 0x1e, 0x3c, + 0x91, 0xa8, 0x27, 0x3d, 0xf8, 0x67, 0x90, 0x78, 0x21, 0xf1, 0xe2, 0xc9, 0x18, 0x30, 0xd1, 0x3f, + 0xc3, 0xec, 0xec, 0x2c, 0xbb, 0x95, 0x69, 0x29, 0x46, 0x13, 0x4f, 0xed, 0xcc, 0xbc, 0xf9, 0xbe, + 0xcf, 0xbe, 0xfd, 0xbe, 0xb7, 0x90, 0xab, 0xf8, 0x82, 0x33, 0xea, 0x11, 0xea, 0x0a, 0xb2, 0x32, + 0x56, 0x71, 0x84, 0x3d, 0x46, 0x16, 0x97, 0x9d, 0xa5, 0x55, 0xab, 0xb6, 0xc4, 0x04, 0xc3, 0x7d, + 0x2a, 0xc0, 0xa2, 0xae, 0xb0, 0x54, 0x80, 0xd1, 0xef, 0x31, 0x8f, 0xc9, 0x73, 0x12, 0xfe, 0x8b, + 0x42, 0x8d, 0xb3, 0x1e, 0x63, 0x5e, 0xe0, 0x10, 0xbb, 0xe6, 0x13, 0x9b, 0x52, 0x26, 0x6c, 0xe1, + 0x33, 0xca, 0xd5, 0xe9, 0x40, 0x95, 0xf1, 0x05, 0xc6, 0x23, 0x71, 0xb2, 0x52, 0x97, 0xc5, 0x28, + 0xa8, 0xc3, 0x8a, 0xcd, 0x9d, 0xfd, 0x88, 0x08, 0xa6, 0x66, 0x7b, 0x3e, 0x95, 0x4a, 0x2a, 0xf6, + 0x9c, 0x0e, 0x39, 0xa4, 0x93, 0xc7, 0xf9, 0x12, 0x9c, 0x7a, 0x14, 0x0a, 0xdc, 0x61, 0x41, 0xe0, + 0x54, 0xc3, 0x7b, 0x65, 0x67, 0x71, 0xd9, 0xe1, 0x02, 0x9b, 0x00, 0xd5, 0xfd, 0xcd, 0x2c, 0x1a, + 0x44, 0xc3, 0xc7, 0xca, 0xa9, 0x9d, 0xf1, 0x9e, 0xcd, 0xad, 0x5c, 0xe6, 0xe7, 0x56, 0x2e, 0x93, + 0x9f, 0x87, 0xd3, 0x07, 0x34, 0x78, 0x8d, 0x51, 0xee, 0xe0, 0x89, 0x03, 0x22, 0xbd, 0xc5, 0x9c, + 0xa5, 0x29, 0x92, 0x95, 0xba, 0xac, 0xcf, 0x32, 0x0b, 0x7d, 0x32, 0xcb, 0xcc, 0x53, 0xea, 0x2c, + 0xcd, 0xb8, 0x2d, 0x62, 0xe2, 0x33, 0xd0, 0x23, 0xd8, 0x13, 0x87, 0xce, 0xf9, 0xf3, 0xd9, 0x36, + 0x79, 0xda, 0x2d, 0xd7, 0x93, 0xf3, 0x29, 0xed, 0x6b, 0xd0, 0x5f, 0xaf, 0xad, 0xf0, 0xfb, 0xa1, + 0x93, 0x85, 0x5b, 0x4a, 0x37, 0x5a, 0x68, 0x98, 0xa6, 0x5d, 0x31, 0x49, 0x5d, 0xf6, 0x57, 0x99, + 0x1e, 0x28, 0xa6, 0x7d, 0x6d, 0xc5, 0x54, 0x80, 0x76, 0xea, 0x0a, 0x55, 0xcb, 0xac, 0xb6, 0x96, + 0xd3, 0xae, 0x28, 0x87, 0x41, 0x29, 0xb5, 0x0d, 0x04, 0x27, 0x62, 0x39, 0xde, 0x2a, 0xe7, 0x3d, + 0x80, 0xc4, 0x4f, 0x92, 0xb4, 0xb7, 0x38, 0x64, 0x45, 0xe6, 0xb3, 0x42, 0xf3, 0x59, 0x91, 0x2b, + 0xe3, 0xbc, 0x0f, 0x6d, 0xcf, 0x51, 0xda, 0xe5, 0xd4, 0xcd, 0x14, 0xc6, 0x6b, 0x04, 0x27, 0x53, + 0x18, 0xea, 0x91, 0x8a, 0xd0, 0x41, 0x5d, 0xc1, 0xb3, 0x68, 0xb0, 0xbd, 0xd9, 0x33, 0x95, 0x3a, + 0xb6, 0xbf, 0xe6, 0x32, 0x65, 0x19, 0x8b, 0xef, 0x6b, 0xd8, 0x2e, 0x1c, 0xca, 0x16, 0x25, 0x6c, + 0x00, 0xb7, 0x81, 0xc0, 0x90, 0x70, 0xb7, 0x83, 0x20, 0xe4, 0x2b, 0x45, 0x7e, 0x88, 0xab, 0xa5, + 0x35, 0xc3, 0x3f, 0xa8, 0xd1, 0x5b, 0x04, 0x03, 0x5a, 0x8c, 0xff, 0xaa, 0x5a, 0xc5, 0x4f, 0x5d, + 0xd0, 0x29, 0x31, 0xf1, 0x1b, 0x04, 0x90, 0xb4, 0x2f, 0xbe, 0xa4, 0x25, 0xd2, 0x4f, 0x19, 0x63, + 0xa4, 0xb5, 0xe0, 0x88, 0x24, 0x3f, 0xbe, 0xf9, 0xe3, 0x63, 0x01, 0x3d, 0xff, 0xfc, 0xfd, 0x65, + 0x1b, 0xc1, 0xa3, 0x44, 0x37, 0xda, 0x12, 0xfb, 0x72, 0xb2, 0x96, 0x2c, 0xd6, 0xf1, 0x7b, 0x04, + 0xdd, 0xaa, 0xbf, 0xf1, 0x70, 0xe3, 0xac, 0xf5, 0xe3, 0xc5, 0xb8, 0xd8, 0x42, 0xa4, 0x82, 0x9b, + 0x4a, 0xe0, 0x6e, 0xe1, 0x9b, 0x47, 0x82, 0x23, 0x6b, 0xf1, 0x3c, 0x58, 0x27, 0x91, 0xad, 0xde, + 0x21, 0xe8, 0x56, 0x9d, 0xdf, 0x8c, 0xb6, 0x7e, 0xf0, 0x34, 0xa3, 0xfd, 0x6d, 0x8c, 0xe4, 0xef, + 0x26, 0xb4, 0xe3, 0xf8, 0xc6, 0x9f, 0xd2, 0xe2, 0x57, 0x08, 0x3a, 0x42, 0x93, 0xe2, 0xf3, 0x4d, + 0x53, 0xc7, 0x23, 0xc7, 0x18, 0x3a, 0x2c, 0x4c, 0xe1, 0x4d, 0x24, 0x78, 0x57, 0x71, 0xf1, 0x68, + 0x78, 0xd2, 0xf1, 0x1f, 0x10, 0x1c, 0xaf, 0x6f, 0x20, 0x4c, 0x1a, 0xe7, 0xd6, 0x76, 0xbc, 0x71, + 0xb9, 0xf5, 0x0b, 0x0a, 0xfb, 0x7a, 0x82, 0x3d, 0x82, 0x0b, 0xa4, 0xc1, 0xb7, 0x97, 0xcf, 0x55, + 0x56, 0xe7, 0xe4, 0x7b, 0x26, 0x6b, 0xf2, 0x67, 0xbd, 0x34, 0xb5, 0xbd, 0x6b, 0xa2, 0x9d, 0x5d, + 0x13, 0x7d, 0xdb, 0x35, 0xd1, 0x8b, 0x3d, 0x33, 0xb3, 0xb3, 0x67, 0x66, 0xbe, 0xec, 0x99, 0x99, + 0xd9, 0x31, 0xcf, 0x17, 0x8f, 0x97, 0x2b, 0x56, 0x95, 0x2d, 0xc4, 0x7a, 0xcc, 0x75, 0xfd, 0xaa, + 0x6f, 0x07, 0xc4, 0x63, 0xa3, 0x71, 0x8a, 0x67, 0x32, 0x89, 0x58, 0xad, 0x39, 0xbc, 0xd2, 0x25, + 0xbf, 0xed, 0x57, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0x77, 0x92, 0xbd, 0x82, 0xaf, 0x08, 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 { + Collection(ctx context.Context, in *QueryCollectionRequest, opts ...grpc.CallOption) (*QueryCollectionResponse, error) + OwnerOf(ctx context.Context, in *QueryOwnerOfRequest, opts ...grpc.CallOption) (*QueryOwnerOfResponse, error) + NftInfo(ctx context.Context, in *QueryNftInfoRequest, opts ...grpc.CallOption) (*QueryNftInfoResponse, error) + Nfts(ctx context.Context, in *QueryNftsRequest, opts ...grpc.CallOption) (*QueryNftsResponse, error) + AllNftsByOwner(ctx context.Context, in *QueryAllNftsByOwnerRequest, opts ...grpc.CallOption) (*QueryAllNftsByOwnerResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Collection(ctx context.Context, in *QueryCollectionRequest, opts ...grpc.CallOption) (*QueryCollectionResponse, error) { + out := new(QueryCollectionResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Query/Collection", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) OwnerOf(ctx context.Context, in *QueryOwnerOfRequest, opts ...grpc.CallOption) (*QueryOwnerOfResponse, error) { + out := new(QueryOwnerOfResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Query/OwnerOf", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) NftInfo(ctx context.Context, in *QueryNftInfoRequest, opts ...grpc.CallOption) (*QueryNftInfoResponse, error) { + out := new(QueryNftInfoResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Query/NftInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Nfts(ctx context.Context, in *QueryNftsRequest, opts ...grpc.CallOption) (*QueryNftsResponse, error) { + out := new(QueryNftsResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Query/Nfts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AllNftsByOwner(ctx context.Context, in *QueryAllNftsByOwnerRequest, opts ...grpc.CallOption) (*QueryAllNftsByOwnerResponse, error) { + out := new(QueryAllNftsByOwnerResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Query/AllNftsByOwner", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Collection(context.Context, *QueryCollectionRequest) (*QueryCollectionResponse, error) + OwnerOf(context.Context, *QueryOwnerOfRequest) (*QueryOwnerOfResponse, error) + NftInfo(context.Context, *QueryNftInfoRequest) (*QueryNftInfoResponse, error) + Nfts(context.Context, *QueryNftsRequest) (*QueryNftsResponse, error) + AllNftsByOwner(context.Context, *QueryAllNftsByOwnerRequest) (*QueryAllNftsByOwnerResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Collection(ctx context.Context, req *QueryCollectionRequest) (*QueryCollectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Collection not implemented") +} +func (*UnimplementedQueryServer) OwnerOf(ctx context.Context, req *QueryOwnerOfRequest) (*QueryOwnerOfResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OwnerOf not implemented") +} +func (*UnimplementedQueryServer) NftInfo(ctx context.Context, req *QueryNftInfoRequest) (*QueryNftInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NftInfo not implemented") +} +func (*UnimplementedQueryServer) Nfts(ctx context.Context, req *QueryNftsRequest) (*QueryNftsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Nfts not implemented") +} +func (*UnimplementedQueryServer) AllNftsByOwner(ctx context.Context, req *QueryAllNftsByOwnerRequest) (*QueryAllNftsByOwnerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllNftsByOwner not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Collection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCollectionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Collection(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Query/Collection", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Collection(ctx, req.(*QueryCollectionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_OwnerOf_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOwnerOfRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).OwnerOf(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Query/OwnerOf", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).OwnerOf(ctx, req.(*QueryOwnerOfRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_NftInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNftInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NftInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Query/NftInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NftInfo(ctx, req.(*QueryNftInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Nfts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNftsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Nfts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Query/Nfts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Nfts(ctx, req.(*QueryNftsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AllNftsByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllNftsByOwnerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AllNftsByOwner(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Query/AllNftsByOwner", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AllNftsByOwner(ctx, req.(*QueryAllNftsByOwnerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var Query_serviceDesc = _Query_serviceDesc +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "bitsong.nft.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Collection", + Handler: _Query_Collection_Handler, + }, + { + MethodName: "OwnerOf", + Handler: _Query_OwnerOf_Handler, + }, + { + MethodName: "NftInfo", + Handler: _Query_NftInfo_Handler, + }, + { + MethodName: "Nfts", + Handler: _Query_Nfts_Handler, + }, + { + MethodName: "AllNftsByOwner", + Handler: _Query_AllNftsByOwner_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "bitsong/nft/v1beta1/query.proto", +} + +func (m *QueryCollectionRequest) 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 *QueryCollectionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCollectionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCollectionResponse) 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 *QueryCollectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCollectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Collection != nil { + { + size, err := m.Collection.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 *QueryOwnerOfRequest) 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 *QueryOwnerOfRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOwnerOfRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryOwnerOfResponse) 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 *QueryOwnerOfResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOwnerOfResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNftInfoRequest) 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 *QueryNftInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNftInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNftInfoResponse) 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 *QueryNftInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNftInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nft != nil { + { + size, err := m.Nft.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 *QueryNftsRequest) 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 *QueryNftsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNftsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNftsResponse) 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 *QueryNftsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNftsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Nfts) > 0 { + for iNdEx := len(m.Nfts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Nfts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryAllNftsByOwnerRequest) 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 *QueryAllNftsByOwnerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllNftsByOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllNftsByOwnerResponse) 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 *QueryAllNftsByOwnerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllNftsByOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Nfts) > 0 { + for iNdEx := len(m.Nfts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Nfts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func 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 *QueryCollectionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCollectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Collection != nil { + l = m.Collection.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryOwnerOfRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryOwnerOfResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNftInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNftInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Nft != nil { + l = m.Nft.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNftsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNftsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Nfts) > 0 { + for _, e := range m.Nfts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllNftsByOwnerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllNftsByOwnerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Nfts) > 0 { + for _, e := range m.Nfts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryCollectionRequest) 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: QueryCollectionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCollectionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = 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 *QueryCollectionResponse) 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: QueryCollectionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCollectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection == nil { + m.Collection = &Collection{} + } + if err := m.Collection.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 *QueryOwnerOfRequest) 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: QueryOwnerOfRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOwnerOfRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", 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.TokenId = 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 *QueryOwnerOfResponse) 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: QueryOwnerOfResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOwnerOfResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = 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 *QueryNftInfoRequest) 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: QueryNftInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNftInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", 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.TokenId = 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 *QueryNftInfoResponse) 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: QueryNftInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNftInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nft", 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.Nft == nil { + m.Nft = &Nft{} + } + if err := m.Nft.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 *QueryNftsRequest) 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: QueryNftsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNftsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNftsResponse) 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: QueryNftsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNftsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nfts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Nfts = append(m.Nfts, Nft{}) + if err := m.Nfts[len(m.Nfts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllNftsByOwnerRequest) 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: QueryAllNftsByOwnerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllNftsByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllNftsByOwnerResponse) 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: QueryAllNftsByOwnerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllNftsByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nfts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Nfts = append(m.Nfts, Nft{}) + if err := m.Nfts[len(m.Nfts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func 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/nft/types/query.pb.gw.go b/x/nft/types/query.pb.gw.go new file mode 100644 index 00000000..139ff621 --- /dev/null +++ b/x/nft/types/query.pb.gw.go @@ -0,0 +1,673 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: bitsong/nft/v1beta1/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 + +func request_Query_Collection_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCollectionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + msg, err := client.Collection(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Collection_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCollectionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + msg, err := server.Collection(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_OwnerOf_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOwnerOfRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + val, ok = pathParams["token_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token_id") + } + + protoReq.TokenId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token_id", err) + } + + msg, err := client.OwnerOf(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_OwnerOf_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOwnerOfRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + val, ok = pathParams["token_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token_id") + } + + protoReq.TokenId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token_id", err) + } + + msg, err := server.OwnerOf(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_NftInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNftInfoRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + val, ok = pathParams["token_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token_id") + } + + protoReq.TokenId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token_id", err) + } + + msg, err := client.NftInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_NftInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNftInfoRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + val, ok = pathParams["token_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token_id") + } + + protoReq.TokenId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token_id", err) + } + + msg, err := server.NftInfo(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Nfts_0 = &utilities.DoubleArray{Encoding: map[string]int{"collection": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_Nfts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNftsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Nfts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Nfts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Nfts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNftsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["collection"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "collection") + } + + protoReq.Collection, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "collection", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Nfts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Nfts(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_AllNftsByOwner_0 = &utilities.DoubleArray{Encoding: map[string]int{"owner": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_AllNftsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllNftsByOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllNftsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AllNftsByOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AllNftsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllNftsByOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllNftsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AllNftsByOwner(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_Collection_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_Collection_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_Collection_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_OwnerOf_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_OwnerOf_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_OwnerOf_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NftInfo_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_NftInfo_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_NftInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Nfts_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_Nfts_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_Nfts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AllNftsByOwner_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_AllNftsByOwner_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_AllNftsByOwner_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_Collection_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_Collection_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_Collection_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_OwnerOf_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_OwnerOf_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_OwnerOf_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NftInfo_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_NftInfo_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_NftInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Nfts_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_Nfts_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_Nfts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AllNftsByOwner_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_AllNftsByOwner_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_AllNftsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Collection_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bitsong", "nft", "v1beta1", "collections", "collection"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_OwnerOf_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"bitsong", "nft", "v1beta1", "collections", "collection", "token_id", "owner"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_NftInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"bitsong", "nft", "v1beta1", "collections", "collection", "token_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Nfts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"bitsong", "nft", "v1beta1", "collections", "collection", "nfts"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AllNftsByOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bitsong", "nft", "v1beta1", "nfts_by_owner", "owner"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Collection_0 = runtime.ForwardResponseMessage + + forward_Query_OwnerOf_0 = runtime.ForwardResponseMessage + + forward_Query_NftInfo_0 = runtime.ForwardResponseMessage + + forward_Query_Nfts_0 = runtime.ForwardResponseMessage + + forward_Query_AllNftsByOwner_0 = runtime.ForwardResponseMessage +) diff --git a/x/nft/types/tx.pb.go b/x/nft/types/tx.pb.go new file mode 100644 index 00000000..ef32cb6a --- /dev/null +++ b/x/nft/types/tx.pb.go @@ -0,0 +1,2495 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: bitsong/nft/v1beta1/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" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgCreateCollection struct { + Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Uri string `protobuf:"bytes,3,opt,name=uri,proto3" json:"uri,omitempty"` + Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"` + Minter string `protobuf:"bytes,5,opt,name=minter,proto3" json:"minter,omitempty"` + Authority string `protobuf:"bytes,6,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (m *MsgCreateCollection) Reset() { *m = MsgCreateCollection{} } +func (m *MsgCreateCollection) String() string { return proto.CompactTextString(m) } +func (*MsgCreateCollection) ProtoMessage() {} +func (*MsgCreateCollection) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{0} +} +func (m *MsgCreateCollection) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateCollection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateCollection.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 *MsgCreateCollection) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateCollection.Merge(m, src) +} +func (m *MsgCreateCollection) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateCollection) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateCollection.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateCollection proto.InternalMessageInfo + +type MsgCreateCollectionResponse struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *MsgCreateCollectionResponse) Reset() { *m = MsgCreateCollectionResponse{} } +func (m *MsgCreateCollectionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateCollectionResponse) ProtoMessage() {} +func (*MsgCreateCollectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{1} +} +func (m *MsgCreateCollectionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateCollectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateCollectionResponse.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 *MsgCreateCollectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateCollectionResponse.Merge(m, src) +} +func (m *MsgCreateCollectionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateCollectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateCollectionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateCollectionResponse proto.InternalMessageInfo + +func (m *MsgCreateCollectionResponse) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type MsgMintNFT struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Uri string `protobuf:"bytes,4,opt,name=uri,proto3" json:"uri,omitempty"` + Minter string `protobuf:"bytes,5,opt,name=minter,proto3" json:"minter,omitempty"` + Recipient string `protobuf:"bytes,7,opt,name=recipient,proto3" json:"recipient,omitempty"` +} + +func (m *MsgMintNFT) Reset() { *m = MsgMintNFT{} } +func (m *MsgMintNFT) String() string { return proto.CompactTextString(m) } +func (*MsgMintNFT) ProtoMessage() {} +func (*MsgMintNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{2} +} +func (m *MsgMintNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintNFT.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 *MsgMintNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintNFT.Merge(m, src) +} +func (m *MsgMintNFT) XXX_Size() int { + return m.Size() +} +func (m *MsgMintNFT) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintNFT proto.InternalMessageInfo + +type MsgMintNFTResponse struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` +} + +func (m *MsgMintNFTResponse) Reset() { *m = MsgMintNFTResponse{} } +func (m *MsgMintNFTResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintNFTResponse) ProtoMessage() {} +func (*MsgMintNFTResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{3} +} +func (m *MsgMintNFTResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintNFTResponse.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 *MsgMintNFTResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintNFTResponse.Merge(m, src) +} +func (m *MsgMintNFTResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintNFTResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintNFTResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintNFTResponse proto.InternalMessageInfo + +func (m *MsgMintNFTResponse) GetCollection() string { + if m != nil { + return m.Collection + } + return "" +} + +func (m *MsgMintNFTResponse) GetTokenId() string { + if m != nil { + return m.TokenId + } + return "" +} + +type MsgSendNFT struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + Sender string `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"` + Recipient string `protobuf:"bytes,4,opt,name=recipient,proto3" json:"recipient,omitempty"` +} + +func (m *MsgSendNFT) Reset() { *m = MsgSendNFT{} } +func (m *MsgSendNFT) String() string { return proto.CompactTextString(m) } +func (*MsgSendNFT) ProtoMessage() {} +func (*MsgSendNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{4} +} +func (m *MsgSendNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendNFT.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 *MsgSendNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendNFT.Merge(m, src) +} +func (m *MsgSendNFT) XXX_Size() int { + return m.Size() +} +func (m *MsgSendNFT) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendNFT proto.InternalMessageInfo + +type MsgSendNFTResponse struct { +} + +func (m *MsgSendNFTResponse) Reset() { *m = MsgSendNFTResponse{} } +func (m *MsgSendNFTResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSendNFTResponse) ProtoMessage() {} +func (*MsgSendNFTResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{5} +} +func (m *MsgSendNFTResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendNFTResponse.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 *MsgSendNFTResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendNFTResponse.Merge(m, src) +} +func (m *MsgSendNFTResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSendNFTResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendNFTResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendNFTResponse proto.InternalMessageInfo + +type MsgPrintEdition struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + Minter string `protobuf:"bytes,5,opt,name=minter,proto3" json:"minter,omitempty"` + Recipient string `protobuf:"bytes,7,opt,name=recipient,proto3" json:"recipient,omitempty"` +} + +func (m *MsgPrintEdition) Reset() { *m = MsgPrintEdition{} } +func (m *MsgPrintEdition) String() string { return proto.CompactTextString(m) } +func (*MsgPrintEdition) ProtoMessage() {} +func (*MsgPrintEdition) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{6} +} +func (m *MsgPrintEdition) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPrintEdition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPrintEdition.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 *MsgPrintEdition) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPrintEdition.Merge(m, src) +} +func (m *MsgPrintEdition) XXX_Size() int { + return m.Size() +} +func (m *MsgPrintEdition) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPrintEdition.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPrintEdition proto.InternalMessageInfo + +type MsgPrintEditionResponse struct { + Collection string `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` + TokenId string `protobuf:"bytes,2,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + Seq uint64 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"` +} + +func (m *MsgPrintEditionResponse) Reset() { *m = MsgPrintEditionResponse{} } +func (m *MsgPrintEditionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPrintEditionResponse) ProtoMessage() {} +func (*MsgPrintEditionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d3dab637c9b79d73, []int{7} +} +func (m *MsgPrintEditionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPrintEditionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPrintEditionResponse.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 *MsgPrintEditionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPrintEditionResponse.Merge(m, src) +} +func (m *MsgPrintEditionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPrintEditionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPrintEditionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPrintEditionResponse proto.InternalMessageInfo + +func (m *MsgPrintEditionResponse) GetCollection() string { + if m != nil { + return m.Collection + } + return "" +} + +func (m *MsgPrintEditionResponse) GetTokenId() string { + if m != nil { + return m.TokenId + } + return "" +} + +func (m *MsgPrintEditionResponse) GetSeq() uint64 { + if m != nil { + return m.Seq + } + return 0 +} + +func init() { + proto.RegisterType((*MsgCreateCollection)(nil), "bitsong.nft.v1beta1.MsgCreateCollection") + proto.RegisterType((*MsgCreateCollectionResponse)(nil), "bitsong.nft.v1beta1.MsgCreateCollectionResponse") + proto.RegisterType((*MsgMintNFT)(nil), "bitsong.nft.v1beta1.MsgMintNFT") + proto.RegisterType((*MsgMintNFTResponse)(nil), "bitsong.nft.v1beta1.MsgMintNFTResponse") + proto.RegisterType((*MsgSendNFT)(nil), "bitsong.nft.v1beta1.MsgSendNFT") + proto.RegisterType((*MsgSendNFTResponse)(nil), "bitsong.nft.v1beta1.MsgSendNFTResponse") + proto.RegisterType((*MsgPrintEdition)(nil), "bitsong.nft.v1beta1.MsgPrintEdition") + proto.RegisterType((*MsgPrintEditionResponse)(nil), "bitsong.nft.v1beta1.MsgPrintEditionResponse") +} + +func init() { proto.RegisterFile("bitsong/nft/v1beta1/tx.proto", fileDescriptor_d3dab637c9b79d73) } + +var fileDescriptor_d3dab637c9b79d73 = []byte{ + // 650 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xe3, 0x26, 0x4d, 0xe8, 0x0a, 0x89, 0xb2, 0x8d, 0xa8, 0x6b, 0x90, 0x8b, 0x2c, 0x24, + 0xaa, 0x8a, 0xda, 0x49, 0x2b, 0xf5, 0x50, 0x4e, 0xb4, 0x02, 0x09, 0xa1, 0x00, 0x4a, 0x38, 0x71, + 0xa9, 0xfc, 0xb1, 0x71, 0x57, 0x8d, 0x77, 0x83, 0x77, 0x53, 0x35, 0x37, 0xc4, 0x09, 0xe5, 0xc4, + 0x23, 0xf4, 0x09, 0x50, 0x0e, 0x3c, 0x04, 0xc7, 0x8a, 0x13, 0x47, 0x94, 0x20, 0x85, 0x13, 0xcf, + 0x80, 0xbc, 0x5e, 0x27, 0x69, 0x13, 0x93, 0x2a, 0x45, 0x5c, 0x92, 0x9d, 0x99, 0xff, 0xcc, 0x6a, + 0x7e, 0x1e, 0x8f, 0xc1, 0x3d, 0x07, 0x73, 0x46, 0x89, 0x6f, 0x91, 0x3a, 0xb7, 0x4e, 0xca, 0x0e, + 0xe2, 0x76, 0xd9, 0xe2, 0xa7, 0x66, 0x33, 0xa4, 0x9c, 0xc2, 0x15, 0x19, 0x35, 0x49, 0x9d, 0x9b, + 0x32, 0xaa, 0x15, 0x7d, 0xea, 0x53, 0x11, 0xb7, 0xa2, 0x53, 0x2c, 0xd5, 0x56, 0x5d, 0xca, 0x02, + 0xca, 0xac, 0x80, 0xf9, 0xd6, 0x49, 0x39, 0xfa, 0x93, 0x81, 0xdb, 0x76, 0x80, 0x09, 0xb5, 0xc4, + 0xaf, 0x74, 0xad, 0xc5, 0xda, 0xc3, 0xb8, 0x48, 0x6c, 0xc4, 0x21, 0xe3, 0xf3, 0x02, 0x58, 0xa9, + 0x30, 0xff, 0x20, 0x44, 0x36, 0x47, 0x07, 0xb4, 0xd1, 0x40, 0x2e, 0xc7, 0x94, 0xc0, 0x3b, 0x20, + 0xcf, 0xda, 0x81, 0x43, 0x1b, 0xaa, 0x72, 0x5f, 0xd9, 0x58, 0xaa, 0x4a, 0x0b, 0x42, 0x90, 0x23, + 0x76, 0x80, 0xd4, 0x05, 0xe1, 0x15, 0x67, 0xb8, 0x0c, 0xb2, 0xad, 0x10, 0xab, 0x59, 0xe1, 0x8a, + 0x8e, 0x70, 0x1b, 0x14, 0xdc, 0xa8, 0x22, 0x0d, 0xd5, 0x5c, 0xe4, 0xdd, 0x57, 0xbf, 0x7d, 0xd9, + 0x2a, 0xca, 0x8b, 0x9f, 0x78, 0x5e, 0x88, 0x18, 0xab, 0xf1, 0x10, 0x13, 0xbf, 0x9a, 0x08, 0x61, + 0x09, 0xe4, 0x03, 0x4c, 0x38, 0x0a, 0xd5, 0xc5, 0x19, 0x29, 0x52, 0x07, 0x77, 0xc1, 0x92, 0xdd, + 0xe2, 0x47, 0x34, 0xc4, 0xbc, 0xad, 0xe6, 0x67, 0x24, 0x8d, 0xa4, 0x7b, 0x8f, 0x3f, 0x9e, 0xad, + 0x67, 0x7e, 0x9d, 0xad, 0x67, 0x3e, 0x0c, 0xba, 0x9b, 0xc9, 0xfd, 0x9d, 0x41, 0x77, 0xd3, 0x88, + 0x33, 0xb7, 0x98, 0x77, 0x2c, 0x9e, 0xcf, 0x14, 0x30, 0xc6, 0x0e, 0xb8, 0x3b, 0xc5, 0x5d, 0x45, + 0xac, 0x49, 0x09, 0x43, 0xb0, 0x08, 0x16, 0x3d, 0x44, 0x68, 0x20, 0xb1, 0xc5, 0x86, 0xd1, 0x59, + 0x00, 0xa0, 0xc2, 0xfc, 0x0a, 0x26, 0xfc, 0xe5, 0xb3, 0x37, 0x50, 0x07, 0xc0, 0x1d, 0xa6, 0x4a, + 0xe5, 0x98, 0x07, 0xae, 0x81, 0x1b, 0x9c, 0x1e, 0x23, 0x72, 0x88, 0x3d, 0x09, 0xba, 0x20, 0xec, + 0xe7, 0xde, 0x90, 0x7f, 0x76, 0x92, 0x7f, 0x6e, 0xc4, 0x7f, 0x2e, 0x96, 0x21, 0x72, 0x71, 0x13, + 0x23, 0xc2, 0xd5, 0xc2, 0x2c, 0x96, 0x43, 0xe9, 0x5e, 0x79, 0x9c, 0xa5, 0x2c, 0x16, 0xa1, 0x5c, + 0x9b, 0x44, 0x29, 0xbb, 0x37, 0x5e, 0x01, 0x38, 0xb2, 0x86, 0xe0, 0xe6, 0x67, 0x62, 0xfc, 0x54, + 0x04, 0xdd, 0x1a, 0x22, 0xde, 0x35, 0xe9, 0x96, 0x40, 0x9e, 0x21, 0xe2, 0xa1, 0x30, 0xe6, 0xfb, + 0x37, 0x6e, 0xb1, 0xee, 0x22, 0xb7, 0xdc, 0xbc, 0xdc, 0xe2, 0x62, 0x29, 0xdc, 0x64, 0x5f, 0x46, + 0x51, 0x70, 0x93, 0x56, 0xc2, 0xcd, 0xf8, 0xad, 0x80, 0x5b, 0x15, 0xe6, 0xbf, 0x0e, 0x31, 0xe1, + 0x4f, 0x3d, 0x2c, 0x3a, 0xbc, 0x1e, 0x81, 0xff, 0x34, 0x39, 0xbb, 0x29, 0x93, 0xa3, 0x4f, 0x12, + 0x18, 0x6f, 0xce, 0xa8, 0x83, 0xd5, 0x4b, 0xae, 0x7f, 0x30, 0x43, 0xd1, 0x3b, 0xc4, 0xd0, 0x3b, + 0xf1, 0xd8, 0x73, 0xd5, 0xe8, 0xb8, 0xdd, 0xc9, 0x82, 0x6c, 0x85, 0xf9, 0x90, 0x80, 0xe5, 0x89, + 0xed, 0xb8, 0x61, 0x4e, 0x59, 0xd4, 0xe6, 0x94, 0xbd, 0xa0, 0x95, 0xae, 0xaa, 0x1c, 0x36, 0x51, + 0x03, 0x85, 0x64, 0x4f, 0xac, 0xa7, 0x25, 0x4b, 0x81, 0xf6, 0x70, 0x86, 0x60, 0xbc, 0x68, 0xf2, + 0x7a, 0xa4, 0x16, 0x95, 0x82, 0xf4, 0xa2, 0x97, 0x46, 0x0f, 0x3a, 0xe0, 0xe6, 0x85, 0xb1, 0x7b, + 0x90, 0x96, 0x38, 0xae, 0xd2, 0x1e, 0x5d, 0x45, 0x95, 0xdc, 0xa1, 0x2d, 0xbe, 0x1f, 0x74, 0x37, + 0x95, 0xfd, 0x17, 0x5f, 0x7b, 0xba, 0x72, 0xde, 0xd3, 0x95, 0x1f, 0x3d, 0x5d, 0xf9, 0xd4, 0xd7, + 0x33, 0xe7, 0x7d, 0x3d, 0xf3, 0xbd, 0xaf, 0x67, 0xde, 0x96, 0x7d, 0xcc, 0x8f, 0x5a, 0x8e, 0xe9, + 0xd2, 0xc0, 0x92, 0x85, 0x69, 0xbd, 0x8e, 0x5d, 0x6c, 0x37, 0x2c, 0x9f, 0x6e, 0x25, 0x9f, 0xdb, + 0x53, 0x31, 0x4b, 0xbc, 0xdd, 0x44, 0xcc, 0xc9, 0x8b, 0x4f, 0xdf, 0xce, 0x9f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x06, 0xf1, 0xea, 0xdd, 0x8c, 0x07, 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 { + CreateCollection(ctx context.Context, in *MsgCreateCollection, opts ...grpc.CallOption) (*MsgCreateCollectionResponse, error) + MintNFT(ctx context.Context, in *MsgMintNFT, opts ...grpc.CallOption) (*MsgMintNFTResponse, error) + SendNFT(ctx context.Context, in *MsgSendNFT, opts ...grpc.CallOption) (*MsgSendNFTResponse, error) + PrintEdition(ctx context.Context, in *MsgPrintEdition, opts ...grpc.CallOption) (*MsgPrintEditionResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateCollection(ctx context.Context, in *MsgCreateCollection, opts ...grpc.CallOption) (*MsgCreateCollectionResponse, error) { + out := new(MsgCreateCollectionResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Msg/CreateCollection", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) MintNFT(ctx context.Context, in *MsgMintNFT, opts ...grpc.CallOption) (*MsgMintNFTResponse, error) { + out := new(MsgMintNFTResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Msg/MintNFT", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SendNFT(ctx context.Context, in *MsgSendNFT, opts ...grpc.CallOption) (*MsgSendNFTResponse, error) { + out := new(MsgSendNFTResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Msg/SendNFT", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) PrintEdition(ctx context.Context, in *MsgPrintEdition, opts ...grpc.CallOption) (*MsgPrintEditionResponse, error) { + out := new(MsgPrintEditionResponse) + err := c.cc.Invoke(ctx, "/bitsong.nft.v1beta1.Msg/PrintEdition", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + CreateCollection(context.Context, *MsgCreateCollection) (*MsgCreateCollectionResponse, error) + MintNFT(context.Context, *MsgMintNFT) (*MsgMintNFTResponse, error) + SendNFT(context.Context, *MsgSendNFT) (*MsgSendNFTResponse, error) + PrintEdition(context.Context, *MsgPrintEdition) (*MsgPrintEditionResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateCollection(ctx context.Context, req *MsgCreateCollection) (*MsgCreateCollectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateCollection not implemented") +} +func (*UnimplementedMsgServer) MintNFT(ctx context.Context, req *MsgMintNFT) (*MsgMintNFTResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintNFT not implemented") +} +func (*UnimplementedMsgServer) SendNFT(ctx context.Context, req *MsgSendNFT) (*MsgSendNFTResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendNFT not implemented") +} +func (*UnimplementedMsgServer) PrintEdition(ctx context.Context, req *MsgPrintEdition) (*MsgPrintEditionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PrintEdition not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateCollection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateCollection) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateCollection(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Msg/CreateCollection", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateCollection(ctx, req.(*MsgCreateCollection)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_MintNFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMintNFT) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MintNFT(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Msg/MintNFT", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MintNFT(ctx, req.(*MsgMintNFT)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SendNFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSendNFT) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SendNFT(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Msg/SendNFT", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SendNFT(ctx, req.(*MsgSendNFT)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_PrintEdition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPrintEdition) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PrintEdition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bitsong.nft.v1beta1.Msg/PrintEdition", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PrintEdition(ctx, req.(*MsgPrintEdition)) + } + return interceptor(ctx, in, info, handler) +} + +var Msg_serviceDesc = _Msg_serviceDesc +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "bitsong.nft.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateCollection", + Handler: _Msg_CreateCollection_Handler, + }, + { + MethodName: "MintNFT", + Handler: _Msg_MintNFT_Handler, + }, + { + MethodName: "SendNFT", + Handler: _Msg_SendNFT_Handler, + }, + { + MethodName: "PrintEdition", + Handler: _Msg_PrintEdition_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "bitsong/nft/v1beta1/tx.proto", +} + +func (m *MsgCreateCollection) 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 *MsgCreateCollection) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateCollection) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x32 + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0x2a + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x22 + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintTx(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateCollectionResponse) 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 *MsgCreateCollectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateCollectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintNFT) 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 *MsgMintNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x3a + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0x2a + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintTx(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x22 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintTx(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintTx(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintNFTResponse) 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 *MsgMintNFTResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintTx(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintTx(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSendNFT) 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 *MsgSendNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x22 + } + 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] = 0x1a + } + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintTx(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintTx(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSendNFTResponse) 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 *MsgSendNFTResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgPrintEdition) 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 *MsgPrintEdition) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPrintEdition) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x3a + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0x2a + } + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintTx(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintTx(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgPrintEditionResponse) 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 *MsgPrintEditionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPrintEditionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Seq != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Seq)) + i-- + dAtA[i] = 0x18 + } + if len(m.TokenId) > 0 { + i -= len(m.TokenId) + copy(dAtA[i:], m.TokenId) + i = encodeVarintTx(dAtA, i, uint64(len(m.TokenId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Collection) > 0 { + i -= len(m.Collection) + copy(dAtA[i:], m.Collection) + i = encodeVarintTx(dAtA, i, uint64(len(m.Collection))) + i-- + dAtA[i] = 0xa + } + 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 *MsgCreateCollection) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateCollectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintNFTResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSendNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSendNFTResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgPrintEdition) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgPrintEditionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Collection) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TokenId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Seq != 0 { + n += 1 + sovTx(uint64(m.Seq)) + } + 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 *MsgCreateCollection) 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: MsgCreateCollection: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateCollection: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", 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.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", 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.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", 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.Minter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = 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 *MsgCreateCollectionResponse) 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: MsgCreateCollectionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateCollectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = 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 *MsgMintNFT) 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: MsgMintNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", 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.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", 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.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", 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.Minter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", 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.Recipient = 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 *MsgMintNFTResponse) 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: MsgMintNFTResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintNFTResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", 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.TokenId = 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 *MsgSendNFT) 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: MsgSendNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", 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.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", 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.Recipient = 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 *MsgSendNFTResponse) 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: MsgSendNFTResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendNFTResponse: 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 *MsgPrintEdition) 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: MsgPrintEdition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPrintEdition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", 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.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", 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.Minter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", 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.Recipient = 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 *MsgPrintEditionResponse) 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: MsgPrintEditionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPrintEditionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collection", 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.Collection = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", 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.TokenId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Seq", wireType) + } + m.Seq = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Seq |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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") +)