Skip to content

Conversation

@shumkov
Copy link
Collaborator

@shumkov shumkov commented Nov 10, 2025

Issue being fixed or feature implemented

Continuation of EvoSDK params refactoring.

What was done?

  • User-friendly typed params for JS SDK methods

How Has This Been Tested?

Wth existing tests

Breaking Changes

EvoSDK public API is changed

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

    • Identifiers accepted in multiple formats (IdentifierLike); protocol proTxHash accepts string or bytes; DPNS usernames support limits and proof responses.
  • Refactor

    • Many APIs now use single query/options objects and JS-friendly camelCase parameter names.
    • Wallet mnemonic and key-derivation functions now accept named options objects.
  • Tests

    • Functional and unit tests updated to the new argument shapes and bindings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Walkthrough

Replaced many string identifier parameters with wasm.IdentifierLike (and arrays), introduced an IdentifierLike TypeScript alias, consolidated multi-argument APIs into query/options objects, added camelCase wasm_bindgen JS names, updated wallet derive helpers to accept option objects, and adjusted tests and wasm bindings accordingly. No core runtime algorithms were changed.

Changes

Cohort / File(s) Summary
JS facades — identifier & query typing
\packages/js-evo-sdk/src/contracts/facade.ts`, `packages/js-evo-sdk/src/documents/facade.ts`, `packages/js-evo-sdk/src/identities/facade.ts`, `packages/js-evo-sdk/src/system/facade.ts`, `packages/js-evo-sdk/src/tokens/facade.ts`, `packages/js-evo-sdk/src/dpns/facade.ts`, `packages/js-evo-sdk/src/group/facade.ts`, `packages/js-evo-sdk/src/protocol/facade.ts`, `packages/js-evo-sdk/src/voting/facade.ts``
Updated public method signatures to use wasm.IdentifierLike / wasm.IdentifierLike[] and wasm.*Query types; consolidated several multi-parameter methods into single query/options objects; introduced import * as wasm.
JS wallet helpers
\packages/js-evo-sdk/src/wallet/functions.ts``
Converted generate/derive wrappers to accept single option objects (wasm param types), await wasm.ensureInitialized, and forward the params to wasm SDK.
Tests (unit & functional)
\packages/js-evo-sdk/tests/`, `packages/wasm-sdk/tests/``
Updated tests to new API shapes: protocol positional args, wallet derive option objects, dpns/group/identities query-object usage and corresponding wasm SDK call expectations.
Identifier TS alias
\packages/wasm-dpp2/src/identifier.rs``
Added a wasm_bindgen TypeScript custom section exporting `export type IdentifierLike = Identifier
WASM SDK — DPNS usernames & proofs
\packages/wasm-sdk/src/dpns.rs``
Added DpnsUsernamesQuery JS/TS bindings and parser, usernames_from_documents, proof response types; switched get/register username APIs to query-object flow and IdentifierLike.
WASM SDK — queries & parsing (many)
\packages/wasm-sdk/src/queries/.rs`` (includes data_contract.rs, document.rs, epoch.rs, group.rs, identity.rs, protocol.rs, system.rs, token.rs, voting/)
Reworked TS bindings to use IdentifierLike; added composite query extern types (e.g., GroupActionSignersQueryJs, IdentitiesContractKeysQueryJs); added parsing helpers, js_name parameter bindings, proof-info variants, and identifier parsing/validation tweaks.
WASM SDK — state transitions (JS bindings)
\packages/wasm-sdk/src/state_transitions/*.rs`` (contracts, documents, identity, tokens)
Added wasm_bindgen(js_name = "...") camelCase JS exposure for many state-transition parameters (ownerId, contractId, dataContractId, documentType, privateKeyWif, etc.); formatting/log adjustments only.
WASM SDK — wallet derivation & key APIs
\packages/wasm-sdk/src/wallet/*.rs`` (extended_derivation.rs, key_derivation.rs, key_generation.rs)
Converted derive helpers to accept options objects with new TS bindings, added deserialization/parsing for option bags, new result structs (DerivedKeyInfoWasm, DashpayContactKeyInfoWasm), and DIP15 handling.
WASM SDK — SDK builder & cached contexts
\packages/wasm-sdk/src/sdk.rs``
Added global cached trusted contexts (MAINNET_TRUSTED_CONTEXT, TESTNET_TRUSTED_CONTEXT), renamed JS-facing builder params via wasm_bindgen(js_name=...), and wired prefetch behavior to caches.

Sequence Diagram(s)

sequenceDiagram
  participant App as JS Facade / Tests
  participant Wasm as WasmSdk
  Note over App,Wasm `#D3E4CD`: New input shapes — IdentifierLike or query/options objects
  App->>Wasm: call(method, identifierLike | identifierLike[])
  App->>Wasm: call(method, queryObject / opts)
  Wasm->>Wasm: deserialize inputs -> parsedQuery
  alt proof requested
    Wasm->>Wasm: run proof path
    Wasm-->>App: ProofResponseWasm (proof + metadata)
  else no proof
    Wasm->>Wasm: run data path
    Wasm-->>App: Data JSON / JS-typed result
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas needing extra attention:

  • Query-object parsing and validation in packages/wasm-sdk/src/queries/group.rs, identity.rs, and dpns.rs.
  • Token pricing extraction, proof variants, and result formatting in packages/wasm-sdk/src/queries/token.rs and token state transitions.
  • Protocol ProTxHash dual-input handling and sha256d logic in packages/wasm-sdk/src/queries/protocol.rs.
  • Wallet derivation options deserialization and DIP15 path computation in extended_derivation.rs and key_derivation.rs.
  • Consistency of wasm_bindgen(js_name=...) bindings across queries, state transitions, and JS facades (parameter naming and ordering).

Suggested reviewers

  • QuantumExplorer

Poem

🐰 I nibble keys and identifiers bright,

IdentifierLike hops into sight,
Queries tucked in one tidy nest,
camelCase doors open to the rest,
A tiny hop — the bindings sing light!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: refactoring SDK parameters to be more user-friendly, which is the primary objective evidenced throughout the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wasm-sdk-params2

📜 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 110f75e and b849bce.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • packages/wasm-sdk/Cargo.toml (2 hunks)
  • packages/wasm-sdk/src/wallet/key_derivation.rs (11 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/wasm-sdk/Cargo.toml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
packages/wasm-sdk/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
🧠 Learnings (9)
📓 Common learnings
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.
📚 Learning: 2025-09-24T05:16:54.422Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2784
File: packages/js-evo-sdk/src/wallet/functions.ts:24-26
Timestamp: 2025-09-24T05:16:54.422Z
Learning: The WASM SDK methods like `deriveKeyFromSeedWithExtendedPath` and `deriveKeyFromSeedWithPath` already handle mnemonic-to-seed conversion internally, so the JS wrapper functions can safely pass mnemonic strings directly without needing to convert them to seeds first.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2025-07-28T20:04:48.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/index.html:4360-4416
Timestamp: 2025-07-28T20:04:48.458Z
Learning: In packages/wasm-sdk, the wallet helper `derive_key_from_seed_with_path` (Rust function in src/wallet/key_derivation.rs) is synchronous; its JS wrapper returns a value immediately, so `await` is unnecessary.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.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/wallet/key_derivation.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/src/wallet/key_derivation.rs
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2025-09-03T15:44:33.889Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:0-0
Timestamp: 2025-09-03T15:44:33.889Z
Learning: In packages/wasm-sdk/docs.html, thephez prefers to keep realistic-looking private key placeholders in documentation examples rather than using obvious fake placeholders, despite secret scanner warnings.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2025-10-15T14:45:30.856Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/dashmate/src/test/constants/services.js:4-4
Timestamp: 2025-10-15T14:45:30.856Z
Learning: In the dashmate codebase (packages/dashmate), during the DAPI Rust migration (rs-dapi), the old service keys `dapi_api` and `dapi_core_streams` are intentionally kept in `generateEnvsFactory.js` for backward compatibility even though the test constants in `src/test/constants/services.js` have been updated to use `rs_dapi`. These deprecated keys will be removed in a future PR after the transition is complete.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/wallet/key_derivation.rs (1)
packages/wasm-sdk/src/queries/utils.rs (2)
  • deserialize_query_with_default (29-45)
  • deserialize_required_query (10-27)
⏰ 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) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Tests
  • GitHub Check: Rust packages (wasm-dpp2) / Linting
  • 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 Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@shumkov shumkov marked this pull request as ready for review November 10, 2025 17:42
Copy link
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: 4

🧹 Nitpick comments (4)
packages/wasm-sdk/src/queries/epoch.rs (2)

471-471: Consider aligning parameter naming with the non-proof version.

The js_name = "proTxHashes" attribute correctly exposes the parameter in camelCase for JavaScript. However, the corresponding non-proof version get_evonodes_proposed_epoch_blocks_by_ids (line 313) uses the parameter name ids instead of proTxHashes, creating an API inconsistency.

For consistency and clarity (since these are ProTxHashes, not generic IDs), consider updating the non-proof version to also use proTxHashes:

