@hardkas/accounts 0.12.0-rc.16 → 0.12.0-rc.18
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/{authorizers-DDHM4SUH.js → authorizers-23P5SD3F.js} +1 -1
- package/dist/{chunk-SYYYAEO7.js → chunk-7U2IIXLY.js} +27 -31
- package/dist/{chunk-EKQU22GY.js → chunk-EJK4QMPM.js} +4 -3
- package/dist/{chunk-AVTGARCA.js → chunk-YBNHOFVX.js} +45 -37
- package/dist/{dev-accounts-K5TPW2TH.js → dev-accounts-F7LATHCT.js} +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -5
- package/dist/{resolve-5JBZXBNN.js → resolve-5G6NEL62.js} +1 -1
- package/package.json +6 -6
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-R5P3WIWR.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveHardkasAccount
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YBNHOFVX.js";
|
|
7
7
|
import {
|
|
8
8
|
loadKaspaWasm
|
|
9
9
|
} from "./chunk-6DPO5V3N.js";
|
|
@@ -15,10 +15,11 @@ import {
|
|
|
15
15
|
import fs from "fs";
|
|
16
16
|
import path from "path";
|
|
17
17
|
import crypto from "crypto";
|
|
18
|
-
import { deterministicCompare } from "@hardkas/core";
|
|
18
|
+
import { deterministicCompare, getNetworkPrefix as getNetworkPrefix2 } from "@hardkas/core";
|
|
19
19
|
|
|
20
20
|
// src/kaspa-wasm-signer.ts
|
|
21
21
|
import { calculateContentHash } from "@hardkas/artifacts";
|
|
22
|
+
import { getNetworkPrefix } from "@hardkas/core";
|
|
22
23
|
var KaspaWasmPrivateKeySigner = class {
|
|
23
24
|
constructor(options) {
|
|
24
25
|
this.options = options;
|
|
@@ -56,7 +57,7 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
56
57
|
if (!pkValue && account.keystorePath) {
|
|
57
58
|
try {
|
|
58
59
|
const KeystoreManager2 = (await import("./keystore-CMWEKGBF.js")).KeystoreManager;
|
|
59
|
-
const DEV_ACCOUNTS_PASSWORD2 = (await import("./dev-accounts-
|
|
60
|
+
const DEV_ACCOUNTS_PASSWORD2 = (await import("./dev-accounts-F7LATHCT.js")).DEV_ACCOUNTS_PASSWORD;
|
|
60
61
|
const keystore = await KeystoreManager2.loadEncryptedKeystore(account.keystorePath);
|
|
61
62
|
const unlock = await KeystoreManager2.decryptEncryptedKeystore(keystore, DEV_ACCOUNTS_PASSWORD2);
|
|
62
63
|
if (unlock.success && unlock.payload) {
|
|
@@ -75,8 +76,8 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
75
76
|
err.code = "INVALID_PRIVATE_KEY_MATERIAL";
|
|
76
77
|
throw err;
|
|
77
78
|
}
|
|
78
|
-
const expectedAddress = new sdk.PrivateKey(pkValue).toKeypair().toAddress(plan.networkId || "simnet").toString();
|
|
79
|
-
const { PrivateKeyAuthorizer } = await import("./authorizers-
|
|
79
|
+
const expectedAddress = new sdk.PrivateKey(pkValue).toKeypair().toAddress(getNetworkPrefix(plan.networkId || "simnet")).toString();
|
|
80
|
+
const { PrivateKeyAuthorizer } = await import("./authorizers-23P5SD3F.js");
|
|
80
81
|
const sourceInputs = plan.inputs || plan.selectedUtxos || [];
|
|
81
82
|
for (let i = 0; i < numInputs; i++) {
|
|
82
83
|
if (!authorizers[i]) {
|
|
@@ -93,7 +94,6 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
try {
|
|
96
|
-
console.log("DEBUG PLAN INPUTS:", JSON.stringify(plan.inputs || plan.selectedUtxos, null, 2));
|
|
97
97
|
const sourceInputs = plan.inputs || plan.selectedUtxos || [];
|
|
98
98
|
const utxos = sourceInputs.map((u) => {
|
|
99
99
|
if (!u.outpoint.transactionId || u.outpoint.index === void 0) {
|
|
@@ -105,15 +105,27 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
105
105
|
"UTXO is missing scriptPublicKey. Real signing flows must never fabricate cryptographic state."
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
|
+
let spkHex = "";
|
|
109
|
+
let spkVersion = 0;
|
|
110
|
+
if (typeof spk === "object" && spk !== null) {
|
|
111
|
+
spkVersion = Number(spk.version ?? 0);
|
|
112
|
+
spkHex = String(spk.scriptPublicKey || spk.script || "");
|
|
113
|
+
} else {
|
|
114
|
+
spkHex = String(spk);
|
|
115
|
+
if (/^[0-9a-fA-F]{72}$/.test(spkHex) && spkHex.startsWith("0000")) {
|
|
116
|
+
spkVersion = parseInt(spkHex.slice(0, 4), 16) || 0;
|
|
117
|
+
spkHex = spkHex.slice(4);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
108
120
|
return {
|
|
109
|
-
address: plan.from.address,
|
|
121
|
+
address: u.address || plan.from.address,
|
|
110
122
|
outpoint: {
|
|
111
123
|
transactionId: u.outpoint.transactionId,
|
|
112
124
|
index: u.outpoint.index
|
|
113
125
|
},
|
|
114
126
|
utxoEntry: {
|
|
115
127
|
amount: BigInt(u.amountSompi),
|
|
116
|
-
scriptPublicKey: new sdk.ScriptPublicKey(
|
|
128
|
+
scriptPublicKey: new sdk.ScriptPublicKey(spkVersion, spkHex),
|
|
117
129
|
blockDaaScore: BigInt(u.blockDaaScore || "0"),
|
|
118
130
|
isCoinbase: !!u.isCoinbase
|
|
119
131
|
}
|
|
@@ -142,9 +154,6 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
142
154
|
}
|
|
143
155
|
return new sdk.PaymentOutput(new sdk.Address(o.address), BigInt(o.amountSompi));
|
|
144
156
|
});
|
|
145
|
-
console.log("DEBUG: Calling V1 createTransaction with:", { utxos: utxos.length, wasmOutputs: wasmOutputs.length, priorityFee });
|
|
146
|
-
console.log("DEBUG KASPA-WASM PATH:", import.meta.resolve("kaspa-wasm"));
|
|
147
|
-
console.log("DEBUG CREATE TRANSACTION FN:", sdk.createTransaction.toString());
|
|
148
157
|
unsignedTx = sdk.createTransaction(
|
|
149
158
|
utxos,
|
|
150
159
|
wasmOutputs,
|
|
@@ -183,8 +192,7 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
183
192
|
amount: BigInt(o.amountSompi)
|
|
184
193
|
};
|
|
185
194
|
});
|
|
186
|
-
|
|
187
|
-
const dummyChange = plan.change?.address || plan.from.address;
|
|
195
|
+
const dummyChange = plan.change && plan.change.address || (typeof plan.from === "string" ? plan.from : plan.from?.address) || plan.outputs && plan.outputs[0] && plan.outputs[0].address;
|
|
188
196
|
unsignedTx = sdk.createTransaction(
|
|
189
197
|
utxos,
|
|
190
198
|
wasmOutputs,
|
|
@@ -202,7 +210,6 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
202
210
|
inputs[i].sigOpCount = 0;
|
|
203
211
|
}
|
|
204
212
|
}
|
|
205
|
-
console.log("DEBUG createFreshTx RETURNING:", unsignedTx?.constructor?.name);
|
|
206
213
|
return unsignedTx;
|
|
207
214
|
};
|
|
208
215
|
const inputOverrides = {};
|
|
@@ -245,8 +252,6 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
245
252
|
const finalTx = createFreshTx();
|
|
246
253
|
const signedTx = finalTx;
|
|
247
254
|
const wasmTxStr = typeof signedTx.serializeToJSON === "function" ? signedTx.serializeToJSON() : signedTx.toString();
|
|
248
|
-
console.log("DEBUG wasmTxStr:", wasmTxStr);
|
|
249
|
-
console.log("DEBUG: about to parseWasmTxToRpc");
|
|
250
255
|
const rpcTx = parseWasmTxToRpc(wasmTxStr, signedTx, inputOverrides, plan);
|
|
251
256
|
const rawTx = JSON.stringify(rpcTx);
|
|
252
257
|
return {
|
|
@@ -263,8 +268,6 @@ var KaspaWasmPrivateKeySigner = class {
|
|
|
263
268
|
}
|
|
264
269
|
};
|
|
265
270
|
} catch (error) {
|
|
266
|
-
console.error("DEBUG SIGNING ERROR:", error);
|
|
267
|
-
console.error("DEBUG STACK:", error?.stack || "NO STACK (raw panic)");
|
|
268
271
|
throw new Error(
|
|
269
272
|
`Kaspa WASM signing failed: ${error instanceof Error ? error.stack || error.message : JSON.stringify(error, Object.getOwnPropertyNames(error))}`
|
|
270
273
|
);
|
|
@@ -290,6 +293,8 @@ async function ensureDevAccounts(workspaceDir) {
|
|
|
290
293
|
}
|
|
291
294
|
await getOrCreateDevAccount(workspaceDir, 0, "alice");
|
|
292
295
|
await getOrCreateDevAccount(workspaceDir, 1, "bob");
|
|
296
|
+
await getOrCreateDevAccount(workspaceDir, 2, "carol");
|
|
297
|
+
await getOrCreateDevAccount(workspaceDir, 3, "dave");
|
|
293
298
|
}
|
|
294
299
|
async function getOrCreateDevAccount(workspaceDir, index, alias) {
|
|
295
300
|
const devAccountsDir = path.join(workspaceDir, ".hardkas", "dev-accounts");
|
|
@@ -320,20 +325,11 @@ async function getOrCreateDevAccount(workspaceDir, index, alias) {
|
|
|
320
325
|
let publicKey = "";
|
|
321
326
|
try {
|
|
322
327
|
if (isSimnet) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
kaspaWasm = await import(
|
|
326
|
-
/* @vite-ignore */
|
|
327
|
-
"kaspa-wasm"
|
|
328
|
-
);
|
|
329
|
-
} catch (e) {
|
|
330
|
-
console.warn(`
|
|
331
|
-
[Warning] kaspa-wasm is not installed. Required for simnet.`);
|
|
332
|
-
return { address: "", privateKey: "", publicKey: "" };
|
|
333
|
-
}
|
|
328
|
+
const { loadKaspaWasm: loadKaspaWasm2 } = await import("./signer-backend-W3LNCQA3.js");
|
|
329
|
+
const kaspaWasm = await loadKaspaWasm2();
|
|
334
330
|
const privKey = new kaspaWasm.PrivateKey(privateKeyHex);
|
|
335
331
|
const kp = privKey.toKeypair();
|
|
336
|
-
address = kp.toAddress(network).toString();
|
|
332
|
+
address = kp.toAddress(getNetworkPrefix2(network)).toString();
|
|
337
333
|
publicKey = kp.publicKey;
|
|
338
334
|
privateKey = privateKeyHex;
|
|
339
335
|
} else {
|
|
@@ -355,7 +351,7 @@ async function getOrCreateDevAccount(workspaceDir, index, alias) {
|
|
|
355
351
|
const privKey = new sdk.PrivateKey(privateKeyHex);
|
|
356
352
|
const pubKey = privKey.toPublicKey();
|
|
357
353
|
try {
|
|
358
|
-
address = pubKey.toAddress(network).toString();
|
|
354
|
+
address = pubKey.toAddress(getNetworkPrefix2(network)).toString();
|
|
359
355
|
} catch (e) {
|
|
360
356
|
const msg = e instanceof Error ? e instanceof Error ? e instanceof Error ? e.message : String(e) : String(e) : String(e);
|
|
361
357
|
if (msg.includes("Second argument must be") || msg.includes("Unsupported")) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/authorizers.ts
|
|
2
|
+
import { getNetworkPrefix } from "@hardkas/core";
|
|
2
3
|
var StaticSignatureScriptAuthorizer = class {
|
|
3
4
|
constructor(signatureScript) {
|
|
4
5
|
this.signatureScript = signatureScript;
|
|
@@ -30,7 +31,7 @@ var PrivateKeyAuthorizer = class {
|
|
|
30
31
|
const { wasm, wasmTransaction, inputIndex } = ctx;
|
|
31
32
|
const privateKey = new wasm.PrivateKey(this.privateKeyHex);
|
|
32
33
|
const networkId = context.plan.networkId || "simnet";
|
|
33
|
-
const expectedAddress = privateKey.toKeypair().toAddress(networkId).toString();
|
|
34
|
+
const expectedAddress = privateKey.toKeypair().toAddress(getNetworkPrefix(networkId)).toString();
|
|
34
35
|
if (planInput.address && expectedAddress !== planInput.address) {
|
|
35
36
|
throw new Error(
|
|
36
37
|
`PRIVATE_KEY_DOES_NOT_CONTROL_INPUT: The provided private key for account '${this.accountName}' derives to address '${expectedAddress}', but input ${context.inputIndex} is controlled by '${planInput.address}'.`
|
|
@@ -63,7 +64,7 @@ var LazyAccountAuthorizer = class {
|
|
|
63
64
|
accountName;
|
|
64
65
|
workspaceRoot;
|
|
65
66
|
async authorize(context) {
|
|
66
|
-
const { resolveHardkasAccount } = await import("./resolve-
|
|
67
|
+
const { resolveHardkasAccount } = await import("./resolve-5G6NEL62.js");
|
|
67
68
|
const account = await resolveHardkasAccount({
|
|
68
69
|
nameOrAddress: this.accountName,
|
|
69
70
|
config: { cwd: this.workspaceRoot }
|
|
@@ -75,7 +76,7 @@ var LazyAccountAuthorizer = class {
|
|
|
75
76
|
if (!pkValue && account.keystorePath) {
|
|
76
77
|
try {
|
|
77
78
|
const { KeystoreManager } = await import("./keystore-CMWEKGBF.js");
|
|
78
|
-
const { DEV_ACCOUNTS_PASSWORD } = await import("./dev-accounts-
|
|
79
|
+
const { DEV_ACCOUNTS_PASSWORD } = await import("./dev-accounts-F7LATHCT.js");
|
|
79
80
|
const keystore = await KeystoreManager.loadEncryptedKeystore(account.keystorePath);
|
|
80
81
|
const unlock = await KeystoreManager.decryptEncryptedKeystore(keystore, DEV_ACCOUNTS_PASSWORD);
|
|
81
82
|
if (unlock.success && unlock.payload) {
|
|
@@ -219,7 +219,7 @@ function resolveHardkasAccount(options) {
|
|
|
219
219
|
let alias = nameOrAddress;
|
|
220
220
|
if (alias === "0") alias = "alice";
|
|
221
221
|
if (alias === "1") alias = "bob";
|
|
222
|
-
const accounts = listHardkasAccounts(config);
|
|
222
|
+
const accounts = listHardkasAccounts(config, options.executionTarget);
|
|
223
223
|
const found = accounts.find((a) => a.name === alias);
|
|
224
224
|
if (found) {
|
|
225
225
|
return found;
|
|
@@ -245,24 +245,28 @@ function assertAccountCompatible(account, target) {
|
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
function listHardkasAccounts(config) {
|
|
248
|
+
function listHardkasAccounts(config, executionTarget) {
|
|
249
249
|
const accounts = /* @__PURE__ */ new Map();
|
|
250
250
|
let targetMode = "localnet";
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
251
|
+
if (executionTarget) {
|
|
252
|
+
targetMode = executionTarget.mode;
|
|
253
|
+
} else {
|
|
254
|
+
const execConfig = config?.execution;
|
|
255
|
+
if (execConfig) {
|
|
256
|
+
if (execConfig.mode) {
|
|
257
|
+
targetMode = execConfig.mode;
|
|
258
|
+
} else if (execConfig.default) {
|
|
259
|
+
const targetName = execConfig.default;
|
|
260
|
+
const target = execConfig.targets?.[targetName];
|
|
261
|
+
if (target?.mode) {
|
|
262
|
+
targetMode = target.mode;
|
|
263
|
+
} else if (targetName === "simulator") {
|
|
264
|
+
targetMode = "simulator";
|
|
265
|
+
}
|
|
262
266
|
}
|
|
267
|
+
} else if (config?.defaultNetwork === "simulated") {
|
|
268
|
+
targetMode = "simulator";
|
|
263
269
|
}
|
|
264
|
-
} else if (config?.defaultNetwork === "simulated") {
|
|
265
|
-
targetMode = "simulator";
|
|
266
270
|
}
|
|
267
271
|
const detAccounts = createDeterministicAccounts();
|
|
268
272
|
for (const det of detAccounts) {
|
|
@@ -271,7 +275,7 @@ function listHardkasAccounts(config) {
|
|
|
271
275
|
name: det.name,
|
|
272
276
|
kind: "synthetic",
|
|
273
277
|
executionMode: "simulator",
|
|
274
|
-
address: det.
|
|
278
|
+
address: `kaspa:sim_${det.name}`,
|
|
275
279
|
evmAddress: det.evmAddress
|
|
276
280
|
});
|
|
277
281
|
} else {
|
|
@@ -297,15 +301,23 @@ function listHardkasAccounts(config) {
|
|
|
297
301
|
if (!keystore.metadata?.network) {
|
|
298
302
|
throw new AccountNetworkMismatchError({ expected: "known network", actual: "undefined", detail: `at ${path2.join(devAccountsDir, file)}` });
|
|
299
303
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
304
|
+
if (targetMode === "simulator") {
|
|
305
|
+
accounts.set(name, {
|
|
306
|
+
name,
|
|
307
|
+
kind: "synthetic",
|
|
308
|
+
executionMode: "simulator",
|
|
309
|
+
address: `kaspa:sim_${name}`,
|
|
310
|
+
keystorePath: path2.join(devAccountsDir, file)
|
|
311
|
+
});
|
|
312
|
+
} else {
|
|
313
|
+
accounts.set(name, {
|
|
314
|
+
name,
|
|
315
|
+
kind: "kaspa",
|
|
316
|
+
network: keystore.metadata.network,
|
|
317
|
+
address: keystore.payload?.address || keystore.metadata?.address,
|
|
318
|
+
keystorePath: path2.join(devAccountsDir, file)
|
|
319
|
+
});
|
|
320
|
+
}
|
|
309
321
|
}
|
|
310
322
|
} catch (e) {
|
|
311
323
|
if (e instanceof AccountNetworkMismatchError) throw e;
|
|
@@ -319,19 +331,15 @@ function listHardkasAccounts(config) {
|
|
|
319
331
|
const data = fs2.readFileSync(keystoreJsonPath, "utf-8");
|
|
320
332
|
const ks = JSON.parse(data);
|
|
321
333
|
for (const [name, acc] of Object.entries(ks)) {
|
|
322
|
-
const existing = accounts.get(name);
|
|
323
|
-
const configKind = acc.type === "simulated" ? "synthetic" : "kaspa";
|
|
324
|
-
if (existing && existing.kind !== configKind) {
|
|
325
|
-
console.error(`COLLISION DETECTED for ${name}. existing:`, existing, `configKind:`, configKind, `workspaceRoot:`, workspaceRoot, `keystoreJsonPath:`, keystoreJsonPath);
|
|
326
|
-
throw new CrossWorldAccountCollisionError({ accountId: name, worlds: [existing.kind, configKind] });
|
|
327
|
-
}
|
|
328
334
|
if (acc.type === "simulated") {
|
|
329
|
-
|
|
330
|
-
name,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
+
if (targetMode === "simulator") {
|
|
336
|
+
accounts.set(name, {
|
|
337
|
+
name,
|
|
338
|
+
kind: "synthetic",
|
|
339
|
+
executionMode: "simulator",
|
|
340
|
+
address: acc.address
|
|
341
|
+
});
|
|
342
|
+
}
|
|
335
343
|
} else {
|
|
336
344
|
if (!acc.network) {
|
|
337
345
|
throw new AccountNetworkMismatchError({ expected: "known network", actual: "undefined", detail: "in keystore.json" });
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
ensureDevAccounts,
|
|
5
5
|
getOrCreateDevAccount,
|
|
6
6
|
listDevAccountsSync
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7U2IIXLY.js";
|
|
8
8
|
import "./chunk-R5P3WIWR.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-YBNHOFVX.js";
|
|
10
10
|
import "./chunk-6DPO5V3N.js";
|
|
11
11
|
import "./chunk-YLG2NIAU.js";
|
|
12
12
|
export {
|
package/dist/index.d.ts
CHANGED
|
@@ -151,10 +151,11 @@ declare class SimulatedSigner implements HardkasSigner {
|
|
|
151
151
|
interface ResolveAccountOptions {
|
|
152
152
|
nameOrAddress: string;
|
|
153
153
|
config?: HardkasConfig | undefined;
|
|
154
|
+
executionTarget?: _hardkas_core.HardkasExecutionTarget | undefined;
|
|
154
155
|
}
|
|
155
156
|
declare function resolveHardkasAccount(options: ResolveAccountOptions): HardkasAccount;
|
|
156
157
|
declare function assertAccountCompatible(account: HardkasAccount, target: _hardkas_core.HardkasExecutionTarget): void;
|
|
157
|
-
declare function listHardkasAccounts(config?: HardkasConfig): HardkasAccount[];
|
|
158
|
+
declare function listHardkasAccounts(config?: HardkasConfig, executionTarget?: _hardkas_core.HardkasExecutionTarget): HardkasAccount[];
|
|
158
159
|
declare function resolveHardkasAccountAddress(accountOrAddress: string, config?: HardkasConfig, context?: "L1" | "L2"): Promise<string>;
|
|
159
160
|
declare function describeAccount(account: HardkasAccount): Record<string, unknown>;
|
|
160
161
|
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
ensureDevAccounts,
|
|
7
7
|
getOrCreateDevAccount,
|
|
8
8
|
listDevAccountsSync
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7U2IIXLY.js";
|
|
10
10
|
import "./chunk-R5P3WIWR.js";
|
|
11
11
|
import {
|
|
12
12
|
assertAccountCompatible,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
validateAccountName,
|
|
29
29
|
validateAddressNetwork,
|
|
30
30
|
validateAddressPrefix
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YBNHOFVX.js";
|
|
32
32
|
import {
|
|
33
33
|
detectCapabilities,
|
|
34
34
|
getKaspaSigningBackendStatus,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
LazyAccountAuthorizer,
|
|
42
42
|
PrivateKeyAuthorizer,
|
|
43
43
|
StaticSignatureScriptAuthorizer
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-EJK4QMPM.js";
|
|
45
45
|
|
|
46
46
|
// src/simulated.ts
|
|
47
47
|
var SimulatedSigner = class {
|
|
@@ -238,6 +238,7 @@ async function signTxPlanArtifact(input) {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
// src/kaspa-sdk-keygen.ts
|
|
241
|
+
import { getNetworkPrefix } from "@hardkas/core";
|
|
241
242
|
var KaspaSdkKeyGenerator = class {
|
|
242
243
|
networkId;
|
|
243
244
|
sdkLoader;
|
|
@@ -268,7 +269,7 @@ var KaspaSdkKeyGenerator = class {
|
|
|
268
269
|
const hex = randomBytes.toString("hex");
|
|
269
270
|
const privKey = new sdk.PrivateKey(hex);
|
|
270
271
|
const kp = privKey.toKeypair();
|
|
271
|
-
const address = kp.toAddress(network).toString();
|
|
272
|
+
const address = kp.toAddress(getNetworkPrefix(network)).toString();
|
|
272
273
|
const privateKeyStr = typeof kp.privateKey === "object" ? hex : kp.privateKey;
|
|
273
274
|
const publicKeyStr = typeof kp.publicKey === "object" ? kp.publicKey.toString() : kp.publicKey;
|
|
274
275
|
if (typeof privateKeyStr !== "string" || !/^[0-9a-f]{64}$/i.test(privateKeyStr)) {
|
|
@@ -482,6 +483,7 @@ async function appendToKeystoreJson(workspaceRoot, alias, accountData) {
|
|
|
482
483
|
// src/address-manager.ts
|
|
483
484
|
import { createHash } from "crypto";
|
|
484
485
|
import { createRequire } from "module";
|
|
486
|
+
import { getNetworkPrefix as getNetworkPrefix2 } from "@hardkas/core";
|
|
485
487
|
var require2 = createRequire(import.meta.url);
|
|
486
488
|
function resolveChain(chain) {
|
|
487
489
|
if (chain === "receive" || chain === 0) return 0;
|
|
@@ -516,7 +518,7 @@ var AddressManager = {
|
|
|
516
518
|
try {
|
|
517
519
|
const kaspa = require2("kaspa-wasm");
|
|
518
520
|
const priv = new kaspa.PrivateKey(hash);
|
|
519
|
-
address = priv.toKeypair().toAddress(network).toString();
|
|
521
|
+
address = priv.toKeypair().toAddress(getNetworkPrefix2(network)).toString();
|
|
520
522
|
} catch (e) {
|
|
521
523
|
const prefix = network.includes("sim") ? "kaspasim" : "kaspatest";
|
|
522
524
|
address = `${prefix}:q${hash.slice(0, 42)}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/accounts",
|
|
3
|
-
"version": "0.12.0-rc.
|
|
3
|
+
"version": "0.12.0-rc.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"hash-wasm": "^4.12.0",
|
|
26
26
|
"kaspa-wasm": "0.13.0",
|
|
27
|
-
"@hardkas/artifacts": "0.12.0-rc.
|
|
28
|
-
"@hardkas/
|
|
29
|
-
"@hardkas/
|
|
30
|
-
"@hardkas/
|
|
31
|
-
"@hardkas/localnet": "0.12.0-rc.
|
|
27
|
+
"@hardkas/artifacts": "0.12.0-rc.18",
|
|
28
|
+
"@hardkas/core": "0.12.0-rc.18",
|
|
29
|
+
"@hardkas/config": "0.12.0-rc.18",
|
|
30
|
+
"@hardkas/tx-builder": "0.12.0-rc.18",
|
|
31
|
+
"@hardkas/localnet": "0.12.0-rc.18"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"tsup": "^8.3.5",
|