-
Notifications
You must be signed in to change notification settings - Fork 45
refactor(sdk)!: typed params for state transition methods #2932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3.0-dev
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughReplace many per-field WASM state-transition APIs with option-object-driven bindings across contracts, documents, identities, tokens; add a reusable macro Changes
Sequence Diagram(s)sequenceDiagram
participant Client as JS Client / Facade
participant Facade as js-evo-sdk Facade
participant WasmSdk as WasmSdk (wasm-bindgen)
participant Signer as IdentitySignerWasm
participant Platform as Platform / Network
Client->>Facade: publish(options)
Facade->>WasmSdk: contractPublish(options)
WasmSdk->>WasmSdk: extract dataContract, identityKey, signer, settings
WasmSdk->>Signer: request signature for transition
Signer-->>WasmSdk: signature
WasmSdk->>Platform: broadcast transition
Platform-->>WasmSdk: broadcast result
WasmSdk-->>Facade: return DataContractWasm
Facade-->>Client: resolved DataContract
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ gRPC Query Coverage Report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
♻️ Duplicate comments (1)
packages/wasm-sdk/tests/functional/protocol.spec.mjs (1)
44-47: Same empty string verification applies here.This test uses the same fallback pattern as the previous test. The same verification for empty string handling in
getProtocolVersionUpgradeVoteStatusWithProofInfo()applies here as well.
🧹 Nitpick comments (16)
packages/rs-sdk/docs/IMPROVE_RETRY_ERROR_HANDLING.md (1)
8-8: Specify language for fenced code blocks.Markdown linting requires language identifiers on code blocks for consistency and syntax highlighting. Lines 8 and 13 contain code examples without language specifiers.
🔎 Proposed fix
-Example: `getDataContractHistory()` fails with proof verification error, but after all addresses are banned, the user sees: -``` +Example: `getDataContractHistory()` fails with proof verification error, but after all addresses are banned, the user sees: +```text Dapi client error: no available addresses to use -``` +```text Instead of the meaningful: -``` +```text Proof verification error: <actual error details> -``` +```textAlso applies to: 13-13
packages/wasm-sdk/tests/functional/epochs-blocks.spec.mjs (2)
20-24: Consider extracting the magic delay constant.The 100ms delay works, but it's a magic number. Consider extracting it as a named constant for clarity, or adding a brief comment explaining why this specific duration was chosen.
🔎 Optional: Extract named constant
+const CLEANUP_DELAY_MS = 100; // Allow pending microtasks to settle + after(async () => { - // Wait briefly to ensure any pending async operations complete - await new Promise((resolve) => { setTimeout(resolve, 100); }); + await new Promise((resolve) => { setTimeout(resolve, CLEANUP_DELAY_MS); }); if (client) { client.free(); } });
65-98: Test may be skipped entirely if no proTxHash is available.When both
evonodeProTxHashis null andbyRangereturns no results, the coregetEvonodesProposedEpochBlocksByIdsWithProofInfocall and its assertions (lines 92-97) are skipped entirely. Consider adding athis.skip()or a log message to make it explicit when this happens, so test runs are transparent about what was actually verified.🔎 Optional: Make test skip explicit
// Only test by IDs if we have a valid proTxHash if (testProTxHash) { const res = await client.getEvonodesProposedEpochBlocksByIdsWithProofInfo(epochIndex, [testProTxHash]); expect(res).to.be.ok(); expect(res.data).to.be.instanceOf(Map); expect(res.proof).to.be.ok(); expect(res.metadata).to.be.ok(); + } else { + this.skip(); // No proTxHash available to test byIds with proof }packages/wasm-sdk/src/wallet/key_generation.rs (1)
268-272: Consider moving imports to module level.These imports are used only within this function, but module-level imports are conventional in Rust. This is a minor style consideration that doesn't affect functionality.
🔎 Suggested refactor
Move these imports to the top of the file with other imports:
use dash_sdk::dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; use dash_sdk::dpp::identity::IdentityPublicKey; use dash_sdk::dpp::version::LATEST_PLATFORM_VERSION; use rand::rngs::StdRng; use rand::SeedableRng;packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (1)
192-195: Consider more meaningful assertions for replace/delete/transfer tests.
expect(true).to.be.trueis essentially a no-op. While the tests do verify success implicitly (no exception thrown), consider asserting on the operation result or fetching the document to verify the change. Based on learnings, use dirty-chai function-call style.🔎 Example improvement for documentReplace
// After replace, optionally fetch and verify the document was updated // Or at minimum, use a more descriptive assertion pattern // The current approach relies on "no throw = success" which is valid but weakpackages/wasm-sdk/src/state_transitions/document.rs (2)
29-39: Consider consolidating string extraction with other option utilities.
extract_string_from_optionsis only used once (line 373 fordocumentTypeName). Consider either:
- Moving to the shared utils module if it will be reused
- Inlining at the call site if truly single-use
105-106: Document cloning may be unnecessary.
document_wasm.clone()is called even thoughdocument_wasmis consumed immediately after. This pattern repeats in replace, transfer, purchase, and set_price methods. Consider using the value directly without cloning when possible.🔎 Example for document_create
- let document: Document = document_wasm.clone().into(); + let document: Document = document_wasm.into();Note: This depends on whether
document_wasmis used after the conversion. Check each method individually.packages/wasm-dpp2/src/private_key.rs (1)
129-151: Implementation looks correct.The
try_from_optionsmethod properly validates field presence and handles conversions with clear error messages. The pattern is consistent with similar manual implementations in this PR.Consider whether this manual implementation could use the
impl_try_from_options!macro for consistency with other types likeIdentityWasm,CoreScriptWasm, andDocumentWasm. The manual approach may be necessary due to theIntoWasmtrait usage, but verifying this would improve codebase uniformity.packages/wasm-dpp2/src/identifier.rs (1)
297-316: Implementation is correct.The
try_from_optionsmethod properly validates field presence and delegates to the existingtry_fromimplementation. Error handling is clear and consistent.Similar to
PrivateKeyWasm, consider whether theimpl_try_from_options!macro could be used here for consistency with types likeIdentityWasmandDocumentWasm, assuming the macro can accommodate the conversion logic.packages/wasm-sdk/tests/functional/transitions/contracts.spec.mjs (1)
87-156: Test dependency between suites.The
contractUpdatetest depends oncreatedContractIdbeing set by the priorcontractPublishtest. While Mocha runs tests sequentially by default (making this work), this creates an implicit ordering dependency. Consider documenting this dependency explicitly or using a shared setup if the tests ever need to run independently.The test logic itself is sound—proper security level selection (CRITICAL for updates), nonce cache refresh, schema augmentation, and version verification.
packages/wasm-sdk/tests/functional/transitions/identity.spec.mjs (1)
126-158: Test interdependency between add and disable key tests.The "disables a public key" test (line 126) depends on the previous "adds a new public key" test having successfully added a MEDIUM-level key. Line 141 asserts
keyToDisableexists, which will fail if the previous test didn't run or failed.This is acceptable for functional/integration tests where sequential operations are being validated, but consider adding a comment noting the dependency.
🔎 Suggested documentation improvement
it('disables a public key on identity', async function testDisablePublicKey() { + // Note: This test depends on the previous test having added a MEDIUM-level key // Identity update requires MASTER key (key index 0) const { signer } = createTestSignerAndKey(sdk, 1, 0);packages/wasm-dpp2/src/identity/signer.rs (1)
103-137: Multi-key-type support correctly implemented, but clippy warning should be addressed.The
get_key_hashmethod properly distinguishes betweenECDSA_HASH160(20-byte hash) andECDSA_SECP256K1(33-byte compressed pubkey that needs hashing). The logic is sound.However, clippy reports
result_large_errbecauseProtocolErroris at least 768 bytes. SinceProtocolErroris from thedppcrate, you can suppress this locally:🔎 Proposed fix to suppress clippy warning
+ #[allow(clippy::result_large_err)] fn get_key_hash(identity_public_key: &IdentityPublicKey) -> Result<[u8; 20], ProtocolError> {Alternatively, if this pattern is widespread, consider using
Box<ProtocolError>in theErrvariant at a higher level, but that would require broader changes to the dpp crate.packages/wasm-sdk/src/state_transitions/token.rs (3)
329-338: Redundant call toextract_settings_from_optionsfor user fee increase.Settings are already extracted on line 300 and stored in
settings. The code on lines 334-335 callsextract_settings_from_optionsagain, which duplicates the deserialization work.🔎 Proposed fix to reuse the already-extracted settings
// Add user fee increase from settings - let user_fee_increase = - get_user_fee_increase(extract_settings_from_options(&options_value)?.as_ref()); + let user_fee_increase = get_user_fee_increase(settings.as_ref()); if user_fee_increase > 0 { builder = builder.with_user_fee_increase(user_fee_increase); }
584-589: Same redundantextract_settings_from_optionspattern in token_burn.This pattern is repeated across multiple token operations. Consider fixing this in all places for consistency and efficiency.
🔎 Proposed fix
// Add user fee increase from settings - let user_fee_increase = - get_user_fee_increase(extract_settings_from_options(&options_value)?.as_ref()); + let user_fee_increase = get_user_fee_increase(settings.as_ref()); if user_fee_increase > 0 { builder = builder.with_user_fee_increase(user_fee_increase); }
831-836: Repeated redundantextract_settings_from_optionscalls across all token operations.This same pattern appears in token_transfer (831-836), token_freeze (1061-1066), token_unfreeze (1291-1296), token_destroy_frozen (1502-1507), token_emergency_action (1726-1731), token_claim (1935-1940), token_set_price (2177-2182), and token_direct_purchase (2399-2404).
Consider refactoring all of these to reuse the already-extracted
settingsvariable.Also applies to: 1061-1066, 1291-1296, 1502-1507, 1726-1731, 1935-1940, 2177-2182, 2399-2404
packages/wasm-sdk/src/state_transitions/addresses.rs (1)
924-931: Identity extraction inidentity_create_from_addressesuses different pattern than other methods.Lines 924-931 use manual
js_sys::Reflect::getandto_wasmfor identity extraction, while other methods in this file (lines 303-304, 511-512) useIdentityWasm::try_from_options. Consider using the consistent pattern for uniformity.🔎 Proposed fix for consistency
- // Extract identity from options - let identity_js = js_sys::Reflect::get(&options_value, &JsValue::from_str("identity")) - .map_err(|_| WasmSdkError::invalid_argument("identity is required"))?; - let identity: Identity = identity_js - .to_wasm::<wasm_dpp2::IdentityWasm>("Identity")? - .clone() - .into(); + // Extract identity from options + let identity: Identity = IdentityWasm::try_from_options(&options_value, "identity")?.into();
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/wasm-sdk/src/state_transitions/identity.rs (1)
861-882: Consider removing unused helper function.The
ecdsa_public_key_matches_identity_keyfunction is well-implemented but doesn't appear to be called anywhere in this file. Since it's not markedpub, it's not accessible from other modules either.If this function is intended for future use, consider adding a
#[allow(dead_code)]attribute with a comment explaining its purpose. Otherwise, remove it to reduce maintenance burden.🧹 Verification script to confirm it's unused
#!/bin/bash # Search for any usage of ecdsa_public_key_matches_identity_key in the codebase rg -n "ecdsa_public_key_matches_identity_key" --type rust
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/src/state_transitions/identity.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/state_transitions/identity.rs
🧠 Learnings (7)
📚 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/state_transitions/identity.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/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/state_transitions/identity.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/identity.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/identity.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-sdk/src/state_transitions/identity.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/state_transitions/identity.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/state_transitions/identity.rs (3)
packages/wasm-sdk/src/queries/utils.rs (1)
deserialize_required_query(11-28)packages/wasm-sdk/src/settings.rs (4)
extract_settings_from_options(259-272)from(66-73)from(203-226)get_user_fee_increase(278-284)packages/wasm-sdk/src/state_transitions/addresses.rs (2)
extract_settings_from_options(88-101)identity(838-840)
⏰ 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). (19)
- GitHub Check: Rust packages (drive-abci) / Check each feature
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (drive-abci) / Formatting
- GitHub Check: Rust packages (drive-abci) / Unused dependencies
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (dpp) / Formatting
- GitHub Check: Rust packages (dpp) / Tests
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Rust packages (dpp) / Detect immutable structure changes
- GitHub Check: Rust packages (dpp) / Linting
- GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
) / Build Drive image - GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Rust crates security audit
- GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
- GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
- GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (9)
packages/wasm-sdk/src/state_transitions/identity.rs (9)
89-127: LGTM! Well-structured identity creation flow.The implementation properly extracts all required options, handles errors with descriptive messages, and follows a clear async flow. The TypeScript interface documentation is comprehensive and helps developers understand the required parameters.
182-217: LGTM! Clean top-up implementation.The method correctly handles the identity top-up flow and returns the new balance as a BigInt. The optional parameter (None at line 209) appears appropriate for the top-up context where the asset lock key is sufficient.
304-354: LGTM! Robust credit transfer implementation.The transfer flow is well-implemented with proper handling of both required and optional parameters. The result struct provides clear access to both balances post-transfer, which is useful for callers.
463-467: Good validation! Zero-amount check prevents invalid withdrawals.The validation ensures that withdrawal requests have a meaningful amount before processing. The error message is clear and actionable.
473-482: LGTM! Safe address parsing with proper error handling.The optional address parsing correctly uses
transpose()to handle the nested Result/Option, and provides a clear error message if the address is malformed.
605-609: LGTM! Revision increment is correctly handled.The in-place revision increment is intentional and well-documented. The comment clearly explains that the platform expects the new revision in the state transition, which aligns with the implementation.
614-642: LGTM! Robust master key validation and selection.The code properly:
- Filters for valid master keys (AUTHENTICATION + MASTER + supported key types)
- Validates at least one master key exists
- Ensures the signer has a matching private key
This prevents invalid update attempts with clear error messages.
645-673: LGTM! Safe key ID assignment logic.The calculation
max().copied().unwrap_or(0) + 1correctly handles:
- Empty key maps (starts at 1)
- Sequential IDs (max + 1)
- Gaps in IDs (avoids collisions)
The loop then assigns sequential IDs to each new key being added.
799-859: LGTM! Clean masternode voting implementation.The voting flow is well-structured with proper extraction of vote components and construction of the vote structures. The use of the PutVote trait keeps the implementation clean and consistent with SDK patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In @packages/wasm-sdk/src/state_transitions/token.rs:
- Around line 867-918: The TypeScript option interfaces for several token
operations (e.g., TOKEN_FREEZE_OPTIONS_TS used by tokenFreeze, and the analogous
TS constants used by tokenUnfreeze, tokenDestroyFrozen, tokenEmergencyAction,
tokenSetPrice, tokenDirectPurchase, etc.) are missing the identityKey field even
though the Rust implementations call
IdentityPublicKeyWasm::try_from_options(..., "identityKey") and require it at
runtime; update each affected TS interface to include identityKey: Identifier
(optionally with a comment matching other signer fields) so TypeScript
signatures match Rust expectations and consumers can provide the required key.
- Around line 46-93: fetch_and_cache_token_contract currently unwraps mutexes
and returns errors if trusted contexts are missing, which can panic on poisoned
mutexes and breaks non‑trusted flows; change it to attempt locking each context
with .lock().map_err(|e| WasmSdkError::generic(format!("...: {:?}", e)))? and
then only call add_known_contract when the guard.as_ref().is_some() (i.e., if
the trusted context is initialized), otherwise silently skip caching (like
sdk.rs) instead of returning an error; ensure you handle all three context
globals (TESTNET_TRUSTED_CONTEXT, MAINNET_TRUSTED_CONTEXT,
LOCAL_TRUSTED_CONTEXT) this way and keep the function returning
Ok(data_contract) on non‑trusted flows.
- Around line 751-781: The from_result function in TokenTransferResultWasm
currently pulls the "first two balances" from TransferResult::IdentitiesBalances
which relies on BTreeMap ordering and can swap sender/recipient; change the
signature of TokenTransferResultWasm::from_result(result: TransferResult,
contract_id: Identifier) to accept sender_id and recipient_id (e.g.
from_result(result, contract_id, sender_id, recipient_id)), then when matching
TransferResult::IdentitiesBalances(balances) lookup balances.get(&sender_id) and
balances.get(&recipient_id) to populate sender_balance and recipient_balance
respectively; update all call sites that invoke
TokenTransferResultWasm::from_result to pass the sender_id and recipient_id, and
keep the existing handling for HistoricalDocument and GroupActionWithDocument
using document_to_wasm(contract_id, "transfer") unchanged.
🧹 Nitpick comments (1)
packages/wasm-sdk/src/state_transitions/token.rs (1)
311-350: Avoid double-parsingsettings(and double error paths).Every operation does:
let settings = extract_settings_from_options(&options_value)?;- later:
get_user_fee_increase(extract_settings_from_options(&options_value)?.as_ref())This repeats work and can fail the call after
settingsalready parsed successfully. It also forces repeated reflection/serde across all token ops.Proposed fix pattern (compute fee increase from the already-parsed settings)
- let settings = extract_settings_from_options(&options_value)?; + let settings = extract_settings_from_options(&options_value)?; + let user_fee_increase = get_user_fee_increase(settings.as_ref()); // Add settings if let Some(settings) = settings { builder = builder.with_settings(settings); } - // Add user fee increase from settings - let user_fee_increase = - get_user_fee_increase(extract_settings_from_options(&options_value)?.as_ref()); if user_fee_increase > 0 { builder = builder.with_user_fee_increase(user_fee_increase); }Also applies to: 568-602, 823-850, 1047-1081, 1278-1312, 1490-1524, 1703-1749, 1933-1959, 2164-2202, 2403-2425
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/src/state_transitions/token.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/state_transitions/token.rs
🧠 Learnings (13)
📓 Common learnings
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.
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.
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.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use JavaScript/TypeScript for client SDKs, developer tools, and test suite
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use state transitions for updates in documents and data contracts
📚 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/token.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/token.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/state_transitions/token.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-sdk/src/state_transitions/token.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/token.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/state_transitions/token.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2185
File: packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v1/mod.rs:47-62
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In `rebroadcast_expired_withdrawal_documents_v1`, the variable `expired_withdrawal_indices` needs to be a `Vec<WithdrawalTransactionIndex>` rather than a `BTreeSet<WithdrawalTransactionIndex>`, because a vector is necessary for subsequent processing.
Applied to files:
packages/wasm-sdk/src/state_transitions/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/state_transitions/token.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/token.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/state_transitions/token.rs
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/wasm-sdk/src/state_transitions/token.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/token.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (wasm-dpp2) / Linting
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (wasm-dpp) / Tests
- GitHub Check: Rust packages (dpp) / Unused dependencies
- GitHub Check: Rust packages (dpp) / Linting
- GitHub Check: Rust packages (dpp) / Check each feature
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
- GitHub Check: Rust packages (drive-abci) / Check each feature
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (drive-abci) / Unused dependencies
- GitHub Check: Rust packages (drive-abci) / 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, SDK_TEST_DATA=true
) / 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
- GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (1)
packages/wasm-sdk/src/state_transitions/token.rs (1)
170-186:bigint | numberin TS +u64in Rust needs a known-good conversion path.All numeric inputs are
u64on the Rust side (amounts, prices, maxTotalCost), while TS allowsbigint. This is fine only ifdeserialize_required_query(and the underlying serde path) reliably converts JSBigInttou64and rejects unsafe JSnumberprecision cases in a predictable way.Also applies to: 431-446, 681-703, 926-947, 1157-1177, 1388-1408, 1602-1622, 1825-1841, 2036-2057, 2272-2291
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🤖 Fix all issues with AI agents
In @packages/wasm-sdk/src/state_transitions/identity.rs:
- Around line 649-668: Compute next_key_id using checked_add to avoid overflow
when taking identity.public_keys().keys().max().copied().unwrap_or(0); replace
the unguarded `+ 1` with a checked add and handle the None/overflow case by
returning an appropriate error (or failing fast) before iterating, and ensure
the loop that sets key_in_creation.set_key_id(next_key_id) updates next_key_id
safely (e.g., use checked_add each increment and propagate an error if it would
overflow) so no wraparound or panic can occur.
In @packages/wasm-sdk/src/state_transitions/token.rs:
- Around line 1558-1602: The interface TokenEmergencyActionOptions is missing
the required identityKey property that the implementation reads from options
(see where identityKey is extracted in the emergency action flow); add a
required identityKey field to TokenEmergencyActionOptions with the same type
used by the implementation (matching the type expected by the code that
extracts/uses identityKey) and include a short JSDoc comment describing it so
the interface and runtime usage are consistent.
- Around line 1994-2039: The TokenSetPriceOptions interface is missing the
required identityKey field (extracted from options in the implementation around
where identityKey is read), so add a non-optional identityKey property to
TokenSetPriceOptions (e.g., identityKey: Identifier | Buffer) and document it
like the other fields; update the interface declaration TokenSetPriceOptions to
include this new identityKey property so callers must provide it when calling
the function that reads identityKey.
- Around line 879-923: The TokenFreezeOptions interface is missing the required
identityKey field used by the implementation; update the TokenFreezeOptions
declaration to include a required identityKey property (with the same type the
implementation expects, e.g. IdentityPublicKey / IdentityKey / Uint8Array /
Buffer / string as appropriate), and add a short JSDoc comment like "The
identity public key (authentication key) used for signing/identification" so
TypeScript callers are forced to provide it and match the runtime extraction in
the freeze token logic.
- Around line 2237-2275: The TokenDirectPurchaseOptions interface is missing the
required identityKey field that the implementation reads; update the
TokenDirectPurchaseOptions interface to include an identityKey property
(matching the type used where it’s extracted, e.g., Identifier or Uint8Array as
appropriate) and add a short JSDoc comment explaining it is the buyer's
authentication key to be used by the signer so callers see the required field.
- Around line 1341-1385: The TokenDestroyFrozenOptions interface is missing the
required identityKey field that the implementation reads from options (see where
identityKey is extracted); add a new identityKey property to
TokenDestroyFrozenOptions (make it required) with the same type used by the
function that consumes it (the identity public key / raw key type your codebase
expects) and include a brief JSDoc comment describing it so callers know to
supply the authority's identity key for the destruction operation.
🧹 Nitpick comments (2)
packages/wasm-sdk/src/state_transitions/token.rs (1)
309-348: Refactor: eliminate duplicate settings extraction.The code extracts settings twice (line 310 and lines 344-345), which is redundant. The second extraction is only to derive
user_fee_increase. Consider storing the result from line 310 and reusing it.♻️ Proposed refactor
// Extract settings from options let settings = extract_settings_from_options(&options_value)?; +let user_fee_increase = get_user_fee_increase(settings.as_ref()); // Build the mint transition using rs-sdk builder let mut builder = TokenMintTransitionBuilder::new( Arc::new(data_contract), parsed.token_position, identity_id, amount, ); // ... (other builder modifications) // Add settings if let Some(settings) = settings { builder = builder.with_settings(settings); } // Add user fee increase from settings -let user_fee_increase = - get_user_fee_increase(extract_settings_from_options(&options_value)?.as_ref()); if user_fee_increase > 0 { builder = builder.with_user_fee_increase(user_fee_increase); }Note: This pattern repeats in all token operations (burn, transfer, freeze, unfreeze, destroy_frozen, emergency_action, claim, set_price, direct_purchase). Apply the same refactor across all operations.
packages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs (1)
150-164: Suggest refactoring to eliminate redundant field access.The
try_from_optional_optionsmethod fetches and validatesfield_value(lines 154-161), but then callstry_from_optionson line 163, which re-fetches the same field and re-checks for undefined/null. This is inefficient.♻️ Proposed refactor to reuse field_value
pub fn try_from_optional_options( options: &JsValue, field_name: &str, ) -> WasmDppResult<Option<Self>> { let field_value = js_sys::Reflect::get(options, &JsValue::from_str(field_name)).map_err(|_| { WasmDppError::invalid_argument(format!("Failed to access {}", field_name)) })?; if field_value.is_undefined() || field_value.is_null() { return Ok(None); } - Self::try_from_options(options, field_name).map(Some) + // Convert the field_value directly instead of re-fetching + field_value + .to_wasm::<GroupStateTransitionInfoStatusWasm>("GroupStateTransitionInfoStatus") + .map(|boxed| Some(boxed.clone())) }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.rspackages/wasm-dpp2/src/lib.rspackages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rspackages/wasm-dpp2/src/utils.rspackages/wasm-sdk/src/sdk.rspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/wasm-dpp2/src/lib.rs
- packages/wasm-dpp2/src/utils.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-sdk/src/state_transitions/identity.rspackages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.rspackages/wasm-sdk/src/sdk.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs
🧠 Learnings (28)
📓 Common learnings
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.
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.
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.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations
Learnt from: 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.
📚 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/state_transitions/identity.rspackages/wasm-sdk/src/sdk.rspackages/wasm-sdk/src/state_transitions/token.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/identity.rspackages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.rspackages/wasm-sdk/src/state_transitions/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/state_transitions/identity.rspackages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.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/identity.rspackages/wasm-sdk/src/state_transitions/token.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/identity.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/sdk.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs
📚 Learning: 2024-10-09T00:22:57.778Z
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-10-09T00:22:57.778Z
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.rspackages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.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/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.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/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.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/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.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/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.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/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.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/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.rspackages/wasm-sdk/src/state_transitions/token.rs
📚 Learning: 2025-11-25T13:10:38.019Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: packages/swift-sdk/SwiftExampleApp/CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:38.019Z
Learning: Applies to packages/swift-sdk/SwiftExampleApp/**/PersistentToken.swift : Provide predicate methods for PersistentToken querying: mintableTokensPredicate(), burnableTokensPredicate(), freezableTokensPredicate(), distributionTokensPredicate(), pausedTokensPredicate(), tokensByContractPredicate(contractId:), and tokensWithControlRulePredicate(rule:)
Applied to files:
packages/wasm-sdk/src/state_transitions/token.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/state_transitions/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/state_transitions/token.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/token.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2185
File: packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v1/mod.rs:47-62
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In `rebroadcast_expired_withdrawal_documents_v1`, the variable `expired_withdrawal_indices` needs to be a `Vec<WithdrawalTransactionIndex>` rather than a `BTreeSet<WithdrawalTransactionIndex>`, because a vector is necessary for subsequent processing.
Applied to files:
packages/wasm-sdk/src/state_transitions/token.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/state_transitions/token.rs
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/wasm-sdk/src/state_transitions/token.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/state_transitions/token.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/state_transitions/token.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/state_transitions/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/state_transitions/token.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/state_transitions/token.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/token.rs
🧬 Code graph analysis (5)
packages/wasm-sdk/src/state_transitions/identity.rs (6)
packages/wasm-sdk/src/queries/utils.rs (1)
deserialize_required_query(11-28)packages/wasm-sdk/src/settings.rs (4)
extract_settings_from_options(259-272)from(66-73)from(203-226)get_user_fee_increase(278-284)packages/wasm-sdk/src/error.rs (2)
generic(71-73)invalid_argument(75-77)packages/wasm-dpp2/src/utils.rs (1)
try_to_u64(125-137)packages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs (1)
try_from_optional_options(150-164)packages/wasm-dpp2/src/identity/signer.rs (1)
new(60-64)
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.rs (1)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (1)
signer(68-68)
packages/wasm-sdk/src/sdk.rs (1)
packages/rs-sdk/src/sdk.rs (1)
refresh_identity_nonce(583-598)
packages/wasm-sdk/src/state_transitions/token.rs (5)
packages/wasm-sdk/src/queries/utils.rs (1)
deserialize_required_query(11-28)packages/wasm-sdk/src/settings.rs (4)
extract_settings_from_options(259-272)get_user_fee_increase(278-284)from(66-73)from(203-226)packages/wasm-sdk/src/error.rs (3)
not_found(83-85)generic(71-73)invalid_argument(75-77)packages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs (4)
from(26-28)from(32-34)try_from_options(132-147)try_from_optional_options(150-164)packages/rs-sdk/src/platform/tokens/builders/emergency_action.rs (2)
pause(44-60)resume(73-89)
packages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs (2)
packages/wasm-sdk/src/sdk.rs (1)
from(93-95)packages/wasm-sdk/src/error.rs (1)
invalid_argument(75-77)
🔇 Additional comments (19)
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/v0_methods.rs (2)
73-77: LGTM! Cleaner error propagation.The use of the
?operator to propagate errors fromsign_externalis more idiomatic Rust than the previous match statement approach. This simplification maintains the same error handling behavior while improving code readability.
23-80: LGTM! Solid implementation.The function correctly handles key selection, validation, and signing:
- Properly validates that the signer can use the specified key
- Falls back to finding an appropriate transfer key when none is specified
- Uses appropriate filters (Purpose::TRANSFER, full security level range, all key types)
- Returns descriptive errors for missing or invalid keys
packages/wasm-sdk/src/state_transitions/token.rs (1)
1110-1154: Critical: Add missingidentityKeyfield to TypeScript interface.The implementation extracts
identityKeyfrom options (lines 1274-1276), but the TypeScript interfaceTokenUnfreezeOptionsdoes not document this required field.📝 Proposed fix
export interface TokenUnfreezeOptions { // ... existing fields ... publicNote?: string; + /** + * The identity public key to use for signing the transition. + * Get this from the authority identity's public keys. + */ + identityKey: IdentityPublicKey; + /** * Signer containing the private key for the authority's authentication key. * Use IdentitySigner to add the authentication key before calling. */ signer: IdentitySigner; // ... remaining fields ... }⛔ Skipped due to learnings
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.packages/wasm-dpp2/src/state_transitions/base/group_state_transition_info_status.rs (5)
1-14: LGTM!The module documentation clearly explains the purpose, and imports are complete and follow standard patterns for WASM bindings.
16-35: LGTM!The wrapper struct and bidirectional conversions follow the standard newtype pattern for WASM bindings established throughout this PR.
56-88: LGTM!Both constructors are correctly implemented:
proposer()creates the Proposer variant with just the positionother_signer()properly converts the action_id and setsaction_is_proposer: falsefor the OtherSigner variantThe flexible JS input handling via
unchecked_param_typeand error handling are appropriate.
90-128: LGTM!All accessor methods correctly handle both enum variants:
is_proposer()uses pattern matching appropriatelygroup_contract_position()extracts the position from both variantsaction_id()correctly returnsNonefor proposer (which doesn't have an action_id) andSomefor other signerto_info()performs the conversion cleanly
39-47: No changes needed. The signature difference betweentype_name(&self)andstruct_name()is consistent with the established pattern throughout the wasm-dpp2 codebase—all similar WASM-bound types use instance getters fortype_nameand static methods forstruct_name. This is intentional design, not an inconsistency.Likely an incorrect or invalid review comment.
packages/wasm-sdk/src/sdk.rs (2)
116-148: LGTM - Clean contract caching helper.The
add_contract_to_context_cachemethod correctly implements network-specific contract caching by pattern-matching on the network type and updating the appropriate global trusted context. The no-op behavior for unsupported networks is appropriate.
150-163: LGTM - Identity nonce refresh binding.The
refresh_identity_nonceWASM binding correctly delegates to the underlying SDK method for clearing cached nonces. The implementation is consistent with the rs-sdk'srefresh_identity_noncemethod shown in the relevant code snippets.packages/wasm-sdk/src/state_transitions/identity.rs (9)
1-27: LGTM - Clean module structure.The module documentation and imports are well-organized. The use of wasm_bindgen for WASM bindings and integration with dash_sdk types is appropriate.
78-127: LGTM - Solid identity creation flow.The
identity_createmethod correctly extracts all required parameters from the options object, including the identity, asset lock proof, private key, and signer. The delegation toput_to_platform_and_wait_for_responsewith proper error handling is appropriate.
172-217: LGTM - Identity top-up implementation.The
identity_top_upmethod correctly handles the top-up flow, extracting the required parameters and returning the new balance as a BigInt for JavaScript interoperability.
271-291: LGTM - Well-designed result type.The
IdentityCreditTransferResultWasmstruct with its getters forsender_balanceandrecipient_balanceprovides a clean API for JavaScript consumers.
294-354: LGTM - Credit transfer implementation.The
identity_credit_transfermethod correctly:
- Parses the amount using
try_to_u64to handle BigInt/Number from JavaScript (lines 321-324)- Extracts the optional signing key (lines 330-332)
- Delegates to the
transfer_creditsmethod and returns both balances
462-467: LGTM - Good validation.The zero-amount validation prevents invalid withdrawal requests with a clear error message.
437-511: LGTM - Comprehensive withdrawal implementation.The
identity_credit_withdrawalmethod correctly:
- Validates the withdrawal amount is non-zero (lines 463-467)
- Parses and validates the optional Dash address (lines 473-482)
- Extracts all required parameters with proper type conversions
- Handles errors appropriately
580-715: LGTM - Comprehensive identity update flow.The
identity_updatemethod handles a complex flow correctly:
- Increments the identity revision with a clear explanatory comment (lines 608-609)
- Validates master keys exist and filters by appropriate criteria (lines 615-631)
- Finds a master key the signer can use (lines 634-642)
- Parses keys to add and assigns sequential IDs (lines 644-673)
- Fetches the identity nonce and constructs the transition properly
The implementation is well-structured and handles all the necessary validations. Note: see separate comment about key ID overflow edge case.
789-859: LGTM - Masternode voting implementation.The
masternode_votemethod correctly implements the voting flow:
- Extracts all required parameters with proper type conversions
- Constructs the ResourceVote and Vote structures correctly
- Delegates to the PutVote trait for submission
- Uses appropriate error propagation with the
?operator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (7)
packages/wasm-sdk/src/state_transitions/identity.rs (2)
204-211: Document theNoneparameter purpose.The
Noneparameter on line 209 is passed totop_up_identitybut its purpose is not documented in the code comments or TypeScript interface. Consider adding a brief comment explaining what this optional parameter represents for future maintainability.📝 Suggested documentation addition
- // Top up the identity + // Top up the identity (None parameter is for optional nonce override) let new_balance = identity .top_up_identity( self.inner_sdk(),
615-642: Consider adding inline comments to the master key selection logic.The master key filtering and selection logic (lines 615-642) implements important security requirements but is quite dense. Adding brief inline comments explaining the security model would improve maintainability.
📝 Suggested documentation enhancement
// Find all valid master keys (AUTHENTICATION + MASTER + supported key type) + // Master keys are required because only they have the authority to update identity keys let master_keys: Vec<_> = identity .public_keys() .iter() .filter(|(_, key)| { + // Must be AUTHENTICATION purpose to sign state transitions key.purpose() == Purpose::AUTHENTICATION + // Must be MASTER security level for update operations && key.security_level() == SecurityLevel::MASTER + // Must use a supported elliptic curve key type && (key.key_type() == KeyType::ECDSA_HASH160 || key.key_type() == KeyType::ECDSA_SECP256K1) })packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (2)
43-63: Consider adding more specific balance assertions.The test verifies that
result.senderBalanceexists but doesn't validate the actual balance change. For a more robust test, consider comparing the sender's balance before and after the transfer to confirm the 10-token deduction.
137-155: Test depends on state from prior test (tokenFreeze).This test unfreezes Identity 3, which was frozen in the
tokenFreezetest. If tests run in isolation or the freeze test fails, this test may behave unexpectedly. The comment on line 139 mentions "Identity 2 is already frozen on TOKEN_0 in genesis state" but the code unfreezes Identity 3 instead.Consider aligning the comment with the actual test behavior or using the genesis-frozen Identity 2 for a more predictable test.
packages/wasm-sdk/src/state_transitions/token.rs (1)
310-311: Redundantextract_settings_from_optionscall.Settings are extracted twice from the same options object - once at line 311 and again at lines 345-346 when getting
user_fee_increase. Consider extracting settings once and reusing:♻️ Suggested optimization
// Extract settings from options let settings = extract_settings_from_options(&options_value)?; + // Get user fee increase from settings (before moving settings into builder) + let user_fee_increase = get_user_fee_increase(settings.as_ref()); + // Build the mint transition using rs-sdk builder let mut builder = TokenMintTransitionBuilder::new( Arc::new(data_contract), parsed.token_position, identity_id, amount, ); // ... other builder setup ... // Add settings if let Some(settings) = settings { builder = builder.with_settings(settings); } // Add user fee increase from settings - let user_fee_increase = - get_user_fee_increase(extract_settings_from_options(&options_value)?.as_ref()); if user_fee_increase > 0 { builder = builder.with_user_fee_increase(user_fee_increase); }This pattern repeats in all token operations (burn, transfer, freeze, etc.). Consider refactoring for consistency.
Also applies to: 344-349
packages/wasm-sdk/tests/functional/transitions/identity.spec.mjs (1)
126-158: Test depends on state from previous test.The "disables a public key" test relies on the MEDIUM security key created in the "adds a new public key" test. If tests run in isolation or the add-key test fails, the assertion at line 141 will fail.
Consider adding a more descriptive error message or creating the key within this test for isolation:
if (!keyToDisable) { this.skip('No MEDIUM security key available - requires prior test to add one'); }packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (1)
193-194: Consider stronger success assertions.Using
expect(true).to.be.trueonly confirms no exception was thrown. While this works, fetching the document and verifying its state would provide stronger validation:// For documentReplace - verify the updated content const fetchedDoc = await client.getDocument(/* query for the document */); expect(fetchedDoc.properties.message).to.equal('Updated message'); // For documentDelete - verify the document no longer exists // (may throw or return null/undefined depending on API) // For documentTransfer - verify new owner const transferredDoc = await client.getDocument(/* query */); expect(transferredDoc.ownerId).to.equal(testData.identityId2);This is optional given the functional test context where the focus is on exercising the API without errors.
Also applies to: 236-237, 288-289
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
packages/wasm-dpp2/src/data_contract/model.rspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/wasm-sdk/tests/functional/transitions/contracts.spec.mjs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/wasm-dpp2/src/data_contract/model.rspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rs
🧠 Learnings (36)
📓 Common learnings
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.
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.
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.
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use JavaScript/TypeScript for client SDKs, developer tools, and test suite
📚 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/tests/functional/transitions/tokens.spec.mjspackages/wasm-sdk/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 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/tests/functional/transitions/tokens.spec.mjspackages/wasm-sdk/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 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/wasm-sdk/tests/functional/transitions/tokens.spec.mjspackages/wasm-sdk/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 Learning: 2025-12-29T10:53:03.792Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2868
File: packages/wasm-sdk/tests/functional/addresses.spec.mjs:75-95
Timestamp: 2025-12-29T10:53:03.792Z
Learning: In this repository, tests use the dirty-chai plugin for Chai. Write assertions using the function-call style (e.g., expect(...).to.be.ok()) instead of the property-based style. Ensure dirty-chai is loaded in the test setup and documented so new tests conform to this pattern.
Applied to files:
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjspackages/wasm-sdk/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.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/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 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/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.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/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/src/state_transitions/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/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 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/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/src/state_transitions/token.rs
📚 Learning: 2025-09-03T19:33:21.688Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/api-definitions.json:1285-1285
Timestamp: 2025-09-03T19:33:21.688Z
Learning: In packages/wasm-sdk/api-definitions.json, thephez prefers to keep the existing "ripemd160hash20bytes1234" placeholder for ECDSA_HASH160 data field in documentation examples rather than using a valid base64-encoded format, maintaining consistency with the previous documentation approach.
Applied to files:
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.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/functional/fixtures/requiredTestData.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/fixtures/requiredTestData.mjspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rs
📚 Learning: 2025-07-10T00:37:09.586Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2690
File: packages/wasm-sdk/src/queries/document.rs:383-384
Timestamp: 2025-07-10T00:37:09.586Z
Learning: In the Dash platform, DPNS (Dash Platform Name Service) contracts have the same ID across all networks (mainnet, testnet, etc.), so hardcoding the DPNS contract ID is appropriate and doesn't need to be configurable.
Applied to files:
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.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/tests/functional/fixtures/requiredTestData.mjs
📚 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-dpp2/src/data_contract/model.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-dpp2/src/data_contract/model.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-dpp2/src/data_contract/model.rspackages/wasm-sdk/src/state_transitions/token.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-dpp2/src/data_contract/model.rspackages/wasm-sdk/src/state_transitions/identity.rspackages/wasm-sdk/src/state_transitions/token.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations
Applied to files:
packages/wasm-dpp2/src/data_contract/model.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/state_transitions/identity.rs
📚 Learning: 2024-10-09T00:22:57.778Z
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-10-09T00:22:57.778Z
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.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/state_transitions/identity.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/token.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2185
File: packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v1/mod.rs:47-62
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In `rebroadcast_expired_withdrawal_documents_v1`, the variable `expired_withdrawal_indices` needs to be a `Vec<WithdrawalTransactionIndex>` rather than a `BTreeSet<WithdrawalTransactionIndex>`, because a vector is necessary for subsequent processing.
Applied to files:
packages/wasm-sdk/src/state_transitions/token.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/state_transitions/token.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/state_transitions/token.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/state_transitions/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/state_transitions/token.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/state_transitions/token.rs
📚 Learning: 2025-04-10T07:20:54.881Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2534
File: packages/rs-dpp/src/tokens/token_event.rs:0-0
Timestamp: 2025-04-10T07:20:54.881Z
Learning: In the TokenEvent system, the purchaser's identity for DirectPurchase events is captured as the owner_id of the document, rather than as a separate field in the event properties.
Applied to files:
packages/wasm-sdk/src/state_transitions/token.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/token.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/tests/functional/transitions/documents.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/functional/transitions/documents.spec.mjs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use state transitions for updates in documents and data contracts
Applied to files:
packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 Learning: 2025-07-31T18:15:51.813Z
Learnt from: thephez
Repo: dashpay/platform PR: 2715
File: packages/wasm-sdk/test/ui-automation/run-ui-tests.sh:6-286
Timestamp: 2025-07-31T18:15:51.813Z
Learning: In packages/wasm-sdk/test/ui-automation/run-ui-tests.sh, the script doesn't require cleanup handling because it relies on Playwright's built-in webServer configuration to manage the HTTP server lifecycle automatically. The script only runs foreground processes through npm/Playwright commands.
Applied to files:
packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
🧬 Code graph analysis (5)
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (1)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (2)
wasmFunctionalTestRequirements(8-29)createTestSignerAndKey(55-117)
packages/wasm-sdk/tests/functional/transitions/identity.spec.mjs (1)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (3)
wasmFunctionalTestRequirements(8-29)createTestSignerAndKey(55-117)signer(68-68)
packages/wasm-dpp2/src/data_contract/model.rs (2)
packages/wasm-sdk/src/error.rs (2)
serialization(79-81)invalid_argument(75-77)packages/wasm-dpp2/src/serialization/conversions.rs (1)
platform_value_from_object(246-249)
packages/wasm-sdk/src/state_transitions/identity.rs (3)
packages/wasm-sdk/src/queries/utils.rs (1)
deserialize_required_query(11-28)packages/wasm-sdk/src/settings.rs (4)
extract_settings_from_options(259-272)from(66-73)from(203-226)get_user_fee_increase(278-284)packages/wasm-sdk/src/error.rs (2)
generic(71-73)invalid_argument(75-77)
packages/wasm-sdk/src/state_transitions/token.rs (1)
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (8)
result(50-58)result(75-83)result(101-110)result(124-131)result(144-151)result(163-170)result(180-187)result(199-206)
🪛 Gitleaks (8.30.0)
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
[high] 15-15: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
⏰ 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). (6)
- GitHub Check: Rust packages (wasm-dpp2) / 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, SDK_TEST_DATA=true
) / Build Drive image - GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Rust crates security audit
🔇 Additional comments (24)
packages/wasm-dpp2/src/data_contract/model.rs (2)
4-4: LGTM: Options-based conversion pattern added.The addition of
impl_try_from_optionsmacro enables the TryFrom-options-style construction forDataContractWasm, aligning with the broader refactor to use typed parameter objects instead of multiple arguments. This is consistent with the documented breaking change in the PR.Also applies to: 547-548
447-452: LGTM: Improved symmetry and type preservation.The refactor to use
platform_value_from_objectcreates better symmetry withgetSchemas(line 319) and correctly preserves integer types by avoiding JSON round-tripping. The explanatory comment is helpful, and the error handling appropriately distinguishes between deserialization failures (serialization error) and format mismatches (invalid_argument).packages/wasm-sdk/src/state_transitions/identity.rs (6)
78-127: LGTM! Well-structured identity creation flow.The implementation correctly:
- Extracts all required parameters using type-safe helpers
- Validates the asset lock proof
- Handles signing with proper error propagation
- Broadcasts and waits for confirmation
271-354: LGTM! Credit transfer implementation is robust.The implementation properly:
- Validates the amount using
try_to_u64with clear error messages- Supports optional signing key for flexibility
- Returns both balances in a well-structured result type
- Handles all error cases appropriately
436-511: LGTM! Withdrawal logic is well-validated.The implementation includes proper safeguards:
- Validates amount is greater than zero (lines 463-467)
- Safely parses the Dash address with clear error messages
- Uses idiomatic
.transpose()?pattern for Option<Result<T, E>> conversion- Handles all optional parameters appropriately
605-609: Excellent: Proper revision increment for state transition.The code correctly increments the identity revision before creating the update transition, with a clear comment explaining that the platform expects the new revision value (current + 1) in the state transition.
654-672: Excellent overflow protection for key ID assignment.The implementation uses
checked_addat two critical points (lines 654-656, 670-672) to prevent key ID overflow, with clear error messages. This defensive coding prevents potential issues with identities that have many keys.
793-864: LGTM! Masternode vote implementation is clean.The implementation correctly:
- Extracts all required parameters for voting
- Constructs the proper vote structure hierarchy (ResourceVoteV0 → ResourceVote → Vote)
- Uses the PutVote trait for consistent broadcast behavior
- Propagates errors appropriately
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (1)
1-117: LGTM!The test fixtures and helper utilities are well-structured and documented. The
createTestSignerAndKeyhelper correctly:
- Extracts key properties from the Map returned by serde_wasm_bindgen
- Maps string enums to their numeric equivalents
- Properly determines
readOnlybased on purpose (TRANSFER keys are read-only)- Constructs the signer and identity key for use in tests
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (3)
12-15: Static analysis false positive - test identity ID, not a secret.The Gitleaks warning about "generic-api-key" on line 15 is a false positive. The
identityId3value is a deterministic test identifier (32 bytes of 0x03 encoded as base58), seeded viaSDK_TEST_DATA=truefor functional testing. This is documented test data, not a secret.
26-42: LGTM!Test lifecycle is properly structured with initialization, quorum prefetching, and cleanup. The 120-second timeout is appropriate for network-bound token operations.
157-191: LGTM!The emergency action tests properly exercise the pause/resume flow in sequence. The second test resumes the token that was paused by the first test, which is the expected sequential dependency for this test suite.
packages/wasm-sdk/src/state_transitions/token.rs (5)
1-46: LGTM!The module setup and imports are well-organized. The
document_to_wasmhelper provides clean conversion of SDK documents to WASM-friendly types with proper metadata.
47-92: Good contract caching with network-aware context.The
fetch_and_cache_token_contracthelper correctly handles caching for different network contexts (Testnet, Mainnet, Regtest). The error for unsupported networks provides clear feedback.
807-812: Good defensive validation for self-transfers.Preventing token transfers to the same identity is proper validation that avoids unnecessary state transitions.
1738-1754: LGTM!The emergency action builder correctly uses dedicated constructors (
pause/resume) based on the action string, with proper case-insensitive matching and clear error messaging for invalid actions.
2152-2188: LGTM!The
TokenSetPriceResultWasm::from_resultcorrectly handles all SDK result variants and properly converts pricing schedules to their WASM equivalents.packages/wasm-sdk/tests/functional/transitions/identity.spec.mjs (3)
35-47: Good defensive cleanup pattern.The guarded
client.free()with try/catch properly handles potential double-free or borrow issues that can occur if tests timeout with pending operations.
75-124: Test correctly handles key addition with signer update.The test properly:
- Generates a new key pair
- Adds the new private key to the signer (required for key proof signing)
- Creates the
IdentityPublicKeyInCreationwith appropriate security level- Waits for platform processing before verification
This follows the expected workflow for identity key management.
187-202: Good documentation for skipped tests.The comments clearly explain why
identityTopUpandidentityCreateare skipped - they require asset lock proofs from the core blockchain, which is complex to set up in functional tests.packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (4)
21-42: LGTM!Test lifecycle is properly structured. The 180-second timeout accommodates the sequential nature of document operations including contract publishing and indexing delays.
43-74: LGTM!The document creation test correctly:
- Uses HIGH security level key (index 2) for document operations
- Creates a unique
saltedDomainHashusing timestamp- Sets revision as
BigInt(1)for initial creation- Stores the generated document ID for potential later use
83-118: Well-designed contract schema for testing document mutability.The schema correctly defines:
mutableNote: mutable and deletable document typetransferableItem: transferable document type withtransferable: 1(Always)- Proper position properties for both types and their fields
147-196: Test demonstrates proper document lifecycle flow.The test correctly:
- Creates a mutable document with revision 1
- Waits for indexing (2 seconds)
- Replaces with incremented revision 2
- Uses the same document ID for the replacement
The sequential dependency on
testContractIdfrom the previous test is acceptable for this end-to-end test suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs:
- Around line 103-112: The comment for the IdentityPublicKey constructor is
misleading — the third-last argument `publicKeyData` must be a raw byte array
(Uint8Array/Buffer) not a hex string; update the comment to say "binary_data as
Uint8Array (33 bytes for ECDSA_SECP256K1, 20 bytes for ECDSA_HASH160)" and
ensure any upstream value passed into sdkModule.IdentityPublicKey (symbol:
IdentityPublicKey, variable: publicKeyData) is a Uint8Array (or convert hex to
bytes before calling) so invalid keys aren't created.
🧹 Nitpick comments (12)
packages/strategy-tests/src/transitions.rs (2)
467-493: Good: use MASTER key id and bump revision before buildingIdentityUpdateTransition.This aligns with how
try_from_identity_with_signersigns/validates updates (master key) and avoids a staleidentity.revision()being embedded in the transition.
Optional hardening: ensure the selected master key is enabled (and, if desired, AUTHENTICATION) to avoid future fixture edge cases.Proposed (optional) hardening
- let master_key_id = *identity - .public_keys() - .iter() - .find(|(_, key)| key.security_level() == MASTER) - .expect("expected to have a master key") - .0; + let master_key_id = *identity + .public_keys() + .iter() + .find(|(_, key)| { + key.security_level() == MASTER + && key.purpose() == AUTHENTICATION + && key.disabled_at().is_none() + }) + .expect("expected to have an enabled master authentication key") + .0;
578-605: Good: same master-key signing + pre-bump revision in disable-keys path.Same rationale as add-keys: ensures the transition is signed with the correct key and embeds the intended revision.
Optional: tighten master key selection to an enabled AUTHENTICATION master key for fixture robustness.Proposed (optional) hardening
- let master_key_id = *identity - .public_keys() - .iter() - .find(|(_, key)| key.security_level() == MASTER) - .expect("expected to have a master key") - .0; + let master_key_id = *identity + .public_keys() + .iter() + .find(|(_, key)| { + key.security_level() == MASTER + && key.purpose() == AUTHENTICATION + && key.disabled_at().is_none() + }) + .expect("expected to have an enabled master authentication key") + .0;packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (3)
31-40:getTestIdentityKeyslikely calls the wrong surface (sdk.generateTestIdentityKeys).The rest of this repo/test suite appears to call the static
sdkModule.WasmSdk.generateTestIdentityKeys(...)shape; here you callsdk.generateTestIdentityKeys(...). Ifsdkis the module import (* as sdk), this will likely beundefined.Proposed fix
export function getTestIdentityKeys(sdk, seed) { - return sdk.generateTestIdentityKeys(BigInt(seed)); + return sdk.WasmSdk.generateTestIdentityKeys(BigInt(seed)); }
53-115: Avoid “silent fallback” defaults in enum mapping; fail fast when keyInfo contains unexpected values.
keyTypeMap[...] ?? 0andpurposeMap[...] ?? 0can silently build the wrongIdentityPublicKey, andsecurityLevelMap[...] ?? keyIndexis especially risky (fallback can become an unrelated numeric). Consider throwing when a string isn’t recognized.Proposed fix
const keyType = keyTypeMap[keyTypeStr] ?? 0; + if (!(keyTypeStr in keyTypeMap)) { + throw new Error(`Unknown keyType from wasm: ${keyTypeStr}`); + } const purpose = purposeMap[purposeStr] ?? 0; + if (!(purposeStr in purposeMap)) { + throw new Error(`Unknown purpose from wasm: ${purposeStr}`); + } - const securityLevel = securityLevelMap[securityLevelStr] ?? keyIndex; + if (!(securityLevelStr in securityLevelMap)) { + throw new Error(`Unknown securityLevel from wasm: ${securityLevelStr}`); + } + const securityLevel = securityLevelMap[securityLevelStr];
65-68: Hardcoded'testnet'network inPrivateKey.fromHexcan make functional tests non-portable.If local environments/devnets differ, this becomes an easy footgun. Consider threading network from env/config (or from the client/builder if exposed).
packages/wasm-sdk/tests/functional/transitions/contracts.spec.mjs (2)
95-101: Replace fixed sleeps with a “wait until processed” mechanism to reduce flakes.The two
setTimeout(..., 2000)calls will be brittle under load/CI. If there’s a platform “wait for ST result / wait for height / retry until version matches” helper, prefer that.Also applies to: 149-151
87-156: Cross-test dependency is OK, but consider moving publish into abeforehook for clearer failure semantics.Right now
contractUpdatedepends on a priorit()to run first; abefore/beforeEachsetup often produces clearer output (and avoids surprises if the runner ever changes ordering/parallelism settings).packages/wasm-sdk/tests/functional/tokens.spec.mjs (1)
27-32: Strengthen the assertion to validate the object structure.
expect(total).to.exist()only checks that the value is truthy but doesn't verify the return type or shape. SincegetTokenTotalSupplyreturns a structured object with atotalSupplyproperty (not a primitive), consider asserting the structure:expect(total).to.be.an('object').with.property('totalSupply');This prevents regressions where the API might return a different structure or null unexpectedly.
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (1)
139-157: Minor comment inconsistency.The comment on line 141 mentions "Identity 2 is already frozen on TOKEN_0 in genesis state", but the test actually unfreezes Identity 3 (line 150), which was frozen by the previous test. The comment is slightly misleading as it describes a genesis condition that isn't directly relevant to this test's action.
Consider updating the comment to reflect the actual test behavior:
- it('unfreezes an identity token balance', async () => { - // Identity 2 is already frozen on TOKEN_0 in genesis state - // Contract owner (Identity 1) can unfreeze + it('unfreezes an identity token balance', async () => { + // Identity 3 was frozen by the previous test + // Contract owner (Identity 1) can unfreezepackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (2)
173-175: Consider extracting the wait pattern to a helper.The 2-second hardcoded wait for indexing appears multiple times (lines 174 and 268). While acceptable for functional tests, consider extracting this to a named helper for clarity and easier adjustment:
♻️ Optional refactor
// In fixtures or test helpers export const waitForIndexing = (ms = 2000) => new Promise((resolve) => { setTimeout(resolve, ms); }); // Usage in tests await waitForIndexing();
193-195: Consider stronger success assertions if possible.The pattern
expect(true).to.be.true()serves as a "no error thrown" assertion. If the SDK methods return any data (e.g., a document ID or confirmation object), asserting on that return value would provide stronger validation. Otherwise, this pattern is acceptable for void operations.packages/wasm-sdk/tests/functional/epochs-blocks.spec.mjs (1)
20-24: Consider documenting or removing the 100ms delay.The 100ms delay before freeing the client is unusual. If it's addressing a specific race condition or cleanup issue, consider adding a more descriptive comment. If it's precautionary, it may not be necessary since
client.free()should handle cleanup synchronously.after(async () => { - // Wait briefly to ensure any pending async operations complete - await new Promise((resolve) => { setTimeout(resolve, 100); }); + // Delay before cleanup to allow any in-flight gRPC responses to settle + // (prevents occasional WASM memory access errors during shutdown) + await new Promise((resolve) => { setTimeout(resolve, 100); }); if (client) { client.free(); } });
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
packages/js-evo-sdk/tests/unit/facades/addresses.spec.mjspackages/js-evo-sdk/tests/unit/facades/documents.spec.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/js-evo-sdk/tests/unit/facades/voting.spec.mjspackages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/strategy-tests/src/transitions.rspackages/wasm-dpp2/src/identity/signer.rspackages/wasm-dpp2/src/platform_address/signer.rspackages/wasm-sdk/tests/functional/contracts.spec.mjspackages/wasm-sdk/tests/functional/epochs-blocks.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/identities.spec.mjspackages/wasm-sdk/tests/functional/protocol.spec.mjspackages/wasm-sdk/tests/functional/tokens.spec.mjspackages/wasm-sdk/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/transitions/identity.spec.mjspackages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjspackages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
✅ Files skipped from review due to trivial changes (1)
- packages/js-evo-sdk/tests/unit/facades/addresses.spec.mjs
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/wasm-sdk/tests/functional/identities.spec.mjs
- packages/wasm-sdk/tests/functional/transitions/identity.spec.mjs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Rust code must passcargo clippy --workspacelinter checks
Rust code must be formatted usingcargo fmt --all
**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants
Files:
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/strategy-tests/src/transitions.rspackages/wasm-dpp2/src/platform_address/signer.rspackages/wasm-dpp2/src/identity/signer.rs
🧠 Learnings (40)
📓 Common learnings
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations
Learnt from: 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.
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.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use state transitions for updates in documents and data contracts
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-10-09T00:22:57.778Z
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.
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.
📚 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/wasm-sdk/tests/functional/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/epochs-blocks.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/tokens.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/protocol.spec.mjspackages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
📚 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/contracts.spec.mjspackages/strategy-tests/src/transitions.rspackages/wasm-sdk/tests/functional/epochs-blocks.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/tokens.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/voting.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/wasm-dpp2/src/identity/signer.rs
📚 Learning: 2025-12-29T10:53:03.792Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2868
File: packages/wasm-sdk/tests/functional/addresses.spec.mjs:75-95
Timestamp: 2025-12-29T10:53:03.792Z
Learning: In this repository, tests use the dirty-chai plugin for Chai. Write assertions using the function-call style (e.g., expect(...).to.be.ok()) instead of the property-based style. Ensure dirty-chai is loaded in the test setup and documented so new tests conform to this pattern.
Applied to files:
packages/wasm-sdk/tests/functional/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/epochs-blocks.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/tokens.spec.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/voting.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/js-evo-sdk/tests/unit/facades/documents.spec.mjspackages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjspackages/wasm-sdk/tests/functional/protocol.spec.mjspackages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
📚 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/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
📚 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/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
📚 Learning: 2025-07-31T18:15:51.813Z
Learnt from: thephez
Repo: dashpay/platform PR: 2715
File: packages/wasm-sdk/test/ui-automation/run-ui-tests.sh:6-286
Timestamp: 2025-07-31T18:15:51.813Z
Learning: In packages/wasm-sdk/test/ui-automation/run-ui-tests.sh, the script doesn't require cleanup handling because it relies on Playwright's built-in webServer configuration to manage the HTTP server lifecycle automatically. The script only runs foreground processes through npm/Playwright commands.
Applied to files:
packages/wasm-sdk/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/protocol.spec.mjs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use state transitions for updates in documents and data contracts
Applied to files:
packages/wasm-sdk/tests/functional/transitions/contracts.spec.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-09T00:22:57.778Z
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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/strategy-tests/src/transitions.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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rs
📚 Learning: 2024-10-09T00:22:57.778Z
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-10-09T00:22:57.778Z
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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/strategy-tests/src/transitions.rspackages/wasm-dpp2/src/identity/signer.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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/wasm-sdk/tests/functional/transitions/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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/strategy-tests/src/transitions.rspackages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjs
📚 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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjs
📚 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/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/wasm-dpp2/src/identity/signer.rs
📚 Learning: 2024-10-04T09:08:47.901Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2206
File: packages/rs-drive-abci/tests/strategy_tests/main.rs:1162-1162
Timestamp: 2024-10-04T09:08:47.901Z
Learning: In the Rust test file `packages/rs-drive-abci/tests/strategy_tests/main.rs`, specific protocol versions like `PROTOCOL_VERSION_1` are intentionally used in tests instead of `PROTOCOL_VERSION_LATEST`.
Applied to files:
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rspackages/wasm-sdk/tests/functional/protocol.spec.mjs
📚 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/strategy-tests/src/transitions.rs
📚 Learning: 2025-09-03T19:33:21.688Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/api-definitions.json:1285-1285
Timestamp: 2025-09-03T19:33:21.688Z
Learning: In packages/wasm-sdk/api-definitions.json, thephez prefers to keep the existing "ripemd160hash20bytes1234" placeholder for ECDSA_HASH160 data field in documentation examples rather than using a valid base64-encoded format, maintaining consistency with the previous documentation approach.
Applied to files:
packages/wasm-sdk/tests/functional/epochs-blocks.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/protocol.spec.mjspackages/wasm-dpp2/src/identity/signer.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/tests/functional/transitions/documents.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/functional/transitions/documents.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/tests/functional/transitions/documents.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/js-evo-sdk/tests/unit/facades/documents.spec.mjspackages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjspackages/wasm-dpp2/src/identity/signer.rs
📚 Learning: 2025-01-19T07:36:32.294Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2431
File: packages/rs-drive/src/drive/tokens/system/fetch_token_total_supply/v0/mod.rs:31-71
Timestamp: 2025-01-19T07:36:32.294Z
Learning: Token ID zero validation is not required in the fetch_token_total_supply_v0 method, as confirmed by the maintainer.
Applied to files:
packages/wasm-sdk/tests/functional/tokens.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/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjspackages/wasm-sdk/tests/functional/protocol.spec.mjs
📚 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/fixtures/requiredTestData.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/documents.spec.mjspackages/wasm-sdk/tests/functional/transitions/key-generation.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/fixtures/requiredTestData.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjspackages/wasm-dpp2/src/identity/signer.rs
📚 Learning: 2025-07-10T00:37:09.586Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2690
File: packages/wasm-sdk/src/queries/document.rs:383-384
Timestamp: 2025-07-10T00:37:09.586Z
Learning: In the Dash platform, DPNS (Dash Platform Name Service) contracts have the same ID across all networks (mainnet, testnet, etc.), so hardcoding the DPNS contract ID is appropriate and doesn't need to be configurable.
Applied to files:
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.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/tests/functional/fixtures/requiredTestData.mjs
📚 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/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/voting.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/js-evo-sdk/tests/unit/facades/documents.spec.mjs
📚 Learning: 2024-10-18T15:37:21.329Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2249
File: packages/dashmate/test/unit/status/scopes/platform.spec.js:466-467
Timestamp: 2024-10-18T15:37:21.329Z
Learning: In test files for the dashmate project, such as `packages/dashmate/test/unit/status/scopes/platform.spec.js`, prefer to keep mocks explicitly in tests rather than consolidating them, to increase readability.
Applied to files:
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/voting.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/js-evo-sdk/tests/unit/facades/documents.spec.mjs
📚 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/tests/unit/facades/tokens.spec.mjs
📚 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/tests/functional/transitions/key-generation.spec.mjs
📚 Learning: 2025-03-13T07:24:37.295Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2449
File: packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs:107-150
Timestamp: 2025-03-13T07:24:37.295Z
Learning: In the RS SDK test data generation code, logging private keys is intentional and only enabled when a developer explicitly chooses to enable it, which is acceptable in test code contexts.
Applied to files:
packages/wasm-sdk/tests/functional/transitions/key-generation.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/functional/transitions/key-generation.spec.mjs
📚 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-dpp2/src/platform_address/signer.rspackages/wasm-dpp2/src/identity/signer.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Applied to files:
packages/wasm-dpp2/src/platform_address/signer.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations
Applied to files:
packages/wasm-dpp2/src/platform_address/signer.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2206
File: packages/rs-drive-abci/tests/strategy_tests/main.rs:89-89
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In tests located in the `packages/rs-drive-abci/tests` directory, the team prefers to use specific protocol versions (e.g., `PROTOCOL_VERSION_1`) instead of `PROTOCOL_VERSION_LATEST`.
Applied to files:
packages/wasm-sdk/tests/functional/protocol.spec.mjs
📚 Learning: 2025-10-23T13:04:39.160Z
Learnt from: thephez
Repo: dashpay/platform PR: 2816
File: packages/js-dapi-client/lib/networkConfigs.js:17-40
Timestamp: 2025-10-23T13:04:39.160Z
Learning: For the testnet DAPI address whitelist in packages/js-dapi-client/lib/networkConfigs.js, nodes may be intentionally excluded even if they are ENABLED if they are running pre-2.1 versions. Version compatibility is an important filtering criterion beyond just enabled status.
Applied to files:
packages/wasm-sdk/tests/functional/protocol.spec.mjs
🧬 Code graph analysis (12)
packages/strategy-tests/src/transitions.rs (1)
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rs (2)
identity(89-92)try_from_identity_with_signer(44-114)
packages/wasm-sdk/tests/functional/tokens.spec.mjs (2)
packages/wasm-sdk/tests/functional/identities.spec.mjs (2)
tokenId(213-213)TOKEN_CONTRACT(212-212)packages/wasm-sdk/tests/functional/token-pricing.spec.mjs (1)
tokenId(23-23)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (6)
packages/wasm-sdk/tests/functional/transitions/contracts.spec.mjs (2)
createTestSignerAndKey(39-39)createTestSignerAndKey(93-93)packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (5)
createTestSignerAndKey(46-46)createTestSignerAndKey(79-79)createTestSignerAndKey(152-152)createTestSignerAndKey(203-203)createTestSignerAndKey(246-246)packages/wasm-sdk/tests/functional/transitions/identity.spec.mjs (1)
createTestSignerAndKey(54-54)packages/wasm-sdk/tests/functional/identities.spec.mjs (1)
keys(144-147)packages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjs (1)
keys(26-26)packages/wasm-sdk/src/queries/identity.rs (2)
keys(107-113)purpose(66-68)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (1)
packages/js-evo-sdk/src/sdk.ts (1)
EvoSDK(38-177)
packages/js-evo-sdk/tests/unit/facades/voting.spec.mjs (2)
packages/js-evo-sdk/src/sdk.ts (1)
EvoSDK(38-177)packages/js-evo-sdk/src/documents/facade.ts (1)
query(12-15)
packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs (1)
packages/js-evo-sdk/src/sdk.ts (1)
EvoSDK(38-177)
packages/js-evo-sdk/tests/unit/facades/documents.spec.mjs (2)
packages/js-evo-sdk/src/sdk.ts (1)
EvoSDK(38-177)packages/js-evo-sdk/src/documents/facade.ts (1)
query(12-15)
packages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjs (1)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (4)
createTestSignerAndKey(53-115)signer(66-66)identityKey(103-112)keyInfo(55-55)
packages/wasm-dpp2/src/platform_address/signer.rs (13)
packages/wasm-dpp2/src/identity/signer.rs (1)
type_name(49-51)packages/wasm-dpp2/src/data_contract/model.rs (1)
type_name(89-91)packages/wasm-dpp2/src/asset_lock_proof/proof.rs (1)
type_name(64-66)packages/wasm-dpp2/src/core_script.rs (1)
type_name(31-33)packages/wasm-dpp2/src/identity/model.rs (1)
type_name(36-38)packages/wasm-dpp2/src/voting/resource_vote_choice.rs (1)
type_name(27-29)packages/wasm-dpp2/src/voting/vote_poll.rs (1)
type_name(31-33)packages/wasm-dpp2/src/private_key.rs (1)
type_name(40-42)packages/wasm-dpp2/src/identity/public_key.rs (1)
type_name(50-52)packages/wasm-dpp2/src/data_contract/document/model.rs (1)
type_name(93-95)packages/wasm-dpp2/src/identity/transitions/credit_withdrawal_transition.rs (1)
type_name(34-36)packages/wasm-dpp2/src/platform_address/address.rs (1)
type_name(183-185)packages/wasm-dpp2/src/state_transitions/base/state_transition.rs (1)
type_name(71-73)
packages/wasm-sdk/tests/functional/protocol.spec.mjs (2)
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (2)
builder(35-35)client(29-29)packages/wasm-sdk/tests/functional/status.spec.mjs (3)
builder(7-7)client(6-6)status(21-21)
packages/wasm-dpp2/src/identity/signer.rs (3)
packages/rs-dpp/src/address_funds/platform_address.rs (1)
hash(239-244)packages/wasm-dpp2/src/identity/public_key.rs (3)
type_name(50-52)struct_name(55-57)public_key_hash(242-250)packages/wasm-sdk/src/queries/identity.rs (1)
key_type(56-58)
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (1)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (2)
wasmFunctionalTestRequirements(8-29)createTestSignerAndKey(53-115)
🪛 Gitleaks (8.30.0)
packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs
[high] 12-12: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs
[high] 15-15: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
⏰ 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). (20)
- GitHub Check: Rust packages (wasm-dpp2) / Linting
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
- GitHub Check: Rust packages (drive) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (dpp) / Check each feature
- GitHub Check: Rust packages (dpp) / Linting
- GitHub Check: Rust packages (dpp) / Unused dependencies
- GitHub Check: Rust packages (dpp) / Tests
- GitHub Check: Rust packages (drive-abci) / Linting
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (drive-abci) / Unused dependencies
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (wasm-dpp) / Tests
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
) / Build Drive image - GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Rust crates security audit
🔇 Additional comments (33)
packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rs (2)
117-161: LGTM!The accessor implementations are straightforward getters and setters that correctly delegate to the struct fields.
64-64: Callers are properly handling the revised responsibility for revision management.The transition now accepts the identity's current revision instead of auto-incrementing. Callers have been updated to handle this: they either bump the identity revision before construction (strategy tests, WASM SDK) or set the transition revision after construction (identity factory). No action needed.
packages/wasm-dpp2/src/platform_address/signer.rs (3)
3-3: LGTM: Macro import is correctly placed.The import is necessary for the macro invocation on line 156 and follows standard Rust conventions.
59-63: LGTM: Type identification follows established pattern.The
type_namemethod implementation is consistent with the pattern used across the codebase (Identity, Document, IdentitySigner, etc.). This provides runtime type identification for WASM objects.
156-156: Macro-based refactoring is complete and properly implemented.The macro invocation at line 156 generates the expected methods:
try_from_options(options)— extracts using default "signer" fieldtry_from_options_with_field(options, field_name)— extracts using custom field namesAll call sites across the codebase (addresses.rs, identity.rs, token.rs, document.rs) have been updated to use the generated methods. The default "signer" field is applied consistently; custom field names like "addressSigner" and "identitySigner" properly use
try_from_options_with_field(). The refactoring pattern is replicated correctly for other types (DataContractWasm, IdentityWasm, etc.).packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (1)
12-27: Make sure the newly referenced seeded identities/token-positions are actually present in genesis test data.If the local platform seed step (
SDK_TEST_DATA=true) doesn’t create identities for 0x02/0x03 and multiple token contract positions, these additions will fail downstream tests in non-obvious ways.packages/wasm-sdk/tests/functional/transitions/key-generation.spec.mjs (2)
1-3: Confirmexpectis available in this test runtime (not imported here).If
expectis only conditionally global, this file will fail in isolation. If it’s guaranteed by the test harness, ignore this.
25-75: No changes needed. The test assertions are correct.publicKeyDatais a hex-encoded string (not a byte array), soto.equal()andto.not.equal()comparisons work as intended for value-based string equality.Likely an incorrect or invalid review comment.
packages/wasm-sdk/tests/functional/contracts.spec.mjs (1)
57-67: LGTM for the refactor to option-object input; skip rationale is clear.Asserting
Mapis also a more concrete check than generic truthiness (and aligns with how other query methods return maps).packages/wasm-sdk/tests/functional/transitions/contracts.spec.mjs (2)
111-132: ConfirmexistingContract.getSchemas()returns a plain object (not a Map).Spreading a
Mapinto an object won’t do what you want. If this is aMap, useObject.fromEntries(existingSchemas)(or the SDK’s own schema mutation helpers, if available).
59-70: The placeholder nonce approach is correct—no action needed.The SDK explicitly fetches the actual identity nonce inside
contractPublish(viaput_to_platform) before creating the state transition, so the initial0nplaceholder is safely overwritten. The contract ID and signable bytes are computed using the fetched nonce, not the placeholder value in the DataContract object.packages/wasm-sdk/tests/functional/transitions/tokens.spec.mjs (2)
1-42: LGTM! Well-structured test setup.The test setup correctly initializes the WASM SDK, prefetches trusted quorums, and builds a local client. The teardown properly frees the client. The documentation comments clearly explain the test identity setup and authorization model.
Regarding the Gitleaks static analysis hint on line 15: This is a false positive. The value
CktRuQ2mttgRGkXJtyksdKHjUdc2C4TgDzyB98oEzy8is a base58-encoded test identifier seeded for functional testing, not an API key.
159-212: LGTM! Comprehensive emergency action and pricing tests.The emergency action tests correctly exercise both pause and resume flows, and the tokenSetPrice test validates the pricing functionality. The sequential pause-then-resume pattern is appropriate for end-to-end testing.
packages/wasm-sdk/tests/functional/protocol.spec.mjs (2)
7-18: LGTM! Good refactor to runtime-derived proTxHash.Fetching the proTxHash dynamically from node status is a better approach than relying on fixture data. This makes the tests more resilient and self-contained.
37-52: LGTM! Graceful fallback for vote status queries.Using
evonodeProTxHash || ''provides a sensible fallback that allows tests to run even when the proTxHash is unavailable. The empty string starts pagination from the beginning, maintaining test coverage.packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (1)
1-42: LGTM! Well-documented test setup with proper lifecycle management.The test setup correctly initializes the SDK and maintains shared state across tests. The documentation clearly explains the test identity setup and the need for a custom contract with mutable document types.
packages/js-evo-sdk/tests/unit/facades/voting.spec.mjs (2)
21-56: LGTM! Comprehensive mock setup for voting operations.The mock setup covers all query methods (with and without proof) and the transition method. The use of
Object.create(wasmSDKPackage.IdentitySigner.prototype)is a valid approach for creating mock objects that passinstanceofchecks.
149-197: LGTM! Good coverage of vote choice variations.The tests verify that the masternodeVote method correctly forwards the options object to the underlying wasm SDK, including the signer. Testing all three vote choices (yes, abstain, lock) ensures comprehensive coverage of the voting functionality.
packages/wasm-sdk/tests/functional/epochs-blocks.spec.mjs (1)
77-89: LGTM! Robust fallback for proTxHash extraction.The logic correctly handles the case where evonodeProTxHash is not available from status by extracting a proTxHash from the range query results. The byte-to-hex conversion is correctly implemented.
packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs (2)
10-14: LGTM! Test identifiers are appropriate.Regarding the Gitleaks static analysis hint on line 12: This is a false positive. The value
BpJvvpPiR2obh7ueZixjtYXsmWQdgJhPpzYbXvAJ4PYH7Ackis a base58-encoded test token identifier used for unit testing, not an API key.
278-440: LGTM! Comprehensive transition method test coverage.The tests thoroughly verify all token transition operations (mint, burn, transfer, freeze, unfreeze, destroyFrozen, emergencyAction, setPrice, directPurchase, claim). Each test validates that:
- The options object is forwarded exactly to the wasm SDK
- The result contains the expected properties
This ensures the facade correctly delegates to the underlying wasm SDK without modifying the inputs.
packages/js-evo-sdk/tests/unit/facades/documents.spec.mjs (2)
17-43: LGTM! Clean mock setup for document operations.The mock setup appropriately covers all document query and transition methods. Using
Object.create(wasmSDKPackage.Document.prototype)and similar for mocks is a valid pattern that maintains prototype chain compatibility.
132-147: LGTM! Good test for flexible document deletion API.This test validates an important use case where
delete()accepts document identifiers as a plain object instead of a fullDocumentinstance. This flexibility improves the API ergonomics when the caller only has document metadata.packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (4)
19-24: LGTM – Mock object pattern is appropriate for these unit tests.Using
Object.create(prototype)creates objects with the correct type metadata that can be passed through the facade without requiring full implementations. This is suitable since the tests verify call signatures rather than behavior.
26-96: Well-structured stub setup with appropriate return types.The stubs correctly differentiate between proof and non-proof method variants, returning the expected
{ data, proof, metadata }structure for*WithProofInfomethods. The use ofBigIntfor nonce and balance values aligns with the WASM SDK's numeric handling.
109-264: Query method tests provide good coverage of the facade layer.Tests correctly verify that facade methods forward to the underlying WASM SDK methods with the expected arguments. The option-object pattern (
queryobjects forgetKeys,contractKeys) aligns with the PR's refactor to typed parameter objects.
266-336: Transition method tests verify the new typed parameter API effectively.The tests confirm that each state transition method receives its options object intact and returns the expected result structure. The distinction between operations requiring a
signer(create, creditTransfer, creditWithdrawal, update) versus those that don't (topUp) is correctly reflected in the test data.packages/wasm-dpp2/src/identity/signer.rs (6)
33-44: Good security practice in Debug impl and correct hash160 implementation.The Debug implementation appropriately shows only
key_countrather than exposing private key material. Thehash160helper correctly delegates to dashcore's implementation of RIPEMD160(SHA256(data)).
72-85: Key storage logic correctly derives the public key hash.The
add_keymethod properly derives the public key hash viaPlatformAddress::from(), which computes hash160 of the compressed public key. This ensures the stored hash will match whatget_key_hashcomputes forECDSA_SECP256K1keys.
103-138: Well-designed key hash derivation with proper validation.The
get_key_hashmethod correctly handles the two supported key types:
ECDSA_HASH160: The 20-byte key data is already the hashECDSA_SECP256K1: Computes hash160 of the 33-byte compressed public keyThe explicit size validations with descriptive error messages will aid debugging when invalid keys are encountered.
159-175: Correct witness type for both ECDSA key types.Both
ECDSA_HASH160andECDSA_SECP256K1use secp256k1 ECDSA signatures, so producingAddressWitness::P2pkhfor both is correct. The signature format is identical; only the key storage format differs (raw hash vs. compressed public key).
177-181: Defensive implementation correctly returns false for unsupported keys.Using
unwrap_or(false)ensures that keys with unsupported types or invalid data sizes are reported as non-signable rather than causing a panic. This is the expected behavior for a capability-query method.
191-201: Macro-based option extraction aligns with the PR's API refactor pattern.The
impl_try_from_options!invocation enables extractingIdentitySignerWasmfrom a"signer"field in JS option objects, consistent with the typed parameter pattern used across other state transition methods in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (2)
38-40: Make helper input expectations explicit (sdk instance vs sdk module).
getTestIdentityKeys(sdk, seed)callssdk.generateTestIdentityKeys(...), whilecreateTestSignerAndKey()callssdkModule.WasmSdk.generateTestIdentityKeys(...). Consider aligning these (or renaming params) to avoid accidental misuse.
53-115: Consider adding a bounds check if keyIndex will be user-supplied; current design is sound.The function works correctly as-is:
generateTestIdentityKeys()always returns exactly 4 keys (verified in tests), and all current callers pass valid indices (0–3). The serde_wasm_bindgen Map structure is part of the tested API contract, not fragile. The manual enum maps are necessary since no KeyType/Purpose/SecurityLevel constants are exported from wasm-sdk; the mappings are correct.If this fixture will accept arbitrary user-supplied keyIndex values in the future, adding a guard before line 56 would help:
const keys = sdkModule.WasmSdk.generateTestIdentityKeys(BigInt(seed)); const keyInfo = keys[keyIndex]; + if (!keyInfo) { + throw new RangeError(`keyIndex ${keyIndex} out of range [0, ${keys.length - 1}]`); + }The hardcoded
'testnet'network is a reasonable default for test fixtures.packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (2)
76-145: Avoid cross-describe()ordering assumptions; consider a sharedbefore()for contract publish.
These suites sharetestContractIdand assume earlier tests ran; that breaks if mocha parallelization is enabled (or if someone runs a singledescribe). Consider moving contract creation into abefore()(or nesting dependent describes) so each block is independently runnable.
147-282: Replace fixed sleeps with polling to reduce CI flakiness (indexing wait).
ThesetTimeout(2000)waits are a common flake source; pollinggetDocuments/queryuntil visible (with a timeout) tends to be much more stable.Example polling helper (pattern only)
+async function waitForCondition(fn, { timeoutMs = 20000, intervalMs = 500 } = {}) { + const start = Date.now(); + // eslint-disable-next-line no-constant-condition + while (true) { + if (await fn()) return; + if (Date.now() - start > timeoutMs) throw new Error('Timed out waiting for condition'); + await new Promise((r) => setTimeout(r, intervalMs)); + } +}
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/wasm-sdk/tests/functional/contracts.spec.mjspackages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/wasm-sdk/tests/functional/contracts.spec.mjs
🧰 Additional context used
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
📚 Learning: 2025-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/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/transitions/documents.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/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs
📚 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/tests/functional/fixtures/requiredTestData.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/functional/fixtures/requiredTestData.mjs
📚 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/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 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/fixtures/requiredTestData.mjs
📚 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/wasm-sdk/tests/functional/fixtures/requiredTestData.mjspackages/wasm-sdk/tests/functional/transitions/documents.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/functional/fixtures/requiredTestData.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/tests/functional/fixtures/requiredTestData.mjs
📚 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/tests/functional/fixtures/requiredTestData.mjs
📚 Learning: 2025-07-10T00:37:09.586Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2690
File: packages/wasm-sdk/src/queries/document.rs:383-384
Timestamp: 2025-07-10T00:37:09.586Z
Learning: In the Dash platform, DPNS (Dash Platform Name Service) contracts have the same ID across all networks (mainnet, testnet, etc.), so hardcoding the DPNS contract ID is appropriate and doesn't need to be configurable.
Applied to files:
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.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/tests/functional/fixtures/requiredTestData.mjs
📚 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/tests/functional/transitions/documents.spec.mjs
📚 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/tests/functional/transitions/documents.spec.mjs
📚 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/tests/functional/transitions/documents.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/functional/transitions/documents.spec.mjs
📚 Learning: 2025-07-31T18:15:51.813Z
Learnt from: thephez
Repo: dashpay/platform PR: 2715
File: packages/wasm-sdk/test/ui-automation/run-ui-tests.sh:6-286
Timestamp: 2025-07-31T18:15:51.813Z
Learning: In packages/wasm-sdk/test/ui-automation/run-ui-tests.sh, the script doesn't require cleanup handling because it relies on Playwright's built-in webServer configuration to manage the HTTP server lifecycle automatically. The script only runs foreground processes through npm/Playwright commands.
Applied to files:
packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use state transitions for updates in documents and data contracts
Applied to files:
packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
📚 Learning: 2025-12-29T10:53:03.792Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2868
File: packages/wasm-sdk/tests/functional/addresses.spec.mjs:75-95
Timestamp: 2025-12-29T10:53:03.792Z
Learning: In this repository, tests use the dirty-chai plugin for Chai. Write assertions using the function-call style (e.g., expect(...).to.be.ok()) instead of the property-based style. Ensure dirty-chai is loaded in the test setup and documented so new tests conform to this pattern.
Applied to files:
packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs
🧬 Code graph analysis (1)
packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (1)
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (2)
wasmFunctionalTestRequirements(8-29)createTestSignerAndKey(53-115)
🔇 Additional comments (4)
packages/wasm-sdk/tests/functional/transitions/documents.spec.mjs (3)
32-42: Setup/teardown looks solid for wasm resources.
prefetchTrustedQuorumsLocal()+localTrusted()+client.free()are the right shape for functional tests.
43-74: Both concerns in this review comment are inconsistent with established patterns in the codebase and should not require changes:
document.idproperty access is the consistent pattern used throughout all document creation tests in this same file (lines 71, 170, 218, 258), confirming it's properly exposed as a JS property immediately after creation.
saltedDomainHashusing a padded timestamp aligns with the codebase convention of accepting placeholder values in tests rather than actual derived values, similar to how documentation examples use simplified test data.The test implementation is correct as written.
Likely an incorrect or invalid review comment.
1-3: No changes needed—test harness properly globalizes expect.The test file correctly omits importing
expectbecausepackages/wasm-sdk/tests/bootstrap.cjsestablishes it globally viag.expect = expect;. This bootstrap is required by both the.mocharc.ymlandfunctional-bootstrap.cjs, ensuringexpectis available in all functional tests. The dirty-chai plugin is also configured, making assertion syntax likeexpect(...).to.exist()valid.Likely an incorrect or invalid review comment.
packages/wasm-sdk/tests/functional/fixtures/requiredTestData.mjs (1)
8-28: The fixture changes are safe—removed fields are not referenced from tests.Verification confirms:
evonodeProTxHashandsampleEpochare not accessed from the test data fixture. TheevonodeProTxHashreferences found in test files are local variables, not fixture accesses.tokenContractsstructure with positions is correctly used: tests accesstokenContracts[0],tokenContracts[1], andtokenContracts[2]with their.positionand.contractIdfields, matching the fixture definition.- Adding
identityId2/3supports the expanded test usage (e.g.,identityId3is referenced in token transfer tests).No further action needed.
Issue being fixed or feature implemented
Currently, state transition methods accept many arguments instead of typed objects, which is a better UX.
What was done?
How Has This Been Tested?
With new functional and unit tests.
Enabled previously skipped tests.
Breaking Changes
Public API of Evo SDK is changed
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
API Updates
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.