Skip to content

Commit

Permalink
feat(txbuilder): allow cloning of relevant structs (#558)
Browse files Browse the repository at this point in the history
Co-authored-by: logicalmechanism <[email protected]>
  • Loading branch information
logicalmechanism and logicalmechanism authored Dec 13, 2024
1 parent cfc840f commit 2864ff4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 0 additions & 2 deletions examples/n2c-miniprotocols/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions pallas-txbuilder/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ 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]
Staging,
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;
Expand Down
14 changes: 7 additions & 7 deletions pallas-txbuilder/src/transaction/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -547,21 +547,21 @@ pub struct Datum {
pub bytes: DatumBytes,
}

#[derive(PartialEq, Eq, Hash, Debug)]
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
pub enum RedeemerPurpose {
Spend(Input),
Mint(PolicyId),
// Reward TODO
// 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<RedeemerPurpose, (Bytes, Option<ExUnits>)>);

impl Deref for Redeemers {
Expand Down Expand Up @@ -595,14 +595,14 @@ impl From<PallasAddress> 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,
Expand Down

0 comments on commit 2864ff4

Please sign in to comment.