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
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ alloc = ["dep:hex", "dep:stellar-strkey", "escape-bytes/alloc", "dep:ethnum"]

# Features from the XDR
test_feature = []
cap_0083 = []
cap_0085_executable_ref = []
cap_0084_muxed_contract = []

# Features available without any new dependencies.
type_enum = []
Expand Down
7 changes: 5 additions & 2 deletions src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub const XDR_FILES_SHA256: [(&str, &str); 13] = [
),
(
"xdr/Stellar-contract.x",
"1e088e19eb379537fd823cb300216e1e73b341c1accb4ba0fcf2871a3ccfb691",
"b87e9474002c0a089a8aa6f4c4e76e74fa497a7c20e3656532f0ac7762374e4e",
),
(
"xdr/Stellar-exporter.x",
Expand All @@ -59,7 +59,7 @@ pub const XDR_FILES_SHA256: [(&str, &str); 13] = [
),
(
"xdr/Stellar-ledger.x",
"4c09454575c291e41b8f514255562a261f8f1cdefa7e8a20062b1108571621b5",
"b6dec791414821d0bae7a11abb4a6b6143ce3e09d0030c580c9ece1815418b13",
),
(
"xdr/Stellar-overlay.x",
Expand Down Expand Up @@ -4366,6 +4366,9 @@ pub use sc_address_type::*;
mod muxed_ed25519_account;
#[allow(unused_imports)]
pub use muxed_ed25519_account::*;
mod muxed_contract;
#[allow(unused_imports)]
pub use muxed_contract::*;
mod sc_address;
#[allow(unused_imports)]
pub use sc_address::*;
Expand Down
15 changes: 1 addition & 14 deletions src/generated/contract_executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ use super::*;
/// Hash wasm_hash;
/// case CONTRACT_EXECUTABLE_STELLAR_ASSET:
/// void;
/// #ifdef CAP_0085_EXECUTABLE_REF
/// case CONTRACT_EXECUTABLE_EXTERNAL_REF:
/// ContractExecutableExternalRef external_ref;
/// #endif
/// };
/// ```
///
Expand All @@ -32,7 +30,6 @@ use super::*;
pub enum ContractExecutable {
Wasm(Hash),
StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
ExternalRef(ContractExecutableExternalRef),
}

Expand All @@ -47,7 +44,6 @@ impl ContractExecutable {
const _VARIANTS: &[ContractExecutableType] = &[
ContractExecutableType::Wasm,
ContractExecutableType::StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
ContractExecutableType::ExternalRef,
];
pub const VARIANTS: [ContractExecutableType; Self::_VARIANTS.len()] = {
Expand All @@ -59,12 +55,7 @@ impl ContractExecutable {
}
arr
};
const _VARIANTS_STR: &[&str] = &[
"Wasm",
"StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
"ExternalRef",
];
const _VARIANTS_STR: &[&str] = &["Wasm", "StellarAsset", "ExternalRef"];
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 @@ -80,7 +71,6 @@ impl ContractExecutable {
match self {
Self::Wasm(_) => "Wasm",
Self::StellarAsset => "StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExternalRef(_) => "ExternalRef",
}
}
Expand All @@ -91,7 +81,6 @@ impl ContractExecutable {
match self {
Self::Wasm(_) => ContractExecutableType::Wasm,
Self::StellarAsset => ContractExecutableType::StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExternalRef(_) => ContractExecutableType::ExternalRef,
}
}
Expand Down Expand Up @@ -133,7 +122,6 @@ impl ReadXdr for ContractExecutable {
let v = match dv {
ContractExecutableType::Wasm => Self::Wasm(Hash::read_xdr(r)?),
ContractExecutableType::StellarAsset => Self::StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
ContractExecutableType::ExternalRef => {
Self::ExternalRef(ContractExecutableExternalRef::read_xdr(r)?)
}
Expand All @@ -154,7 +142,6 @@ impl WriteXdr for ContractExecutable {
match self {
Self::Wasm(v) => v.write_xdr(w)?,
Self::StellarAsset => ().write_xdr(w)?,
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExternalRef(v) => v.write_xdr(w)?,
};
Ok(())
Expand Down
3 changes: 0 additions & 3 deletions src/generated/contract_executable_external_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::*;
/// };
/// ```
///
#[cfg(feature = "cap_0085_executable_ref")]
#[cfg_attr(feature = "alloc", derive(Default))]
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
Expand All @@ -27,7 +26,6 @@ pub struct ContractExecutableExternalRef {
pub tag: ScString,
}

#[cfg(feature = "cap_0085_executable_ref")]
impl ReadXdr for ContractExecutableExternalRef {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
Expand All @@ -40,7 +38,6 @@ impl ReadXdr for ContractExecutableExternalRef {
}
}

#[cfg(feature = "cap_0085_executable_ref")]
impl WriteXdr for ContractExecutableExternalRef {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
Expand Down
17 changes: 3 additions & 14 deletions src/generated/contract_executable_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use super::*;
/// enum ContractExecutableType
/// {
/// CONTRACT_EXECUTABLE_WASM = 0,
/// CONTRACT_EXECUTABLE_STELLAR_ASSET = 1
/// #ifdef CAP_0085_EXECUTABLE_REF
/// ,CONTRACT_EXECUTABLE_EXTERNAL_REF = 2
/// #endif
/// CONTRACT_EXECUTABLE_STELLAR_ASSET = 1,
/// CONTRACT_EXECUTABLE_EXTERNAL_REF = 2
/// };
/// ```
///
Expand All @@ -29,15 +27,13 @@ pub enum ContractExecutableType {
#[cfg_attr(feature = "alloc", default)]
Wasm = 0,
StellarAsset = 1,
#[cfg(feature = "cap_0085_executable_ref")]
ExternalRef = 2,
}

impl ContractExecutableType {
const _VARIANTS: &[ContractExecutableType] = &[
ContractExecutableType::Wasm,
ContractExecutableType::StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
ContractExecutableType::ExternalRef,
];
pub const VARIANTS: [ContractExecutableType; Self::_VARIANTS.len()] = {
Expand All @@ -49,12 +45,7 @@ impl ContractExecutableType {
}
arr
};
const _VARIANTS_STR: &[&str] = &[
"Wasm",
"StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
"ExternalRef",
];
const _VARIANTS_STR: &[&str] = &["Wasm", "StellarAsset", "ExternalRef"];
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 @@ -70,7 +61,6 @@ impl ContractExecutableType {
match self {
Self::Wasm => "Wasm",
Self::StellarAsset => "StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExternalRef => "ExternalRef",
}
}
Expand Down Expand Up @@ -109,7 +99,6 @@ impl TryFrom<i32> for ContractExecutableType {
let e = match i {
0 => ContractExecutableType::Wasm,
1 => ContractExecutableType::StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
2 => ContractExecutableType::ExternalRef,
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
Expand Down
58 changes: 58 additions & 0 deletions src/generated/muxed_contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;

/// MuxedContract is an XDR Struct defined as:
///
/// ```text
/// struct MuxedContract
/// {
/// uint64 id;
/// ContractID contractId;
/// };
/// ```
///
#[cfg(feature = "cap_0084_muxed_contract")]
#[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 MuxedContract {
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_as(as = "NumberOrString")
)]
pub id: u64,
pub contract_id: ContractId,
}

#[cfg(feature = "cap_0084_muxed_contract")]
impl ReadXdr for MuxedContract {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
r.with_limited_depth(|r| {
Ok(Self {
id: u64::read_xdr(r)?,
contract_id: ContractId::read_xdr(r)?,
})
})
}
}

#[cfg(feature = "cap_0084_muxed_contract")]
impl WriteXdr for MuxedContract {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.id.write_xdr(w)?;
self.contract_id.write_xdr(w)?;
Ok(())
})
}
}
18 changes: 18 additions & 0 deletions src/generated/sc_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ use super::*;
/// ClaimableBalanceID claimableBalanceId;
/// case SC_ADDRESS_TYPE_LIQUIDITY_POOL:
/// PoolID liquidityPoolId;
/// #ifdef CAP_0084_MUXED_CONTRACT
/// case SC_ADDRESS_TYPE_MUXED_CONTRACT:
/// MuxedContract muxedContract;
/// #endif
/// };
/// ```
///
Expand All @@ -34,6 +38,8 @@ pub enum ScAddress {
MuxedAccount(MuxedEd25519Account),
ClaimableBalance(ClaimableBalanceId),
LiquidityPool(PoolId),
#[cfg(feature = "cap_0084_muxed_contract")]
MuxedContract(MuxedContract),
}

#[cfg(feature = "alloc")]
Expand All @@ -50,6 +56,8 @@ impl ScAddress {
ScAddressType::MuxedAccount,
ScAddressType::ClaimableBalance,
ScAddressType::LiquidityPool,
#[cfg(feature = "cap_0084_muxed_contract")]
ScAddressType::MuxedContract,
];
pub const VARIANTS: [ScAddressType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand All @@ -66,6 +74,8 @@ impl ScAddress {
"MuxedAccount",
"ClaimableBalance",
"LiquidityPool",
#[cfg(feature = "cap_0084_muxed_contract")]
"MuxedContract",
];
pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
Expand All @@ -85,6 +95,8 @@ impl ScAddress {
Self::MuxedAccount(_) => "MuxedAccount",
Self::ClaimableBalance(_) => "ClaimableBalance",
Self::LiquidityPool(_) => "LiquidityPool",
#[cfg(feature = "cap_0084_muxed_contract")]
Self::MuxedContract(_) => "MuxedContract",
}
}

Expand All @@ -97,6 +109,8 @@ impl ScAddress {
Self::MuxedAccount(_) => ScAddressType::MuxedAccount,
Self::ClaimableBalance(_) => ScAddressType::ClaimableBalance,
Self::LiquidityPool(_) => ScAddressType::LiquidityPool,
#[cfg(feature = "cap_0084_muxed_contract")]
Self::MuxedContract(_) => ScAddressType::MuxedContract,
}
}

Expand Down Expand Up @@ -144,6 +158,8 @@ impl ReadXdr for ScAddress {
Self::ClaimableBalance(ClaimableBalanceId::read_xdr(r)?)
}
ScAddressType::LiquidityPool => Self::LiquidityPool(PoolId::read_xdr(r)?),
#[cfg(feature = "cap_0084_muxed_contract")]
ScAddressType::MuxedContract => Self::MuxedContract(MuxedContract::read_xdr(r)?),
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand All @@ -164,6 +180,8 @@ impl WriteXdr for ScAddress {
Self::MuxedAccount(v) => v.write_xdr(w)?,
Self::ClaimableBalance(v) => v.write_xdr(w)?,
Self::LiquidityPool(v) => v.write_xdr(w)?,
#[cfg(feature = "cap_0084_muxed_contract")]
Self::MuxedContract(v) => v.write_xdr(w)?,
};
Ok(())
})
Expand Down
14 changes: 14 additions & 0 deletions src/generated/sc_address_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use super::*;
/// SC_ADDRESS_TYPE_MUXED_ACCOUNT = 2,
/// SC_ADDRESS_TYPE_CLAIMABLE_BALANCE = 3,
/// SC_ADDRESS_TYPE_LIQUIDITY_POOL = 4
/// #ifdef CAP_0084_MUXED_CONTRACT
/// ,
/// SC_ADDRESS_TYPE_MUXED_CONTRACT = 5
/// #endif
/// };
/// ```
///
Expand All @@ -32,6 +36,8 @@ pub enum ScAddressType {
MuxedAccount = 2,
ClaimableBalance = 3,
LiquidityPool = 4,
#[cfg(feature = "cap_0084_muxed_contract")]
MuxedContract = 5,
}

