Skip to content

Conversation

@PastaPastaPasta
Copy link
Member

@PastaPastaPasta PastaPastaPasta commented Jan 14, 2026

Issue being fixed or feature implemented

Many SDK APIs changed from simple credential parameters to requiring pre-constructed typed objects, making the API more complex for common use cases. This PR adds convenience methods that accept simple credentials (identityId, publicKeyId, privateKey) for DPNS registerName as a proof of concept for the pattern.

Old API Style (dev.9):

await sdk.dpns.registerName({
  label,
  identityId,       // Just the ID string
  publicKeyId,      // Just the key index number  
  privateKeyWif,    // Just the WIF string
});

Current API Style (requires pre-construction):

const identity = await sdk.identities.fetch(identityId);
const identityKey = identity.getPublicKeyById(publicKeyId);
const signer = new IdentitySigner();
signer.addKeyFromWif(privateKeyWif);

await sdk.dpns.registerName({ label, identity, identityKey, signer });

What was done?

Added support for both parameter styles in DPNS registerName:

  1. simple-signer:

    • Updated doc comment to reflect production use (not just tests)
    • Added from_wif(), from_private_key(), add_key_from_wif() helper methods
  2. rs-sdk:

    • Added simple-signer as dependency
    • Added register_dpns_name_with_credentials() convenience method
  3. wasm-sdk:

    • Updated DpnsRegisterNameOptions TypeScript interface to accept both styles
    • Added routing logic to detect parameter style and call appropriate method
  4. js-evo-sdk:

    • Added JSDoc documentation explaining both parameter styles

New simple credentials style:

await sdk.dpns.registerName({
  label: 'alice',
  identityId: '...',
  publicKeyId: 1,
  privateKey: new Uint8Array([...]),  // 32 bytes
});

The existing typed objects style continues to work unchanged.

How Has This Been Tested?

  • cargo check -p simple-signer --features state-transitions
  • cargo check -p dash-sdk
  • cargo check -p wasm-sdk

Future PRs will add functional tests as part of expanding this pattern to other methods.

Breaking Changes

None. This is purely additive - the existing typed objects API continues to work unchanged.

Checklist:

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

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Added simplified DPNS name registration using credential parameters (identityId, publicKeyId, privateKey) as an alternative to complex typed objects.
    • Added WIF (Wallet Import Format) support for importing private keys.
    • Made entropy parameter optional in document creation.

✏️ Tip: You can customize this high-level summary in your review settings.

PastaPastaPasta and others added 3 commits January 13, 2026 17:11
…provided

Previously, documentCreate() would throw an error if the Document didn't
have entropy set. This was a breaking change for SDKs that create documents
via fromObject(), fromJSON(), or fromBytes() which don't auto-generate entropy.

Now entropy is auto-generated at the wasm-sdk level when not provided,
making it truly optional while maintaining backward compatibility.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Instead of generating entropy in wasm-sdk, pass None to rs-sdk
when entropy is not set. This lets rs-sdk handle both entropy
generation and document ID regeneration correctly.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add convenience method that accepts simple credentials (identityId,
publicKeyId, privateKey) instead of requiring pre-constructed typed
objects (Identity, IdentityPublicKey, IdentitySigner).

This simplifies the API for common use cases where the caller has
credentials but doesn't need full control over object construction.

Changes:
- simple-signer: Add from_wif(), from_private_key(), add_key_from_wif()
  helper methods; update doc to reflect production use
- rs-sdk: Add register_dpns_name_with_credentials() convenience method
- wasm-sdk: Support both parameter styles in dpnsRegisterName()
- js-evo-sdk: Add JSDoc documentation for both styles

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@github-actions github-actions bot added this to the v3.0.0 milestone Jan 14, 2026
@github-actions
Copy link

✅ gRPC Query Coverage Report

================================================================================
gRPC Query Coverage Report - NEW QUERIES ONLY
================================================================================

Total queries in proto: 53
Previously known queries: 47
New queries found: 6

================================================================================