In the function at line 313-338, change:

 pub async fn get_evonodes_proposed_epoch_blocks_by_ids(
     &self,
     epoch: u16,
-    ids: Vec<String>,
+    #[wasm_bindgen(js_name = "proTxHashes")] pro_tx_hashes: Vec<String>,
 ) -> Result<Map, WasmSdkError> {
-    let pro_tx_hashes: Vec<ProTxHash> = ids
+    let pro_tx_hashes: Vec<ProTxHash> = pro_tx_hashes

479-488: Pre-existing: Unnecessary query parsing in unimplemented stub.

The function parses the query (line 483) before returning a "not yet implemented" error. This is wasteful and inconsistent—callers may receive parsing errors instead of the not-implemented message.

Consider removing the parsing to fail fast:

 pub async fn get_evonodes_proposed_epoch_blocks_by_range_with_proof_info(
     &self,
     query: EvonodeProposedBlocksRangeQueryJs,
 ) -> Result<JsValue, WasmSdkError> {
-    let parsed = parse_evonode_range_query(query)?;
-    let _ = (self, parsed);
+    let _ = (self, query);
     Err(WasmSdkError::generic(
         "get_evonodes_proposed_epoch_blocks_by_range_with_proof_info is not yet implemented",
     ))
 }
packages/js-evo-sdk/src/system/facade.ts (1)

1-1: Use a type-only import for the wasm namespace.

wasm is only referenced for its types, so importing it as a value forces bundlers to pull in the runtime unnecessarily. Please switch to a type-only import to keep the generated JS lean.

-import * as wasm from '../wasm.js';
+import type * as wasm from '../wasm.js';
packages/js-evo-sdk/src/protocol/facade.ts (1)

10-18: Consider using wasm namespace types instead of 'as any' casts.

While the as any casts work for JsValue interop, the broader pattern in this PR (evident in other facades) uses typed wasm namespace interfaces. Consider defining a type alias or using the wasm namespace types for better type safety.

Example approach:

-  async versionUpgradeVoteStatus(startProTxHash: string | Uint8Array, count: number): Promise<any> {
+  async versionUpgradeVoteStatus(startProTxHash: string | Uint8Array, count: number): Promise<any> {
     const w = await this.sdk.getWasmSdkConnected();
-    return w.getProtocolVersionUpgradeVoteStatus(startProTxHash as any, count);
+    return w.getProtocolVersionUpgradeVoteStatus(startProTxHash, count);
   }

However, this may require updating the wasm TypeScript bindings to properly reflect the union type.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 912ac2a and 80c1772.

📒 Files selected for processing (39)
  • packages/js-evo-sdk/src/contracts/facade.ts (1 hunks)
  • packages/js-evo-sdk/src/documents/facade.ts (4 hunks)
  • packages/js-evo-sdk/src/dpns/facade.ts (1 hunks)
  • packages/js-evo-sdk/src/group/facade.ts (1 hunks)
  • packages/js-evo-sdk/src/identities/facade.ts (2 hunks)
  • packages/js-evo-sdk/src/protocol/facade.ts (1 hunks)
  • packages/js-evo-sdk/src/system/facade.ts (2 hunks)
  • packages/js-evo-sdk/src/tokens/facade.ts (1 hunks)
  • packages/js-evo-sdk/src/voting/facade.ts (1 hunks)
  • packages/js-evo-sdk/src/wallet/functions.ts (1 hunks)
  • packages/js-evo-sdk/tests/functional/protocol.spec.mjs (1 hunks)
  • packages/js-evo-sdk/tests/functional/wallet.spec.mjs (1 hunks)
  • packages/js-evo-sdk/tests/unit/facades/dpns.spec.mjs (1 hunks)
  • packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (1 hunks)
  • packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (1 hunks)
  • packages/js-evo-sdk/tests/unit/facades/protocol.spec.mjs (1 hunks)
  • packages/wasm-dpp2/src/identifier.rs (1 hunks)
  • packages/wasm-sdk/src/dpns.rs (5 hunks)
  • packages/wasm-sdk/src/queries/data_contract.rs (3 hunks)
  • packages/wasm-sdk/src/queries/document.rs (4 hunks)
  • packages/wasm-sdk/src/queries/epoch.rs (1 hunks)
  • packages/wasm-sdk/src/queries/group.rs (13 hunks)
  • packages/wasm-sdk/src/queries/identity.rs (19 hunks)
  • packages/wasm-sdk/src/queries/mod.rs (4 hunks)
  • packages/wasm-sdk/src/queries/protocol.rs (3 hunks)
  • packages/wasm-sdk/src/queries/system.rs (2 hunks)
  • packages/wasm-sdk/src/queries/token.rs (14 hunks)
  • packages/wasm-sdk/src/queries/voting/resources.rs (1 hunks)
  • packages/wasm-sdk/src/queries/voting/state.rs (2 hunks)
  • packages/wasm-sdk/src/queries/voting/voters.rs (3 hunks)
  • packages/wasm-sdk/src/queries/voting/votes.rs (2 hunks)
  • packages/wasm-sdk/src/sdk.rs (6 hunks)
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs (4 hunks)
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs (14 hunks)
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs (15 hunks)
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs (26 hunks)
  • packages/wasm-sdk/src/wallet/extended_derivation.rs (1 hunks)
  • packages/wasm-sdk/src/wallet/key_derivation.rs (5 hunks)
  • packages/wasm-sdk/src/wallet/key_generation.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/wasm-sdk/src/queries/voting/votes.rs
  • packages/wasm-sdk/src/queries/voting/resources.rs
  • packages/wasm-dpp2/src/identifier.rs
  • packages/wasm-sdk/src/queries/voting/state.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/queries/epoch.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/queries/voting/voters.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/queries/group.rs
packages/wasm-sdk/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Files:

  • packages/wasm-sdk/src/queries/voting/votes.rs
  • packages/wasm-sdk/src/queries/voting/resources.rs
  • packages/wasm-sdk/src/queries/voting/state.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/queries/epoch.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/queries/voting/voters.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/queries/group.rs
🧠 Learnings (48)
📓 Common learnings
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.
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/queries/voting/votes.rs
  • packages/wasm-sdk/src/queries/voting/state.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/js-evo-sdk/src/identities/facade.ts
📚 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/voting/votes.rs
  • packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
  • packages/js-evo-sdk/src/system/facade.ts
  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/js-evo-sdk/src/dpns/facade.ts
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/js-evo-sdk/src/voting/facade.ts
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/js-evo-sdk/src/contracts/facade.ts
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/js-evo-sdk/src/documents/facade.ts
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/queries/group.rs
  • packages/js-evo-sdk/src/group/facade.ts
  • packages/js-evo-sdk/src/identities/facade.ts
  • packages/js-evo-sdk/src/tokens/facade.ts
📚 Learning: 2024-10-18T15:37:36.387Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2249
File: packages/dashmate/test/unit/status/scopes/platform.spec.js:77-78
Timestamp: 2024-10-18T15:37:36.387Z
Learning: In `packages/dashmate/test/unit/status/scopes/platform.spec.js`, prefer to keep mocks explicitly in tests to increase readability, rather than refactoring them into shared `beforeEach` blocks or helper functions.

Applied to files:

  • packages/js-evo-sdk/tests/unit/facades/protocol.spec.mjs
📚 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/js-evo-sdk/tests/unit/facades/protocol.spec.mjs
  • packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
  • packages/js-evo-sdk/src/system/facade.ts
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/js-evo-sdk/src/identities/facade.ts
📚 Learning: 2025-06-18T03:44:14.385Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Applied to files:

  • packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.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/js-evo-sdk/tests/unit/facades/identities.spec.mjs
  • packages/js-evo-sdk/src/system/facade.ts
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/queries/epoch.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/queries/group.rs
  • packages/js-evo-sdk/src/identities/facade.ts
📚 Learning: 2024-10-30T11:19:59.163Z
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.

Applied to files:

  • packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/js-evo-sdk/tests/unit/facades/dpns.spec.mjs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.

Applied to files:

  • packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
  • packages/js-evo-sdk/src/system/facade.ts
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/js-evo-sdk/src/identities/facade.ts
📚 Learning: 2024-11-06T07:27:01.722Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2314
File: packages/wallet-contract/test/bootstrap.js:14-16
Timestamp: 2024-11-06T07:27:01.722Z
Learning: In `packages/wallet-contract/test/bootstrap.js`, for Mocha tests in Node.js, async functions like `loadWasmDpp` can be assigned directly to `beforeAll` without wrapping them in another async function.

Applied to files:

  • packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
📚 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/js-evo-sdk/src/system/facade.ts
  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/js-evo-sdk/src/dpns/facade.ts
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/js-evo-sdk/src/contracts/facade.ts
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/js-evo-sdk/src/documents/facade.ts
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/js-evo-sdk/src/tokens/facade.ts
📚 Learning: 2025-09-03T14:41:16.196Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.

Applied to files:

  • packages/js-evo-sdk/src/system/facade.ts
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/js-evo-sdk/src/contracts/facade.ts
  • packages/js-evo-sdk/src/documents/facade.ts
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/mod.rs
📚 Learning: 2025-09-03T14:42:29.958Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.

Applied to files:

  • packages/js-evo-sdk/src/system/facade.ts
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/js-evo-sdk/src/documents/facade.ts
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/mod.rs
📚 Learning: 2025-09-24T05:16:54.422Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2784
File: packages/js-evo-sdk/src/wallet/functions.ts:24-26
Timestamp: 2025-09-24T05:16:54.422Z
Learning: The WASM SDK methods like `deriveKeyFromSeedWithExtendedPath` and `deriveKeyFromSeedWithPath` already handle mnemonic-to-seed conversion internally, so the JS wrapper functions can safely pass mnemonic strings directly without needing to convert them to seeds first.

Applied to files:

  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/js-evo-sdk/tests/functional/wallet.spec.mjs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2025-07-28T20:04:48.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/index.html:4360-4416
Timestamp: 2025-07-28T20:04:48.458Z
Learning: In packages/wasm-sdk, the wallet helper `derive_key_from_seed_with_path` (Rust function in src/wallet/key_derivation.rs) is synchronous; its JS wrapper returns a value immediately, so `await` is unnecessary.

Applied to files:

  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/js-evo-sdk/tests/functional/wallet.spec.mjs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2025-09-03T15:44:33.889Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:0-0
Timestamp: 2025-09-03T15:44:33.889Z
Learning: In packages/wasm-sdk/docs.html, thephez prefers to keep realistic-looking private key placeholders in documentation examples rather than using obvious fake placeholders, despite secret scanner warnings.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2024-10-21T01:03:42.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299
Timestamp: 2024-10-21T01:03:42.458Z
Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2025-09-02T13:30:17.703Z
Learnt from: thephez
Repo: dashpay/platform PR: 2739
File: packages/wasm-sdk/test/ui-automation/tests/state-transitions.spec.js:1-171
Timestamp: 2025-09-02T13:30:17.703Z
Learning: In packages/wasm-sdk/index.html, state transition definitions are loaded dynamically from api-definitions.json rather than being hardcoded in the HTML file. The UI loads transition categories, types, inputs, and labels from this JSON configuration file.

Applied to files:

  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-09-02T13:30:17.703Z
Learnt from: thephez
Repo: dashpay/platform PR: 2739
File: packages/wasm-sdk/test/ui-automation/tests/state-transitions.spec.js:1-171
Timestamp: 2025-09-02T13:30:17.703Z
Learning: In packages/wasm-sdk/index.html, state transition definitions are loaded dynamically from api-definitions.json via the loadApiDefinitions() function that fetches './api-definitions.json'. The UI doesn't have hardcoded transition definitions - instead it populates categories, types, inputs, and labels from this JSON configuration file at runtime.

Applied to files:

  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-08-14T15:03:56.681Z
Learnt from: thephez
Repo: dashpay/platform PR: 2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.681Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.

Applied to files:

  • packages/wasm-sdk/src/queries/system.rs
📚 Learning: 2024-11-22T08:19:14.448Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2345
File: packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs:93-99
Timestamp: 2024-11-22T08:19:14.448Z
Learning: In `packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs`, the `insert_contract` method requires an owned `BlockInfo`, so cloning `block_info` is necessary when calling it.

Applied to files:

  • packages/wasm-sdk/src/queries/system.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/system.rs
  • packages/wasm-sdk/src/queries/epoch.rs
📚 Learning: 2025-10-01T08:37:27.687Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2790
File: packages/rs-drive/src/drive/document/index_uniqueness/validate_document_transfer_transition_action_uniqueness/mod.rs:64-0
Timestamp: 2025-10-01T08:37:27.687Z
Learning: In v1 validators for document transitions that change ownership (transfer, purchase), the owner_id parameter should be omitted from the method signature and extracted internally from the transition's document() accessor, since the owner_id is being changed by the transition itself.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
📚 Learning: 2024-10-10T05:10:50.059Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2235
File: packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs:8-9
Timestamp: 2024-10-10T05:10:50.059Z
Learning: In the codebase, importing `Secp256k1` from `dashcore::key::Secp256k1` is acceptable.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-10-01T08:37:32.168Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2790
File: packages/rs-drive/src/drive/document/index_uniqueness/validate_document_purchase_transition_action_uniqueness/v1/mod.rs:65-0
Timestamp: 2025-10-01T08:37:32.168Z
Learning: In purchase document transitions (packages/rs-drive/src/drive/document/index_uniqueness/validate_document_purchase_transition_action_uniqueness/v1/mod.rs), the `changed_data_values` field in `UniquenessOfDataRequestUpdateType::ChangedDocument` should be set to an empty BTreeSet (`Cow::Owned(BTreeSet::new())`) because purchase transitions do not modify document data properties (like "price"), only ownership and transfer metadata. An empty set signals the uniqueness validation logic to skip checking unique indexes on data properties.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
📚 Learning: 2024-10-09T00:22:57.778Z
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-09T00:22:57.778Z
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/epoch.rs
📚 Learning: 2025-04-11T09:08:05.652Z
Learnt from: pauldelucia
Repo: dashpay/platform PR: 2523
File: packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/v1/mod.rs:147-151
Timestamp: 2025-04-11T09:08:05.652Z
Learning: Description length validation for data contracts is already handled in the data contract validation process, specifically in packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs.

Applied to files:

  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-04-11T09:08:05.652Z
Learnt from: pauldelucia
Repo: dashpay/platform PR: 2523
File: packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/v1/mod.rs:147-151
Timestamp: 2025-04-11T09:08:05.652Z
Learning: Description length validation for data contracts (ensuring it's between 3 and 100 characters) is already handled at the data contract validation level in packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs, making additional checks in the update operations redundant.

Applied to files:

  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.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/data_contract.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-12-05T12:59:22.044Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-dapi-client/src/request_settings.rs:74-74
Timestamp: 2024-12-05T12:59:22.044Z
Learning: The `AppliedRequestSettings` struct in `packages/rs-dapi-client/src/request_settings.rs` is intended for internal use within the monorepo and is not part of the public API.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-10-30T11:04:33.634Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/platform/fetch_unproved.rs:0-0
Timestamp: 2024-10-30T11:04:33.634Z
Learning: In `packages/rs-sdk/src/platform/fetch_unproved.rs`, the `execute()` method consumes the request object, so cloning the request is necessary before passing it to `execute()` and `maybe_from_unproved_with_metadata`.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-10-30T11:13:22.398Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/platform/fetch_many.rs:0-0
Timestamp: 2024-10-30T11:13:22.398Z
Learning: In the `fetch_many` method in `packages/rs-sdk/src/platform/fetch_many.rs`, we cannot move `request` into the async closure, as moving `request` into the async context will not work correctly.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.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/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
  • packages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2025-09-07T22:18:50.883Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T22:18:50.883Z
Learning: Applies to packages/wasm-sdk/** : Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Applied to files:

  • packages/wasm-sdk/src/sdk.rs
📚 Learning: 2024-10-18T15:39:51.172Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2254
File: packages/rs-sdk/src/sdk.rs:585-585
Timestamp: 2024-10-18T15:39:51.172Z
Learning: The 'platform' project uses Rust version 1.80, so code in 'packages/rs-sdk' can use features available in Rust 1.80, such as the `abs_diff()` method.

Applied to files:

  • packages/wasm-sdk/src/sdk.rs
📚 Learning: 2024-10-10T10:30:19.883Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2232
File: packages/rs-sdk/src/mock/sdk.rs:90-95
Timestamp: 2024-10-10T10:30:19.883Z
Learning: In `packages/rs-sdk/src/mock/sdk.rs`, the `load_expectations` method in `MockDashPlatformSdk` remains asynchronous (`async`) for backward compatibility, even though it now delegates to the synchronous `load_expectations_sync` method.

Applied to files:

  • packages/wasm-sdk/src/sdk.rs
📚 Learning: 2025-10-15T14:45:30.856Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/dashmate/src/test/constants/services.js:4-4
Timestamp: 2025-10-15T14:45:30.856Z
Learning: In the dashmate codebase (packages/dashmate), during the DAPI Rust migration (rs-dapi), the old service keys `dapi_api` and `dapi_core_streams` are intentionally kept in `generateEnvsFactory.js` for backward compatibility even though the test constants in `src/test/constants/services.js` have been updated to use `rs_dapi`. These deprecated keys will be removed in a future PR after the transition is complete.

Applied to files:

  • packages/js-evo-sdk/tests/unit/facades/dpns.spec.mjs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-11-20T10:01:50.837Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs:94-94
Timestamp: 2024-11-20T10:01:50.837Z
Learning: In `packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs`, when converting with `PublicKey::try_from`, it's acceptable to use `.expect()` to handle potential conversion errors.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-09-30T12:11:35.148Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2186
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs:48-54
Timestamp: 2024-09-30T12:11:35.148Z
Learning: In the identity credit withdrawal transition code, the field `platform_version.drive_abci.validation_and_processing.state_transitions.identity_credit_withdrawal_state_transition.transform_into_action` is not an `Option` type, so handling `None` cases is unnecessary.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2025-08-28T14:06:02.805Z
Learnt from: thephez
Repo: dashpay/platform PR: 2739
File: packages/wasm-sdk/test/ui-automation/fixtures/test-data.js:711-723
Timestamp: 2025-08-28T14:06:02.805Z
Learning: The tokenDestroyFrozen operation destroys the entire identity balance for that token and does not require an amount parameter.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
📚 Learning: 2025-10-09T15:59:28.329Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:181-187
Timestamp: 2025-10-09T15:59:28.329Z
Learning: In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`, the maintainer requires logging full state transition bytes (`tx_bytes = hex::encode(st_bytes)`) at debug level when a state transition passes CheckTx but is removed from the block by the proposer, to facilitate debugging of this rare edge case.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/tokens/mod.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/document.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-02-14T04:31:17.170Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2449
File: packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs:35-38
Timestamp: 2025-02-14T04:31:17.170Z
Learning: In test scenarios, it's acceptable for different types of identifiers (e.g., identity IDs and contract IDs) to share the same byte values since they operate in different scopes and contexts.

Applied to files:

  • packages/wasm-sdk/src/queries/group.rs
📚 Learning: 2025-01-23T02:10:08.979Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2439
File: packages/rs-dpp/src/errors/consensus/state/token/mod.rs:4-22
Timestamp: 2025-01-23T02:10:08.979Z
Learning: The user QuantumExplorer prefers to handle documentation of breaking changes separately from the code changes, particularly for token-related error types and validation rules.

Applied to files:

  • packages/js-evo-sdk/src/tokens/facade.ts
🧬 Code graph analysis (27)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (2)
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (8)
  • query (42-42)
  • query (51-57)
  • query (66-71)
  • query (80-86)
  • proofQuery (44-44)
  • proofQuery (59-59)
  • proofQuery (73-73)
  • proofQuery (88-92)
packages/js-evo-sdk/tests/unit/facades/documents.spec.mjs (2)
  • query (27-34)
  • query (40-43)
packages/js-evo-sdk/src/system/facade.ts (1)
packages/js-evo-sdk/src/sdk.ts (1)
  • wasm (68-71)
packages/js-evo-sdk/src/wallet/functions.ts (1)
packages/js-evo-sdk/src/sdk.ts (1)
  • wasm (68-71)
packages/js-evo-sdk/src/dpns/facade.ts (1)
packages/js-evo-sdk/src/documents/facade.ts (1)
  • query (13-16)
packages/wasm-sdk/src/wallet/key_generation.rs (2)
packages/wasm-sdk/src/error.rs (3)
  • invalid_argument (73-75)
  • generic (69-71)
  • serialization (77-79)
packages/wasm-sdk/src/sdk.rs (1)
  • network (45-47)
packages/wasm-sdk/src/queries/token.rs (2)
packages/wasm-sdk/src/queries/utils.rs (2)
  • identifier_from_js (86-90)
  • identifiers_from_js (92-100)
packages/wasm-sdk/src/queries/mod.rs (6)
  • from (75-84)
  • from (167-176)
  • metadata (204-206)
  • proof (212-214)
  • data (196-198)
  • from_sdk_parts (232-242)
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (2)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (3)
  • query (57-65)
  • query (71-74)
  • query (123-123)
packages/js-evo-sdk/src/documents/facade.ts (1)
  • query (13-16)
packages/wasm-sdk/src/queries/system.rs (2)
packages/wasm-sdk/src/queries/utils.rs (1)
  • identifier_from_js (86-90)
packages/wasm-sdk/src/error.rs (2)
  • invalid_argument (73-75)
  • generic (69-71)
packages/wasm-sdk/src/state_transitions/documents/mod.rs (2)
packages/wasm-sdk/src/error.rs (3)
  • invalid_argument (73-75)
  • not_found (81-83)
  • generic (69-71)
packages/rs-sdk/src/platform/documents/document_query.rs (1)
  • new_with_data_contract_id (88-102)
packages/js-evo-sdk/src/voting/facade.ts (2)
packages/js-evo-sdk/src/sdk.ts (2)
  • EvoSDK (37-165)
  • wasm (68-71)
packages/js-evo-sdk/src/documents/facade.ts (1)
  • query (13-16)
packages/wasm-sdk/src/queries/epoch.rs (3)
packages/rs-sdk/src/platform/fetch_many.rs (1)
  • fetch_many_with_metadata_and_proof (203-253)
packages/wasm-dpp2/src/identifier.rs (4)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
packages/wasm-sdk/src/error.rs (1)
  • generic (69-71)
packages/wasm-sdk/src/wallet/extended_derivation.rs (3)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-sdk/src/wallet/key_derivation.rs (1)
  • mnemonic_to_seed (256-265)
packages/wasm-sdk/src/error.rs (3)
  • invalid_argument (73-75)
  • generic (69-71)
  • serialization (77-79)
packages/wasm-sdk/src/queries/identity.rs (4)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (3)
  • query (57-65)
  • query (71-74)
  • query (123-123)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-dpp2/src/identifier.rs (8)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
  • try_from (48-60)
  • try_from (65-92)
  • try_from (97-99)
  • try_from (105-115)
packages/js-evo-sdk/src/identities/facade.ts (1)
  • fetch (12-15)
packages/wasm-sdk/src/sdk.rs (2)
packages/rs-sdk/src/sdk.rs (7)
  • address_list (590-596)
  • build (1045-1161)
  • with_context_provider (952-959)
  • context_provider (342-347)
  • with_version (941-944)
  • default (788-825)
  • with_proofs (833-836)
packages/rs-dapi-client/src/request_settings.rs (1)
  • default (39-46)
packages/js-evo-sdk/src/contracts/facade.ts (2)
packages/js-evo-sdk/src/sdk.ts (1)
  • wasm (68-71)
packages/js-evo-sdk/src/documents/facade.ts (1)
  • query (13-16)
packages/wasm-sdk/src/state_transitions/identity/mod.rs (2)
packages/wasm-sdk/src/error.rs (2)
  • invalid_argument (73-75)
  • not_found (81-83)
packages/wasm-sdk/src/queries/utils.rs (1)
  • identifier_from_js (86-90)
packages/js-evo-sdk/src/documents/facade.ts (2)
packages/js-evo-sdk/tests/unit/facades/documents.spec.mjs (2)
  • query (27-34)
  • query (40-43)
packages/js-evo-sdk/src/sdk.ts (1)
  • wasm (68-71)
packages/wasm-sdk/src/state_transitions/tokens/mod.rs (1)
packages/wasm-sdk/src/error.rs (3)
  • serialization (77-79)
  • generic (69-71)
  • invalid_argument (73-75)
packages/wasm-sdk/src/dpns.rs (4)
packages/wasm-sdk/src/queries/utils.rs (2)
  • deserialize_required_query (10-27)
  • identifier_from_js (86-90)
packages/wasm-dpp2/src/identifier.rs (6)
  • value (72-72)
  • value (80-80)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
packages/rs-sdk/src/platform/documents/document_query.rs (1)
  • new_with_data_contract_id (88-102)
packages/rs-sdk/src/platform/fetch_many.rs (1)
  • fetch_many_with_metadata_and_proof (203-253)
packages/wasm-sdk/src/state_transitions/contracts/mod.rs (2)
packages/wasm-sdk/src/queries/identity.rs (1)
  • key_id (44-46)
packages/wasm-sdk/src/error.rs (1)
  • invalid_argument (73-75)
packages/wasm-sdk/src/queries/document.rs (5)
packages/wasm-dpp2/src/identifier.rs (6)
  • value (72-72)
  • value (80-80)
  • try_from (48-60)
  • try_from (65-92)
  • try_from (97-99)
  • try_from (105-115)
packages/js-evo-sdk/src/documents/facade.ts (1)
  • query (13-16)
packages/rs-sdk/src/platform/documents/document_query.rs (1)
  • new_with_data_contract_id (88-102)
packages/js-evo-sdk/src/identities/facade.ts (1)
  • fetch (12-15)
packages/js-evo-sdk/src/contracts/facade.ts (1)
  • fetch (12-15)
packages/wasm-sdk/src/queries/protocol.rs (1)
packages/wasm-sdk/src/error.rs (1)
  • invalid_argument (73-75)
packages/wasm-sdk/src/wallet/key_derivation.rs (2)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-sdk/src/error.rs (3)
  • invalid_argument (73-75)
  • generic (69-71)
  • serialization (77-79)
packages/wasm-sdk/src/queries/group.rs (3)
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (4)
  • query (42-42)
  • query (51-57)
  • query (66-71)
  • query (80-86)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-dpp2/src/identifier.rs (10)
  • try_from (48-60)
  • try_from (65-92)
  • try_from (97-99)
  • try_from (105-115)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
  • value (72-72)
  • value (80-80)
packages/js-evo-sdk/src/group/facade.ts (2)
packages/js-evo-sdk/src/sdk.ts (3)
  • GroupFacade (175-175)
  • EvoSDK (37-165)
  • wasm (68-71)
packages/js-evo-sdk/src/documents/facade.ts (1)
  • query (13-16)
packages/js-evo-sdk/src/identities/facade.ts (2)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (3)
  • query (57-65)
  • query (71-74)
  • query (123-123)
packages/js-evo-sdk/src/documents/facade.ts (1)
  • query (13-16)
packages/js-evo-sdk/src/tokens/facade.ts (1)
packages/wasm-sdk/tests/functional/identities.spec.mjs (1)
  • tokenId (61-61)
⏰ 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). (12)
  • GitHub Check: Rust packages (wasm-sdk) / Formatting
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Tests
  • GitHub Check: Rust packages (wasm-dpp2) / 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 (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit

Copy link
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

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/document.rs (1)

311-324: Use Identifier::try_from instead of heuristic-based parsing.

The TODO comment correctly identifies the issue. The codebase uses Identifier::try_from as the standard pattern for identifier conversion (used extensively in rs-drive-proof-verifier, rs-drive, rs-dpp, and rs-drive-abci), but this code applies a fragile heuristic instead:

  • The 44-character length check may not be valid for all identifier contexts.
  • is_alphanumeric() accepts 0, O, I, l, which are invalid in Base58 encoding.
  • Valid identifiers failing the heuristic are incorrectly treated as plain text.

Replace the heuristic with direct try_from usage:

-        JsonValue::String(s) => {
-            // TODO: Should use Identifier::try_from and return text if failed
-            // Check if it's an identifier (base58 encoded)
-            if s.len() == 44 && s.chars().all(|c| c.is_alphanumeric()) {
-                // Try to parse as identifier
-                match Identifier::from_string(
-                    s,
-                    dash_sdk::dpp::platform_value::string_encoding::Encoding::Base58,
-                ) {
-                    Ok(id) => Ok(platform_value!(id)),
-                    Err(_) => Ok(Value::Text(s.clone())),
-                }
-            } else {
-                Ok(Value::Text(s.clone()))
-            }
-        }
+        JsonValue::String(s) => {
+            match Identifier::try_from(s.as_bytes()) {
+                Ok(id) => Ok(platform_value!(id)),
+                Err(_) => Ok(Value::Text(s.clone())),
+            }
+        }
♻️ Duplicate comments (3)
packages/wasm-sdk/src/wallet/extended_derivation.rs (1)

237-247: Critical: DIP15 path construction still violates specification.

This critical issue was flagged in a previous review but remains unresolved. According to DIP15 specification, the path format is:

m/9'/5'/15'/0'/<sender_id>/<receiver_id>/<index>

The current implementation has two violations:

  1. Line 237-241: coin_type varies by network (5 for mainnet, 1 for testnet). DIP15 mandates coin_type must always be 5 (Dash), regardless of network.

  2. Line 246: Uses the account parameter directly. DIP15 mandates account must always be 0 (hardened), not a variable.

These violations break DIP15 compliance and interoperability.

Apply this diff to fix both violations:

-        let coin_type = match network.as_str() {
-            "mainnet" => 5,
-            "testnet" => 1,
-            _ => return Err(WasmSdkError::invalid_argument("Invalid network")),
-        };
+        // DIP15 mandates fixed values: coin_type=5 (Dash), account=0
+        let coin_type = 5;
+        let account_hardened = 0;
         // Build the DIP15 path
         // m / 9' / coin_type' / 15' / account' / sender_id / receiver_id / index
         let path = format!(
             "m/9'/{}'/{}'/{}'/{}/{}/{}",
-            coin_type, 15, account, sender_id_formatted, receiver_id_formatted, address_index
+            coin_type, 15, account_hardened, sender_id_formatted, receiver_id_formatted, address_index
         );
packages/wasm-sdk/src/queries/identity.rs (1)

1381-1436: Proof metadata/proof only cover the first identity.

Inside get_identities_contract_keys_with_proof_info the code accumulates metadata and proof from the first identity only (lines 1396-1400) and silently ignores the rest. The returned JS array can contain keys for multiple identities, but the proof bundle no longer authenticates anything beyond the first identity. This makes the proof response invalid for callers whenever identityIds has more than one entry.

Please either:

  1. Enforce a single identityId when proofs are requested, or
  2. Restructure the code to fetch all identities in one call (or merge proofs correctly) so that the proof payload corresponds to the entire data set.
packages/wasm-sdk/src/queries/token.rs (1)

571-579: Leave raw block height untouched when parsing RawBytes.

This issue was previously flagged: When block_height decodes to 0, the code rewrites it to 1, which silently changes the payload received from Core. Consumers should see the actual value returned by the platform, not a fabricated height.

Apply this diff to preserve the original block height:

                                    // Validate block height: must be a positive value
                                    let validated_block_height = if block_height == 0 {
                                        tracing::warn!(
                                            target = "wasm_sdk",
                                            "Invalid block height in raw bytes: 0 (genesis block not expected)"
                                        );
-                                        1 // Use minimum valid block height
+                                        block_height
                                    } else {
                                        block_height
                                    };

And similarly for the fallback parsing:

                                    // Validate block height
                                    let validated_block_height = if block_height == 0 {
                                        tracing::warn!(
                                            target = "wasm_sdk",
                                            "Invalid block height in fallback parsing: 0"
                                        );
-                                        1 // Use minimum valid block height
+                                        block_height
                                    } else {
                                        block_height
                                    };

Also applies to: 592-600

🧹 Nitpick comments (7)
packages/wasm-sdk/src/state_transitions/contracts/mod.rs (1)

63-119: Consider extracting shared private key and authentication logic.

Both contract_create and contract_update contain nearly identical code for:

  • Private key parsing (WIF → secret bytes → public key)
  • Public key hash generation (hash160)
  • Authentication key matching (by key_id or finding first match)

Extracting this into helper functions (e.g., derive_authentication_key_from_wif) would reduce duplication and improve maintainability.

Also applies to: 250-306

packages/wasm-sdk/src/wallet/extended_derivation.rs (1)

48-53: Consider removing redundant serde rename attributes.

The explicit #[serde(rename = "...")] attributes on lines 48, 50, and 53 are redundant since #[serde(rename_all = "camelCase")] on line 43 already converts sender_identity_idsenderIdentityId, receiver_identity_idreceiverIdentityId, and address_indexaddressIndex automatically.

Apply this diff to simplify the code:

-    #[serde(rename = "senderIdentityId")]
     sender_identity_id: String,
-    #[serde(rename = "receiverIdentityId")]
     receiver_identity_id: String,
     account: u32,
-    #[serde(rename = "addressIndex")]
     address_index: u32,
packages/wasm-sdk/src/queries/identity.rs (1)

865-894: Clarify TODO comments and improve input validation.

The TODO comments at lines 869, 973, 1250, and 1296 indicate known issues ("This is incorrect") but don't explain what's wrong. The current logic appears reasonable: it decodes hex strings and converts Uint8Arrays.

However, there are two concerns:

  1. Input type validation: If a caller passes a value that's neither a string nor a Uint8Array, Uint8Array::new() may produce unexpected results, and the subsequent 20-byte length check will fail with a misleading error message.

  2. Code duplication: This parsing logic is repeated in four places, making it harder to maintain.

Consider:

  1. Clarifying what the TODO comments refer to or removing them if the implementation is now correct.

  2. Adding explicit type validation:

fn parse_public_key_hash(public_key_hash: JsValue) -> Result<[u8; 20], WasmSdkError> {
    let hash_bytes: Vec<u8> = if let Some(hex_str) = public_key_hash.as_string() {
        let s = hex_str.strip_prefix("0x").unwrap_or(&hex_str);
        hex::decode(s).map_err(|e| {
            WasmSdkError::invalid_argument(format!("Invalid public key hash hex: {}", e))
        })?
    } else if public_key_hash.is_instance_of::<Uint8Array>() {
        let arr = Uint8Array::new(&public_key_hash);
        arr.to_vec()
    } else {
        return Err(WasmSdkError::invalid_argument(
            "publicKeyHash must be a hex string or Uint8Array"
        ));
    };
    
    if hash_bytes.len() != 20 {
        return Err(WasmSdkError::invalid_argument(
            "Public key hash must be 20 bytes (40 hex characters)"
        ));
    }
    
    let mut hash_array = [0u8; 20];
    hash_array.copy_from_slice(&hash_bytes);
    Ok(hash_array)
}

Then call this helper in all four functions to eliminate duplication.

Also applies to: 963-987, 1243-1265, 1286-1310

packages/wasm-sdk/src/sdk.rs (3)

66-100: Consider explicit error handling for mutex locks.

The .lock().unwrap() calls (lines 79, 97) will panic if the mutex is poisoned. While unlikely in WASM's single-threaded context, using .expect() with a descriptive message would improve error clarity.

Example for line 79:

-        *MAINNET_TRUSTED_CONTEXT.lock().unwrap() = Some(trusted_context);
+        *MAINNET_TRUSTED_CONTEXT.lock()
+            .expect("MAINNET_TRUSTED_CONTEXT mutex poisoned") = Some(trusted_context);

138-209: Validate address and network inputs properly, but consider mutex error handling.

The validation logic for addresses and network is robust with clear error messages. However, lines 182 and 191 use .lock().unwrap() which could panic if the mutex is poisoned (though unlikely in WASM).

Consider using .expect() with descriptive messages:

             let guard = MAINNET_TRUSTED_CONTEXT.lock().unwrap();
+            // or
+            let guard = MAINNET_TRUSTED_CONTEXT.lock()
+                .expect("MAINNET_TRUSTED_CONTEXT mutex poisoned");

435-448: Consider extracting cached context retrieval into a helper function.

The pattern of retrieving cached trusted context (lines 440-448 for mainnet, 700-708 for testnet) is duplicated across multiple functions. Extracting this into a helper would reduce duplication and centralize the mutex handling.

Example helper:

fn get_or_create_trusted_context(
    cache: &Lazy<Mutex<Option<WasmTrustedContext>>>,
    create_fn: impl FnOnce() -> Result<WasmTrustedContext, dash_sdk::Error>
) -> Result<WasmTrustedContext, WasmSdkError> {
    let guard = cache.lock().expect("trusted context mutex poisoned");
    guard.clone()
        .map(Ok)
        .unwrap_or_else(|| create_fn().map_err(|e| WasmSdkError::from(dash_sdk::Error::from(e))))
}

Also applies to: 695-708

packages/wasm-sdk/src/dpns.rs (1)

40-44: Cap limits to the platform maximum
resolve_dpns_usernames_limit forwards any positive value, so callers can ask for more than the 100-document limit enforced by Platform and get a validation error back. Clamping here (e.g., min(value, 100)) would keep the API user-friendly and align with the documented ceiling.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80c1772 and 65a29b0.

📒 Files selected for processing (18)
  • packages/wasm-sdk/src/dpns.rs (8 hunks)
  • packages/wasm-sdk/src/queries/data_contract.rs (3 hunks)
  • packages/wasm-sdk/src/queries/document.rs (8 hunks)
  • packages/wasm-sdk/src/queries/epoch.rs (1 hunks)
  • packages/wasm-sdk/src/queries/group.rs (15 hunks)
  • packages/wasm-sdk/src/queries/identity.rs (26 hunks)
  • packages/wasm-sdk/src/queries/mod.rs (5 hunks)
  • packages/wasm-sdk/src/queries/protocol.rs (4 hunks)
  • packages/wasm-sdk/src/queries/system.rs (3 hunks)
  • packages/wasm-sdk/src/queries/token.rs (24 hunks)
  • packages/wasm-sdk/src/sdk.rs (8 hunks)
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs (4 hunks)
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs (12 hunks)
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs (19 hunks)
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs (13 hunks)
  • packages/wasm-sdk/src/wallet/extended_derivation.rs (8 hunks)
  • packages/wasm-sdk/src/wallet/key_derivation.rs (11 hunks)
  • packages/wasm-sdk/src/wallet/key_generation.rs (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/wasm-sdk/src/queries/epoch.rs
  • packages/wasm-sdk/src/queries/system.rs
  • packages/wasm-sdk/src/state_transitions/documents/mod.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/group.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
packages/wasm-sdk/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/group.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
🧠 Learnings (39)
📓 Common learnings
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.
📚 Learning: 2025-07-28T20:04:48.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/index.html:4360-4416
Timestamp: 2025-07-28T20:04:48.458Z
Learning: In packages/wasm-sdk, the wallet helper `derive_key_from_seed_with_path` (Rust function in src/wallet/key_derivation.rs) is synchronous; its JS wrapper returns a value immediately, so `await` is unnecessary.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2025-09-24T05:16:54.422Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2784
File: packages/js-evo-sdk/src/wallet/functions.ts:24-26
Timestamp: 2025-09-24T05:16:54.422Z
Learning: The WASM SDK methods like `deriveKeyFromSeedWithExtendedPath` and `deriveKeyFromSeedWithPath` already handle mnemonic-to-seed conversion internally, so the JS wrapper functions can safely pass mnemonic strings directly without needing to convert them to seeds first.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/wallet/key_derivation.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/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/group.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-10-10T05:10:50.059Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2235
File: packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs:8-9
Timestamp: 2024-10-10T05:10:50.059Z
Learning: In the codebase, importing `Secp256k1` from `dashcore::key::Secp256k1` is acceptable.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
📚 Learning: 2024-10-30T11:19:59.163Z
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.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2025-04-11T09:08:05.652Z
Learnt from: pauldelucia
Repo: dashpay/platform PR: 2523
File: packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/v1/mod.rs:147-151
Timestamp: 2025-04-11T09:08:05.652Z
Learning: Description length validation for data contracts is already handled in the data contract validation process, specifically in packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs.

Applied to files:

  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-04-11T09:08:05.652Z
Learnt from: pauldelucia
Repo: dashpay/platform PR: 2523
File: packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/v1/mod.rs:147-151
Timestamp: 2025-04-11T09:08:05.652Z
Learning: Description length validation for data contracts (ensuring it's between 3 and 100 characters) is already handled at the data contract validation level in packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs, making additional checks in the update operations redundant.

Applied to files:

  • packages/wasm-sdk/src/queries/data_contract.rs
  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-09-02T13:30:17.703Z
Learnt from: thephez
Repo: dashpay/platform PR: 2739
File: packages/wasm-sdk/test/ui-automation/tests/state-transitions.spec.js:1-171
Timestamp: 2025-09-02T13:30:17.703Z
Learning: In packages/wasm-sdk/index.html, state transition definitions are loaded dynamically from api-definitions.json via the loadApiDefinitions() function that fetches './api-definitions.json'. The UI doesn't have hardcoded transition definitions - instead it populates categories, types, inputs, and labels from this JSON configuration file at runtime.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-09-03T14:41:16.196Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/document.rs
📚 Learning: 2025-09-02T13:30:17.703Z
Learnt from: thephez
Repo: dashpay/platform PR: 2739
File: packages/wasm-sdk/test/ui-automation/tests/state-transitions.spec.js:1-171
Timestamp: 2025-09-02T13:30:17.703Z
Learning: In packages/wasm-sdk/index.html, state transition definitions are loaded dynamically from api-definitions.json rather than being hardcoded in the HTML file. The UI loads transition categories, types, inputs, and labels from this JSON configuration file.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
📚 Learning: 2025-09-03T14:42:29.958Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/mod.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/queries/document.rs
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/contracts/mod.rs
  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.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/sdk.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/queries/protocol.rs
📚 Learning: 2025-09-07T22:18:50.883Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T22:18:50.883Z
Learning: Applies to packages/wasm-sdk/** : Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Applied to files:

  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.

Applied to files:

  • packages/wasm-sdk/src/sdk.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-10-10T10:30:19.883Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2232
File: packages/rs-sdk/src/mock/sdk.rs:90-95
Timestamp: 2024-10-10T10:30:19.883Z
Learning: In `packages/rs-sdk/src/mock/sdk.rs`, the `load_expectations` method in `MockDashPlatformSdk` remains asynchronous (`async`) for backward compatibility, even though it now delegates to the synchronous `load_expectations_sync` method.

Applied to files:

  • packages/wasm-sdk/src/sdk.rs
📚 Learning: 2025-08-28T14:06:02.805Z
Learnt from: thephez
Repo: dashpay/platform PR: 2739
File: packages/wasm-sdk/test/ui-automation/fixtures/test-data.js:711-723
Timestamp: 2025-08-28T14:06:02.805Z
Learning: The tokenDestroyFrozen operation destroys the entire identity balance for that token and does not require an amount parameter.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/tokens/mod.rs
📚 Learning: 2025-09-03T15:44:33.889Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:0-0
Timestamp: 2025-09-03T15:44:33.889Z
Learning: In packages/wasm-sdk/docs.html, thephez prefers to keep realistic-looking private key placeholders in documentation examples rather than using obvious fake placeholders, despite secret scanner warnings.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_generation.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/mod.rs
  • packages/wasm-sdk/src/queries/group.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2025-02-14T04:31:17.170Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2449
File: packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs:35-38
Timestamp: 2025-02-14T04:31:17.170Z
Learning: In test scenarios, it's acceptable for different types of identifiers (e.g., identity IDs and contract IDs) to share the same byte values since they operate in different scopes and contexts.

Applied to files:

  • packages/wasm-sdk/src/queries/group.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/src/dpns.rs
  • packages/wasm-sdk/src/queries/document.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-10-18T15:43:32.447Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2254
File: packages/rs-sdk/src/sdk.rs:654-658
Timestamp: 2024-10-18T15:43:32.447Z
Learning: In `packages/rs-sdk/src/sdk.rs`, within the `verify_metadata_height` function, when using `compare_exchange` on `last_seen_height`, it's acceptable to use `Ordering::Relaxed` for the failure ordering, as any inconsistency would only trigger an extra loop iteration without affecting correctness.

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: 2024-11-03T10:39:11.242Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/finalize_block.rs:81-0
Timestamp: 2024-11-03T10:39:11.242Z
Learning: In `packages/rs-drive-abci/src/abci/handler/finalize_block.rs`, the use of `.expect("commit transaction")` after `app.commit_transaction(platform_version)` is intentional due to the provided comment explaining its necessity. Do not flag this usage in future reviews.

Applied to files:

  • packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-10-09T15:59:28.329Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:181-187
Timestamp: 2025-10-09T15:59:28.329Z
Learning: In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`, the maintainer requires logging full state transition bytes (`tx_bytes = hex::encode(st_bytes)`) at debug level when a state transition passes CheckTx but is removed from the block by the proposer, to facilitate debugging of this rare edge case.

Applied to files:

  • packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2024-10-09T00:22:57.778Z
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-09T00:22:57.778Z
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: 2024-10-08T13:28:03.529Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-drive-abci/src/platform_types/platform_state/mod.rs:141-141
Timestamp: 2024-10-08T13:28:03.529Z
Learning: When converting `PlatformStateV0` to `PlatformStateForSavingV1` in `packages/rs-drive-abci/src/platform_types/platform_state/mod.rs`, only version `0` needs to be handled in the match on `platform_state_for_saving_structure_default` because the changes are retroactive.

Applied to files:

  • packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2025-06-18T03:44:14.385Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Applied to files:

  • packages/wasm-sdk/src/queries/token.rs
  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2025-10-09T15:59:18.338Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.js:325-334
Timestamp: 2025-10-09T15:59:18.338Z
Learning: In `packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.js`, the continuous sync restart intentionally uses `Math.max(1, lastSyncedBlockHeight)` rather than `lastSyncedBlockHeight + 1` because the last block's processing status is uncertain at restart time. This conservative approach ensures no blocks are missed by reprocessing the last synced block, accepting potential duplicate processing for data completeness.

Applied to files:

  • packages/wasm-sdk/src/queries/token.rs
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-10-21T01:03:42.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299
Timestamp: 2024-10-21T01:03:42.458Z
Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.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/identity.rs
  • packages/wasm-sdk/src/queries/protocol.rs
  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
📚 Learning: 2025-08-14T15:03:56.681Z
Learnt from: thephez
Repo: dashpay/platform PR: 2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.681Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.

Applied to files:

  • packages/wasm-sdk/src/queries/document.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/document.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: 2024-11-20T10:01:50.837Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs:94-94
Timestamp: 2024-11-20T10:01:50.837Z
Learning: In `packages/rs-drive-abci/src/platform_types/platform_state/v0/old_structures/mod.rs`, when converting with `PublicKey::try_from`, it's acceptable to use `.expect()` to handle potential conversion errors.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/identity/mod.rs
🧬 Code graph analysis (11)
packages/wasm-sdk/src/wallet/extended_derivation.rs (3)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-sdk/src/wallet/key_derivation.rs (1)
  • mnemonic_to_seed (280-293)
packages/wasm-sdk/src/error.rs (3)
  • invalid_argument (73-75)
  • serialization (77-79)
  • generic (69-71)
packages/wasm-sdk/src/state_transitions/contracts/mod.rs (1)
packages/wasm-sdk/src/error.rs (1)
  • invalid_argument (73-75)
packages/wasm-sdk/src/sdk.rs (1)
packages/rs-sdk/src/sdk.rs (4)
  • with_context_provider (952-959)
  • context_provider (342-347)
  • with_version (941-944)
  • with_proofs (833-836)
packages/wasm-sdk/src/wallet/key_generation.rs (1)
packages/wasm-sdk/src/error.rs (1)
  • invalid_argument (73-75)
packages/wasm-sdk/src/wallet/key_derivation.rs (1)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-sdk/src/queries/group.rs (3)
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (4)
  • query (42-42)
  • query (51-57)
  • query (66-71)
  • query (80-86)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-sdk/src/error.rs (1)
  • invalid_argument (73-75)
packages/wasm-sdk/src/dpns.rs (2)
packages/wasm-sdk/src/queries/utils.rs (2)
  • deserialize_required_query (10-27)
  • identifier_from_js (86-90)
packages/wasm-dpp2/src/identifier.rs (6)
  • value (72-72)
  • value (80-80)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
packages/wasm-sdk/src/queries/token.rs (2)
packages/wasm-sdk/src/queries/identity.rs (6)
  • p (908-918)
  • p (1366-1376)
  • identity_ids (812-821)
  • identity_ids (1175-1184)
  • identity_id (98-100)
  • identity_id (142-144)
packages/wasm-sdk/src/error.rs (1)
  • generic (69-71)
packages/wasm-sdk/src/queries/identity.rs (4)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (3)
  • query (57-65)
  • query (71-74)
  • query (123-123)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-dpp2/src/identifier.rs (4)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts (1)
  • Keys (1065-1081)
packages/wasm-sdk/src/queries/protocol.rs (2)
packages/wasm-sdk/src/error.rs (1)
  • invalid_argument (73-75)
packages/js-evo-sdk/tests/unit/facades/protocol.spec.mjs (1)
  • bytes (35-35)
packages/wasm-sdk/src/state_transitions/identity/mod.rs (1)
packages/wasm-sdk/src/error.rs (2)
  • invalid_argument (73-75)
  • not_found (81-83)

Copy link
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

♻️ Duplicate comments (1)
packages/wasm-sdk/src/queries/identity.rs (1)

1373-1427: Proof metadata/proof only covers the first identity.

This function captures metadata and proof from only the first identity (lines 1389-1392) and silently ignores proof data from subsequent identities. This makes the returned proof invalid when identity_ids contains multiple entries, as the proof bundle doesn't authenticate data beyond the first identity.

This issue was previously flagged. Please either:

  1. Enforce single identity when proofs are requested (add validation at the start)
  2. Restructure to fetch all identities in one call with a unified proof
  3. Document clearly that only single-identity queries are supported with proof

The current implementation silently produces invalid proofs for multi-identity requests.

🧹 Nitpick comments (2)
packages/wasm-sdk/src/queries/identity.rs (2)

870-877: Extract duplicated public key hash parsing logic into a helper function.

The same public key hash parsing logic (hex string or Uint8Array → 20-byte array) is repeated in four functions. This duplication increases maintenance burden and the risk of inconsistent behavior.

Consider extracting a helper function:

fn parse_public_key_hash(public_key_hash: JsValue) -> Result<[u8; 20], WasmSdkError> {
    let hash_bytes: Vec<u8> = if let Some(hex_str) = public_key_hash.as_string() {
        hex::decode(&hex_str).map_err(|e| {
            WasmSdkError::invalid_argument(format!("Invalid public key hash hex: {}", e))
        })?
    } else {
        let arr = Uint8Array::new(&public_key_hash);
        arr.to_vec()
    };
    
    if hash_bytes.len() != 20 {
        return Err(WasmSdkError::invalid_argument(
            "Public key hash must be 20 bytes (40 hex characters)",
        ));
    }
    
    let mut hash_array = [0u8; 20];
    hash_array.copy_from_slice(&hash_bytes);
    Ok(hash_array)
}

Then replace each occurrence with:

let hash_array = parse_public_key_hash(public_key_hash)?;

Also applies to: 971-978, 1247-1254, 1290-1297


905-917: Consider extracting purpose conversion logic.

The purpose conversion logic is duplicated between get_identities_contract_keys and get_identities_contract_keys_with_proof_info. While this is only two occurrences, extracting it would improve maintainability.

Consider a helper function:

fn convert_purposes(purposes: Vec<u32>) -> Vec<u32> {
    use dash_sdk::dpp::identity::Purpose;
    purposes
        .into_iter()
        .filter_map(|purpose_int| match purpose_int {
            0 => Some(Purpose::AUTHENTICATION as u32),
            1 => Some(Purpose::ENCRYPTION as u32),
            2 => Some(Purpose::DECRYPTION as u32),
            3 => Some(Purpose::TRANSFER as u32),
            4 => Some(Purpose::SYSTEM as u32),
            5 => Some(Purpose::VOTING as u32),
            _ => None,
        })
        .collect()
}

Also applies to: 1357-1369

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between edb82d1 and c08dede.

📒 Files selected for processing (1)
  • packages/wasm-sdk/src/queries/identity.rs (26 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/wasm-sdk/src/queries/identity.rs
packages/wasm-sdk/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Files:

  • packages/wasm-sdk/src/queries/identity.rs
🧠 Learnings (9)
📓 Common learnings
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.
📚 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/identity.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/identity.rs
📚 Learning: 2025-06-18T03:44:14.385Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-10-30T11:19:59.163Z
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.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-10-21T01:03:42.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299
Timestamp: 2024-10-21T01:03:42.458Z
Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.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/identity.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/queries/identity.rs (4)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (3)
  • query (57-65)
  • query (71-74)
  • query (123-123)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-dpp2/src/identifier.rs (4)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts (1)
  • Keys (1065-1081)
⏰ 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) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Tests
  • GitHub Check: Rust packages (wasm-dpp2) / Linting
  • 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 Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (5)
packages/wasm-sdk/src/queries/identity.rs (5)

219-279: LGTM! Well-structured query type definition.

The TypeScript interface, deserialization types, and parsing logic are correctly implemented. The use of IdentifierLike for identity and contract identifiers aligns with the PR's goal of making parameters more user-friendly.


336-336: Good refactor to use IdentifierLike type.

This change makes the parameter type consistent with other identifier parameters across the SDK.


435-435: Excellent API standardization with camelCase parameter names.

Adding js_name attributes to expose camelCase parameter names (identityId, contractId, tokenIds, publicKeyHash, startAfterId) significantly improves the JavaScript/TypeScript developer experience and aligns with ecosystem conventions.

Also applies to: 451-451, 475-475, 662-662, 685-685, 714-717, 744-749, 784-786, 805-807, 844-846, 865-867, 964-969, 1023-1028, 1135-1137, 1164-1166, 1213-1215, 1242-1244, 1283-1288, 1433-1438


894-959: Implementation looks correct for non-proof case.

The function properly parses the query, fetches keys per-identity (since batch API isn't available yet), and filters by purpose when specified. The _contract_identifier is appropriately prefixed with underscore to indicate it's reserved for future use.


1109-1113: Correct handling of unsupported search with proof.

Properly returns an error for search key requests with proof, which aligns with the known limitation that the get_identity_keys_with_proof_info function doesn't support the "search" key request type.

Based on learnings

@shumkov shumkov changed the title refactor: user-friendsly evo sdk params refactor(sdk): user-friendsly evo sdk params Nov 11, 2025
Copy link
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

♻️ Duplicate comments (2)
packages/wasm-sdk/src/wallet/extended_derivation.rs (1)

238-248: Fix DIP15 path construction to match specification.

According to DIP15, the derivation path must be m/9'/5'/15'/0'/<userA_unique_id>/<userB_unique_id>/<index> where:

  • coin_type must always be 5 (Dash), not vary by network
  • account must always be 0 (hardened), not a variable parameter

Currently, the code uses 1 for testnet and accepts arbitrary account values, which breaks DIP15 compliance.

Apply this diff to fix the path construction:

-        let coin_type = match network.as_str() {
-            "mainnet" => 5,
-            "testnet" => 1,
-            _ => return Err(WasmSdkError::invalid_argument("Invalid network")),
-        };
-        // Build the DIP15 path
-        // m / 9' / coin_type' / 15' / account' / sender_id / receiver_id / index
         let path = format!(
-            "m/9'/{}'/{}'/{}'/{}/{}/{}",
-            coin_type, 15, account, sender_id_formatted, receiver_id_formatted, address_index
+            "m/9'/5'/15'/0'/{}/{}/{}",
+            sender_id_formatted, receiver_id_formatted, address_index
         );
packages/wasm-sdk/src/queries/identity.rs (1)

1346-1428: Proof bundle still only covers the first identity

combined_metadata and combined_proof are set during the first loop iteration and left unchanged afterwards, so a request with multiple identityIds still returns proofs that authenticate only the first identity. Callers get keys for every identity but a proof that no longer matches the payload, which breaks the proof contract. Until we can merge per-identity proofs correctly, we should at least reject multi-identity proof requests so we don’t hand back invalid proofs.

         let params = parse_identities_contract_keys_query(query)?;
-        let identity_ids = params.identity_ids;
+        let identity_ids = params.identity_ids;
+        if identity_ids.len() > 1 {
+            return Err(WasmSdkError::invalid_argument(
+                "getIdentitiesContractKeysWithProofInfo currently supports a single identity per request",
+            ));
+        }
         let _contract_identifier = params.contract_id;
🧹 Nitpick comments (1)
packages/wasm-sdk/src/wallet/extended_derivation.rs (1)

251-321: Consider extracting duplicated derivation logic.

The derivation logic (lines 251-276) duplicates the implementation in derive_key_from_seed_with_extended_path. While the comment mentions avoiding re-deserialization, this creates maintenance overhead.

Consider refactoring to call a shared internal helper after the DIP15 path is constructed, or document why direct implementation is necessary for performance.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c08dede and ae1238c.

📒 Files selected for processing (8)
  • packages/wasm-sdk/src/queries/identity.rs (26 hunks)
  • packages/wasm-sdk/src/wallet/extended_derivation.rs (8 hunks)
  • packages/wasm-sdk/tests/functional/dpns.spec.mjs (1 hunks)
  • packages/wasm-sdk/tests/functional/identities.spec.mjs (1 hunks)
  • packages/wasm-sdk/tests/unit/address-validation.spec.mjs (1 hunks)
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs (6 hunks)
  • packages/wasm-sdk/tests/unit/errors.spec.mjs (1 hunks)
  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/identity.rs
packages/wasm-sdk/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/tests/functional/identities.spec.mjs
  • packages/wasm-sdk/tests/functional/dpns.spec.mjs
  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs
  • packages/wasm-sdk/tests/unit/address-validation.spec.mjs
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/tests/unit/errors.spec.mjs
🧠 Learnings (18)
📓 Common learnings
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.
📚 Learning: 2025-07-28T20:04:48.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/index.html:4360-4416
Timestamp: 2025-07-28T20:04:48.458Z
Learning: In packages/wasm-sdk, the wallet helper `derive_key_from_seed_with_path` (Rust function in src/wallet/key_derivation.rs) is synchronous; its JS wrapper returns a value immediately, so `await` is unnecessary.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs
  • packages/wasm-sdk/tests/unit/address-validation.spec.mjs
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
  • packages/wasm-sdk/tests/unit/errors.spec.mjs
📚 Learning: 2025-09-24T05:16:54.422Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2784
File: packages/js-evo-sdk/src/wallet/functions.ts:24-26
Timestamp: 2025-09-24T05:16:54.422Z
Learning: The WASM SDK methods like `deriveKeyFromSeedWithExtendedPath` and `deriveKeyFromSeedWithPath` already handle mnemonic-to-seed conversion internally, so the JS wrapper functions can safely pass mnemonic strings directly without needing to convert them to seeds first.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs
  • packages/wasm-sdk/tests/unit/address-validation.spec.mjs
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
  • packages/wasm-sdk/tests/unit/errors.spec.mjs
📚 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/wallet/extended_derivation.rs
  • packages/wasm-sdk/tests/functional/identities.spec.mjs
  • packages/wasm-sdk/tests/functional/dpns.spec.mjs
  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs
  • packages/wasm-sdk/tests/unit/address-validation.spec.mjs
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/tests/unit/errors.spec.mjs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.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/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs
  • packages/wasm-sdk/tests/unit/address-validation.spec.mjs
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
  • packages/wasm-sdk/tests/unit/errors.spec.mjs
📚 Learning: 2024-10-10T05:10:50.059Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2235
File: packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs:8-9
Timestamp: 2024-10-10T05:10:50.059Z
Learning: In the codebase, importing `Secp256k1` from `dashcore::key::Secp256k1` is acceptable.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
📚 Learning: 2024-10-30T11:19:59.163Z
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.

Applied to files:

  • packages/wasm-sdk/src/wallet/extended_derivation.rs
  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2025-06-18T03:44:14.385Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Applied to files:

  • packages/wasm-sdk/tests/functional/identities.spec.mjs
  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.

Applied to files:

  • packages/wasm-sdk/tests/functional/identities.spec.mjs
  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs
  • packages/wasm-sdk/tests/unit/address-validation.spec.mjs
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
  • packages/wasm-sdk/src/queries/identity.rs
  • packages/wasm-sdk/tests/unit/errors.spec.mjs
📚 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/identities.spec.mjs
  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2025-10-15T14:45:30.856Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/dashmate/src/test/constants/services.js:4-4
Timestamp: 2025-10-15T14:45:30.856Z
Learning: In the dashmate codebase (packages/dashmate), during the DAPI Rust migration (rs-dapi), the old service keys `dapi_api` and `dapi_core_streams` are intentionally kept in `generateEnvsFactory.js` for backward compatibility even though the test constants in `src/test/constants/services.js` have been updated to use `rs_dapi`. These deprecated keys will be removed in a future PR after the transition is complete.

Applied to files:

  • packages/wasm-sdk/tests/unit/extended-keys.spec.mjs
  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
📚 Learning: 2025-09-03T15:44:33.889Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:0-0
Timestamp: 2025-09-03T15:44:33.889Z
Learning: In packages/wasm-sdk/docs.html, thephez prefers to keep realistic-looking private key placeholders in documentation examples rather than using obvious fake placeholders, despite secret scanner warnings.

Applied to files:

  • packages/wasm-sdk/tests/unit/derivation.spec.mjs
📚 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/unit/derivation.spec.mjs
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-10-21T01:03:42.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299
Timestamp: 2024-10-21T01:03:42.458Z
Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/queries/identity.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/identity.rs
🧬 Code graph analysis (4)
packages/wasm-sdk/src/wallet/extended_derivation.rs (2)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-sdk/src/wallet/key_derivation.rs (1)
  • mnemonic_to_seed (280-293)
packages/wasm-sdk/tests/functional/identities.spec.mjs (3)
packages/wasm-sdk/tests/functional/dpns.spec.mjs (2)
  • TEST_IDENTITY (79-79)
  • DPNS_CONTRACT (6-6)
packages/wasm-sdk/tests/functional/groups.spec.mjs (2)
  • DPNS_CONTRACT (21-21)
  • DPNS_CONTRACT (36-36)
packages/wasm-sdk/tests/functional/voting.spec.mjs (1)
  • DPNS_CONTRACT (23-23)
packages/wasm-sdk/tests/unit/extended-keys.spec.mjs (1)
packages/wasm-sdk/tests/unit/key-generation.spec.mjs (1)
  • TEST_MNEMONIC (4-4)
packages/wasm-sdk/src/queries/identity.rs (5)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (3)
  • query (57-65)
  • query (71-74)
  • query (123-123)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-dpp2/src/identifier.rs (4)
  • from (23-25)
  • from (29-31)
  • from (35-37)
  • from (41-43)
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts (1)
  • Keys (1065-1081)
packages/wasm-sdk/src/error.rs (3)
  • serialization (77-79)
  • generic (69-71)
  • invalid_argument (73-75)
⏰ 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). (4)
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (6)
packages/wasm-sdk/tests/functional/dpns.spec.mjs (1)

80-80: LGTM! API update aligns with PR objectives.

The change to object-based parameters improves type safety and readability, consistent with the PR's goals.

packages/wasm-sdk/src/wallet/extended_derivation.rs (1)

6-93: LGTM! Well-structured refactoring to object-based parameters.

The introduction of typed input structs (DeriveFromExtendedPathInput) and corresponding TypeScript interfaces provides better type safety and aligns with the PR's goal of making the API more user-friendly. The use of deserialize_required_query ensures proper validation.

packages/wasm-sdk/tests/unit/address-validation.spec.mjs (1)

17-22: LGTM! Test correctly updated for new API.

The object-based parameter pattern with explicit passphrase: null is clear and consistent with the refactored API.

packages/wasm-sdk/tests/unit/extended-keys.spec.mjs (1)

12-64: LGTM! Comprehensive test coverage for new API.

All test cases correctly updated to use the object-based parameter pattern for deriveKeyFromSeedWithExtendedPath, maintaining existing test coverage while validating the new API shape.

packages/wasm-sdk/tests/unit/errors.spec.mjs (1)

39-41: LGTM! Error handling test properly updated.

The test correctly validates error handling with the new object-based API, ensuring that invalid arguments are still properly caught and reported.

packages/wasm-sdk/tests/unit/derivation.spec.mjs (1)

55-180: LGTM! Comprehensive test suite updated for new API.

All derivation functions (deriveKeyFromSeedWithPath, deriveKeyFromSeedWithExtendedPath, deriveDashpayContactKey) are correctly updated to use object-based parameters. The test suite maintains excellent coverage of various scenarios including BIP44, DIP9, DIP13, DIP14, and DIP15 paths.

@shumkov shumkov changed the title refactor(sdk): user-friendsly evo sdk params refactor(sdk)!: user-friendly evo sdk params Nov 11, 2025
@shumkov shumkov added this to the v2.2.0 milestone Nov 11, 2025
@shumkov shumkov self-assigned this Nov 11, 2025
@shumkov shumkov moved this to In Progress in Platform team Nov 11, 2025
@shumkov shumkov moved this from In Progress to In review / testing in Platform team Nov 11, 2025
Copy link
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

♻️ Duplicate comments (2)
packages/wasm-sdk/src/wallet/extended_derivation.rs (2)

53-53: Remove account parameter to comply with DIP15 specification.

DIP15 mandates that the account index must always be 0 (hardened). Accepting account as a parameter allows callers to construct non-compliant paths. Remove the account field from both DeriveDashpayContactKeyInput (line 53) and the TypeScript interface DeriveDashpayContactKeyParams (line 66), and hardcode account = 0 in the path construction logic at line 297.

Also applies to: 66-66


288-292: Fix DIP15 path construction to match specification: coin_type must be fixed to 5, account must be fixed to 0.

According to DIP15, the path format is m / 9' / 5' / 15' / 0' / <userA_unique_id> / <userB_unique_id> / <index>, but the code deviates in two critical ways:

  1. Coin type must always be 5 (Dash), not vary by network. Currently uses 1 for testnet and 5 for mainnet, which breaks DIP15 compliance.
  2. Account must always be 0 (hardened), not a variable parameter. Currently accepts arbitrary account values from the params.

Apply this diff to fix the path construction:

-        let coin_type = match network.as_str() {
-            "mainnet" => 5,
-            "testnet" => 1,
-            _ => return Err(WasmSdkError::invalid_argument("Invalid network")),
-        };
-        // Build the DIP15 path
-        // m / 9' / coin_type' / 15' / account' / sender_id / receiver_id / index
         let path = format!(
-            "m/9'/{}'/{}'/{}'/0x{}/0x{}/{}",
-            coin_type, 15, account, sender_id_hex, receiver_id_hex, address_index
+            "m/9'/5'/15'/0'/0x{}/0x{}/{}",
+            sender_id_hex, receiver_id_hex, address_index
         );

Also applies to: 295-298

🧹 Nitpick comments (2)
packages/js-evo-sdk/tests/functional/wallet.spec.mjs (1)

14-20: Consider omitting explicit null for optional fields.

The tests explicitly pass passphrase: null when calling the derivation functions. Since passphrase is optional in the TypeScript interfaces, you could simplify these calls by omitting the field entirely.

For example:

-    expect(await wallet.deriveKeyFromSeedPhrase({ mnemonic, passphrase: null, network: 'testnet' })).to.exist();
+    expect(await wallet.deriveKeyFromSeedPhrase({ mnemonic, network: 'testnet' })).to.exist();

However, the explicit passphrase: null does make the intent clearer and isn't incorrect.

packages/wasm-sdk/src/wallet/extended_derivation.rs (1)

202-202: Consider hardcoding the account field to 0.

Since DIP15 mandates that the account index must always be 0, the account field in DashpayContactKeyInfoWasm will always have the same value. Once the account parameter is removed from the input (per the critical issue above), consider either:

  1. Hardcoding account: 0 in the from_common constructor (line 228) and removing the parameter (line 212), or
  2. Removing the field entirely if it provides no useful information to callers.

Also applies to: 212-212, 228-228

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a26b97d and 110f75e.

📒 Files selected for processing (5)
  • packages/js-evo-sdk/src/wallet/functions.ts (2 hunks)
  • packages/js-evo-sdk/tests/functional/wallet.spec.mjs (2 hunks)
  • packages/wasm-sdk/src/wallet/extended_derivation.rs (1 hunks)
  • packages/wasm-sdk/src/wallet/key_derivation.rs (11 hunks)
  • packages/wasm-sdk/tests/unit/key-generation.spec.mjs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/wasm-sdk/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK

Files:

  • packages/wasm-sdk/tests/unit/key-generation.spec.mjs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
🧠 Learnings (13)
📓 Common learnings
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.
📚 Learning: 2025-09-24T05:16:54.422Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2784
File: packages/js-evo-sdk/src/wallet/functions.ts:24-26
Timestamp: 2025-09-24T05:16:54.422Z
Learning: The WASM SDK methods like `deriveKeyFromSeedWithExtendedPath` and `deriveKeyFromSeedWithPath` already handle mnemonic-to-seed conversion internally, so the JS wrapper functions can safely pass mnemonic strings directly without needing to convert them to seeds first.

Applied to files:

  • packages/js-evo-sdk/tests/functional/wallet.spec.mjs
  • packages/wasm-sdk/tests/unit/key-generation.spec.mjs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
📚 Learning: 2025-07-28T20:04:48.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/index.html:4360-4416
Timestamp: 2025-07-28T20:04:48.458Z
Learning: In packages/wasm-sdk, the wallet helper `derive_key_from_seed_with_path` (Rust function in src/wallet/key_derivation.rs) is synchronous; its JS wrapper returns a value immediately, so `await` is unnecessary.

Applied to files:

  • packages/js-evo-sdk/tests/functional/wallet.spec.mjs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/wasm-sdk/src/wallet/extended_derivation.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/js-evo-sdk/tests/functional/wallet.spec.mjs
  • packages/wasm-sdk/tests/unit/key-generation.spec.mjs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.

Applied to files:

  • packages/wasm-sdk/tests/unit/key-generation.spec.mjs
  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/js-evo-sdk/src/wallet/functions.ts
📚 Learning: 2025-09-03T14:41:16.196Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.

Applied to files:

  • packages/wasm-sdk/tests/unit/key-generation.spec.mjs
📚 Learning: 2025-09-03T14:42:29.958Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.

Applied to files:

  • packages/wasm-sdk/tests/unit/key-generation.spec.mjs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/wasm-sdk/src/wallet/extended_derivation.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/src/wallet/key_derivation.rs
  • packages/js-evo-sdk/src/wallet/functions.ts
  • packages/wasm-sdk/src/wallet/extended_derivation.rs
📚 Learning: 2025-10-15T14:45:30.856Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/dashmate/src/test/constants/services.js:4-4
Timestamp: 2025-10-15T14:45:30.856Z
Learning: In the dashmate codebase (packages/dashmate), during the DAPI Rust migration (rs-dapi), the old service keys `dapi_api` and `dapi_core_streams` are intentionally kept in `generateEnvsFactory.js` for backward compatibility even though the test constants in `src/test/constants/services.js` have been updated to use `rs_dapi`. These deprecated keys will be removed in a future PR after the transition is complete.

Applied to files:

  • packages/wasm-sdk/src/wallet/key_derivation.rs
  • packages/js-evo-sdk/src/wallet/functions.ts
📚 Learning: 2025-09-03T15:44:33.889Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:0-0
Timestamp: 2025-09-03T15:44:33.889Z
Learning: In packages/wasm-sdk/docs.html, thephez prefers to keep realistic-looking private key placeholders in documentation examples rather than using obvious fake placeholders, despite secret scanner warnings.

Applied to files:

  • packages/js-evo-sdk/src/wallet/functions.ts
📚 Learning: 2024-11-06T07:27:01.722Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2314
File: packages/wallet-contract/test/bootstrap.js:14-16
Timestamp: 2024-11-06T07:27:01.722Z
Learning: In `packages/wallet-contract/test/bootstrap.js`, for Mocha tests in Node.js, async functions like `loadWasmDpp` can be assigned directly to `beforeAll` without wrapping them in another async function.

Applied to files:

  • packages/js-evo-sdk/src/wallet/functions.ts
📚 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/wallet/extended_derivation.rs
🧬 Code graph analysis (3)
packages/wasm-sdk/src/wallet/key_derivation.rs (2)
packages/wasm-sdk/src/queries/utils.rs (2)
  • deserialize_query_with_default (29-45)
  • deserialize_required_query (10-27)
packages/wasm-sdk/tests/unit/derivation.spec.mjs (2)
  • mnemonic (107-107)
  • mnemonic (129-129)
packages/js-evo-sdk/src/wallet/functions.ts (1)
packages/js-evo-sdk/src/sdk.ts (1)
  • wasm (68-71)
packages/wasm-sdk/src/wallet/extended_derivation.rs (2)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (10-27)
packages/wasm-sdk/src/wallet/key_derivation.rs (1)
  • mnemonic_to_seed (309-322)
⏰ 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) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (wasm-dpp2) / Tests
  • GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Linting
  • 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 Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (13)
packages/js-evo-sdk/src/wallet/functions.ts (2)

4-7: LGTM: Clean migration to options object for mnemonic generation.

The function signature now accepts an optional GenerateMnemonicParams object and correctly passes params ?? null to the WASM SDK, which handles both null and undefined appropriately.


19-37: LGTM: Consistent refactoring of key derivation functions to options objects.

All four functions (deriveKeyFromSeedPhrase, deriveKeyFromSeedWithPath, deriveKeyFromSeedWithExtendedPath, deriveDashpayContactKey) now accept strongly-typed parameter objects instead of positional arguments, improving type safety and API extensibility.

packages/wasm-sdk/src/wallet/key_derivation.rs (7)

20-61: LGTM: Well-defined TypeScript interfaces for WASM bindings.

The TypeScript interfaces (GenerateMnemonicParams, DeriveKeyFromSeedPhraseParams, DeriveKeyFromSeedWithPathParams) are clearly defined with appropriate optional fields, providing strong typing at the JS/TS boundary.


64-90: LGTM: Rust deserialization structs correctly mirror TypeScript interfaces.

The structs use #[serde(rename_all = "camelCase")] to match JavaScript naming conventions and #[serde(default)] on optional fields, ensuring correct deserialization from JS objects.


221-230: LGTM: Proper handling of optional parameters with sensible defaults.

The function now uses deserialize_query_with_default to handle optional parameters, which returns a default GenerateMnemonicInput (12 words, English) when params are null/undefined.


281-284: LGTM: camelCase binding for JavaScript API consistency.

The js_name attribute ensures the parameter is exposed as languageCode in JavaScript, maintaining naming convention consistency across the SDK.


326-337: LGTM: Required parameters properly validated with clear error messages.

Using deserialize_required_query ensures that the required mnemonic and network fields are present, returning a clear error message if the options object is missing.


390-405: LGTM: Consistent parameter handling for path-based derivation.

The refactored function follows the same pattern as derive_key_from_seed_phrase, deserializing required parameters (mnemonic, path, network) and optional parameters (passphrase) with appropriate error handling.


501-519: LGTM: camelCase binding for DIP9 derivation functions.

The featureType parameter is now consistently exposed with camelCase naming in JavaScript through the js_name attribute, aligning with JavaScript conventions.

packages/wasm-sdk/tests/unit/key-generation.spec.mjs (1)

11-27: LGTM: Test updates reflect the new options-based API.

The test cases have been correctly updated to pass object parameters to generateMnemonic, covering both basic usage ({ wordCount: 12 }) and extended usage with language codes ({ wordCount: 12, languageCode: lang }).

packages/js-evo-sdk/tests/functional/wallet.spec.mjs (1)

5-5: LGTM: generateMnemonic updated to options object.

The function call now correctly passes an options object with wordCount and languageCode.

packages/wasm-sdk/src/wallet/extended_derivation.rs (2)

89-132: LGTM!

The derive_common_from_mnemonic function correctly handles mnemonic-to-seed conversion, network selection, master key creation, path derivation, and result construction. The error handling is appropriate throughout.


240-257: LGTM!

The refactored derive_key_from_seed_with_extended_path correctly deserializes the option bag parameters, performs the derivation, and returns a typed wasm result. The error handling and debug logging are appropriate.

const mnemonic = 'birth kingdom trash renew flavor utility donkey gasp regular alert pave layer';
const sender = '0x555d3854c910b7dee436869c4724bed2fe0784e198b8a39f02bbb49d8ebcfc3a';
const receiver = '0xa137439f36d04a15474ff7423e4b904a14373fafb37a41db74c84f1dbb5c89b5';
// Hex without 0x prefix (we don't use 0x)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should support both with and without 0x...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then it must be done everwhere: rs-dpp, rs-sdk, DET, dashcore lib, ...

@shumkov shumkov merged commit fd2fb2d into v2.2-dev Nov 13, 2025
33 checks passed
@shumkov shumkov deleted the wasm-sdk-params2 branch November 13, 2025 04:49
@github-project-automation github-project-automation bot moved this from In review / testing to Done in Platform team Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants