-
Notifications
You must be signed in to change notification settings - Fork 45
fix(sdk): non proved JS SDK methods #2871
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
base: v3.0-dev
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughImplements proof-enabled query endpoints in the Wasm SDK and JS SDK tests, adds trusted-context token-configuration caching APIs in the Rust provider, and introduces token-prefetching and moment-based last-claim conversions in Wasm token queries. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant WASM as Wasm SDK
participant EpochQuery as Epoch Query Handler
participant Service as ProposerBlockCount Service
participant Context as Trusted Context
Client->>WASM: getEvonodesProposedEpochBlocksByIdsWithProofInfo(epoch, ids)
WASM->>EpochQuery: validate & parse ProTxHash ids
EpochQuery->>Service: fetch_many_with_metadata_and_proof(ids, epoch)
Service-->>EpochQuery: counts, metadata, proof
EpochQuery->>Context: (optional) check/add known token configuration
EpochQuery-->>WASM: ProofMetadataResponseWasm{data: Map, proof, metadata}
WASM-->>Client: return proof-enabled response
sequenceDiagram
autonumber
actor Client
participant WASM as Wasm SDK
participant ProtocolQuery as Protocol Query Handler
participant VoteService as MasternodeProtocolVote Service
Client->>WASM: getProtocolVersionUpgradeVoteStatusWithProofInfo(startProTxHash, count)
WASM->>ProtocolQuery: parse startProTxHash (string|Uint8Array)
ProtocolQuery->>VoteService: fetch_many_with_metadata_and_proof(LimitQuery)
VoteService-->>ProtocolQuery: votes, metadata, proof
ProtocolQuery-->>WASM: ProofMetadataResponseWasm{Map<string, VoteStatus>, proof, metadata}
WASM-->>Client: return proof-enabled response
sequenceDiagram
autonumber
actor Client
participant WASM as Wasm SDK
participant TokenQuery as Token Query Handler
participant Context as Trusted Context
participant Fallback as Fallback Provider
Client->>WASM: token query requiring configuration (token_id)
WASM->>TokenQuery: prefetch_token_configuration(token_id)
TokenQuery->>Context: check known_token_configurations cache
alt cached
Context-->>TokenQuery: cached TokenConfiguration
else not cached
TokenQuery->>Fallback: fetch TokenContractInfo & DataContract
Fallback-->>TokenQuery: contract data
TokenQuery->>Context: add_known_token_configuration(token_id, config)
Context-->>TokenQuery: cache stored
end
TokenQuery->>TokenQuery: perform proof-aware fetch (e.g., last-claim)
TokenQuery-->>WASM: ProofMetadataResponseWasm
WASM-->>Client: return result with proof and metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
… upgrade state queries
get_token_perpetual_distribution_last_claim
✅ gRPC Query Coverage Report |
…ity in context provider and queries
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.
Actionable comments posted: 1
🧹 Nitpick comments (4)
packages/wasm-sdk/tests/functional/protocol.spec.mjs (1)
39-46: Consider extractingSTART_PROTXto describe-level scope.The
START_PROTXconstant is duplicated at lines 34 and 40. Consider defining it once at the describe block level for better maintainability.🔎 Proposed refactor
describe('Protocol versions', function describeProtocolVersions() { this.timeout(60000); let client; let builder; + const START_PROTX = '143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113'; // ... in tests, remove local declarations and use the shared constantpackages/wasm-sdk/src/queries/token.rs (2)
506-514: Clarify the semantic meaning oflast_claim_block_heightforEpochBasedMoment.When handling
EpochBasedMoment, the epoch value is stored inlast_claim_block_height. This could be semantically confusing to consumers since an epoch is not a block height. Consider either:
- Adding a comment explaining this mapping, or
- Extending
TokenLastClaimWasmwith anepochfield for clearer semantics.
882-896: Reduce code duplication between proof and non-proof variants.The
RewardDistributionMomenttoTokenLastClaimWasmmapping logic is duplicated betweenget_token_perpetual_distribution_last_claim(lines 506-514) andget_token_perpetual_distribution_last_claim_with_proof_info(lines 882-896). Consider extracting this to a helper function.🔎 Proposed helper extraction
fn moment_to_last_claim_wasm(moment: RewardDistributionMoment) -> TokenLastClaimWasm { let (last_claim_timestamp_ms, last_claim_block_height) = match moment { RewardDistributionMoment::BlockBasedMoment(height) => (0, height), RewardDistributionMoment::TimeBasedMoment(timestamp) => (timestamp, 0), RewardDistributionMoment::EpochBasedMoment(epoch) => (0, epoch as u64), }; TokenLastClaimWasm::new(last_claim_timestamp_ms, last_claim_block_height) }packages/wasm-sdk/src/queries/protocol.rs (1)
270-294: Consider extracting ProTxHash parsing logic to reduce duplication.The ProTxHash parsing logic (lines 270-294) is duplicated from
get_protocol_version_upgrade_vote_status(lines 160-183). Consider extracting this to a helper function.🔎 Proposed helper extraction
fn parse_optional_pro_tx_hash(js_value: JsValue) -> Result<Option<ProTxHash>, WasmSdkError> { use dash_sdk::dpp::dashcore::hashes::{sha256d, Hash as _}; use dash_sdk::dpp::dashcore::ProTxHash; use std::str::FromStr; if let Some(s) = js_value.as_string() { if s.is_empty() { Ok(None) } else { ProTxHash::from_str(&s) .map(Some) .map_err(|e| WasmSdkError::invalid_argument(format!("Invalid ProTxHash: {}", e))) } } else { let bytes = js_sys::Uint8Array::new(&js_value).to_vec(); if bytes.is_empty() { Ok(None) } else if bytes.len() != 32 { Err(WasmSdkError::invalid_argument( "ProTxHash must be 32 bytes or an empty value", )) } else { let mut arr = [0u8; 32]; arr.copy_from_slice(&bytes); let raw = sha256d::Hash::from_byte_array(arr); Ok(Some(ProTxHash::from_raw_hash(raw))) } } }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
.github/grpc-queries-cache.jsonpackages/js-evo-sdk/tests/functional/epoch.spec.mjspackages/js-evo-sdk/tests/functional/protocol.spec.mjspackages/rs-sdk-trusted-context-provider/src/provider.rspackages/wasm-sdk/src/context_provider.rspackages/wasm-sdk/src/queries/epoch.rspackages/wasm-sdk/src/queries/protocol.rspackages/wasm-sdk/src/queries/token.rspackages/wasm-sdk/tests/functional/epochs-blocks.spec.mjspackages/wasm-sdk/tests/functional/protocol.spec.mjs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/context_provider.rspackages/wasm-sdk/src/queries/token.rspackages/wasm-sdk/src/queries/protocol.rspackages/rs-sdk-trusted-context-provider/src/provider.rspackages/wasm-sdk/src/queries/epoch.rs
🧠 Learnings (13)
📓 Common learnings
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/wasm-sdk/tests/functional/protocol.spec.mjspackages/wasm-sdk/src/queries/protocol.rspackages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-02-10T11:26:36.709Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Applied to files:
packages/wasm-sdk/tests/functional/protocol.spec.mjspackages/wasm-sdk/src/queries/protocol.rspackages/wasm-sdk/src/queries/epoch.rspackages/wasm-sdk/tests/functional/epochs-blocks.spec.mjs
📚 Learning: 2025-11-25T13:10:38.019Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: packages/swift-sdk/SwiftExampleApp/CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:38.019Z
Learning: Applies to packages/swift-sdk/SwiftExampleApp/**/PersistentToken.swift : Provide predicate methods for PersistentToken querying: mintableTokensPredicate(), burnableTokensPredicate(), freezableTokensPredicate(), distributionTokensPredicate(), pausedTokensPredicate(), tokensByContractPredicate(contractId:), and tokensWithControlRulePredicate(rule:)
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount from crate::balances::credits is compatible with u64 when used for token base supply.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount is defined as `type TokenAmount = u64` in balances/credits.rs, making it directly compatible with u64 values without any conversion needed.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-15T08:09:59.365Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2422
File: packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs:152-163
Timestamp: 2025-01-15T08:09:59.365Z
Learning: In the `transition_to_version_8` function, errors from `grove_get_path_query` when retrieving active contested resource votes are intentionally logged and ignored (returning `Ok(())`) to allow the protocol upgrade to proceed despite query failures.
Applied to files:
packages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.
Applied to files:
packages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2025-01-23T09:23:32.740Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/rs-sdk/src/sync.rs:88-95
Timestamp: 2025-01-23T09:23:32.740Z
Learning: The `block_on` function in `packages/rs-sdk/src/sync.rs` is currently only used in tests, and its WebAssembly implementation is deferred until there's a user request for it.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-01-23T09:23:32.740Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/rs-sdk/src/sync.rs:88-95
Timestamp: 2025-01-23T09:23:32.740Z
Learning: The `block_on` function in `packages/rs-sdk/src/sync.rs` requires true blocking behavior, which is why a non-blocking WebAssembly implementation using `wasm_bindgen_futures::spawn_local` is not suitable.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-09-03T19:33:21.688Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/api-definitions.json:1285-1285
Timestamp: 2025-09-03T19:33:21.688Z
Learning: In packages/wasm-sdk/api-definitions.json, thephez prefers to keep the existing "ripemd160hash20bytes1234" placeholder for ECDSA_HASH160 data field in documentation examples rather than using a valid base64-encoded format, maintaining consistency with the previous documentation approach.
Applied to files:
packages/wasm-sdk/tests/functional/epochs-blocks.spec.mjs
🧬 Code graph analysis (6)
packages/js-evo-sdk/tests/functional/protocol.spec.mjs (1)
packages/wasm-sdk/tests/functional/protocol.spec.mjs (3)
res(26-26)res(35-35)res(41-41)
packages/js-evo-sdk/tests/functional/epoch.spec.mjs (2)
packages/js-evo-sdk/tests/functional/protocol.spec.mjs (5)
res(14-14)res(19-19)res(27-27)res(32-32)sdk(6-6)packages/wasm-sdk/tests/functional/epochs-blocks.spec.mjs (2)
res(51-51)res(59-62)
packages/wasm-sdk/src/context_provider.rs (2)
packages/rs-sdk-trusted-context-provider/src/provider.rs (1)
add_known_token_configuration(216-219)packages/wasm-sdk/src/queries/token.rs (1)
token_id(43-45)
packages/wasm-sdk/tests/functional/protocol.spec.mjs (1)
packages/js-evo-sdk/tests/functional/protocol.spec.mjs (4)
res(14-14)res(19-19)res(27-27)res(32-32)
packages/wasm-sdk/src/queries/protocol.rs (3)
packages/wasm-sdk/src/error.rs (1)
invalid_argument(75-77)packages/wasm-sdk/src/queries/mod.rs (5)
metadata(278-280)proof(288-290)from(100-109)from(212-221)from_sdk_parts(333-339)packages/rs-sdk/src/platform/fetch_many.rs (1)
fetch_many_with_metadata_and_proof(205-255)
packages/wasm-sdk/src/queries/epoch.rs (4)
packages/wasm-sdk/src/queries/mod.rs (5)
metadata(278-280)proof(288-290)from(100-109)from(212-221)from_sdk_parts(333-339)packages/wasm-sdk/src/error.rs (1)
invalid_argument(75-77)packages/rs-sdk/src/platform/fetch_many.rs (1)
fetch_many_with_metadata_and_proof(205-255)packages/wasm-dpp2/src/identifier.rs (4)
from(23-25)from(29-31)from(35-37)from(41-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
- GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Rust crates security audit
🔇 Additional comments (14)
.github/grpc-queries-cache.json (1)
145-156: Verify that these address-related queries belong in this PR.The PR objectives state this PR is about fixing non-proved JS SDK methods for token, protocol, and evonode queries. However, these newly added address-related queries (
getAddressInfo,getAddressesBranchState,getAddressesInfos,getAddressesTrunkState) are not mentioned anywhere in the PR description, commit messages, or related context.Please confirm whether:
- These changes are intentionally part of this PR, or
- They should be moved to a separate PR focused on address query functionality
packages/js-evo-sdk/tests/functional/epoch.spec.mjs (1)
27-42: LGTM!The new test cases for proof-enabled epoch query variants are well-structured, follow existing patterns in the file, and appropriately verify the presence of
data,proof, andmetadatain the responses.packages/js-evo-sdk/tests/functional/protocol.spec.mjs (1)
18-37: LGTM!The new tests for
versionUpgradeStateWithProof()andversionUpgradeVoteStatusWithProof()follow the established pattern and correctly verify the presence of proof and metadata in the responses.packages/wasm-sdk/src/context_provider.rs (2)
109-110: LGTM!Enabling
refetch_if_not_foundby default for both mainnet and testnet aligns with the rs-sdk behavior and ensures token configurations (and other context) are pulled on demand.Also applies to: 124-125
167-171: LGTM!The new
add_known_token_configurationmethod follows the same delegation pattern as the existingadd_known_contractmethod and correctly exposes the inner provider's caching capability.packages/wasm-sdk/tests/functional/protocol.spec.mjs (1)
25-31: LGTM!The test correctly verifies that the protocol upgrade state with proof returns the expected structure including
data,proof, andmetadata.packages/wasm-sdk/src/queries/token.rs (1)
913-984: LGTM with a minor observation.The
prefetch_token_configurationhelper is well-structured. For networks other than Mainnet/Testnet (lines 976-979), the function silently continues without caching. This is acceptable since proof verification may still work if the context provider has the info through other means. The comment explains this behavior well.packages/wasm-sdk/src/queries/protocol.rs (1)
254-325: LGTM - Implementation is correct.The implementation properly handles ProTxHash parsing, creates the
LimitQuery, fetches with metadata and proof, and constructs the response. The logic aligns with the non-proof variant.packages/rs-sdk-trusted-context-provider/src/provider.rs (3)
64-66: LGTM!The new
known_token_configurationscache follows the same pattern as the existingknown_contractscache usingArc<Mutex<HashMap>>.
215-230: LGTM!The
add_known_token_configurationandadd_known_token_configurationsmethods follow the same pattern as the existingadd_known_contractandadd_known_contractsmethods.
771-776: LGTM!The
get_token_configurationmethod correctly checks the known token configurations cache first and properly drops the lock before delegating to the fallback provider, avoiding potential deadlocks.packages/wasm-sdk/src/queries/epoch.rs (2)
520-563: LGTM!The implementation correctly parses ProTxHash strings, fetches with metadata and proof, and constructs the response. The logic mirrors the non-proof variant with added proof handling.
565-608: LGTM!The implementation correctly creates a
LimitQuery, fetches proposed blocks by range with metadata and proof, and wraps the result inProofMetadataResponseWasm.Note: The
order_ascendingfield is explicitly ignored (line 579), which is consistent with the non-proof version (line 380). If ordering support is planned for the future, consider adding a TODO comment.packages/wasm-sdk/tests/functional/epochs-blocks.spec.mjs (1)
58-67: No critical syntax issues found, but verify intentional API differences.The
.ok()syntax is valid in Chai—both.ok(property) and.ok()(function-call) forms are supported and functionally identical, so the assertions at lines 63, 65, and 66 are correct as written.However, the proof-enabled test (lines 58–67) omits the
startAfterparameter that the non-proof variant includes (line 44). Clarify whether this difference is intentional or if the test should includestartAfterfor complete coverage.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/wasm-sdk/src/queries/epoch.rs (1)
532-556: Consider extracting shared logic into helper functions.There's code duplication between the proof and non-proof variants:
- ProTxHash parsing logic (lines 337-347 vs 532-542)
- Map construction from counts (lines 353-358 vs 552-556, and lines 390-394 vs 595-599)
Extracting these into helper functions would improve maintainability and reduce duplication.
💡 Example refactoring approach
You could create helper functions like:
fn parse_pro_tx_hashes(hashes: Vec<String>) -> Result<Vec<ProTxHash>, WasmSdkError> { hashes .into_iter() .map(|hash_str| { ProTxHash::from_str(&hash_str).map_err(|e| { WasmSdkError::invalid_argument(format!( "Invalid ProTxHash '{}': {}", hash_str, e )) }) }) .collect() } fn counts_to_map(counts: ProposerBlockCounts) -> Map { let map = Map::new(); for (identifier, count) in counts.0 { let key = JsValue::from(IdentifierWasm::from(identifier)); map.set(&key, &JsValue::from(BigInt::from(count))); } map }Then use them in both proof and non-proof variants.
Also applies to: 595-599
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/js-evo-sdk/tests/functional/epoch.spec.mjspackages/wasm-sdk/src/queries/epoch.rspackages/wasm-sdk/src/queries/protocol.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/js-evo-sdk/tests/functional/epoch.spec.mjs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/queries/epoch.rspackages/wasm-sdk/src/queries/protocol.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rspackages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2025-02-10T11:26:36.709Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rspackages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2025-01-23T09:23:32.740Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/rs-sdk/src/sync.rs:88-95
Timestamp: 2025-01-23T09:23:32.740Z
Learning: The `block_on` function in `packages/rs-sdk/src/sync.rs` is currently only used in tests, and its WebAssembly implementation is deferred until there's a user request for it.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-01-23T09:23:32.740Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/rs-sdk/src/sync.rs:88-95
Timestamp: 2025-01-23T09:23:32.740Z
Learning: The `block_on` function in `packages/rs-sdk/src/sync.rs` requires true blocking behavior, which is why a non-blocking WebAssembly implementation using `wasm_bindgen_futures::spawn_local` is not suitable.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-01-15T08:09:59.365Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2422
File: packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs:152-163
Timestamp: 2025-01-15T08:09:59.365Z
Learning: In the `transition_to_version_8` function, errors from `grove_get_path_query` when retrieving active contested resource votes are intentionally logged and ignored (returning `Ok(())`) to allow the protocol upgrade to proceed despite query failures.
Applied to files:
packages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.
Applied to files:
packages/wasm-sdk/src/queries/protocol.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/queries/protocol.rs (3)
packages/wasm-sdk/src/error.rs (1)
invalid_argument(75-77)packages/wasm-sdk/src/queries/mod.rs (5)
metadata(278-280)proof(288-290)from(100-109)from(212-221)from_sdk_parts(333-339)packages/rs-sdk/src/platform/fetch_many.rs (1)
fetch_many_with_metadata_and_proof(205-255)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
- GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Rust crates security audit
🔇 Additional comments (3)
packages/wasm-sdk/src/queries/protocol.rs (1)
254-323: LGTM! Proof-enabled implementation is well-structured.The implementation correctly replaces the placeholder with a full proof-enabled flow:
- Proper input validation for both string and Uint8Array ProTxHash formats
- Correct use of
LimitQueryandfetch_many_with_metadata_and_proof- Appropriate error handling for invalid inputs
- Follows the established pattern for proof-enabled wasm responses via
from_sdk_partspackages/wasm-sdk/src/queries/epoch.rs (2)
520-561: LGTM! Proof-enabled implementation for IDs query is correct.The implementation properly:
- Validates and parses ProTxHash strings with clear error messages
- Uses
fetch_many_with_metadata_and_proofto retrieve counts with verification- Constructs the response Map with correct type conversions
- Returns ProofMetadataResponseWasm following the established pattern
563-604: LGTM! Proof-enabled range query implementation is correct.The implementation correctly:
- Parses the query parameters including ProTxHash validation
- Constructs a proper
LimitQueryfor the range request- Uses
fetch_many_with_metadata_and_prooffor verified retrieval- Builds the response Map with appropriate type conversions
- Returns ProofMetadataResponseWasm via
from_sdk_partsThe
order_ascendingparameter is parsed but not used (line 577), consistent with the non-proof version (line 380), indicating ordering support is not yet implemented in the underlying SDK layer.
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/wasm-sdk/src/queries/epoch.rs (1)
507-548: LGTM! Implementation follows the established proof pattern.The proof-enabled method correctly:
- Parses ProTxHash strings with clear error messages
- Fetches counts with metadata and proof using the appropriate SDK method
- Builds and returns the response with proper type conversions
The explicit parameter naming (
proTxHashesin JS) improves API clarity compared to the non-proof variant's genericids.Minor observation: The ProTxHash parsing logic (lines 519-529) and Map building logic (lines 539-543) duplicate the non-proof variant. Consider extracting helper functions if more similar methods are added in the future.
🔎 Optional helper extraction example
fn parse_pro_tx_hashes(hashes: Vec<String>) -> Result<Vec<ProTxHash>, WasmSdkError> { hashes .into_iter() .map(|hash_str| { ProTxHash::from_str(&hash_str).map_err(|e| { WasmSdkError::invalid_argument(format!( "Invalid ProTxHash '{}': {}", hash_str, e )) }) }) .collect() } fn build_identifier_count_map(counts: impl IntoIterator<Item = (impl Into<IdentifierWasm>, u64)>) -> Map { let map = Map::new(); for (identifier, count) in counts { let key = JsValue::from(identifier.into()); map.set(&key, &JsValue::from(BigInt::from(count))); } map }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/wasm-dpp2/TODO.mdpackages/wasm-sdk/src/context_provider.rspackages/wasm-sdk/src/queries/epoch.rspackages/wasm-sdk/src/queries/token.rs
✅ Files skipped from review due to trivial changes (1)
- packages/wasm-dpp2/TODO.md
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/wasm-sdk/src/context_provider.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/queries/token.rspackages/wasm-sdk/src/queries/epoch.rs
🧠 Learnings (10)
📓 Common learnings
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
📚 Learning: 2025-11-25T13:10:38.019Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: packages/swift-sdk/SwiftExampleApp/CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:38.019Z
Learning: Applies to packages/swift-sdk/SwiftExampleApp/**/PersistentToken.swift : Provide predicate methods for PersistentToken querying: mintableTokensPredicate(), burnableTokensPredicate(), freezableTokensPredicate(), distributionTokensPredicate(), pausedTokensPredicate(), tokensByContractPredicate(contractId:), and tokensWithControlRulePredicate(rule:)
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-05-28T16:22:26.334Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2644
File: packages/rs-drive/src/cache/system_contracts.rs:18-19
Timestamp: 2025-05-28T16:22:26.334Z
Learning: In packages/rs-drive/src/cache/system_contracts.rs, the `active_since_protocol_version` field in `ActiveSystemDataContract` struct is intentionally added for future use, not current implementation. QuantumExplorer confirmed this is "meant for later" when questioned about the `#[allow(unused)]` attribute.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount from crate::balances::credits is compatible with u64 when used for token base supply.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount is defined as `type TokenAmount = u64` in balances/credits.rs, making it directly compatible with u64 values without any conversion needed.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-02-10T11:26:36.709Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Applied to files:
packages/wasm-sdk/src/queries/token.rspackages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/wasm-sdk/src/queries/token.rspackages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-01-23T09:23:32.740Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/rs-sdk/src/sync.rs:88-95
Timestamp: 2025-01-23T09:23:32.740Z
Learning: The `block_on` function in `packages/rs-sdk/src/sync.rs` is currently only used in tests, and its WebAssembly implementation is deferred until there's a user request for it.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-01-23T09:23:32.740Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/rs-sdk/src/sync.rs:88-95
Timestamp: 2025-01-23T09:23:32.740Z
Learning: The `block_on` function in `packages/rs-sdk/src/sync.rs` requires true blocking behavior, which is why a non-blocking WebAssembly implementation using `wasm_bindgen_futures::spawn_local` is not suitable.
Applied to files:
packages/wasm-sdk/src/queries/epoch.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build JS packages / Build JS
🔇 Additional comments (5)
packages/wasm-sdk/src/queries/epoch.rs (1)
550-590: LGTM! Range query proof implementation is correct.The implementation properly:
- Reuses the existing
parse_evonode_range_queryparser- Constructs a
LimitQuerywith the parsed epoch, limit, and start_info- Fetches counts with proof using
ProposerBlockCountByRange::fetch_many_with_metadata_and_proof- Returns the response in the expected
ProofMetadataResponseWasmformatThe approach is consistent with other proof-enabled methods in this file.
packages/wasm-sdk/src/queries/token.rs (4)
506-518: LGTM! Proper integration of token configuration prefetching.The prefetch call ensures token configuration is cached before querying, and the new query structure provides a cleaner interface compared to the previous implementation.
869-887: LGTM! Proof-enabled variant properly implemented.The prefetch ensures token configuration is available for proof verification, and the result conversion correctly handles the Option type with proper chaining.
894-896: Good code organization.Separating internal helper methods into a dedicated impl block with clear comments improves code maintainability and readability.
75-85: No changes needed. The cast ofEpochIndex(defined asu16) tou64is safe—all u16 values fit within u64 bounds without overflow.Likely an incorrect or invalid review comment.
…latform into fix/sdk/non-proved-token-query
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/wasm-sdk/src/queries/token.rs (1)
506-508: Consider expanding the comment to explain the prefetch rationale.The comment mentions that prefetching is "required for proof verification to work" but doesn't explain why. Consider adding a brief explanation of what would fail without prefetching (e.g., "Token configuration must be cached in the trusted context before proof verification; otherwise, the verifier cannot validate token-specific data structures").
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/src/queries/token.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/queries/token.rs
🧠 Learnings (7)
📓 Common learnings
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's `rs-sdk/tests` integration tests (e.g., in `packages/rs-sdk/tests/fetch/config.rs`), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount from crate::balances::credits is compatible with u64 when used for token base supply.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount is defined as `type TokenAmount = u64` in balances/credits.rs, making it directly compatible with u64 values without any conversion needed.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-02-10T11:26:36.709Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-dpp2) / Linting
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
- GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
- GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Rust crates security audit
🔇 Additional comments (3)
packages/wasm-sdk/src/queries/token.rs (3)
8-12: LGTM: Imports aligned with new proof-enabled flow.The added imports for
RewardDistributionMomentandTokenLastClaimQuerysupport the refactored token claim query paths that now use SDK fetch with proof verification.
869-892: LGTM: Proof-enabled variant correctly implements prefetch and conversion flow.The implementation correctly:
- Prefetches token configuration for proof verification context
- Uses
fetch_with_metadata_and_proofto retrieve verified data- Converts
RewardDistributionMomenttoTokenLastClaimWasmvia theFromimplementationSame optional comment improvement applies here as in the non-proof variant (lines 506-508).
894-977: LGTM: Prefetch helper correctly implements token configuration caching.The implementation properly:
- Fetches token contract info and data contract in sequence
- Extracts and validates token configuration
- Returns descriptive errors if trusted context is uninitialized (addresses past review feedback)
- Supports both Dash and Testnet networks with clear error for unsupported networks
The error handling is robust and includes relevant context (token_id, network) in error messages.
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/wasm-sdk/src/queries/token.rs (1)
854-857: JSDoc return type is inconsistent with actual return type.The
unchecked_return_typeannotation referencesTokenLastClaimbut the method now returnsRewardDistributionMoment. This mismatch could confuse TypeScript consumers relying on generated type definitions.🔎 Proposed fix
#[wasm_bindgen( js_name = "getTokenPerpetualDistributionLastClaimWithProofInfo", - unchecked_return_type = "ProofMetadataResponseTyped<TokenLastClaim | undefined>" + unchecked_return_type = "ProofMetadataResponseTyped<RewardDistributionMoment | undefined>" )]
🧹 Nitpick comments (2)
packages/wasm-sdk/src/queries/token.rs (2)
867-869: Consider removing redundant local imports.
TokenLastClaimQuery,RewardDistributionMoment, andFetchare already imported at the module level (lines 8, 12-13). These local imports are redundant.🔎 Proposed fix
) -> Result<ProofMetadataResponseWasm, WasmSdkError> { - use dash_sdk::platform::query::TokenLastClaimQuery; - use dash_sdk::dpp::data_contract::associated_token::token_perpetual_distribution::reward_distribution_moment::RewardDistributionMoment; - use dash_sdk::platform::Fetch; - // Parse IDs
954-964: Consider handling poisoned mutex gracefully.The
.unwrap()calls onlock()could panic if the mutex was poisoned (i.e., a previous holder panicked). While rare, especially in WASM, you could handle this more gracefully:🔎 Proposed approach
Network::Dash => { - let guard = MAINNET_TRUSTED_CONTEXT.lock().unwrap(); + let guard = MAINNET_TRUSTED_CONTEXT.lock().unwrap_or_else(|e| e.into_inner()); let ctx = guard.as_ref().ok_or_else(|| {Alternatively, convert the poison error to a
WasmSdkErrorfor a more descriptive failure.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/src/queries/token.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/queries/token.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2024-10-06T16:17:34.571Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs:105-105
Timestamp: 2024-10-06T16:17:34.571Z
Learning: In `run_block_proposal` in `packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs`, when retrieving `last_block_time_ms`, it's acceptable to use `platform_state` instead of `block_platform_state`, even after updating the protocol version.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-02-03T23:39:10.579Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2450
File: packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/v0/methods.rs:10-12
Timestamp: 2025-02-03T23:39:10.579Z
Learning: Block interval calculations in token distribution logic should use checked arithmetic operations (checked_sub, checked_add) to prevent potential overflows, especially when dealing with block heights and intervals.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount from crate::balances::credits is compatible with u64 when used for token base supply.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount is defined as `type TokenAmount = u64` in balances/credits.rs, making it directly compatible with u64 values without any conversion needed.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-02-10T11:26:36.709Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/wasm-sdk/src/queries/token.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Rust packages (wasm-dpp2) / Linting
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Rust crates security audit
🔇 Additional comments (4)
packages/wasm-sdk/src/queries/token.rs (4)
8-13: LGTM!The new imports for
RewardDistributionMoment,TokenLastClaimQuery, and the updatedFetch/FetchManyimports are correctly added to support the new proof-verified token query functionality.
58-105: Well-designed wrapper with clear type discrimination.The
RewardDistributionMomentWasmstruct addresses the previous concern about semantic mapping by providing:
- A
moment_typegetter that returns "block", "time", or "epoch" as a discriminant- Type-specific accessors (
block_height,timestamp_ms,epoch_index) that returnOption<T>, making it clear when values are applicableThis is a clean, self-documenting API for JavaScript consumers.
507-525: LGTM!The updated method correctly:
- Prefetches token configuration before proof-verified queries (addressing the PR objective)
- Uses the SDK's
Fetchtrait with proper query construction- Returns the new
RewardDistributionMomentWasmtype with clean conversion
900-982: Well-structured prefetch helper that addresses previous review concerns.The implementation correctly:
- Fetches token contract info and data contract to obtain the configuration
- Returns descriptive errors when context is not initialized (addressing the past review)
- Supports both mainnet and testnet networks with clear error messages
The mutex usage is safe here since the lock is held briefly without crossing await points.
Issue being fixed or feature implemented
Some of the methods aren't verifiable or do not provide proof information.
What was done?
How Has This Been Tested?
Breaking Changes
None
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.