-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Generate nft protobuf, refer #9826. <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
- Loading branch information
Zhiqiang Zhang
committed
Aug 31, 2021
1 parent
2c31451
commit 6bddcd5
Showing
12 changed files
with
8,076 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
syntax = "proto3"; | ||
package cosmos.nft.v1beta1; | ||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/nft"; | ||
|
||
// EventSend is emitted on Msg/Send | ||
message EventSend { | ||
string class_id = 1; | ||
string id = 2; | ||
string sender = 3; | ||
string receiver = 4; | ||
} | ||
|
||
// EventMint is emitted on Mint | ||
message EventMint { | ||
string class_id = 1; | ||
string id = 2; | ||
string owner = 3; | ||
} | ||
|
||
// EventBurn is emitted on Burn | ||
message EventBurn { | ||
string class_id = 1; | ||
string id = 2; | ||
string owner = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
syntax = "proto3"; | ||
package cosmos.nft.v1beta1; | ||
|
||
import "cosmos/nft/v1beta1/nft.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/nft"; | ||
|
||
// GenesisState defines the nft module's genesis state. | ||
message GenesisState { | ||
// class defines the class of the nft type. | ||
repeated cosmos.nft.v1beta1.Class classes = 1; | ||
repeated Entry entries = 2; | ||
} | ||
|
||
// Entry Defines all nft owned by a person | ||
message Entry { | ||
// owner is the owner address of the following nft | ||
string owner = 1; | ||
|
||
// nfts is a group of nfts of the same owner | ||
repeated cosmos.nft.v1beta1.NFT nfts = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
syntax = "proto3"; | ||
package cosmos.nft.v1beta1; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/nft"; | ||
|
||
// Class defines the class of the nft type. | ||
message Class { | ||
// id defines the unique identifier of the NFT classification, similar to the contract address of ERC721 | ||
string id = 1; | ||
|
||
// name defines the human-readable name of the NFT classification | ||
string name = 2; | ||
|
||
// symbol is an abbreviated name for nft classification | ||
string symbol = 3; | ||
|
||
// description is a brief description of nft classification | ||
string description = 4; | ||
|
||
// uri is a URI may point to a JSON file that conforms to the nft classification Metadata JSON Schema. | ||
string uri = 5; | ||
|
||
// uri_hash is a hash of the document pointed to uri | ||
string uri_hash = 6; | ||
} | ||
|
||
// NFT defines the NFT. | ||
message NFT { | ||
// class_id defines the unique identifier of the NFT classification, similar to the contract address of ERC721 | ||
string class_id = 1; | ||
|
||
// id defines the unique identification of NFT | ||
string id = 2; | ||
|
||
// uri defines NFT's metadata storage address outside the chain | ||
string uri = 3; | ||
|
||
// uri_hash is a hash of the document pointed to uri | ||
string uri_hash = 4; | ||
|
||
// data is the metadata of the NFT | ||
google.protobuf.Any data = 10; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
syntax = "proto3"; | ||
package cosmos.nft.v1beta1; | ||
|
||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/nft/v1beta1/nft.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/nft"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 | ||
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) { | ||
option (google.api.http).get = "/cosmos/nft/v1beta1/balance/{class_id}/{owner}"; | ||
} | ||
|
||
// Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 | ||
rpc Owner(QueryOwnerRequest) returns (QueryOwnerResponse) { | ||
option (google.api.http).get = "/cosmos/nft/v1beta1/owner/{class_id}/{id}"; | ||
} | ||
|
||
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721. | ||
rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) { | ||
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 | ||
rpc NFTsOfClass(QueryNFTsOfClassRequest) returns (QueryNFTsOfClassResponse) { | ||
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts/{class_id}"; | ||
} | ||
|
||
// NFT queries an NFT based on its class and id. | ||
rpc NFT(QueryNFTRequest) returns (QueryNFTResponse) { | ||
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts/{class_id}/{id}"; | ||
} | ||
|
||
// Class queries an NFT class based on its id | ||
rpc Class(QueryClassRequest) returns (QueryClassResponse) { | ||
option (google.api.http).get = "/cosmos/nft/v1beta1/classes/{class_id}"; | ||
} | ||
|
||
// Classes queries all NFT classes | ||
rpc Classes(QueryClassesRequest) returns (QueryClassesResponse) { | ||
option (google.api.http).get = "/cosmos/nft/v1beta1/classes"; | ||
} | ||
} | ||
|
||
// QueryBalanceRequest is the request type for the Query/Balance RPC method | ||
message QueryBalanceRequest { | ||
string class_id = 1; | ||
string owner = 2; | ||
} | ||
|
||
// QueryBalanceResponse is the response type for the Query/Balance RPC method | ||
message QueryBalanceResponse { | ||
uint64 amount = 1; | ||
} | ||
|
||
// QueryOwnerRequest is the request type for the Query/Owner RPC method | ||
message QueryOwnerRequest { | ||
string class_id = 1; | ||
string id = 2; | ||
} | ||
|
||
// QueryOwnerResponse is the response type for the Query/Owner RPC method | ||
message QueryOwnerResponse { | ||
string owner = 1; | ||
} | ||
|
||
// QuerySupplyRequest is the request type for the Query/Supply RPC method | ||
message QuerySupplyRequest { | ||
string class_id = 1; | ||
} | ||
|
||
// QuerySupplyResponse is the response type for the Query/Supply RPC method | ||
message QuerySupplyResponse { | ||
uint64 amount = 1; | ||
} | ||
|
||
// QueryNFTsOfClassRequest is the request type for the Query/NFTsOfClass RPC method | ||
message QueryNFTsOfClassRequest { | ||
string class_id = 1; | ||
string owner = 2; | ||
cosmos.base.query.v1beta1.PageRequest pagination = 3; | ||
} | ||
|
||
// QueryNFTsOfClassResponse is the response type for the Query/NFTsOfClass and Query/NFTsOfClassByOwner RPC methods | ||
message QueryNFTsOfClassResponse { | ||
repeated cosmos.nft.v1beta1.NFT nfts = 1; | ||
cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
} | ||
|
||
// QueryNFTRequest is the request type for the Query/NFT RPC method | ||
message QueryNFTRequest { | ||
string class_id = 1; | ||
string id = 2; | ||
} | ||
|
||
// QueryNFTResponse is the response type for the Query/NFT RPC method | ||
message QueryNFTResponse { | ||
cosmos.nft.v1beta1.NFT nft = 1; | ||
} | ||
|
||
// QueryClassRequest is the request type for the Query/Class RPC method | ||
message QueryClassRequest { | ||
string class_id = 1; | ||
} | ||
|
||
// QueryClassResponse is the response type for the Query/Class RPC method | ||
message QueryClassResponse { | ||
cosmos.nft.v1beta1.Class class = 1; | ||
} | ||
|
||
// QueryClassesRequest is the request type for the Query/Classes RPC method | ||
message QueryClassesRequest { | ||
// pagination defines an optional pagination for the request. | ||
cosmos.base.query.v1beta1.PageRequest pagination = 1; | ||
} | ||
|
||
// QueryClassesResponse is the response type for the Query/Classes RPC method | ||
message QueryClassesResponse { | ||
repeated cosmos.nft.v1beta1.Class classes = 1; | ||
cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
syntax = "proto3"; | ||
package cosmos.nft.v1beta1; | ||
|
||
import "cosmos/nft/v1beta1/nft.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/nft"; | ||
|
||
// Msg defines the nft Msg service. | ||
service Msg { | ||
// Send defines a method to send a nft from one account to another account. | ||
rpc Send(MsgSend) returns (MsgSendResponse); | ||
} | ||
// MsgSend represents a message to send a nft from one account to another account. | ||
message MsgSend { | ||
// class_id defines the unique identifier of the nft classification, similar to the contract address of ERC721 | ||
string class_id = 1; | ||
|
||
// id defines the unique identification of nft | ||
string id = 2; | ||
|
||
// sender is the address of the owner of nft | ||
string sender = 3; | ||
|
||
// receiver is the receiver address of nft | ||
string receiver = 4; | ||
} | ||
// MsgSendResponse defines the Msg/Send response type. | ||
message MsgSendResponse {} |
Oops, something went wrong.