From f0875e32f6e21ca4a5821564e0718f510ac78660 Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 10 Jun 2026 16:43:12 -0400 Subject: [PATCH 1/3] fix(types): declare missing core exports to fix root typecheck The setupDashClient-core.d.mts was added as a narrow typed boundary for the example apps and only declared the subset they consume. Node16 resolution makes the root tsc lint resolve this .d.mts instead of the JSDoc-typed .mjs, so the root wrapper failed to typecheck against members it relies on. Declare the missing exports (createForNewIdentity, AddressKeyManager, KEY_SPECS, dip13KeyPath), export ConnectedDashClientLike, and widen createClient's return to ConnectedDashClientLike & EvoSDK so the wrapper sees the full SDK surface. --- setupDashClient-core.d.mts | 44 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/setupDashClient-core.d.mts b/setupDashClient-core.d.mts index 9f238b4..ff75224 100644 --- a/setupDashClient-core.d.mts +++ b/setupDashClient-core.d.mts @@ -1,10 +1,21 @@ import type { DataContract, + EvoSDK, Identity, IdentityPublicKey, IdentitySigner, + PlatformAddress, + PlatformAddressInfo, + PlatformAddressSigner, } from "@dashevo/evo-sdk"; +interface AddressEntry { + address: PlatformAddress; + bech32m: string; + privateKeyWif: string; + path: string; +} + interface ConnectedDocumentLike { revision?: bigint | number | string; toJSON?: () => Record; @@ -25,7 +36,7 @@ interface ConnectedDocumentTokenPaymentInfo { | 2; } -interface ConnectedDashClientLike { +export interface ConnectedDashClientLike { contracts: { fetch(contractId: string): Promise<{ toJSON?: () => Record; @@ -148,6 +159,12 @@ export declare class IdentityKeyManager { network?: string; identityIndex?: number; }): Promise; + static createForNewIdentity(opts: { + sdk: ConnectedDashClientLike; + mnemonic: string; + network?: string; + identityIndex?: number; + }): Promise; readonly identityId: string | null | undefined; getAuth(): Promise<{ identity: Identity; @@ -161,6 +178,29 @@ export declare class IdentityKeyManager { }>; } +export declare class AddressKeyManager { + static create(opts: { + sdk: ConnectedDashClientLike; + mnemonic: string; + network?: string; + count?: number; + }): Promise; + readonly addresses: AddressEntry[]; + readonly primaryAddress: AddressEntry; + getSigner(): PlatformAddressSigner; + getFullSigner(): PlatformAddressSigner; + getInfo(): Promise; + getInfoAt(index: number): Promise; +} + +export declare const KEY_SPECS: readonly unknown[]; + +export declare function dip13KeyPath( + network: string, + identityIndex: number, + keyIndex: number, +): Promise; + export declare function createClient( network?: string, -): Promise; +): Promise; From cf2b9e3d19f39aa46e6097f4e8ae7f9aeea50ba5 Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 10 Jun 2026 16:45:12 -0400 Subject: [PATCH 2/3] chore: pin prettier and typescript as devDependencies Move prettier and typescript from on-the-fly npx invocations to pinned devDependencies, and call the local binaries directly in the fmt and lint scripts. --- package-lock.json | 52 +++++++++++++++++++++++++++++++++++++++++++++-- package.json | 8 +++++--- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 479f51b..4263374 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,9 @@ "@types/node": "25.5.0", "chai": "6.2.2", "eslint": "8.45.0", - "mocha": "11.7.5" + "mocha": "11.7.5", + "prettier": "3.8.1", + "typescript": "4.9.5" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -330,6 +332,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -630,6 +633,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.45.0.tgz", "integrity": "sha512-pd8KSxiQpdYRfYa9Wufvdoct3ZPQQuVuU5O6scNgMuOMYuxvH0IGaYK0wUFjo4UYYQQCUndlXiMbnxopwvvTiw==", "dev": true, + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", @@ -1460,6 +1464,22 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", + "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -1756,6 +1776,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/undici-types": { "version": "7.18.2", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", @@ -2123,7 +2157,8 @@ "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", - "dev": true + "dev": true, + "peer": true }, "acorn-jsx": { "version": "5.3.2", @@ -2325,6 +2360,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.45.0.tgz", "integrity": "sha512-pd8KSxiQpdYRfYa9Wufvdoct3ZPQQuVuU5O6scNgMuOMYuxvH0IGaYK0wUFjo4UYYQQCUndlXiMbnxopwvvTiw==", "dev": true, + "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", @@ -2926,6 +2962,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", + "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", + "dev": true + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -3101,6 +3143,12 @@ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true }, + "typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true + }, "undici-types": { "version": "7.18.2", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", diff --git a/package.json b/package.json index cf57769..6e9d7bf 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "Tutorial code for https://docs.dash.org/platform", "main": "connect.mjs", "scripts": { - "fmt": "npx prettier@3.8.1 --write '**/*.{js,mjs}'", - "lint": "npx -p typescript@4 tsc", + "fmt": "prettier --write '**/*.{js,mjs}'", + "lint": "tsc", "test": "node --test --test-timeout=120000 test/read-only.test.mjs", "test:read-only": "node --test --test-timeout=120000 test/read-only.test.mjs", "test:read-write": "node --test --test-timeout=300000 --test-concurrency=1 test/read-write.test.mjs", @@ -31,6 +31,8 @@ "@types/node": "25.5.0", "chai": "6.2.2", "eslint": "8.45.0", - "mocha": "11.7.5" + "mocha": "11.7.5", + "prettier": "3.8.1", + "typescript": "4.9.5" } } From 9100cd822f54e4b2277ca484763de3ab172e9d89 Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 10 Jun 2026 16:52:16 -0400 Subject: [PATCH 3/3] feat(view-wallet): show identity balance in credits and DASH Fetch the identity after resolving its ID and print the balance, converting credits to DASH (1000 credits = 1 duff, 1e8 duffs = 1 DASH). --- view-wallet.mjs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/view-wallet.mjs b/view-wallet.mjs index e230aae..4826d6c 100644 --- a/view-wallet.mjs +++ b/view-wallet.mjs @@ -22,6 +22,7 @@ try { const { bech32m, path } = addressKeyManager.primaryAddress; let identityId = 'No identity found for this mnemonic'; + let balance = null; try { const keyManager = await IdentityKeyManager.create({ sdk, @@ -29,6 +30,8 @@ try { network, }); identityId = keyManager.identityId; + const identity = await sdk.identities.fetch(identityId); + balance = identity.balance; } catch (e) { if (!e.message?.includes('No identity found for the given mnemonic')) throw e; @@ -43,6 +46,14 @@ try { `https://bridge.thepasta.org/?address=${bech32m}`, ); console.log('Identity ID: ', identityId); + if (balance !== null) { + // 1000 credits = 1 duff, 100_000_000 duffs = 1 Dash + const dash = Number(balance) / 1e11; + console.log( + 'Identity balance:', + `${balance} credits (${dash.toFixed(8)} DASH)`, + ); + } } catch (e) { console.error('Something went wrong:\n', e.message); }