Skip to content

Commit

Permalink
Merge pull request #33 from sidan-lab/feature/refactor-export
Browse files Browse the repository at this point in the history
feat: fix redeemer update index issue
  • Loading branch information
HinsonSIDAN authored Jun 12, 2024
2 parents 3f6c3e2 + e990df6 commit c495159
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions packages/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/sidan-csl-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sidan-csl-rs"
version = "0.5.0-alpha.12"
version = "0.5.1"
edition = "2021"
license = "Apache-2.0"
description = "Wrapper around the cardano-serialization-lib for easier transaction building, heavily inspired by cardano-cli APIs"
Expand Down
23 changes: 1 addition & 22 deletions packages/sidan-csl-rs/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,11 @@ pub fn js_serialize_tx_body(mesh_tx_builder_body_json: &str, params_json: &str)
///
/// * `String` - the built transaction hex
pub fn serialize_tx_body(
mut mesh_tx_builder_body: MeshTxBuilderBody,
mesh_tx_builder_body: MeshTxBuilderBody,
params: Option<Protocol>,
) -> String {
let mut mesh_csl = MeshCSL::new(params);

mesh_tx_builder_body
.mints
.sort_by(|a, b| a.policy_id.cmp(&b.policy_id));

mesh_tx_builder_body.inputs.sort_by(|a, b| {
let tx_in_data_a: &TxInParameter = match a {
TxIn::PubKeyTxIn(pub_key_tx_in) => &pub_key_tx_in.tx_in,
TxIn::ScriptTxIn(script_tx_in) => &script_tx_in.tx_in,
};

let tx_in_data_b: &TxInParameter = match b {
TxIn::PubKeyTxIn(pub_key_tx_in) => &pub_key_tx_in.tx_in,
TxIn::ScriptTxIn(script_tx_in) => &script_tx_in.tx_in,
};

tx_in_data_a
.tx_hash
.cmp(&tx_in_data_b.tx_hash)
.then_with(|| tx_in_data_a.tx_index.cmp(&tx_in_data_b.tx_index))
});

MeshTxBuilderCore::add_all_inputs(&mut mesh_csl, mesh_tx_builder_body.inputs.clone());
MeshTxBuilderCore::add_all_outputs(&mut mesh_csl, mesh_tx_builder_body.outputs.clone());
MeshTxBuilderCore::add_all_collaterals(&mut mesh_csl, mesh_tx_builder_body.collaterals.clone());
Expand Down
4 changes: 2 additions & 2 deletions packages/whisky/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "whisky"
version = "0.5.0-alpha.12"
version = "0.5.1"
edition = "2021"
license = "Apache-2.0"
description = "The Cardano Rust SDK, inspired by MeshJS"
Expand All @@ -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.12", path = "../sidan-csl-rs" }
sidan-csl-rs = { version = "=0.5.1", path = "../sidan-csl-rs" }

[profile.release]
# Tell `rustc` to optimize for small code size.
Expand Down
23 changes: 23 additions & 0 deletions packages/whisky/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ impl IMeshTxBuilder for MeshTxBuilder {
self.add_utxos_from(self.extra_inputs.clone(), self.selection_threshold);
}
}

self.core
.mesh_tx_builder_body
.mints
.sort_by(|a, b| a.policy_id.cmp(&b.policy_id));

self.core.mesh_tx_builder_body.inputs.sort_by(|a, b| {
let tx_in_data_a: &TxInParameter = match a {
TxIn::PubKeyTxIn(pub_key_tx_in) => &pub_key_tx_in.tx_in,
TxIn::ScriptTxIn(script_tx_in) => &script_tx_in.tx_in,
};

let tx_in_data_b: &TxInParameter = match b {
TxIn::PubKeyTxIn(pub_key_tx_in) => &pub_key_tx_in.tx_in,
TxIn::ScriptTxIn(script_tx_in) => &script_tx_in.tx_in,
};

tx_in_data_a
.tx_hash
.cmp(&tx_in_data_b.tx_hash)
.then_with(|| tx_in_data_a.tx_index.cmp(&tx_in_data_b.tx_index))
});

let tx_hex = serialize_tx_body(
self.core.mesh_tx_builder_body.clone(),
self.protocol_params.clone(),
Expand Down

0 comments on commit c495159

Please sign in to comment.