Skip to content

feat(sdk): fetch token contract info#2670

Merged
QuantumExplorer merged 4 commits into
v2.0-devfrom
feat/fetch-token-contract-info
Jun 11, 2025
Merged

feat(sdk): fetch token contract info#2670
QuantumExplorer merged 4 commits into
v2.0-devfrom
feat/fetch-token-contract-info

Conversation

@pauldelucia
Copy link
Copy Markdown
Member

@pauldelucia pauldelucia commented Jun 11, 2025

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:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Added support for querying and fetching token contract information using a new query structure and gRPC transport.
    • Introduced a module for handling token contract info queries and responses.
    • Enabled serialization and deserialization of token contract info for mock testing.
  • Tests

    • Added unit tests to verify fetching and querying of token contract information, including request construction and response handling.
  • Documentation

    • Included documentation comments for the new token contract info query module.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 11, 2025

Walkthrough

This 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

File(s) Change Summary
.../src/transport/grpc.rs Added gRPC transport request implementation for get_token_contract_info.
.../src/proof.rs
.../src/proof/token_contract_info.rs
Exported new token_contract_info module; implemented FromProof for token contract info proof verification.
.../src/mock/requests.rs Implemented MockResponse trait for TokenContractInfo for serialization/deserialization.
.../src/platform/fetch.rs Implemented Fetch trait for TokenContractInfo with associated request type.
.../src/platform/tokens/mod.rs
.../src/platform/tokens/token_contract_info.rs
Added token_contract_info module; defined query struct and implemented Query trait for token contract info.
.../tests/fetch/tokens/mod.rs
.../tests/fetch/tokens/token_contract_info.rs
Added test module and async unit tests for token contract info fetch and query behavior.

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.
Loading

Poem

In the warren of code, a new path appears,
Token contracts unveiled, dispelling old fears.
With queries and proofs, the journey begins,
Mock bunnies test fetches, ensuring all wins.
From gRPC calls to bytes on the wire—
This hop brings new features for all to admire!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b358f7 and 2aa22a3.

📒 Files selected for processing (2)
  • packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs (1 hunks)
  • packages/rs-sdk/src/platform/tokens/token_contract_info.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/rs-sdk/src/platform/tokens/token_contract_info.rs
  • packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (rs-dapi-client) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (rs-dapi-client) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (rs-dapi-client) / Unused dependencies
  • GitHub Check: Rust packages (rs-dapi-client) / Linting
  • 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 Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build JS packages / Build JS
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pauldelucia pauldelucia marked this pull request as ready for review June 11, 2025 10:30
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id variable 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa63dc and 1b358f7.

📒 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: Add token_contract_info test module
Good to see the new submodule integrated into the test suite. Ensure token_contract_info.rs exists and is picked up by cargo test.

packages/rs-sdk/src/platform/tokens/mod.rs (1)

4-5: Expose token_contract_info in platform tokens API
The new module is correctly documented and added. Confirm that token_contract_info.rs implements the expected query and serialization logic.

packages/rs-drive-proof-verifier/src/proof.rs (1)

3-3: Export token_contract_info proof module
The proof verifier now publicly exposes the new token_contract_info module. Verify that its FromProof implementation aligns with the gRPC response structure.

packages/rs-sdk/src/platform/fetch.rs (1)

301-304: Implement Fetch for TokenContractInfo
The Fetch trait is correctly implemented using GetTokenContractInfoRequest. Ensure that TokenContractInfoQuery implements Query for this request and that mock support is in place.

packages/rs-dapi-client/src/transport/grpc.rs (1)

609-616: Add gRPC transport request for get_token_contract_info
The new TransportRequest implementation follows the existing pattern with default settings and the correct method name. Confirm that the service definition matches get_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=true and correctly verifies both the token_id and prove flag in the generated request.


62-75: LGTM!

The test properly validates query construction with prove=false and correctly verifies the prove flag is set to false in the request.

packages/rs-sdk/src/mock/requests.rs (1)

391-404: LGTM!

The MockResponse implementation for TokenContractInfo follows the established pattern and correctly uses platform serialization methods.

packages/rs-sdk/src/platform/tokens/token_contract_info.rs (3)

6-11: LGTM!

The TokenContractInfoQuery struct is well-defined with appropriate derives and documentation.


13-26: LGTM!

The Query implementation 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 hardcoded false parameter in verify_token_contract_info.

The third parameter to Drive::verify_token_contract_info is hardcoded as false. This appears to be the verify_subset_of_proof parameter. Consider if this should be configurable based on the request parameters or if false is always the correct value for this use case.

Could you verify if the verify_subset_of_proof parameter should always be false for token contract info verification, or if it should be derived from the request?

@QuantumExplorer QuantumExplorer merged commit 04a84f9 into v2.0-dev Jun 11, 2025
29 of 31 checks passed
@QuantumExplorer QuantumExplorer deleted the feat/fetch-token-contract-info branch June 11, 2025 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants