@hardkas/sdk 0.8.14-alpha → 0.8.15-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 +35 -4
- package/package.json +14 -13
package/dist/index.js
CHANGED
|
@@ -201,6 +201,16 @@ var HardkasTx = class {
|
|
|
201
201
|
feeRateSompiPerMass: options.feeRate ?? 1n
|
|
202
202
|
});
|
|
203
203
|
const isSimulated = activeNetwork === "simulated" || this.sdk.config.config.networks?.[activeNetwork]?.kind === "simulated";
|
|
204
|
+
let resolvedAssumptionLevel = options.assumption;
|
|
205
|
+
if (!resolvedAssumptionLevel) {
|
|
206
|
+
if (isSimulated) {
|
|
207
|
+
resolvedAssumptionLevel = "local-simulated";
|
|
208
|
+
} else if (activeNetwork === "simnet") {
|
|
209
|
+
resolvedAssumptionLevel = "local-rpc";
|
|
210
|
+
} else {
|
|
211
|
+
resolvedAssumptionLevel = activeNetwork;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
204
214
|
const basePlan = createTxPlanArtifact({
|
|
205
215
|
networkId: activeNetwork,
|
|
206
216
|
mode: isSimulated ? "simulated" : "real",
|
|
@@ -215,7 +225,11 @@ var HardkasTx = class {
|
|
|
215
225
|
},
|
|
216
226
|
amountSompi,
|
|
217
227
|
plan: builderPlan,
|
|
218
|
-
ctx:
|
|
228
|
+
ctx: {
|
|
229
|
+
...systemRuntimeContext,
|
|
230
|
+
...options.workflowId ? { workflowId: options.workflowId } : {},
|
|
231
|
+
assumptionLevel: resolvedAssumptionLevel
|
|
232
|
+
}
|
|
219
233
|
});
|
|
220
234
|
if (options.policy || options.policies) {
|
|
221
235
|
const inputPolicies = options.policies || (options.policy ? [options.policy] : []);
|
|
@@ -254,11 +268,12 @@ var HardkasTx = class {
|
|
|
254
268
|
basePlan.contentHash = newHash;
|
|
255
269
|
if (basePlan.lineage) {
|
|
256
270
|
basePlan.lineage.lineageId = newHash;
|
|
257
|
-
basePlan.lineage.parentArtifactId =
|
|
271
|
+
basePlan.lineage.parentArtifactId = "";
|
|
258
272
|
basePlan.lineage.rootArtifactId = newHash;
|
|
259
273
|
const finalHash = calculateContentHash2(basePlan, CURRENT_HASH_VERSION2);
|
|
260
274
|
basePlan.contentHash = finalHash;
|
|
261
275
|
basePlan.lineage.artifactId = finalHash;
|
|
276
|
+
basePlan.planId = `plan-${finalHash.slice(0, 16)}`;
|
|
262
277
|
}
|
|
263
278
|
this.sdk.artifacts.cacheArtifact(basePlan);
|
|
264
279
|
if (basePlan.policyRefs && basePlan.policyRefs.length > 0) {
|
|
@@ -509,7 +524,14 @@ var HardkasTx = class {
|
|
|
509
524
|
*/
|
|
510
525
|
async simulate(target, options = {}) {
|
|
511
526
|
if (typeof target === "object" && target !== null && target.contentHash) {
|
|
512
|
-
|
|
527
|
+
try {
|
|
528
|
+
await this.sdk.artifacts.verify(target, { throwOnInvalid: true, strict: true, enforceMetadata: false });
|
|
529
|
+
} catch (e) {
|
|
530
|
+
if (e.message.includes("PARENT_MISSING")) {
|
|
531
|
+
throw new Error("parent_plan_unresolved: Missing context plan for simulation.");
|
|
532
|
+
}
|
|
533
|
+
throw e;
|
|
534
|
+
}
|
|
513
535
|
}
|
|
514
536
|
const persist = options.persist ?? true;
|
|
515
537
|
if (typeof target === "object" && target !== null) {
|
|
@@ -628,6 +650,8 @@ var HardkasTx = class {
|
|
|
628
650
|
confirmedAt: simResult.receipt.createdAt,
|
|
629
651
|
rpcUrl: "simulated://local",
|
|
630
652
|
tracePath,
|
|
653
|
+
...planArtifact.workflowId ? { workflowId: planArtifact.workflowId } : {},
|
|
654
|
+
...planArtifact.assumptionLevel ? { assumptionLevel: planArtifact.assumptionLevel } : {},
|
|
631
655
|
lineage: {
|
|
632
656
|
artifactId: "",
|
|
633
657
|
// To be computed
|
|
@@ -700,7 +724,14 @@ var HardkasTx = class {
|
|
|
700
724
|
*/
|
|
701
725
|
async send(signedArtifact, urlOrOptions) {
|
|
702
726
|
if (typeof signedArtifact === "object" && signedArtifact !== null && signedArtifact.contentHash) {
|
|
703
|
-
|
|
727
|
+
try {
|
|
728
|
+
await this.sdk.artifacts.verify(signedArtifact, { throwOnInvalid: true, strict: true, enforceMetadata: false });
|
|
729
|
+
} catch (e) {
|
|
730
|
+
if (e.message.includes("PARENT_MISSING")) {
|
|
731
|
+
throw new Error("parent_plan_unresolved: Missing context plan for simulation.");
|
|
732
|
+
}
|
|
733
|
+
throw e;
|
|
734
|
+
}
|
|
704
735
|
}
|
|
705
736
|
const verification = verifySignedTxSemantics(signedArtifact);
|
|
706
737
|
if (!verification.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.15-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -23,18 +23,19 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@hardkas/
|
|
28
|
-
"@hardkas/
|
|
29
|
-
"@hardkas/
|
|
30
|
-
"@hardkas/kaspa-rpc": "0.8.
|
|
31
|
-
"@hardkas/
|
|
32
|
-
"@hardkas/
|
|
33
|
-
"@hardkas/
|
|
34
|
-
"@hardkas/
|
|
35
|
-
"@hardkas/query": "0.8.
|
|
36
|
-
"@hardkas/
|
|
37
|
-
"@hardkas/
|
|
26
|
+
"@kaspa/core-lib": "^1.6.5",
|
|
27
|
+
"@hardkas/accounts": "0.8.15-alpha",
|
|
28
|
+
"@hardkas/artifacts": "0.8.15-alpha",
|
|
29
|
+
"@hardkas/config": "0.8.15-alpha",
|
|
30
|
+
"@hardkas/kaspa-rpc": "0.8.15-alpha",
|
|
31
|
+
"@hardkas/core": "0.8.15-alpha",
|
|
32
|
+
"@hardkas/l2": "0.8.15-alpha",
|
|
33
|
+
"@hardkas/localnet": "0.8.15-alpha",
|
|
34
|
+
"@hardkas/query": "0.8.15-alpha",
|
|
35
|
+
"@hardkas/query-store": "0.8.15-alpha",
|
|
36
|
+
"@hardkas/tx-builder": "0.8.15-alpha",
|
|
37
|
+
"@hardkas/simulator": "0.8.15-alpha",
|
|
38
|
+
"@hardkas/wallet-adapter": "0.8.15-alpha"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"tsup": "^8.3.5",
|