New Query Implementation Status:
--------------------------------------------------------------------------------
✓ getAddressInfo                                /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs
✓ getAddressesBranchState                       /home/runner/work/platform/platform/packages/rs-sdk/src/platform/address_sync/mod.rs
✓ getAddressesInfos                             /home/runner/work/platform/platform/packages/rs-sdk/src/platform/fetch_many.rs
✓ getAddressesTrunkState                        /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs
✓ getRecentAddressBalanceChanges                /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs
✓ getRecentCompactedAddressBalanceChanges       /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs

================================================================================
Summary:
--------------------------------------------------------------------------------
New queries implemented: 6 (100.0%)
New queries missing: 0 (0.0%)

Total known queries: 53
  - Implemented: 50
  - Not implemented: 2
  - Excluded: 1

Not implemented queries:
  - getConsensusParams
  - getTokenPreProgrammedDistributions

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

📝 Walkthrough

Walkthrough

The PR adds simplified DPNS name registration by introducing credential-based registration flows across the SDK stack. SimpleSigner is expanded with WIF parsing and convenience constructors. The WASM and JavaScript SDKs are updated to support dual-style parameter handling, while Rust SDK gains a credential-focused registration method. Document creation entropy handling becomes optional.

Changes

Cohort / File(s) Summary
DPNS Credential Registration
packages/rs-sdk/src/platform/dpns_usernames/mod.rs, packages/wasm-sdk/src/dpns.rs, packages/js-evo-sdk/src/dpns/facade.ts
Added credential-based DPNS name registration alongside typed object style. Rust layer introduces register_dpns_name_with_credentials using simple parameters (label, identity_id, public_key_id, private_key). WASM layer routes between Style A (identity/identityKey/signer) and Style B (identityId/publicKeyId/privateKey) via new extraction helpers. JavaScript facade wraps with registerName method.
SimpleSigner Expansion
packages/simple-signer/src/signer.rs
Made internal key maps public (private_keys, private_keys_in_creation, address_private_keys, address_private_keys_in_creation). Added three new public methods: add_key_from_wif (parses WIF string), from_wif (convenience constructor from WIF), from_private_key (convenience constructor from raw 32-byte key).
Dependency Addition
packages/rs-sdk/Cargo.toml
Added simple-signer dependency with path reference, disabled default features, enabled "state-transitions" feature.
Document Creation Enhancement
packages/wasm-sdk/src/state_transitions/document.rs
Made entropy optional in document creation flow. Changed entropy validation from mandatory 32-byte requirement to conditional acceptance; now passes Option<[u8; 32]> to platform layer instead of concrete array.

Sequence Diagram

sequenceDiagram
    participant TS as TypeScript App
    participant JSFacade as JS Facade
    participant WasmSDK as WASM SDK
    participant RustSDK as Rust SDK
    participant Signer as SimpleSigner

    TS->>JSFacade: registerName(options)
    JSFacade->>WasmSDK: dpns_register_name(options)
    
    alt Style B: Simple Credentials
        WasmSDK->>WasmSDK: Extract identityId, publicKeyId, privateKey
        WasmSDK->>RustSDK: register_dpns_name_with_credentials(label, identity_id, public_key_id, private_key)
        RustSDK->>RustSDK: Fetch identity from platform
        RustSDK->>Signer: Create SimpleSigner with private key
        Signer->>Signer: Store private key mapped to public key
        RustSDK->>RustSDK: Call register_dpns_name with signer
    else Style A: Typed Objects
        WasmSDK->>WasmSDK: Extract identity, identityKey, signer
        WasmSDK->>RustSDK: register_dpns_name(RegisterDpnsNameInput)
    end
    
    RustSDK->>WasmSDK: RegisterDpnsNameResult
    WasmSDK->>JSFacade: Promise resolves
    JSFacade->>TS: RegisterDpnsNameResult
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hark! Credentials flow through layers deep,
SimpleSigner wakes from testing sleep,
WIF to keys, two styles take flight,
DPNS registration done just right! ✨🔑

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature added across the PR: a credentials-based API for DPNS registerName that accepts simple credential parameters (identityId, publicKeyId, privateKey) as an alternative to the existing typed-object style.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
packages/wasm-sdk/src/dpns.rs (1)

