Skip to content

Commit

Permalink
Update with stellar-xdr containing split interface (#389)
Browse files Browse the repository at this point in the history
* Update with stellar-xdr containing split interface

* update next too

* update curr

* fix curr

* upd
  • Loading branch information
leighmcculloch authored Sep 2, 2024
1 parent 1746499 commit 39d7dbb
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 24 deletions.
116 changes: 106 additions & 10 deletions src/curr/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub const XDR_FILES_SHA256: [(&str, &str); 12] = [
),
(
"xdr/curr/Stellar-contract-env-meta.x",
"928a30de814ee589bc1d2aadd8dd81c39f71b7e6f430f56974505ccb1f49654b",
"75a271414d852096fea3283c63b7f2a702f2905f78fc28eb60ec7d7bd366a780",
),
(
"xdr/curr/Stellar-contract-meta.x",
Expand Down Expand Up @@ -5282,13 +5282,61 @@ impl WriteXdr for ScEnvMetaKind {
}
}

/// ScEnvMetaEntryInterfaceVersion is an XDR NestedStruct defines as:
///
/// ```text
/// struct {
/// uint32 protocol;
/// uint32 preRelease;
/// }
/// ```
///
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "snake_case")
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ScEnvMetaEntryInterfaceVersion {
pub protocol: u32,
pub pre_release: u32,
}

impl ReadXdr for ScEnvMetaEntryInterfaceVersion {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self> {
r.with_limited_depth(|r| {
Ok(Self {
protocol: u32::read_xdr(r)?,
pre_release: u32::read_xdr(r)?,
})
})
}
}

impl WriteXdr for ScEnvMetaEntryInterfaceVersion {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<()> {
w.with_limited_depth(|w| {
self.protocol.write_xdr(w)?;
self.pre_release.write_xdr(w)?;
Ok(())
})
}
}

