From 2864ff45a94e030d097c3d67c0e9be7605a7c95a Mon Sep 17 00:00:00 2001 From: Logical Mechanism <77127298+logicalmechanism@users.noreply.github.com> Date: Fri, 13 Dec 2024 02:57:36 -0800 Subject: [PATCH] feat(txbuilder): allow cloning of relevant structs (#558) Co-authored-by: logicalmechanism --- examples/n2c-miniprotocols/src/main.rs | 2 -- pallas-txbuilder/src/transaction/mod.rs | 6 +++--- pallas-txbuilder/src/transaction/model.rs | 14 +++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/n2c-miniprotocols/src/main.rs b/examples/n2c-miniprotocols/src/main.rs index 5e5a9edd..5fe5509e 100644 --- a/examples/n2c-miniprotocols/src/main.rs +++ b/examples/n2c-miniprotocols/src/main.rs @@ -16,8 +16,6 @@ use pallas::{ use tracing::info; use hex::FromHex; -use hex::FromHex; - async fn do_localstate_query(client: &mut NodeClient) { let client = client.statequery(); diff --git a/pallas-txbuilder/src/transaction/mod.rs b/pallas-txbuilder/src/transaction/mod.rs index 654bad4d..a804d435 100644 --- a/pallas-txbuilder/src/transaction/mod.rs +++ b/pallas-txbuilder/src/transaction/mod.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; pub mod model; pub mod serialise; -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Clone)] #[serde(rename_all = "snake_case")] pub enum TransactionStatus { #[default] @@ -11,10 +11,10 @@ pub enum TransactionStatus { Built, } -#[derive(PartialEq, Eq, Hash, Debug)] +#[derive(PartialEq, Eq, Hash, Debug, Clone)] pub struct Bytes32(pub [u8; 32]); -#[derive(Hash, PartialEq, Eq, Debug)] +#[derive(Hash, PartialEq, Eq, Debug, Clone)] pub struct Bytes64(pub [u8; 64]); type PublicKey = Bytes32; diff --git a/pallas-txbuilder/src/transaction/model.rs b/pallas-txbuilder/src/transaction/model.rs index 24eb44ed..97d60c6d 100644 --- a/pallas-txbuilder/src/transaction/model.rs +++ b/pallas-txbuilder/src/transaction/model.rs @@ -18,7 +18,7 @@ use super::{ }; // TODO: Don't make wrapper types public -#[derive(Default, Serialize, Deserialize, PartialEq, Eq, Debug)] +#[derive(Default, Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] pub struct StagingTransaction { pub version: String, pub status: TransactionStatus, @@ -375,7 +375,7 @@ impl StagingTransaction { } // TODO: Don't want our wrapper types in fields public -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Hash)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Hash, Clone)] pub struct Input { pub tx_hash: TxHash, pub txo_index: u64, @@ -547,7 +547,7 @@ pub struct Datum { pub bytes: DatumBytes, } -#[derive(PartialEq, Eq, Hash, Debug)] +#[derive(PartialEq, Eq, Hash, Debug, Clone)] pub enum RedeemerPurpose { Spend(Input), Mint(PolicyId), @@ -555,13 +555,13 @@ pub enum RedeemerPurpose { // Cert TODO } -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] pub struct ExUnits { pub mem: u64, pub steps: u64, } -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Clone)] pub struct Redeemers(HashMap)>); impl Deref for Redeemers { @@ -595,14 +595,14 @@ impl From for Address { } } -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] #[serde(rename_all = "snake_case")] pub enum BuilderEra { Babbage, Conway, } -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] pub struct BuiltTransaction { pub version: String, pub era: BuilderEra,