Skip to content
Closed
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 @@ -47,6 +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 = []

# Features available without any new dependencies.
type_enum = []
Expand Down
5 changes: 4 additions & 1 deletion src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub const XDR_FILES_SHA256: [(&str, &str); 13] = [
),
(
"xdr/Stellar-ledger.x",
"93cdd4dd597d9f0b271762c2f3c81be8562e2004f4f019f539ca7d7e92167099",
"4c09454575c291e41b8f514255562a261f8f1cdefa7e8a20062b1108571621b5",
),
(
"xdr/Stellar-overlay.x",
Expand Down Expand Up @@ -4348,6 +4348,9 @@ pub use int256_parts::*;
mod contract_executable_type;
#[allow(unused_imports)]
pub use contract_executable_type::*;
mod contract_executable_external_ref;
#[allow(unused_imports)]
pub use contract_executable_external_ref::*;
mod contract_executable;
#[allow(unused_imports)]
pub use contract_executable::*;
Expand Down
25 changes: 24 additions & 1 deletion src/generated/contract_executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ 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 @@ -28,6 +32,8 @@ use super::*;
pub enum ContractExecutable {
Wasm(Hash),
StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
ExternalRef(ContractExecutableExternalRef),
}

#[cfg(feature = "alloc")]
Expand All @@ -41,6 +47,8 @@ impl ContractExecutable {
const _VARIANTS: &[ContractExecutableType] = &[
ContractExecutableType::Wasm,
ContractExecutableType::StellarAsset,
#[cfg(feature = "cap_0085_executable_ref")]
ContractExecutableType::ExternalRef,
];
pub const VARIANTS: [ContractExecutableType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand All @@ -51,7 +59,12 @@ impl ContractExecutable {
}
arr
};
const _VARIANTS_STR: &[&str] = &["Wasm", "StellarAsset"];
const _VARIANTS_STR: &[&str] = &[
"Wasm",
"StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
"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 @@ -67,6 +80,8 @@ impl ContractExecutable {
match self {
Self::Wasm(_) => "Wasm",
Self::StellarAsset => "StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExternalRef(_) => "ExternalRef",
}
}

Expand All @@ -76,6 +91,8 @@ 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 @@ -116,6 +133,10 @@ 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)?)
}
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand All @@ -133,6 +154,8 @@ 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
53 changes: 53 additions & 0 deletions src/generated/contract_executable_external_ref.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;

/// ContractExecutableExternalRef is an XDR Struct defined as:
///
/// ```text
/// struct ContractExecutableExternalRef {
/// SCAddress executable_owner;
/// SCString tag;
/// };
/// ```
///
#[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)]
#[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 ContractExecutableExternalRef {
pub executable_owner: ScAddress,
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> {
r.with_limited_depth(|r| {
Ok(Self {
executable_owner: ScAddress::read_xdr(r)?,
tag: ScString::read_xdr(r)?,
})
})
}
}

#[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> {
w.with_limited_depth(|w| {
self.executable_owner.write_xdr(w)?;
self.tag.write_xdr(w)?;
Ok(())
})
}
}
18 changes: 17 additions & 1 deletion src/generated/contract_executable_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use super::*;
/// {
/// CONTRACT_EXECUTABLE_WASM = 0,
/// CONTRACT_EXECUTABLE_STELLAR_ASSET = 1
/// #ifdef CAP_0085_EXECUTABLE_REF
/// ,CONTRACT_EXECUTABLE_EXTERNAL_REF = 2
/// #endif
/// };
/// ```
///
Expand All @@ -26,12 +29,16 @@ 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()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand All @@ -42,7 +49,12 @@ impl ContractExecutableType {
}
arr
};
const _VARIANTS_STR: &[&str] = &["Wasm", "StellarAsset"];
const _VARIANTS_STR: &[&str] = &[
"Wasm",
"StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
"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 @@ -58,6 +70,8 @@ impl ContractExecutableType {
match self {
Self::Wasm => "Wasm",
Self::StellarAsset => "StellarAsset",
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExternalRef => "ExternalRef",
}
}

Expand Down Expand Up @@ -95,6 +109,8 @@ 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
19 changes: 19 additions & 0 deletions src/generated/sc_val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ use super::*;
/// void;
/// case SCV_LEDGER_KEY_NONCE:
/// SCNonceKey nonce_key;
///
/// #ifdef CAP_0085_EXECUTABLE_REF
/// case SCV_EXECUTABLE_TAG:
/// SCString executable_tag;
/// #endif
/// };
/// ```
///
Expand Down Expand Up @@ -113,6 +118,8 @@ pub enum ScVal {
ContractInstance(ScContractInstance),
LedgerKeyContractInstance,
LedgerKeyNonce(ScNonceKey),
#[cfg(feature = "cap_0085_executable_ref")]
ExecutableTag(ScString),
}

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -146,6 +153,8 @@ impl ScVal {
ScValType::ContractInstance,
ScValType::LedgerKeyContractInstance,
ScValType::LedgerKeyNonce,
#[cfg(feature = "cap_0085_executable_ref")]
ScValType::ExecutableTag,
];
pub const VARIANTS: [ScValType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand Down Expand Up @@ -179,6 +188,8 @@ impl ScVal {
"ContractInstance",
"LedgerKeyContractInstance",
"LedgerKeyNonce",
#[cfg(feature = "cap_0085_executable_ref")]
"ExecutableTag",
];
pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
Expand Down Expand Up @@ -215,6 +226,8 @@ impl ScVal {
Self::ContractInstance(_) => "ContractInstance",
Self::LedgerKeyContractInstance => "LedgerKeyContractInstance",
Self::LedgerKeyNonce(_) => "LedgerKeyNonce",
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExecutableTag(_) => "ExecutableTag",
}
}

