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

Remove Provision of Both Datum and Its Hash #457

Closed
wants to merge 1 commit into from
Closed
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/short-tools-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lucid-evolution/lucid": patch
---

Remove provision of both datum and datum hash, and prioritize inline datum over datum hashes.
7 changes: 5 additions & 2 deletions packages/lucid/src/tx-builder/internal/Read.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Effect, pipe } from "effect";
import { Effect } from "effect";
import { Data } from "@lucid-evolution/plutus";
import { utxoToCore } from "@lucid-evolution/utils";
import { UTxO } from "@lucid-evolution/core-types";
Expand All @@ -16,13 +16,16 @@ export const readFrom = (
Effect.gen(function* () {
if (utxos.length === 0) yield* readError(ERROR_MESSAGE.EMPTY_UTXO);
for (const utxo of utxos) {
if (utxo.datumHash) {
if (utxo.datum && utxo.datumHash) {
utxo.datumHash = undefined;
} else if (utxo.datumHash) {
const data = yield* Effect.tryPromise({
try: () => datumOf(config.lucidConfig.provider, utxo),
catch: (cause) => readError(cause),
});

utxo.datum = Data.to(data);
utxo.datumHash = undefined;
}
const coreUtxo = utxoToCore(utxo);
// An array of unspent transaction outputs to be used as inputs when running uplc eval.
Expand Down
Loading