Skip to content
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ alloc = ["dep:hex", "dep:stellar-strkey", "escape-bytes/alloc", "dep:ethnum"]

# Features from the XDR
test_feature = []
cap_0071 = []

# Features dependent on optional dependencies.
base64 = ["std", "dep:base64"]
Expand Down
285 changes: 272 additions & 13 deletions src/generated.rs

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/generated/envelope_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ use super::*;
/// ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7,
/// ENVELOPE_TYPE_CONTRACT_ID = 8,
/// ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9
/// #ifdef CAP_0071
/// ,
/// ENVELOPE_TYPE_SOROBAN_AUTHORIZATION_WITH_ADDRESS = 10
/// #endif
/// };
/// ```
///
Expand All @@ -42,6 +46,8 @@ pub enum EnvelopeType {
PoolRevokeOpId = 7,
ContractId = 8,
SorobanAuthorization = 9,
#[cfg(feature = "cap_0071")]
SorobanAuthorizationWithAddress = 10,
}

impl EnvelopeType {
Expand All @@ -56,6 +62,8 @@ impl EnvelopeType {
EnvelopeType::PoolRevokeOpId,
EnvelopeType::ContractId,
EnvelopeType::SorobanAuthorization,
#[cfg(feature = "cap_0071")]
EnvelopeType::SorobanAuthorizationWithAddress,
];
pub const VARIANTS: [EnvelopeType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand All @@ -77,6 +85,8 @@ impl EnvelopeType {
"PoolRevokeOpId",
"ContractId",
"SorobanAuthorization",
#[cfg(feature = "cap_0071")]
"SorobanAuthorizationWithAddress",
];
pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
Expand All @@ -101,6 +111,8 @@ impl EnvelopeType {
Self::PoolRevokeOpId => "PoolRevokeOpId",
Self::ContractId => "ContractId",
Self::SorobanAuthorization => "SorobanAuthorization",
#[cfg(feature = "cap_0071")]
Self::SorobanAuthorizationWithAddress => "SorobanAuthorizationWithAddress",
}
}

Expand Down Expand Up @@ -146,6 +158,8 @@ impl TryFrom<i32> for EnvelopeType {
7 => EnvelopeType::PoolRevokeOpId,
8 => EnvelopeType::ContractId,
9 => EnvelopeType::SorobanAuthorization,
#[cfg(feature = "cap_0071")]
10 => EnvelopeType::SorobanAuthorizationWithAddress,
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand Down
31 changes: 31 additions & 0 deletions src/generated/hash_id_preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ use super::*;
/// uint32 signatureExpirationLedger;
/// SorobanAuthorizedInvocation invocation;
/// } sorobanAuthorization;
/// #ifdef CAP_0071
/// case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION_WITH_ADDRESS:
/// struct
/// {
/// Hash networkID;
/// int64 nonce;
/// uint32 signatureExpirationLedger;
/// SCAddress address;
/// SorobanAuthorizedInvocation invocation;
/// } sorobanAuthorizationWithAddress;
/// #endif
/// };
/// ```
///
Expand All @@ -56,6 +67,8 @@ pub enum HashIdPreimage {
PoolRevokeOpId(HashIdPreimageRevokeId),
ContractId(HashIdPreimageContractId),
SorobanAuthorization(HashIdPreimageSorobanAuthorization),
#[cfg(feature = "cap_0071")]
SorobanAuthorizationWithAddress(HashIdPreimageSorobanAuthorizationWithAddress),
}

#[cfg(feature = "alloc")]
Expand All @@ -71,6 +84,8 @@ impl HashIdPreimage {
EnvelopeType::PoolRevokeOpId,
EnvelopeType::ContractId,
EnvelopeType::SorobanAuthorization,
#[cfg(feature = "cap_0071")]
EnvelopeType::SorobanAuthorizationWithAddress,
];
pub const VARIANTS: [EnvelopeType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand All @@ -86,6 +101,8 @@ impl HashIdPreimage {
"PoolRevokeOpId",
"ContractId",
"SorobanAuthorization",
#[cfg(feature = "cap_0071")]
"SorobanAuthorizationWithAddress",
];
pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
Expand All @@ -104,6 +121,8 @@ impl HashIdPreimage {
Self::PoolRevokeOpId(_) => "PoolRevokeOpId",
Self::ContractId(_) => "ContractId",
Self::SorobanAuthorization(_) => "SorobanAuthorization",
#[cfg(feature = "cap_0071")]
Self::SorobanAuthorizationWithAddress(_) => "SorobanAuthorizationWithAddress",
}
}

Expand All @@ -115,6 +134,10 @@ impl HashIdPreimage {
Self::PoolRevokeOpId(_) => EnvelopeType::PoolRevokeOpId,
Self::ContractId(_) => EnvelopeType::ContractId,
Self::SorobanAuthorization(_) => EnvelopeType::SorobanAuthorization,
#[cfg(feature = "cap_0071")]
Self::SorobanAuthorizationWithAddress(_) => {
EnvelopeType::SorobanAuthorizationWithAddress
}
}
}

Expand Down Expand Up @@ -163,6 +186,12 @@ impl ReadXdr for HashIdPreimage {
EnvelopeType::SorobanAuthorization => {
Self::SorobanAuthorization(HashIdPreimageSorobanAuthorization::read_xdr(r)?)
}
#[cfg(feature = "cap_0071")]
EnvelopeType::SorobanAuthorizationWithAddress => {
Self::SorobanAuthorizationWithAddress(
HashIdPreimageSorobanAuthorizationWithAddress::read_xdr(r)?,
)
}
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand All @@ -182,6 +211,8 @@ impl WriteXdr for HashIdPreimage {
Self::PoolRevokeOpId(v) => v.write_xdr(w)?,
Self::ContractId(v) => v.write_xdr(w)?,
Self::SorobanAuthorization(v) => v.write_xdr(w)?,
#[cfg(feature = "cap_0071")]
Self::SorobanAuthorizationWithAddress(v) => v.write_xdr(w)?,
};
Ok(())
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;

/// HashIdPreimageSorobanAuthorizationWithAddress is an XDR NestedStruct defined as:
///
/// ```text
/// struct
/// {
/// Hash networkID;
/// int64 nonce;
/// uint32 signatureExpirationLedger;
/// SCAddress address;
/// SorobanAuthorizedInvocation invocation;
/// }
/// ```
///
#[cfg(feature = "cap_0071")]
#[cfg_attr(feature = "alloc", derive(Default))]
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_with::serde_as,
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "snake_case")
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct HashIdPreimageSorobanAuthorizationWithAddress {
pub network_id: Hash,
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_as(as = "NumberOrString")
)]
pub nonce: i64,
pub signature_expiration_ledger: u32,
pub address: ScAddress,
pub invocation: SorobanAuthorizedInvocation,
}