502-546: Consider validating style exclusivity and improving error messages.

The routing logic correctly detects and handles both parameter styles. However, there are edge cases that could lead to user confusion:

  1. Mixed styles: If users accidentally provide both identity and identityId, the credentials-based path silently takes precedence. Consider detecting this scenario and returning a clear error.

  2. Partial credentials: If only 1 or 2 of the 3 credential fields are provided, has_simple_credentials returns false, causing the code to fall through to Style A extraction, which will likely fail with errors about missing identity/identityKey/signer. This could confuse users who intended to use credentials but forgot a field.

💡 Suggested improvements

Consider adding validation after line 467:

// Detect which style is being used
let has_identity = !js_sys::Reflect::get(&options_value, &JsValue::from_str("identity"))
    .map(|v| v.is_undefined() || v.is_null())
    .unwrap_or(true);

let has_credentials = has_simple_credentials(&options_value);

// Check for any partial credential fields
let has_identity_id = js_sys::Reflect::get(&options_value, &JsValue::from_str("identityId"))
    .map(|v| !v.is_undefined() && !v.is_null())
    .unwrap_or(false);
let has_public_key_id = js_sys::Reflect::get(&options_value, &JsValue::from_str("publicKeyId"))
    .map(|v| !v.is_undefined() && !v.is_null())
    .unwrap_or(false);
let has_private_key = js_sys::Reflect::get(&options_value, &JsValue::from_str("privateKey"))
    .map(|v| !v.is_undefined() && !v.is_null())
    .unwrap_or(false);

if has_identity && has_credentials {
    return Err(WasmSdkError::invalid_argument(
        "Cannot mix parameter styles. Use either (identity, identityKey, signer) OR (identityId, publicKeyId, privateKey)"
    ));
}

if (has_identity_id || has_public_key_id || has_private_key) && !has_credentials {
    return Err(WasmSdkError::invalid_argument(
        "Incomplete credentials. For credentials-based registration, provide all three: identityId, publicKeyId, and privateKey"
    ));
}

Alternatively, enhance error messages when extracting credential fields:

 let public_key_id = extract_optional_u32_from_options(&options_value, "publicKeyId")?
-    .ok_or_else(|| WasmSdkError::invalid_argument("publicKeyId is required"))?;
+    .ok_or_else(|| WasmSdkError::invalid_argument("publicKeyId is required for credentials-based registration"))?;

 let private_key = extract_optional_bytes32_from_options(&options_value, "privateKey")?
-    .ok_or_else(|| WasmSdkError::invalid_argument("privateKey is required"))?;
+    .ok_or_else(|| WasmSdkError::invalid_argument("privateKey is required for credentials-based registration (32-byte Uint8Array)"))?;
📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c66c07e and 8aa5644.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • packages/js-evo-sdk/src/dpns/facade.ts
  • packages/rs-sdk/Cargo.toml
  • packages/rs-sdk/src/platform/dpns_usernames/mod.rs
  • packages/simple-signer/src/signer.rs
  • packages/wasm-sdk/src/dpns.rs
  • packages/wasm-sdk/src/state_transitions/document.rs
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo 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/dpns_usernames/mod.rs
  • packages/simple-signer/src/signer.rs
  • packages/wasm-sdk/src/state_transitions/document.rs
  • packages/wasm-sdk/src/dpns.rs
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,jsx,ts,tsx}: Use 2-space indent for JS/TS files
Use camelCase for variables and functions in JS/TS
Use PascalCase for class names in JS/TS
Use ESLint with Airbnb/TypeScript rules for JS/TS files

Files:

  • packages/js-evo-sdk/src/dpns/facade.ts
packages/**/!(node_modules)/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use kebab-case for filenames within JS packages

Files:

  • packages/js-evo-sdk/src/dpns/facade.ts
