Skip to content

Commit

Permalink
added missing data from read only utxos
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 20, 2025
1 parent 6184ce1 commit 64e5b64
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Binary file modified src/core/libs/lucid_core/pkg/lucid_core_bg.wasm
Binary file not shown.
14 changes: 8 additions & 6 deletions src/core/libs/lucid_core/src/instruction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ impl InstructionBuilder {
}
Instruction::ReadFrom { utxos } => {
for utxo in utxos {
match (&utxo.datum_hash, &utxo.datum) {
(Some(_), Some(data)) => self.add_data(data)?,
_ => (),
};
match &utxo.script_ref {
Some(script) => {
self.add_language_or_keys(script)?;
Expand Down Expand Up @@ -592,12 +596,10 @@ impl InstructionBuilder {
}

fn add_input(&mut self, utxo: Utxo, redeemer: Option<String>) -> CoreResult<()> {
if let Some(_) = redeemer {
match (&utxo.datum_hash, &utxo.datum) {
(Some(_), Some(data)) => self.add_data(data)?,
_ => (),
};
}
match (&utxo.datum_hash, &utxo.datum) {
(Some(_), Some(data)) => self.add_data(data)?,
_ => (),
};
match &utxo.script_ref {
Some(script) => {
self.add_language_or_keys(script)?;
Expand Down
10 changes: 5 additions & 5 deletions src/lucid/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export class Tx {

/** Read data from utxos. These utxos are only referenced and not spent. */
readFrom(utxos: Utxo[]): Tx {
this.tasks.push(async (that) => {
this.tasks.push(async ({ lucid }) => {
for (const utxo of utxos) {
if (utxo.datumHash) {
utxo.datum = Data.to(await that.lucid.datumOf(utxo));
if (utxo.datumHash && !utxo.datum) {
utxo.datum = Data.to(await lucid.datumOf(utxo));
}
}
return { type: "ReadFrom", utxos };
Expand All @@ -52,10 +52,10 @@ export class Tx {
* With redeemer it's a plutus script input.
*/
collectFrom(utxos: Utxo[], redeemer?: string): Tx {
this.tasks.push(async (that) => {
this.tasks.push(async ({ lucid }) => {
for (const utxo of utxos) {
if (utxo.datumHash && !utxo.datum) {
utxo.datum = Data.to(await that.lucid.datumOf(utxo));
utxo.datum = Data.to(await lucid.datumOf(utxo));
}
}
return { type: "CollectFrom", utxos, redeemer };
Expand Down

0 comments on commit 64e5b64

Please sign in to comment.