#[cfg(feature = "cap_0071")]
impl ReadXdr for HashIdPreimageSorobanAuthorizationWithAddress {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
r.with_limited_depth(|r| {
Ok(Self {
network_id: Hash::read_xdr(r)?,
nonce: i64::read_xdr(r)?,
signature_expiration_ledger: u32::read_xdr(r)?,
address: ScAddress::read_xdr(r)?,
invocation: SorobanAuthorizedInvocation::read_xdr(r)?,
})
})
}
}

#[cfg(feature = "cap_0071")]
impl WriteXdr for HashIdPreimageSorobanAuthorizationWithAddress {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.network_id.write_xdr(w)?;
self.nonce.write_xdr(w)?;
self.signature_expiration_ledger.write_xdr(w)?;
self.address.write_xdr(w)?;
self.invocation.write_xdr(w)?;
Ok(())
})
}
}
54 changes: 54 additions & 0 deletions src/generated/soroban_address_credentials_with_delegates.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;

/// SorobanAddressCredentialsWithDelegates is an XDR Struct defined as:
///
/// ```text
/// struct SorobanAddressCredentialsWithDelegates
/// {
/// SorobanAddressCredentials addressCredentials;
/// SorobanDelegateSignature delegates<>;
/// };
/// ```
///
#[cfg(feature = "cap_0071")]
#[cfg_attr(feature = "alloc", derive(Default))]
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_with::serde_as,
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "snake_case")
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct SorobanAddressCredentialsWithDelegates {
pub address_credentials: SorobanAddressCredentials,
pub delegates: VecM<SorobanDelegateSignature>,
}