🧠 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.
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/api-definitions.json:1285-1285
Timestamp: 2025-09-03T19:33:21.688Z
Learning: In packages/wasm-sdk/api-definitions.json, thephez prefers to keep the existing "ripemd160hash20bytes1234" placeholder for ECDSA_HASH160 data field in documentation examples rather than using a valid base64-encoded format, maintaining consistency with the previous documentation approach.
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-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/dpns_usernames/mod.rs
📚 Learning: 2024-10-21T01:03:42.458Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-dpp/src/core_types/validator_set/v0/mod.rs:299-299
Timestamp: 2024-10-21T01:03:42.458Z
Learning: In the `test_serialize_deserialize_validator_set_v0` test within `packages/rs-dpp/src/core_types/validator_set/v0/mod.rs`, deterministic BLS keys cannot be easily used; therefore, using `BlsPublicKey::generate()` is acceptable.

Applied to files:

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

Applied to files:

  • packages/rs-sdk/src/platform/dpns_usernames/mod.rs
📚 Learning: 2024-10-29T10:42:00.521Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-dapi-client/Cargo.toml:22-22
Timestamp: 2024-10-29T10:42:00.521Z
Learning: In `packages/rs-dapi-client/Cargo.toml`, `backon` will not work without the `tokio-sleep` feature in our setup, so it's unnecessary to declare `tokio-sleep` as a separate feature in the `[features]` section.

Applied to files:

  • packages/rs-sdk/Cargo.toml
📚 Learning: 2025-09-03T16:37:11.605Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2756
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_list/update_state_masternode_list/v0/mod.rs:11-11
Timestamp: 2025-09-03T16:37:11.605Z
Learning: In packages/rs-dpp/Cargo.toml, the abci feature already includes core_rpc_client, and core_rpc_client is defined as ["dep:dashcore-rpc"]. This means rs-drive-abci can access dashcore-rpc types through dpp when using the abci feature.

Applied to files:

  • packages/rs-sdk/Cargo.toml
📚 Learning: 2025-03-11T09:39:23.071Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2489
File: packages/rs-dpp/Cargo.toml:32-32
Timestamp: 2025-03-11T09:39:23.071Z
Learning: In the Dash Platform project, dependencies are currently managed using Git repository references with tags (repo+tag format in Cargo.toml) rather than published crates, as the team is not currently publishing crates to crates.io.

Applied to files:

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

Applied to files:

  • packages/rs-sdk/Cargo.toml
📚 Learning: 2025-01-19T07:36:46.042Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2431
File: packages/rs-drive/Cargo.toml:55-60
Timestamp: 2025-01-19T07:36:46.042Z
Learning: The grovedb dependencies in packages/rs-drive/Cargo.toml and related files are intentionally kept at specific revisions rather than using the latest stable version, with plans to update them at a later time.

Applied to files:

  • packages/rs-sdk/Cargo.toml
📚 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 Rust for core platform components (Drive, DAPI server, DPP implementation)

Applied to files:

  • packages/rs-sdk/Cargo.toml
📚 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/simple-signer/src/signer.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/document.rs
  • packages/wasm-sdk/src/dpns.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/document.rs
📚 Learning: 2025-09-03T14:42:29.958Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/document.rs
📚 Learning: 2025-09-03T19:33:21.688Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/api-definitions.json:1285-1285
Timestamp: 2025-09-03T19:33:21.688Z
Learning: In packages/wasm-sdk/api-definitions.json, thephez prefers to keep the existing "ripemd160hash20bytes1234" placeholder for ECDSA_HASH160 data field in documentation examples rather than using a valid base64-encoded format, maintaining consistency with the previous documentation approach.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/document.rs
  • packages/wasm-sdk/src/dpns.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/document.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

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

Applied to files:

  • packages/wasm-sdk/src/state_transitions/document.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/document.rs
🧬 Code graph analysis (3)
packages/rs-sdk/src/platform/dpns_usernames/mod.rs (2)
packages/simple-signer/src/single_key_signer.rs (1)
  • private_key (76-78)
packages/simple-signer/src/signer.rs (1)
  • from_private_key (145-152)
packages/simple-signer/src/signer.rs (1)
packages/simple-signer/src/single_key_signer.rs (2)
  • private_key (76-78)
  • from_private_key (61-63)
