@hardkas/localnet 0.7.4-alpha → 0.7.5-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.
@@ -2,6 +2,9 @@
2
2
  import fs from "fs/promises";
3
3
  import path from "path";
4
4
  import { existsSync } from "fs";
5
+ import {
6
+ ARTIFACT_SCHEMAS
7
+ } from "@hardkas/artifacts";
5
8
  import { writeFileAtomic } from "@hardkas/core";
6
9
  import { deterministicCompare } from "@hardkas/core";
7
10
  function getDefaultReceiptsDir(cwd = process.cwd()) {
@@ -47,7 +50,9 @@ async function listSimulatedReceipts(options) {
47
50
  try {
48
51
  const txId = path.basename(file, ".json");
49
52
  const receipt = await loadSimulatedReceipt(txId, options);
50
- receipts.push(receipt);
53
+ if (receipt.schema === ARTIFACT_SCHEMAS.TX_RECEIPT) {
54
+ receipts.push(receipt);
55
+ }
51
56
  } catch (e) {
52
57
  }
53
58
  }
package/dist/index.d.ts CHANGED
@@ -372,7 +372,7 @@ declare function moveSink(dag: SimulatedDag, newSinkId: string, txProvider: (txI
372
372
  inputs: string[];
373
373
  } | undefined): SimulatedDag;
374
374
  /**
375
- * Deterministic Conflict Resolution (Approximation for 0.7.4-alpha)
375
+ * Deterministic Conflict Resolution (Approximation for 0.7.5-alpha)
376
376
  * Priority:
377
377
  * 1. sink ancestry priority (is part of selectedPathToSink?)
378
378
  * 2. deterministic block order (daaScore then block ID)
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  listSimulatedReceipts,
5
5
  loadSimulatedReceipt,
6
6
  saveSimulatedReceipt
7
- } from "./chunk-BPFCWLVJ.js";
7
+ } from "./chunk-2YOFWE4E.js";
8
8
  import {
9
9
  getDefaultTracesDir,
10
10
  getTracePath,
@@ -449,7 +449,7 @@ function applySimulatedPayment(state, input, ctx) {
449
449
  }
450
450
  const unspent = getSpendableUtxos(state, fromAddress);
451
451
  if (unspent.length === 0) {
452
- throw new Error(`Insufficient funds: no unspent UTXOs for ${fromAddress}`);
452
+ throw new Error("insufficient simulated funds");
453
453
  }
454
454
  const availableUtxos = unspent.map((u) => {
455
455
  const parts = u.id.split(":");
@@ -477,8 +477,8 @@ function applySimulatedPayment(state, input, ctx) {
477
477
  }
478
478
  for (const id of spentUtxoIds) {
479
479
  const utxo = state.utxos.find((u) => u.id === id);
480
- if (!utxo) throw new Error(`UTXO not found: ${id}`);
481
- if (utxo.spent) throw new Error(`UTXO already spent: ${id}`);
480
+ if (!utxo) throw new Error("missing simulated UTXO");
481
+ if (utxo.spent) throw new Error("invalid simulated input");
482
482
  }
483
483
  const planArtifact = createTxPlanArtifact({
484
484
  networkId: state.networkId || "simnet",
@@ -584,8 +584,8 @@ function applySimulatedPlan(state, planArtifact, ctx, options) {
584
584
  );
585
585
  for (const id of spentUtxoIds) {
586
586
  const utxo = state.utxos.find((u) => u.id === id);
587
- if (!utxo) throw new Error(`UTXO not found: ${id}`);
588
- if (utxo.spent) throw new Error(`UTXO already spent: ${id}`);
587
+ if (!utxo) throw new Error("missing simulated UTXO");
588
+ if (utxo.spent) throw new Error("invalid simulated input");
589
589
  }
590
590
  const nextDaaScore = (BigInt(state.daaScore) + 1n).toString();
591
591
  const txId = options?.txId || generateDeterministicTxId(planArtifact, preStateHash, nextDaaScore);
@@ -752,7 +752,7 @@ function verifyReplay(state, originalPlan, originalReceipt, ctx) {
752
752
  };
753
753
  }
754
754
  async function getSimulatedReplaySummary(txId, options = {}) {
755
- const { loadSimulatedReceipt: loadSimulatedReceipt2 } = await import("./receipts-VDODBRS6.js");
755
+ const { loadSimulatedReceipt: loadSimulatedReceipt2 } = await import("./receipts-IEHNHM4Q.js");
756
756
  const { loadSimulatedTrace: loadSimulatedTrace2 } = await import("./traces-ZUBWSXYB.js");
757
757
  const receipt = await loadSimulatedReceipt2(txId, options);
758
758
  const trace = await loadSimulatedTrace2(txId, options);
@@ -4,7 +4,7 @@ import {
4
4
  listSimulatedReceipts,
5
5
  loadSimulatedReceipt,
6
6
  saveSimulatedReceipt
7
- } from "./chunk-BPFCWLVJ.js";
7
+ } from "./chunk-2YOFWE4E.js";
8
8
  export {
9
9
  getDefaultReceiptsDir,
10
10
  getReceiptPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/localnet",
3
- "version": "0.7.4-alpha",
3
+ "version": "0.7.5-alpha",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -8,12 +8,12 @@
8
8
  ".": "./dist/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@hardkas/artifacts": "0.7.4-alpha",
12
- "@hardkas/core": "0.7.4-alpha",
13
- "@hardkas/simulator": "0.7.4-alpha",
14
- "@hardkas/tx-builder": "0.7.4-alpha",
15
- "@hardkas/query": "0.7.4-alpha",
16
- "@hardkas/kaspa-rpc": "0.7.4-alpha"
11
+ "@hardkas/artifacts": "0.7.5-alpha",
12
+ "@hardkas/core": "0.7.5-alpha",
13
+ "@hardkas/simulator": "0.7.5-alpha",
14
+ "@hardkas/kaspa-rpc": "0.7.5-alpha",
15
+ "@hardkas/query": "0.7.5-alpha",
16
+ "@hardkas/tx-builder": "0.7.5-alpha"
17
17
  },
18
18
  "devDependencies": {
19
19
  "fast-check": "^4.8.0",