/// ScEnvMetaEntry is an XDR Union defines as:
///
/// ```text
/// union SCEnvMetaEntry switch (SCEnvMetaKind kind)
/// {
/// case SC_ENV_META_KIND_INTERFACE_VERSION:
/// uint64 interfaceVersion;
/// struct {
/// uint32 protocol;
/// uint32 preRelease;
/// } interfaceVersion;
/// };
/// ```
///
Expand All @@ -5303,7 +5351,7 @@ impl WriteXdr for ScEnvMetaKind {
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[allow(clippy::large_enum_variant)]
pub enum ScEnvMetaEntry {
ScEnvMetaKindInterfaceVersion(u64),
ScEnvMetaKindInterfaceVersion(ScEnvMetaEntryInterfaceVersion),
}

impl ScEnvMetaEntry {
Expand Down Expand Up @@ -5361,7 +5409,9 @@ impl ReadXdr for ScEnvMetaEntry {
#[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)]
let v = match dv {
ScEnvMetaKind::ScEnvMetaKindInterfaceVersion => {
Self::ScEnvMetaKindInterfaceVersion(u64::read_xdr(r)?)
Self::ScEnvMetaKindInterfaceVersion(ScEnvMetaEntryInterfaceVersion::read_xdr(
r,
)?)
}
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
Expand Down Expand Up @@ -46106,6 +46156,7 @@ pub enum TypeVariant {
ConfigSettingEntry,
ScEnvMetaKind,
ScEnvMetaEntry,
ScEnvMetaEntryInterfaceVersion,
ScMetaV0,
ScMetaKind,
ScMetaEntry,
Expand Down Expand Up @@ -46541,7 +46592,7 @@ pub enum TypeVariant {
}

impl TypeVariant {
pub const VARIANTS: [TypeVariant; 458] = [
pub const VARIANTS: [TypeVariant; 459] = [
TypeVariant::Value,
TypeVariant::ScpBallot,
TypeVariant::ScpStatementType,
Expand All @@ -46568,6 +46619,7 @@ impl TypeVariant {
TypeVariant::ConfigSettingEntry,
TypeVariant::ScEnvMetaKind,
TypeVariant::ScEnvMetaEntry,
TypeVariant::ScEnvMetaEntryInterfaceVersion,
TypeVariant::ScMetaV0,
TypeVariant::ScMetaKind,
TypeVariant::ScMetaEntry,
Expand Down Expand Up @@ -47001,7 +47053,7 @@ impl TypeVariant {
TypeVariant::BinaryFuseFilterType,
TypeVariant::SerializedBinaryFuseFilter,
];
pub const VARIANTS_STR: [&'static str; 458] = [
pub const VARIANTS_STR: [&'static str; 459] = [
"Value",
"ScpBallot",
"ScpStatementType",
Expand All @@ -47028,6 +47080,7 @@ impl TypeVariant {
"ConfigSettingEntry",
"ScEnvMetaKind",
"ScEnvMetaEntry",
"ScEnvMetaEntryInterfaceVersion",
"ScMetaV0",
"ScMetaKind",
"ScMetaEntry",
Expand Down Expand Up @@ -47492,6 +47545,7 @@ impl TypeVariant {
Self::ConfigSettingEntry => "ConfigSettingEntry",
Self::ScEnvMetaKind => "ScEnvMetaKind",
Self::ScEnvMetaEntry => "ScEnvMetaEntry",
Self::ScEnvMetaEntryInterfaceVersion => "ScEnvMetaEntryInterfaceVersion",
Self::ScMetaV0 => "ScMetaV0",
Self::ScMetaKind => "ScMetaKind",
Self::ScMetaEntry => "ScMetaEntry",
Expand Down Expand Up @@ -47941,7 +47995,7 @@ impl TypeVariant {

#[must_use]
#[allow(clippy::too_many_lines)]
pub const fn variants() -> [TypeVariant; 458] {
pub const fn variants() -> [TypeVariant; 459] {
Self::VARIANTS
}

Expand Down Expand Up @@ -47988,6 +48042,9 @@ impl TypeVariant {
Self::ConfigSettingEntry => gen.into_root_schema_for::<ConfigSettingEntry>(),
Self::ScEnvMetaKind => gen.into_root_schema_for::<ScEnvMetaKind>(),
Self::ScEnvMetaEntry => gen.into_root_schema_for::<ScEnvMetaEntry>(),
Self::ScEnvMetaEntryInterfaceVersion => {
gen.into_root_schema_for::<ScEnvMetaEntryInterfaceVersion>()
}
Self::ScMetaV0 => gen.into_root_schema_for::<ScMetaV0>(),
Self::ScMetaKind => gen.into_root_schema_for::<ScMetaKind>(),
Self::ScMetaEntry => gen.into_root_schema_for::<ScMetaEntry>(),
Expand Down Expand Up @@ -48666,6 +48723,7 @@ impl core::str::FromStr for TypeVariant {
"ConfigSettingEntry" => Ok(Self::ConfigSettingEntry),
"ScEnvMetaKind" => Ok(Self::ScEnvMetaKind),
"ScEnvMetaEntry" => Ok(Self::ScEnvMetaEntry),
"ScEnvMetaEntryInterfaceVersion" => Ok(Self::ScEnvMetaEntryInterfaceVersion),
"ScMetaV0" => Ok(Self::ScMetaV0),
"ScMetaKind" => Ok(Self::ScMetaKind),
"ScMetaEntry" => Ok(Self::ScMetaEntry),
Expand Down Expand Up @@ -49160,6 +49218,7 @@ pub enum Type {
ConfigSettingEntry(Box<ConfigSettingEntry>),
ScEnvMetaKind(Box<ScEnvMetaKind>),
ScEnvMetaEntry(Box<ScEnvMetaEntry>),
ScEnvMetaEntryInterfaceVersion(Box<ScEnvMetaEntryInterfaceVersion>),
ScMetaV0(Box<ScMetaV0>),
ScMetaKind(Box<ScMetaKind>),
ScMetaEntry(Box<ScMetaEntry>),
Expand Down Expand Up @@ -49595,7 +49654,7 @@ pub enum Type {
}

impl Type {
pub const VARIANTS: [TypeVariant; 458] = [
pub const VARIANTS: [TypeVariant; 459] = [
TypeVariant::Value,
TypeVariant::ScpBallot,
TypeVariant::ScpStatementType,
Expand All @@ -49622,6 +49681,7 @@ impl Type {
TypeVariant::ConfigSettingEntry,
TypeVariant::ScEnvMetaKind,
TypeVariant::ScEnvMetaEntry,
TypeVariant::ScEnvMetaEntryInterfaceVersion,
TypeVariant::ScMetaV0,
TypeVariant::ScMetaKind,
TypeVariant::ScMetaEntry,
Expand Down Expand Up @@ -50055,7 +50115,7 @@ impl Type {
TypeVariant::BinaryFuseFilterType,
TypeVariant::SerializedBinaryFuseFilter,
];
pub const VARIANTS_STR: [&'static str; 458] = [
pub const VARIANTS_STR: [&'static str; 459] = [
"Value",
"ScpBallot",
"ScpStatementType",
Expand All @@ -50082,6 +50142,7 @@ impl Type {
"ConfigSettingEntry",
"ScEnvMetaKind",
"ScEnvMetaEntry",
"ScEnvMetaEntryInterfaceVersion",
"ScMetaV0",
"ScMetaKind",
"ScMetaEntry",
Expand Down Expand Up @@ -50634,6 +50695,11 @@ impl Type {
TypeVariant::ScEnvMetaEntry => r.with_limited_depth(|r| {
Ok(Self::ScEnvMetaEntry(Box::new(ScEnvMetaEntry::read_xdr(r)?)))
}),
TypeVariant::ScEnvMetaEntryInterfaceVersion => r.with_limited_depth(|r| {
Ok(Self::ScEnvMetaEntryInterfaceVersion(Box::new(
ScEnvMetaEntryInterfaceVersion::read_xdr(r)?,
)))
}),
TypeVariant::ScMetaV0 => {
r.with_limited_depth(|r| Ok(Self::ScMetaV0(Box::new(ScMetaV0::read_xdr(r)?))))
}
Expand Down Expand Up @@ -52676,6 +52742,13 @@ impl Type {
ReadXdrIter::<_, ScEnvMetaEntry>::new(&mut r.inner, r.limits.clone())
.map(|r| r.map(|t| Self::ScEnvMetaEntry(Box::new(t)))),
),
TypeVariant::ScEnvMetaEntryInterfaceVersion => Box::new(
ReadXdrIter::<_, ScEnvMetaEntryInterfaceVersion>::new(
&mut r.inner,
r.limits.clone(),
)
.map(|r| r.map(|t| Self::ScEnvMetaEntryInterfaceVersion(Box::new(t)))),
),
TypeVariant::ScMetaV0 => Box::new(
ReadXdrIter::<_, ScMetaV0>::new(&mut r.inner, r.limits.clone())
.map(|r| r.map(|t| Self::ScMetaV0(Box::new(t)))),
Expand Down Expand Up @@ -54660,6 +54733,13 @@ impl Type {
ReadXdrIter::<_, Frame<ScEnvMetaEntry>>::new(&mut r.inner, r.limits.clone())
.map(|r| r.map(|t| Self::ScEnvMetaEntry(Box::new(t.0)))),
),
TypeVariant::ScEnvMetaEntryInterfaceVersion => Box::new(
ReadXdrIter::<_, Frame<ScEnvMetaEntryInterfaceVersion>>::new(
&mut r.inner,
r.limits.clone(),
)
.map(|r| r.map(|t| Self::ScEnvMetaEntryInterfaceVersion(Box::new(t.0)))),
),
TypeVariant::ScMetaV0 => Box::new(
ReadXdrIter::<_, Frame<ScMetaV0>>::new(&mut r.inner, r.limits.clone())
.map(|r| r.map(|t| Self::ScMetaV0(Box::new(t.0)))),
Expand Down Expand Up @@ -56923,6 +57003,10 @@ impl Type {
ReadXdrIter::<_, ScEnvMetaEntry>::new(dec, r.limits.clone())
.map(|r| r.map(|t| Self::ScEnvMetaEntry(Box::new(t)))),
),
TypeVariant::ScEnvMetaEntryInterfaceVersion => Box::new(
ReadXdrIter::<_, ScEnvMetaEntryInterfaceVersion>::new(dec, r.limits.clone())
.map(|r| r.map(|t| Self::ScEnvMetaEntryInterfaceVersion(Box::new(t)))),
),
TypeVariant::ScMetaV0 => Box::new(
ReadXdrIter::<_, ScMetaV0>::new(dec, r.limits.clone())
.map(|r| r.map(|t| Self::ScMetaV0(Box::new(t)))),
Expand Down Expand Up @@ -58778,6 +58862,9 @@ impl Type {
TypeVariant::ScEnvMetaEntry => {
Ok(Self::ScEnvMetaEntry(Box::new(serde_json::from_reader(r)?)))
}
TypeVariant::ScEnvMetaEntryInterfaceVersion => Ok(
Self::ScEnvMetaEntryInterfaceVersion(Box::new(serde_json::from_reader(r)?)),
),
TypeVariant::ScMetaV0 => Ok(Self::ScMetaV0(Box::new(serde_json::from_reader(r)?))),
TypeVariant::ScMetaKind => Ok(Self::ScMetaKind(Box::new(serde_json::from_reader(r)?))),
TypeVariant::ScMetaEntry => {
Expand Down Expand Up @@ -60054,6 +60141,11 @@ impl Type {
TypeVariant::ScEnvMetaEntry => Ok(Self::ScEnvMetaEntry(Box::new(
serde::de::Deserialize::deserialize(r)?,
))),
TypeVariant::ScEnvMetaEntryInterfaceVersion => {
Ok(Self::ScEnvMetaEntryInterfaceVersion(Box::new(
serde::de::Deserialize::deserialize(r)?,
)))
}
TypeVariant::ScMetaV0 => Ok(Self::ScMetaV0(Box::new(
serde::de::Deserialize::deserialize(r)?,
))),
Expand Down Expand Up @@ -61451,6 +61543,7 @@ impl Type {
Self::ConfigSettingEntry(ref v) => v.as_ref(),
Self::ScEnvMetaKind(ref v) => v.as_ref(),
Self::ScEnvMetaEntry(ref v) => v.as_ref(),
Self::ScEnvMetaEntryInterfaceVersion(ref v) => v.as_ref(),
Self::ScMetaV0(ref v) => v.as_ref(),
Self::ScMetaKind(ref v) => v.as_ref(),
Self::ScMetaEntry(ref v) => v.as_ref(),
Expand Down Expand Up @@ -61920,6 +62013,7 @@ impl Type {
Self::ConfigSettingEntry(_) => "ConfigSettingEntry",
Self::ScEnvMetaKind(_) => "ScEnvMetaKind",
Self::ScEnvMetaEntry(_) => "ScEnvMetaEntry",
Self::ScEnvMetaEntryInterfaceVersion(_) => "ScEnvMetaEntryInterfaceVersion",
Self::ScMetaV0(_) => "ScMetaV0",
Self::ScMetaKind(_) => "ScMetaKind",
Self::ScMetaEntry(_) => "ScMetaEntry",
Expand Down Expand Up @@ -62377,7 +62471,7 @@ impl Type {

#[must_use]
#[allow(clippy::too_many_lines)]
pub const fn variants() -> [TypeVariant; 458] {
pub const fn variants() -> [TypeVariant; 459] {
Self::VARIANTS
}

Expand Down Expand Up @@ -62419,6 +62513,7 @@ impl Type {
Self::ConfigSettingEntry(_) => TypeVariant::ConfigSettingEntry,
Self::ScEnvMetaKind(_) => TypeVariant::ScEnvMetaKind,
Self::ScEnvMetaEntry(_) => TypeVariant::ScEnvMetaEntry,
Self::ScEnvMetaEntryInterfaceVersion(_) => TypeVariant::ScEnvMetaEntryInterfaceVersion,
Self::ScMetaV0(_) => TypeVariant::ScMetaV0,
Self::ScMetaKind(_) => TypeVariant::ScMetaKind,
Self::ScMetaEntry(_) => TypeVariant::ScMetaEntry,
Expand Down Expand Up @@ -62957,6 +63052,7 @@ impl WriteXdr for Type {
Self::ConfigSettingEntry(v) => v.write_xdr(w),
Self::ScEnvMetaKind(v) => v.write_xdr(w),
Self::ScEnvMetaEntry(v) => v.write_xdr(w),
Self::ScEnvMetaEntryInterfaceVersion(v) => v.write_xdr(w),
Self::ScMetaV0(v) => v.write_xdr(w),
Self::ScMetaKind(v) => v.write_xdr(w),
Self::ScMetaEntry(v) => v.write_xdr(w),
Expand Down
Loading

0 comments on commit 39d7dbb

Please sign in to comment.