Skip to content

Commit

Permalink
fix bug with min output with extra info
Browse files Browse the repository at this point in the history
  • Loading branch information
twwu123 committed Dec 24, 2024
1 parent 95d62a0 commit 415004d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/sidan-csl-rs/src/core/core_csl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,20 @@ impl MeshCSL {
match built_output.amount().multiasset() {
Some(multiasset) => {
if multiasset.len() == 0 {
built_output = csl::TransactionOutput::new(
let mut new_built_output = csl::TransactionOutput::new(
&built_output.address(),
&csl::Value::new(&built_output.amount().coin()),
)
);
if built_output.has_data_hash() {
new_built_output.set_data_hash(&built_output.data_hash().unwrap());
}
if built_output.has_plutus_data() {
new_built_output.set_plutus_data(&built_output.plutus_data().unwrap());
}
if built_output.has_script_ref() {
new_built_output.set_script_ref(&built_output.script_ref().unwrap());
}
built_output = new_built_output;
}
}
None => {}
Expand Down
33 changes: 33 additions & 0 deletions packages/whisky/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,4 +729,37 @@ mod int_tests {
println!("{}", signed_tx);
assert!(mesh.core.mesh_csl.tx_hex != *"");
}

#[test]
fn test_min_output_with_datum() {
let mut mesh = TxBuilder::new(TxBuilderParam {
evaluator: None,
fetcher: None,
submitter: None,
params: None,
});
let signed_tx = mesh
.tx_in(
"2cb57168ee66b68bd04a0d595060b546edf30c04ae1031b883c9ac797967dd85",
3,
&[Asset::new_from_str("lovelace", "9891607895")],
"addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
)
.tx_out(
"addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
&[]
)
.tx_out_inline_datum_value(&WData::JSON(json!({
"constructor": 0,
"fields": []
}).to_string()))
.change_address("addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh")
.signing_key("51022b7e38be01d1cc581230e18030e6e1a3e949a1fdd2aeae5f5412154fe82b")
.complete_sync(None)
.unwrap()
.complete_signing().unwrap();

println!("{}", signed_tx);
assert!(mesh.core.mesh_csl.tx_hex != *"");
}
}

0 comments on commit 415004d

Please sign in to comment.