From d0138770652a615e3cd99447f2f2727658c17450 Mon Sep 17 00:00:00 2001 From: Jay Geng Date: Mon, 15 Apr 2024 17:47:14 -0400 Subject: [PATCH] Define contract spec for Hash; adds instruction for XDR-gen (#361) * Define contract spec for Hash * Add instruction for xdr regeneration --- README.md | 20 ++++++++ src/curr/generated.rs | 114 +++++++++++++++++++++++++++++++++++++----- src/next/generated.rs | 114 +++++++++++++++++++++++++++++++++++++----- xdr/curr | 2 +- xdr/curr-version | 2 +- xdr/next | 2 +- xdr/next-version | 2 +- 7 files changed, 226 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 5ec42dc6..bf8fa9fe 100644 --- a/README.md +++ b/README.md @@ -88,3 +88,23 @@ stellar-xdr decode --type BucketEntry --input stream-framed --output json-format ``` License: Apache-2.0 + + +### For Developers: How to Regenerate From XDR +To regenerate types from XDR definitions +1. Update XDR definitions +```concole +git submodule update --init --remote +``` +The `--init` flag is only required for the first time setting up the local project. +`--remote` flag will make sure to fetch the latest changes from from the remote-tracking branches `curr` and `next` at [stellar/stellar-xdr]. + +**_NOTE:_** if you had multiple remotes specified in the submodules (e.g. one tracking `stellar/stellar-xdr`, the other tracking `your-fork/stellar-xdr`), +make sure the remote that tracks [stellar/stellar-xdr] match with what's specifies in the `.git/config` or `.gitsubmodules` (with `.git/config` taking precedence. If neither file specifies it, then `origin` is used). + +2. Recompile and test +```console +make +``` + +When the regenerated types are ready to be merged, make sure to commit the regenerated code file `src/curr/generated.rs`, `src/next/generated.rs`, the version string file `xdr/curr-version`, `xdr/next-version`, as well as the submodule files `xdr/curr`, `xdr/next`. \ No newline at end of file diff --git a/src/curr/generated.rs b/src/curr/generated.rs index deabc26b..9dba1da3 100644 --- a/src/curr/generated.rs +++ b/src/curr/generated.rs @@ -34,7 +34,7 @@ pub const XDR_FILES_SHA256: [(&str, &str); 12] = [ ), ( "xdr/curr/Stellar-contract-spec.x", - "c7ffa21d2e91afb8e666b33524d307955426ff553a486d670c29217ed9888d49", + "8d7f6bdd82c3e529cd8c6f035202ca0e7677cc05e4727492a165dfdc51a9cb3e", ), ( "xdr/curr/Stellar-contract.x", @@ -5554,6 +5554,7 @@ pub const SC_SPEC_DOC_LIMIT: u64 = 1024; /// SC_SPEC_TYPE_MAP = 1004, /// SC_SPEC_TYPE_TUPLE = 1005, /// SC_SPEC_TYPE_BYTES_N = 1006, +/// SC_SPEC_TYPE_HASH = 1007, /// /// // User defined types. /// SC_SPEC_TYPE_UDT = 2000 @@ -5594,11 +5595,12 @@ pub enum ScSpecType { Map = 1004, Tuple = 1005, BytesN = 1006, + Hash = 1007, Udt = 2000, } impl ScSpecType { - pub const VARIANTS: [ScSpecType; 25] = [ + pub const VARIANTS: [ScSpecType; 26] = [ ScSpecType::Val, ScSpecType::Bool, ScSpecType::Void, @@ -5623,9 +5625,10 @@ impl ScSpecType { ScSpecType::Map, ScSpecType::Tuple, ScSpecType::BytesN, + ScSpecType::Hash, ScSpecType::Udt, ]; - pub const VARIANTS_STR: [&'static str; 25] = [ + pub const VARIANTS_STR: [&'static str; 26] = [ "Val", "Bool", "Void", @@ -5650,6 +5653,7 @@ impl ScSpecType { "Map", "Tuple", "BytesN", + "Hash", "Udt", ]; @@ -5680,12 +5684,13 @@ impl ScSpecType { Self::Map => "Map", Self::Tuple => "Tuple", Self::BytesN => "BytesN", + Self::Hash => "Hash", Self::Udt => "Udt", } } #[must_use] - pub const fn variants() -> [ScSpecType; 25] { + pub const fn variants() -> [ScSpecType; 26] { Self::VARIANTS } } @@ -5740,6 +5745,7 @@ impl TryFrom for ScSpecType { 1004 => ScSpecType::Map, 1005 => ScSpecType::Tuple, 1006 => ScSpecType::BytesN, + 1007 => ScSpecType::Hash, 2000 => ScSpecType::Udt, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), @@ -6030,6 +6036,47 @@ impl WriteXdr for ScSpecTypeBytesN { } } +/// ScSpectTypeHash is an XDR Struct defines as: +/// +/// ```text +/// struct SCSpectTypeHash +/// { +/// uint32 n; +/// }; +/// ``` +/// +#[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") +)] +pub struct ScSpectTypeHash { + pub n: u32, +} + +impl ReadXdr for ScSpectTypeHash { + #[cfg(feature = "std")] + fn read_xdr(r: &mut Limited) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + n: u32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ScSpectTypeHash { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut Limited) -> Result<()> { + w.with_limited_depth(|w| { + self.n.write_xdr(w)?; + Ok(()) + }) + } +} + /// ScSpecTypeUdt is an XDR Struct defines as: /// /// ```text @@ -6107,6 +6154,8 @@ impl WriteXdr for ScSpecTypeUdt { /// SCSpecTypeTuple tuple; /// case SC_SPEC_TYPE_BYTES_N: /// SCSpecTypeBytesN bytesN; +/// case SC_SPEC_TYPE_HASH: +/// SCSpectTypeHash hash; /// case SC_SPEC_TYPE_UDT: /// SCSpecTypeUDT udt; /// }; @@ -6146,11 +6195,12 @@ pub enum ScSpecTypeDef { Map(Box), Tuple(Box), BytesN(ScSpecTypeBytesN), + Hash(ScSpectTypeHash), Udt(ScSpecTypeUdt), } impl ScSpecTypeDef { - pub const VARIANTS: [ScSpecType; 25] = [ + pub const VARIANTS: [ScSpecType; 26] = [ ScSpecType::Val, ScSpecType::Bool, ScSpecType::Void, @@ -6175,9 +6225,10 @@ impl ScSpecTypeDef { ScSpecType::Map, ScSpecType::Tuple, ScSpecType::BytesN, + ScSpecType::Hash, ScSpecType::Udt, ]; - pub const VARIANTS_STR: [&'static str; 25] = [ + pub const VARIANTS_STR: [&'static str; 26] = [ "Val", "Bool", "Void", @@ -6202,6 +6253,7 @@ impl ScSpecTypeDef { "Map", "Tuple", "BytesN", + "Hash", "Udt", ]; @@ -6232,6 +6284,7 @@ impl ScSpecTypeDef { Self::Map(_) => "Map", Self::Tuple(_) => "Tuple", Self::BytesN(_) => "BytesN", + Self::Hash(_) => "Hash", Self::Udt(_) => "Udt", } } @@ -6264,12 +6317,13 @@ impl ScSpecTypeDef { Self::Map(_) => ScSpecType::Map, Self::Tuple(_) => ScSpecType::Tuple, Self::BytesN(_) => ScSpecType::BytesN, + Self::Hash(_) => ScSpecType::Hash, Self::Udt(_) => ScSpecType::Udt, } } #[must_use] - pub const fn variants() -> [ScSpecType; 25] { + pub const fn variants() -> [ScSpecType; 26] { Self::VARIANTS } } @@ -6327,6 +6381,7 @@ impl ReadXdr for ScSpecTypeDef { ScSpecType::Map => Self::Map(Box::::read_xdr(r)?), ScSpecType::Tuple => Self::Tuple(Box::::read_xdr(r)?), ScSpecType::BytesN => Self::BytesN(ScSpecTypeBytesN::read_xdr(r)?), + ScSpecType::Hash => Self::Hash(ScSpectTypeHash::read_xdr(r)?), ScSpecType::Udt => Self::Udt(ScSpecTypeUdt::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), @@ -6367,6 +6422,7 @@ impl WriteXdr for ScSpecTypeDef { Self::Map(v) => v.write_xdr(w)?, Self::Tuple(v) => v.write_xdr(w)?, Self::BytesN(v) => v.write_xdr(w)?, + Self::Hash(v) => v.write_xdr(w)?, Self::Udt(v) => v.write_xdr(w)?, }; Ok(()) @@ -42887,6 +42943,7 @@ pub enum TypeVariant { ScSpecTypeMap, ScSpecTypeTuple, ScSpecTypeBytesN, + ScSpectTypeHash, ScSpecTypeUdt, ScSpecTypeDef, ScSpecUdtStructFieldV0, @@ -43279,7 +43336,7 @@ pub enum TypeVariant { } impl TypeVariant { - pub const VARIANTS: [TypeVariant; 425] = [ + pub const VARIANTS: [TypeVariant; 426] = [ TypeVariant::Value, TypeVariant::ScpBallot, TypeVariant::ScpStatementType, @@ -43316,6 +43373,7 @@ impl TypeVariant { TypeVariant::ScSpecTypeMap, TypeVariant::ScSpecTypeTuple, TypeVariant::ScSpecTypeBytesN, + TypeVariant::ScSpectTypeHash, TypeVariant::ScSpecTypeUdt, TypeVariant::ScSpecTypeDef, TypeVariant::ScSpecUdtStructFieldV0, @@ -43706,7 +43764,7 @@ impl TypeVariant { TypeVariant::HmacSha256Key, TypeVariant::HmacSha256Mac, ]; - pub const VARIANTS_STR: [&'static str; 425] = [ + pub const VARIANTS_STR: [&'static str; 426] = [ "Value", "ScpBallot", "ScpStatementType", @@ -43743,6 +43801,7 @@ impl TypeVariant { "ScSpecTypeMap", "ScSpecTypeTuple", "ScSpecTypeBytesN", + "ScSpectTypeHash", "ScSpecTypeUdt", "ScSpecTypeDef", "ScSpecUdtStructFieldV0", @@ -44174,6 +44233,7 @@ impl TypeVariant { Self::ScSpecTypeMap => "ScSpecTypeMap", Self::ScSpecTypeTuple => "ScSpecTypeTuple", Self::ScSpecTypeBytesN => "ScSpecTypeBytesN", + Self::ScSpectTypeHash => "ScSpectTypeHash", Self::ScSpecTypeUdt => "ScSpecTypeUdt", Self::ScSpecTypeDef => "ScSpecTypeDef", Self::ScSpecUdtStructFieldV0 => "ScSpecUdtStructFieldV0", @@ -44574,7 +44634,7 @@ impl TypeVariant { #[must_use] #[allow(clippy::too_many_lines)] - pub const fn variants() -> [TypeVariant; 425] { + pub const fn variants() -> [TypeVariant; 426] { Self::VARIANTS } } @@ -44637,6 +44697,7 @@ impl core::str::FromStr for TypeVariant { "ScSpecTypeMap" => Ok(Self::ScSpecTypeMap), "ScSpecTypeTuple" => Ok(Self::ScSpecTypeTuple), "ScSpecTypeBytesN" => Ok(Self::ScSpecTypeBytesN), + "ScSpectTypeHash" => Ok(Self::ScSpectTypeHash), "ScSpecTypeUdt" => Ok(Self::ScSpecTypeUdt), "ScSpecTypeDef" => Ok(Self::ScSpecTypeDef), "ScSpecUdtStructFieldV0" => Ok(Self::ScSpecUdtStructFieldV0), @@ -45085,6 +45146,7 @@ pub enum Type { ScSpecTypeMap(Box), ScSpecTypeTuple(Box), ScSpecTypeBytesN(Box), + ScSpectTypeHash(Box), ScSpecTypeUdt(Box), ScSpecTypeDef(Box), ScSpecUdtStructFieldV0(Box), @@ -45477,7 +45539,7 @@ pub enum Type { } impl Type { - pub const VARIANTS: [TypeVariant; 425] = [ + pub const VARIANTS: [TypeVariant; 426] = [ TypeVariant::Value, TypeVariant::ScpBallot, TypeVariant::ScpStatementType, @@ -45514,6 +45576,7 @@ impl Type { TypeVariant::ScSpecTypeMap, TypeVariant::ScSpecTypeTuple, TypeVariant::ScSpecTypeBytesN, + TypeVariant::ScSpectTypeHash, TypeVariant::ScSpecTypeUdt, TypeVariant::ScSpecTypeDef, TypeVariant::ScSpecUdtStructFieldV0, @@ -45904,7 +45967,7 @@ impl Type { TypeVariant::HmacSha256Key, TypeVariant::HmacSha256Mac, ]; - pub const VARIANTS_STR: [&'static str; 425] = [ + pub const VARIANTS_STR: [&'static str; 426] = [ "Value", "ScpBallot", "ScpStatementType", @@ -45941,6 +46004,7 @@ impl Type { "ScSpecTypeMap", "ScSpecTypeTuple", "ScSpecTypeBytesN", + "ScSpectTypeHash", "ScSpecTypeUdt", "ScSpecTypeDef", "ScSpecUdtStructFieldV0", @@ -46488,6 +46552,11 @@ impl Type { ScSpecTypeBytesN::read_xdr(r)?, ))) }), + TypeVariant::ScSpectTypeHash => r.with_limited_depth(|r| { + Ok(Self::ScSpectTypeHash(Box::new(ScSpectTypeHash::read_xdr( + r, + )?))) + }), TypeVariant::ScSpecTypeUdt => r.with_limited_depth(|r| { Ok(Self::ScSpecTypeUdt(Box::new(ScSpecTypeUdt::read_xdr(r)?))) }), @@ -48373,6 +48442,10 @@ impl Type { ReadXdrIter::<_, ScSpecTypeBytesN>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t)))), ), + TypeVariant::ScSpectTypeHash => Box::new( + ReadXdrIter::<_, ScSpectTypeHash>::new(&mut r.inner, r.limits.clone()) + .map(|r| r.map(|t| Self::ScSpectTypeHash(Box::new(t)))), + ), TypeVariant::ScSpecTypeUdt => Box::new( ReadXdrIter::<_, ScSpecTypeUdt>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t)))), @@ -50199,6 +50272,10 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t.0)))), ), + TypeVariant::ScSpectTypeHash => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.limits.clone()) + .map(|r| r.map(|t| Self::ScSpectTypeHash(Box::new(t.0)))), + ), TypeVariant::ScSpecTypeUdt => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t.0)))), @@ -52275,6 +52352,10 @@ impl Type { ReadXdrIter::<_, ScSpecTypeBytesN>::new(dec, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t)))), ), + TypeVariant::ScSpectTypeHash => Box::new( + ReadXdrIter::<_, ScSpectTypeHash>::new(dec, r.limits.clone()) + .map(|r| r.map(|t| Self::ScSpectTypeHash(Box::new(t)))), + ), TypeVariant::ScSpecTypeUdt => Box::new( ReadXdrIter::<_, ScSpecTypeUdt>::new(dec, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t)))), @@ -53965,6 +54046,9 @@ impl Type { TypeVariant::ScSpecTypeBytesN => Ok(Self::ScSpecTypeBytesN(Box::new( serde_json::from_reader(r)?, ))), + TypeVariant::ScSpectTypeHash => { + Ok(Self::ScSpectTypeHash(Box::new(serde_json::from_reader(r)?))) + } TypeVariant::ScSpecTypeUdt => { Ok(Self::ScSpecTypeUdt(Box::new(serde_json::from_reader(r)?))) } @@ -55063,6 +55147,7 @@ impl Type { Self::ScSpecTypeMap(ref v) => v.as_ref(), Self::ScSpecTypeTuple(ref v) => v.as_ref(), Self::ScSpecTypeBytesN(ref v) => v.as_ref(), + Self::ScSpectTypeHash(ref v) => v.as_ref(), Self::ScSpecTypeUdt(ref v) => v.as_ref(), Self::ScSpecTypeDef(ref v) => v.as_ref(), Self::ScSpecUdtStructFieldV0(ref v) => v.as_ref(), @@ -55499,6 +55584,7 @@ impl Type { Self::ScSpecTypeMap(_) => "ScSpecTypeMap", Self::ScSpecTypeTuple(_) => "ScSpecTypeTuple", Self::ScSpecTypeBytesN(_) => "ScSpecTypeBytesN", + Self::ScSpectTypeHash(_) => "ScSpectTypeHash", Self::ScSpecTypeUdt(_) => "ScSpecTypeUdt", Self::ScSpecTypeDef(_) => "ScSpecTypeDef", Self::ScSpecUdtStructFieldV0(_) => "ScSpecUdtStructFieldV0", @@ -55903,7 +55989,7 @@ impl Type { #[must_use] #[allow(clippy::too_many_lines)] - pub const fn variants() -> [TypeVariant; 425] { + pub const fn variants() -> [TypeVariant; 426] { Self::VARIANTS } @@ -55955,6 +56041,7 @@ impl Type { Self::ScSpecTypeMap(_) => TypeVariant::ScSpecTypeMap, Self::ScSpecTypeTuple(_) => TypeVariant::ScSpecTypeTuple, Self::ScSpecTypeBytesN(_) => TypeVariant::ScSpecTypeBytesN, + Self::ScSpectTypeHash(_) => TypeVariant::ScSpectTypeHash, Self::ScSpecTypeUdt(_) => TypeVariant::ScSpecTypeUdt, Self::ScSpecTypeDef(_) => TypeVariant::ScSpecTypeDef, Self::ScSpecUdtStructFieldV0(_) => TypeVariant::ScSpecUdtStructFieldV0, @@ -56446,6 +56533,7 @@ impl WriteXdr for Type { Self::ScSpecTypeMap(v) => v.write_xdr(w), Self::ScSpecTypeTuple(v) => v.write_xdr(w), Self::ScSpecTypeBytesN(v) => v.write_xdr(w), + Self::ScSpectTypeHash(v) => v.write_xdr(w), Self::ScSpecTypeUdt(v) => v.write_xdr(w), Self::ScSpecTypeDef(v) => v.write_xdr(w), Self::ScSpecUdtStructFieldV0(v) => v.write_xdr(w), diff --git a/src/next/generated.rs b/src/next/generated.rs index 5e1bb265..f95d7443 100644 --- a/src/next/generated.rs +++ b/src/next/generated.rs @@ -34,7 +34,7 @@ pub const XDR_FILES_SHA256: [(&str, &str); 12] = [ ), ( "xdr/next/Stellar-contract-spec.x", - "c7ffa21d2e91afb8e666b33524d307955426ff553a486d670c29217ed9888d49", + "8d7f6bdd82c3e529cd8c6f035202ca0e7677cc05e4727492a165dfdc51a9cb3e", ), ( "xdr/next/Stellar-contract.x", @@ -5554,6 +5554,7 @@ pub const SC_SPEC_DOC_LIMIT: u64 = 1024; /// SC_SPEC_TYPE_MAP = 1004, /// SC_SPEC_TYPE_TUPLE = 1005, /// SC_SPEC_TYPE_BYTES_N = 1006, +/// SC_SPEC_TYPE_HASH = 1007, /// /// // User defined types. /// SC_SPEC_TYPE_UDT = 2000 @@ -5594,11 +5595,12 @@ pub enum ScSpecType { Map = 1004, Tuple = 1005, BytesN = 1006, + Hash = 1007, Udt = 2000, } impl ScSpecType { - pub const VARIANTS: [ScSpecType; 25] = [ + pub const VARIANTS: [ScSpecType; 26] = [ ScSpecType::Val, ScSpecType::Bool, ScSpecType::Void, @@ -5623,9 +5625,10 @@ impl ScSpecType { ScSpecType::Map, ScSpecType::Tuple, ScSpecType::BytesN, + ScSpecType::Hash, ScSpecType::Udt, ]; - pub const VARIANTS_STR: [&'static str; 25] = [ + pub const VARIANTS_STR: [&'static str; 26] = [ "Val", "Bool", "Void", @@ -5650,6 +5653,7 @@ impl ScSpecType { "Map", "Tuple", "BytesN", + "Hash", "Udt", ]; @@ -5680,12 +5684,13 @@ impl ScSpecType { Self::Map => "Map", Self::Tuple => "Tuple", Self::BytesN => "BytesN", + Self::Hash => "Hash", Self::Udt => "Udt", } } #[must_use] - pub const fn variants() -> [ScSpecType; 25] { + pub const fn variants() -> [ScSpecType; 26] { Self::VARIANTS } } @@ -5740,6 +5745,7 @@ impl TryFrom for ScSpecType { 1004 => ScSpecType::Map, 1005 => ScSpecType::Tuple, 1006 => ScSpecType::BytesN, + 1007 => ScSpecType::Hash, 2000 => ScSpecType::Udt, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), @@ -6030,6 +6036,47 @@ impl WriteXdr for ScSpecTypeBytesN { } } +/// ScSpectTypeHash is an XDR Struct defines as: +/// +/// ```text +/// struct SCSpectTypeHash +/// { +/// uint32 n; +/// }; +/// ``` +/// +#[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") +)] +pub struct ScSpectTypeHash { + pub n: u32, +} + +impl ReadXdr for ScSpectTypeHash { + #[cfg(feature = "std")] + fn read_xdr(r: &mut Limited) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + n: u32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ScSpectTypeHash { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut Limited) -> Result<()> { + w.with_limited_depth(|w| { + self.n.write_xdr(w)?; + Ok(()) + }) + } +} + /// ScSpecTypeUdt is an XDR Struct defines as: /// /// ```text @@ -6107,6 +6154,8 @@ impl WriteXdr for ScSpecTypeUdt { /// SCSpecTypeTuple tuple; /// case SC_SPEC_TYPE_BYTES_N: /// SCSpecTypeBytesN bytesN; +/// case SC_SPEC_TYPE_HASH: +/// SCSpectTypeHash hash; /// case SC_SPEC_TYPE_UDT: /// SCSpecTypeUDT udt; /// }; @@ -6146,11 +6195,12 @@ pub enum ScSpecTypeDef { Map(Box), Tuple(Box), BytesN(ScSpecTypeBytesN), + Hash(ScSpectTypeHash), Udt(ScSpecTypeUdt), } impl ScSpecTypeDef { - pub const VARIANTS: [ScSpecType; 25] = [ + pub const VARIANTS: [ScSpecType; 26] = [ ScSpecType::Val, ScSpecType::Bool, ScSpecType::Void, @@ -6175,9 +6225,10 @@ impl ScSpecTypeDef { ScSpecType::Map, ScSpecType::Tuple, ScSpecType::BytesN, + ScSpecType::Hash, ScSpecType::Udt, ]; - pub const VARIANTS_STR: [&'static str; 25] = [ + pub const VARIANTS_STR: [&'static str; 26] = [ "Val", "Bool", "Void", @@ -6202,6 +6253,7 @@ impl ScSpecTypeDef { "Map", "Tuple", "BytesN", + "Hash", "Udt", ]; @@ -6232,6 +6284,7 @@ impl ScSpecTypeDef { Self::Map(_) => "Map", Self::Tuple(_) => "Tuple", Self::BytesN(_) => "BytesN", + Self::Hash(_) => "Hash", Self::Udt(_) => "Udt", } } @@ -6264,12 +6317,13 @@ impl ScSpecTypeDef { Self::Map(_) => ScSpecType::Map, Self::Tuple(_) => ScSpecType::Tuple, Self::BytesN(_) => ScSpecType::BytesN, + Self::Hash(_) => ScSpecType::Hash, Self::Udt(_) => ScSpecType::Udt, } } #[must_use] - pub const fn variants() -> [ScSpecType; 25] { + pub const fn variants() -> [ScSpecType; 26] { Self::VARIANTS } } @@ -6327,6 +6381,7 @@ impl ReadXdr for ScSpecTypeDef { ScSpecType::Map => Self::Map(Box::::read_xdr(r)?), ScSpecType::Tuple => Self::Tuple(Box::::read_xdr(r)?), ScSpecType::BytesN => Self::BytesN(ScSpecTypeBytesN::read_xdr(r)?), + ScSpecType::Hash => Self::Hash(ScSpectTypeHash::read_xdr(r)?), ScSpecType::Udt => Self::Udt(ScSpecTypeUdt::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), @@ -6367,6 +6422,7 @@ impl WriteXdr for ScSpecTypeDef { Self::Map(v) => v.write_xdr(w)?, Self::Tuple(v) => v.write_xdr(w)?, Self::BytesN(v) => v.write_xdr(w)?, + Self::Hash(v) => v.write_xdr(w)?, Self::Udt(v) => v.write_xdr(w)?, }; Ok(()) @@ -42887,6 +42943,7 @@ pub enum TypeVariant { ScSpecTypeMap, ScSpecTypeTuple, ScSpecTypeBytesN, + ScSpectTypeHash, ScSpecTypeUdt, ScSpecTypeDef, ScSpecUdtStructFieldV0, @@ -43279,7 +43336,7 @@ pub enum TypeVariant { } impl TypeVariant { - pub const VARIANTS: [TypeVariant; 425] = [ + pub const VARIANTS: [TypeVariant; 426] = [ TypeVariant::Value, TypeVariant::ScpBallot, TypeVariant::ScpStatementType, @@ -43316,6 +43373,7 @@ impl TypeVariant { TypeVariant::ScSpecTypeMap, TypeVariant::ScSpecTypeTuple, TypeVariant::ScSpecTypeBytesN, + TypeVariant::ScSpectTypeHash, TypeVariant::ScSpecTypeUdt, TypeVariant::ScSpecTypeDef, TypeVariant::ScSpecUdtStructFieldV0, @@ -43706,7 +43764,7 @@ impl TypeVariant { TypeVariant::HmacSha256Key, TypeVariant::HmacSha256Mac, ]; - pub const VARIANTS_STR: [&'static str; 425] = [ + pub const VARIANTS_STR: [&'static str; 426] = [ "Value", "ScpBallot", "ScpStatementType", @@ -43743,6 +43801,7 @@ impl TypeVariant { "ScSpecTypeMap", "ScSpecTypeTuple", "ScSpecTypeBytesN", + "ScSpectTypeHash", "ScSpecTypeUdt", "ScSpecTypeDef", "ScSpecUdtStructFieldV0", @@ -44174,6 +44233,7 @@ impl TypeVariant { Self::ScSpecTypeMap => "ScSpecTypeMap", Self::ScSpecTypeTuple => "ScSpecTypeTuple", Self::ScSpecTypeBytesN => "ScSpecTypeBytesN", + Self::ScSpectTypeHash => "ScSpectTypeHash", Self::ScSpecTypeUdt => "ScSpecTypeUdt", Self::ScSpecTypeDef => "ScSpecTypeDef", Self::ScSpecUdtStructFieldV0 => "ScSpecUdtStructFieldV0", @@ -44574,7 +44634,7 @@ impl TypeVariant { #[must_use] #[allow(clippy::too_many_lines)] - pub const fn variants() -> [TypeVariant; 425] { + pub const fn variants() -> [TypeVariant; 426] { Self::VARIANTS } } @@ -44637,6 +44697,7 @@ impl core::str::FromStr for TypeVariant { "ScSpecTypeMap" => Ok(Self::ScSpecTypeMap), "ScSpecTypeTuple" => Ok(Self::ScSpecTypeTuple), "ScSpecTypeBytesN" => Ok(Self::ScSpecTypeBytesN), + "ScSpectTypeHash" => Ok(Self::ScSpectTypeHash), "ScSpecTypeUdt" => Ok(Self::ScSpecTypeUdt), "ScSpecTypeDef" => Ok(Self::ScSpecTypeDef), "ScSpecUdtStructFieldV0" => Ok(Self::ScSpecUdtStructFieldV0), @@ -45085,6 +45146,7 @@ pub enum Type { ScSpecTypeMap(Box), ScSpecTypeTuple(Box), ScSpecTypeBytesN(Box), + ScSpectTypeHash(Box), ScSpecTypeUdt(Box), ScSpecTypeDef(Box), ScSpecUdtStructFieldV0(Box), @@ -45477,7 +45539,7 @@ pub enum Type { } impl Type { - pub const VARIANTS: [TypeVariant; 425] = [ + pub const VARIANTS: [TypeVariant; 426] = [ TypeVariant::Value, TypeVariant::ScpBallot, TypeVariant::ScpStatementType, @@ -45514,6 +45576,7 @@ impl Type { TypeVariant::ScSpecTypeMap, TypeVariant::ScSpecTypeTuple, TypeVariant::ScSpecTypeBytesN, + TypeVariant::ScSpectTypeHash, TypeVariant::ScSpecTypeUdt, TypeVariant::ScSpecTypeDef, TypeVariant::ScSpecUdtStructFieldV0, @@ -45904,7 +45967,7 @@ impl Type { TypeVariant::HmacSha256Key, TypeVariant::HmacSha256Mac, ]; - pub const VARIANTS_STR: [&'static str; 425] = [ + pub const VARIANTS_STR: [&'static str; 426] = [ "Value", "ScpBallot", "ScpStatementType", @@ -45941,6 +46004,7 @@ impl Type { "ScSpecTypeMap", "ScSpecTypeTuple", "ScSpecTypeBytesN", + "ScSpectTypeHash", "ScSpecTypeUdt", "ScSpecTypeDef", "ScSpecUdtStructFieldV0", @@ -46488,6 +46552,11 @@ impl Type { ScSpecTypeBytesN::read_xdr(r)?, ))) }), + TypeVariant::ScSpectTypeHash => r.with_limited_depth(|r| { + Ok(Self::ScSpectTypeHash(Box::new(ScSpectTypeHash::read_xdr( + r, + )?))) + }), TypeVariant::ScSpecTypeUdt => r.with_limited_depth(|r| { Ok(Self::ScSpecTypeUdt(Box::new(ScSpecTypeUdt::read_xdr(r)?))) }), @@ -48373,6 +48442,10 @@ impl Type { ReadXdrIter::<_, ScSpecTypeBytesN>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t)))), ), + TypeVariant::ScSpectTypeHash => Box::new( + ReadXdrIter::<_, ScSpectTypeHash>::new(&mut r.inner, r.limits.clone()) + .map(|r| r.map(|t| Self::ScSpectTypeHash(Box::new(t)))), + ), TypeVariant::ScSpecTypeUdt => Box::new( ReadXdrIter::<_, ScSpecTypeUdt>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t)))), @@ -50199,6 +50272,10 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t.0)))), ), + TypeVariant::ScSpectTypeHash => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.limits.clone()) + .map(|r| r.map(|t| Self::ScSpectTypeHash(Box::new(t.0)))), + ), TypeVariant::ScSpecTypeUdt => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t.0)))), @@ -52275,6 +52352,10 @@ impl Type { ReadXdrIter::<_, ScSpecTypeBytesN>::new(dec, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t)))), ), + TypeVariant::ScSpectTypeHash => Box::new( + ReadXdrIter::<_, ScSpectTypeHash>::new(dec, r.limits.clone()) + .map(|r| r.map(|t| Self::ScSpectTypeHash(Box::new(t)))), + ), TypeVariant::ScSpecTypeUdt => Box::new( ReadXdrIter::<_, ScSpecTypeUdt>::new(dec, r.limits.clone()) .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t)))), @@ -53965,6 +54046,9 @@ impl Type { TypeVariant::ScSpecTypeBytesN => Ok(Self::ScSpecTypeBytesN(Box::new( serde_json::from_reader(r)?, ))), + TypeVariant::ScSpectTypeHash => { + Ok(Self::ScSpectTypeHash(Box::new(serde_json::from_reader(r)?))) + } TypeVariant::ScSpecTypeUdt => { Ok(Self::ScSpecTypeUdt(Box::new(serde_json::from_reader(r)?))) } @@ -55063,6 +55147,7 @@ impl Type { Self::ScSpecTypeMap(ref v) => v.as_ref(), Self::ScSpecTypeTuple(ref v) => v.as_ref(), Self::ScSpecTypeBytesN(ref v) => v.as_ref(), + Self::ScSpectTypeHash(ref v) => v.as_ref(), Self::ScSpecTypeUdt(ref v) => v.as_ref(), Self::ScSpecTypeDef(ref v) => v.as_ref(), Self::ScSpecUdtStructFieldV0(ref v) => v.as_ref(), @@ -55499,6 +55584,7 @@ impl Type { Self::ScSpecTypeMap(_) => "ScSpecTypeMap", Self::ScSpecTypeTuple(_) => "ScSpecTypeTuple", Self::ScSpecTypeBytesN(_) => "ScSpecTypeBytesN", + Self::ScSpectTypeHash(_) => "ScSpectTypeHash", Self::ScSpecTypeUdt(_) => "ScSpecTypeUdt", Self::ScSpecTypeDef(_) => "ScSpecTypeDef", Self::ScSpecUdtStructFieldV0(_) => "ScSpecUdtStructFieldV0", @@ -55903,7 +55989,7 @@ impl Type { #[must_use] #[allow(clippy::too_many_lines)] - pub const fn variants() -> [TypeVariant; 425] { + pub const fn variants() -> [TypeVariant; 426] { Self::VARIANTS } @@ -55955,6 +56041,7 @@ impl Type { Self::ScSpecTypeMap(_) => TypeVariant::ScSpecTypeMap, Self::ScSpecTypeTuple(_) => TypeVariant::ScSpecTypeTuple, Self::ScSpecTypeBytesN(_) => TypeVariant::ScSpecTypeBytesN, + Self::ScSpectTypeHash(_) => TypeVariant::ScSpectTypeHash, Self::ScSpecTypeUdt(_) => TypeVariant::ScSpecTypeUdt, Self::ScSpecTypeDef(_) => TypeVariant::ScSpecTypeDef, Self::ScSpecUdtStructFieldV0(_) => TypeVariant::ScSpecUdtStructFieldV0, @@ -56446,6 +56533,7 @@ impl WriteXdr for Type { Self::ScSpecTypeMap(v) => v.write_xdr(w), Self::ScSpecTypeTuple(v) => v.write_xdr(w), Self::ScSpecTypeBytesN(v) => v.write_xdr(w), + Self::ScSpectTypeHash(v) => v.write_xdr(w), Self::ScSpecTypeUdt(v) => v.write_xdr(w), Self::ScSpecTypeDef(v) => v.write_xdr(w), Self::ScSpecUdtStructFieldV0(v) => v.write_xdr(w), diff --git a/xdr/curr b/xdr/curr index 59062438..2ba40495 160000 --- a/xdr/curr +++ b/xdr/curr @@ -1 +1 @@ -Subproject commit 59062438237d5f77fd6feb060b76288e88b7e222 +Subproject commit 2ba4049554bb0564950e6d9213e01a60fc190f54 diff --git a/xdr/curr-version b/xdr/curr-version index 610c71d2..8c75a203 100644 --- a/xdr/curr-version +++ b/xdr/curr-version @@ -1 +1 @@ -59062438237d5f77fd6feb060b76288e88b7e222 \ No newline at end of file +2ba4049554bb0564950e6d9213e01a60fc190f54 \ No newline at end of file diff --git a/xdr/next b/xdr/next index 9b19baf2..e93d6126 160000 --- a/xdr/next +++ b/xdr/next @@ -1 +1 @@ -Subproject commit 9b19baf22b12d93e6a1a6eb05cd1586c8658a967 +Subproject commit e93d612659437d8e89631a382e4888b52c130bfa diff --git a/xdr/next-version b/xdr/next-version index d7e82b73..41ca7a8e 100644 --- a/xdr/next-version +++ b/xdr/next-version @@ -1 +1 @@ -9b19baf22b12d93e6a1a6eb05cd1586c8658a967 \ No newline at end of file +e93d612659437d8e89631a382e4888b52c130bfa \ No newline at end of file