@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 +1 -0
- package/dist/index.js +16 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
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(
|
|
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(
|
|
339
|
-
|
|
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
|
-
|
|
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(
|
|
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.
|
|
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.
|
|
15
|
+
"@hardkas/core": "0.9.2-alpha"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"tsup": "^8.3.5",
|