@hardkas/sdk 0.7.1-alpha → 0.7.3-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 +65 -15
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -75,16 +75,34 @@ var HardkasTx = class {
|
|
|
75
75
|
if (!fromAccount.address) throw new Error(`From account ${fromAccount.name} has no address.`);
|
|
76
76
|
if (!toAccount.address) throw new Error(`To account ${toAccount.name} has no address.`);
|
|
77
77
|
const amountSompi = typeof options.amount === "string" ? parseKasToSompi(options.amount) : typeof options.amount === "number" ? BigInt(options.amount) : options.amount;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
let builderUtxos = [];
|
|
79
|
+
if (this.sdk.network === "simulated") {
|
|
80
|
+
const { loadOrCreateLocalnetState, getSpendableUtxos } = await import("@hardkas/localnet");
|
|
81
|
+
const localState = await loadOrCreateLocalnetState({ cwd: this.sdk.workspace.root });
|
|
82
|
+
const unspent = getSpendableUtxos(localState, fromAccount.address);
|
|
83
|
+
builderUtxos = unspent.map((u) => {
|
|
84
|
+
const parts = u.id.split(":");
|
|
85
|
+
const index = Number(parts[parts.length - 1]);
|
|
86
|
+
const transactionId = parts.slice(0, -1).join(":");
|
|
87
|
+
return {
|
|
88
|
+
outpoint: { transactionId, index },
|
|
89
|
+
address: u.address,
|
|
90
|
+
amountSompi: BigInt(u.amountSompi),
|
|
91
|
+
scriptPublicKey: "mock-script"
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
const rpcUtxos = await this.sdk.rpc.getUtxosByAddress(fromAccount.address);
|
|
96
|
+
builderUtxos = rpcUtxos.map((u) => ({
|
|
97
|
+
outpoint: {
|
|
98
|
+
transactionId: u.outpoint.transactionId,
|
|
99
|
+
index: u.outpoint.index
|
|
100
|
+
},
|
|
101
|
+
address: u.address,
|
|
102
|
+
amountSompi: u.amountSompi,
|
|
103
|
+
scriptPublicKey: u.scriptPublicKey || ""
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
88
106
|
const builderPlan = buildPaymentPlan({
|
|
89
107
|
fromAddress: fromAccount.address,
|
|
90
108
|
availableUtxos: builderUtxos,
|
|
@@ -213,6 +231,22 @@ var HardkasTx = class {
|
|
|
213
231
|
events,
|
|
214
232
|
receiptPath
|
|
215
233
|
});
|
|
234
|
+
coreEvents.normalizeAndEmit({
|
|
235
|
+
kind: "artifact.created",
|
|
236
|
+
schema: receipt.schema,
|
|
237
|
+
artifactId: receipt.txId,
|
|
238
|
+
network: receipt.networkId,
|
|
239
|
+
mode: receipt.mode,
|
|
240
|
+
path: receiptPath
|
|
241
|
+
});
|
|
242
|
+
coreEvents.normalizeAndEmit({
|
|
243
|
+
kind: "tx.confirmed",
|
|
244
|
+
txId: receipt.txId,
|
|
245
|
+
network: receipt.networkId,
|
|
246
|
+
mode: receipt.mode,
|
|
247
|
+
amountSompi: receipt.amountSompi,
|
|
248
|
+
feeSompi: receipt.feeSompi
|
|
249
|
+
});
|
|
216
250
|
return {
|
|
217
251
|
receipt,
|
|
218
252
|
receiptPath,
|
|
@@ -356,12 +390,28 @@ var HardkasReplay = class {
|
|
|
356
390
|
* against the mathematically reconstructed localnet state.
|
|
357
391
|
*/
|
|
358
392
|
async verify(options) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
393
|
+
let artifactDir = this.sdk.config.cwd;
|
|
394
|
+
let planPath = path.join(artifactDir, "tx-plan.json");
|
|
395
|
+
let receiptPath = path.join(artifactDir, "tx-receipt.json");
|
|
396
|
+
if (options.path) {
|
|
397
|
+
const fullPath = path.resolve(this.sdk.config.cwd, options.path);
|
|
398
|
+
if (fs.existsSync(fullPath)) {
|
|
399
|
+
if (fs.statSync(fullPath).isFile()) {
|
|
400
|
+
planPath = fullPath;
|
|
401
|
+
artifactDir = path.dirname(fullPath);
|
|
402
|
+
receiptPath = fullPath.replace("tx-plan", "tx-receipt");
|
|
403
|
+
} else {
|
|
404
|
+
artifactDir = fullPath;
|
|
405
|
+
planPath = path.join(artifactDir, "tx-plan.json");
|
|
406
|
+
receiptPath = path.join(artifactDir, "tx-receipt.json");
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
throw new Error(`Path not found: ${options.path}`);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (!fs.existsSync(path.join(this.sdk.config.cwd, "hardkas.config.ts"))) {
|
|
413
|
+
throw new Error(`Workspace not found at ${this.sdk.config.cwd}`);
|
|
362
414
|
}
|
|
363
|
-
const planPath = path.join(artifactDir, "tx-plan.json");
|
|
364
|
-
const receiptPath = path.join(artifactDir, "tx-receipt.json");
|
|
365
415
|
const canonicalDirs = [
|
|
366
416
|
path.join(artifactDir, ".hardkas", "receipts"),
|
|
367
417
|
path.join(artifactDir, ".hardkas", "traces"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@hardkas/
|
|
27
|
-
"@hardkas/
|
|
28
|
-
"@hardkas/
|
|
29
|
-
"@hardkas/
|
|
30
|
-
"@hardkas/
|
|
31
|
-
"@hardkas/
|
|
32
|
-
"@hardkas/
|
|
33
|
-
"@hardkas/
|
|
34
|
-
"@hardkas/
|
|
35
|
-
"@hardkas/
|
|
36
|
-
"@hardkas/
|
|
26
|
+
"@hardkas/accounts": "0.7.3-alpha",
|
|
27
|
+
"@hardkas/config": "0.7.3-alpha",
|
|
28
|
+
"@hardkas/core": "0.7.3-alpha",
|
|
29
|
+
"@hardkas/artifacts": "0.7.3-alpha",
|
|
30
|
+
"@hardkas/query": "0.7.3-alpha",
|
|
31
|
+
"@hardkas/l2": "0.7.3-alpha",
|
|
32
|
+
"@hardkas/localnet": "0.7.3-alpha",
|
|
33
|
+
"@hardkas/simulator": "0.7.3-alpha",
|
|
34
|
+
"@hardkas/kaspa-rpc": "0.7.3-alpha",
|
|
35
|
+
"@hardkas/wallet-adapter": "0.7.3-alpha",
|
|
36
|
+
"@hardkas/tx-builder": "0.7.3-alpha"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"tsup": "^8.3.5",
|