-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(x/nft): add new queries for nft modules that support query string #18355
Conversation
WalkthroughWalkthroughThe Cosmos NFT module has been updated to include new RPC methods that allow querying NFT data using query strings. These additions provide alternative ways to request information about NFT balances, owners, supplies, individual NFTs, and classes. The changes are reflected in the service's protocol buffers and the corresponding Go implementation, including tests. The updates are documented in the module's changelog, highlighting the new query capabilities introduced in the system. Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (4)
- api/cosmos/nft/v1beta1/query_grpc.pb.go
- client/docs/swagger-ui/swagger.yaml
- x/nft/query.pb.go
- x/nft/query.pb.gw.go
Files selected for processing (3)
- proto/cosmos/nft/v1beta1/query.proto (5 hunks)
- x/nft/keeper/grpc_query.go (5 hunks)
- x/nft/keeper/grpc_query_test.go (5 hunks)
Additional comments: 25
x/nft/keeper/grpc_query.go (5)
34-56: The function
BalanceByQueryString
is similar toBalance
but accepts a request via a query string. Ensure that the query string is properly parsed and validated before being used in the function. Also, consider adding error handling for invalid query strings.81-109: The function
OwnerByQueryString
is similar toOwner
but accepts a request via a query string. Ensure that the query string is properly parsed and validated before being used in the function. Also, consider adding error handling for invalid query strings.122-138: The function
SupplyByQueryString
is similar toSupply
but accepts a request via a query string. Ensure that the query string is properly parsed and validated before being used in the function. Also, consider adding error handling for invalid query strings.220-242: The function
NFTByQueryString
is similar toNFT
but accepts a request via a query string. Ensure that the query string is properly parsed and validated before being used in the function. Also, consider adding error handling for invalid query strings.260-279: The function
ClassByQueryString
is similar toClass
but accepts a request via a query string. Ensure that the query string is properly parsed and validated before being used in the function. Also, consider adding error handling for invalid query strings.proto/cosmos/nft/v1beta1/query.proto (15)
14-20: The new RPC method
BalanceByQueryString
has been added. Ensure that the server-side implementation correctly handles the query string parameters.28-30: The new RPC method
OwnerByQueryString
has been added. Ensure that the server-side implementation correctly handles the query string parameters.38-40: The new RPC method
SupplyByQueryString
has been added. Ensure that the server-side implementation correctly handles the query string parameters.54-56: The new RPC method
NFTByQueryString
has been added. Ensure that the server-side implementation correctly handles the query string parameters.64-66: The new RPC method
ClassByQueryString
has been added. Ensure that the server-side implementation correctly handles the query string parameters.83-90: The new request message type
QueryBalanceByQueryStringRequest
has been added. Ensure that the server-side implementation correctly handles the fields in this message.98-102: The new response message type
QueryBalanceByQueryStringResponse
has been added. Ensure that the server-side implementation correctly populates the fields in this message.113-120: The new request message type
QueryOwnerByQueryStringRequest
has been added. Ensure that the server-side implementation correctly handles the fields in this message.128-132: The new response message type
QueryOwnerByQueryStringResponse
has been added. Ensure that the server-side implementation correctly populates the fields in this message.140-144: The new request message type
QuerySupplyByQueryStringRequest
has been added. Ensure that the server-side implementation correctly handles the fields in this message.152-156: The new response message type
QuerySupplyByQueryStringResponse
has been added. Ensure that the server-side implementation correctly populates the fields in this message.188-195: The new request message type
QueryNFTByQueryStringRequest
has been added. Ensure that the server-side implementation correctly handles the fields in this message.203-207: The new response message type
QueryNFTByQueryStringResponse
has been added. Ensure that the server-side implementation correctly populates the fields in this message.215-219: The new request message type
QueryClassByQueryStringRequest
has been added. Ensure that the server-side implementation correctly handles the fields in this message.227-231: The new response message type
QueryClassByQueryStringResponse
has been added. Ensure that the server-side implementation correctly populates the fields in this message.x/nft/keeper/grpc_query_test.go (5)
83-146: The
TestBalanceByQueryString
function tests theBalanceByQueryString
method. It covers various scenarios including emptyClassId
, invalidOwner
address, and successful query. The test cases are well-structured and cover the necessary edge cases. However, it would be better to add a test case for a non-existentOwner
address.237-324: The
TestOwnerByQueryString
function tests theOwnerByQueryString
method. It covers various scenarios including emptyClassId
, emptynft id
, non-existentnft id
, non-existentClassId
, and successful query. The test cases are well-structured and cover the necessary edge cases.409-491: The
TestSupplyByQueryString
function tests theSupplyByQueryString
method. It covers various scenarios including emptyClassId
, non-existentClassId
, zero supply, and successful query. The test cases are well-structured and cover the necessary edge cases.708-793: The
TestNFTByQueryString
function tests theNFTByQueryString
method. It covers various scenarios including emptyClassId
, emptynft id
, non-existentClassId
, non-existentnft id
, and successful query. The test cases are well-structured and cover the necessary edge cases.862-927: The
TestClassByQueryString
function tests theClassByQueryString
method. It covers various scenarios including emptyClassId
, non-existentClassId
, and successful query. The test cases are well-structured and cover the necessary edge cases.
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.
CHANGELOG.md
Outdated
@@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ | |||
* (server) [#17094](https://github.com/cosmos/cosmos-sdk/pull/17094) Add duration `shutdown-grace` for resource clean up (closing database handles) before exit. | |||
* (x/auth/vesting) [#17810](https://github.com/cosmos/cosmos-sdk/pull/17810) Add the ability to specify a start time for continuous vesting accounts. | |||
* (baseapp) [#18071](https://github.com/cosmos/cosmos-sdk/pull/18071) Add hybrid handlers to `MsgServiceRouter`. | |||
* (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query 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.
There's a typo in the changelog entry. It should be "Adds" instead of "Addes". Also, there's an extra period at the end of the sentence. Here's the corrected version:
- * (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query string..
+ * (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Adds new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receive requests via query string.
Commitable suggestion (Beta)
* (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query string.. | |
* (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Adds new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receive requests via query string. | |
[ISSUE] |
Co-authored-by: Julien Robert <julien@rbrt.fr>
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.
CHANGELOG.md
Outdated
@@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ | |||
* (server) [#17094](https://github.com/cosmos/cosmos-sdk/pull/17094) Add duration `shutdown-grace` for resource clean up (closing database handles) before exit. | |||
* (x/auth/vesting) [#17810](https://github.com/cosmos/cosmos-sdk/pull/17810) Add the ability to specify a start time for continuous vesting accounts. | |||
* (baseapp) [#18071](https://github.com/cosmos/cosmos-sdk/pull/18071) Add hybrid handlers to `MsgServiceRouter`. | |||
* (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query 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.
Minor typo in the changelog entry. It should be "Adds" instead of "Addes".
- * (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query string.
+ * (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Adds new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query string.
Commitable suggestion (Beta)
* (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query string. | |
* (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Adds new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query 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.
mostly lgtm! however, we can simplufy grpc_query.go.
x/nft/keeper/grpc_query.go
Outdated
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.
Imho, XXXByQueryString
should simply call the other method XXX
with the request correctly filled.
This avoids repeating the method logic, which could inevitably differ mistakenly after a while.
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.
mostly lgtm! however, we can simplify grpc_query.go.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- x/nft/keeper/grpc_query.go (5 hunks)
Files skipped from review due to trivial changes (1)
- x/nft/keeper/grpc_query.go
CHANGELOG.md
Outdated
@@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ | |||
* (server) [#17094](https://github.com/cosmos/cosmos-sdk/pull/17094) Add duration `shutdown-grace` for resource clean up (closing database handles) before exit. | |||
* (x/auth/vesting) [#17810](https://github.com/cosmos/cosmos-sdk/pull/17810) Add the ability to specify a start time for continuous vesting accounts. | |||
* (baseapp) [#18071](https://github.com/cosmos/cosmos-sdk/pull/18071) Add hybrid handlers to `MsgServiceRouter`. | |||
* (x/nft) [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query 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.
lgtm, can you delete this and put it under x/nft/CHANGELOG.md
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.
Thanks, did 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.
x/nft/CHANGELOG.md
Outdated
### Features | ||
|
||
* [#17825](https://github.com/cosmos/cosmos-sdk/pull/17825) Add AutoCLI Options. | ||
* [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query 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.
Typographical error in the changelog entry. The word "Addes" should be corrected to "Adds", and "receives" should be "receive" to match subject-verb agreement.
- * [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query string.
+ * [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Adds new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receive requests via query string.
Commitable suggestion
[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.
### Features | |
* [#17825](https://github.com/cosmos/cosmos-sdk/pull/17825) Add AutoCLI Options. | |
* [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Addes new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receives request via query string. | |
### Features | |
* [#17825](https://github.com/cosmos/cosmos-sdk/pull/17825) Add AutoCLI Options. | |
* [#18355](https://github.com/cosmos/cosmos-sdk/pull/18355) Adds new versions for `Balance`, `Owner`, `Supply`, `NFT`, `Class` queries that receive requests via query 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.
lgtm! thank you
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.
one last nit
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.
Can you add a since comment above all the messages and rpcs?
@@ -55,12 +80,27 @@ message QueryBalanceRequest { | |||
string owner = 2; | |||
} | |||
|
|||
// QueryBalanceByQueryStringRequest is the request type for the Query/Balance RPC method | |||
message QueryBalanceByQueryStringRequest { |
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.
message QueryBalanceByQueryStringRequest { | |
// | |
// Since: nft v0.1.1 | |
message QueryBalanceByQueryStringRequest { |
@@ -14,16 +14,31 @@ service Query { | |||
option (google.api.http).get = "/cosmos/nft/v1beta1/balance/{owner}/{class_id}"; | |||
} | |||
|
|||
// BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 | |||
rpc BalanceByQueryString(QueryBalanceByQueryStringRequest) returns (QueryBalanceByQueryStringResponse) { |
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.
rpc BalanceByQueryString(QueryBalanceByQueryStringRequest) returns (QueryBalanceByQueryStringResponse) { | |
// | |
// Since: nft v0.1.1 | |
rpc BalanceByQueryString(QueryBalanceByQueryStringRequest) returns (QueryBalanceByQueryStringResponse) { |
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.
Description
Closes: #17488
Addes new versions for
Balance
,Owner
,Supply
,NFT
,Class
that receives request via query string.Tested new funcs
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
make lint
andmake test
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 changeSummary by CodeRabbit
New Features
Documentation