1#![allow(clippy::too_many_arguments)]
2
3extern crate derivative;
4pub mod allegra;
5pub mod alonzo;
6pub mod babbage;
7pub mod byron;
8pub mod mary;
9pub mod serialization;
10pub mod shelley;
11pub mod utils;
12use crate::{
16 allegra::{AllegraBlock, AllegraTransactionBody},
17 alonzo::{AlonzoBlock, AlonzoTransactionBody},
18 babbage::{BabbageBlock, BabbageTransactionBody},
19 byron::{block::ByronBlock, transaction::ByronTx},
20 mary::{MaryBlock, MaryTransactionBody},
21 shelley::{ShelleyBlock, ShelleyTransactionBody},
22};
23use cml_chain::block::Block;
24use cml_chain::crypto::GenesisHash;
25use cml_chain::{address::RewardAccount, transaction::TransactionBody};
26
27pub type GenesisHashList = Vec<GenesisHash>;
28
29pub type RewardAccountList = Vec<RewardAccount>;
30
31#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
32pub enum MultiEraBlock {
33 Byron(ByronBlock),
34 Shelley(ShelleyBlock),
35 Allegra(AllegraBlock),
36 Mary(MaryBlock),
37 Alonzo(AlonzoBlock),
38 Babbage(BabbageBlock),
39 Conway(Block),
40}
41
42impl MultiEraBlock {
43 pub fn new_byron(byron: ByronBlock) -> Self {
44 Self::Byron(byron)
45 }
46
47 pub fn new_shelley(shelley: ShelleyBlock) -> Self {
48 Self::Shelley(shelley)
49 }
50
51 pub fn new_allegra(allegra: AllegraBlock) -> Self {
52 Self::Allegra(allegra)
53 }
54
55 pub fn new_mary(mary: MaryBlock) -> Self {
56 Self::Mary(mary)
57 }
58
59 pub fn new_alonzo(alonzo: AlonzoBlock) -> Self {
60 Self::Alonzo(alonzo)
61 }
62
63 pub fn new_babbage(babbage: BabbageBlock) -> Self {
64 Self::Babbage(babbage)
65 }
66
67 pub fn new_conway(conway: Block) -> Self {
68 Self::Conway(conway)
69 }
70}
71
72#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
73pub enum MultiEraTransactionBody {
74 Byron(ByronTx),
75 Shelley(ShelleyTransactionBody),
76 Allegra(AllegraTransactionBody),
77 Mary(MaryTransactionBody),
78 Alonzo(AlonzoTransactionBody),
79 Babbage(BabbageTransactionBody),
80 Conway(TransactionBody),
81}
82
83impl MultiEraTransactionBody {
84 pub fn new_byron(byron: ByronTx) -> Self {
85 Self::Byron(byron)
86 }
87
88 pub fn new_shelley(shelley: ShelleyTransactionBody) -> Self {
89 Self::Shelley(shelley)
90 }
91
92 pub fn new_allegra(allegra: AllegraTransactionBody) -> Self {
93 Self::Allegra(allegra)
94 }
95
96 pub fn new_mary(mary: MaryTransactionBody) -> Self {
97 Self::Mary(mary)
98 }
99
100 pub fn new_alonzo(alonzo: AlonzoTransactionBody) -> Self {
101 Self::Alonzo(alonzo)
102 }
103
104 pub fn new_babbage(babbage: BabbageTransactionBody) -> Self {
105 Self::Babbage(babbage)
106 }
107
108 pub fn new_conway(conway: TransactionBody) -> Self {
109 Self::Conway(conway)
110 }
111}