-
Notifications
You must be signed in to change notification settings - Fork 89
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
[TRA-181] Add query function for collateral pool address. #1256
[TRA-181] Add query function for collateral pool address. #1256
Conversation
WalkthroughThe update introduces a new RPC method, Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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 path filters (2)
protocol/x/subaccounts/types/query.pb.go
is excluded by:!**/*.pb.go
protocol/x/subaccounts/types/query.pb.gw.go
is excluded by:!**/*.pb.gw.go
Files selected for processing (3)
- proto/dydxprotocol/subaccounts/query.proto (2 hunks)
- protocol/x/subaccounts/keeper/grpc_query_collateral_pool.go (1 hunks)
- protocol/x/subaccounts/keeper/grpc_query_collateral_pool_test.go (1 hunks)
Additional comments: 9
protocol/x/subaccounts/keeper/grpc_query_collateral_pool.go (6)
- 19-20: Ensure that the error message provided for an invalid request is descriptive enough to help the caller understand what constitutes a valid request.
- 22-22: The use of
lib.UnwrapSDKContext
with a module name is an interesting approach. Verify that this method correctly handles the context unwrapping and that the module name is used appropriately within this context.- 24-27: This segment fetches the collateral pool address using the perpetual ID. Ensure that
GetCollateralPoolFromPerpetualId
method efficiently handles the lookup and consider caching mechanisms if this operation is expected to be high frequency.- 29-37: Good error handling for a specific case where the perpetual ID does not exist. This provides clear feedback to the caller.
- 40-40: Consider providing more detailed error information for the generic internal error case to aid in debugging. This could include logging the original error message or categorizing internal errors more granularly.
- 43-45: Returning the collateral pool address as a string is straightforward. Verify that the
.String()
method ofcollateralPool
provides the expected format and consider any potential formatting issues.protocol/x/subaccounts/keeper/grpc_query_collateral_pool_test.go (1)
- 16-68: The test cases cover a good range of scenarios including error conditions and successful queries. Ensure that all edge cases are covered, especially those involving invalid input formats and boundary conditions for perpetual IDs.
proto/dydxprotocol/subaccounts/query.proto (2)
- 36-40: The RPC method
CollateralPoolAddress
is clearly defined with an appropriate HTTP GET path. Ensure that the path parameterperpetual_id
is correctly handled in the implementation of the HTTP endpoint.- 81-91: The request and response message types for
CollateralPoolAddress
are well-defined. Verify that theperpetual_id
field in the request and thecollateral_pool_address
field in the response are correctly used and formatted in the implementation.
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)
- protocol/mocks/QueryClient.go (1 hunks)
Additional comments: 1
protocol/mocks/QueryClient.go (1)
- 366-401: The implementation of the
CollateralPoolAddress
mock function is consistent with the expected patterns for gRPC query functions and the use of testify for mocking. The function signature, mock setup, return value handling, and panic condition are all correctly implemented.
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 path filters (1)
protocol/x/subaccounts/types/query.pb.go
is excluded by:!**/*.pb.go
Files selected for processing (3)
- indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.lcd.ts (3 hunks)
- indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.ts (5 hunks)
- indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.ts (2 hunks)
Additional comments: 3
indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.lcd.ts (1)
- 53-55: The implementation of
collateralPoolAddress
looks correct and follows best practices for async functions and endpoint construction. However, consider adding a comment about error handling, especially ifthis.req.get
does not handle errors internally. This can help future maintainers understand where and how errors should be managed.indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.ts (1)
- 54-57: The implementation of
collateralPoolAddress
in both the interface andQueryClientImpl
is correct, utilizing protobuf encoding/decoding and making an RPC request appropriately. Consider adding a comment about error handling practices, especially if errors are handled by the RPC framework or upstream, to guide future maintainers.indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/query.ts (1)
- 93-132: The new interfaces for the
collateralPoolAddress
query and their SDKType counterparts are correctly defined, and the functions for creating base requests and encoding/decoding responses are implemented appropriately. The use of protobuf for encoding and decoding is correctly applied, ensuring type safety and efficient data serialization.
@@ -29,7 +29,15 @@ service Query { | |||
QueryGetWithdrawalAndTransfersBlockedInfoRequest) | |||
returns (QueryGetWithdrawalAndTransfersBlockedInfoResponse) { | |||
option (google.api.http).get = | |||
"/dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info"; | |||
"/dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info/" | |||
"{perpetual_id}"; |
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.
Is this supposed to be part of this change?
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, I noticed I didn't update the URL in a previous PR so rolled it up into this one. Going to update the description.
Changelist
Add gRPC query to get the collateral pool address given a perpetual id.
Misc. change:
GetWithdrawalAndTransfersBlockedInfo
Test Plan
Unit tests.
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.