Expand Down Expand Up @@ -244,6 +257,8 @@ impl ScVal {
Self::ContractInstance(_) => ScValType::ContractInstance,
Self::LedgerKeyContractInstance => ScValType::LedgerKeyContractInstance,
Self::LedgerKeyNonce(_) => ScValType::LedgerKeyNonce,
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExecutableTag(_) => ScValType::ExecutableTag,
}
}

Expand Down Expand Up @@ -306,6 +321,8 @@ impl ReadXdr for ScVal {
}
ScValType::LedgerKeyContractInstance => Self::LedgerKeyContractInstance,
ScValType::LedgerKeyNonce => Self::LedgerKeyNonce(ScNonceKey::read_xdr(r)?),
#[cfg(feature = "cap_0085_executable_ref")]
ScValType::ExecutableTag => Self::ExecutableTag(ScString::read_xdr(r)?),
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand Down Expand Up @@ -343,6 +360,8 @@ impl WriteXdr for ScVal {
Self::ContractInstance(v) => v.write_xdr(w)?,
Self::LedgerKeyContractInstance => ().write_xdr(w)?,
Self::LedgerKeyNonce(v) => v.write_xdr(w)?,
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExecutableTag(v) => v.write_xdr(w)?,
};
Ok(())
})
Expand Down
14 changes: 14 additions & 0 deletions src/generated/sc_val_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ use super::*;
/// // instance and an address' nonce, respectively.
/// SCV_LEDGER_KEY_CONTRACT_INSTANCE = 20,
/// SCV_LEDGER_KEY_NONCE = 21
///
/// #ifdef CAP_0085_EXECUTABLE_REF
/// ,SCV_EXECUTABLE_TAG = 22
/// #endif
/// };
/// ```
///
Expand Down Expand Up @@ -95,6 +99,8 @@ pub enum ScValType {
ContractInstance = 19,
LedgerKeyContractInstance = 20,
LedgerKeyNonce = 21,
#[cfg(feature = "cap_0085_executable_ref")]
ExecutableTag = 22,
}

impl ScValType {
Expand All @@ -121,6 +127,8 @@ impl ScValType {
ScValType::ContractInstance,
ScValType::LedgerKeyContractInstance,
ScValType::LedgerKeyNonce,
#[cfg(feature = "cap_0085_executable_ref")]
ScValType::ExecutableTag,
];
pub const VARIANTS: [ScValType; Self::_VARIANTS.len()] = {
let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
Expand Down Expand Up @@ -154,6 +162,8 @@ impl ScValType {
"ContractInstance",
"LedgerKeyContractInstance",
"LedgerKeyNonce",
#[cfg(feature = "cap_0085_executable_ref")]
"ExecutableTag",
];
pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
Expand Down Expand Up @@ -190,6 +200,8 @@ impl ScValType {
Self::ContractInstance => "ContractInstance",
Self::LedgerKeyContractInstance => "LedgerKeyContractInstance",
Self::LedgerKeyNonce => "LedgerKeyNonce",
#[cfg(feature = "cap_0085_executable_ref")]
Self::ExecutableTag => "ExecutableTag",
}
}

Expand Down Expand Up @@ -247,6 +259,8 @@ impl TryFrom<i32> for ScValType {
19 => ScValType::ContractInstance,
20 => ScValType::LedgerKeyContractInstance,
21 => ScValType::LedgerKeyNonce,
#[cfg(feature = "cap_0085_executable_ref")]
22 => ScValType::ExecutableTag,
#[allow(unreachable_patterns)]
_ => return Err(Error::Invalid),
};
Expand Down
2 changes: 1 addition & 1 deletion src/generated/soroban_transaction_meta_ext_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use super::*;
/// // transactions, this will be `0` for failed transactions.
/// int64 totalRefundableResourceFeeCharged;
/// // Amount (in stroops) that has been charged for rent.
/// // This is a part of `totalNonRefundableResourceFeeCharged`.
/// // This is a part of `totalRefundableResourceFeeCharged`.
/// int64 rentFeeCharged;
/// };
/// ```
Expand Down
Loading
Loading