@hardkas/sdk 0.8.2-alpha → 0.8.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.d.ts +3 -0
- package/dist/index.js +85 -8
- package/package.json +13 -13
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -200,7 +200,7 @@ var HardkasTx = class {
|
|
|
200
200
|
feeRateSompiPerMass: options.feeRate ?? 1n
|
|
201
201
|
});
|
|
202
202
|
const isSimulated = activeNetwork === "simulated" || this.sdk.config.config.networks?.[activeNetwork]?.kind === "simulated";
|
|
203
|
-
|
|
203
|
+
const basePlan = createTxPlanArtifact({
|
|
204
204
|
networkId: activeNetwork,
|
|
205
205
|
mode: isSimulated ? "simulated" : "real",
|
|
206
206
|
from: {
|
|
@@ -216,6 +216,44 @@ var HardkasTx = class {
|
|
|
216
216
|
plan: builderPlan,
|
|
217
217
|
ctx: options.workflowId ? { ...systemRuntimeContext, workflowId: options.workflowId } : systemRuntimeContext
|
|
218
218
|
});
|
|
219
|
+
if (options.policy) {
|
|
220
|
+
try {
|
|
221
|
+
const pol = await this.sdk.artifacts.read(options.policy);
|
|
222
|
+
basePlan.policyRef = pol.contentHash || pol.artifactId || options.policy;
|
|
223
|
+
} catch (e) {
|
|
224
|
+
basePlan.policyRef = options.policy;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (options.networkProfile) {
|
|
228
|
+
try {
|
|
229
|
+
const net = await this.sdk.artifacts.read(options.networkProfile);
|
|
230
|
+
basePlan.networkProfileRef = net.contentHash || net.artifactId || options.networkProfile;
|
|
231
|
+
} catch (e) {
|
|
232
|
+
basePlan.networkProfileRef = options.networkProfile;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (options.assumption) {
|
|
236
|
+
try {
|
|
237
|
+
const asm = await this.sdk.artifacts.read(options.assumption);
|
|
238
|
+
basePlan.assumptionRef = asm.contentHash || asm.artifactId || options.assumption;
|
|
239
|
+
} catch (e) {
|
|
240
|
+
basePlan.assumptionRef = options.assumption;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const { CURRENT_HASH_VERSION: CURRENT_HASH_VERSION2, calculateContentHash: calculateContentHash2 } = await import("@hardkas/artifacts");
|
|
244
|
+
const newHash = calculateContentHash2(basePlan, CURRENT_HASH_VERSION2);
|
|
245
|
+
basePlan.contentHash = newHash;
|
|
246
|
+
if (basePlan.lineage) {
|
|
247
|
+
basePlan.lineage.artifactId = newHash;
|
|
248
|
+
basePlan.lineage.parentArtifactId = newHash;
|
|
249
|
+
basePlan.lineage.rootArtifactId = newHash;
|
|
250
|
+
const finalHash = calculateContentHash2(basePlan, CURRENT_HASH_VERSION2);
|
|
251
|
+
basePlan.contentHash = finalHash;
|
|
252
|
+
basePlan.lineage.artifactId = finalHash;
|
|
253
|
+
basePlan.lineage.parentArtifactId = finalHash;
|
|
254
|
+
basePlan.lineage.rootArtifactId = finalHash;
|
|
255
|
+
}
|
|
256
|
+
return basePlan;
|
|
219
257
|
}
|
|
220
258
|
/**
|
|
221
259
|
* Signs a transaction plan.
|
|
@@ -301,7 +339,7 @@ var HardkasTx = class {
|
|
|
301
339
|
lineage: {
|
|
302
340
|
artifactId: "",
|
|
303
341
|
// To be computed from contentHash
|
|
304
|
-
lineageId: partialTx.lineage?.lineageId ||
|
|
342
|
+
lineageId: partialTx.lineage?.lineageId || partialTx.contentHash || "0".repeat(64),
|
|
305
343
|
parentArtifactId: partialTx.contentHash || partialTx.signedId,
|
|
306
344
|
rootArtifactId: partialTx.lineage?.rootArtifactId || partialTx.sourcePlanId
|
|
307
345
|
}
|
|
@@ -385,7 +423,7 @@ var HardkasTx = class {
|
|
|
385
423
|
lineage: {
|
|
386
424
|
artifactId: "",
|
|
387
425
|
// To be computed
|
|
388
|
-
lineageId: plan.lineage?.lineageId ||
|
|
426
|
+
lineageId: plan.lineage?.lineageId || plan.contentHash || "0".repeat(64),
|
|
389
427
|
parentArtifactId: plan.contentHash || plan.planId,
|
|
390
428
|
rootArtifactId: plan.contentHash || plan.planId
|
|
391
429
|
},
|
|
@@ -546,9 +584,22 @@ var HardkasTx = class {
|
|
|
546
584
|
submittedAt: simResult.receipt.createdAt,
|
|
547
585
|
confirmedAt: simResult.receipt.createdAt,
|
|
548
586
|
rpcUrl: "simulated://local",
|
|
549
|
-
tracePath
|
|
587
|
+
tracePath,
|
|
588
|
+
lineage: {
|
|
589
|
+
artifactId: "",
|
|
590
|
+
// To be computed
|
|
591
|
+
lineageId: targetObj.lineage?.lineageId || targetObj.contentHash || "0".repeat(64),
|
|
592
|
+
parentArtifactId: targetObj.contentHash || "0".repeat(64),
|
|
593
|
+
rootArtifactId: targetObj.lineage?.rootArtifactId || "0".repeat(64),
|
|
594
|
+
sequence: (targetObj.lineage?.sequence || 1) + 1
|
|
595
|
+
}
|
|
550
596
|
};
|
|
551
597
|
receiptBase.contentHash = calculateContentHash(receiptBase, CURRENT_HASH_VERSION);
|
|
598
|
+
if (receiptBase.lineage) {
|
|
599
|
+
receiptBase.lineage.artifactId = receiptBase.contentHash;
|
|
600
|
+
receiptBase.contentHash = calculateContentHash(receiptBase, CURRENT_HASH_VERSION);
|
|
601
|
+
receiptBase.lineage.artifactId = receiptBase.contentHash;
|
|
602
|
+
}
|
|
552
603
|
const receipt = Object.freeze(receiptBase);
|
|
553
604
|
const traceSteps = events.map((ev) => ({
|
|
554
605
|
phase: ev.phase || ev.message || "unknown",
|
|
@@ -687,12 +738,26 @@ var HardkasTx = class {
|
|
|
687
738
|
feeSompi: signedArtifact.metadata?.estimatedFeeSompi || "0",
|
|
688
739
|
submittedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
689
740
|
...url ? { rpcUrl: url } : {},
|
|
690
|
-
...signedArtifact.workflowId ? { workflowId: signedArtifact.workflowId } : {}
|
|
741
|
+
...signedArtifact.workflowId ? { workflowId: signedArtifact.workflowId } : {},
|
|
742
|
+
tracePath: void 0,
|
|
743
|
+
lineage: {
|
|
744
|
+
artifactId: "",
|
|
745
|
+
// To be computed
|
|
746
|
+
lineageId: signedArtifact.lineage?.lineageId || signedArtifact.contentHash || "0".repeat(64),
|
|
747
|
+
parentArtifactId: signedArtifact.contentHash || "0".repeat(64),
|
|
748
|
+
rootArtifactId: signedArtifact.lineage?.rootArtifactId || "0".repeat(64),
|
|
749
|
+
sequence: (signedArtifact.lineage?.sequence || 1) + 1
|
|
750
|
+
}
|
|
691
751
|
};
|
|
692
752
|
realReceiptBase.contentHash = calculateContentHash(
|
|
693
753
|
realReceiptBase,
|
|
694
754
|
CURRENT_HASH_VERSION
|
|
695
755
|
);
|
|
756
|
+
if (realReceiptBase.lineage) {
|
|
757
|
+
realReceiptBase.lineage.artifactId = realReceiptBase.contentHash;
|
|
758
|
+
realReceiptBase.contentHash = calculateContentHash(realReceiptBase, CURRENT_HASH_VERSION);
|
|
759
|
+
realReceiptBase.lineage.artifactId = realReceiptBase.contentHash;
|
|
760
|
+
}
|
|
696
761
|
const receipt = realReceiptBase;
|
|
697
762
|
const receiptPath = getDefaultReceiptPath(receipt.txId, this.sdk.config.cwd);
|
|
698
763
|
await writeArtifact(receiptPath, receipt);
|
|
@@ -997,8 +1062,20 @@ var HardkasReplay = class {
|
|
|
997
1062
|
* against the mathematically reconstructed localnet state.
|
|
998
1063
|
*/
|
|
999
1064
|
async verify(targetOrOptions, options) {
|
|
1065
|
+
const throwOnInvalid = options?.throwOnInvalid !== false;
|
|
1000
1066
|
if (typeof targetOrOptions === "object" && targetOrOptions !== null && targetOrOptions.contentHash) {
|
|
1001
|
-
await this.sdk.artifacts.verify(targetOrOptions, { throwOnInvalid
|
|
1067
|
+
const verifyRes = await this.sdk.artifacts.verify(targetOrOptions, { throwOnInvalid });
|
|
1068
|
+
if (!verifyRes.valid && !throwOnInvalid) {
|
|
1069
|
+
return {
|
|
1070
|
+
passed: false,
|
|
1071
|
+
artifactsScanned: 1,
|
|
1072
|
+
lineage: "invalid",
|
|
1073
|
+
determinism: "failed",
|
|
1074
|
+
contamination: "clean",
|
|
1075
|
+
report: null,
|
|
1076
|
+
error: `Artifact verification failed: ${verifyRes.reason}`
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1002
1079
|
}
|
|
1003
1080
|
let opts = options || {};
|
|
1004
1081
|
if (typeof targetOrOptions === "string") {
|
|
@@ -1757,8 +1834,8 @@ var Hardkas = class _Hardkas {
|
|
|
1757
1834
|
resolveRpcUrl() {
|
|
1758
1835
|
const networkId = this.config.config.defaultNetwork || "simnet";
|
|
1759
1836
|
const target = this.config.config.networks?.[networkId];
|
|
1760
|
-
if (target &&
|
|
1761
|
-
return target.rpcUrl
|
|
1837
|
+
if (target && "rpcUrl" in target && typeof target.rpcUrl === "string") {
|
|
1838
|
+
return target.rpcUrl;
|
|
1762
1839
|
}
|
|
1763
1840
|
return "ws://127.0.0.1:18210";
|
|
1764
1841
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@hardkas/artifacts": "0.8.
|
|
27
|
-
"@hardkas/
|
|
28
|
-
"@hardkas/kaspa-rpc": "0.8.
|
|
29
|
-
"@hardkas/
|
|
30
|
-
"@hardkas/
|
|
31
|
-
"@hardkas/
|
|
32
|
-
"@hardkas/localnet": "0.8.
|
|
33
|
-
"@hardkas/
|
|
34
|
-
"@hardkas/
|
|
35
|
-
"@hardkas/
|
|
36
|
-
"@hardkas/
|
|
37
|
-
"@hardkas/query-store": "0.8.
|
|
26
|
+
"@hardkas/artifacts": "0.8.3-alpha",
|
|
27
|
+
"@hardkas/accounts": "0.8.3-alpha",
|
|
28
|
+
"@hardkas/kaspa-rpc": "0.8.3-alpha",
|
|
29
|
+
"@hardkas/config": "0.8.3-alpha",
|
|
30
|
+
"@hardkas/core": "0.8.3-alpha",
|
|
31
|
+
"@hardkas/l2": "0.8.3-alpha",
|
|
32
|
+
"@hardkas/localnet": "0.8.3-alpha",
|
|
33
|
+
"@hardkas/simulator": "0.8.3-alpha",
|
|
34
|
+
"@hardkas/wallet-adapter": "0.8.3-alpha",
|
|
35
|
+
"@hardkas/query": "0.8.3-alpha",
|
|
36
|
+
"@hardkas/tx-builder": "0.8.3-alpha",
|
|
37
|
+
"@hardkas/query-store": "0.8.3-alpha"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"tsup": "^8.3.5",
|