Skip to content

Commit

Permalink
fixed payToWithData
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 19, 2025
1 parent 118e355 commit 6184ce1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Binary file modified src/core/libs/lucid_core/pkg/lucid_core_bg.wasm
Binary file not shown.
18 changes: 14 additions & 4 deletions src/core/libs/lucid_core/src/instruction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,13 @@ impl InstructionBuilder {
_ => (None, None),
};

let mut utxo =
Utxo::from_output(address, assets, datum_hash, datum, script_ref);
let mut utxo = Utxo::from_output(
address,
assets,
datum_hash,
datum,
script_ref.map(|s| s.try_double_cbor()).transpose()?,
);
utxo.required_lovelace_mut(self.protocol_parameters.coins_per_utxo_byte);

if utxo.size_assets() > self.protocol_parameters.max_val_size {
Expand Down Expand Up @@ -350,8 +355,13 @@ impl InstructionBuilder {
DatumVariant::Inline(data) => (None, Some(data)),
};

let mut utxo =
Utxo::from_output(address, assets, datum_hash, datum, script_ref);
let mut utxo = Utxo::from_output(
address,
assets,
datum_hash,
datum,
script_ref.map(|s| s.try_double_cbor()).transpose()?,
);
utxo.required_lovelace_mut(self.protocol_parameters.coins_per_utxo_byte);

if utxo.size_assets() > self.protocol_parameters.max_val_size {
Expand Down
4 changes: 2 additions & 2 deletions src/core/libs/lucid_core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod tests {
Utils::apply_single_cbor_encoding("480100002221200101").unwrap(),
"480100002221200101"
);
assert!(Utils::apply_single_cbor_encoding("0100002221200101").is_err(),);
assert!(Utils::apply_single_cbor_encoding("0100002221200101").is_err());
}

#[test]
Expand All @@ -94,6 +94,6 @@ mod tests {
Utils::apply_double_cbor_encoding("480100002221200101").unwrap(),
"49480100002221200101"
);
assert!(Utils::apply_double_cbor_encoding("0100002221200101").is_err(),);
assert!(Utils::apply_double_cbor_encoding("0100002221200101").is_err());
}
}
4 changes: 3 additions & 1 deletion src/lucid/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export class Tx {
type: "PayTo",
address,
assets,
datumVariant: datumVariant as DatumVariant | undefined,
datumVariant: Object.keys(datumVariant).length > 0
? datumVariant as DatumVariant
: undefined,
scriptRef,
};
});
Expand Down

0 comments on commit 6184ce1

Please sign in to comment.