From 536962702a5e61c8282e7328f50d59d6f6921d69 Mon Sep 17 00:00:00 2001 From: Micah Kendall Date: Sun, 8 Sep 2024 15:28:06 +1000 Subject: [PATCH] patch: recursively reevaluate --- .changeset/bright-pillows-melt.md | 5 +++++ packages/blaze-tx/src/tx.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/bright-pillows-melt.md diff --git a/.changeset/bright-pillows-melt.md b/.changeset/bright-pillows-melt.md new file mode 100644 index 00000000..8078e61c --- /dev/null +++ b/.changeset/bright-pillows-melt.md @@ -0,0 +1,5 @@ +--- +"@blaze-cardano/tx": patch +--- + +patch: evaluate recursively diff --git a/packages/blaze-tx/src/tx.ts b/packages/blaze-tx/src/tx.ts index 2e9c566e..dba145c4 100644 --- a/packages/blaze-tx/src/tx.ts +++ b/packages/blaze-tx/src/tx.ts @@ -1440,10 +1440,10 @@ export class TxBuilder { new Value(-(bigintMax(this.fee, this.minimumFee) + this.feePadding)), ); this.balanceChange(excessValue); + let evaluationFee: bigint = 0n; if (this.redeemers.size() > 0) { this.prepareCollateral(); tw = this.buildTransactionWitnessSet(); - let evaluationFee: bigint = 0n; try { evaluationFee = await this.evaluate(draft_tx); } catch (e) { @@ -1479,6 +1479,7 @@ export class TxBuilder { } let final_size = draft_tx.toCbor().length / 2; do { + const oldEvaluationFee = evaluationFee; this.fee += BigInt( Math.ceil((final_size - draft_size) * this.params.minFeeCoefficient), ); @@ -1504,6 +1505,13 @@ export class TxBuilder { for (const input of selectionResult.selectedInputs) { this.addInput(input); } + draft_tx.setBody(this.body); + if (evaluationFee > 0) { + evaluationFee = await this.evaluate(draft_tx); + if (evaluationFee > oldEvaluationFee) { + continue; + } + } } if (this.body.collateral()) { this.balanceCollateralChange();