fix: repair root typecheck and pin lint/format tooling#93
Conversation
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.
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.
Fetch the identity after resolving its ID and print the balance, converting credits to DASH (1000 credits = 1 duff, 1e8 duffs = 1 DASH).
📝 WalkthroughWalkthroughThis PR updates build tooling to use locally installed binaries, expands the SDK type surface with key and address management APIs, and enhances the wallet script to fetch and display identity balance information from the Dash network. ChangesWallet Balance Display Feature
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@setupDashClient-core.d.mts`:
- Around line 162-167: The added type declarations for non-exported symbols must
be removed or replaced to match the installed `@dashevo/evo-sdk` (3.1.0-dev.6):
remove or revert the declarations for AddressKeyManager, KEY_SPECS, dip13KeyPath
and the static IdentityKeyManager.createForNewIdentity signature, and instead
use the actual exported types from the package (EvoSDK and EvoSDKOptions / any
types available in dist/sdk.d.ts); update any references in
setupDashClient-core.d.mts that import or rely on
IdentityKeyManager.createForNewIdentity to use the EvoSDK-provided APIs or
factory functions exposed by EvoSDK/EvoSDKOptions so the declaration file
matches the package's real exports.
In `@view-wallet.mjs`:
- Line 49: The current guard only checks balance !== null which still allows
undefined and leads to NaN when doing Number(balance)/1e11; update the condition
around where balance (derived from identity.balance) is used (the if block that
begins with "if (balance !== null)") to explicitly check for both null and
undefined (e.g., use balance != null or balance !== null && balance !==
undefined) so the conversion Number(balance)/1e11 only runs when balance is
actually present.
- Around line 33-34: sdk.identities.fetch(identityId) can return undefined, so
before reading identity.balance you must guard the fetch result (the identity
variable from sdk.identities.fetch) and handle the case where it's undefined;
verify the wasm.Identity type for the exact shape and nullability of the balance
property and coerce/convert it to the expected primitive (e.g., Number or
string) or default to 0 if absent. Update the code path using identity.balance
to first check for identity !== undefined (or throw/return an error),
assert/extract the confirmed balance type from wasm.Identity, and assign a safe
fallback to balance so downstream code never accesses a property on undefined.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b663337d-61c4-4cc2-931f-90620618fb24
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
package.jsonsetupDashClient-core.d.mtsview-wallet.mjs
Summary
The root
npm run lintwas failing againstsetupDashClient.mjs. This branch fixes the typecheck, pins the tooling it depends on, and adds an identity balance readout toview-wallet.mjs.What changed
setupDashClient-core.d.mtswas added as a narrow typed boundary for the example apps and only declared the subset they consume. Because the roottscresolves this.d.mtsinstead of the JSDoc-typed.mjs, the wrapper failed to typecheck against members it relies on. Declared the missing exports and widenedcreateClient's return to the full SDK surface; the example apps' imports are unaffected.prettierandtypescriptfromnpxto pinneddevDependenciesand pointed thefmt/lintscripts at the local binaries.view-wallet.mjsnow fetches the identity and prints its balance in credits and DASH.Test plan
npm run lintpasses (previously errored)node view-wallet.mjsshows the identity balance lineSummary by CodeRabbit