feat!: enhanced grpc interface of nft module (#10709)
* add grpc NFTsOfOwner method * add comment * fix test error * apply comment from github * format code * apply comments from github * add test case * assert error msg * update adr-043 docs Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
parent
9606c16c31
commit
006650c3db
|
@ -95,8 +95,8 @@ message NFT {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- `class_id` is the identifier of the NFT class where the NFT belongs; _required_
|
- `class_id` is the identifier of the NFT class where the NFT belongs; _required_,`[a-zA-Z][a-zA-Z0-9/:-]{2,100}`
|
||||||
- `id` is an alphanumeric identifier of the NFT, unique within the scope of its class. It is specified by the creator of the NFT and may be expanded to use DID in the future. `class_id` combined with `id` uniquely identifies an NFT and is used as the primary index for storing the NFT; _required_
|
- `id` is an alphanumeric identifier of the NFT, unique within the scope of its class. It is specified by the creator of the NFT and may be expanded to use DID in the future. `class_id` combined with `id` uniquely identifies an NFT and is used as the primary index for storing the NFT; _required_,`[a-zA-Z][a-zA-Z0-9/:-]{2,100}`
|
||||||
|
|
||||||
```
|
```
|
||||||
{class_id}/{id} --> NFT (bytes)
|
{class_id}/{id} --> NFT (bytes)
|
||||||
|
@ -175,10 +175,9 @@ The query service methods for the `x/nft` module are:
|
||||||
|
|
||||||
```proto
|
```proto
|
||||||
service Query {
|
service Query {
|
||||||
|
|
||||||
// Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721
|
// Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721
|
||||||
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
|
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/balance/{class_id}/{owner}";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/balance/{owner}/{class_id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721
|
// Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721
|
||||||
|
@ -186,19 +185,14 @@ service Query {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/owner/{class_id}/{id}";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/owner/{class_id}/{id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supply queries the number of NFTs of a given class, same as totalSupply in ERC721Enumerable
|
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721.
|
||||||
rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) {
|
rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/supply/{class_id}";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/supply/{class_id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// NFTsOfClassByOwner queries the NFTs of a given class owned by the owner, similar to tokenOfOwnerByIndex in ERC721Enumerable
|
// NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in ERC721Enumerable
|
||||||
rpc NFTsOfClassByOwner(QueryNFTsOfClassByOwnerRequest) returns (QueryNFTsResponse) {
|
rpc NFTs(QueryNFTsRequest) returns (QueryNFTsResponse) {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/owned_nfts/{class_id}/{owner}";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts";
|
||||||
}
|
|
||||||
|
|
||||||
// NFTsOfClass queries all NFTs of a given class, similar to tokenByIndex in ERC721Enumerable
|
|
||||||
rpc NFTsOfClass(QueryNFTsOfClassRequest) returns (QueryNFTsResponse) {
|
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts/{class_id}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NFT queries an NFT based on its class and id.
|
// NFT queries an NFT based on its class and id.
|
||||||
|
@ -208,12 +202,12 @@ service Query {
|
||||||
|
|
||||||
// Class queries an NFT class based on its id
|
// Class queries an NFT class based on its id
|
||||||
rpc Class(QueryClassRequest) returns (QueryClassResponse) {
|
rpc Class(QueryClassRequest) returns (QueryClassResponse) {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/classes/{class_id}";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/classes/{class_id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classes queries all NFT classes
|
// Classes queries all NFT classes
|
||||||
rpc Classes(QueryClassesRequest) returns (QueryClassesResponse) {
|
rpc Classes(QueryClassesRequest) returns (QueryClassesResponse) {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/classes";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/classes";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +218,7 @@ message QueryBalanceRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryBalanceResponse is the response type for the Query/Balance RPC method
|
// QueryBalanceResponse is the response type for the Query/Balance RPC method
|
||||||
message QueryBalanceResponse{
|
message QueryBalanceResponse {
|
||||||
uint64 amount = 1;
|
uint64 amount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +229,7 @@ message QueryOwnerRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryOwnerResponse is the response type for the Query/Owner RPC method
|
// QueryOwnerResponse is the response type for the Query/Owner RPC method
|
||||||
message QueryOwnerResponse{
|
message QueryOwnerResponse {
|
||||||
string owner = 1;
|
string owner = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,20 +243,14 @@ message QuerySupplyResponse {
|
||||||
uint64 amount = 1;
|
uint64 amount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryNFTsOfClassByOwnerRequest is the request type for the Query/NFTsOfClassByOwner RPC method
|
// QueryNFTstRequest is the request type for the Query/NFTs RPC method
|
||||||
message QueryNFTsOfClassByOwnerRequest {
|
message QueryNFTsRequest {
|
||||||
string class_id = 1;
|
string class_id = 1;
|
||||||
string owner = 2;
|
string owner = 2;
|
||||||
cosmos.base.query.v1beta1.PageResponse pagination = 3;
|
cosmos.base.query.v1beta1.PageRequest pagination = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryNFTsOfClassRequest is the request type for the Query/NFTsOfClass RPC method
|
// QueryNFTsResponse is the response type for the Query/NFTs RPC methods
|
||||||
message QueryNFTsOfClassRequest {
|
|
||||||
string class_id = 1;
|
|
||||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryNFTsResponse is the response type for the Query/NFTsOfClass and Query/NFTsOfClassByOwner RPC methods
|
|
||||||
message QueryNFTsResponse {
|
message QueryNFTsResponse {
|
||||||
repeated cosmos.nft.v1beta1.NFT nfts = 1;
|
repeated cosmos.nft.v1beta1.NFT nfts = 1;
|
||||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||||
|
|
|
@ -24,9 +24,9 @@ service Query {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/supply/{class_id}";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/supply/{class_id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// NFTsOfClass queries all NFTs of a given class or optional owner, similar to tokenByIndex in ERC721Enumerable
|
// NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in ERC721Enumerable
|
||||||
rpc NFTsOfClass(QueryNFTsOfClassRequest) returns (QueryNFTsOfClassResponse) {
|
rpc NFTs(QueryNFTsRequest) returns (QueryNFTsResponse) {
|
||||||
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts/{class_id}";
|
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts";
|
||||||
}
|
}
|
||||||
|
|
||||||
// NFT queries an NFT based on its class and id.
|
// NFT queries an NFT based on its class and id.
|
||||||
|
@ -77,15 +77,15 @@ message QuerySupplyResponse {
|
||||||
uint64 amount = 1;
|
uint64 amount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryNFTsOfClassRequest is the request type for the Query/NFTsOfClass RPC method
|
// QueryNFTstRequest is the request type for the Query/NFTs RPC method
|
||||||
message QueryNFTsOfClassRequest {
|
message QueryNFTsRequest {
|
||||||
string class_id = 1;
|
string class_id = 1;
|
||||||
string owner = 2;
|
string owner = 2;
|
||||||
cosmos.base.query.v1beta1.PageRequest pagination = 3;
|
cosmos.base.query.v1beta1.PageRequest pagination = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryNFTsOfClassResponse is the response type for the Query/NFTsOfClass and Query/NFTsOfClassByOwner RPC methods
|
// QueryNFTsResponse is the response type for the Query/NFTs RPC methods
|
||||||
message QueryNFTsOfClassResponse {
|
message QueryNFTsResponse {
|
||||||
repeated cosmos.nft.v1beta1.NFT nfts = 1;
|
repeated cosmos.nft.v1beta1.NFT nfts = 1;
|
||||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,21 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
"github.com/cosmos/cosmos-sdk/x/nft"
|
"github.com/cosmos/cosmos-sdk/x/nft"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Flag names and values
|
// Flag names and values
|
||||||
const (
|
const (
|
||||||
FlagOwner = "owner"
|
FlagOwner = "owner"
|
||||||
|
FlagClassID = "class-id"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetQueryCmd returns the cli query commands for this module
|
// GetQueryCmd returns the cli query commands for this module
|
||||||
|
@ -126,8 +128,7 @@ func GetCmdQueryNFT() *cobra.Command {
|
||||||
// GetCmdQueryNFTs implements the query nft command.
|
// GetCmdQueryNFTs implements the query nft command.
|
||||||
func GetCmdQueryNFTs() *cobra.Command {
|
func GetCmdQueryNFTs() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "nfts [class-id]",
|
Use: "nfts",
|
||||||
Args: cobra.ExactArgs(1),
|
|
||||||
Short: "query all NFTs of a given class or owner address.",
|
Short: "query all NFTs of a given class or owner address.",
|
||||||
Long: strings.TrimSpace(
|
Long: strings.TrimSpace(
|
||||||
fmt.Sprintf(`Query all NFTs of a given class or owner address. If owner
|
fmt.Sprintf(`Query all NFTs of a given class or owner address. If owner
|
||||||
|
@ -148,20 +149,38 @@ $ %s query %s nfts <class-id> --owner=<owner>
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
request := &nft.QueryNFTsOfClassRequest{
|
|
||||||
ClassId: args[0],
|
|
||||||
Pagination: pageReq,
|
|
||||||
}
|
|
||||||
|
|
||||||
owner, err := cmd.Flags().GetString(FlagOwner)
|
owner, err := cmd.Flags().GetString(FlagOwner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(owner) > 0 {
|
if len(owner) > 0 {
|
||||||
request.Owner = owner
|
if _, err := sdk.AccAddressFromBech32(owner); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res, err := queryClient.NFTsOfClass(cmd.Context(), request)
|
|
||||||
|
classID, err := cmd.Flags().GetString(FlagClassID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(classID) > 0 {
|
||||||
|
if err := nft.ValidateClassID(classID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(owner) == 0 && len(classID) == 0 {
|
||||||
|
return errors.ErrInvalidRequest.Wrap("must provide at least one of classID or owner")
|
||||||
|
}
|
||||||
|
|
||||||
|
request := &nft.QueryNFTsRequest{
|
||||||
|
ClassId: classID,
|
||||||
|
Owner: owner,
|
||||||
|
Pagination: pageReq,
|
||||||
|
}
|
||||||
|
res, err := queryClient.NFTs(cmd.Context(), request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -171,6 +190,7 @@ $ %s query %s nfts <class-id> --owner=<owner>
|
||||||
flags.AddQueryFlagsToCmd(cmd)
|
flags.AddQueryFlagsToCmd(cmd)
|
||||||
flags.AddPaginationFlagsToCmd(cmd, "nfts")
|
flags.AddPaginationFlagsToCmd(cmd, "nfts")
|
||||||
cmd.Flags().String(FlagOwner, "", "The owner of the nft")
|
cmd.Flags().String(FlagOwner, "", "The owner of the nft")
|
||||||
|
cmd.Flags().String(FlagClassID, "", "The class-id of the nft")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,7 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() {
|
||||||
var result nft.QueryOwnerResponse
|
var result nft.QueryOwnerResponse
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &result)
|
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &result)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
s.Require().EqualValues(tc.expectResult, result.Owner)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -228,7 +229,7 @@ func (s *IntegrationTestSuite) TestQuerySupplyGRPC() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestQueryNFTsByOwnerGRPC() {
|
func (s *IntegrationTestSuite) TestQueryNFTsGRPC() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -241,44 +242,61 @@ func (s *IntegrationTestSuite) TestQueryNFTsByOwnerGRPC() {
|
||||||
expectResult []*nft.NFT
|
expectResult []*nft.NFT
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "class id is invalid",
|
name: "classID and owner are both empty",
|
||||||
|
args: struct {
|
||||||
|
ClassId string
|
||||||
|
Owner string
|
||||||
|
}{},
|
||||||
|
errorMsg: "must provide at least one of classID or owner",
|
||||||
|
expectErr: true,
|
||||||
|
expectResult: []*nft.NFT{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "classID is invalid",
|
||||||
args: struct {
|
args: struct {
|
||||||
ClassId string
|
ClassId string
|
||||||
Owner string
|
Owner string
|
||||||
}{
|
}{
|
||||||
ClassId: "invalid_class_id",
|
ClassId: "invalid_class_id",
|
||||||
Owner: s.owner.String(),
|
|
||||||
},
|
},
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
errorMsg: "invalid class id",
|
|
||||||
expectResult: []*nft.NFT{},
|
expectResult: []*nft.NFT{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "class id does not exist",
|
name: "classID does not exist",
|
||||||
args: struct {
|
args: struct {
|
||||||
ClassId string
|
ClassId string
|
||||||
Owner string
|
Owner string
|
||||||
}{
|
}{
|
||||||
ClassId: "class-id",
|
ClassId: "class-id",
|
||||||
Owner: s.owner.String(),
|
|
||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
expectResult: []*nft.NFT{},
|
expectResult: []*nft.NFT{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "owner does not exist",
|
name: "success query by classID",
|
||||||
args: struct {
|
args: struct {
|
||||||
ClassId string
|
ClassId string
|
||||||
Owner string
|
Owner string
|
||||||
}{
|
}{
|
||||||
ClassId: ExpNFT.ClassId,
|
ClassId: ExpNFT.ClassId,
|
||||||
Owner: s.owner.String(),
|
|
||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
expectResult: []*nft.NFT{},
|
expectResult: []*nft.NFT{&ExpNFT},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "nft exist",
|
name: "success query by owner",
|
||||||
|
args: struct {
|
||||||
|
ClassId string
|
||||||
|
Owner string
|
||||||
|
}{
|
||||||
|
Owner: val.Address.String(),
|
||||||
|
},
|
||||||
|
expectErr: false,
|
||||||
|
expectResult: []*nft.NFT{&ExpNFT},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "success query by owner and classID",
|
||||||
args: struct {
|
args: struct {
|
||||||
ClassId string
|
ClassId string
|
||||||
Owner string
|
Owner string
|
||||||
|
@ -290,7 +308,7 @@ func (s *IntegrationTestSuite) TestQueryNFTsByOwnerGRPC() {
|
||||||
expectResult: []*nft.NFT{&ExpNFT},
|
expectResult: []*nft.NFT{&ExpNFT},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
nftsOfClassURL := val.APIAddress + "/cosmos/nft/v1beta1/nfts/%s?owner=%s"
|
nftsOfClassURL := val.APIAddress + "/cosmos/nft/v1beta1/nfts?class_id=%s&owner=%s"
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
uri := fmt.Sprintf(nftsOfClassURL, tc.args.ClassId, tc.args.Owner)
|
uri := fmt.Sprintf(nftsOfClassURL, tc.args.ClassId, tc.args.Owner)
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
@ -299,67 +317,7 @@ func (s *IntegrationTestSuite) TestQueryNFTsByOwnerGRPC() {
|
||||||
s.Require().Contains(string(resp), tc.errorMsg)
|
s.Require().Contains(string(resp), tc.errorMsg)
|
||||||
} else {
|
} else {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
var result nft.QueryNFTsOfClassResponse
|
var result nft.QueryNFTsResponse
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &result)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
s.Require().EqualValues(tc.expectResult, result.Nfts)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestQueryNFTsOfClassGRPC() {
|
|
||||||
val := s.network.Validators[0]
|
|
||||||
testCases := []struct {
|
|
||||||
name string
|
|
||||||
args struct {
|
|
||||||
ClassId string
|
|
||||||
}
|
|
||||||
expectErr bool
|
|
||||||
errorMsg string
|
|
||||||
expectResult []*nft.NFT
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "class id is invalid",
|
|
||||||
args: struct {
|
|
||||||
ClassId string
|
|
||||||
}{
|
|
||||||
ClassId: "invalid_class_id",
|
|
||||||
},
|
|
||||||
expectErr: true,
|
|
||||||
expectResult: []*nft.NFT{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "class id does not exist",
|
|
||||||
args: struct {
|
|
||||||
ClassId string
|
|
||||||
}{
|
|
||||||
ClassId: "class-id",
|
|
||||||
},
|
|
||||||
expectErr: false,
|
|
||||||
expectResult: []*nft.NFT{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "class id exist",
|
|
||||||
args: struct {
|
|
||||||
ClassId string
|
|
||||||
}{
|
|
||||||
ClassId: ExpNFT.ClassId,
|
|
||||||
},
|
|
||||||
expectErr: false,
|
|
||||||
expectResult: []*nft.NFT{&ExpNFT},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
nftsOfClassURL := val.APIAddress + "/cosmos/nft/v1beta1/nfts/%s"
|
|
||||||
for _, tc := range testCases {
|
|
||||||
uri := fmt.Sprintf(nftsOfClassURL, tc.args.ClassId)
|
|
||||||
s.Run(tc.name, func() {
|
|
||||||
resp, err := rest.GetRequest(uri)
|
|
||||||
if tc.expectErr {
|
|
||||||
s.Require().Contains(string(resp), tc.errorMsg)
|
|
||||||
} else {
|
|
||||||
s.Require().NoError(err)
|
|
||||||
var result nft.QueryNFTsOfClassResponse
|
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &result)
|
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &result)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().EqualValues(tc.expectResult, result.Nfts)
|
s.Require().EqualValues(tc.expectResult, result.Nfts)
|
||||||
|
|
|
@ -137,53 +137,6 @@ func (s *IntegrationTestSuite) TestQueryNFT() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestQueryNFTs() {
|
func (s *IntegrationTestSuite) TestQueryNFTs() {
|
||||||
val := s.network.Validators[0]
|
|
||||||
testCases := []struct {
|
|
||||||
name string
|
|
||||||
args struct {
|
|
||||||
ClassID string
|
|
||||||
}
|
|
||||||
expectErr bool
|
|
||||||
expectResult []*nft.NFT
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "class id does not exist",
|
|
||||||
args: struct {
|
|
||||||
ClassID string
|
|
||||||
}{
|
|
||||||
ClassID: "class",
|
|
||||||
},
|
|
||||||
expectErr: false,
|
|
||||||
expectResult: []*nft.NFT{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "class id exist",
|
|
||||||
args: struct {
|
|
||||||
ClassID string
|
|
||||||
}{
|
|
||||||
ClassID: testClassID,
|
|
||||||
},
|
|
||||||
expectErr: false,
|
|
||||||
expectResult: []*nft.NFT{&ExpNFT},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tc := range testCases {
|
|
||||||
s.Run(tc.name, func() {
|
|
||||||
resp, err := ExecQueryNFTs(val, tc.args.ClassID)
|
|
||||||
if tc.expectErr {
|
|
||||||
s.Require().Error(err)
|
|
||||||
} else {
|
|
||||||
s.Require().NoError(err)
|
|
||||||
var result nft.QueryNFTsOfClassResponse
|
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &result)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
s.Require().EqualValues(tc.expectResult, result.Nfts)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestQueryNFTsByOwner() {
|
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -218,6 +171,15 @@ func (s *IntegrationTestSuite) TestQueryNFTsByOwner() {
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
expectResult: []*nft.NFT{},
|
expectResult: []*nft.NFT{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "class id and owner both does not exist",
|
||||||
|
args: struct {
|
||||||
|
ClassID string
|
||||||
|
Owner string
|
||||||
|
}{},
|
||||||
|
expectErr: true,
|
||||||
|
expectResult: []*nft.NFT{},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "nft exist",
|
name: "nft exist",
|
||||||
args: struct {
|
args: struct {
|
||||||
|
@ -233,12 +195,12 @@ func (s *IntegrationTestSuite) TestQueryNFTsByOwner() {
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
resp, err := ExecQueryNFTsByOwner(val, tc.args.ClassID, tc.args.Owner)
|
resp, err := ExecQueryNFTs(val, tc.args.ClassID, tc.args.Owner)
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
} else {
|
} else {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
var result nft.QueryNFTsOfClassResponse
|
var result nft.QueryNFTsResponse
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &result)
|
err = val.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &result)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().EqualValues(tc.expectResult, result.Nfts)
|
s.Require().EqualValues(tc.expectResult, result.Nfts)
|
||||||
|
|
|
@ -40,18 +40,10 @@ func ExecQueryNFT(val *network.Validator, classID, nftID string) (testutil.Buffe
|
||||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExecQueryNFTs(val *network.Validator, classID string) (testutil.BufferWriter, error) {
|
func ExecQueryNFTs(val *network.Validator, classID, owner string) (testutil.BufferWriter, error) {
|
||||||
cmd := cli.GetCmdQueryNFTs()
|
cmd := cli.GetCmdQueryNFTs()
|
||||||
var args []string
|
var args []string
|
||||||
args = append(args, classID)
|
args = append(args, fmt.Sprintf("--%s=%s", cli.FlagClassID, classID))
|
||||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
|
||||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExecQueryNFTsByOwner(val *network.Validator, classID, owner string) (testutil.BufferWriter, error) {
|
|
||||||
cmd := cli.GetCmdQueryNFTs()
|
|
||||||
var args []string
|
|
||||||
args = append(args, classID)
|
|
||||||
args = append(args, fmt.Sprintf("--%s=%s", cli.FlagOwner, owner))
|
args = append(args, fmt.Sprintf("--%s=%s", cli.FlagOwner, owner))
|
||||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||||
|
|
|
@ -15,7 +15,7 @@ var _ nft.QueryServer = Keeper{}
|
||||||
// Balance return the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721
|
// Balance return the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721
|
||||||
func (k Keeper) Balance(goCtx context.Context, r *nft.QueryBalanceRequest) (*nft.QueryBalanceResponse, error) {
|
func (k Keeper) Balance(goCtx context.Context, r *nft.QueryBalanceRequest) (*nft.QueryBalanceResponse, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty request")
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
||||||
|
@ -35,7 +35,7 @@ func (k Keeper) Balance(goCtx context.Context, r *nft.QueryBalanceRequest) (*nft
|
||||||
// Owner return the owner of the NFT based on its class and id, same as ownerOf in ERC721
|
// Owner return the owner of the NFT based on its class and id, same as ownerOf in ERC721
|
||||||
func (k Keeper) Owner(goCtx context.Context, r *nft.QueryOwnerRequest) (*nft.QueryOwnerResponse, error) {
|
func (k Keeper) Owner(goCtx context.Context, r *nft.QueryOwnerRequest) (*nft.QueryOwnerResponse, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty request")
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
||||||
|
@ -54,7 +54,7 @@ func (k Keeper) Owner(goCtx context.Context, r *nft.QueryOwnerRequest) (*nft.Que
|
||||||
// Supply return the number of NFTs from the given class, same as totalSupply of ERC721.
|
// Supply return the number of NFTs from the given class, same as totalSupply of ERC721.
|
||||||
func (k Keeper) Supply(goCtx context.Context, r *nft.QuerySupplyRequest) (*nft.QuerySupplyResponse, error) {
|
func (k Keeper) Supply(goCtx context.Context, r *nft.QuerySupplyRequest) (*nft.QuerySupplyResponse, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty request")
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
||||||
|
@ -65,58 +65,68 @@ func (k Keeper) Supply(goCtx context.Context, r *nft.QuerySupplyRequest) (*nft.Q
|
||||||
return &nft.QuerySupplyResponse{Amount: supply}, nil
|
return &nft.QuerySupplyResponse{Amount: supply}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NFTsOfClass return all NFTs of a given class or optional owner, similar to tokenByIndex in ERC721Enumerable
|
// NFTs queries all NFTs of a given class or owner (at least one must be provided), similar to tokenByIndex in ERC721Enumerable
|
||||||
func (k Keeper) NFTsOfClass(goCtx context.Context, r *nft.QueryNFTsOfClassRequest) (*nft.QueryNFTsOfClassResponse, error) {
|
func (k Keeper) NFTs(goCtx context.Context, r *nft.QueryNFTsRequest) (*nft.QueryNFTsResponse, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty request")
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
var err error
|
||||||
return nil, err
|
var owner sdk.AccAddress
|
||||||
|
if len(r.ClassId) > 0 {
|
||||||
|
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nfts []*nft.NFT
|
|
||||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
||||||
|
|
||||||
// if owner is not empty, filter nft by owner
|
|
||||||
if len(r.Owner) > 0 {
|
if len(r.Owner) > 0 {
|
||||||
owner, err := sdk.AccAddressFromBech32(r.Owner)
|
owner, err = sdk.AccAddressFromBech32(r.Owner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ownerStore := k.getClassStoreByOwner(ctx, owner, r.ClassId)
|
var nfts []*nft.NFT
|
||||||
pageRes, err := query.Paginate(ownerStore, r.Pagination, func(key []byte, _ []byte) error {
|
var pageRes *query.PageResponse
|
||||||
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(r.ClassId) > 0 && len(r.Owner) > 0:
|
||||||
|
if pageRes, err = query.Paginate(k.getClassStoreByOwner(ctx, owner, r.ClassId), r.Pagination, func(key []byte, _ []byte) error {
|
||||||
nft, has := k.GetNFT(ctx, r.ClassId, string(key))
|
nft, has := k.GetNFT(ctx, r.ClassId, string(key))
|
||||||
if has {
|
if has {
|
||||||
nfts = append(nfts, &nft)
|
nfts = append(nfts, &nft)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
}); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &nft.QueryNFTsOfClassResponse{
|
case len(r.ClassId) > 0 && len(r.Owner) == 0:
|
||||||
Nfts: nfts,
|
nftStore := k.getNFTStore(ctx, r.ClassId)
|
||||||
Pagination: pageRes,
|
if pageRes, err = query.Paginate(nftStore, r.Pagination, func(_ []byte, value []byte) error {
|
||||||
}, nil
|
var nft nft.NFT
|
||||||
}
|
if err := k.cdc.Unmarshal(value, &nft); err != nil {
|
||||||
|
return err
|
||||||
nftStore := k.getNFTStore(ctx, r.ClassId)
|
}
|
||||||
pageRes, err := query.Paginate(nftStore, r.Pagination, func(_ []byte, value []byte) error {
|
nfts = append(nfts, &nft)
|
||||||
var nft nft.NFT
|
return nil
|
||||||
if err := k.cdc.Unmarshal(value, &nft); err != nil {
|
}); err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
nfts = append(nfts, &nft)
|
case len(r.ClassId) == 0 && len(r.Owner) > 0:
|
||||||
return nil
|
if pageRes, err = query.Paginate(k.prefixStoreNftOfClassByOwner(ctx, owner), r.Pagination, func(key []byte, value []byte) error {
|
||||||
})
|
classID, nftID := parseNftOfClassByOwnerStoreKey(key)
|
||||||
|
if n, has := k.GetNFT(ctx, classID, nftID); has {
|
||||||
if err != nil {
|
nfts = append(nfts, &n)
|
||||||
return nil, err
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("must provide at least one of classID or owner")
|
||||||
}
|
}
|
||||||
return &nft.QueryNFTsOfClassResponse{
|
return &nft.QueryNFTsResponse{
|
||||||
Nfts: nfts,
|
Nfts: nfts,
|
||||||
Pagination: pageRes,
|
Pagination: pageRes,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -125,7 +135,7 @@ func (k Keeper) NFTsOfClass(goCtx context.Context, r *nft.QueryNFTsOfClassReques
|
||||||
// NFT return an NFT based on its class and id.
|
// NFT return an NFT based on its class and id.
|
||||||
func (k Keeper) NFT(goCtx context.Context, r *nft.QueryNFTRequest) (*nft.QueryNFTResponse, error) {
|
func (k Keeper) NFT(goCtx context.Context, r *nft.QueryNFTRequest) (*nft.QueryNFTResponse, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty request")
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
||||||
|
@ -138,7 +148,7 @@ func (k Keeper) NFT(goCtx context.Context, r *nft.QueryNFTRequest) (*nft.QueryNF
|
||||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
n, has := k.GetNFT(ctx, r.ClassId, r.Id)
|
n, has := k.GetNFT(ctx, r.ClassId, r.Id)
|
||||||
if !has {
|
if !has {
|
||||||
return nil, sdkerrors.Wrapf(nft.ErrNFTNotExists, "not found nft: class: %s, id: %s", r.ClassId, r.Id)
|
return nil, nft.ErrNFTNotExists.Wrapf("not found nft: class: %s, id: %s", r.ClassId, r.Id)
|
||||||
}
|
}
|
||||||
return &nft.QueryNFTResponse{Nft: &n}, nil
|
return &nft.QueryNFTResponse{Nft: &n}, nil
|
||||||
|
|
||||||
|
@ -147,7 +157,7 @@ func (k Keeper) NFT(goCtx context.Context, r *nft.QueryNFTRequest) (*nft.QueryNF
|
||||||
// Class return an NFT class based on its id
|
// Class return an NFT class based on its id
|
||||||
func (k Keeper) Class(goCtx context.Context, r *nft.QueryClassRequest) (*nft.QueryClassResponse, error) {
|
func (k Keeper) Class(goCtx context.Context, r *nft.QueryClassRequest) (*nft.QueryClassResponse, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty request")
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
if err := nft.ValidateClassID(r.ClassId); err != nil {
|
||||||
|
@ -157,7 +167,7 @@ func (k Keeper) Class(goCtx context.Context, r *nft.QueryClassRequest) (*nft.Que
|
||||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
class, has := k.GetClass(ctx, r.ClassId)
|
class, has := k.GetClass(ctx, r.ClassId)
|
||||||
if !has {
|
if !has {
|
||||||
return nil, sdkerrors.Wrapf(nft.ErrClassNotExists, "not found class: %s", r.ClassId)
|
return nil, nft.ErrClassNotExists.Wrapf("not found class: %s", r.ClassId)
|
||||||
}
|
}
|
||||||
return &nft.QueryClassResponse{Class: &class}, nil
|
return &nft.QueryClassResponse{Class: &class}, nil
|
||||||
}
|
}
|
||||||
|
@ -165,7 +175,7 @@ func (k Keeper) Class(goCtx context.Context, r *nft.QueryClassRequest) (*nft.Que
|
||||||
// Classes return all NFT classes
|
// Classes return all NFT classes
|
||||||
func (k Keeper) Classes(goCtx context.Context, r *nft.QueryClassesRequest) (*nft.QueryClassesResponse, error) {
|
func (k Keeper) Classes(goCtx context.Context, r *nft.QueryClassesRequest) (*nft.QueryClassesResponse, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty request")
|
return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
|
@ -15,7 +15,7 @@ func TestGRPCQuery(t *testing.T) {
|
||||||
suite.Run(t, new(TestSuite))
|
suite.Run(t, new(TestSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestSuite) TestBalance() {
|
func (s *TestSuite) TestBalance() {
|
||||||
var (
|
var (
|
||||||
req *nft.QueryBalanceRequest
|
req *nft.QueryBalanceRequest
|
||||||
)
|
)
|
||||||
|
@ -50,10 +50,10 @@ func (suite *TestSuite) TestBalance() {
|
||||||
{
|
{
|
||||||
"Success",
|
"Success",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
suite.TestMint()
|
s.TestMint()
|
||||||
req = &nft.QueryBalanceRequest{
|
req = &nft.QueryBalanceRequest{
|
||||||
ClassId: testClassID,
|
ClassId: testClassID,
|
||||||
Owner: suite.addrs[0].String(),
|
Owner: s.addrs[0].String(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
|
@ -64,10 +64,10 @@ func (suite *TestSuite) TestBalance() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for index, tc := range testCases {
|
for index, tc := range testCases {
|
||||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
require := suite.Require()
|
require := s.Require()
|
||||||
tc.malleate(index, require)
|
tc.malleate(index, require)
|
||||||
result, err := suite.queryClient.Balance(gocontext.Background(), req)
|
result, err := s.queryClient.Balance(gocontext.Background(), req)
|
||||||
if tc.expError == "" {
|
if tc.expError == "" {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,7 +79,7 @@ func (suite *TestSuite) TestBalance() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestSuite) TestOwner() {
|
func (s *TestSuite) TestOwner() {
|
||||||
var (
|
var (
|
||||||
req *nft.QueryOwnerRequest
|
req *nft.QueryOwnerRequest
|
||||||
owner string
|
owner string
|
||||||
|
@ -139,12 +139,12 @@ func (suite *TestSuite) TestOwner() {
|
||||||
{
|
{
|
||||||
"Success",
|
"Success",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
suite.TestMint()
|
s.TestMint()
|
||||||
req = &nft.QueryOwnerRequest{
|
req = &nft.QueryOwnerRequest{
|
||||||
ClassId: testClassID,
|
ClassId: testClassID,
|
||||||
Id: testID,
|
Id: testID,
|
||||||
}
|
}
|
||||||
owner = suite.addrs[0].String()
|
owner = s.addrs[0].String()
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryOwnerResponse) {
|
func(index int, require *require.Assertions, res *nft.QueryOwnerResponse) {
|
||||||
|
@ -153,10 +153,10 @@ func (suite *TestSuite) TestOwner() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for index, tc := range testCases {
|
for index, tc := range testCases {
|
||||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
require := suite.Require()
|
require := s.Require()
|
||||||
tc.malleate(index, require)
|
tc.malleate(index, require)
|
||||||
result, err := suite.queryClient.Owner(gocontext.Background(), req)
|
result, err := s.queryClient.Owner(gocontext.Background(), req)
|
||||||
if tc.expError == "" {
|
if tc.expError == "" {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -168,7 +168,7 @@ func (suite *TestSuite) TestOwner() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestSuite) TestSupply() {
|
func (s *TestSuite) TestSupply() {
|
||||||
var (
|
var (
|
||||||
req *nft.QuerySupplyRequest
|
req *nft.QuerySupplyRequest
|
||||||
)
|
)
|
||||||
|
@ -207,7 +207,7 @@ func (suite *TestSuite) TestSupply() {
|
||||||
req = &nft.QuerySupplyRequest{
|
req = &nft.QuerySupplyRequest{
|
||||||
ClassId: testClassID,
|
ClassId: testClassID,
|
||||||
}
|
}
|
||||||
suite.TestSaveClass()
|
s.TestSaveClass()
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
|
@ -223,7 +223,7 @@ func (suite *TestSuite) TestSupply() {
|
||||||
Id: testID,
|
Id: testID,
|
||||||
Uri: testURI,
|
Uri: testURI,
|
||||||
}
|
}
|
||||||
err := suite.app.NFTKeeper.Mint(suite.ctx, n, suite.addrs[0])
|
err := s.app.NFTKeeper.Mint(s.ctx, n, s.addrs[0])
|
||||||
require.NoError(err, "the error occurred on:%d", index)
|
require.NoError(err, "the error occurred on:%d", index)
|
||||||
|
|
||||||
req = &nft.QuerySupplyRequest{
|
req = &nft.QuerySupplyRequest{
|
||||||
|
@ -238,10 +238,10 @@ func (suite *TestSuite) TestSupply() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for index, tc := range testCases {
|
for index, tc := range testCases {
|
||||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
require := suite.Require()
|
require := s.Require()
|
||||||
tc.malleate(index, require)
|
tc.malleate(index, require)
|
||||||
result, err := suite.queryClient.Supply(gocontext.Background(), req)
|
result, err := s.queryClient.Supply(gocontext.Background(), req)
|
||||||
if tc.expError == "" {
|
if tc.expError == "" {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -252,43 +252,42 @@ func (suite *TestSuite) TestSupply() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (s *TestSuite) TestNFTs() {
|
||||||
func (suite *TestSuite) TestNFTsOfClass() {
|
|
||||||
var (
|
var (
|
||||||
req *nft.QueryNFTsOfClassRequest
|
req *nft.QueryNFTsRequest
|
||||||
nfts []*nft.NFT
|
nfts []*nft.NFT
|
||||||
)
|
)
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg string
|
msg string
|
||||||
malleate func(index int, require *require.Assertions)
|
malleate func(index int, require *require.Assertions)
|
||||||
expError string
|
expError string
|
||||||
postTest func(index int, require *require.Assertions, res *nft.QueryNFTsOfClassResponse)
|
postTest func(index int, require *require.Assertions, res *nft.QueryNFTsResponse)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"fail empty ClassId",
|
"fail empty Owner and ClassId",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
req = &nft.QueryNFTsOfClassRequest{}
|
req = &nft.QueryNFTsRequest{}
|
||||||
},
|
},
|
||||||
"invalid class id",
|
"must provide at least one of classID or owner",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryNFTsOfClassResponse) {},
|
func(index int, require *require.Assertions, res *nft.QueryNFTsResponse) {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"success, no nft",
|
"success,empty ClassId and no nft",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
req = &nft.QueryNFTsOfClassRequest{
|
req = &nft.QueryNFTsRequest{
|
||||||
ClassId: testClassID,
|
Owner: s.addrs[1].String(),
|
||||||
}
|
}
|
||||||
suite.TestSaveClass()
|
s.TestSaveClass()
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryNFTsOfClassResponse) {
|
func(index int, require *require.Assertions, res *nft.QueryNFTsResponse) {
|
||||||
require.Len(res.Nfts, 0, "the error occurred on:%d", index)
|
require.Len(res.Nfts, 0, "the error occurred on:%d", index)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"success, class id not exist",
|
"success, empty Owner and class id not exist",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
req = &nft.QueryNFTsOfClassRequest{
|
req = &nft.QueryNFTsRequest{
|
||||||
ClassId: "kitty1",
|
ClassId: "kitty1",
|
||||||
}
|
}
|
||||||
n := nft.NFT{
|
n := nft.NFT{
|
||||||
|
@ -296,52 +295,60 @@ func (suite *TestSuite) TestNFTsOfClass() {
|
||||||
Id: testID,
|
Id: testID,
|
||||||
Uri: testURI,
|
Uri: testURI,
|
||||||
}
|
}
|
||||||
err := suite.app.NFTKeeper.Mint(suite.ctx, n, suite.addrs[0])
|
err := s.app.NFTKeeper.Mint(s.ctx, n, s.addrs[0])
|
||||||
require.NoError(err, "the error occurred on:%d", index)
|
require.NoError(err, "the error occurred on:%d", index)
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryNFTsOfClassResponse) {
|
func(index int, require *require.Assertions, res *nft.QueryNFTsResponse) {
|
||||||
require.Len(res.Nfts, 0, "the error occurred on:%d", index)
|
require.Len(res.Nfts, 0, "the error occurred on:%d", index)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"success, owner not exist",
|
"Success,query by owner",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
req = &nft.QueryNFTsOfClassRequest{
|
err := s.app.NFTKeeper.SaveClass(s.ctx, nft.Class{
|
||||||
ClassId: testClassID,
|
Id: "MyKitty",
|
||||||
Owner: suite.addrs[1].String(),
|
})
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
nfts = []*nft.NFT{}
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
n := nft.NFT{
|
||||||
|
ClassId: "MyKitty",
|
||||||
|
Id: fmt.Sprintf("MyCat%d", i),
|
||||||
|
}
|
||||||
|
err := s.app.NFTKeeper.Mint(s.ctx, n, s.addrs[2])
|
||||||
|
require.NoError(err)
|
||||||
|
nfts = append(nfts, &n)
|
||||||
|
}
|
||||||
|
|
||||||
|
req = &nft.QueryNFTsRequest{
|
||||||
|
Owner: s.addrs[2].String(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryNFTsOfClassResponse) {
|
func(index int, require *require.Assertions, res *nft.QueryNFTsResponse) {
|
||||||
require.Len(res.Nfts, 0, "the error occurred on:%d", index)
|
require.EqualValues(res.Nfts, nfts, "the error occurred on:%d", index)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Success, query by classId",
|
"Success,query by classID",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
req = &nft.QueryNFTsOfClassRequest{
|
req = &nft.QueryNFTsRequest{
|
||||||
ClassId: testClassID,
|
ClassId: "MyKitty",
|
||||||
}
|
|
||||||
nfts = []*nft.NFT{
|
|
||||||
{
|
|
||||||
ClassId: testClassID,
|
|
||||||
Id: testID,
|
|
||||||
Uri: testURI,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryNFTsOfClassResponse) {
|
func(index int, require *require.Assertions, res *nft.QueryNFTsResponse) {
|
||||||
require.Equal(res.Nfts, nfts, "the error occurred on:%d", index)
|
require.EqualValues(res.Nfts, nfts, "the error occurred on:%d", index)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Success,query by classId and owner",
|
"Success,query by classId and owner",
|
||||||
func(index int, require *require.Assertions) {
|
func(index int, require *require.Assertions) {
|
||||||
req = &nft.QueryNFTsOfClassRequest{
|
req = &nft.QueryNFTsRequest{
|
||||||
ClassId: testClassID,
|
ClassId: testClassID,
|
||||||
Owner: suite.addrs[0].String(),
|
Owner: s.addrs[0].String(),
|
||||||
}
|
}
|
||||||
nfts = []*nft.NFT{
|
nfts = []*nft.NFT{
|
||||||
{
|
{
|
||||||
|
@ -352,16 +359,16 @@ func (suite *TestSuite) TestNFTsOfClass() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryNFTsOfClassResponse) {
|
func(index int, require *require.Assertions, res *nft.QueryNFTsResponse) {
|
||||||
require.Equal(res.Nfts, nfts, "the error occurred on:%d", index)
|
require.Equal(res.Nfts, nfts, "the error occurred on:%d", index)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for index, tc := range testCases {
|
for index, tc := range testCases {
|
||||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
require := suite.Require()
|
require := s.Require()
|
||||||
tc.malleate(index, require)
|
tc.malleate(index, require)
|
||||||
result, err := suite.queryClient.NFTsOfClass(gocontext.Background(), req)
|
result, err := s.queryClient.NFTs(gocontext.Background(), req)
|
||||||
if tc.expError == "" {
|
if tc.expError == "" {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -373,7 +380,7 @@ func (suite *TestSuite) TestNFTsOfClass() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestSuite) TestNFT() {
|
func (s *TestSuite) TestNFT() {
|
||||||
var (
|
var (
|
||||||
req *nft.QueryNFTRequest
|
req *nft.QueryNFTRequest
|
||||||
expNFT nft.NFT
|
expNFT nft.NFT
|
||||||
|
@ -409,7 +416,7 @@ func (suite *TestSuite) TestNFT() {
|
||||||
ClassId: "kitty1",
|
ClassId: "kitty1",
|
||||||
Id: testID,
|
Id: testID,
|
||||||
}
|
}
|
||||||
suite.TestMint()
|
s.TestMint()
|
||||||
},
|
},
|
||||||
"not found nft",
|
"not found nft",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryNFTResponse) {},
|
func(index int, require *require.Assertions, res *nft.QueryNFTResponse) {},
|
||||||
|
@ -445,10 +452,10 @@ func (suite *TestSuite) TestNFT() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for index, tc := range testCases {
|
for index, tc := range testCases {
|
||||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
require := suite.Require()
|
require := s.Require()
|
||||||
tc.malleate(index, require)
|
tc.malleate(index, require)
|
||||||
result, err := suite.queryClient.NFT(gocontext.Background(), req)
|
result, err := s.queryClient.NFT(gocontext.Background(), req)
|
||||||
if tc.expError == "" {
|
if tc.expError == "" {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,7 +467,7 @@ func (suite *TestSuite) TestNFT() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestSuite) TestClass() {
|
func (s *TestSuite) TestClass() {
|
||||||
var (
|
var (
|
||||||
req *nft.QueryClassRequest
|
req *nft.QueryClassRequest
|
||||||
class nft.Class
|
class nft.Class
|
||||||
|
@ -485,7 +492,7 @@ func (suite *TestSuite) TestClass() {
|
||||||
req = &nft.QueryClassRequest{
|
req = &nft.QueryClassRequest{
|
||||||
ClassId: "kitty1",
|
ClassId: "kitty1",
|
||||||
}
|
}
|
||||||
suite.TestSaveClass()
|
s.TestSaveClass()
|
||||||
},
|
},
|
||||||
"not found class",
|
"not found class",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryClassResponse) {},
|
func(index int, require *require.Assertions, res *nft.QueryClassResponse) {},
|
||||||
|
@ -512,10 +519,10 @@ func (suite *TestSuite) TestClass() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for index, tc := range testCases {
|
for index, tc := range testCases {
|
||||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
require := suite.Require()
|
require := s.Require()
|
||||||
tc.malleate(index, require)
|
tc.malleate(index, require)
|
||||||
result, err := suite.queryClient.Class(gocontext.Background(), req)
|
result, err := s.queryClient.Class(gocontext.Background(), req)
|
||||||
if tc.expError == "" {
|
if tc.expError == "" {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -527,7 +534,7 @@ func (suite *TestSuite) TestClass() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *TestSuite) TestClasses() {
|
func (s *TestSuite) TestClasses() {
|
||||||
var (
|
var (
|
||||||
req *nft.QueryClassesRequest
|
req *nft.QueryClassesRequest
|
||||||
classes []nft.Class
|
classes []nft.Class
|
||||||
|
@ -562,7 +569,7 @@ func (suite *TestSuite) TestClasses() {
|
||||||
UriHash: testClassURIHash,
|
UriHash: testClassURIHash,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
suite.TestSaveClass()
|
s.TestSaveClass()
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
func(index int, require *require.Assertions, res *nft.QueryClassesResponse) {
|
func(index int, require *require.Assertions, res *nft.QueryClassesResponse) {
|
||||||
|
@ -572,10 +579,10 @@ func (suite *TestSuite) TestClasses() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for index, tc := range testCases {
|
for index, tc := range testCases {
|
||||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
require := suite.Require()
|
require := s.Require()
|
||||||
tc.malleate(index, require)
|
tc.malleate(index, require)
|
||||||
result, err := suite.queryClient.Classes(gocontext.Background(), req)
|
result, err := s.queryClient.Classes(gocontext.Background(), req)
|
||||||
if tc.expError == "" {
|
if tc.expError == "" {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -169,7 +169,7 @@ func (s *TestSuite) TestMint() {
|
||||||
|
|
||||||
// test GetNFTsOfClassByOwner
|
// test GetNFTsOfClassByOwner
|
||||||
actNFTs = s.app.NFTKeeper.GetNFTsOfClassByOwner(s.ctx, testClassID, s.addrs[0])
|
actNFTs = s.app.NFTKeeper.GetNFTsOfClassByOwner(s.ctx, testClassID, s.addrs[0])
|
||||||
s.Require().EqualValues([]nft.NFT{expNFT,expNFT2}, actNFTs)
|
s.Require().EqualValues([]nft.NFT{expNFT, expNFT2}, actNFTs)
|
||||||
|
|
||||||
// test GetBalance
|
// test GetBalance
|
||||||
balance = s.app.NFTKeeper.GetBalance(s.ctx, testClassID, s.addrs[0])
|
balance = s.app.NFTKeeper.GetBalance(s.ctx, testClassID, s.addrs[0])
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"github.com/cosmos/cosmos-sdk/internal/conv"
|
"github.com/cosmos/cosmos-sdk/internal/conv"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/address"
|
"github.com/cosmos/cosmos-sdk/types/address"
|
||||||
|
@ -48,16 +49,43 @@ func classTotalSupply(classID string) []byte {
|
||||||
|
|
||||||
// nftOfClassByOwnerStoreKey returns the byte representation of the nft owner
|
// nftOfClassByOwnerStoreKey returns the byte representation of the nft owner
|
||||||
// Items are stored with the following key: values
|
// Items are stored with the following key: values
|
||||||
// 0x03<owner><classID><Delimiter(1 Byte)>
|
// 0x03<owner><Delimiter(1 Byte)><classID><Delimiter(1 Byte)>
|
||||||
func nftOfClassByOwnerStoreKey(owner sdk.AccAddress, classID string) []byte {
|
func nftOfClassByOwnerStoreKey(owner sdk.AccAddress, classID string) []byte {
|
||||||
owner = address.MustLengthPrefix(owner)
|
owner = address.MustLengthPrefix(owner)
|
||||||
classIDBz := conv.UnsafeStrToBytes(classID)
|
classIDBz := conv.UnsafeStrToBytes(classID)
|
||||||
|
|
||||||
var key = make([]byte, len(NFTOfClassByOwnerKey)+len(owner)+len(classIDBz)+len(Delimiter))
|
var key = make([]byte, len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter)+len(classIDBz)+len(Delimiter))
|
||||||
copy(key, NFTOfClassByOwnerKey)
|
copy(key, NFTOfClassByOwnerKey)
|
||||||
copy(key[len(NFTOfClassByOwnerKey):], owner)
|
copy(key[len(NFTOfClassByOwnerKey):], owner)
|
||||||
copy(key[len(NFTOfClassByOwnerKey)+len(owner):], classIDBz)
|
copy(key[len(NFTOfClassByOwnerKey)+len(owner):], Delimiter)
|
||||||
return append(key, Delimiter...)
|
copy(key[len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter):], classIDBz)
|
||||||
|
copy(key[len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter)+len(classIDBz):], Delimiter)
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
|
// prefixNftOfClassByOwnerStoreKey returns the prefix of the result of the method nftOfClassByOwnerStoreKey
|
||||||
|
// Items are stored with the following key: values
|
||||||
|
// 0x03<owner><Delimiter>
|
||||||
|
func prefixNftOfClassByOwnerStoreKey(owner sdk.AccAddress) []byte {
|
||||||
|
owner = address.MustLengthPrefix(owner)
|
||||||
|
|
||||||
|
var key = make([]byte, len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter))
|
||||||
|
copy(key, NFTOfClassByOwnerKey)
|
||||||
|
copy(key[len(NFTOfClassByOwnerKey):], owner)
|
||||||
|
copy(key[len(NFTOfClassByOwnerKey)+len(owner):], Delimiter)
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: the full path of the nftOfClassByOwnerStoreKey stored in the store: 0x03<owner><Delimiter><classID><Delimiter><nftID>,
|
||||||
|
// the key of the prefix store query result constructed using the prefixNftOfClassByOwnerStoreKey function needs to remove the 0x03<owner><Delimiter> prefix
|
||||||
|
func parseNftOfClassByOwnerStoreKey(key []byte) (classID, nftID string) {
|
||||||
|
ret := bytes.Split(key, Delimiter)
|
||||||
|
if len(ret) != 2 {
|
||||||
|
panic("invalid nftOfClassByOwnerStoreKey")
|
||||||
|
}
|
||||||
|
classID = conv.UnsafeBytesToStr(ret[0])
|
||||||
|
nftID = string(ret[1])
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ownerStoreKey returns the byte representation of the nft owner
|
// ownerStoreKey returns the byte representation of the nft owner
|
||||||
|
@ -72,5 +100,6 @@ func ownerStoreKey(classID, nftID string) []byte {
|
||||||
copy(key, OwnerKey)
|
copy(key, OwnerKey)
|
||||||
copy(key[len(OwnerKey):], classIDBz)
|
copy(key[len(OwnerKey):], classIDBz)
|
||||||
copy(key[len(OwnerKey)+len(classIDBz):], Delimiter)
|
copy(key[len(OwnerKey)+len(classIDBz):], Delimiter)
|
||||||
return append(key, nftIDBz...)
|
copy(key[len(OwnerKey)+len(classIDBz)+len(Delimiter):], nftIDBz)
|
||||||
|
return key
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,12 @@ func (k Keeper) getClassStoreByOwner(ctx sdk.Context, owner sdk.AccAddress, clas
|
||||||
return prefix.NewStore(store, key)
|
return prefix.NewStore(store, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k Keeper) prefixStoreNftOfClassByOwner(ctx sdk.Context, owner sdk.AccAddress) prefix.Store {
|
||||||
|
store := ctx.KVStore(k.storeKey)
|
||||||
|
key := prefixNftOfClassByOwnerStoreKey(owner)
|
||||||
|
return prefix.NewStore(store, key)
|
||||||
|
}
|
||||||
|
|
||||||
func (k Keeper) incrTotalSupply(ctx sdk.Context, classID string) {
|
func (k Keeper) incrTotalSupply(ctx sdk.Context, classID string) {
|
||||||
supply := k.GetTotalSupply(ctx, classID) + 1
|
supply := k.GetTotalSupply(ctx, classID) + 1
|
||||||
k.updateTotalSupply(ctx, classID, supply)
|
k.updateTotalSupply(ctx, classID, supply)
|
||||||
|
|
|
@ -315,25 +315,25 @@ func (m *QuerySupplyResponse) GetAmount() uint64 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryNFTsOfClassRequest is the request type for the Query/NFTsOfClass RPC method
|
// QueryNFTstRequest is the request type for the Query/NFTs RPC method
|
||||||
type QueryNFTsOfClassRequest struct {
|
type QueryNFTsRequest struct {
|
||||||
ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"`
|
ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"`
|
||||||
Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"`
|
Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||||
Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) Reset() { *m = QueryNFTsOfClassRequest{} }
|
func (m *QueryNFTsRequest) Reset() { *m = QueryNFTsRequest{} }
|
||||||
func (m *QueryNFTsOfClassRequest) String() string { return proto.CompactTextString(m) }
|
func (m *QueryNFTsRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*QueryNFTsOfClassRequest) ProtoMessage() {}
|
func (*QueryNFTsRequest) ProtoMessage() {}
|
||||||
func (*QueryNFTsOfClassRequest) Descriptor() ([]byte, []int) {
|
func (*QueryNFTsRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_0d24e0db697b0f9d, []int{6}
|
return fileDescriptor_0d24e0db697b0f9d, []int{6}
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassRequest) XXX_Unmarshal(b []byte) error {
|
func (m *QueryNFTsRequest) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
func (m *QueryNFTsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
if deterministic {
|
if deterministic {
|
||||||
return xxx_messageInfo_QueryNFTsOfClassRequest.Marshal(b, m, deterministic)
|
return xxx_messageInfo_QueryNFTsRequest.Marshal(b, m, deterministic)
|
||||||
} else {
|
} else {
|
||||||
b = b[:cap(b)]
|
b = b[:cap(b)]
|
||||||
n, err := m.MarshalToSizedBuffer(b)
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
@ -343,57 +343,57 @@ func (m *QueryNFTsOfClassRequest) XXX_Marshal(b []byte, deterministic bool) ([]b
|
||||||
return b[:n], nil
|
return b[:n], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassRequest) XXX_Merge(src proto.Message) {
|
func (m *QueryNFTsRequest) XXX_Merge(src proto.Message) {
|
||||||
xxx_messageInfo_QueryNFTsOfClassRequest.Merge(m, src)
|
xxx_messageInfo_QueryNFTsRequest.Merge(m, src)
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassRequest) XXX_Size() int {
|
func (m *QueryNFTsRequest) XXX_Size() int {
|
||||||
return m.Size()
|
return m.Size()
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassRequest) XXX_DiscardUnknown() {
|
func (m *QueryNFTsRequest) XXX_DiscardUnknown() {
|
||||||
xxx_messageInfo_QueryNFTsOfClassRequest.DiscardUnknown(m)
|
xxx_messageInfo_QueryNFTsRequest.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xxx_messageInfo_QueryNFTsOfClassRequest proto.InternalMessageInfo
|
var xxx_messageInfo_QueryNFTsRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) GetClassId() string {
|
func (m *QueryNFTsRequest) GetClassId() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.ClassId
|
return m.ClassId
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) GetOwner() string {
|
func (m *QueryNFTsRequest) GetOwner() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Owner
|
return m.Owner
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) GetPagination() *query.PageRequest {
|
func (m *QueryNFTsRequest) GetPagination() *query.PageRequest {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Pagination
|
return m.Pagination
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryNFTsOfClassResponse is the response type for the Query/NFTsOfClass and Query/NFTsOfClassByOwner RPC methods
|
// QueryNFTsResponse is the response type for the Query/NFTs RPC methods
|
||||||
type QueryNFTsOfClassResponse struct {
|
type QueryNFTsResponse struct {
|
||||||
Nfts []*NFT `protobuf:"bytes,1,rep,name=nfts,proto3" json:"nfts,omitempty"`
|
Nfts []*NFT `protobuf:"bytes,1,rep,name=nfts,proto3" json:"nfts,omitempty"`
|
||||||
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassResponse) Reset() { *m = QueryNFTsOfClassResponse{} }
|
func (m *QueryNFTsResponse) Reset() { *m = QueryNFTsResponse{} }
|
||||||
func (m *QueryNFTsOfClassResponse) String() string { return proto.CompactTextString(m) }
|
func (m *QueryNFTsResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*QueryNFTsOfClassResponse) ProtoMessage() {}
|
func (*QueryNFTsResponse) ProtoMessage() {}
|
||||||
func (*QueryNFTsOfClassResponse) Descriptor() ([]byte, []int) {
|
func (*QueryNFTsResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_0d24e0db697b0f9d, []int{7}
|
return fileDescriptor_0d24e0db697b0f9d, []int{7}
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassResponse) XXX_Unmarshal(b []byte) error {
|
func (m *QueryNFTsResponse) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
func (m *QueryNFTsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
if deterministic {
|
if deterministic {
|
||||||
return xxx_messageInfo_QueryNFTsOfClassResponse.Marshal(b, m, deterministic)
|
return xxx_messageInfo_QueryNFTsResponse.Marshal(b, m, deterministic)
|
||||||
} else {
|
} else {
|
||||||
b = b[:cap(b)]
|
b = b[:cap(b)]
|
||||||
n, err := m.MarshalToSizedBuffer(b)
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
@ -403,26 +403,26 @@ func (m *QueryNFTsOfClassResponse) XXX_Marshal(b []byte, deterministic bool) ([]
|
||||||
return b[:n], nil
|
return b[:n], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassResponse) XXX_Merge(src proto.Message) {
|
func (m *QueryNFTsResponse) XXX_Merge(src proto.Message) {
|
||||||
xxx_messageInfo_QueryNFTsOfClassResponse.Merge(m, src)
|
xxx_messageInfo_QueryNFTsResponse.Merge(m, src)
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassResponse) XXX_Size() int {
|
func (m *QueryNFTsResponse) XXX_Size() int {
|
||||||
return m.Size()
|
return m.Size()
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassResponse) XXX_DiscardUnknown() {
|
func (m *QueryNFTsResponse) XXX_DiscardUnknown() {
|
||||||
xxx_messageInfo_QueryNFTsOfClassResponse.DiscardUnknown(m)
|
xxx_messageInfo_QueryNFTsResponse.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xxx_messageInfo_QueryNFTsOfClassResponse proto.InternalMessageInfo
|
var xxx_messageInfo_QueryNFTsResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassResponse) GetNfts() []*NFT {
|
func (m *QueryNFTsResponse) GetNfts() []*NFT {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Nfts
|
return m.Nfts
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassResponse) GetPagination() *query.PageResponse {
|
func (m *QueryNFTsResponse) GetPagination() *query.PageResponse {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Pagination
|
return m.Pagination
|
||||||
}
|
}
|
||||||
|
@ -723,8 +723,8 @@ func init() {
|
||||||
proto.RegisterType((*QueryOwnerResponse)(nil), "cosmos.nft.v1beta1.QueryOwnerResponse")
|
proto.RegisterType((*QueryOwnerResponse)(nil), "cosmos.nft.v1beta1.QueryOwnerResponse")
|
||||||
proto.RegisterType((*QuerySupplyRequest)(nil), "cosmos.nft.v1beta1.QuerySupplyRequest")
|
proto.RegisterType((*QuerySupplyRequest)(nil), "cosmos.nft.v1beta1.QuerySupplyRequest")
|
||||||
proto.RegisterType((*QuerySupplyResponse)(nil), "cosmos.nft.v1beta1.QuerySupplyResponse")
|
proto.RegisterType((*QuerySupplyResponse)(nil), "cosmos.nft.v1beta1.QuerySupplyResponse")
|
||||||
proto.RegisterType((*QueryNFTsOfClassRequest)(nil), "cosmos.nft.v1beta1.QueryNFTsOfClassRequest")
|
proto.RegisterType((*QueryNFTsRequest)(nil), "cosmos.nft.v1beta1.QueryNFTsRequest")
|
||||||
proto.RegisterType((*QueryNFTsOfClassResponse)(nil), "cosmos.nft.v1beta1.QueryNFTsOfClassResponse")
|
proto.RegisterType((*QueryNFTsResponse)(nil), "cosmos.nft.v1beta1.QueryNFTsResponse")
|
||||||
proto.RegisterType((*QueryNFTRequest)(nil), "cosmos.nft.v1beta1.QueryNFTRequest")
|
proto.RegisterType((*QueryNFTRequest)(nil), "cosmos.nft.v1beta1.QueryNFTRequest")
|
||||||
proto.RegisterType((*QueryNFTResponse)(nil), "cosmos.nft.v1beta1.QueryNFTResponse")
|
proto.RegisterType((*QueryNFTResponse)(nil), "cosmos.nft.v1beta1.QueryNFTResponse")
|
||||||
proto.RegisterType((*QueryClassRequest)(nil), "cosmos.nft.v1beta1.QueryClassRequest")
|
proto.RegisterType((*QueryClassRequest)(nil), "cosmos.nft.v1beta1.QueryClassRequest")
|
||||||
|
@ -736,53 +736,53 @@ func init() {
|
||||||
func init() { proto.RegisterFile("cosmos/nft/v1beta1/query.proto", fileDescriptor_0d24e0db697b0f9d) }
|
func init() { proto.RegisterFile("cosmos/nft/v1beta1/query.proto", fileDescriptor_0d24e0db697b0f9d) }
|
||||||
|
|
||||||
var fileDescriptor_0d24e0db697b0f9d = []byte{
|
var fileDescriptor_0d24e0db697b0f9d = []byte{
|
||||||
// 734 bytes of a gzipped FileDescriptorProto
|
// 728 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x4f, 0x13, 0x4f,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4b, 0x6f, 0xd3, 0x40,
|
||||||
0x18, 0xc7, 0x99, 0x96, 0xd2, 0xdf, 0xef, 0x21, 0xf1, 0xcf, 0x48, 0xa4, 0x54, 0xdd, 0x90, 0x45,
|
0x10, 0xc7, 0xbb, 0x49, 0xd3, 0xc0, 0x54, 0xe2, 0xb1, 0x54, 0x90, 0x1a, 0xb0, 0x22, 0xf7, 0x91,
|
||||||
0xda, 0x42, 0x65, 0x86, 0x3f, 0x89, 0x27, 0xf4, 0x80, 0xb1, 0xc6, 0x0b, 0x68, 0xe5, 0x64, 0x62,
|
0xb4, 0x55, 0x77, 0xfb, 0x90, 0x38, 0x15, 0x0e, 0x45, 0x04, 0x71, 0x29, 0x10, 0x7a, 0x42, 0x42,
|
||||||
0xcc, 0xb6, 0xdd, 0xd6, 0x8d, 0x65, 0x77, 0x61, 0xb6, 0x2a, 0x21, 0x1c, 0xe4, 0x60, 0xf4, 0x46,
|
0xc8, 0x49, 0x9c, 0x60, 0x91, 0xda, 0x69, 0xd7, 0x06, 0xaa, 0xaa, 0x07, 0x7a, 0x40, 0x54, 0x5c,
|
||||||
0x14, 0xdf, 0x93, 0x47, 0x12, 0x2f, 0xde, 0x34, 0xe0, 0x0b, 0x31, 0x3b, 0xf3, 0x6c, 0xd9, 0x95,
|
0x90, 0xe8, 0xe7, 0xe1, 0xcc, 0xb1, 0x12, 0x17, 0x8e, 0xa8, 0xe5, 0x83, 0x20, 0xef, 0x8e, 0x53,
|
||||||
0xed, 0x6e, 0x43, 0x3c, 0x91, 0xd9, 0xf9, 0x3e, 0xf3, 0xfd, 0xcc, 0xf3, 0x3c, 0xf3, 0x50, 0xd0,
|
0x9b, 0x3a, 0x76, 0x15, 0x71, 0xaa, 0xec, 0xfd, 0xcf, 0xfc, 0x7f, 0xde, 0x79, 0x34, 0xa0, 0x37,
|
||||||
0x9a, 0x8e, 0xd8, 0x72, 0x04, 0xb7, 0xdb, 0x1e, 0x7f, 0xb3, 0xd4, 0x30, 0x3d, 0x63, 0x89, 0x6f,
|
0x5d, 0xb1, 0xe5, 0x0a, 0xee, 0xb4, 0x3d, 0xfe, 0x6e, 0xb9, 0x61, 0x79, 0xe6, 0x32, 0xdf, 0xf6,
|
||||||
0xf7, 0xcc, 0x9d, 0x5d, 0xe6, 0xee, 0x38, 0x9e, 0x43, 0xa9, 0xda, 0x67, 0x76, 0xdb, 0x63, 0xb8,
|
0xad, 0x9d, 0x5d, 0xd6, 0xdb, 0x71, 0x3d, 0x97, 0x52, 0x75, 0xce, 0x9c, 0xb6, 0xc7, 0xf0, 0x5c,
|
||||||
0x5f, 0x9c, 0xc7, 0x98, 0x86, 0x21, 0x4c, 0x25, 0xee, 0x87, 0xba, 0x46, 0xc7, 0xb2, 0x0d, 0xcf,
|
0x9b, 0xc7, 0x98, 0x86, 0x29, 0x2c, 0x25, 0xee, 0x87, 0xf6, 0xcc, 0x8e, 0xed, 0x98, 0x9e, 0xed,
|
||||||
0x72, 0x6c, 0x15, 0x5f, 0xbc, 0xd9, 0x71, 0x9c, 0x4e, 0xd7, 0xe4, 0x86, 0x6b, 0x71, 0xc3, 0xb6,
|
0x3a, 0x2a, 0x5e, 0xbb, 0xd3, 0x71, 0xdd, 0x4e, 0xd7, 0xe2, 0x66, 0xcf, 0xe6, 0xa6, 0xe3, 0xb8,
|
||||||
0x1d, 0x4f, 0x6e, 0x8a, 0x60, 0x37, 0xc6, 0xdd, 0x77, 0x92, 0xbb, 0x7a, 0x0d, 0xae, 0x3d, 0xf5,
|
0x9e, 0x3c, 0x14, 0xe1, 0x69, 0x82, 0x7b, 0xe0, 0x24, 0x4f, 0x8d, 0x1a, 0xdc, 0x78, 0x1e, 0x64,
|
||||||
0x4f, 0x5f, 0x33, 0xba, 0x86, 0xdd, 0x34, 0xeb, 0xe6, 0x76, 0xcf, 0x14, 0x1e, 0x9d, 0x82, 0xff,
|
0x5f, 0x37, 0xbb, 0xa6, 0xd3, 0xb4, 0xea, 0xd6, 0xb6, 0x6f, 0x09, 0x8f, 0x4e, 0xc2, 0xa5, 0x66,
|
||||||
0x9a, 0x5d, 0x43, 0x88, 0x97, 0x56, 0xab, 0x40, 0xa6, 0x49, 0xe5, 0xff, 0x7a, 0x5e, 0xae, 0x1f,
|
0xd7, 0x14, 0xe2, 0xb5, 0xdd, 0x2a, 0x91, 0x32, 0xa9, 0x5e, 0xae, 0x17, 0xe5, 0xf3, 0x93, 0x16,
|
||||||
0xb7, 0xe8, 0x04, 0xe4, 0x9c, 0xb7, 0xb6, 0xb9, 0x53, 0xc8, 0xc8, 0xef, 0x6a, 0xa1, 0x33, 0x98,
|
0x9d, 0x80, 0x82, 0xfb, 0xde, 0xb1, 0x76, 0x4a, 0x39, 0xf9, 0x5e, 0x3d, 0x18, 0x0c, 0x26, 0xe2,
|
||||||
0x88, 0x9e, 0x23, 0x5c, 0xc7, 0x16, 0x26, 0xbd, 0x0e, 0x63, 0xc6, 0x96, 0xd3, 0xb3, 0x3d, 0x79,
|
0x79, 0x44, 0xcf, 0x75, 0x84, 0x45, 0x6f, 0xc2, 0x98, 0xb9, 0xe5, 0xfa, 0x8e, 0x27, 0xd3, 0x8c,
|
||||||
0xcc, 0x68, 0x1d, 0x57, 0xfa, 0x7d, 0xb8, 0x2a, 0xf5, 0x1b, 0x7e, 0xf4, 0x10, 0xae, 0x97, 0x20,
|
0xd6, 0xf1, 0xc9, 0x78, 0x00, 0xd7, 0xa5, 0xfe, 0x69, 0x10, 0x7d, 0x01, 0xd7, 0x2b, 0x90, 0xb3,
|
||||||
0x63, 0xb5, 0xd0, 0x32, 0x63, 0xb5, 0xf4, 0x79, 0xa0, 0xe1, 0x78, 0x74, 0xeb, 0xb3, 0x91, 0x30,
|
0x5b, 0x68, 0x99, 0xb3, 0x5b, 0xc6, 0x3c, 0xd0, 0x68, 0x3c, 0xba, 0xf5, 0xd9, 0x48, 0x94, 0x8d,
|
||||||
0x1b, 0x47, 0xed, 0xb3, 0x9e, 0xeb, 0x76, 0x77, 0xd3, 0xcd, 0xf4, 0x05, 0x4c, 0x4a, 0x10, 0x90,
|
0xa3, 0xf6, 0x85, 0xdf, 0xeb, 0x75, 0x77, 0xb3, 0xcd, 0x8c, 0x45, 0xbc, 0x94, 0x30, 0x20, 0xe3,
|
||||||
0x72, 0x97, 0xcf, 0x04, 0x26, 0xa5, 0x7e, 0xbd, 0xb6, 0x29, 0x36, 0xda, 0x0f, 0xfc, 0x53, 0x2e,
|
0x5b, 0xbe, 0x10, 0xb8, 0x26, 0xf5, 0x1b, 0xb5, 0x4d, 0x31, 0xec, 0x0d, 0xd2, 0x1a, 0xc0, 0x59,
|
||||||
0x9a, 0x48, 0x5a, 0x03, 0x38, 0x2b, 0x70, 0x21, 0x3b, 0x4d, 0x2a, 0xe3, 0xcb, 0x25, 0x86, 0x1d,
|
0x65, 0x4b, 0xf9, 0x32, 0xa9, 0x8e, 0xaf, 0xcc, 0x32, 0x6c, 0x8d, 0xa0, 0x0d, 0x98, 0xea, 0x19,
|
||||||
0xe2, 0x77, 0x03, 0x53, 0xad, 0x83, 0xa5, 0x64, 0x4f, 0x8c, 0x4e, 0x50, 0xb5, 0x7a, 0x28, 0x52,
|
0xac, 0x21, 0x7b, 0x66, 0x76, 0xc2, 0x72, 0xd5, 0x23, 0x91, 0xc6, 0x21, 0xc1, 0xab, 0x55, 0x34,
|
||||||
0x3f, 0x24, 0x50, 0x38, 0x0f, 0x85, 0x37, 0xa9, 0xc2, 0xa8, 0xdd, 0xf6, 0x44, 0x81, 0x4c, 0x67,
|
0xc8, 0xbe, 0x00, 0xa3, 0x4e, 0xdb, 0x13, 0x25, 0x52, 0xce, 0x57, 0xc7, 0x57, 0x6e, 0xb1, 0xf3,
|
||||||
0x2b, 0xe3, 0xcb, 0x93, 0xec, 0x7c, 0x03, 0xb2, 0xf5, 0xda, 0x66, 0x5d, 0x8a, 0xe8, 0xa3, 0x08,
|
0x2d, 0xc7, 0x36, 0x6a, 0x9b, 0x75, 0x29, 0xa2, 0x8f, 0x63, 0x28, 0x39, 0x89, 0x52, 0xc9, 0x44,
|
||||||
0x51, 0x46, 0x12, 0x95, 0x53, 0x89, 0x94, 0x53, 0x04, 0x69, 0x15, 0x2e, 0x07, 0x44, 0x17, 0xa8,
|
0x51, 0x4e, 0x31, 0x96, 0x35, 0xb8, 0x1a, 0xa2, 0x0c, 0x51, 0xe3, 0xfb, 0x67, 0xd7, 0xda, 0xff,
|
||||||
0xf8, 0x3d, 0xb8, 0x72, 0x16, 0x8d, 0xf7, 0x98, 0x83, 0xac, 0xdd, 0x56, 0xe5, 0x48, 0xb8, 0x86,
|
0x8e, 0x39, 0xc8, 0x3b, 0x6d, 0x55, 0x80, 0x94, 0xcf, 0x08, 0x34, 0x06, 0xc3, 0x7b, 0x78, 0x18,
|
||||||
0xaf, 0xd1, 0x19, 0x36, 0xdc, 0x90, 0xd5, 0xd1, 0x1f, 0x62, 0xd3, 0x44, 0x13, 0xc7, 0x21, 0x27,
|
0xa4, 0xbf, 0x40, 0xd5, 0x1f, 0x61, 0x9b, 0xa0, 0x1e, 0x0d, 0x39, 0x14, 0xa4, 0x00, 0x2d, 0x27,
|
||||||
0x05, 0x68, 0x39, 0x15, 0x67, 0xa9, 0x22, 0x94, 0x4e, 0x7f, 0x81, 0xad, 0x24, 0x3f, 0x9a, 0x7d,
|
0x93, 0x2c, 0x55, 0x84, 0xd2, 0x19, 0xaf, 0xb0, 0x79, 0xe4, 0x4b, 0xab, 0x6f, 0x1c, 0x2f, 0x2f,
|
||||||
0xe3, 0x68, 0x95, 0xc9, 0x85, 0xab, 0x7c, 0x44, 0xf0, 0xdd, 0xf5, 0xcf, 0x47, 0xd0, 0x15, 0x50,
|
0x19, 0xba, 0xbc, 0x47, 0x04, 0x27, 0xad, 0x9f, 0x1f, 0x41, 0x57, 0x41, 0x7d, 0x89, 0x15, 0x16,
|
||||||
0x37, 0x31, 0x83, 0x22, 0x27, 0xa0, 0x06, 0xca, 0x7f, 0x56, 0xe9, 0xe5, 0x9f, 0x79, 0xc8, 0x49,
|
0x39, 0x05, 0x35, 0x54, 0xfe, 0xb7, 0x4a, 0xaf, 0x7c, 0x2f, 0x42, 0x41, 0x62, 0xd1, 0x23, 0x02,
|
||||||
0x2c, 0x7a, 0x44, 0x20, 0x8f, 0x33, 0x81, 0x96, 0xe3, 0x10, 0x62, 0xa6, 0x4f, 0xb1, 0x92, 0x2e,
|
0x45, 0xdc, 0x02, 0xb4, 0x92, 0x84, 0x90, 0xb0, 0x6f, 0xb4, 0x6a, 0xb6, 0x50, 0x99, 0x1a, 0xf7,
|
||||||
0x54, 0xa6, 0xfa, 0xdd, 0x83, 0xef, 0xbf, 0xbf, 0x64, 0x16, 0x29, 0xe3, 0x31, 0x53, 0xae, 0xa1,
|
0x0e, 0x7e, 0xfe, 0xf9, 0x96, 0x5b, 0xa2, 0x8c, 0x27, 0xec, 0xb5, 0x86, 0x12, 0xf3, 0x3d, 0x39,
|
||||||
0xc4, 0x7c, 0x4f, 0xbe, 0xac, 0x7d, 0xbe, 0x17, 0xd4, 0x7a, 0x9f, 0x7e, 0x22, 0x90, 0x93, 0xa3,
|
0x52, 0xfb, 0x7c, 0x2f, 0xac, 0xf5, 0x3e, 0x3d, 0x24, 0x50, 0x90, 0xcb, 0x82, 0xce, 0x0c, 0xf4,
|
||||||
0x83, 0xce, 0x0e, 0xf4, 0x0a, 0x8f, 0xa6, 0x62, 0x29, 0x4d, 0x86, 0x40, 0x4b, 0x12, 0xa8, 0x4a,
|
0x8a, 0x2e, 0x23, 0x6d, 0x36, 0x4b, 0x86, 0x40, 0xcb, 0x12, 0x68, 0x81, 0xce, 0x25, 0x01, 0x49,
|
||||||
0xe7, 0xe2, 0x80, 0x24, 0x47, 0x08, 0x83, 0xef, 0xf9, 0x2c, 0x1f, 0x09, 0x8c, 0xa9, 0x49, 0x43,
|
0x8e, 0x08, 0x06, 0xdf, 0x0b, 0x58, 0x3e, 0x13, 0x18, 0x53, 0xbb, 0x85, 0x0e, 0x76, 0x89, 0x6d,
|
||||||
0x07, 0xbb, 0x44, 0x66, 0x57, 0xb1, 0x9c, 0xaa, 0x43, 0x9c, 0x05, 0x89, 0x53, 0xa6, 0xb3, 0x71,
|
0x2b, 0xad, 0x92, 0xa9, 0x43, 0x9c, 0x45, 0x89, 0x53, 0xa1, 0x33, 0x49, 0x38, 0x42, 0x6a, 0xa3,
|
||||||
0x38, 0x42, 0x6a, 0xc3, 0x69, 0xf9, 0x4a, 0x60, 0x3c, 0x34, 0x2f, 0x68, 0x75, 0xa0, 0xcf, 0xf9,
|
0xd7, 0xe2, 0xc3, 0x68, 0xb0, 0x27, 0xe8, 0xf4, 0xc0, 0xfc, 0x91, 0xa5, 0xa6, 0xcd, 0x64, 0xa8,
|
||||||
0x51, 0x57, 0xbc, 0x33, 0x9c, 0x18, 0xc9, 0xaa, 0x92, 0x6c, 0x96, 0xce, 0xf0, 0xf8, 0xff, 0x4f,
|
0x90, 0xa1, 0x2c, 0x19, 0x34, 0x5a, 0xe2, 0xc9, 0xff, 0x7b, 0x04, 0x3d, 0x20, 0x90, 0xdf, 0xa8,
|
||||||
0x22, 0xcc, 0x75, 0x40, 0x20, 0xbb, 0x5e, 0xdb, 0xa4, 0x33, 0x49, 0x16, 0x01, 0xc7, 0xed, 0x64,
|
0x6d, 0xd2, 0xa9, 0xb4, 0x84, 0xa1, 0xeb, 0x74, 0xba, 0x08, 0x4d, 0x97, 0xa4, 0xe9, 0x3c, 0xad,
|
||||||
0x11, 0xfa, 0x2f, 0x4a, 0xff, 0x79, 0x5a, 0x19, 0xc2, 0x5f, 0xd5, 0xe9, 0x03, 0x81, 0x9c, 0x4a,
|
0x0e, 0x32, 0x3d, 0x57, 0x86, 0x4f, 0x04, 0x0a, 0x72, 0x1e, 0x52, 0x5a, 0x22, 0xba, 0x3c, 0x52,
|
||||||
0xcb, 0xe0, 0x9e, 0x89, 0x24, 0xa4, 0x94, 0x26, 0x43, 0x14, 0x26, 0x51, 0x2a, 0xb4, 0x14, 0x87,
|
0x5a, 0x22, 0xb6, 0x33, 0x0c, 0x26, 0x51, 0xaa, 0x74, 0x36, 0x09, 0x05, 0x47, 0x2f, 0x5a, 0x84,
|
||||||
0x82, 0x6f, 0x33, 0x9c, 0x8d, 0xf7, 0x04, 0xf2, 0xf8, 0xde, 0x13, 0xde, 0x54, 0x74, 0xe2, 0x24,
|
0x8f, 0x04, 0x8a, 0x38, 0xce, 0x29, 0x23, 0x13, 0x5f, 0x28, 0x29, 0x23, 0xf3, 0xcf, 0x66, 0x30,
|
||||||
0xbc, 0xa9, 0xbf, 0x46, 0x87, 0x3e, 0x23, 0x71, 0x6e, 0xd1, 0x1b, 0x09, 0x38, 0x6b, 0xab, 0xdf,
|
0xa6, 0x24, 0xce, 0x5d, 0x7a, 0x3b, 0x05, 0x67, 0x7d, 0xed, 0xc7, 0x89, 0x4e, 0x8e, 0x4f, 0x74,
|
||||||
0x4e, 0x34, 0x72, 0x7c, 0xa2, 0x91, 0x5f, 0x27, 0x1a, 0x39, 0x3c, 0xd5, 0x46, 0x8e, 0x4f, 0xb5,
|
0xf2, 0xfb, 0x44, 0x27, 0x5f, 0x4f, 0xf5, 0x91, 0xe3, 0x53, 0x7d, 0xe4, 0xd7, 0xa9, 0x3e, 0xf2,
|
||||||
0x91, 0x1f, 0xa7, 0xda, 0xc8, 0x73, 0xbd, 0x63, 0x79, 0xaf, 0x7a, 0x0d, 0xd6, 0x74, 0xb6, 0x82,
|
0xd2, 0xe8, 0xd8, 0xde, 0x1b, 0xbf, 0xc1, 0x9a, 0xee, 0x56, 0x98, 0x40, 0xfd, 0x59, 0x14, 0xad,
|
||||||
0x03, 0xd4, 0x9f, 0x05, 0xd1, 0x7a, 0xcd, 0xdf, 0xf9, 0xa7, 0x35, 0xc6, 0xe4, 0x8f, 0x8f, 0x95,
|
0xb7, 0xfc, 0x43, 0x90, 0xad, 0x31, 0x26, 0x7f, 0x4d, 0xac, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff,
|
||||||
0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf3, 0xed, 0xff, 0x2d, 0x1a, 0x09, 0x00, 0x00,
|
0x01, 0x46, 0x70, 0x1f, 0xeb, 0x08, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
@ -803,8 +803,8 @@ type QueryClient interface {
|
||||||
Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error)
|
Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error)
|
||||||
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721.
|
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721.
|
||||||
Supply(ctx context.Context, in *QuerySupplyRequest, opts ...grpc.CallOption) (*QuerySupplyResponse, error)
|
Supply(ctx context.Context, in *QuerySupplyRequest, opts ...grpc.CallOption) (*QuerySupplyResponse, error)
|
||||||
// NFTsOfClass queries all NFTs of a given class or optional owner, similar to tokenByIndex in ERC721Enumerable
|
// NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in ERC721Enumerable
|
||||||
NFTsOfClass(ctx context.Context, in *QueryNFTsOfClassRequest, opts ...grpc.CallOption) (*QueryNFTsOfClassResponse, error)
|
NFTs(ctx context.Context, in *QueryNFTsRequest, opts ...grpc.CallOption) (*QueryNFTsResponse, error)
|
||||||
// NFT queries an NFT based on its class and id.
|
// NFT queries an NFT based on its class and id.
|
||||||
NFT(ctx context.Context, in *QueryNFTRequest, opts ...grpc.CallOption) (*QueryNFTResponse, error)
|
NFT(ctx context.Context, in *QueryNFTRequest, opts ...grpc.CallOption) (*QueryNFTResponse, error)
|
||||||
// Class queries an NFT class based on its id
|
// Class queries an NFT class based on its id
|
||||||
|
@ -848,9 +848,9 @@ func (c *queryClient) Supply(ctx context.Context, in *QuerySupplyRequest, opts .
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *queryClient) NFTsOfClass(ctx context.Context, in *QueryNFTsOfClassRequest, opts ...grpc.CallOption) (*QueryNFTsOfClassResponse, error) {
|
func (c *queryClient) NFTs(ctx context.Context, in *QueryNFTsRequest, opts ...grpc.CallOption) (*QueryNFTsResponse, error) {
|
||||||
out := new(QueryNFTsOfClassResponse)
|
out := new(QueryNFTsResponse)
|
||||||
err := c.cc.Invoke(ctx, "/cosmos.nft.v1beta1.Query/NFTsOfClass", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/cosmos.nft.v1beta1.Query/NFTs", in, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -892,8 +892,8 @@ type QueryServer interface {
|
||||||
Owner(context.Context, *QueryOwnerRequest) (*QueryOwnerResponse, error)
|
Owner(context.Context, *QueryOwnerRequest) (*QueryOwnerResponse, error)
|
||||||
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721.
|
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721.
|
||||||
Supply(context.Context, *QuerySupplyRequest) (*QuerySupplyResponse, error)
|
Supply(context.Context, *QuerySupplyRequest) (*QuerySupplyResponse, error)
|
||||||
// NFTsOfClass queries all NFTs of a given class or optional owner, similar to tokenByIndex in ERC721Enumerable
|
// NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in ERC721Enumerable
|
||||||
NFTsOfClass(context.Context, *QueryNFTsOfClassRequest) (*QueryNFTsOfClassResponse, error)
|
NFTs(context.Context, *QueryNFTsRequest) (*QueryNFTsResponse, error)
|
||||||
// NFT queries an NFT based on its class and id.
|
// NFT queries an NFT based on its class and id.
|
||||||
NFT(context.Context, *QueryNFTRequest) (*QueryNFTResponse, error)
|
NFT(context.Context, *QueryNFTRequest) (*QueryNFTResponse, error)
|
||||||
// Class queries an NFT class based on its id
|
// Class queries an NFT class based on its id
|
||||||
|
@ -915,8 +915,8 @@ func (*UnimplementedQueryServer) Owner(ctx context.Context, req *QueryOwnerReque
|
||||||
func (*UnimplementedQueryServer) Supply(ctx context.Context, req *QuerySupplyRequest) (*QuerySupplyResponse, error) {
|
func (*UnimplementedQueryServer) Supply(ctx context.Context, req *QuerySupplyRequest) (*QuerySupplyResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Supply not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Supply not implemented")
|
||||||
}
|
}
|
||||||
func (*UnimplementedQueryServer) NFTsOfClass(ctx context.Context, req *QueryNFTsOfClassRequest) (*QueryNFTsOfClassResponse, error) {
|
func (*UnimplementedQueryServer) NFTs(ctx context.Context, req *QueryNFTsRequest) (*QueryNFTsResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method NFTsOfClass not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method NFTs not implemented")
|
||||||
}
|
}
|
||||||
func (*UnimplementedQueryServer) NFT(ctx context.Context, req *QueryNFTRequest) (*QueryNFTResponse, error) {
|
func (*UnimplementedQueryServer) NFT(ctx context.Context, req *QueryNFTRequest) (*QueryNFTResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method NFT not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method NFT not implemented")
|
||||||
|
@ -986,20 +986,20 @@ func _Query_Supply_Handler(srv interface{}, ctx context.Context, dec func(interf
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _Query_NFTsOfClass_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _Query_NFTs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(QueryNFTsOfClassRequest)
|
in := new(QueryNFTsRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if interceptor == nil {
|
if interceptor == nil {
|
||||||
return srv.(QueryServer).NFTsOfClass(ctx, in)
|
return srv.(QueryServer).NFTs(ctx, in)
|
||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: "/cosmos.nft.v1beta1.Query/NFTsOfClass",
|
FullMethod: "/cosmos.nft.v1beta1.Query/NFTs",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(QueryServer).NFTsOfClass(ctx, req.(*QueryNFTsOfClassRequest))
|
return srv.(QueryServer).NFTs(ctx, req.(*QueryNFTsRequest))
|
||||||
}
|
}
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
@ -1075,8 +1075,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{
|
||||||
Handler: _Query_Supply_Handler,
|
Handler: _Query_Supply_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "NFTsOfClass",
|
MethodName: "NFTs",
|
||||||
Handler: _Query_NFTsOfClass_Handler,
|
Handler: _Query_NFTs_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "NFT",
|
MethodName: "NFT",
|
||||||
|
@ -1285,7 +1285,7 @@ func (m *QuerySupplyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) Marshal() (dAtA []byte, err error) {
|
func (m *QueryNFTsRequest) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
@ -1295,12 +1295,12 @@ func (m *QueryNFTsOfClassRequest) Marshal() (dAtA []byte, err error) {
|
||||||
return dAtA[:n], nil
|
return dAtA[:n], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) MarshalTo(dAtA []byte) (int, error) {
|
func (m *QueryNFTsRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
func (m *QueryNFTsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
i := len(dAtA)
|
i := len(dAtA)
|
||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
|
@ -1334,7 +1334,7 @@ func (m *QueryNFTsOfClassRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassResponse) Marshal() (dAtA []byte, err error) {
|
func (m *QueryNFTsResponse) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
@ -1344,12 +1344,12 @@ func (m *QueryNFTsOfClassResponse) Marshal() (dAtA []byte, err error) {
|
||||||
return dAtA[:n], nil
|
return dAtA[:n], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassResponse) MarshalTo(dAtA []byte) (int, error) {
|
func (m *QueryNFTsResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
func (m *QueryNFTsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
i := len(dAtA)
|
i := len(dAtA)
|
||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
|
@ -1699,7 +1699,7 @@ func (m *QuerySupplyResponse) Size() (n int) {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassRequest) Size() (n int) {
|
func (m *QueryNFTsRequest) Size() (n int) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1720,7 +1720,7 @@ func (m *QueryNFTsOfClassRequest) Size() (n int) {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryNFTsOfClassResponse) Size() (n int) {
|
func (m *QueryNFTsResponse) Size() (n int) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -2363,7 +2363,7 @@ func (m *QuerySupplyResponse) Unmarshal(dAtA []byte) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassRequest) Unmarshal(dAtA []byte) error {
|
func (m *QueryNFTsRequest) Unmarshal(dAtA []byte) error {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
for iNdEx < l {
|
for iNdEx < l {
|
||||||
|
@ -2386,10 +2386,10 @@ func (m *QueryNFTsOfClassRequest) Unmarshal(dAtA []byte) error {
|
||||||
fieldNum := int32(wire >> 3)
|
fieldNum := int32(wire >> 3)
|
||||||
wireType := int(wire & 0x7)
|
wireType := int(wire & 0x7)
|
||||||
if wireType == 4 {
|
if wireType == 4 {
|
||||||
return fmt.Errorf("proto: QueryNFTsOfClassRequest: wiretype end group for non-group")
|
return fmt.Errorf("proto: QueryNFTsRequest: wiretype end group for non-group")
|
||||||
}
|
}
|
||||||
if fieldNum <= 0 {
|
if fieldNum <= 0 {
|
||||||
return fmt.Errorf("proto: QueryNFTsOfClassRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
return fmt.Errorf("proto: QueryNFTsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
}
|
}
|
||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -2513,7 +2513,7 @@ func (m *QueryNFTsOfClassRequest) Unmarshal(dAtA []byte) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (m *QueryNFTsOfClassResponse) Unmarshal(dAtA []byte) error {
|
func (m *QueryNFTsResponse) Unmarshal(dAtA []byte) error {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
for iNdEx < l {
|
for iNdEx < l {
|
||||||
|
@ -2536,10 +2536,10 @@ func (m *QueryNFTsOfClassResponse) Unmarshal(dAtA []byte) error {
|
||||||
fieldNum := int32(wire >> 3)
|
fieldNum := int32(wire >> 3)
|
||||||
wireType := int(wire & 0x7)
|
wireType := int(wire & 0x7)
|
||||||
if wireType == 4 {
|
if wireType == 4 {
|
||||||
return fmt.Errorf("proto: QueryNFTsOfClassResponse: wiretype end group for non-group")
|
return fmt.Errorf("proto: QueryNFTsResponse: wiretype end group for non-group")
|
||||||
}
|
}
|
||||||
if fieldNum <= 0 {
|
if fieldNum <= 0 {
|
||||||
return fmt.Errorf("proto: QueryNFTsOfClassResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
return fmt.Errorf("proto: QueryNFTsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
}
|
}
|
||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
@ -238,73 +238,37 @@ func local_request_Query_Supply_0(ctx context.Context, marshaler runtime.Marshal
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
filter_Query_NFTsOfClass_0 = &utilities.DoubleArray{Encoding: map[string]int{"class_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
filter_Query_NFTs_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
)
|
)
|
||||||
|
|
||||||
func request_Query_NFTsOfClass_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
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 QueryNFTsOfClassRequest
|
var protoReq QueryNFTsRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
var (
|
|
||||||
val string
|
|
||||||
ok bool
|
|
||||||
err error
|
|
||||||
_ = err
|
|
||||||
)
|
|
||||||
|
|
||||||
val, ok = pathParams["class_id"]
|
|
||||||
if !ok {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id")
|
|
||||||
}
|
|
||||||
|
|
||||||
protoReq.ClassId, err = runtime.String(val)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_NFTsOfClass_0); err != nil {
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_NFTs_0); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := client.NFTsOfClass(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
msg, err := client.NFTs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_Query_NFTsOfClass_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
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 QueryNFTsOfClassRequest
|
var protoReq QueryNFTsRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
var (
|
|
||||||
val string
|
|
||||||
ok bool
|
|
||||||
err error
|
|
||||||
_ = err
|
|
||||||
)
|
|
||||||
|
|
||||||
val, ok = pathParams["class_id"]
|
|
||||||
if !ok {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id")
|
|
||||||
}
|
|
||||||
|
|
||||||
protoReq.ClassId, err = runtime.String(val)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_NFTsOfClass_0); err != nil {
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_NFTs_0); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := server.NFTsOfClass(ctx, &protoReq)
|
msg, err := server.NFTs(ctx, &protoReq)
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -541,7 +505,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.Handle("GET", pattern_Query_NFTsOfClass_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle("GET", pattern_Query_NFTs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
@ -550,14 +514,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := local_request_Query_NFTsOfClass_0(rctx, inboundMarshaler, server, req, pathParams)
|
resp, md, err := local_request_Query_NFTs_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_Query_NFTsOfClass_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_Query_NFTs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -722,7 +686,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.Handle("GET", pattern_Query_NFTsOfClass_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle("GET", pattern_Query_NFTs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
@ -731,14 +695,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_Query_NFTsOfClass_0(rctx, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_Query_NFTs_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_Query_NFTsOfClass_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_Query_NFTs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -812,7 +776,7 @@ var (
|
||||||
|
|
||||||
pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "nft", "v1beta1", "supply", "class_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "nft", "v1beta1", "supply", "class_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
pattern_Query_NFTsOfClass_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "nft", "v1beta1", "nfts", "class_id"}, "", runtime.AssumeColonVerbOpt(false)))
|
pattern_Query_NFTs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "nft", "v1beta1", "nfts"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
pattern_Query_NFT_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{"cosmos", "nft", "v1beta1", "nfts", "class_id", "id"}, "", runtime.AssumeColonVerbOpt(false)))
|
pattern_Query_NFT_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{"cosmos", "nft", "v1beta1", "nfts", "class_id", "id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
|
@ -828,7 +792,7 @@ var (
|
||||||
|
|
||||||
forward_Query_Supply_0 = runtime.ForwardResponseMessage
|
forward_Query_Supply_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_Query_NFTsOfClass_0 = runtime.ForwardResponseMessage
|
forward_Query_NFTs_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_Query_NFT_0 = runtime.ForwardResponseMessage
|
forward_Query_NFT_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue