@hardkas/tx-builder 0.9.0-alpha → 0.9.2-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
@@ -137,6 +137,7 @@ interface TxPlanResult {
137
137
  selectedUtxos: number;
138
138
  selectionStrategy: "largest-first" | "consolidation-smallest-first";
139
139
  purpose?: "wallet-consolidation";
140
+ warnings?: string[];
140
141
  };
141
142
  }
142
143
  declare class TxPlanService {
package/dist/index.js CHANGED
@@ -332,16 +332,23 @@ var TxPlanService = class {
332
332
  }
333
333
  }
334
334
  if (selectedAmount < request.amountSompi) {
335
- throw new Error(`Insufficient funds: needed ${request.amountSompi} sompi but only found ${selectedAmount} sompi across ${selectedInputsCount} UTXOs.`);
335
+ throw new Error(
336
+ `Insufficient funds: needed ${request.amountSompi} sompi but only found ${selectedAmount} sompi across ${selectedInputsCount} UTXOs.`
337
+ );
336
338
  }
337
339
  if (selectedInputsCount > this.maxInputsPerTx) {
338
- const err = new Error(`TOO_MANY_INPUTS_FOR_SINGLE_TX: Transaction requires ${selectedInputsCount} inputs to cover the amount, which exceeds the safe limit of ${this.maxInputsPerTx} inputs.
339
- Hint: Run 'hardkas accounts consolidate' to merge dust UTXOs.`);
340
+ const err = new Error(
341
+ `TOO_MANY_INPUTS_FOR_SINGLE_TX: Transaction requires ${selectedInputsCount} inputs to cover the amount, which exceeds the safe limit of ${this.maxInputsPerTx} inputs.
342
+ Hint: Run 'hardkas accounts consolidate' to merge dust UTXOs.`
343
+ );
340
344
  err.code = "TOO_MANY_INPUTS_FOR_SINGLE_TX";
341
345
  throw err;
342
346
  }
347
+ const warnings = [];
343
348
  if (selectedInputsCount >= this.warnInputs) {
344
- console.warn(`\u26A0\uFE0F WARNING: Transaction requires ${selectedInputsCount} inputs. Consider running 'hardkas accounts consolidate'.`);
349
+ warnings.push(
350
+ `Transaction requires ${selectedInputsCount} inputs. Consider running 'hardkas accounts consolidate'.`
351
+ );
345
352
  }
346
353
  const builderPlan = buildPaymentPlan({
347
354
  fromAddress: request.fromAddress,
@@ -359,7 +366,8 @@ Hint: Run 'hardkas accounts consolidate' to merge dust UTXOs.`);
359
366
  utxoSelection: {
360
367
  totalUtxosSeen: allFetchedUtxos.length,
361
368
  selectedUtxos: selectedInputsCount,
362
- selectionStrategy: "largest-first"
369
+ selectionStrategy: "largest-first",
370
+ warnings
363
371
  }
364
372
  };
365
373
  }
@@ -375,7 +383,9 @@ Hint: Run 'hardkas accounts consolidate' to merge dust UTXOs.`);
375
383
  const estimatedMass = BigInt(request.selectedUtxos.length) * massPerInput + 500n;
376
384
  const expectedFee = estimatedMass * feeRate;
377
385
  if (totalAmount <= expectedFee) {
378
- throw new Error(`Consolidation failed: Total selected UTXO amount (${totalAmount}) is less than or equal to the estimated fee (${expectedFee}).`);
386
+ throw new Error(
387
+ `Consolidation failed: Total selected UTXO amount (${totalAmount}) is less than or equal to the estimated fee (${expectedFee}).`
388
+ );
379
389
  }
380
390
  const outputAmount = totalAmount - expectedFee;
381
391
  const builderPlan = buildPaymentPlan({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/tx-builder",
3
- "version": "0.9.0-alpha",
3
+ "version": "0.9.2-alpha",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@hardkas/core": "0.9.0-alpha"
15
+ "@hardkas/core": "0.9.2-alpha"
16
16
  },
17
17
  "devDependencies": {
18
18
  "tsup": "^8.3.5",