Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation + fix acronym names #339

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chain/rust/src/auxdata/cbor_encodings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct ConwayFormatAuxDataEncoding {
}

#[derive(Clone, Debug, Default)]
pub struct ShelleyMaFormatAuxDataEncoding {
pub struct ShelleyMAFormatAuxDataEncoding {
pub len_encoding: LenEncoding,
pub auxiliary_scripts_encoding: LenEncoding,
}
14 changes: 7 additions & 7 deletions chain/rust/src/auxdata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ pub mod utils;

use crate::plutus::{PlutusV1Script, PlutusV2Script, PlutusV3Script};
use crate::transaction::NativeScript;
use cbor_encodings::{ConwayFormatAuxDataEncoding, ShelleyMaFormatAuxDataEncoding};
use cbor_encodings::{ConwayFormatAuxDataEncoding, ShelleyMAFormatAuxDataEncoding};

pub use metadata::*;

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
pub enum AuxiliaryData {
Shelley(ShelleyFormatAuxData),
ShelleyMA(ShelleyMaFormatAuxData),
ShelleyMA(ShelleyMAFormatAuxData),
Conway(ConwayFormatAuxData),
}

Expand All @@ -24,8 +24,8 @@ impl AuxiliaryData {
Self::Shelley(shelley)
}

pub fn new_shelley_m_a(shelley_m_a: ShelleyMaFormatAuxData) -> Self {
Self::ShelleyMA(shelley_m_a)
pub fn new_shelley_ma(shelley_ma: ShelleyMAFormatAuxData) -> Self {
Self::ShelleyMA(shelley_ma)
}

pub fn new_conway(conway: ConwayFormatAuxData) -> Self {
Expand Down Expand Up @@ -66,14 +66,14 @@ impl Default for ConwayFormatAuxData {
pub type ShelleyFormatAuxData = Metadata;

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
pub struct ShelleyMaFormatAuxData {
pub struct ShelleyMAFormatAuxData {
pub transaction_metadata: Metadata,
pub auxiliary_scripts: Vec<NativeScript>,
#[serde(skip)]
pub encodings: Option<ShelleyMaFormatAuxDataEncoding>,
pub encodings: Option<ShelleyMAFormatAuxDataEncoding>,
}

impl ShelleyMaFormatAuxData {
impl ShelleyMAFormatAuxData {
pub fn new(transaction_metadata: Metadata, auxiliary_scripts: Vec<NativeScript>) -> Self {
Self {
transaction_metadata,
Expand Down
18 changes: 9 additions & 9 deletions chain/rust/src/auxdata/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ impl Serialize for AuxiliaryData {
) -> cbor_event::Result<&'se mut Serializer<W>> {
match self {
AuxiliaryData::Shelley(shelley) => shelley.serialize(serializer, force_canonical),
AuxiliaryData::ShelleyMA(shelley_m_a) => {
shelley_m_a.serialize(serializer, force_canonical)
AuxiliaryData::ShelleyMA(shelley_ma) => {
shelley_ma.serialize(serializer, force_canonical)
}
AuxiliaryData::Conway(conway) => conway.serialize(serializer, force_canonical),
}
Expand All @@ -43,9 +43,9 @@ impl Deserialize for AuxiliaryData {
}
};
let deser_variant: Result<_, DeserializeError> =
ShelleyMaFormatAuxData::deserialize(raw);
ShelleyMAFormatAuxData::deserialize(raw);
match deser_variant {
Ok(shelley_m_a) => return Ok(Self::ShelleyMA(shelley_m_a)),
Ok(shelley_ma) => return Ok(Self::ShelleyMA(shelley_ma)),
Err(e) => {
errs.push(e.annotate("ShelleyMA"));
raw.as_mut_ref()
Expand Down Expand Up @@ -513,7 +513,7 @@ impl Deserialize for ConwayFormatAuxData {
}
}

impl Serialize for ShelleyMaFormatAuxData {
impl Serialize for ShelleyMAFormatAuxData {
fn serialize<'se, W: Write>(
&self,
serializer: &'se mut Serializer<W>,
Expand Down Expand Up @@ -551,7 +551,7 @@ impl Serialize for ShelleyMaFormatAuxData {
}
}

impl Deserialize for ShelleyMaFormatAuxData {
impl Deserialize for ShelleyMAFormatAuxData {
fn deserialize<R: BufRead + Seek>(raw: &mut Deserializer<R>) -> Result<Self, DeserializeError> {
let len = raw.array_sz()?;
let len_encoding: LenEncoding = len.into();
Expand Down Expand Up @@ -586,15 +586,15 @@ impl Deserialize for ShelleyMaFormatAuxData {
_ => return Err(DeserializeFailure::EndingBreakMissing.into()),
},
}
Ok(ShelleyMaFormatAuxData {
Ok(ShelleyMAFormatAuxData {
transaction_metadata,
auxiliary_scripts,
encodings: Some(ShelleyMaFormatAuxDataEncoding {
encodings: Some(ShelleyMAFormatAuxDataEncoding {
len_encoding,
auxiliary_scripts_encoding,
}),
})
})()
.map_err(|e| e.annotate("ShelleyMaFormatAuxData"))
.map_err(|e| e.annotate("ShelleyMAFormatAuxData"))
}
}
4 changes: 2 additions & 2 deletions chain/rust/src/auxdata/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
transaction::NativeScript,
};

use super::{AuxiliaryData, ConwayFormatAuxData, ShelleyMaFormatAuxData};
use super::{AuxiliaryData, ConwayFormatAuxData, ShelleyMAFormatAuxData};

impl AuxiliaryData {
pub fn new() -> Self {
Expand Down Expand Up @@ -81,7 +81,7 @@ impl AuxiliaryData {
pub fn add_native_scripts(&mut self, scripts: Vec<NativeScript>) {
match self {
Self::Shelley(shelley) => {
*self = Self::ShelleyMA(ShelleyMaFormatAuxData::new(shelley.clone(), scripts));
*self = Self::ShelleyMA(ShelleyMAFormatAuxData::new(shelley.clone(), scripts));
}
Self::ShelleyMA(shelley_ma) => {
shelley_ma.auxiliary_scripts.extend(scripts);
Expand Down
16 changes: 8 additions & 8 deletions chain/rust/src/certs/cbor_encodings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct AuthCommitteeHotCertEncoding {
}

#[derive(Clone, Debug, Default)]
pub struct DnsNameEncoding {
pub struct DNSNameEncoding {
pub inner_encoding: StringEncoding,
}

Expand Down Expand Up @@ -64,14 +64,14 @@ pub struct PoolRetirementEncoding {
pub struct RegCertEncoding {
pub len_encoding: LenEncoding,
pub tag_encoding: Option<cbor_event::Sz>,
pub coin_encoding: Option<cbor_event::Sz>,
pub deposit_encoding: Option<cbor_event::Sz>,
}

#[derive(Clone, Debug, Default)]
pub struct RegDrepCertEncoding {
pub len_encoding: LenEncoding,
pub index_0_encoding: Option<cbor_event::Sz>,
pub coin_encoding: Option<cbor_event::Sz>,
pub deposit_encoding: Option<cbor_event::Sz>,
}

#[derive(Clone, Debug, Default)]
Expand Down Expand Up @@ -112,7 +112,7 @@ pub struct StakeRegDelegCertEncoding {
pub len_encoding: LenEncoding,
pub tag_encoding: Option<cbor_event::Sz>,
pub pool_encoding: StringEncoding,
pub coin_encoding: Option<cbor_event::Sz>,
pub deposit_encoding: Option<cbor_event::Sz>,
}

#[derive(Clone, Debug, Default)]
Expand All @@ -133,21 +133,21 @@ pub struct StakeVoteRegDelegCertEncoding {
pub len_encoding: LenEncoding,
pub tag_encoding: Option<cbor_event::Sz>,
pub pool_encoding: StringEncoding,
pub coin_encoding: Option<cbor_event::Sz>,
pub deposit_encoding: Option<cbor_event::Sz>,
}

#[derive(Clone, Debug, Default)]
pub struct UnregCertEncoding {
pub len_encoding: LenEncoding,
pub tag_encoding: Option<cbor_event::Sz>,
pub coin_encoding: Option<cbor_event::Sz>,
pub deposit_encoding: Option<cbor_event::Sz>,
}

#[derive(Clone, Debug, Default)]
pub struct UnregDrepCertEncoding {
pub len_encoding: LenEncoding,
pub index_0_encoding: Option<cbor_event::Sz>,
pub coin_encoding: Option<cbor_event::Sz>,
pub deposit_encoding: Option<cbor_event::Sz>,
}

#[derive(Clone, Debug, Default)]
Expand All @@ -171,5 +171,5 @@ pub struct VoteDelegCertEncoding {
pub struct VoteRegDelegCertEncoding {
pub len_encoding: LenEncoding,
pub tag_encoding: Option<cbor_event::Sz>,
pub coin_encoding: Option<cbor_event::Sz>,
pub deposit_encoding: Option<cbor_event::Sz>,
}
Loading
Loading