Skip to content

Commit b1b32dc

Browse files
thephezclaude
andauthored
chore: remove legacy CJS files, fix env defaults, and improve type annotations (#63)
* chore: remove old sdk files * chore: fix main in package.json * fix: use || instead of ?? for env var defaults to handle empty strings ?? only falls back on null/undefined, so an empty env var (e.g. DATA_CONTRACT_ID='') would be used as-is instead of the intended default. * chore: fmt * chore: fix tsconfig to check setupDashClient with correct ESM settings (#64) * chore: fix tsconfig to check setupDashClient with correct ESM settings Update tsconfig.json to use module/moduleResolution node16 for proper .mjs ESM support, scope include to setupDashClient.mjs only, and set maxNodeModuleJsDepth to 0. Add @types/node and @types/mocha devDeps. Add JSDoc type annotations to setupDashClient.mjs to pass strict tsc check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: replace any types with precise SDK types in setupDashClient Add JSDoc typedef imports for Identity, IdentityPublicKey, PlatformAddress, PlatformAddressInfo, and NetworkLike. Define DerivedKeyEntry and AddressEntry typedefs. Replace all any params/returns with real SDK types. Add missing @returns to create(), convenience signer methods, and exported functions. Add identity-not-found guard in getSigner() with corresponding test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5b85735 commit b1b32dc

21 files changed

Lines changed: 212 additions & 139 deletions

1-Identities-and-Names/identity-retrieve-account-ids.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

1-Identities-and-Names/identity-transfer-credits.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { identity, signer } = await keyManager.getTransfer();
66

77
// Default recipient (testnet). Replace or override via RECIPIENT_ID.
88
const recipientId =
9-
process.env.RECIPIENT_ID ?? '7XcruVSsGQVSgTcmPewaE4tXLutnW1F6PXxwMbo8GYQC';
9+
process.env.RECIPIENT_ID || '7XcruVSsGQVSgTcmPewaE4tXLutnW1F6PXxwMbo8GYQC';
1010
const transferAmount = 100000n; // Credits to transfer
1111

1212
try {

1-Identities-and-Names/identity-update-add-key.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

1-Identities-and-Names/identity-update-disable-key.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

1-Identities-and-Names/identity-update-disable-key.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { sdk, keyManager } = await setupDashClient();
55
const { identity, signer } = await keyManager.getMaster();
66

77
// Replace with one of the identity's existing public key IDs
8-
const DISABLE_KEY_ID = Number(process.env.DISABLE_KEY_ID ?? 99);
8+
const DISABLE_KEY_ID = Number(process.env.DISABLE_KEY_ID || 99);
99

1010
console.log(
1111
`Disabling key ${DISABLE_KEY_ID} on identity ${keyManager.identityId}...`,

1-Identities-and-Names/identity-withdraw-credits.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ console.log('Identity balance before withdrawal:', identity.balance);
88

99
// Default: testnet faucet address. Replace or override via WITHDRAWAL_ADDRESS.
1010
const toAddress =
11-
process.env.WITHDRAWAL_ADDRESS ?? 'yXWJGWuD4VBRMp9n2MtXQbGpgSeWyTRHme';
11+
process.env.WITHDRAWAL_ADDRESS || 'yXWJGWuD4VBRMp9n2MtXQbGpgSeWyTRHme';
1212
const amount = 190000n; // Credits to withdraw
1313
const amountDash = Number(amount) / (1000 * 100000000);
1414

1-Identities-and-Names/name-register.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { sdk, keyManager } = await setupDashClient();
55
const { identity, identityKey, signer } = await keyManager.getAuth();
66

77
// ⚠️ Change this to a unique name to register
8-
const NAME_LABEL = process.env.NAME_LABEL ?? 'alice';
8+
const NAME_LABEL = process.env.NAME_LABEL || 'alice';
99

1010
try {
1111
// Register a DPNS name for the identity

2-Contracts-and-Documents/contract-retrieve-history.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { sdk } = await setupDashClient();
44

55
// Default tutorial contract with history (testnet). Replace or override via DATA_CONTRACT_ID.
66
const DATA_CONTRACT_ID =
7-
process.env.DATA_CONTRACT_ID ??
7+
process.env.DATA_CONTRACT_ID ||
88
'5J4VPym1Bnc2Ap9bbo9wNw6fZLGsCzDM7ZScdzcggN1r';
99

1010
try {

2-Contracts-and-Documents/contract-retrieve.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { sdk } = await setupDashClient();
55

66
// Default tutorial contract (testnet). Replace or override via DATA_CONTRACT_ID.
77
const DATA_CONTRACT_ID =
8-
process.env.DATA_CONTRACT_ID ??
8+
process.env.DATA_CONTRACT_ID ||
99
'FW3DHrQiG24VqzPY4ARenMgjEPpBNuEQTZckV8hbVCG4';
1010

1111
try {

2-Contracts-and-Documents/contract-update-history.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { identityKey, signer } = await keyManager.getAuth();
77
// Edit these values for your environment
88
// Your contract ID from the Register a Data Contract tutorial
99
const DATA_CONTRACT_ID =
10-
process.env.DATA_CONTRACT_ID ?? 'YOUR_DATA_CONTRACT_ID';
10+
process.env.DATA_CONTRACT_ID || 'YOUR_DATA_CONTRACT_ID';
1111
const DOCUMENT_TYPE = 'note';
1212

1313
if (!DATA_CONTRACT_ID || DATA_CONTRACT_ID === 'YOUR_DATA_CONTRACT_ID') {

0 commit comments

Comments
 (0)