cml_multi_era/shelley/
mod.rs

1// This file was code-generated using an experimental CDDL to rust tool:
2// https://github.com/dcSpark/cddl-codegen
3
4pub mod cbor_encodings;
5pub mod serialization;
6pub mod utils;
7
8use cbor_encodings::{
9    MultisigAllEncoding, MultisigAnyEncoding, MultisigNOfKEncoding, MultisigPubkeyEncoding,
10    ShelleyBlockEncoding, ShelleyHeaderBodyEncoding, ShelleyHeaderEncoding,
11    ShelleyMultiHostNameEncoding, ShelleyPoolRegistrationEncoding,
12    ShelleyProtocolParamUpdateEncoding, ShelleySingleHostNameEncoding,
13    ShelleyTransactionBodyEncoding, ShelleyTransactionEncoding, ShelleyTransactionOutputEncoding,
14    ShelleyTransactionWitnessSetEncoding, ShelleyUpdateEncoding,
15};
16use cml_chain::address::{Address, RewardAccount};
17use cml_chain::assets::Coin;
18use cml_chain::auxdata::Metadata;
19use cml_chain::block::{OperationalCert, ProtocolVersion};
20use cml_chain::certs::{
21    Ipv4, Ipv6, PoolMetadata, PoolRetirement, SingleHostAddr, StakeCredential, StakeDelegation,
22    StakeDeregistration, StakeRegistration,
23};
24use cml_chain::crypto::{
25    AuxiliaryDataHash, BlockBodyHash, BlockHeaderHash, BootstrapWitness, Ed25519KeyHash,
26    GenesisHash, KESSignature, Nonce, VRFCert, VRFVkey, Vkey, Vkeywitness,
27};
28use cml_chain::transaction::TransactionInput;
29use cml_chain::{Epoch, Port, Rational, UnitInterval, Withdrawals};
30use cml_core::ordered_hash_map::OrderedHashMap;
31use cml_core::{DeserializeError, DeserializeFailure, TransactionIndex};
32use cml_crypto::{GenesisDelegateHash, VRFKeyHash};
33use std::collections::BTreeMap;
34use std::convert::TryFrom;
35
36use crate::allegra::MIRPot;
37
38use self::cbor_encodings::{
39    GenesisKeyDelegationEncoding, ProtocolVersionStructEncoding, ShelleyDNSNameEncoding,
40    ShelleyMoveInstantaneousRewardEncoding, ShelleyMoveInstantaneousRewardsCertEncoding,
41    ShelleyPoolParamsEncoding,
42};
43#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
44pub struct GenesisKeyDelegation {
45    pub genesis_hash: GenesisHash,
46    pub genesis_delegate_hash: GenesisDelegateHash,
47    pub vrf_key_hash: VRFKeyHash,
48    #[serde(skip)]
49    pub encodings: Option<GenesisKeyDelegationEncoding>,
50}
51
52impl GenesisKeyDelegation {
53    pub fn new(
54        genesis_hash: GenesisHash,
55        genesis_delegate_hash: GenesisDelegateHash,
56        vrf_key_hash: VRFKeyHash,
57    ) -> Self {
58        Self {
59            genesis_hash,
60            genesis_delegate_hash,
61            vrf_key_hash,
62            encodings: None,
63        }
64    }
65}
66
67#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
68pub struct MultisigAll {
69    pub multisig_scripts: Vec<MultisigScript>,
70    #[serde(skip)]
71    pub encodings: Option<MultisigAllEncoding>,
72}
73
74impl MultisigAll {
75    pub fn new(multisig_scripts: Vec<MultisigScript>) -> Self {
76        Self {
77            multisig_scripts,
78            encodings: None,
79        }
80    }
81}
82
83#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
84pub struct MultisigAny {
85    pub multisig_scripts: Vec<MultisigScript>,
86    #[serde(skip)]
87    pub encodings: Option<MultisigAnyEncoding>,
88}
89
90impl MultisigAny {
91    pub fn new(multisig_scripts: Vec<MultisigScript>) -> Self {
92        Self {
93            multisig_scripts,
94            encodings: None,
95        }
96    }
97}
98
99#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
100pub struct MultisigNOfK {
101    pub n: u64,
102    pub multisig_scripts: Vec<MultisigScript>,
103    #[serde(skip)]
104    pub encodings: Option<MultisigNOfKEncoding>,
105}
106
107impl MultisigNOfK {
108    pub fn new(n: u64, multisig_scripts: Vec<MultisigScript>) -> Self {
109        Self {
110            n,
111            multisig_scripts,
112            encodings: None,
113        }
114    }
115}
116
117#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
118pub struct MultisigPubkey {
119    pub ed25519_key_hash: Ed25519KeyHash,
120    #[serde(skip)]
121    pub encodings: Option<MultisigPubkeyEncoding>,
122}
123
124impl MultisigPubkey {
125    pub fn new(ed25519_key_hash: Ed25519KeyHash) -> Self {
126        Self {
127            ed25519_key_hash,
128            encodings: None,
129        }
130    }
131}
132
133#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
134pub enum MultisigScript {
135    MultisigPubkey(MultisigPubkey),
136    MultisigAll(MultisigAll),
137    MultisigAny(MultisigAny),
138    MultisigNOfK(MultisigNOfK),
139}
140
141impl MultisigScript {
142    pub fn new_multisig_pubkey(ed25519_key_hash: Ed25519KeyHash) -> Self {
143        Self::MultisigPubkey(MultisigPubkey::new(ed25519_key_hash))
144    }
145
146    pub fn new_multisig_all(multisig_scripts: Vec<MultisigScript>) -> Self {
147        Self::MultisigAll(MultisigAll::new(multisig_scripts))
148    }
149
150    pub fn new_multisig_any(multisig_scripts: Vec<MultisigScript>) -> Self {
151        Self::MultisigAny(MultisigAny::new(multisig_scripts))
152    }
153
154    pub fn new_multisig_n_of_k(n: u64, multisig_scripts: Vec<MultisigScript>) -> Self {
155        Self::MultisigNOfK(MultisigNOfK::new(n, multisig_scripts))
156    }
157}
158
159#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
160pub struct ProtocolVersionStruct {
161    pub protocol_version: ProtocolVersion,
162    #[serde(skip)]
163    pub encodings: Option<ProtocolVersionStructEncoding>,
164}
165
166impl ProtocolVersionStruct {
167    pub fn new(protocol_version: ProtocolVersion) -> Self {
168        Self {
169            protocol_version,
170            encodings: None,
171        }
172    }
173}
174
175#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
176pub struct ShelleyBlock {
177    pub header: ShelleyHeader,
178    pub transaction_bodies: Vec<ShelleyTransactionBody>,
179    pub transaction_witness_sets: Vec<ShelleyTransactionWitnessSet>,
180    pub transaction_metadata_set: OrderedHashMap<TransactionIndex, Metadata>,
181    #[serde(skip)]
182    pub encodings: Option<ShelleyBlockEncoding>,
183}
184
185impl ShelleyBlock {
186    pub fn new(
187        header: ShelleyHeader,
188        transaction_bodies: Vec<ShelleyTransactionBody>,
189        transaction_witness_sets: Vec<ShelleyTransactionWitnessSet>,
190        transaction_metadata_set: OrderedHashMap<TransactionIndex, Metadata>,
191    ) -> Self {
192        Self {
193            header,
194            transaction_bodies,
195            transaction_witness_sets,
196            transaction_metadata_set,
197            encodings: None,
198        }
199    }
200}
201
202#[allow(clippy::large_enum_variant)]
203#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
204pub enum ShelleyCertificate {
205    StakeRegistration(StakeRegistration),
206    StakeDeregistration(StakeDeregistration),
207    StakeDelegation(StakeDelegation),
208    ShelleyPoolRegistration(ShelleyPoolRegistration),
209    PoolRetirement(PoolRetirement),
210    GenesisKeyDelegation(GenesisKeyDelegation),
211    ShelleyMoveInstantaneousRewardsCert(ShelleyMoveInstantaneousRewardsCert),
212}
213
214impl ShelleyCertificate {
215    pub fn new_stake_registration(stake_credential: StakeCredential) -> Self {
216        Self::StakeRegistration(StakeRegistration::new(stake_credential))
217    }
218
219    pub fn new_stake_deregistration(stake_credential: StakeCredential) -> Self {
220        Self::StakeDeregistration(StakeDeregistration::new(stake_credential))
221    }
222
223    pub fn new_stake_delegation(
224        stake_credential: StakeCredential,
225        ed25519_key_hash: Ed25519KeyHash,
226    ) -> Self {
227        Self::StakeDelegation(StakeDelegation::new(stake_credential, ed25519_key_hash))
228    }
229
230    pub fn new_shelley_pool_registration(pool_params: ShelleyPoolParams) -> Self {
231        Self::ShelleyPoolRegistration(ShelleyPoolRegistration::new(pool_params))
232    }
233
234    pub fn new_pool_retirement(ed25519_key_hash: Ed25519KeyHash, epoch: Epoch) -> Self {
235        Self::PoolRetirement(PoolRetirement::new(ed25519_key_hash, epoch))
236    }
237
238    pub fn new_genesis_key_delegation(
239        genesis_hash: GenesisHash,
240        genesis_delegate_hash: GenesisDelegateHash,
241        vrf_key_hash: VRFKeyHash,
242    ) -> Self {
243        Self::GenesisKeyDelegation(GenesisKeyDelegation::new(
244            genesis_hash,
245            genesis_delegate_hash,
246            vrf_key_hash,
247        ))
248    }
249
250    pub fn new_shelley_move_instantaneous_rewards_cert(
251        shelley_move_instantaneous_reward: ShelleyMoveInstantaneousReward,
252    ) -> Self {
253        Self::ShelleyMoveInstantaneousRewardsCert(ShelleyMoveInstantaneousRewardsCert::new(
254            shelley_move_instantaneous_reward,
255        ))
256    }
257}
258
259#[derive(Clone, Debug)]
260pub struct ShelleyDNSName {
261    pub inner: String,
262    pub encodings: Option<ShelleyDNSNameEncoding>,
263}
264
265impl ShelleyDNSName {
266    pub fn get(&self) -> &String {
267        &self.inner
268    }
269
270    pub fn new(inner: String) -> Result<Self, DeserializeError> {
271        if inner.len() > 64 {
272            return Err(DeserializeError::new(
273                "ShelleyDNSName",
274                DeserializeFailure::RangeCheck {
275                    found: inner.len() as isize,
276                    min: Some(0),
277                    max: Some(64),
278                },
279            ));
280        }
281        Ok(Self {
282            inner,
283            encodings: None,
284        })
285    }
286}
287
288impl TryFrom<String> for ShelleyDNSName {
289    type Error = DeserializeError;
290
291    fn try_from(inner: String) -> Result<Self, Self::Error> {
292        ShelleyDNSName::new(inner)
293    }
294}
295
296impl serde::Serialize for ShelleyDNSName {
297    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
298    where
299        S: serde::Serializer,
300    {
301        self.inner.serialize(serializer)
302    }
303}
304
305impl<'de> serde::de::Deserialize<'de> for ShelleyDNSName {
306    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
307    where
308        D: serde::de::Deserializer<'de>,
309    {
310        let inner = <String as serde::de::Deserialize>::deserialize(deserializer)?;
311        Self::new(inner.clone()).map_err(|_e| {
312            serde::de::Error::invalid_value(
313                serde::de::Unexpected::Str(&inner),
314                &"invalid ShelleyDNSName",
315            )
316        })
317    }
318}
319
320impl schemars::JsonSchema for ShelleyDNSName {
321    fn schema_name() -> String {
322        String::from("ShelleyDNSName")
323    }
324
325    fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
326        String::json_schema(gen)
327    }
328
329    fn is_referenceable() -> bool {
330        String::is_referenceable()
331    }
332}
333
334#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
335pub struct ShelleyHeader {
336    pub body: ShelleyHeaderBody,
337    pub signature: KESSignature,
338    #[serde(skip)]
339    pub encodings: Option<ShelleyHeaderEncoding>,
340}
341
342impl ShelleyHeader {
343    pub fn new(body: ShelleyHeaderBody, signature: KESSignature) -> Self {
344        Self {
345            body,
346            signature,
347            encodings: None,
348        }
349    }
350}
351
352#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
353pub struct ShelleyHeaderBody {
354    pub block_number: u64,
355    pub slot: u64,
356    pub prev_hash: Option<BlockHeaderHash>,
357    pub issuer_vkey: Vkey,
358    pub vrf_vkey: VRFVkey,
359    pub nonce_vrf: VRFCert,
360    pub leader_vrf: VRFCert,
361    pub block_body_size: u64,
362    pub block_body_hash: BlockBodyHash,
363    pub operational_cert: OperationalCert,
364    pub protocol_version: ProtocolVersion,
365    #[serde(skip)]
366    pub encodings: Option<ShelleyHeaderBodyEncoding>,
367}
368
369impl ShelleyHeaderBody {
370    pub fn new(
371        block_number: u64,
372        slot: u64,
373        prev_hash: Option<BlockHeaderHash>,
374        issuer_vkey: Vkey,
375        vrf_vkey: VRFVkey,
376        nonce_vrf: VRFCert,
377        leader_vrf: VRFCert,
378        block_body_size: u64,
379        block_body_hash: BlockBodyHash,
380        operational_cert: OperationalCert,
381        protocol_version: ProtocolVersion,
382    ) -> Self {
383        Self {
384            block_number,
385            slot,
386            prev_hash,
387            issuer_vkey,
388            vrf_vkey,
389            nonce_vrf,
390            leader_vrf,
391            block_body_size,
392            block_body_hash,
393            operational_cert,
394            protocol_version,
395            encodings: None,
396        }
397    }
398}
399
400#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
401pub struct ShelleyMoveInstantaneousReward {
402    pub pot: MIRPot,
403    pub to_stake_credentials: OrderedHashMap<StakeCredential, Coin>,
404    #[serde(skip)]
405    pub encodings: Option<ShelleyMoveInstantaneousRewardEncoding>,
406}
407
408impl ShelleyMoveInstantaneousReward {
409    pub fn new(pot: MIRPot, to_stake_credentials: OrderedHashMap<StakeCredential, Coin>) -> Self {
410        Self {
411            pot,
412            to_stake_credentials,
413            encodings: None,
414        }
415    }
416}
417
418#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
419pub struct ShelleyMoveInstantaneousRewardsCert {
420    pub shelley_move_instantaneous_reward: ShelleyMoveInstantaneousReward,
421    #[serde(skip)]
422    pub encodings: Option<ShelleyMoveInstantaneousRewardsCertEncoding>,
423}
424
425impl ShelleyMoveInstantaneousRewardsCert {
426    pub fn new(shelley_move_instantaneous_reward: ShelleyMoveInstantaneousReward) -> Self {
427        Self {
428            shelley_move_instantaneous_reward,
429            encodings: None,
430        }
431    }
432}
433
434#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
435pub struct ShelleyMultiHostName {
436    /// A SRV DNS record
437    pub shelley_dns_name: ShelleyDNSName,
438    #[serde(skip)]
439    pub encodings: Option<ShelleyMultiHostNameEncoding>,
440}
441
442impl ShelleyMultiHostName {
443    /// * `shelley_dns_name` - A SRV DNS record
444    pub fn new(shelley_dns_name: ShelleyDNSName) -> Self {
445        Self {
446            shelley_dns_name,
447            encodings: None,
448        }
449    }
450}
451
452#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
453pub struct ShelleyPoolParams {
454    pub operator: Ed25519KeyHash,
455    pub vrf_keyhash: VRFKeyHash,
456    pub pledge: Coin,
457    pub cost: Coin,
458    pub margin: UnitInterval,
459    pub reward_account: RewardAccount,
460    pub pool_owners: Vec<Ed25519KeyHash>,
461    pub relays: Vec<ShelleyRelay>,
462    pub pool_metadata: Option<PoolMetadata>,
463    #[serde(skip)]
464    pub encodings: Option<ShelleyPoolParamsEncoding>,
465}
466
467impl ShelleyPoolParams {
468    pub fn new(
469        operator: Ed25519KeyHash,
470        vrf_keyhash: VRFKeyHash,
471        pledge: Coin,
472        cost: Coin,
473        margin: UnitInterval,
474        reward_account: RewardAccount,
475        pool_owners: Vec<Ed25519KeyHash>,
476        relays: Vec<ShelleyRelay>,
477        pool_metadata: Option<PoolMetadata>,
478    ) -> Self {
479        Self {
480            operator,
481            vrf_keyhash,
482            pledge,
483            cost,
484            margin,
485            reward_account,
486            pool_owners,
487            relays,
488            pool_metadata,
489            encodings: None,
490        }
491    }
492}
493
494#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
495pub struct ShelleyPoolRegistration {
496    pub pool_params: ShelleyPoolParams,
497    #[serde(skip)]
498    pub encodings: Option<ShelleyPoolRegistrationEncoding>,
499}
500
501impl ShelleyPoolRegistration {
502    pub fn new(pool_params: ShelleyPoolParams) -> Self {
503        Self {
504            pool_params,
505            encodings: None,
506        }
507    }
508}
509
510pub type ShelleyProposedProtocolParameterUpdates =
511    OrderedHashMap<GenesisHash, ShelleyProtocolParamUpdate>;
512
513#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
514pub struct ShelleyProtocolParamUpdate {
515    pub minfee_a: Option<u64>,
516    pub minfee_b: Option<u64>,
517    pub max_block_body_size: Option<u64>,
518    pub max_transaction_size: Option<u64>,
519    pub max_block_header_size: Option<u64>,
520    pub key_deposit: Option<Coin>,
521    pub pool_deposit: Option<Coin>,
522    pub maximum_epoch: Option<Epoch>,
523    pub n_opt: Option<u64>,
524    pub pool_pledge_influence: Option<Rational>,
525    pub expansion_rate: Option<UnitInterval>,
526    pub treasury_growth_rate: Option<UnitInterval>,
527    pub decentralization_constant: Option<UnitInterval>,
528    pub extra_entropy: Option<Nonce>,
529    pub protocol_version: Option<ProtocolVersionStruct>,
530    pub min_utxo_value: Option<Coin>,
531    #[serde(skip)]
532    pub encodings: Option<ShelleyProtocolParamUpdateEncoding>,
533}
534
535impl ShelleyProtocolParamUpdate {
536    pub fn new() -> Self {
537        Self {
538            minfee_a: None,
539            minfee_b: None,
540            max_block_body_size: None,
541            max_transaction_size: None,
542            max_block_header_size: None,
543            key_deposit: None,
544            pool_deposit: None,
545            maximum_epoch: None,
546            n_opt: None,
547            pool_pledge_influence: None,
548            expansion_rate: None,
549            treasury_growth_rate: None,
550            decentralization_constant: None,
551            extra_entropy: None,
552            protocol_version: None,
553            min_utxo_value: None,
554            encodings: None,
555        }
556    }
557}
558
559impl Default for ShelleyProtocolParamUpdate {
560    fn default() -> Self {
561        Self::new()
562    }
563}
564
565#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
566pub enum ShelleyRelay {
567    SingleHostAddr(SingleHostAddr),
568    ShelleySingleHostName(ShelleySingleHostName),
569    ShelleyMultiHostName(ShelleyMultiHostName),
570}
571
572impl ShelleyRelay {
573    pub fn new_single_host_addr(
574        port: Option<Port>,
575        ipv4: Option<Ipv4>,
576        ipv6: Option<Ipv6>,
577    ) -> Self {
578        Self::SingleHostAddr(SingleHostAddr::new(port, ipv4, ipv6))
579    }
580
581    pub fn new_shelley_single_host_name(
582        port: Option<Port>,
583        shelley_dns_name: ShelleyDNSName,
584    ) -> Self {
585        Self::ShelleySingleHostName(ShelleySingleHostName::new(port, shelley_dns_name))
586    }
587
588    pub fn new_shelley_multi_host_name(shelley_dns_name: ShelleyDNSName) -> Self {
589        Self::ShelleyMultiHostName(ShelleyMultiHostName::new(shelley_dns_name))
590    }
591}
592
593#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
594pub struct ShelleySingleHostName {
595    pub port: Option<Port>,
596    /// An A or AAAA DNS record
597    pub shelley_dns_name: ShelleyDNSName,
598    #[serde(skip)]
599    pub encodings: Option<ShelleySingleHostNameEncoding>,
600}
601
602impl ShelleySingleHostName {
603    /// * `shelley_dns_name` - An A or AAAA DNS record
604    pub fn new(port: Option<Port>, shelley_dns_name: ShelleyDNSName) -> Self {
605        Self {
606            port,
607            shelley_dns_name,
608            encodings: None,
609        }
610    }
611}
612
613#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
614pub struct ShelleyTransaction {
615    pub body: ShelleyTransactionBody,
616    pub witness_set: ShelleyTransactionWitnessSet,
617    pub metadata: Option<Metadata>,
618    #[serde(skip)]
619    pub encodings: Option<ShelleyTransactionEncoding>,
620}
621
622impl ShelleyTransaction {
623    pub fn new(
624        body: ShelleyTransactionBody,
625        witness_set: ShelleyTransactionWitnessSet,
626        metadata: Option<Metadata>,
627    ) -> Self {
628        Self {
629            body,
630            witness_set,
631            metadata,
632            encodings: None,
633        }
634    }
635}
636
637#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
638pub struct ShelleyTransactionBody {
639    pub inputs: Vec<TransactionInput>,
640    pub outputs: Vec<ShelleyTransactionOutput>,
641    pub fee: Coin,
642    pub ttl: u64,
643    pub certs: Option<Vec<ShelleyCertificate>>,
644    pub withdrawals: Option<Withdrawals>,
645    pub update: Option<ShelleyUpdate>,
646    pub auxiliary_data_hash: Option<AuxiliaryDataHash>,
647    #[serde(skip)]
648    pub encodings: Option<ShelleyTransactionBodyEncoding>,
649}
650
651impl ShelleyTransactionBody {
652    pub fn new(
653        inputs: Vec<TransactionInput>,
654        outputs: Vec<ShelleyTransactionOutput>,
655        fee: Coin,
656        ttl: u64,
657    ) -> Self {
658        Self {
659            inputs,
660            outputs,
661            fee,
662            ttl,
663            certs: None,
664            withdrawals: None,
665            update: None,
666            auxiliary_data_hash: None,
667            encodings: None,
668        }
669    }
670}
671
672pub type ShelleyTransactionIndex = u16;
673
674#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
675pub struct ShelleyTransactionOutput {
676    pub address: Address,
677    pub amount: Coin,
678    #[serde(skip)]
679    pub encodings: Option<ShelleyTransactionOutputEncoding>,
680}
681
682impl ShelleyTransactionOutput {
683    pub fn new(address: Address, amount: Coin) -> Self {
684        Self {
685            address,
686            amount,
687            encodings: None,
688        }
689    }
690}
691
692#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
693pub struct ShelleyTransactionWitnessSet {
694    pub vkeywitnesses: Option<Vec<Vkeywitness>>,
695    pub native_scripts: Option<Vec<MultisigScript>>,
696    pub bootstrap_witnesses: Option<Vec<BootstrapWitness>>,
697    #[serde(skip)]
698    pub encodings: Option<ShelleyTransactionWitnessSetEncoding>,
699}
700
701impl ShelleyTransactionWitnessSet {
702    pub fn new() -> Self {
703        Self {
704            vkeywitnesses: None,
705            native_scripts: None,
706            bootstrap_witnesses: None,
707            encodings: None,
708        }
709    }
710}
711
712impl Default for ShelleyTransactionWitnessSet {
713    fn default() -> Self {
714        Self::new()
715    }
716}
717
718#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
719pub struct ShelleyUpdate {
720    pub shelley_proposed_protocol_parameter_updates: ShelleyProposedProtocolParameterUpdates,
721    pub epoch: Epoch,
722    #[serde(skip)]
723    pub encodings: Option<ShelleyUpdateEncoding>,
724}
725
726impl ShelleyUpdate {
727    pub fn new(
728        shelley_proposed_protocol_parameter_updates: ShelleyProposedProtocolParameterUpdates,
729        epoch: Epoch,
730    ) -> Self {
731        Self {
732            shelley_proposed_protocol_parameter_updates,
733            epoch,
734            encodings: None,
735        }
736    }
737}
738
739impl From<ShelleyDNSName> for String {
740    fn from(wrapper: ShelleyDNSName) -> Self {
741        wrapper.inner
742    }
743}