feat(sdk): add more SDK methods#2784
Conversation
WalkthroughAdds many new public wrapper methods across Group, Identities, and Tokens facades that delegate to the connected Wasm SDK (including WithProof variants), introduces a wallet helpers module and exports, updates EvoSDK static/instance helpers, and extends functional and unit tests to cover the new APIs while removing explicit Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor App
participant Facade as JS Facade (Group/Identities/Tokens)
participant SDK as EvoSDK
participant Wasm as WasmSdk
App->>Facade: callMethod(params, opts?)
Facade->>SDK: getConnectedWasmSdk()
SDK-->>Facade: wasmInstance
alt non-proof request
Facade->>Wasm: wasm.method(params, normalizedOptsOrNull)
Wasm-->>Facade: result
else proof request
Facade->>Wasm: wasm.methodWithProofInfo(params, normalizedOptsOrNull)
Wasm-->>Facade: resultWithProof
end
Facade-->>App: return result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ 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). (3)
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
packages/js-evo-sdk/tests/unit/wallet.spec.mjs (1)
2-2: Prefer importing the ESM bundle for consistencyUse the module build to avoid potential named‑export mismatch with CJS.
-import { wallet } from '../../dist/sdk.js'; +import { wallet } from '../../dist/evo-sdk.module.js';packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs (1)
48-51: Align import target with ESM bundle (optional)Some tests import from evo-sdk.module.js; consider switching here too for consistency.
packages/js-evo-sdk/src/tokens/facade.ts (1)
12-14: Consider narrowing return types instead of any (follow‑up)Typed results would improve DX; can be added later without behavior change.
packages/js-evo-sdk/src/group/facade.ts (1)
7-91: Forwarding methods are correct and consistentParameter null-normalization and delegation look correct across info/infos/members/identityGroups/actions/signers/dataContracts.
- Consider tightening types (e.g.,
statusas a union type and specific return types instead ofany).- Minor DRY: a small helper to fetch
w = await this.sdk.getWasmSdkConnected()could reduce repetition.packages/js-evo-sdk/src/wallet/functions.ts (1)
3-99: Type tightening for wallet functionsMultiple functions accept
network: string. Constrain to'mainnet' | 'testnet'to prevent misconfiguration at compile time. Consider adding precise return types where available from wasm typings.packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (1)
1-224: Add a test for the 'search' fallback pathRecommend asserting that
getKeysWithProof({ keyRequestType: 'search', searchPurposeMap: {...} })callsgetIdentityKeys(non-proof) and not the proof variant.Proposed test addition:
+ it('getKeysWithProof() falls back to non-proof for keyRequestType "search"', async () => { + await client.identities.getKeysWithProof({ + identityId: 'id', + keyRequestType: 'search', + searchPurposeMap: { purpose: 1 }, + limit: 5, + offset: 1, + }); + expect(wasmSdk.getIdentityKeys).to.be.calledOnce(); + expect(wasmSdk.getIdentityKeysWithProofInfo).to.not.be.called; + const { args } = wasmSdk.getIdentityKeys.firstCall; + expect(args[0]).to.equal('id'); + expect(args[1]).to.equal('search'); + expect(args[2]).to.equal(null); + expect(args[3]).to.equal(JSON.stringify({ purpose: 1 })); + expect(args[4]).to.equal(5); + expect(args[5]).to.equal(1); + });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
packages/js-evo-sdk/src/group/facade.ts(1 hunks)packages/js-evo-sdk/src/identities/facade.ts(1 hunks)packages/js-evo-sdk/src/sdk.ts(2 hunks)packages/js-evo-sdk/src/tokens/facade.ts(3 hunks)packages/js-evo-sdk/src/wallet/functions.ts(1 hunks)packages/js-evo-sdk/tests/functional/documents.spec.mjs(0 hunks)packages/js-evo-sdk/tests/functional/dpns.spec.mjs(0 hunks)packages/js-evo-sdk/tests/functional/epoch.spec.mjs(0 hunks)packages/js-evo-sdk/tests/functional/group.spec.mjs(1 hunks)packages/js-evo-sdk/tests/functional/identities.spec.mjs(1 hunks)packages/js-evo-sdk/tests/functional/protocol.spec.mjs(0 hunks)packages/js-evo-sdk/tests/functional/system.spec.mjs(0 hunks)packages/js-evo-sdk/tests/functional/tokens.spec.mjs(2 hunks)packages/js-evo-sdk/tests/functional/voting.spec.mjs(0 hunks)packages/js-evo-sdk/tests/functional/wallet.spec.mjs(1 hunks)packages/js-evo-sdk/tests/unit/facades/group.spec.mjs(1 hunks)packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs(2 hunks)packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs(4 hunks)packages/js-evo-sdk/tests/unit/sdk.spec.mjs(1 hunks)packages/js-evo-sdk/tests/unit/wallet.spec.mjs(1 hunks)
💤 Files with no reviewable changes (6)
- packages/js-evo-sdk/tests/functional/epoch.spec.mjs
- packages/js-evo-sdk/tests/functional/dpns.spec.mjs
- packages/js-evo-sdk/tests/functional/documents.spec.mjs
- packages/js-evo-sdk/tests/functional/system.spec.mjs
- packages/js-evo-sdk/tests/functional/protocol.spec.mjs
- packages/js-evo-sdk/tests/functional/voting.spec.mjs
🧰 Additional context used
📓 Path-based instructions (2)
packages/**/tests/**
📄 CodeRabbit inference engine (AGENTS.md)
Place unit and integration tests alongside each package in packages//tests
Files:
packages/js-evo-sdk/tests/functional/group.spec.mjspackages/js-evo-sdk/tests/unit/wallet.spec.mjspackages/js-evo-sdk/tests/unit/sdk.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/js-evo-sdk/tests/functional/wallet.spec.mjspackages/js-evo-sdk/tests/functional/identities.spec.mjspackages/js-evo-sdk/tests/unit/facades/group.spec.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjspackages/js-evo-sdk/tests/functional/tokens.spec.mjs
packages/**/**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/**/**/*.{js,ts,jsx,tsx}: Adhere to ESLint with Airbnb/TypeScript configs for JS/TS code
Use camelCase for JS/TS variables and functions
Use PascalCase for JS/TS classes
Prefer kebab-case filenames within JS packages
Files:
packages/js-evo-sdk/src/tokens/facade.tspackages/js-evo-sdk/src/wallet/functions.tspackages/js-evo-sdk/src/sdk.tspackages/js-evo-sdk/src/group/facade.tspackages/js-evo-sdk/src/identities/facade.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: QuantumExplorer
PR: dashpay/platform#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-06T07:27:01.722Z
Learnt from: shumkov
PR: dashpay/platform#2314
File: packages/wallet-contract/test/bootstrap.js:14-16
Timestamp: 2024-11-06T07:27:01.722Z
Learning: In `packages/wallet-contract/test/bootstrap.js`, for Mocha tests in Node.js, async functions like `loadWasmDpp` can be assigned directly to `beforeAll` without wrapping them in another async function.
Applied to files:
packages/js-evo-sdk/tests/unit/sdk.spec.mjspackages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs
📚 Learning: 2025-02-10T11:26:36.709Z
Learnt from: lklimek
PR: dashpay/platform#2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Applied to files:
packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/js-evo-sdk/src/tokens/facade.tspackages/js-evo-sdk/src/identities/facade.tspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
📚 Learning: 2025-07-28T20:04:48.458Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/index.html:4360-4416
Timestamp: 2025-07-28T20:04:48.458Z
Learning: In packages/wasm-sdk, the wallet helper `derive_key_from_seed_with_path` (Rust function in src/wallet/key_derivation.rs) is synchronous; its JS wrapper returns a value immediately, so `await` is unnecessary.
Applied to files:
packages/js-evo-sdk/src/wallet/functions.ts
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
PR: dashpay/platform#2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
Applied to files:
packages/js-evo-sdk/tests/functional/identities.spec.mjspackages/js-evo-sdk/src/identities/facade.tspackages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.
Applied to files:
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs
🧬 Code graph analysis (10)
packages/js-evo-sdk/tests/functional/group.spec.mjs (1)
packages/js-evo-sdk/tests/functional/identities.spec.mjs (12)
res(14-14)res(19-19)res(24-29)res(34-37)res(42-42)res(47-47)res(52-52)res(57-57)res(62-62)res(67-67)res(75-81)sdk(6-6)
packages/js-evo-sdk/tests/unit/wallet.spec.mjs (1)
packages/js-evo-sdk/src/sdk.ts (1)
wallet(144-144)
packages/js-evo-sdk/tests/unit/sdk.spec.mjs (1)
packages/js-evo-sdk/src/sdk.ts (1)
EvoSDK(34-132)
packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs (2)
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (2)
wasmSdk(5-5)client(6-6)packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (7)
wasmSdk(5-5)wasmSdk(65-65)wasmSdk(83-83)wasmSdk(183-183)wasmSdk(200-200)wasmSdk(216-216)client(6-6)
packages/js-evo-sdk/src/tokens/facade.ts (1)
packages/js-evo-sdk/src/sdk.ts (1)
wasm(65-68)
packages/js-evo-sdk/src/wallet/functions.ts (3)
packages/js-evo-sdk/src/sdk.ts (2)
wallet(144-144)wasm(65-68)packages/js-evo-sdk/tests/functional/wallet.spec.mjs (5)
mnemonic(5-5)mnemonic(11-11)mnemonic(30-30)xpub(36-36)address(39-39)packages/wasm-sdk/tests/unit/derivation.spec.mjs (1)
hardened(86-86)
packages/js-evo-sdk/tests/functional/identities.spec.mjs (2)
packages/js-evo-sdk/tests/functional/group.spec.mjs (1)
sdk(7-7)packages/js-evo-sdk/tests/unit/sdk.spec.mjs (1)
sdk(14-14)
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (2)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (7)
wasmSdk(5-5)wasmSdk(65-65)wasmSdk(83-83)wasmSdk(183-183)wasmSdk(200-200)wasmSdk(216-216)client(6-6)packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs (2)
wasmSdk(5-5)client(6-6)
packages/js-evo-sdk/src/identities/facade.ts (2)
packages/js-evo-sdk/src/sdk.ts (1)
wasm(65-68)packages/rs-drive-proof-verifier/src/proof.rs (1)
purposes(1506-1513)
packages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (2)
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (2)
wasmSdk(5-5)client(6-6)packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs (2)
wasmSdk(5-5)client(6-6)
🔇 Additional comments (34)
packages/js-evo-sdk/tests/unit/wallet.spec.mjs (1)
5-28: LGTM: wallet surface smoke test is solidGood presence/shape checks for all exported helpers.
packages/js-evo-sdk/tests/unit/sdk.spec.mjs (1)
12-17: LGTM: fromWasm factory testAccurately verifies connected state and wasm passthrough.
packages/js-evo-sdk/tests/functional/group.spec.mjs (1)
36-59: LGTM: group facade functional coverageCalls map to new facade methods and basic existence assertions are fine.
packages/js-evo-sdk/tests/unit/facades/tokens.spec.mjs (1)
22-23: LGTM: tokens facade forwarding + calculateId
- Stubs for identity-based balances align with wasm names.
- calculateId expectation is deterministic.
- Forwarding assertions cover the added methods thoroughly.
Also applies to: 48-51, 61-92
packages/js-evo-sdk/tests/functional/tokens.spec.mjs (1)
13-17: LGTM: functional tests for calculateId and identityBalancesBoth additions exercise the new public API as intended.
Also applies to: 33-37
packages/js-evo-sdk/tests/functional/identities.spec.mjs (1)
33-69: LGTM: identities facade proof/non‑proof and lookupsGood coverage for newly exposed methods; parameters match expected shapes.
packages/js-evo-sdk/src/tokens/facade.ts (3)
1-1: LGTM: wasm importImporting the wasm namespace is appropriate for using static helpers.
12-14: LGTM: calculateId via wasm static helperPure utility fits well here.
52-60: LGTM: identity balances (with/without proof)Forwarding to wasm with connected instance is correct.
packages/js-evo-sdk/tests/functional/wallet.spec.mjs (1)
1-47: LGTM: wallet helpers functional suiteSolid end‑to‑end checks across mnemonic, derivation, addresses, and signing with sensible skips.
packages/js-evo-sdk/src/sdk.ts (3)
115-117: Expose wasm version: LGTMAccurate delegation to the underlying Wasm SDK.
119-121: Static log level passthrough: LGTMMatches wasm API expectations; safe for consumers.
123-125: Latest version passthrough: LGTMSimple, correct delegation to the builder.
packages/js-evo-sdk/tests/unit/facades/group.spec.mjs (7)
14-27: Stub setup is comprehensive: LGTMCovers all newly forwarded group methods including proof variants.
34-39: info/infoWithProof forwarding assertions: LGTM
41-46: infos/infosWithProof defaults to nulls: LGTM
48-53: members/membersWithProof arg mapping: LGTM
55-62: identityGroups forwarding with optional filters: LGTM
64-73: actions/actionSigners forwarding and defaults: LGTM
75-80: groupsDataContracts forwarding: LGTMpackages/js-evo-sdk/src/identities/facade.ts (4)
53-101: Nonce/balance/contract helpers: LGTMConsistent forwarding and null-normalization.
103-123: Public key hash lookups: LGTMArgument mapping matches wasm methods.
125-137: contractKeys forwarding with Uint32Array conversion: LGTMGood use of typed array for purposes.
139-147: tokenBalances forwarding: LGTMpackages/js-evo-sdk/tests/unit/facades/identities.spec.mjs (9)
18-36: Stub setup aligns with added facade methods: LGTM
75-91: getKeysWithProof(specific) forwarding: LGTMCovers Uint32Array conversion and args.
92-97: nonce helpers: LGTM
99-104: contractNonce helpers: LGTM
106-115: balance/balances helpers: LGTM
117-122: balanceAndRevision helpers: LGTM
124-133: public key hash lookups: LGTM
135-144: contractKeys tests validate Uint32Array conversion: LGTM
146-151: tokenBalances tests: LGTMpackages/js-evo-sdk/src/wallet/functions.ts (1)
20-22: Incorrect — deriveKeyFromSeedWithPath expects a mnemonic (string), not a seed
packages/wasm-sdk/src/wallet/key_derivation.rs: derive_key_from_seed_with_path(mnemonic: &str, passphrase: Option, path: &str, network: &str) calls mnemonicToSeed internally; the JS wrapper packages/js-evo-sdk/src/wallet/functions.ts:20–22 is correct.Likely an incorrect or invalid review comment.
Issue being fixed or feature implemented
Many of the WASM SDK methods weren't exposed in Evo SDK
What was done?
How Has This Been Tested?
Added unit and functional tests
Breaking Changes
None
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit