feat(sdk): fetch token contract info#2670
Conversation
WalkthroughThis change introduces support for querying token contract information across several Rust packages. It adds new modules, traits, and implementations to handle gRPC transport requests, proof verification, SDK fetch/query logic, and corresponding unit tests. The updates include serialization, deserialization, and error handling for token contract info queries and responses. Changes
Sequence Diagram(s)sequenceDiagram
participant SDK
participant PlatformGrpcClient
participant ProofVerifier
participant MockSDK
SDK->>PlatformGrpcClient: Send GetTokenContractInfoRequest
PlatformGrpcClient-->>SDK: Return GetTokenContractInfoResponse
SDK->>ProofVerifier: Verify proof from response
ProofVerifier-->>SDK: Return TokenContractInfo or error
Note over SDK,MockSDK: In tests, MockSDK serializes/deserializes TokenContractInfo and simulates fetches.
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (12)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/rs-sdk/tests/fetch/tokens/token_contract_info.rs (1)
15-18: Consider verifying the token_id in mock expectations.The mock expectation accepts any token_id without verification. Consider using the specific
token_idvariable in the expectation to ensure the correct identifier is being passed through.sdk.mock() - .expect_fetch(token_id, None as Option<TokenContractInfo>) + .expect_fetch(token_id.clone(), None as Option<TokenContractInfo>)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
packages/rs-dapi-client/src/transport/grpc.rs(1 hunks)packages/rs-drive-proof-verifier/src/proof.rs(1 hunks)packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs(1 hunks)packages/rs-sdk/src/mock/requests.rs(2 hunks)packages/rs-sdk/src/platform/fetch.rs(1 hunks)packages/rs-sdk/src/platform/tokens/mod.rs(1 hunks)packages/rs-sdk/src/platform/tokens/token_contract_info.rs(1 hunks)packages/rs-sdk/tests/fetch/tokens/mod.rs(1 hunks)packages/rs-sdk/tests/fetch/tokens/token_contract_info.rs(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/rs-dapi-client/src/transport/grpc.rs (1)
packages/rs-drive-abci/src/query/service.rs (1)
get_token_contract_info(770-780)
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: Rust packages (dash-sdk) / Formatting
- GitHub Check: Rust packages (dash-sdk) / Linting
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (rs-dapi-client) / Check each feature
- GitHub Check: Rust packages (dash-sdk) / Unused dependencies
- GitHub Check: Rust packages (rs-dapi-client) / Tests
- GitHub Check: Rust packages (rs-dapi-client) / Unused dependencies
- GitHub Check: Rust packages (rs-dapi-client) / Linting
- GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
- GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
- GitHub Check: Build JS packages / Build JS
🔇 Additional comments (13)
packages/rs-sdk/tests/fetch/tokens/mod.rs (1)
2-2: Addtoken_contract_infotest module
Good to see the new submodule integrated into the test suite. Ensuretoken_contract_info.rsexists and is picked up bycargo test.packages/rs-sdk/src/platform/tokens/mod.rs (1)
4-5: Exposetoken_contract_infoin platform tokens API
The new module is correctly documented and added. Confirm thattoken_contract_info.rsimplements the expected query and serialization logic.packages/rs-drive-proof-verifier/src/proof.rs (1)
3-3: Exporttoken_contract_infoproof module
The proof verifier now publicly exposes the newtoken_contract_infomodule. Verify that itsFromProofimplementation aligns with the gRPC response structure.packages/rs-sdk/src/platform/fetch.rs (1)
301-304: ImplementFetchforTokenContractInfo
TheFetchtrait is correctly implemented usingGetTokenContractInfoRequest. Ensure thatTokenContractInfoQueryimplementsQueryfor this request and that mock support is in place.packages/rs-dapi-client/src/transport/grpc.rs (1)
609-616: Add gRPC transport request forget_token_contract_info
The newTransportRequestimplementation follows the existing pattern with default settings and the correct method name. Confirm that the service definition matchesget_token_contract_info.packages/rs-sdk/tests/fetch/tokens/token_contract_info.rs (3)
26-45: LGTM!The test correctly validates fetching with an explicit query and properly verifies the query object in the mock expectation.
47-60: LGTM!The test properly validates query construction with
prove=trueand correctly verifies both the token_id and prove flag in the generated request.
62-75: LGTM!The test properly validates query construction with
prove=falseand correctly verifies the prove flag is set to false in the request.packages/rs-sdk/src/mock/requests.rs (1)
391-404: LGTM!The
MockResponseimplementation forTokenContractInfofollows the established pattern and correctly uses platform serialization methods.packages/rs-sdk/src/platform/tokens/token_contract_info.rs (3)
6-11: LGTM!The
TokenContractInfoQuerystruct is well-defined with appropriate derives and documentation.
13-26: LGTM!The
Queryimplementation correctly constructs the gRPC request with proper version handling and token ID conversion.
28-32: LGTM!Nice ergonomic convenience implementation that allows direct querying from an
Identifier.packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs (1)
46-52: Clarify the hardcodedfalseparameter inverify_token_contract_info.The third parameter to
Drive::verify_token_contract_infois hardcoded asfalse. This appears to be theverify_subset_of_proofparameter. Consider if this should be configurable based on the request parameters or iffalseis always the correct value for this use case.Could you verify if the
verify_subset_of_proofparameter should always befalsefor token contract info verification, or if it should be derived from the request?
Issue being fixed or feature implemented
Implemented Fetch for TokenContractInfo, making use of the new gRPC call.
What was done?
^
How Has This Been Tested?
Added SDK tests and tested in DET.
Breaking Changes
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Tests
Documentation