Skip to content
Draft
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage = "https://github.com/stellar/rs-stellar-xdr"
repository = "https://github.com/stellar/rs-stellar-xdr"
authors = ["Stellar Development Foundation <info@stellar.org>"]
license = "Apache-2.0"
version = "27.0.0"
version = "28.0.0"
edition = "2021"
rust-version = "1.84.0"

Expand Down Expand Up @@ -47,6 +47,7 @@ alloc = ["dep:hex", "dep:stellar-strkey", "escape-bytes/alloc", "dep:ethnum"]
# Features from the XDR
test_feature = []
cap_0083 = []
cap_0084_muxed_contract = []

# Features available without any new dependencies.
type_enum = []
Expand Down
3 changes: 3 additions & 0 deletions src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4357,6 +4357,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
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