Skip to content

Commit

Permalink
Merge pull request #389 from sourabhxyz/388-dont-require-collateral-w…
Browse files Browse the repository at this point in the history
…hen-simple-script

feat(#388): require collateral only for plutus scripts & ignore for n…
  • Loading branch information
solidsnakedev authored Nov 5, 2024
2 parents c12c5e3 + 23f1fdd commit 04daa78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-shrimps-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lucid-evolution/lucid": patch
---

add collateral only when Script is not NativeScript
8 changes: 5 additions & 3 deletions packages/lucid/src/tx-builder/internal/CompleteTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ export const complete = (

// Execute programs sequentially
yield* Effect.all(config.programs);
const hasScriptExecutions: boolean = config.scripts.size > 0;
const hasPlutusScriptExecutions: boolean = Array.from(
config.scripts.values(),
).some((value) => value.type !== "Native");
// Set collateral input if there are script executions
if (hasScriptExecutions) {
if (hasPlutusScriptExecutions) {
const collateralInput = yield* findCollateral(
config.lucidConfig.protocolParameters.coinsPerUtxoByte,
setCollateral,
Expand All @@ -141,7 +143,7 @@ export const complete = (
// Second round of coin selection by including script execution costs in fee estimation.
// UPLC evaluation need to be performed again if new inputs are selected during coin selection.
// Because increasing the inputs can increase the script execution budgets.
if (hasScriptExecutions)
if (hasPlutusScriptExecutions)
yield* selectionAndEvaluation(
config,
walletInputs,
Expand Down

0 comments on commit 04daa78

Please sign in to comment.