Repository navigation
feat: upgrade to evo-sdk v3.1.0-dev.1 with typed API migration - #14
Conversation
Regenerate lock file to remove stale entries from previously removed dependencies. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Migrate all platform operations to the v3.1 SDK API: - Use AssetLockProof.createInstantAssetLockProof() with raw Uint8Array components instead of hex-encoded JSON via fromHex() - Switch to typed constructors (Identity, IdentityPublicKey, IdentityPublicKeyInCreation, IdentitySigner, PlatformAddressSigner) - Replace key.publicKeyData with key.data, key.disabled with key.disabledAt, onPreorder with preorderCallback - Use identity.publicKeys property instead of getPublicKeys() method - Fetch identity before topUp/update/DPNS operations - Add AssetLockProofData type to replace hex proof strings - Pass fundFromAssetLock outputs as plain objects for WASM serde compatibility with reduceOutput fee strategy Co-Authored-By: Claude Opus 4.6 <[email protected]>
The SDK requires private keys for all keys involved in a state transition, not just the signing key. Generated keys' WIFs were available but never passed through to the IdentitySigner. Co-Authored-By: Claude Opus 4.6 <[email protected]>
📝 WalkthroughWalkthroughThis PR migrates the codebase to support Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/platform/identity.ts (1)
258-272:⚠️ Potential issue | 🔴 Critical
topUp()returns a boolean, not a balance—Number(result)will be 0 or 1, not the actual identity balance.The
identities.topUp()method in evo-sdk returns a boolean success indicator, not the updated balance. The current code converts this boolean to a number (yielding 0 or 1), which misrepresents the identity's actual balance to callers. The function signature promises to returnbalance?: number, but cannot fulfill this fromtopUp()alone.Either fetch the updated balance separately after the top-up succeeds, or remove
balancefrom the return type and only return the success flag.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platform/identity.ts` around lines 258 - 272, The code treats sdk.identities.topUp(...) as returning a balance but it actually returns a boolean; change the implementation so after withRetry(() => sdk.identities.topUp(...), retryOptions) succeeds you either (a) call the SDK's balance-fetching method (e.g., sdk.identities.getBalance(identity) or the appropriate method in your SDK) to obtain and return the numeric balance in the returned object, or (b) if no balance API exists, remove the balance field from the return value and only return success: true/false; update the code around sdk.identities.topUp, the result variable, and the function's return type/signature accordingly.
🧹 Nitpick comments (1)
src/platform/identity.ts (1)
18-41: Remove duplicate utility functions and import from established modules.The functions
hash160andhexToBytesare already exported fromsrc/crypto/hash.tsandsrc/utils/hex.tsrespectively. Remove the local implementations and import them instead to eliminate duplication.♻️ Proposed fix — import existing utilities
-import { sha256 } from '@noble/hashes/sha256'; -import { ripemd160 } from '@noble/hashes/ripemd160'; -import type { PublicKeyInfo, IdentityKeyConfig, AssetLockProofData } from '../types.js'; +import type { PublicKeyInfo, IdentityKeyConfig, AssetLockProofData } from '../types.js'; +import { hash160 } from '../crypto/hash.js'; +import { hexToBytes } from '../utils/hex.js'; import { withRetry, type RetryOptions } from '../utils/retry.js'; - -/** - * Compute hash160 (RIPEMD160(SHA256(data))) of a buffer - */ -function hash160(data: Uint8Array): Uint8Array { - return ripemd160(sha256(data)); -} - -function hexToBytes(hex: string): Uint8Array { - if (!hex || hex.length % 2 !== 0) { - throw new Error('Invalid hex string'); - } - const bytes = new Uint8Array(hex.length / 2); - for (let i = 0; i < bytes.length; i++) { - bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); - } - return bytes; -}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platform/identity.ts` around lines 18 - 41, Remove the local implementations of hash160 and hexToBytes and import them from the project's shared utilities instead: delete the functions named hash160 and hexToBytes in this file, add imports for hash160 (from the crypto/hash module) and hexToBytes (from the utils/hex module) at the top of the file, and keep base64ToBytes as-is if no existing utility replaces it; update any local references in this file to use the imported symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/platform/identity.ts`:
- Around line 258-272: The code treats sdk.identities.topUp(...) as returning a
balance but it actually returns a boolean; change the implementation so after
withRetry(() => sdk.identities.topUp(...), retryOptions) succeeds you either (a)
call the SDK's balance-fetching method (e.g.,
sdk.identities.getBalance(identity) or the appropriate method in your SDK) to
obtain and return the numeric balance in the returned object, or (b) if no
balance API exists, remove the balance field from the return value and only
return success: true/false; update the code around sdk.identities.topUp, the
result variable, and the function's return type/signature accordingly.
---
Nitpick comments:
In `@src/platform/identity.ts`:
- Around line 18-41: Remove the local implementations of hash160 and hexToBytes
and import them from the project's shared utilities instead: delete the
functions named hash160 and hexToBytes in this file, add imports for hash160
(from the crypto/hash module) and hexToBytes (from the utils/hex module) at the
top of the file, and keep base64ToBytes as-is if no existing utility replaces
it; update any local references in this file to use the imported symbols.
Upgrade to evo-sdk v3.1.0-dev.1
Migrates all Dash Platform operations to the
@dashevo/evo-sdkv3.1 API surface. The new SDK version introduces typed constructors and changes how asset lock proofs, identity keys, and state transitions are built, requiring updates across the identity, DPNS, and proof modules.Highlights
@dashevo/evo-sdkfrom3.0.0-dev.9to3.1.0-dev.1with regenerated lockfileUint8Arraycomponents viaAssetLockProof.createInstantAssetLockProof(), introducing a newAssetLockProofDatatypeIdentity,IdentityPublicKey,IdentityPublicKeyInCreation,IdentitySigner,PrivateKey) instead of passing loosely-typed JSON stringskey.publicKeyData→key.data,key.disabled→key.disabledAt,onPreorder→preorderCallbackIdentitySignerso the SDK can sign transitions for all involved keysFiles Changed
src/platform/identity.ts— Rewrite create/topUp/update to use typed SDK APIsrc/platform/dpns.ts— Adapt DPNS registration and key queries to new SDKsrc/proof/builder.ts— Simplify to return raw proof components instead of hex-encoded JSONsrc/types.ts— AddAssetLockProofDatainterface, updateBridgeStatesrc/ui/state.ts— Update proof type in state transitionssrc/main.ts— PassprivateKeyWifthrough for identity key updatesTesting
Tested locally
Co-Authored-By: Claude Opus 4.6 [email protected]
Summary by CodeRabbit
Chores
Refactor