From 9e498d98b09f8fb639313719cc1b98058e33b81d Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 9 Jun 2024 14:28:25 +0800 Subject: [PATCH] feat: exporting new_core fn --- packages/Cargo.lock | 4 ++-- packages/sidan-csl-rs/Cargo.toml | 2 +- packages/whisky/Cargo.toml | 4 ++-- packages/whisky/src/builder/core.rs | 15 +++++++++++++-- packages/whisky/src/builder/interface.rs | 13 +++++++++++++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/packages/Cargo.lock b/packages/Cargo.lock index d687b73..f029f73 100644 --- a/packages/Cargo.lock +++ b/packages/Cargo.lock @@ -1833,7 +1833,7 @@ dependencies = [ [[package]] name = "sidan-csl-rs" -version = "0.5.0-alpha.10" +version = "0.5.0-alpha.11" dependencies = [ "cardano-serialization-lib", "cryptoxide", @@ -2387,7 +2387,7 @@ dependencies = [ [[package]] name = "whisky" -version = "0.5.0-alpha.10" +version = "0.5.0-alpha.11" dependencies = [ "async-trait", "cardano-serialization-lib", diff --git a/packages/sidan-csl-rs/Cargo.toml b/packages/sidan-csl-rs/Cargo.toml index 7dea09e..2c326e3 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.5.0-alpha.10" +version = "0.5.0-alpha.11" edition = "2021" license = "Apache-2.0" description = "Wrapper around the cardano-serialization-lib for easier transaction building, heavily inspired by cardano-cli APIs" diff --git a/packages/whisky/Cargo.toml b/packages/whisky/Cargo.toml index e2fdd83..40f8612 100644 --- a/packages/whisky/Cargo.toml +++ b/packages/whisky/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "whisky" -version = "0.5.0-alpha.10" +version = "0.5.0-alpha.11" edition = "2021" license = "Apache-2.0" description = "The Cardano Rust SDK, inspired by MeshJS" @@ -24,7 +24,7 @@ noop_proc_macro = "0.3.0" pallas-codec = "0.22.0" pallas-primitives = "0.22.0" pallas-traverse = "0.22.0" -sidan-csl-rs = { version = "=0.5.0-alpha.10", path = "../sidan-csl-rs" } +sidan-csl-rs = { version = "=0.5.0-alpha.11", path = "../sidan-csl-rs" } [profile.release] # Tell `rustc` to optimize for small code size. diff --git a/packages/whisky/src/builder/core.rs b/packages/whisky/src/builder/core.rs index aeebbc8..5c3cf6c 100644 --- a/packages/whisky/src/builder/core.rs +++ b/packages/whisky/src/builder/core.rs @@ -39,6 +39,15 @@ impl IMeshTxBuilder for MeshTxBuilder { } } + fn new_core() -> Self { + Self::new(super::MeshTxBuilderParam { + evaluator: None, + fetcher: None, + submitter: None, + params: None, + }) + } + async fn complete(&mut self, customized_tx: Option) -> &mut Self { self.complete_sync(customized_tx); match &self.evaluator { @@ -69,8 +78,10 @@ impl IMeshTxBuilder for MeshTxBuilder { self.add_utxos_from(self.extra_inputs.clone(), self.selection_threshold); } } - let tx_hex = - serialize_tx_body(self.core.mesh_tx_builder_body.clone(), self.protocol_params.clone()); + let tx_hex = serialize_tx_body( + self.core.mesh_tx_builder_body.clone(), + self.protocol_params.clone(), + ); self.core.mesh_csl.tx_hex = tx_hex; self.core.mesh_csl.tx_builder = build_tx_builder(None); self.core.mesh_csl.tx_inputs_builder = csl::TxInputsBuilder::new(); diff --git a/packages/whisky/src/builder/interface.rs b/packages/whisky/src/builder/interface.rs index 3025827..fcc980c 100644 --- a/packages/whisky/src/builder/interface.rs +++ b/packages/whisky/src/builder/interface.rs @@ -40,11 +40,24 @@ pub trait IMeshTxBuilder { /// /// Create a new MeshTxBuilder instance /// + /// ### Arguments + /// + /// * `param` - Parameters for setting up the MeshTxBuilder instance, including evaluator, fetcher, submitter, and protocol parameters + /// /// ### Returns /// /// * `Self` - A new MeshTxBuilder instance fn new(param: MeshTxBuilderParam) -> Self; + /// ## Transaction building method + /// + /// Create a new MeshTxBuilder instance + /// + /// ### Returns + /// + /// * `Self` - A new MeshTxBuilder instance + fn new_core() -> Self; + /// ## Transaction building method /// /// Complete the transaction building process with fetching missing information & tx evaluation