packages/wasm-sdk/src/dpns.rs (3)
packages/wasm-sdk/src/error.rs (1)
  • invalid_argument (75-77)
packages/wasm-sdk/src/queries/identity.rs (3)
  • new (94-96)
  • new (125-127)
  • identity_id (102-104)
packages/wasm-sdk/src/queries/utils.rs (1)
  • identifier_from_js (89-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). (16)
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (wasm-sdk) / Formatting
  • GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • 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 (13)
packages/wasm-sdk/src/state_transitions/document.rs (3)

54-55: Documentation accurately reflects the new optional entropy behavior.

The TypeScript interface comment correctly states entropy is optional and will be auto-generated if not set.


112-121: LGTM! Clean handling of optional entropy.

The logic correctly extracts entropy only when it's the expected 32 bytes, otherwise returns None to let rs-sdk generate it. The and_then chain is idiomatic.


145-145: Correctly passes optional entropy to the platform call.

This aligns with the upstream rs-sdk signature expecting Option<[u8; 32]>.

packages/js-evo-sdk/src/dpns/facade.ts (1)

36-71: Well-documented dual parameter styles.

The JSDoc clearly explains both Style A (typed objects) and Style B (simple credentials) with practical examples. This improves developer experience by showing both usage patterns upfront.

packages/rs-sdk/Cargo.toml (1)

22-24: Dependency correctly configured.

The simple-signer crate is added with the state-transitions feature required for the new credentials-based DPNS registration flow. The path-based reference follows the established workspace pattern.

packages/rs-sdk/src/platform/dpns_usernames/mod.rs (2)

18-21: Imports correctly added for new functionality.

The KeyID type and SimpleSigner are properly imported to support the new credentials-based registration method.


365-438: Well-implemented convenience method for credentials-based registration.

The method correctly:

  1. Fetches the identity and handles the not-found case
  2. Retrieves the public key by ID with clear error messaging
  3. Constructs the signer using SimpleSigner::from_private_key
  4. Delegates to the existing register_dpns_name flow

The documentation is thorough with clear argument descriptions and error conditions.

Note: The method trusts that the provided private_key corresponds to the identity_public_key. Mismatched keys will result in a signing error at transaction time rather than at signer creation, which is consistent with the existing SimpleSigner behavior.

packages/simple-signer/src/signer.rs (3)

20-35: Public fields enable flexibility but expose key material.

The documentation update and public fields are appropriate for the stated use cases. Note that making private_keys and related maps public allows direct access to key material. This is consistent with the convenience-oriented design of this struct, but consumers should be aware when handling the signer in sensitive contexts.


88-109: Clean WIF parsing implementation.

The add_key_from_wif method correctly parses the WIF string using dashcore::PrivateKey::from_wif and extracts the secret bytes. Error handling appropriately wraps the parse error in a ProtocolError::Generic.


111-152: Convenience constructors follow established patterns.

Both from_wif and from_private_key provide clean factory methods for single-key signers. The from_private_key implementation aligns with the SingleKeySigner::from_private_key pattern seen in the codebase (per relevant code snippet from packages/simple-signer/src/single_key_signer.rs).

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

100-187: LGTM! Clear documentation for dual-style API.

The TypeScript documentation effectively describes both parameter styles with helpful examples. The interface correctly marks all parameters as optional, allowing either style to be used.


278-340: Well-implemented helper functions.

The extraction helpers follow consistent patterns with proper null/undefined handling and validation. The 32-byte length check in extract_optional_bytes32_from_options correctly guards against incorrect private key sizes.


441-458: Clear function documentation.

The doc comment accurately describes the dual-style API and provides a good overview of the registration flow.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Collaborator

@shumkov shumkov left a comment

Choose a reason for hiding this comment

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

The idea is that eventually Evo SDK will keep in context with user identities, data contracts, and signer, so these params become optional in all methods. We have this one in our TODO list. Currently, we aligned all interfaces and remove implicit fetching of data inside methods. I'm not sure that patching of one specific method is the right way to move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants