@hardkas/tx-builder 0.6.0-alpha → 0.7.0-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.
Files changed (2) hide show
  1. package/dist/index.js +12 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -67,8 +67,9 @@ function verifyTxPlanSemantics(plan, context = {}) {
67
67
  const addIssue = (code, severity, message, path) => {
68
68
  issues.push({ code, severity, message, ...path ? { path } : {} });
69
69
  };
70
- if (plan.mode === "simulated" && plan.networkId !== "simnet") {
71
- addIssue("ENV_CONSISTENCY_FAILURE", "error", `Environment mismatch: simulated plan must target 'simnet', but targets '${plan.networkId}'`);
70
+ const ePlan = plan;
71
+ if (ePlan.mode === "simulated" && ePlan.networkId !== "simnet") {
72
+ addIssue("ENV_CONSISTENCY_FAILURE", "error", `Environment mismatch: simulated plan must target 'simnet', but targets '${ePlan.networkId}'`);
72
73
  }
73
74
  if (!plan.inputs.every((i) => i.address.includes(":"))) {
74
75
  addIssue("INVALID_ADDRESS_FORMAT", "error", "One or more input addresses are missing prefix (e.g. kaspa:)");
@@ -154,14 +155,18 @@ function verifySignedTxSemantics(signed, plan) {
154
155
  issues.push({ code, severity, message });
155
156
  };
156
157
  if (plan) {
157
- if (signed.sourcePlanId !== plan.planId && signed.sourcePlanId !== plan.contentHash) {
158
+ const ePlan = plan;
159
+ if (signed.sourcePlanId !== ePlan.planId && signed.sourcePlanId !== ePlan.contentHash) {
160
+ addIssue("PLAN_ID_MISMATCH", "critical", `Security violation: sourcePlanId mismatch. Signed sourcePlanId is ${signed.sourcePlanId}, but plan is ${ePlan.planId}`);
158
161
  }
159
- if (BigInt(signed.amountSompi) !== BigInt(plan.amountSompi)) {
160
- addIssue("IMMUTABLE_FIELD_MUTATION", "critical", `Security violation: amountSompi changed from ${plan.amountSompi} to ${signed.amountSompi} after signing`);
162
+ if (ePlan.amountSompi && BigInt(signed.amountSompi) !== BigInt(ePlan.amountSompi)) {
163
+ addIssue("IMMUTABLE_FIELD_MUTATION", "critical", `Security violation: amountSompi changed from ${ePlan.amountSompi} to ${signed.amountSompi} after signing`);
161
164
  }
162
- if (signed.networkId !== plan.networkId) {
163
- addIssue("NETWORK_MISMATCH", "critical", `Security violation: networkId changed from ${plan.networkId} to ${signed.networkId} after signing`);
165
+ if (signed.networkId !== ePlan.networkId) {
166
+ addIssue("NETWORK_MISMATCH", "critical", `Security violation: networkId changed from ${ePlan.networkId} to ${signed.networkId} after signing`);
164
167
  }
168
+ } else {
169
+ addIssue("PLAN_UNAVAILABLE_FOR_LINEAGE_CHECK", "warning", "Source plan is not available in the workspace; skipping lineage check");
165
170
  }
166
171
  if (!signed.signedTransaction?.payload) {
167
172
  addIssue("MISSING_PAYLOAD", "error", "Signed transaction is missing its raw payload");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/tx-builder",
3
- "version": "0.6.0-alpha",
3
+ "version": "0.7.0-alpha",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  ".": "./dist/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@hardkas/core": "0.6.0-alpha"
11
+ "@hardkas/core": "0.7.0-alpha"
12
12
  },
13
13
  "devDependencies": {
14
14
  "tsup": "^8.3.5",