-
Notifications
You must be signed in to change notification settings - Fork 45
feat(dpp): add Identity new_with_input_addresses_and_keys() #2971
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
Conversation
📝 WalkthroughWalkthroughAdded an identity constructor that derives IDs from input addresses; extracted identity-ID derivation into a helper; switched two verification flags to true; required explicit address nonces across SDK/FFI; added nonce-fetching helper in WASM SDK and propagated AddressFunds (nonce+balance) through address-sync plumbing. Changes
Sequence Diagram(s)sequenceDiagram
actor WASM as WASM_SDK
participant RPC as Platform_RPC
participant SDK as RS_SDK
participant DPP as RS_DPP
WASM->>RPC: fetch_many(addresses)
RPC-->>WASM: AddressInfo (nonce + balance)
WASM->>WASM: merge nonces into inputs_map -> inputs_with_nonce
WASM->>SDK: put_with_address_funding(inputs_with_nonce, keys, ...)
SDK->>DPP: identity_id_from_input_addresses(inputs_with_nonce)
DPP-->>SDK: Identity (via new_with_input_addresses_and_keys)
SDK-->>WASM: result / broadcast state transition
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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: 0
🧹 Nitpick comments (1)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
49-54: Clarify the documentation phrasing.The phrase "This is a preferred method" is ambiguous—it's unclear whether "this" refers to
put_with_address_funding_with_nonceor toIdentity::new_with_input_addresses_and_keys. Consider rephrasing for clarity.📝 Suggested documentation improvement
/// Creates an identity funded by Platform addresses using explicit nonces. /// /// Use [Identity::new_with_input_addresses_and_keys](dpp::identity::Identity::new_with_input_addresses_and_keys) -/// to create an identity. Then use this method to put it to the platform. +/// to create an identity with the same nonces provided to this method. /// -/// This is a preferred method, as you need to use the same nonces when creating the identity. +/// # Important +/// +/// The `inputs_with_nonce` parameter must contain the same nonces used when +/// constructing the identity via `new_with_input_addresses_and_keys`, as the +/// identity ID is derived from these addresses and nonces.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/rs-sdk/src/platform/transition/put_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/rs-sdk/src/platform/transition/put_identity.rs
🧠 Learnings (6)
📚 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-sdk/src/platform/transition/put_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/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-09-30T12:11:35.148Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2186
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs:48-54
Timestamp: 2024-09-30T12:11:35.148Z
Learning: In the identity credit withdrawal transition code, the field `platform_version.drive_abci.validation_and_processing.state_transitions.identity_credit_withdrawal_state_transition.transform_into_action` is not an `Option` type, so handling `None` cases is unnecessary.
Applied to files:
packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/rs-sdk/src/platform/transition/put_identity.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/rs-sdk/src/platform/transition/put_identity.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-sdk/src/platform/transition/put_identity.rs
🧬 Code graph analysis (1)
packages/rs-sdk/src/platform/transition/put_identity.rs (2)
packages/rs-sdk/src/platform/transition/address_inputs.rs (1)
collect_address_infos_from_proof(44-90)packages/rs-sdk/src/platform/transition/broadcast.rs (2)
broadcast(23-23)broadcast(38-93)
⏰ 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 (dash-sdk) / Unused dependencies
- GitHub Check: Rust packages (dash-sdk) / Formatting
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (dash-sdk) / Linting
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (dpp) / Linting
- GitHub Check: Rust packages (drive) / Formatting
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (wasm-dpp) / Tests
- GitHub Check: Rust packages (drive) / Linting
- GitHub Check: Rust packages (drive) / Unused dependencies
- GitHub Check: Rust packages (drive) / 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 JS packages / Build JS
- GitHub Check: Rust crates security audit
- GitHub Check: Swift SDK and Example build (warnings as errors)
- GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
- GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
🔇 Additional comments (4)
packages/rs-sdk/src/platform/transition/put_identity.rs (4)
3-3: LGTM: Import changes align with API simplification.The import changes correctly reflect the removal of automatic nonce fetching functionality, keeping only the items needed for explicit nonce-based identity creation.
55-63: LGTM: Method signature is well-designed.The explicit nonce-based API is clear and type-safe. The return of both the
IdentityandAddressInfosprovides useful information to callers.
108-127: LGTM: Clean delegation pattern.The implementation correctly delegates to the helper function with all parameters forwarded appropriately.
149-211: LGTM: Robust implementation with proper verification.The helper function correctly:
- Creates the state transition with explicit nonces
- Validates the structure before broadcasting
- Verifies the proved identity ID matches the expected ID
- Collects and validates address information from the proof
The error handling is appropriate for all edge cases.
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 (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)
1047-1059: Suggest more robust merge logic using key lookup instead of zip.The current implementation uses
zipto mergeinputs_mapandfetched_addresses, relying on BTreeMap's sorted iteration order. While both maps should have identical keys (validated at line 1041), usingzipis fragile and requires the defensiveaddress_left != address_rightcheck.Consider a more explicit approach that directly looks up each address:
♻️ Proposed refactor using key lookup
- // merge nonces into inputs map - let inputs = inputs_map - .into_iter() - .zip(fetched_addresses) - .map(|((address_left, amount), (address_right, info))| { - if address_left != address_right { - Err(WasmSdkError::generic( - "Address mismatch when merging nonces for identity creation; platform bug?", - ))? - } - let nonce = info.nonce; - Ok((address_left, (nonce, amount))) - }) - .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?; + // merge nonces into inputs map + let inputs = inputs_map + .into_iter() + .map(|(address, amount)| { + let info = fetched_addresses.get(&address).ok_or_else(|| { + WasmSdkError::generic(format!( + "Address {} not found in fetched addresses; platform bug?", + address + )) + })?; + let nonce = info.nonce; + Ok((address, (nonce, amount))) + }) + .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;packages/rs-sdk/src/platform/transition/put_identity.rs (1)
49-63: Consider clarifying nonce consistency requirement in documentation.The documentation helpfully explains that
new_with_input_addresses_and_keysshould be used to create the identity and that "you need to use the same nonces when creating the identity." Consider adding a note about what happens if the nonces don't match (e.g., transaction failure, identity ID mismatch) to make the requirement more explicit.Example addition:
/// Use [Identity::new_with_input_addresses_and_keys](dpp::identity::Identity::new_with_input_addresses_and_keys) /// to create an identity. Then use this method to put it to the platform. /// /// This is a preferred method, as you need to use the same nonces when creating the identity. /// The identity ID is derived from the input addresses and their nonces, so using different /// nonces will result in an identity ID mismatch and transaction failure.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/rs-sdk/src/platform/transition/put_identity.rspackages/wasm-sdk/src/state_transitions/addresses.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/addresses.rspackages/rs-sdk/src/platform/transition/put_identity.rs
🧠 Learnings (10)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
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/**/{KeychainManager,*Key,*Identity}.swift : Store private keys separately from identities using iOS Keychain for secure storage; private keys belong to public keys, not identities
📚 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/addresses.rs
📚 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/wasm-sdk/src/state_transitions/addresses.rspackages/rs-sdk/src/platform/transition/put_identity.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/addresses.rspackages/rs-sdk/src/platform/transition/put_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/addresses.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: Applies to **/swift-sdk/**/*.{swift,h,m,c} : iOS SDK must combine both Core (SPV wallet) and Platform (identity/documents) functionality in the unified SDK with proper function naming: `dash_core_sdk_*` prefix for Core functions, `dash_sdk_*` prefix for Platform functions, and `dash_unified_sdk_*` prefix for unified functions
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rspackages/rs-sdk/src/platform/transition/put_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/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/rs-sdk/src/platform/transition/put_identity.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-sdk/src/platform/transition/put_identity.rs
🧬 Code graph analysis (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (3)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
inputs(162-162)packages/wasm-sdk/src/error.rs (1)
generic(71-73)packages/wasm-sdk/src/queries/address.rs (1)
nonce(42-44)
packages/rs-sdk/src/platform/transition/put_identity.rs (2)
packages/rs-sdk/src/platform/transition/address_inputs.rs (1)
collect_address_infos_from_proof(44-90)packages/rs-sdk/src/platform/transition/broadcast.rs (2)
broadcast(23-23)broadcast(38-93)
⏰ 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 (drive-abci) / Tests
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (drive) / Tests
- GitHub Check: Rust packages (drive) / Unused dependencies
- GitHub Check: Rust packages (dpp) / Check each feature
- GitHub Check: Rust packages (drive) / Linting
- GitHub Check: Rust packages (dpp) / Unused dependencies
- GitHub Check: Rust packages (wasm-dpp) / Tests
- GitHub Check: Rust packages (dpp) / Linting
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
- 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: 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 (7)
packages/wasm-sdk/src/state_transitions/addresses.rs (4)
5-5: LGTM: Import additions support new nonce-fetching functionality.The new imports (BTreeMap, BTreeSet, FetchMany, Identity, Sdk, Credits, AddressNonce) are necessary for the fetch_nonces_into_address_map helper and updated type signatures.
Also applies to: 18-21
976-977: LGTM: Correct nonce fetching and passing.The function correctly fetches nonces using the new
fetch_nonces_into_address_maphelper (line 977) and passes the nonce-enriched inputs toput_with_address_funding(line 996), aligning with the new API requirement for explicit nonces.Also applies to: 996-996
171-201: No changes needed—the implementation is correct.The
transfer_address_fundsmethod in the SDK already handles nonce fetching internally. At line 55 ofpackages/rs-sdk/src/platform/transition/transfer_address_funds.rs, the implementation callsfetch_inputs_with_nonce(self, &inputs).await?before delegating totransfer_address_funds_with_nonce. The comment at line 193 in the reviewed code correctly documents this behavior ("which handles nonces, building, and broadcasting").The pattern differs from
identity_create_from_addresses(which explicitly callsfetch_nonces_into_address_mapbefore proceeding), but both approaches are valid. Nonces are properly fetched and incremented in either case.
303-341: Nonces are fetched internally by the underlying RS SDK method.The
top_up_from_addressescall delegates nonce fetching to the RS SDK'sIdentity::top_up_from_addressesimplementation, which automatically fetches nonces viafetch_inputs_with_noncebefore creating the transition. This is documented in the RS SDK method's comment: "nonces looked up automatically."However, this differs from the pattern in
address_funds_transferandidentity_create_from_addressesin the same file, which both explicitly callfetch_nonces_into_address_mapat the WASM layer. Consider aligning the pattern here for consistency.packages/rs-sdk/src/platform/transition/put_identity.rs (3)
3-3: LGTM: Removed unused imports.The removal of
fetch_inputs_with_nonceandnonce_incis correct since the method now requires nonces to be provided by the caller rather than fetching them internally.
108-127: LGTM: Clean delegation to helper function.The implementation correctly delegates to the helper function with all parameters passed through.
149-210: LGTM: Correct implementation with proper validation.The function correctly:
- Uses caller-provided nonces (no internal fetching)
- Creates the state transition with
try_from_inputs_with_signer- Validates that the proved identity ID matches the expected identity ID (lines 192-199)
- Collects and returns address infos with proper validation
The identity ID validation is critical for preventing mismatches when the identity is derived from input addresses and nonces.
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: 2
🤖 Fix all issues with AI agents
In @packages/rs-dpp/src/identity/identity.rs:
- Around line 122-146: The doc comment for new_with_input_addresses_and_keys is
inaccurate: the inputs map value is (AddressNonce, Credits), not just
AddressNonce, and Credits are ignored when deriving the identity id; update the
function doc to state that inputs is a BTreeMap<PlatformAddress, (AddressNonce,
Credits)> and explicitly note that only the address and AddressNonce are used by
identity_id_from_input_addresses (Credits are not part of ID derivation). Keep
the existing call to crate::state_transition::identity_id_from_input_addresses
and ensure the docs mention that function as the derivation used.
In @packages/wasm-sdk/src/state_transitions/addresses.rs:
- Around line 1014-1062: The function fetch_nonces_into_address_map should first
validate that inputs_map is non-empty and return
WasmSdkError::invalid_argument(...) when empty; keep using
dash_sdk::query_types::AddressInfo::fetch_many to fetch infos but replace the
zip-based merge with a key-based join: iterate over inputs_map.keys(), look up
each key in fetched_addresses (the BTreeMap from fetch_many), and for any
missing key return WasmSdkError::invalid_argument(...) indicating which input
addresses were not found/are empty; when present, extract info.nonce and
preserve the Credits value to build the resulting BTreeMap<(PlatformAddress,
(AddressNonce, Credits))>; update all validation errors to use
WasmSdkError::invalid_argument instead of WasmSdkError::generic and remove the
address-left/address-right mismatch logic.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/rs-dpp/src/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.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/addresses.rspackages/rs-dpp/src/identity/identity.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
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: 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.
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.
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's `rs-sdk/tests` integration tests (e.g., in `packages/rs-sdk/tests/fetch/config.rs`), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rspackages/rs-dpp/src/identity/identity.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/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.
Applied to files:
packages/rs-dpp/src/identity/identity.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/rs-dpp/src/identity/identity.rs
🧬 Code graph analysis (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (2)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
inputs(162-162)packages/wasm-sdk/src/error.rs (1)
generic(71-73)
packages/rs-dpp/src/identity/identity.rs (1)
packages/rs-dpp/src/state_transition/traits/state_transition_identity_id_from_inputs.rs (1)
identity_id_from_input_addresses(25-44)
⏰ 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 (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-sdk) / Formatting
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (dash-sdk) / Unused dependencies
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (dpp) / Check each feature
- GitHub Check: Rust packages (drive) / Tests
- GitHub Check: Rust packages (dpp) / Linting
- GitHub Check: Rust packages (dpp) / Unused dependencies
- GitHub Check: Rust packages (dpp) / Tests
- GitHub Check: Rust packages (drive) / 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-sim)
- GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
- GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (2)
packages/rs-dpp/src/identity/identity.rs (1)
1-4: Import additions look fine; ensure they’re feature-justified.
No issues here, assumingAddressNonceis only needed for the new constructor path.packages/wasm-sdk/src/state_transitions/addresses.rs (1)
974-1012: Good flow change: nonce-enrich inputs beforeput_with_address_funding.
Fetching nonces here keeps the public JS API simpler and matches the “nonces fetched automatically” docs.
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/src/state_transitions/addresses.rs:
- Line 1040: Fix the typo in the inline comment near the filter_map check in
addresses.rs: change "shouuld" to "should" in the comment that currently reads
"// sanity check - filter_map above shouuld have removed any non-existing
addresses" so the comment reads "... should have removed any non-existing
addresses".
🧹 Nitpick comments (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)
1047-1069: Consider simplifying the merge logic to avoid relying on BTreeMap ordering.The current
zipapproach works because bothBTreeMaps have identical keys in the same order, and the address mismatch check (line 1052) validates this. However, this relies on a subtle ordering assumption that could be fragile during future refactoring.A clearer approach would directly look up each input address in the fetched map:
♻️ Alternative implementation
- // merge nonces into inputs map - let inputs = inputs_map - .into_iter() - .zip(fetched_addresses) - .map( - |((address_requested, amount), (address_received, info_received))| { - if address_requested != address_received { - Err(WasmSdkError::invalid_argument( - format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?", - address_requested, address_received) - ))? - } - if amount > info_received.balance { - Err(WasmSdkError::invalid_argument(format!( - "Input address {} has insufficient balance: requested {}, available {}", - address_requested, amount, info_received.balance - )))? - } - let nonce = info_received.nonce; - Ok((address_requested, (nonce, amount))) - }, - ) - .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?; + // merge nonces into inputs map + let inputs = inputs_map + .into_iter() + .map(|(address, amount)| { + let info = fetched_addresses.get(&address).ok_or_else(|| { + WasmSdkError::invalid_argument(format!( + "Address {} not found when merging nonces; platform bug?", + address + )) + })?; + if amount > info.balance { + return Err(WasmSdkError::invalid_argument(format!( + "Input address {} has insufficient balance: requested {}, available {}", + address, amount, info.balance + ))); + } + Ok((address, (info.nonce, amount))) + }) + .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;This approach is more explicit about the lookup relationship and doesn't depend on iterator ordering alignment.
packages/rs-dpp/src/identity/identity.rs (1)
122-147: Nonce semantics are well-documented; prioritize unit tests over implementation verificationThe implementation correctly delegates to the validated
identity_id_from_input_addresseshelper and existing constructor. The nonce semantics concern is valid but already documented consistently across the codebase—the helper function (line 22 instate_transition_identity_id_from_inputs.rs) and SDK documentation both state that "nonces should represent state after creation of the identity (e.g., be incremented by 1)." This is an intentional design requiring callers to use post-transaction nonce values, and the wasm-sdk shows the proper usage pattern (fetching current nonces and incrementing them before passing to the constructor).Focus on test coverage instead: The constructor lacks direct unit tests. Add tests demonstrating:
- Correct identity ID generation from various input combinations
- Proper error handling for empty inputs
- The nonce increment requirement and its effect on derived identity ID
- Consistency with existing identity creation flow
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/rs-dpp/src/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.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/rs-dpp/src/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.rs
🧠 Learnings (12)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
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: 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.
📚 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/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.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/rs-dpp/src/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.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/rs-dpp/src/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.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/identity/identity.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/rs-dpp/src/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.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/rs-dpp/src/identity/identity.rspackages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rs
📚 Learning: 2024-10-04T14:16:05.798Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-04T14:16:05.798Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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-sdk/src/state_transitions/addresses.rs
🧬 Code graph analysis (1)
packages/rs-dpp/src/identity/identity.rs (1)
packages/rs-dpp/src/state_transition/traits/state_transition_identity_id_from_inputs.rs (1)
identity_id_from_input_addresses(25-44)
⏰ 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 (drive-abci) / Tests
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (dash-sdk) / Linting
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-sdk) / 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 (drive) / Linting
- GitHub Check: Rust packages (drive) / Tests
- GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
) / Build Drive 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 (8)
packages/wasm-sdk/src/state_transitions/addresses.rs (7)
5-5: LGTM! Import additions support the new nonce-fetching functionality.The new imports are all necessary for the
fetch_nonces_into_address_maphelper function.Also applies to: 13-13, 15-15, 20-21
171-201: Inconsistency between AI summary and actual changes.The AI summary states that
address_funds_transferwas updated to usefetch_nonces_into_address_map, but the provided code shows no such changes to this method. It continues to calltransfer_address_fundsdirectly without the new helper.This might indicate:
- The changes were made elsewhere (in the SDK layer)
- The summary is incorrect
- Changes are missing from this file
Please verify whether
address_funds_transfershould also be updated to fetch nonces explicitly, or if the SDK'stransfer_address_fundsmethod handles this internally.
976-977: LGTM! Correct integration of nonce-fetching logic.The changes properly fetch nonces before creating the identity and pass the enriched inputs map (with nonces) to
put_with_address_funding. The type transition fromBTreeMap<PlatformAddress, Credits>toBTreeMap<PlatformAddress, (AddressNonce, Credits)>is handled correctly.Also applies to: 996-996
1014-1022: LGTM! Clear documentation and signature.The helper function is properly scoped as private, has clear documentation, and uses appropriate types.
1023-1038: LGTM! Clean address fetching logic.The code efficiently fetches all input addresses in a single call and properly handles the conversion from
IndexMaptoBTreeMap.
1041-1045: LGTM! Proper validation of fetched addresses.The length check ensures all requested addresses were successfully fetched from the platform.
1070-1071: LGTM! Clean return statement.The function correctly returns the merged map with the expected type.
packages/rs-dpp/src/identity/identity.rs (1)
1-4: LGTM: Clean import additionsThe new imports for
PlatformAddressandAddressNonceare appropriately added to support the new constructor, and movingRevisionto the prelude is a reasonable refactoring.
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/src/state_transitions/addresses.rs:
- Around line 1047-1068: The current use of zip() to pair inputs_map and
fetched_addresses is unsafe because it relies on positional alignment; instead
build an indexed lookup for fetched_addresses (e.g., convert fetched_addresses
into a map keyed by address_received) and then iterate inputs_map.into_iter(),
for each (address_requested, amount) perform an explicit lookup in that fetched
map, return an error if the address is missing, check amount <=
info_received.balance and extract nonce, and collect the results into the same
Result<BTreeMap<_, _>, WasmSdkError>() so order/pairing is guaranteed; update
the closure that previously matched |((address_requested, amount),
(address_received, info_received))| accordingly to use a lookup by
address_requested and preserve the same error messages (including address
mismatch/insufficient balance) and returned tuple shape (address_requested,
(nonce, amount)).
🧹 Nitpick comments (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)
1024-1025: Consider using.copied()ifPlatformAddressimplementsCopy.If
PlatformAddressimplementsCopy, using.copied().collect()is slightly more idiomatic than.cloned().collect().♻️ Potential simplification
- let input_addresses: BTreeSet<PlatformAddress> = - inputs_map.keys().cloned().collect::<BTreeSet<_>>(); + let input_addresses: BTreeSet<PlatformAddress> = + inputs_map.keys().copied().collect::<BTreeSet<_>>();
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rs
🧠 Learnings (13)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
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/src/state_transitions/addresses.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/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.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/addresses.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/addresses.rs
📚 Learning: 2024-10-04T14:16:05.798Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-04T14:16:05.798Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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-sdk/src/state_transitions/addresses.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (2)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
inputs(162-162)packages/wasm-sdk/src/error.rs (2)
generic(71-73)invalid_argument(75-77)
⏰ 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). (14)
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (dpp) / Check each feature
- GitHub Check: Rust packages (dash-sdk) / Linting
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (drive) / Tests
- 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: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
) / Build Drive image - GitHub Check: Build JS packages / Build JS
🔇 Additional comments (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (2)
5-21: LGTM! Imports are appropriate for the new functionality.The added imports support the nonce fetching logic and are all utilized in the new helper function.
976-977: Integration with helper function looks correct.The call to
fetch_nonces_into_address_mapproperly enhances the inputs before passing them to the SDK method.
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/addresses.rs (1)
1009-1031: Consider usingBTreeMap::getfor safer key matching.The current zip-based approach relies on both
BTreeMaps having identical key ordering. While this should hold given both are sorted and the length check passes, directly looking up by key would be more robust and clearer:♻️ Safer alternative using direct key lookup
- // merge nonces into inputs map - let inputs = inputs_map - .into_iter() - .zip(fetched_addresses) - .map( - |((address_requested, amount), (address_received, info_received))| { - if address_requested != address_received { - Err(WasmSdkError::invalid_argument( - format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?", - address_requested, address_received) - ))? - } - if amount > info_received.balance { - Err(WasmSdkError::invalid_argument(format!( - "Input address {} has insufficient balance: requested {}, available {}", - address_requested, amount, info_received.balance - )))? - } - let nonce = info_received.nonce; - Ok((address_requested, (nonce, amount))) - }, - ) - .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?; + // merge nonces into inputs map + let inputs = inputs_map + .into_iter() + .map(|(address, amount)| { + let info = fetched_addresses + .get(&address) + .ok_or_else(|| WasmSdkError::invalid_argument( + format!("Address {} not found in fetched results", address) + ))?; + if amount > info.balance { + return Err(WasmSdkError::invalid_argument(format!( + "Input address {} has insufficient balance: requested {}, available {}", + address, amount, info.balance + ))); + } + Ok((address, (info.nonce, amount))) + }) + .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rspackages/wasm-sdk/src/state_transitions/addresses.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/addresses.rspackages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
🧠 Learnings (21)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
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: 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.
📚 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/addresses.rspackages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.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/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.rspackages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.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/addresses.rspackages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.rspackages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.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/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.rs
📚 Learning: 2024-11-28T14:08:53.428Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2351
File: packages/rs-dapi-client/src/address_list.rs:241-250
Timestamp: 2024-11-28T14:08:53.428Z
Learning: In the `IntoIterator` implementation for `AddressList` in `packages/rs-dapi-client/src/address_list.rs`, since `self` is consumed, holding a write lock while converting to an iterator does not block other operations.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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-sdk/src/state_transitions/addresses.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-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2025-10-09T15:59:28.329Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:181-187
Timestamp: 2025-10-09T15:59:28.329Z
Learning: In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`, the maintainer requires logging full state transition bytes (`tx_bytes = hex::encode(st_bytes)`) at debug level when a state transition passes CheckTx but is removed from the block by the proposer, to facilitate debugging of this rare edge case.
Applied to files:
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.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 `rs-drive-proof-verifier` for cryptographic proof verification
Applied to files:
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2024-11-03T10:38:00.762Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/info.rs:0-0
Timestamp: 2024-11-03T10:38:00.762Z
Learning: In this context, using `.unwrap()?` on the result of `root_hash` is acceptable and will not cause a panic.
Applied to files:
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
inputs(162-162)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: 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: Rust crates security audit
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build JS packages / Build JS
- 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)
🔇 Additional comments (4)
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs (1)
999-1020: LGTM! Verification flags correctly updated for subset proof handling.The boolean parameters for
verify_full_identity_by_identity_idandverify_addresses_infosare now set totrue, indicating these verifications expect subset proofs. This is consistent with theIdentityCreateFromAddressesflow where both identity and address info are verified from a combined proof, and the subsequent root hash comparison at lines 1022-1027 validates they share the same proof root.packages/wasm-sdk/src/state_transitions/addresses.rs (3)
939-940: LGTM! Nonce fetching integrated correctly.The integration properly fetches nonces before calling
put_with_address_funding, aligning with the SDK's nonce-aware API requirements. The flow is clear: inputs are parsed, nonces are fetched and merged, then the combined data is passed to the SDK method.Also applies to: 956-964
977-985: LGTM! Well-documented helper function.The helper function has clear documentation explaining its purpose and error conditions. The signature is appropriate for the internal use case.
5-6: Remove the unusedFetchManyimport on line 20.The
FetchManyimport is not used anywhere in this file. TheIdentityimport is actually used multiple times (lines 259, 309, 517, 619, 865, 932, 933), so it should be kept.⛔ Skipped due to learnings
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.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.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.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.Learnt from: QuantumExplorer Repo: dashpay/platform PR: 2215 File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30 Timestamp: 2024-10-09T00:22:57.778Z Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.Learnt from: lklimek Repo: dashpay/platform PR: 2207 File: packages/rs-drive-proof-verifier/Cargo.toml:46-46 Timestamp: 2024-10-04T10:07:23.863Z Learning: Usages of `BTreeMap` in crates that are out of scope of a change should not be flagged for replacement.Learnt from: lklimek Repo: dashpay/platform PR: 2207 File: packages/rs-drive-proof-verifier/Cargo.toml:46-46 Timestamp: 2024-10-09T00:22:57.778Z Learning: Usages of `BTreeMap` in crates that are out of scope of a change should not be flagged for replacement.
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/rs-sdk/src/platform/address_sync/types.rs (1)
27-28: Minor formatting: missing blank line between struct definitions.Consider adding a blank line after the
AddressFundsstruct closing brace for consistency with Rust formatting conventions.Suggested fix
pub struct AddressFunds { /// Address nonce used for anti-replay. pub nonce: AddressNonce, /// Credits balance held by the address. pub balance: Credits, } + /// Configuration for address synchronization. #[derive(Debug, Clone)] pub struct AddressSyncConfig {
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/rs-sdk-ffi/src/address_sync/mod.rspackages/rs-sdk-ffi/src/address_sync/provider.rspackages/rs-sdk-ffi/src/address_sync/types.rspackages/rs-sdk/src/platform/address_sync/mod.rspackages/rs-sdk/src/platform/address_sync/provider.rspackages/rs-sdk/src/platform/address_sync/types.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/rs-sdk/src/platform/address_sync/provider.rspackages/rs-sdk-ffi/src/address_sync/mod.rspackages/rs-sdk/src/platform/address_sync/types.rspackages/rs-sdk-ffi/src/address_sync/types.rspackages/rs-sdk/src/platform/address_sync/mod.rspackages/rs-sdk-ffi/src/address_sync/provider.rs
🧠 Learnings (8)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/rs-sdk/src/platform/address_sync/provider.rspackages/rs-sdk-ffi/src/address_sync/mod.rspackages/rs-sdk/src/platform/address_sync/mod.rspackages/rs-sdk-ffi/src/address_sync/provider.rs
📚 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-sdk/src/platform/address_sync/provider.rspackages/rs-sdk-ffi/src/address_sync/mod.rspackages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2024-10-28T10:38:49.538Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2259
File: packages/rs-dapi-client/src/executor.rs:49-56
Timestamp: 2024-10-28T10:38:49.538Z
Learning: In `packages/rs-dapi-client/src/executor.rs`, the `ExecutionResponse` struct always has a non-optional `address` field of type `Address` because an address is always present when there's a successful response.
Applied to files:
packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2024-10-22T10:53:12.111Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2259
File: packages/rs-dapi-client/src/dapi_client.rs:137-139
Timestamp: 2024-10-22T10:53:12.111Z
Learning: In `packages/rs-dapi-client/src/dapi_client.rs`, when passing data into asynchronous code, ensure that data structures are `Send + Sync`. Using `Arc<AtomicUsize>` is necessary for the retry counter.
Applied to files:
packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount from crate::balances::credits is compatible with u64 when used for token base supply.
Applied to files:
packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2182
File: packages/rs-dpp/src/withdrawal/daily_withdrawal_limit/v0/mod.rs:23-31
Timestamp: 2024-10-09T00:22:57.778Z
Learning: `Credits` is a `u64`, and division by 10 won't cause an overflow.
Applied to files:
packages/rs-sdk/src/platform/address_sync/types.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/rs-sdk/src/platform/address_sync/mod.rs
🧬 Code graph analysis (2)
packages/rs-sdk/src/platform/address_sync/provider.rs (1)
packages/rs-sdk-ffi/src/address_sync/provider.rs (1)
on_address_found(130-142)
packages/rs-sdk-ffi/src/address_sync/provider.rs (1)
packages/rs-sdk/src/platform/address_sync/provider.rs (1)
on_address_found(79-79)
⏰ 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). (16)
- GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (drive) / Unused dependencies
- GitHub Check: Rust packages (drive) / Formatting
- GitHub Check: Rust packages (wasm-sdk) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (drive) / Tests
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (dash-sdk) / Unused dependencies
- GitHub Check: Rust packages (dpp) / Check each feature
- GitHub Check: Rust packages (dpp) / Tests
- GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
- GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
- GitHub Check: Build JS packages / Build JS
- GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
) / Build Drive image
🔇 Additional comments (17)
packages/rs-sdk/src/platform/address_sync/types.rs (3)
20-27: LGTM! Well-structured composite type for address funds.The
AddressFundsstruct cleanly encapsulates nonce and balance together, with appropriate derive traits (Copy,Clone,Debug,PartialEq,Eq) for a value type. The doc comments clearly explain each field's purpose.
74-77: LGTM! Map value type correctly updated to AddressFunds.The
foundmap now stores the compositeAddressFundstype, enabling callers to access both nonce and balance for each discovered address.
112-122: LGTM! Helper methods correctly adapted to AddressFunds.Both
total_balance()andnon_zero_count()properly accessfunds.balancefrom the new composite type. The logic remains unchanged, just adapted to the new data structure.packages/rs-sdk-ffi/src/address_sync/types.rs (1)
66-84: LGTM! FFI struct correctly extended with nonce field.The
nonce: u32field is properly placed and documented. The typeu32aligns withAddressNoncefrom the SDK core.Note: This is an ABI-breaking change for FFI consumers. Ensure downstream Swift/iOS code is updated to account for the new field in the struct layout.
packages/rs-sdk-ffi/src/address_sync/mod.rs (1)
163-179: LGTM! Conversion correctly maps AddressFunds to FFI struct.The iteration over
result.foundnow properly destructures theAddressFundsvalue and assigns bothnonceandbalancefields to the FFI-compatibleDashSDKFoundAddressstruct.packages/rs-sdk/src/platform/address_sync/provider.rs (3)
3-3: LGTM! Import correctly updated.The import now includes
AddressFundsalongside existing type aliases.
39-45: LGTM! Doc example correctly demonstrates new API.The example shows proper usage of the
AddressFundsparameter and accessingfunds.balancefor gap extension logic.
76-79: LGTM! Trait method signature correctly updated.The
on_address_foundmethod now acceptsfunds: AddressFundsinstead of a raw balance, enabling providers to access both nonce and balance. The doc comment accurately describes the new parameter.Note: This is a breaking change for existing
AddressProviderimplementations.packages/rs-sdk/src/platform/address_sync/mod.rs (5)
44-47: LGTM! Public export correctly added.
AddressFundsis now part of the public API surface, enabling consumers to use the composite type.
244-272: LGTM! Function correctly updated to return Result and propagate errors.The
process_trunk_resultfunction now:
- Returns
Result<(), Error>instead of()- Uses
?to propagate conversion errors fromAddressFunds::try_from- Passes
fundsto provider callback
470-505: LGTM! Branch result processing correctly updated.The
process_branch_resultfunction mirrors the trunk result changes with proper error propagation andAddressFundsusage.
586-596: LGTM! Test updated for new API.The test correctly validates that:
Element::ItemWithSumItemwith nonce bytes[0, 0, 0, 5]produces nonce5- Balance
1000is correctly extracted- Invalid element types (plain
Element::Item) returnInvalidProvedResponseerror
507-530: LGTM! Well-implemented TryFrom conversion with proper error handling.The implementation correctly:
- Pattern matches on
Element::ItemWithSumItem- Validates nonce is exactly 4 bytes before conversion
- Uses
from_be_bytesfor nonce deserialization, consistent with how the platform handles all nonce types (bothAddressNonceas u32 and identity nonces as u64)- Handles potential out-of-range balance values with
try_into()- Returns descriptive error messages for all failure cases
packages/rs-sdk-ffi/src/address_sync/provider.rs (4)
4-4: LGTM! Import correctly updated.
AddressFundsis now imported alongside other address sync types.
26-36: LGTM! FFI callback signature correctly extended.The
OnAddressFoundFntype now includesnonce: u32parameter beforebalance: u64, maintaining a logical order matching theAddressFundsstruct. The doc comment is updated to reflect that both balance and nonce are provided.
130-142: LGTM! Callback implementation correctly updated.The
on_address_foundmethod now:
- Accepts
funds: AddressFundsmatching the trait signature- Extracts
funds.nonceandfunds.balancewhen calling the vtable function- Maintains correct parameter order in the FFI call
220-228: LGTM! Test callback updated for new signature.The
test_on_foundfunction correctly includes the_nonce: u32parameter to match the updatedOnAddressFoundFntype.
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/src/state_transitions/addresses.rs:
- Around line 916-923: Fix the typo in the documentation comment: replace
"aviod" with "avoid" in the TODO comment that references requiring address
nonces in the IdentityCreateFromAddressesOptionsJs and the note about
implementing the sync_address_balances mechanism; ensure the corrected sentence
reads clearly (e.g., "to avoid potential leak of address owner IP address")
while keeping the rest of the comment intact.
🧹 Nitpick comments (3)
packages/wasm-dpp2/src/platform_address/input_output.rs (1)
85-93: Acknowledged: TODO to add nonce to output struct.The TODO comment clearly tracks the need to add a
noncefield toPlatformAddressOutputWasmto achieve parity withPlatformAddressInputWasm. The reference toWasmSdk::identity_create_from_addressesprovides good traceability.Would you like me to open an issue to track this enhancement, or help implement the nonce field addition now?
packages/rs-sdk/tests/fetch/address_sync.rs (1)
63-65: Consider adopting "should..." naming convention for test functions.As per coding guidelines, tests should be named descriptively starting with "should...". The docstring already describes the behavior well. Consider renaming to something like
should_sync_found_and_absent_address_balances.This is a minor suggestion and can be deferred if the codebase has an established
test_prefix convention.packages/wasm-sdk/src/state_transitions/addresses.rs (1)
1017-1039: Consider using direct lookup instead of zip for clearer intent.The current zip pattern relies on both
BTreeMaps being sorted identically and having the exact same keys. While the equality check at lines 1023-1027 catches mismatches, iteratinginputs_mapand looking up infetched_addressesdirectly would be clearer and more robust:♻️ Suggested refactor using direct lookup
- // merge nonces into inputs map - let inputs = inputs_map - .into_iter() - .zip(fetched_addresses) - .map( - |((address_requested, amount), (address_received, info_received))| { - if address_requested != address_received { - Err(WasmSdkError::invalid_argument( - format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?", - address_requested, address_received) - ))? - } - if amount > info_received.balance { - Err(WasmSdkError::invalid_argument(format!( - "Input address {} has insufficient balance: requested {}, available {}", - address_requested, amount, info_received.balance - )))? - } - let nonce = info_received.nonce; - Ok((address_requested, (nonce, amount))) - }, - ) - .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?; + // merge nonces into inputs map + let inputs = inputs_map + .into_iter() + .map(|(address, amount)| { + let info = fetched_addresses.get(&address).ok_or_else(|| { + WasmSdkError::invalid_argument(format!( + "Input address {} not found when fetching nonces", + address + )) + })?; + if amount > info.balance { + return Err(WasmSdkError::invalid_argument(format!( + "Input address {} has insufficient balance: requested {}, available {}", + address, amount, info.balance + ))); + } + Ok((address, (info.nonce, amount))) + }) + .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;This approach eliminates the need for the length check at lines 1011-1016 as well, since the lookup handles missing addresses directly.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/rs-sdk/tests/fetch/address_sync.rspackages/wasm-dpp2/src/platform_address/input_output.rspackages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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/platform_address/input_output.rspackages/wasm-sdk/src/state_transitions/addresses.rspackages/rs-sdk/tests/fetch/address_sync.rs
**/tests/**/*.{js,jsx,ts,tsx,rs}
📄 CodeRabbit inference engine (AGENTS.md)
**/tests/**/*.{js,jsx,ts,tsx,rs}: Name tests descriptively, starting with 'should …'
Unit and integration tests should not perform network calls; mock dependencies
Files:
packages/rs-sdk/tests/fetch/address_sync.rs
🧠 Learnings (19)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
📚 Learning: 2024-09-29T13:13:54.230Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2182
File: packages/rs-platform-version/src/version/drive_abci_versions.rs:116-121
Timestamp: 2024-09-29T13:13:54.230Z
Learning: Adding Rust doc comments to structs and fields is recommended to enhance clarity and documentation.
Applied to files:
packages/wasm-dpp2/src/platform_address/input_output.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/wasm-dpp2/src/platform_address/input_output.rspackages/wasm-sdk/src/state_transitions/addresses.rspackages/rs-sdk/tests/fetch/address_sync.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/addresses.rspackages/rs-sdk/tests/fetch/address_sync.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/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.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/addresses.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/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.rs
📚 Learning: 2024-11-28T14:08:53.428Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2351
File: packages/rs-dapi-client/src/address_list.rs:241-250
Timestamp: 2024-11-28T14:08:53.428Z
Learning: In the `IntoIterator` implementation for `AddressList` in `packages/rs-dapi-client/src/address_list.rs`, since `self` is consumed, holding a write lock while converting to an iterator does not block other operations.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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-sdk/src/state_transitions/addresses.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/rs-sdk/tests/fetch/address_sync.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (3)
packages/wasm-sdk/src/queries/utils.rs (1)
deserialize_required_query(11-28)packages/rs-sdk/src/platform/transition/put_identity.rs (1)
inputs(162-162)packages/wasm-sdk/src/error.rs (2)
generic(71-73)invalid_argument(75-77)
⏰ 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 (wasm-dpp) / Tests
- GitHub Check: Rust packages (dash-sdk) / Linting
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (dpp) / Linting
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (dpp) / Tests
- GitHub Check: Rust packages (dpp) / Unused dependencies
- GitHub Check: Rust packages (wasm-dpp2) / Formatting
- GitHub Check: Rust packages (dpp) / Check each feature
- GitHub Check: Rust packages (wasm-dpp2) / Linting
- GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
- GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
) / Build Drive 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 (6)
packages/rs-sdk/tests/fetch/address_sync.rs (4)
1-3: LGTM!Import correctly adds
AddressFundsfrom the address_sync module, aligning with the new type used in the test harness.
15-21: LGTM!The
foundfield type correctly updated to storeAddressFundsinstead of rawu64balance, consistent with the trait signature changes.
47-51: LGTM!Method signature and implementation correctly updated to handle
AddressFunds. The insertion logic properly stores the complete struct rather than just the balance.
88-103: LGTM!Test assertions correctly updated to unwrap with
.expect()(providing clear failure context) and access the.balancefield fromAddressFunds. The multi-line formatting improves readability.packages/wasm-sdk/src/state_transitions/addresses.rs (2)
5-6: LGTM!All new imports are used by the
fetch_nonces_into_address_maphelper function and are appropriate for the functionality being added.Also applies to: 13-13, 15-15, 20-21
947-948: LGTM!The integration properly fetches nonces before calling
put_with_address_funding, ensuring the SDK method receives the required(AddressNonce, Credits)tuples.Also applies to: 967-967
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/addresses.rs (1)
990-1016: Consider using a lookup-based merge instead of zip for robustness.The current implementation relies on both
inputs_mapandfetched_addresseshaving identical keys in the same order for thezipat line 1020 to produce correct pairings. While BTreeMap iterates in sorted order and the length check at line 1012 should catch mismatches, a lookup-based approach would be more explicit and safer against subtle ordering issues.Also, the
BTreeSetcollection at lines 995-996 is unnecessary sinceFetchManycan accept any iterable of keys, and you could passinputs_map.keys().cloned()directly.♻️ Suggested refactor using lookup-based merge
async fn fetch_nonces_into_address_map( sdk: &Sdk, inputs_map: BTreeMap<PlatformAddress, Credits>, ) -> Result<BTreeMap<PlatformAddress, (AddressNonce, Credits)>, WasmSdkError> { - // collect addresses - let input_addresses: BTreeSet<PlatformAddress> = - inputs_map.keys().cloned().collect::<BTreeSet<_>>(); - // fetch nonces - let fetched_addresses = dash_sdk::query_types::AddressInfo::fetch_many(sdk, input_addresses) + let fetched_addresses = dash_sdk::query_types::AddressInfo::fetch_many( + sdk, + inputs_map.keys().cloned().collect::<Vec<_>>(), + ) .await .map_err(|e| { WasmSdkError::generic(format!( "Failed to fetch address infos for identity creation: {}", e )) })? .into_iter() .filter_map(|(k, v)| v.map(|info| (k, info))) .collect::<BTreeMap<_, _>>(); - // sanity check - filter_map above should have removed any non-existing addresses - if inputs_map.len() != fetched_addresses.len() { - return Err(WasmSdkError::invalid_argument( - "Some input addresses were not found when fetching nonces", - )); - } - // merge nonces into inputs map - let inputs = inputs_map + // merge nonces into inputs map using lookup + inputs_map .into_iter() - .zip(fetched_addresses) - .map( - |((address_requested, amount), (address_received, info_received))| { - if address_requested != address_received { - Err(WasmSdkError::invalid_argument( - format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?", - address_requested, address_received) - ))? - } - if amount > info_received.balance { + .map(|(address, amount)| { + let info = fetched_addresses.get(&address).ok_or_else(|| { + WasmSdkError::invalid_argument(format!( + "Input address {} was not found when fetching nonces", + address + )) + })?; + if amount > info.balance { + return Err(WasmSdkError::invalid_argument(format!( + "Input address {} has insufficient balance: requested {}, available {}", + address, amount, info.balance + ))); + } - Err(WasmSdkError::invalid_argument(format!( - "Input address {} has insufficient balance: requested {}, available {}", - address_requested, amount, info_received.balance - )))? - } - let nonce = info_received.nonce; - Ok((address_requested, (nonce, amount))) - }, - ) - .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?; - - Ok(inputs) + Ok((address, (info.nonce, amount))) + }) + .collect() }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rs
🧠 Learnings (20)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.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/addresses.rs
📚 Learning: 2024-10-04T14:16:05.798Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-04T14:16:05.798Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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/addresses.rs
📚 Learning: 2024-11-28T14:08:53.428Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2351
File: packages/rs-dapi-client/src/address_list.rs:241-250
Timestamp: 2024-11-28T14:08:53.428Z
Learning: In the `IntoIterator` implementation for `AddressList` in `packages/rs-dapi-client/src/address_list.rs`, since `self` is consumed, holding a write lock while converting to an iterator does not block other operations.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-09-03T15:44:33.889Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:0-0
Timestamp: 2025-09-03T15:44:33.889Z
Learning: In packages/wasm-sdk/docs.html, thephez prefers to keep realistic-looking private key placeholders in documentation examples rather than using obvious fake placeholders, despite secret scanner warnings.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.rs
📚 Learning: 2025-09-03T14:41:16.196Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-09-29T13:13:54.230Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2182
File: packages/rs-platform-version/src/version/drive_abci_versions.rs:116-121
Timestamp: 2024-09-29T13:13:54.230Z
Learning: Adding Rust doc comments to structs and fields is recommended to enhance clarity and documentation.
Applied to files:
packages/wasm-sdk/src/state_transitions/addresses.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/addresses.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-sdk/src/state_transitions/addresses.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 (dpp) / Formatting
- GitHub Check: Rust packages (drive) / Unused dependencies
- GitHub Check: Rust packages (drive) / Linting
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (rs-sdk-ffi) / Unused dependencies
- GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
- GitHub Check: Rust packages (rs-sdk-ffi) / Linting
- GitHub Check: Rust packages (rs-sdk-ffi) / Tests
- GitHub Check: Rust packages (wasm-sdk) / Formatting
- GitHub Check: Rust packages (wasm-sdk) / Linting
- GitHub Check: Rust packages (wasm-dpp2) / Tests
- GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
- GitHub Check: Rust packages (wasm-dpp2) / Linting
- GitHub Check: Build Docker images (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: Swift SDK and Example build (warnings as errors)
- 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)
🔇 Additional comments (4)
packages/wasm-sdk/src/state_transitions/addresses.rs (4)
916-923: Good documentation of unstable API and privacy concerns.The documentation clearly warns users about the privacy implications and the planned changes. However, the crate path reference
crate::platform::Platform::sync_address_balancesin the TODO comment may be incorrect since this is inwasm-sdk, not the main SDK crate. Consider updating the path or using a more generic reference.
947-948: LGTM!The integration of
fetch_nonces_into_address_mapinto the identity creation flow is clean and maintains proper error propagation.
1029-1034: Balance comparison uses correct types.The balance comparison
amount > info_received.balancecorrectly comparesCreditsvalues. The error message is clear and helpful for debugging.
20-21: TheIdentityimport fromdash_sdk::platformat line 20 is actively used throughout the file (struct fields at lines 259, 619, and variable annotations at lines 309, 517, 940). It is the sole import source forIdentityand is necessary. This import should not be questioned.Likely an incorrect or invalid review comment.
Issue being fixed or feature implemented
Identity creation with funds from platform addresses is confusing:
it's not clear how to create identity ID.
What was done?
Added Identity::new_with_input_addresses_and_keys() constructor that generated identity ID internally.
How Has This Been Tested?
With dash evo tool; WASM changes to be tested separately.
Breaking Changes
None, new feature
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
Bug Fixes
New Features
Chores / Breaking Change
✏️ Tip: You can customize this high-level summary in your review settings.