@hardkas/artifacts 0.5.3-alpha → 0.5.4-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 CHANGED
@@ -2,7 +2,7 @@ import { ArtifactType, NetworkId, ExecutionMode, ContentHash, WorkflowId, Artifa
2
2
  import { z } from 'zod';
3
3
  import { TxOutput, Utxo, TxPlan as TxPlan$1 } from '@hardkas/tx-builder';
4
4
 
5
- declare const HARDKAS_VERSION = "0.5.3-alpha";
5
+ declare const HARDKAS_VERSION = "0.5.4-alpha";
6
6
  declare const ARTIFACT_SCHEMAS: {
7
7
  readonly LOCALNET_STATE: "hardkas.localnetState.v1";
8
8
  readonly REAL_ACCOUNT_STORE: "hardkas.realAccountStore.v1";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/constants.ts
2
- var HARDKAS_VERSION = "0.5.3-alpha";
2
+ var HARDKAS_VERSION = "0.5.4-alpha";
3
3
  var ARTIFACT_SCHEMAS = {
4
4
  LOCALNET_STATE: "hardkas.localnetState.v1",
5
5
  REAL_ACCOUNT_STORE: "hardkas.realAccountStore.v1",
@@ -513,7 +513,10 @@ async function verifyArtifactIntegrity(artifactOrPath) {
513
513
  addError("FILE_NOT_FOUND", `File not found: ${artifactOrPath}`);
514
514
  return result;
515
515
  }
516
- const content = fs.readFileSync(artifactOrPath, "utf-8");
516
+ let content = fs.readFileSync(artifactOrPath, "utf-8");
517
+ if (content.charCodeAt(0) === 65279) {
518
+ content = content.slice(1);
519
+ }
517
520
  artifact = JSON.parse(content);
518
521
  } else {
519
522
  artifact = artifactOrPath;
@@ -643,13 +646,22 @@ function verifyArtifactSemantics(artifact, context = {}) {
643
646
  const from = v.from;
644
647
  const to = v.to;
645
648
  const addr = from?.address || to?.address;
646
- const expectedPrefix = networkIdStr === "mainnet" ? "kaspa:" : networkIdStr.startsWith("testnet") ? "kaspatest:" : "kaspasim:";
647
- if (addr && typeof addr === "string" && !addr.startsWith(expectedPrefix)) {
648
- addIssue({
649
- code: "NETWORK_ADDRESS_MISMATCH",
650
- severity: "error",
651
- message: `Network/Address mismatch: network is ${networkId} but address is ${addr}`
652
- });
649
+ if (addr && typeof addr === "string") {
650
+ let mismatch = false;
651
+ if (networkIdStr === "mainnet") {
652
+ mismatch = !addr.startsWith("kaspa:") || addr.startsWith("kaspa:sim_");
653
+ } else if (networkIdStr.startsWith("testnet")) {
654
+ mismatch = !addr.startsWith("kaspatest:");
655
+ } else {
656
+ mismatch = !addr.startsWith("kaspa:sim_");
657
+ }
658
+ if (mismatch) {
659
+ addIssue({
660
+ code: "NETWORK_ADDRESS_MISMATCH",
661
+ severity: "error",
662
+ message: `Network/Address mismatch: network is ${networkId} but address is ${addr}`
663
+ });
664
+ }
653
665
  }
654
666
  }
655
667
  return result;
@@ -897,7 +909,10 @@ function getDefaultReceiptPath(txId, cwd = process.cwd()) {
897
909
  }
898
910
  async function readArtifact(filePath) {
899
911
  try {
900
- const content = await fs2.readFile(filePath, "utf-8");
912
+ let content = await fs2.readFile(filePath, "utf-8");
913
+ if (content.charCodeAt(0) === 65279) {
914
+ content = content.slice(1);
915
+ }
901
916
  return JSON.parse(content);
902
917
  } catch (error) {
903
918
  if (error.code === "ENOENT") {
@@ -1108,6 +1123,7 @@ function createSimulatedSignedTxArtifact(plan, payload) {
1108
1123
  from: { address: plan.from.address },
1109
1124
  to: { address: plan.to.address },
1110
1125
  amountSompi: plan.amountSompi,
1126
+ txId: `simulated-${plan.planId}-tx`,
1111
1127
  signedTransaction: {
1112
1128
  format: "simulated",
1113
1129
  payload
@@ -1115,7 +1131,6 @@ function createSimulatedSignedTxArtifact(plan, payload) {
1115
1131
  };
1116
1132
  const hash = calculateContentHash(artifact, CURRENT_HASH_VERSION);
1117
1133
  artifact.signedId = `signed-${hash.slice(0, 16)}`;
1118
- artifact.txId = `simulated-${plan.planId}-${hash.slice(0, 8)}`;
1119
1134
  artifact.contentHash = hash;
1120
1135
  return artifact;
1121
1136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/artifacts",
3
- "version": "0.5.3-alpha",
3
+ "version": "0.5.4-alpha",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Javier Rodriguez",
@@ -24,8 +24,8 @@
24
24
  "types": "./dist/index.d.ts",
25
25
  "dependencies": {
26
26
  "zod": "^3.24.1",
27
- "@hardkas/core": "0.5.3-alpha",
28
- "@hardkas/tx-builder": "0.5.3-alpha"
27
+ "@hardkas/core": "0.5.4-alpha",
28
+ "@hardkas/tx-builder": "0.5.4-alpha"
29
29
  },
30
30
  "devDependencies": {
31
31
  "tsup": "^8.3.5",