diff --git a/packages/Cargo.lock b/packages/Cargo.lock index 603af56..f98e1ac 100644 --- a/packages/Cargo.lock +++ b/packages/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "actix-codec" @@ -1120,6 +1120,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hamming" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" + [[package]] name = "hashbrown" version = "0.12.3" @@ -1964,22 +1970,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "pallas-addresses" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84460293bb3323066e9ce608702750c14f02bc36d41c469e44b3eef5ec0fdbf6" -dependencies = [ - "base58", - "bech32 0.9.1", - "crc", - "cryptoxide", - "hex", - "pallas-codec 0.30.2", - "pallas-crypto 0.30.2", - "thiserror", -] - [[package]] name = "pallas-addresses" version = "0.31.0" @@ -1992,7 +1982,7 @@ dependencies = [ "cryptoxide", "hex", "pallas-codec 0.31.0", - "pallas-crypto 0.31.0", + "pallas-crypto", "thiserror", ] @@ -2022,20 +2012,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "pallas-crypto" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6f8b08e32c7dbb50302222701ae15ef9ac1a7cc39225ce29c253f6ddab2aa7" -dependencies = [ - "cryptoxide", - "hex", - "pallas-codec 0.30.2", - "rand_core 0.6.4", - "serde", - "thiserror", -] - [[package]] name = "pallas-crypto" version = "0.31.0" @@ -2051,22 +2027,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "pallas-primitives" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24929d461308626183d5bf15290e6315f4cc67fa38a1a66469425919683cceb2" -dependencies = [ - "base58", - "bech32 0.9.1", - "hex", - "log", - "pallas-codec 0.30.2", - "pallas-crypto 0.30.2", - "serde", - "serde_json", -] - [[package]] name = "pallas-primitives" version = "0.31.0" @@ -2078,28 +2038,11 @@ dependencies = [ "hex", "log", "pallas-codec 0.31.0", - "pallas-crypto 0.31.0", + "pallas-crypto", "serde", "serde_json", ] -[[package]] -name = "pallas-traverse" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ca94c2278a160c226d6f5bb1756ea5f355421158aaa697445f59f09477a6a4" -dependencies = [ - "hex", - "itertools 0.13.0", - "pallas-addresses 0.30.2", - "pallas-codec 0.30.2", - "pallas-crypto 0.30.2", - "pallas-primitives 0.30.2", - "paste", - "serde", - "thiserror", -] - [[package]] name = "pallas-traverse" version = "0.31.0" @@ -2108,10 +2051,10 @@ checksum = "5d04fc75a2144eb257c68b4604cdde647e07404ea185b791c0005826960dfb35" dependencies = [ "hex", "itertools 0.13.0", - "pallas-addresses 0.31.0", + "pallas-addresses", "pallas-codec 0.31.0", - "pallas-crypto 0.31.0", - "pallas-primitives 0.31.0", + "pallas-crypto", + "pallas-primitives", "paste", "serde", "thiserror", @@ -2887,7 +2830,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "sidan-csl-rs" -version = "0.9.11" +version = "0.9.12" dependencies = [ "cardano-serialization-lib 13.2.0", "cryptoxide", @@ -2896,8 +2839,8 @@ dependencies = [ "js-sys", "noop_proc_macro", "pallas-codec 0.31.0", - "pallas-primitives 0.31.0", - "pallas-traverse 0.31.0", + "pallas-primitives", + "pallas-traverse", "rand_os", "schemars", "serde", @@ -3349,12 +3292,14 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "uplc" -version = "1.1.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a9088742df018693bcdf85de363ba9e0554e0e39cced45b9cfab61b8cd3e2b9" +checksum = "1e54b8261f8127d7d6234e639d8024a40c8734eeae0921661372690c1c2b62d8" dependencies = [ + "bitvec", "blst", "cryptoxide", + "hamming", "hex", "indexmap 1.9.3", "itertools 0.10.5", @@ -3364,11 +3309,11 @@ dependencies = [ "num-integer", "num-traits", "once_cell", - "pallas-addresses 0.31.0", + "pallas-addresses", "pallas-codec 0.31.0", - "pallas-crypto 0.31.0", - "pallas-primitives 0.31.0", - "pallas-traverse 0.31.0", + "pallas-crypto", + "pallas-primitives", + "pallas-traverse", "peg", "pretty", "secp256k1", @@ -3515,7 +3460,7 @@ dependencies = [ [[package]] name = "whisky" -version = "0.9.11" +version = "0.9.12" dependencies = [ "async-trait", "cryptoxide", @@ -3525,8 +3470,8 @@ dependencies = [ "maestro-rust-sdk", "noop_proc_macro", "pallas-codec 0.30.2", - "pallas-primitives 0.30.2", - "pallas-traverse 0.30.2", + "pallas-primitives", + "pallas-traverse", "rand_os", "reqwest 0.12.9", "serde", @@ -3540,7 +3485,7 @@ dependencies = [ [[package]] name = "whisky-examples" -version = "0.9.11" +version = "0.9.12" dependencies = [ "actix-cors", "actix-web", diff --git a/packages/Cargo.toml b/packages/Cargo.toml index 58fa1e1..5dd7433 100644 --- a/packages/Cargo.toml +++ b/packages/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -version = "0.9.11" +version = "0.9.12" resolver = "2" members = [ "sidan-csl-rs", diff --git a/packages/sidan-csl-rs/Cargo.toml b/packages/sidan-csl-rs/Cargo.toml index 73837b1..f868901 100644 --- a/packages/sidan-csl-rs/Cargo.toml +++ b/packages/sidan-csl-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sidan-csl-rs" -version = "0.9.11" +version = "0.9.12" edition = "2021" license = "Apache-2.0" description = "Wrapper around the cardano-serialization-lib for easier transaction building, heavily inspired by cardano-cli APIs" @@ -22,7 +22,7 @@ schemars = "0.8.8" [target.'cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))'.dependencies] # uplc = { version = "=1.0.26-alpha", default-features = false, features = ["native-secp256k1"] } # uplc = "=1.0.26-alpha" -uplc = "=1.1.7" +uplc = "=1.1.9" wasm-bindgen = { version = "=0.2.92", features = ["serde-serialize"] } rand_os = "0.1" noop_proc_macro = "0.3.0" @@ -34,7 +34,7 @@ pallas-traverse = "0.31.0" [target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] serde-wasm-bindgen = "0.4.5" # uplc = { version = "=1.0.26-alpha", default-features = false, features = ["native-secp256k1"] } -uplc = "=1.1.7" +uplc = "=1.1.9" wasm-bindgen = { version = "=0.2.92", features = ["serde-serialize"] } rand_os = { version = "0.1", features = ["wasm-bindgen"] } js-sys = "=0.3.61" diff --git a/packages/sidan-csl-rs/src/core/core_csl.rs b/packages/sidan-csl-rs/src/core/core_csl.rs index d3d5e74..c12f391 100644 --- a/packages/sidan-csl-rs/src/core/core_csl.rs +++ b/packages/sidan-csl-rs/src/core/core_csl.rs @@ -178,7 +178,7 @@ impl MeshCSL { let tx_value = to_value(&output.amount); let amount_builder = output_builder.next()?; - let built_output: csl::TransactionOutput = if tx_value.multiasset().is_some() { + let mut built_output: csl::TransactionOutput = if tx_value.multiasset().is_some() { if tx_value.coin().is_zero() { amount_builder .with_asset_and_min_required_coin_by_utxo_cost( @@ -196,6 +196,17 @@ impl MeshCSL { } else { amount_builder.with_coin(&tx_value.coin()).build()? }; + match built_output.amount().multiasset() { + Some(multiasset) => { + if multiasset.len() == 0 { + built_output = csl::TransactionOutput::new( + &built_output.address(), + &csl::Value::new(&built_output.amount().coin()), + ) + } + } + None => {} + } self.tx_builder.add_output(&built_output)?; Ok(()) } diff --git a/packages/sidan-csl-rs/src/core/utils/evaluator.rs b/packages/sidan-csl-rs/src/core/utils/evaluator.rs index 992d62a..f0007ae 100644 --- a/packages/sidan-csl-rs/src/core/utils/evaluator.rs +++ b/packages/sidan-csl-rs/src/core/utils/evaluator.rs @@ -5,25 +5,24 @@ use uplc::tx::SlotConfig; use crate::core::constants::get_cost_models_from_network; use crate::core::tx_parser::MeshTxParser; +use crate::core::utils::phase_two::{eval_phase_two, PhaseTwoEvalResult}; use crate::csl::{Address, JsError}; -use crate::model::{Action, Asset, Budget, EvalError, EvalResult, JsVecString, Network, RedeemerTag, UTxO, UtxoOutput}; +use crate::model::{ + Action, Asset, Budget, EvalError, EvalResult, JsVecString, Network, RedeemerTag, UTxO, + UtxoOutput, +}; use crate::wasm::WasmResult; use crate::*; use pallas_codec::utils::{Bytes, CborWrap, PositiveCoin}; use pallas_primitives::{ conway::{ - AssetName, Coin, CostModels, DatumOption, PlutusData, PolicyId, PostAlonzoTransactionOutput, - ScriptRef, TransactionOutput, Value, + AssetName, Coin, CostModels, DatumOption, PlutusData, PolicyId, + PostAlonzoTransactionOutput, ScriptRef, TransactionOutput, Value, }, Fragment, }; use pallas_traverse::{Era, MultiEraTx}; -use uplc::{ - tx::error::Error as UplcError, - tx::ResolvedInput, - Hash, TransactionInput, -}; -use crate::core::utils::phase_two::{eval_phase_two, PhaseTwoEvalResult}; +use uplc::{tx::error::Error as UplcError, tx::ResolvedInput, Hash, TransactionInput}; #[wasm_bindgen] pub fn evaluate_tx_scripts_js( @@ -107,17 +106,17 @@ pub fn evaluate_tx_scripts( &SlotConfig::default(), ) .map_err(|err| JsError::from_str(&format!("Error occurred during evaluation: {}", err))) - .map(|reds| { - reds.into_iter() - .map(map_eval_result) - .collect() - }) + .map(|reds| reds.into_iter().map(map_eval_result).collect()) } fn map_eval_result(result: PhaseTwoEvalResult) -> EvalResult { match result { - PhaseTwoEvalResult::Success(redeemer) => EvalResult::Success(map_redeemer_to_action(redeemer)), - PhaseTwoEvalResult::Error(redeemer, err) => EvalResult::Error(map_error_to_eval_error(err, redeemer)), + PhaseTwoEvalResult::Success(redeemer) => { + EvalResult::Success(map_redeemer_to_action(redeemer)) + } + PhaseTwoEvalResult::Error(redeemer, err) => { + EvalResult::Error(map_error_to_eval_error(err, redeemer)) + } } } @@ -133,36 +132,28 @@ fn map_error_to_eval_error(err: UplcError, original_redeemer: Redeemer) -> EvalE error_message: format!("{}", err), logs, }, - UplcError::RedeemerError{err, .. } => { - match *err { - UplcError::Machine(err, budget, logs) => EvalError { - index: original_redeemer.index, - budget: Budget { - mem: budget.mem as u64, - steps: budget.cpu as u64, - }, - tag: map_redeemer_tag(&original_redeemer.tag), - error_message: format!("{}", err), - logs, + UplcError::RedeemerError { err, .. } => match *err { + UplcError::Machine(err, budget, logs) => EvalError { + index: original_redeemer.index, + budget: Budget { + mem: budget.mem as u64, + steps: budget.cpu as u64, }, - _ => EvalError { - index: original_redeemer.index, - budget: Budget { - mem: 0, - steps: 0, - }, - tag: map_redeemer_tag(&original_redeemer.tag), - error_message: format!("{}", err), - logs: vec![], - } - } + tag: map_redeemer_tag(&original_redeemer.tag), + error_message: format!("{}", err), + logs, + }, + _ => EvalError { + index: original_redeemer.index, + budget: Budget { mem: 0, steps: 0 }, + tag: map_redeemer_tag(&original_redeemer.tag), + error_message: format!("{}", err), + logs: vec![], + }, }, _ => EvalError { index: original_redeemer.index, - budget: Budget { - mem: 0, - steps: 0, - }, + budget: Budget { mem: 0, steps: 0 }, tag: map_redeemer_tag(&original_redeemer.tag), error_message: format!("{}", err), logs: vec![], @@ -392,7 +383,8 @@ mod test { let redeemer = match &redeemers[0] { EvalResult::Success(redeemer) => Ok(redeemer), EvalResult::Error(_) => Err("Unexpected error"), - }.unwrap(); + } + .unwrap(); redeemer_json.insert("index".to_string(), redeemer.index.to_string().into()); let mut ex_unit_json = serde_json::Map::new(); @@ -408,6 +400,33 @@ mod test { ) } + #[test] + fn test_eval_2() { + let result = evaluate_tx_scripts( + "84a800d90102818258205fefa1a58e20732f7e55972315dda0123b90e5a1d7f086bc37b566f0f9210229000182a300581d71fe23153596f3415c21374454937dd858b1afcce3ee9c7d43fb05a90f01821a00178b44a1581c9e138ea088768af3d2f1216271f2f41172a96b54780225036bc0475ea14001028201d8185859d8799f1b00000193ae9213085820cff20d3f762fecf4f90a186062263bbe07928bff70d50166be88c4c2bffbd10ed8799fd87a9f581cd649c0eb6532b3649e1a2b358fd83ce5778d1d91fdc8d3f6e0539a20ffd87a80ff03ff825839013354e5941d41d08051005f407b50355a3e7ad6bb983016028baae6a1f3f2436fa221ebc2d81481ee126944d7e11256ea793da594e0e033921a00f19ca6021a000eda89031a0860837005a1581df124f5fe1c897b34180e6dcbc57fa7b2435b4d7cf6e8f3773a3edf08250009a1581c9e138ea088768af3d2f1216271f2f41172a96b54780225036bc0475ea140010b582071c6e77365d456e9ed48e7bfbe4c76a5d7f91a999080624f60d40922661c9fc80dd90102818258205fefa1a58e20732f7e55972315dda0123b90e5a1d7f086bc37b566f0f921022900a301d9010281830303878200581cf800e7ea3e1312cccf402b957e568e0d29786efe3f9cb818caadc7e38200581cfcbb77e221db810dfcbb9c9684c9c23e7f4c25868a20ff0701bf619e8200581c2efaf69bb7551328bb8625684bc1cea922ebc5aeca48df09b7b830458200581c0eaabc8286318f13f45d1eb7383e100964a94a01124b184bde55ba9a8200581c804ff6e71914f1ef08e31c86dc3ee7046424b464a6ee1536b38a04e38200581c21c3bd0ab2357a1879a96b948145fee311015430a68617996901b8bb8200581cd0730dfe0cb0140621dcdf751bbea7b1fb03c5eca57779c3fbc07f1706d9010281590b84590b8101000033332323232323232323232322322232232323232322533300f3232323232325333015300b3017375400226464a66602e66ebcdd30009ba633300500248900480084c94ccc060c038c068dd500089919299980d19b8748010c070dd500089919191919299980f980a98109baa00113232533302153330213375e602060486ea80240705288a998112481366f776e5f6f75747075742e61646472657373203d3d20636f6c645f696e74656e745f686f6c645f61646472657373203f2046616c73650014a02a666042a666042008294454cc0892411174746c5f636865636b203f2046616c73650014a02a666042002294454cc089240117617574686f726974795f636865636b203f2046616c73650014a02940528299981019198008009bab302730283028302830283028302830243754602060486ea804c894ccc0980045280992999811992999812180d18131baa00113375e6054604e6ea800406c54cc0952412465787065637420496e6c696e65286372656429203d207769746864726177616c2e31737400163025302900214a22660060060026052002266e1cdd6981318139813981398119baa00500114a06eb4c094c088dd50008a9981024814265787065637420536f6d6528617574686f726974795f6e756d62657229203d206765745f666972737428617574686f726974795f6d61702c2072656465656d6572290016323300100101b22533302400114c0103d87a8000132323253330233375e034604a006266e95200033028375000297ae0133005005002375a604a0046050004604c0026464a66603e602a0022a6604092012a5472616e73616374696f6e2074746c2073686f756c64206861766520616e20757070657220626f756e6400161533301f30140011337126eb4c094c088dd50011bad300e302237540082a66040921365472616e73616374696f6e20757070657220626f756e642073686f756c646e277420626520706f73697469766520696e66696e697479001630203754002601860406ea8c08cc090c080dd51811981218121812181218121812181218101baa300c3020375401ea6660386024603c6ea80044c94ccc08400454cc078070584c8c94ccc08c00454cc080078584c8c94ccc09400454cc088080584c8c94ccc09c00454cc090088584c94ccc0a0c0ac0084c9265333024301a30263754006264a6660520022a6604c0482c26464a6660560022a6605004c2c264a666058605e0042646493192999815181000089929998178008a998160150b0992999818181980109924c64a66605a6046002264a6660640022a6605e05a2c264a666066606c00426493198118008170a998180170b19299999981b80088008a998180170b0a998180170b0a998180170b0a998180170b181a00098181baa0021533302d30220011325333032001153302f02d16132325333034001153303102f161323253330360011533033031161325333037303a002149854cc0d00c858c94cccccc0ec00454cc0d00c85854cc0d00c85854cc0d00c8584dd68008a9981a0190b181c000981c00119299999981c8008a998190180b0a998190180b0a998190180b09bad00115330320301630360013036002325333333037001153303002e16153303002e16153303002e161375a0022a6606005c2c606800260606ea800854cc0b80b058c0b8dd50008a998168158b19299999981a00088008a998168158b0a998168158b0a998168158b0a998168158b181880098169baa0031533302a301f0011533302e302d37540062930a998158148b0a998158148b18159baa0023301c0030271533029027163253333330300011001153302902716153302902716153302902716153302902716302d001302d00232533333302e0011001153302702516153302702516153302702516153302702516302b001302737540062a6604a0462c2a6604a0462c64a6666660580022a6604a0462c2a6604a0462c2a6604a0462c26eb400454cc09408c58c0a4004c0a4008c94cccccc0a8004400454cc08c0845854cc08c0845854cc08c0845854cc08c08458c09c004c09c008c94cccccc0a000454cc08407c5854cc08407c5854cc08407c5854cc08407c584dd7000981280098128011929999998130008a9980f80e8b0a9980f80e8b0a9980f80e8b09bad001153301f01d163023001301f37540022a6603a0362ca66666604600220022a660380342c2a660380342c2a660380342c2a660380342c6040603a6ea800454cc06d2413665787065637420496e6c696e65446174756d286f776e5f6f75747075745f6461746129203d206f776e5f6f75747075742e646174756d00163006301c3754002603c60366ea800454cc065241146f776e206f7574707574206e6f7420666f756e64001632533301c00114c103d87a800013374a90001980e980f000a5eb80c8cc004004dd61802980d9baa3007301b375401444a66603a002297ae013232533301b3375e6e98cc030dd59805980f1baa002488100374c66601200c91100480084cc080008cc0100100044cc010010004c084008c07c00454ccc05ccdd79ba6001374c66600a00491100480045288a503300737566038603a603a603a603a60326ea8c014c064dd500424500375c603660306ea800454cc059240128657870656374204d696e74286f776e5f706f6c6963795f696429203d206374782e707572706f7365001630043017375400c4603460366036002444a66602a6016002297adef6c6013232330010014bd6f7b63011299980e00089980e99bb0375200c6e9800d2f5bded8c0264646464a66603866e400280084cc084cdd81ba900a374c00e00a2a66603866e3c0280084cc084cdd81ba900a374c00e00626604266ec0dd48011ba6001330060060033756603c0066eb8c070008c080008c078004c8cc0040052f5bded8c044a66603600226603866ec0dd48021ba80034bd6f7b630099191919299980d99b90008002133020337606ea4020dd40038028a99980d99b8f008002133020337606ea4020dd400380189981019bb037520046ea0004cc01801800cdd6980e8019bae301b002301f002301d0012301800123017301800122323300100100322533301700114bd6f7b630099191919299980b99b91007002153330173371e00e0042006200a26603866ec0dd48011ba600133006006003375660320066eb8c05c008c06c008c064004526153301049011856616c696461746f722072657475726e65642066616c736500136563300100400b2232533300f3005001132533301400115330110031613253330153018002149854cc04801058c94cccccc06400454cc0480105854cc0480105854cc0480105854cc048010584dd7000980b00098091baa0031533300f3004001132533301400115330110031613253330153018002149854cc04801058c94cccccc06400454cc0480105854cc0480105854cc0480105854cc048010584dd7000980b00098091baa003153301000216301037540046e1d2002370e9000299999980880088008a998050038b0a998050038b0a998050038b0a998050038b1bae00137560029211472656465656d65723a2043726564656e7469616c0049013d657870656374206f776e5f6f75747075745f646174756d3a20436f6c64526566496e74656e74446174756d203d206f776e5f6f75747075745f64617461005734ae7155ceaab9e5573eae815d0aba25748981b0a5d87a9f581c24f5fe1c897b34180e6dcbc57fa7b2435b4d7cf6e8f3773a3edf0825ff03d87a9f581c883af74520be6f27da1ee389aee3c8ce5b11c7fb24d715404caec1c4ff04d87a9f581c059030947d487b5a1230cb9acae8f93fb29cb03d8061f798133d6de3ff05d87a9f581cc844f7034f137e3230540be47a22e3c6693c3bc76f728ada836d1b8fff06d87a9f581c97a5e64f557774e55fda8171feb7d3af93b5567838b3b25ae99990d9ff07004c0129d8799fd87a9f581cfe23153596f3415c21374454937dd858b1afcce3ee9c7d43fb05a90fffd87a80ff004c01165554737974787743327542326c4b654767436b755136000105a182010082d87a9f581c24f5fe1c897b34180e6dcbc57fa7b2435b4d7cf6e8f3773a3edf0825ff821a006acfc01ab2d05e00f5f6", + &vec![UTxO { + input: UtxoInput { + tx_hash: "5fefa1a58e20732f7e55972315dda0123b90e5a1d7f086bc37b566f0f9210229".to_string(), + output_index: 0 + }, + output: UtxoOutput { + address: "addr1qye4fev5r4qapqz3qp05q76sx4dru7kkhwvrq9sz3w4wdg0n7fpklg3pa0pds9ypacfxj3xhuyf9d6ne8kjefc8qxwfqply43d".to_string(), + amount: vec![Asset::new_from_str("lovelace", "18350707")], + data_hash: None, + plutus_data: None, + script_hash: None, + script_ref: None, + } + }], + &[], + &Network::Mainnet + ); + assert_eq!( + serde_json::json!([{"success": {"budget":{"mem":184912,"steps":61492185},"index": 0, "tag": "mint"}}]).to_string(), + serde_json::json!(result.unwrap()).to_string() + ) + } + #[test] fn test_cbor() { let script_bytes = hex::decode("5655010000322223253330054a229309b2b1bad0025735").unwrap(); @@ -593,7 +612,10 @@ mod test { assert_eq!(error_result.budget.steps, 1203691); assert_eq!(error_result.tag, RedeemerTag::Mint); assert_eq!(error_result.index, 0); - assert_eq!(error_result.error_message, "the validator crashed / exited prematurely"); + assert_eq!( + error_result.error_message, + "the validator crashed / exited prematurely" + ); assert_eq!(error_result.logs, ["This is a trace"]); } } diff --git a/packages/sidan-csl-rs/src/core/utils/phase_two.rs b/packages/sidan-csl-rs/src/core/utils/phase_two.rs index bffba5c..a5ee801 100644 --- a/packages/sidan-csl-rs/src/core/utils/phase_two.rs +++ b/packages/sidan-csl-rs/src/core/utils/phase_two.rs @@ -16,9 +16,6 @@ pub fn eval_phase_two( ) -> Result, Error> { let redeemers = tx.transaction_witness_set.redeemer.as_ref(); - //TODO: remove it after uplc will be updated to newer cost model - let cost_mdls = trim_cost_modes(cost_mdls); - let lookup_table = DataLookupTable::from_transaction(tx, utxos); match redeemers { @@ -42,7 +39,7 @@ pub fn eval_phase_two( slot_config, &redeemer, &lookup_table, - cost_mdls.as_ref(), + cost_mdls, &remaining_budget, ); @@ -58,18 +55,18 @@ pub fn eval_phase_two( } } -fn trim_cost_modes(cost_mdls: Option<&CostModels>) -> Option { - match cost_mdls { - None => None, - Some(mdls) => { - Some(CostModels { - plutus_v1: mdls.plutus_v1.clone(), - plutus_v2: mdls.plutus_v2.clone(), - plutus_v3: match &mdls.plutus_v3 { - None => None, - Some(mdls_vec) => Some(mdls_vec[0..251].to_vec()) - } - }) - } - } -} \ No newline at end of file +// fn trim_cost_modes(cost_mdls: Option<&CostModels>) -> Option { +// match cost_mdls { +// None => None, +// Some(mdls) => { +// Some(CostModels { +// plutus_v1: mdls.plutus_v1.clone(), +// plutus_v2: mdls.plutus_v2.clone(), +// plutus_v3: match &mdls.plutus_v3 { +// None => None, +// Some(mdls_vec) => Some(mdls_vec[0..251].to_vec()) +// } +// }) +// } +// } +// } \ No newline at end of file diff --git a/packages/sidan-csl-rs/src/wasm/txbuilder.rs b/packages/sidan-csl-rs/src/wasm/txbuilder.rs index 0e12f3a..ff1641d 100644 --- a/packages/sidan-csl-rs/src/wasm/txbuilder.rs +++ b/packages/sidan-csl-rs/src/wasm/txbuilder.rs @@ -41,7 +41,7 @@ pub fn js_serialize_tx_body(tx_builder_body_json: &str, params_json: &str) -> Wa #[test] fn test_js_serialize_tx_body() { - let mesh_tx_builder_body_json = r#"{"inputs":[{"scriptTxIn":{"txIn":{"txHash":"51e5fa01fec20243a16c3cd45a86b9de22761d6aebe7ca7c904664a17a317416","txIndex":2,"amount":[{"unit":"bdeb17d07ea41c2ccaa923fc9a97f1036f09d77f062ae7932f838d9e","quantity":"1"},{"unit":"lovelace","quantity":"1323170"}],"address":"addr_test1wrh7mlyk9s540ue3puvax3qrg4spvsceel7fz6d3g2cvg3sh9pzy3"},"scriptTxIn":{"scriptSource":{"providedScriptSource":{"scriptCbor":"58b258b0010100333232323232232225333005323232323232330010013758601c601e601e601e601e601e601e601e601e60186ea8c038c030dd50039129998070008a50132533300d3371e6eb8c04000802c52889980180180098080009806180680118058009805801180480098031baa00114984d958dd7000ab9a5573caae7d5d0aba24c011e581cfa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525c004c010847362d7370656e640001","languageVersion":"v3"}},"datumSource":{"inlineDatumSource":{"txHash":"51e5fa01fec20243a16c3cd45a86b9de22761d6aebe7ca7c904664a17a317416","txIndex":2}},"redeemer":{"data":"d87b80","exUnits":{"mem":7000000,"steps":3000000000}}}}},{"scriptTxIn":{"txIn":{"txHash":"54a4c620467373a2d1b294fdfa6d53d995ae8d074c5b477306a999bd0067896b","txIndex":1,"amount":[{"unit":"57dd033da7865978bd4224234c58f38d387e78f3abcfac760dbea6e4","quantity":"1"},{"unit":"lovelace","quantity":"1323170"}],"address":"addr_test1wpau6rysxjgkf4qj8rsyr334ty35sr4pn6zrn2cz2ne63yqeptp8a"},"scriptTxIn":{"scriptSource":{"providedScriptSource":{"scriptCbor":"58b258b0010100333232323232232225333005323232323232330010013758601c601e601e601e601e601e601e601e601e60186ea8c038c030dd50039129998070008a50132533300d3371e6eb8c04000802c52889980180180098080009806180680118058009805801180480098031baa00114984d958dd7000ab9a5573caae7d5d0aba24c011e581cfa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525c004c010847352d7370656e640001","languageVersion":"v3"}},"datumSource":{"inlineDatumSource":{"txHash":"54a4c620467373a2d1b294fdfa6d53d995ae8d074c5b477306a999bd0067896b","txIndex":1}},"redeemer":{"data":"d87d80","exUnits":{"mem":7000000,"steps":3000000000}}}}}],"outputs":[{"address":"addr_test1wpau6rysxjgkf4qj8rsyr334ty35sr4pn6zrn2cz2ne63yqeptp8a","amount":[{"unit":"bdeb17d07ea41c2ccaa923fc9a97f1036f09d77f062ae7932f838d9e","quantity":"1"},{"unit":"lovelace","quantity":"1323170"}],"datum":{"inline":"d8799f58200000000000000000000000000000000000000000000000000000000000000000ff"},"referenceScript":null},{"address":"addr_test1wpau6rysxjgkf4qj8rsyr334ty35sr4pn6zrn2cz2ne63yqeptp8a","amount":[{"unit":"57dd033da7865978bd4224234c58f38d387e78f3abcfac760dbea6e4","quantity":"1"},{"unit":"lovelace","quantity":"1323170"}],"datum":{"inline":"d8799f58200000000000000000000000000000000000000000000000000000000000000000ff"},"referenceScript":null},{"address":"addr_test1wz0a74329m3tdc5dgkxpatzc7vkxwjtp4rlg2h47ngyfp9qpqyzes","amount":[{"unit":"3ef107f3846191c353d00a7a6c7320771d11703593d7506d5bad85fc","quantity":"1"}],"datum":{"inline":"d8799f581c04845038ee499ee8bc0afe56f688f27b2dd76f230d3698a9afcc1b66a140a1401a02faf080ff"},"referenceScript":null}],"collaterals":[{"txIn":{"txHash":"83fc6b20417455242112b682137346048d16cf2a3ec1674f6e54ec06b42501b4","txIndex":0,"amount":[],"address":"addr_test1vra9zdhfa8kteyr3mfe7adkf5nlh8jl5xcg9e7pcp5w9yhq5exvwh"}}],"requiredSignatures":["fa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525c"],"referenceInputs":[],"mints":[{"scriptMint":{"mint":{"policyId":"3ef107f3846191c353d00a7a6c7320771d11703593d7506d5bad85fc","assetName":"","amount":1},"redeemer":{"data":"d87980","exUnits":{"mem":7000000,"steps":3000000000}},"scriptSource":{"providedScriptSource":{"scriptCbor":"58b158af010100333232323232232225333005323232323232330010013758601c601e601e601e601e601e601e601e601e60186ea8c038c030dd50039129998070008a50132533300d3371e6eb8c04000802c52889980180180098080009806180680118058009805801180480098031baa00114984d958dd7000ab9a5573caae7d5d0aba24c011e581cfa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525c004c010746392d6d696e740001","languageVersion":"v3"}}}}],"changeAddress":"addr_test1qra9zdhfa8kteyr3mfe7adkf5nlh8jl5xcg9e7pcp5w9yhyf5tek6vpnha97yd5yw9pezm3wyd77fyrfs3ynftyg7njs5cfz2x","metadata":[],"validityRange":{"invalidBefore":null,"invalidHereafter":null},"certificates":[],"signingKey":[],"withdrawals":[{"plutusScriptWithdrawal":{"address":"stake_test17r6tcnyl7kgclhuc5zney663we9tzdgdeh62cxx03xh7hvsuragew","coin":0,"scriptSource":{"providedScriptSource":{"scriptCbor":"58b758b5010100333232323232232225333005323232323232330010013758601c601e601e601e601e601e601e601e601e60186ea8c038c030dd50039129998070008a50132533300d3371e6eb8c04000802c52889980180180098080009806180680118058009805801180480098031baa00114984d958dd7000ab9a5573caae7d5d0aba24c011e581cfa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525c004c010d4c312d68796472612d6f70656e0001","languageVersion":"v3"}},"redeemer":{"data":"d8799f4040ff","exUnits":{"mem":7000000,"steps":3000000000}}}}],"votes":[],"network":"mainnet"}"#; + let mesh_tx_builder_body_json = r#"{"inputs":[{"pubKeyTxIn":{"txIn":{"txHash":"2cb57168ee66b68bd04a0d595060b546edf30c04ae1031b883c9ac797967dd85","txIndex":3,"amount":[{"unit":"lovelace","quantity":"9891607895"}],"address":"addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh"}}}],"outputs":[{"address":"addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh","amount":[],"datum":null,"referenceScript":null}],"collaterals":[],"requiredSignatures":[],"referenceInputs":[],"mints":[],"changeAddress":"addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh","metadata":[],"validityRange":{"invalidBefore":null,"invalidHereafter":null},"certificates":[],"signingKey":[],"withdrawals":[],"votes":[],"network":"mainnet"}"#; // let mesh_tx_builder_body_json = r#"{"inputs":[{"pubKeyTxIn":{"txIn":{"txHash":"5b0145fe7b0212a7807e7dba24997049374d965f587300a2039b73cd30806c78","txIndex":1,"amount":[{"unit":"lovelace","quantity":"1132923230"}],"address":"addr_test1qq0yavv5uve45rwvfaw96qynrqt8ckpmkwcg08vlwxxdncxk82f5wz75mzaesmqzl79xqsmedwgucwtuav5str6untqqmykcpn"}}}],"outputs":[{"address":"addr_test1wpnlxv2xv9a9ucvnvzqakwepzl9ltx7jzgm53av2e9ncv4sysemm8","amount":[{"unit":"lovelace","quantity":"1600000"}],"datum":{"hash":{"type":"Mesh","content":"supersecret"}},"referenceScript":null}],"collaterals":[{"txIn":{"txHash":"ec0c2e70b898cf531b03c9db937602e98c45378d9fa8e8a5b5a91ec5c1d7540d","txIndex":5,"amount":[{"unit":"lovelace","quantity":"5000000"}],"address":"addr_test1qq0yavv5uve45rwvfaw96qynrqt8ckpmkwcg08vlwxxdncxk82f5wz75mzaesmqzl79xqsmedwgucwtuav5str6untqqmykcpn"}}],"requiredSignatures":[],"referenceInputs":[],"mints":[],"changeAddress":"addr_test1qq0yavv5uve45rwvfaw96qynrqt8ckpmkwcg08vlwxxdncxk82f5wz75mzaesmqzl79xqsmedwgucwtuav5str6untqqmykcpn","metadata":[],"validityRange":{"invalidBefore":null,"invalidHereafter":null},"certificates":[],"signingKey":[],"withdrawals":[]}"#; let params_json = r#"{"epoch":0,"coinsPerUtxoSize":0,"priceMem":0.0,"priceStep":0.0,"minFeeA":0,"minFeeB":0,"keyDeposit":2000000,"maxTxSize":16384,"maxValSize":5000,"poolDeposit":500000000,"maxCollateralInputs":3,"decentralisation":0,"maxBlockSize":65536,"collateralPercent":150,"maxBlockHeaderSize":1100,"minPoolCost":"340000000","maxTxExMem":"14000000","maxTxExSteps":"10000000000","maxBlockExMem":"62000000","maxBlockExSteps":"20000000000","minFeeRefScriptCostPerByte":15}"#; let tx_build_result = js_serialize_tx_body(mesh_tx_builder_body_json, params_json); diff --git a/packages/whisky-examples/Cargo.toml b/packages/whisky-examples/Cargo.toml index f0d1a5a..581bd9e 100644 --- a/packages/whisky-examples/Cargo.toml +++ b/packages/whisky-examples/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "whisky-examples" -version = "0.9.11" +version = "0.9.12" edition = "2021" license = "Apache-2.0" description = "The Cardano Rust SDK, inspired by MeshJS" @@ -13,4 +13,4 @@ path = "src/server.rs" actix-cors = "0.7.0" actix-web = "4.9.0" serde = "1.0.209" -whisky = { version = "=0.9.11", path = "../whisky" } +whisky = { version = "=0.9.12", path = "../whisky" } diff --git a/packages/whisky/Cargo.toml b/packages/whisky/Cargo.toml index d31aebd..6b0373e 100644 --- a/packages/whisky/Cargo.toml +++ b/packages/whisky/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "whisky" -version = "0.9.11" +version = "0.9.12" edition = "2021" license = "Apache-2.0" description = "The Cardano Rust SDK, inspired by MeshJS" @@ -16,15 +16,15 @@ serde_json = "1.0" cryptoxide = "0.4.4" serde-wasm-bindgen = "0.6.5" async-trait = "0.1.79" -uplc = "=1.1.7" +uplc = "=1.1.9" wasm-bindgen = { version = "=0.2.92", features = ["serde-serialize"] } rand_os = "0.1" noop_proc_macro = "0.3.0" pallas-codec = { version = "0.30.2", features = ["num-bigint"] } -pallas-primitives = "0.30.2" -pallas-traverse = "0.30.2" +pallas-primitives = "0.31.0" +pallas-traverse = "0.31.0" maestro-rust-sdk = "1.1.3" -sidan-csl-rs = { version = "=0.9.11", path = "../sidan-csl-rs" } +sidan-csl-rs = { version = "=0.9.12", path = "../sidan-csl-rs" } reqwest = "0.12.5" tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] } diff --git a/packages/whisky/tests/integration_tests.rs b/packages/whisky/tests/integration_tests.rs index 8629e21..e7a1dd1 100644 --- a/packages/whisky/tests/integration_tests.rs +++ b/packages/whisky/tests/integration_tests.rs @@ -701,4 +701,32 @@ mod int_tests { println!("{}", signed_tx); assert!(mesh.core.mesh_csl.tx_hex != *""); } + + #[test] + fn test_balance() { + 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", + &[] + ) + .change_address("addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh") + .complete_sync(None) + .unwrap() + .complete_signing().unwrap(); + + println!("{}", signed_tx); + assert!(mesh.core.mesh_csl.tx_hex != *""); + } }