impl ScAddressType {
Expand All @@ -41,6 +47,8 @@ impl ScAddressType {
ScAddressType::MuxedAccount,
ScAddressType::ClaimableBalance,
ScAddressType::LiquidityPool,
#[cfg(feature = "cap_0084_muxed_contract")]
ScAddressType::MuxedContract,
];
pub const VARIANTS: [ScAddressType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand All @@ -57,6 +65,8 @@ impl ScAddressType {
"MuxedAccount",
"ClaimableBalance",
"LiquidityPool",
#[cfg(feature = "cap_0084_muxed_contract")]
"MuxedContract",
];
pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
Expand All @@ -76,6 +86,8 @@ impl ScAddressType {
Self::MuxedAccount => "MuxedAccount",
Self::ClaimableBalance => "ClaimableBalance",
Self::LiquidityPool => "LiquidityPool",
#[cfg(feature = "cap_0084_muxed_contract")]
Self::MuxedContract => "MuxedContract",
}
}

Expand Down Expand Up @@ -116,6 +128,8 @@ impl TryFrom<i32> for ScAddressType {
2 => ScAddressType::MuxedAccount,
3 => ScAddressType::ClaimableBalance,
4 => ScAddressType::LiquidityPool,
#[cfg(feature = "cap_0084_muxed_contract")]
5 => ScAddressType::MuxedContract,
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand Down
Loading
Loading