Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#388): require collateral only for plutus scripts & ignore for n… #389

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading