-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generate nft protobuf #9747
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intended to be against master?
Let's remove gogoproto annotations because we're migrating to golang v2 protobuf and these don't seem necessary.
Yes, we hope that this module is completed when it is merged into master, so that it will not affect the release of new versions based on the master branch. If this consideration is redundant, we can directly PR to the master. |
Let's please target PRs against master. Thanks 🙏 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Pre-approving, but left few comments
proto/cosmos/nft/v1beta1/nft.proto
Outdated
string name = 2; | ||
string symbol = 3; | ||
string description = 4; | ||
string uri = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we add: uri_hash
- this will be a hash of the document pointed by URI - similar to what we have in bank.proto
metadata,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment to the uri_hash
proto/cosmos/nft/v1beta1/nft.proto
Outdated
message NFT { | ||
string class_id = 1; | ||
string id = 2; | ||
string uri = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add uri_hash
as well.
proto/cosmos/nft/v1beta1/nft.proto
Outdated
string class_id = 1; | ||
string id = 2; | ||
string uri = 3; | ||
google.protobuf.Any data = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add comment to the data
field. Both data
and any
has almost no meaning.
proto/cosmos/nft/v1beta1/query.proto
Outdated
option (google.api.http).get = "/cosmos/nft/v1beta1/owner/{class_id}/{id}"; | ||
} | ||
|
||
// Supply queries the number of nft based on the class, same as totalSupply of ERC721 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Supply queries the number of nft based on the class, same as totalSupply of ERC721 | |
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721. |
|
||
import "cosmos/nft/v1beta1/nft.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/nft"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about putting genesis into a subpackage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that genesis output to github.com/cosmos/cosmos-sdk/x/nft/genesis
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. What do you think about this idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When thinking more about it - I would propose to split it in the following way:
- x/nft -- for all things related to RPC
- x/nft/dal -- for all things related to storage (data access layer)
This way we have a clear domains.
PS: we think to do the same for eco-credit module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: Aaron pointed in a chat, that this will require splitting the proto packages as well:
- proto/cosmos/nft/v1beta1
- proto/cosmos/nft/dal/v1beta1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main point for breaking down the proto into 2 (or more) packages is to have more freedom to upgrading it in the future:
- the protobuf service API and related types should be rather stable and we want to avoid any breaking change. We will version it.
- the storage types can be in an internal package and don't need to be versioned. If "tomorrow" we will find a better storage layout we can update the module without bumping the API version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, got it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's please not use the term dal. I would use state instead. I also don't want to delay this PR unnecessarily, and would prefer to do this design in a more general way for the SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, how can this PR be modified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recently, @aaronc pointed that the store proto version is important for merkle proofs. So, we will probably need to discuss more about it.
TL;DR - let's merge this in one package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Let's add a comment to the uri_hash
attribute.
proto/cosmos/nft/v1beta1/nft.proto
Outdated
string name = 2; | ||
string symbol = 3; | ||
string description = 4; | ||
string uri = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment to the uri_hash
Is there anything left for finalizing this PR? We will need a second review. Not sure if @aaronc will have a time (he is starting holidays next week). So maybe @okwme or @alexanderbez ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
But I would really like there to be more documentation comments.
(side note: I am a bit uncomfortable that we disabled COMMENT_FIELD
in buf.yaml. can we maybe change this @AmauryM @ryanchristo ?)
Yeah, I agree. #9978 |
Codecov Report
@@ Coverage Diff @@
## master #9747 +/- ##
=======================================
Coverage 63.56% 63.56%
=======================================
Files 572 572
Lines 53584 53584
=======================================
+ Hits 34058 34059 +1
+ Misses 17583 17582 -1
Partials 1943 1943
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we waiting for comments on the message fields before merging?
There are very few descriptions for message fields generated in the proto documentation. I think it would be preferred to address adding the comments within this pull request rather than having to play catch up in #9978 or a followup pull request.
The group module provides a good example of how thorough comments should be:
https://github.com/cosmos/cosmos-sdk/blob/master/proto/cosmos/group/v1beta1/tx.proto
| Field | Type | Label | Description | | ||
| ----- | ---- | ----- | ----------- | | ||
| `class_id` | [string](#string) | | | | ||
| `id` | [string](#string) | | | | ||
| `owner` | [string](#string) | | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example of the generated protobuf documentation without comments.
I believe this is ready for merge - please check if all doc comments are there. |
Visit https://dashboard.github.orijtech.com?back=0&pr=9747&remote=false&repo=cosmos%2Fcosmos-sdk to see benchmark details. |
Description
Generate nft protobuf, refer #9826.
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...
!
in the type prefix if API or client breaking change