#[cfg(feature = "cap_0071")]
impl ReadXdr for SorobanAddressCredentialsWithDelegates {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
r.with_limited_depth(|r| {
Ok(Self {
address_credentials: SorobanAddressCredentials::read_xdr(r)?,
delegates: VecM::<SorobanDelegateSignature>::read_xdr(r)?,
})
})
}
}

#[cfg(feature = "cap_0071")]
impl WriteXdr for SorobanAddressCredentialsWithDelegates {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.address_credentials.write_xdr(w)?;
self.delegates.write_xdr(w)?;
Ok(())
})
}
}
25 changes: 24 additions & 1 deletion src/generated/soroban_credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use super::*;
/// void;
/// case SOROBAN_CREDENTIALS_ADDRESS:
/// SorobanAddressCredentials address;
/// #ifdef CAP_0071
/// case SOROBAN_CREDENTIALS_ADDRESS_WITH_DELEGATES:
/// SorobanAddressCredentialsWithDelegates addressWithDelegates;
/// #endif
/// };
/// ```
///
Expand All @@ -28,6 +32,8 @@ use super::*;
pub enum SorobanCredentials {
SourceAccount,
Address(SorobanAddressCredentials),
#[cfg(feature = "cap_0071")]
AddressWithDelegates(SorobanAddressCredentialsWithDelegates),
}

#[cfg(feature = "alloc")]
Expand All @@ -41,6 +47,8 @@ impl SorobanCredentials {
const _VARIANTS: &[SorobanCredentialsType] = &[
SorobanCredentialsType::SourceAccount,
SorobanCredentialsType::Address,
#[cfg(feature = "cap_0071")]
SorobanCredentialsType::AddressWithDelegates,
];
pub const VARIANTS: [SorobanCredentialsType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand All @@ -51,7 +59,12 @@ impl SorobanCredentials {
}
arr
};
const _VARIANTS_STR: &[&str] = &["SourceAccount", "Address"];
const _VARIANTS_STR: &[&str] = &[
"SourceAccount",
"Address",
#[cfg(feature = "cap_0071")]
"AddressWithDelegates",
];
pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
let mut i = 1;
Expand All @@ -67,6 +80,8 @@ impl SorobanCredentials {
match self {
Self::SourceAccount => "SourceAccount",
Self::Address(_) => "Address",
#[cfg(feature = "cap_0071")]
Self::AddressWithDelegates(_) => "AddressWithDelegates",
}
}

Expand All @@ -76,6 +91,8 @@ impl SorobanCredentials {
match self {
Self::SourceAccount => SorobanCredentialsType::SourceAccount,
Self::Address(_) => SorobanCredentialsType::Address,
#[cfg(feature = "cap_0071")]
Self::AddressWithDelegates(_) => SorobanCredentialsType::AddressWithDelegates,
}
}

Expand Down Expand Up @@ -118,6 +135,10 @@ impl ReadXdr for SorobanCredentials {
SorobanCredentialsType::Address => {
Self::Address(SorobanAddressCredentials::read_xdr(r)?)
}
#[cfg(feature = "cap_0071")]
SorobanCredentialsType::AddressWithDelegates => {
Self::AddressWithDelegates(SorobanAddressCredentialsWithDelegates::read_xdr(r)?)
}
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand All @@ -135,6 +156,8 @@ impl WriteXdr for SorobanCredentials {
match self {
Self::SourceAccount => ().write_xdr(w)?,
Self::Address(v) => v.write_xdr(w)?,
#[cfg(feature = "cap_0071")]
Self::AddressWithDelegates(v) => v.write_xdr(w)?,
};
Ok(())
})
Expand Down
Loading
Loading