@hardkas/accounts 0.9.0-alpha → 0.9.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -12
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -124,7 +124,9 @@ function validateAddressPrefix(address) {
|
|
|
124
124
|
const validPrefixes = ["kaspa:", "kaspatest:", "kaspasim:"];
|
|
125
125
|
const hasValidPrefix = validPrefixes.some((prefix) => address.startsWith(prefix));
|
|
126
126
|
if (!hasValidPrefix) {
|
|
127
|
-
const err = new Error(
|
|
127
|
+
const err = new Error(
|
|
128
|
+
`HARDKAS_INVALID_ADDRESS: Invalid address '${address}'. Must start with one of: ${validPrefixes.join(", ")}`
|
|
129
|
+
);
|
|
128
130
|
err.code = "HARDKAS_INVALID_ADDRESS";
|
|
129
131
|
throw err;
|
|
130
132
|
}
|
|
@@ -148,7 +150,9 @@ function validateAddressNetwork(address, networkId, allowMainnet) {
|
|
|
148
150
|
return;
|
|
149
151
|
}
|
|
150
152
|
if (!address.startsWith(expectedPrefix)) {
|
|
151
|
-
const err = new Error(
|
|
153
|
+
const err = new Error(
|
|
154
|
+
`NETWORK_ADDRESS_MISMATCH: Address '${address}' does not match the expected prefix '${expectedPrefix}' for network '${networkId}'.`
|
|
155
|
+
);
|
|
152
156
|
err.code = "NETWORK_ADDRESS_MISMATCH";
|
|
153
157
|
throw err;
|
|
154
158
|
}
|
|
@@ -365,14 +369,18 @@ async function resolveHardkasAccountAddress(accountOrAddress, config, context =
|
|
|
365
369
|
new kaspa.Address(accountOrAddress);
|
|
366
370
|
}
|
|
367
371
|
} catch (e) {
|
|
368
|
-
const err = new Error(
|
|
372
|
+
const err = new Error(
|
|
373
|
+
`HARDKAS_INVALID_ADDRESS: Invalid Kaspa address format or checksum.`
|
|
374
|
+
);
|
|
369
375
|
err.code = "HARDKAS_INVALID_ADDRESS";
|
|
370
376
|
throw err;
|
|
371
377
|
}
|
|
372
378
|
} catch (e) {
|
|
373
379
|
if (e.code === "HARDKAS_INVALID_ADDRESS") throw e;
|
|
374
380
|
if (e.code === "ERR_MODULE_NOT_FOUND" || e.message.includes("Cannot find module") || e.message.includes("kaspa-wasm")) {
|
|
375
|
-
const err = new Error(
|
|
381
|
+
const err = new Error(
|
|
382
|
+
"ADDRESS_VALIDATOR_UNAVAILABLE: The Kaspa address validator backend is not available."
|
|
383
|
+
);
|
|
376
384
|
err.code = "ADDRESS_VALIDATOR_UNAVAILABLE";
|
|
377
385
|
throw err;
|
|
378
386
|
}
|
|
@@ -888,13 +896,17 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
888
896
|
let pkValue = account.privateKeyEnv ? process.env[account.privateKeyEnv] : void 0;
|
|
889
897
|
if (!pkValue && account.privateKey) {
|
|
890
898
|
if (plan.networkId === "mainnet") {
|
|
891
|
-
throw new Error(
|
|
899
|
+
throw new Error(
|
|
900
|
+
`Mainnet guard: Unsafe plaintext privateKey fallback is forbidden on mainnet for account '${account.name}'. Use privateKeyEnv instead.`
|
|
901
|
+
);
|
|
892
902
|
}
|
|
893
903
|
pkValue = account.privateKey;
|
|
894
904
|
}
|
|
895
905
|
if (!pkValue && account.keystorePath) {
|
|
896
906
|
try {
|
|
897
|
-
const keystore = await KeystoreManager.loadEncryptedKeystore(
|
|
907
|
+
const keystore = await KeystoreManager.loadEncryptedKeystore(
|
|
908
|
+
account.keystorePath
|
|
909
|
+
);
|
|
898
910
|
const unlock = await KeystoreManager.decryptEncryptedKeystore(
|
|
899
911
|
keystore,
|
|
900
912
|
DEV_ACCOUNTS_PASSWORD
|
|
@@ -906,12 +918,16 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
906
918
|
}
|
|
907
919
|
}
|
|
908
920
|
if (!pkValue) {
|
|
909
|
-
const err = new Error(
|
|
921
|
+
const err = new Error(
|
|
922
|
+
`DEV_ACCOUNT_KEY_UNAVAILABLE: Missing required private key for account '${account.name}'.`
|
|
923
|
+
);
|
|
910
924
|
err.code = "DEV_ACCOUNT_KEY_UNAVAILABLE";
|
|
911
925
|
throw err;
|
|
912
926
|
}
|
|
913
927
|
if (typeof pkValue !== "string" || pkValue.trim() === "" || !/^[0-9a-fA-F]{64}$/.test(pkValue)) {
|
|
914
|
-
const err = new Error(
|
|
928
|
+
const err = new Error(
|
|
929
|
+
"INVALID_PRIVATE_KEY_MATERIAL: Private key must be a valid 64-character hex string."
|
|
930
|
+
);
|
|
915
931
|
err.code = "INVALID_PRIVATE_KEY_MATERIAL";
|
|
916
932
|
throw err;
|
|
917
933
|
}
|
|
@@ -1137,7 +1153,9 @@ var KaspaSdkKeyGenerator = class {
|
|
|
1137
1153
|
const privateKeyStr = typeof kp.privateKey === "object" ? hex : kp.privateKey;
|
|
1138
1154
|
const publicKeyStr = typeof kp.publicKey === "object" ? kp.publicKey.toString() : kp.publicKey;
|
|
1139
1155
|
if (typeof privateKeyStr !== "string" || !/^[0-9a-f]{64}$/i.test(privateKeyStr)) {
|
|
1140
|
-
throw new Error(
|
|
1156
|
+
throw new Error(
|
|
1157
|
+
"Generated private key is not a valid 64-character hex string."
|
|
1158
|
+
);
|
|
1141
1159
|
}
|
|
1142
1160
|
return {
|
|
1143
1161
|
address,
|
|
@@ -1165,7 +1183,12 @@ async function createLocalKaspaWallet(options) {
|
|
|
1165
1183
|
}
|
|
1166
1184
|
|
|
1167
1185
|
// src/fixture-signer.ts
|
|
1168
|
-
import {
|
|
1186
|
+
import {
|
|
1187
|
+
calculateContentHash as calculateContentHash3,
|
|
1188
|
+
HARDKAS_VERSION as HARDKAS_VERSION3,
|
|
1189
|
+
ARTIFACT_VERSION as ARTIFACT_VERSION2,
|
|
1190
|
+
CURRENT_HASH_VERSION
|
|
1191
|
+
} from "@hardkas/artifacts";
|
|
1169
1192
|
function toHex2(arr) {
|
|
1170
1193
|
return Buffer.from(arr).toString("hex");
|
|
1171
1194
|
}
|
|
@@ -1215,7 +1238,9 @@ var HardkasFixtureSigner = class {
|
|
|
1215
1238
|
try {
|
|
1216
1239
|
return await import("kaspa-wasm");
|
|
1217
1240
|
} catch (e) {
|
|
1218
|
-
const err = new Error(
|
|
1241
|
+
const err = new Error(
|
|
1242
|
+
"SIGNER_BACKEND_UNAVAILABLE: Official Kaspa WASM backend is required to sign transactions.\nInstall it via: npm install kaspa-wasm"
|
|
1243
|
+
);
|
|
1219
1244
|
err.code = "SIGNER_BACKEND_UNAVAILABLE";
|
|
1220
1245
|
throw err;
|
|
1221
1246
|
}
|
|
@@ -1237,7 +1262,9 @@ var HardkasFixtureSigner = class {
|
|
|
1237
1262
|
}
|
|
1238
1263
|
const spk = u.scriptPublicKey;
|
|
1239
1264
|
if (!spk) {
|
|
1240
|
-
throw new Error(
|
|
1265
|
+
throw new Error(
|
|
1266
|
+
"UTXO is missing scriptPublicKey. Real signing flows must never fabricate cryptographic state."
|
|
1267
|
+
);
|
|
1241
1268
|
}
|
|
1242
1269
|
return {
|
|
1243
1270
|
address: plan.from.address,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/accounts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"hash-wasm": "^4.12.0",
|
|
21
21
|
"kaspa-wasm": "0.13.0",
|
|
22
|
-
"@hardkas/artifacts": "0.9.
|
|
23
|
-
"@hardkas/config": "0.9.
|
|
24
|
-
"@hardkas/core": "0.9.
|
|
25
|
-
"@hardkas/localnet": "0.9.
|
|
22
|
+
"@hardkas/artifacts": "0.9.1-alpha",
|
|
23
|
+
"@hardkas/config": "0.9.1-alpha",
|
|
24
|
+
"@hardkas/core": "0.9.1-alpha",
|
|
25
|
+
"@hardkas/localnet": "0.9.1-alpha"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.3.5",
|