From c7e69ad1e71bd7ddcda09129bf1f53fce5470c49 Mon Sep 17 00:00:00 2001 From: Siddharth Suresh Date: Fri, 8 Sep 2023 13:54:31 -0700 Subject: [PATCH 1/2] Bump curr and next --- src/curr/generated.rs | 34732 +++++++++++++++++++++++++++------------- src/next/generated.rs | 66 +- xdr/curr | 2 +- xdr/curr-version | 2 +- xdr/next | 2 +- xdr/next-version | 2 +- 6 files changed, 24031 insertions(+), 10775 deletions(-) diff --git a/src/curr/generated.rs b/src/curr/generated.rs index 9fddd7a0..9f9614c3 100644 --- a/src/curr/generated.rs +++ b/src/curr/generated.rs @@ -1,5 +1,10 @@ // Module is generated from: // xdr/curr/Stellar-SCP.x +// xdr/curr/Stellar-contract-config-setting.x +// xdr/curr/Stellar-contract-env-meta.x +// xdr/curr/Stellar-contract-meta.x +// xdr/curr/Stellar-contract-spec.x +// xdr/curr/Stellar-contract.x // xdr/curr/Stellar-internal.x // xdr/curr/Stellar-ledger-entries.x // xdr/curr/Stellar-ledger.x @@ -10,34 +15,54 @@ #![allow(clippy::missing_errors_doc, clippy::unreadable_literal)] /// `XDR_FILES_SHA256` is a list of pairs of source files and their SHA256 hashes. -pub const XDR_FILES_SHA256: [(&str, &str); 7] = [ +pub const XDR_FILES_SHA256: [(&str, &str); 12] = [ ( "xdr/curr/Stellar-SCP.x", "8f32b04d008f8bc33b8843d075e69837231a673691ee41d8b821ca229a6e802a", ), + ( + "xdr/curr/Stellar-contract-config-setting.x", + "fd8709d1bcc36a90a1f7b1fd8cb4407f7733bec5ca06494cac9b6a99b942ef99", + ), + ( + "xdr/curr/Stellar-contract-env-meta.x", + "928a30de814ee589bc1d2aadd8dd81c39f71b7e6f430f56974505ccb1f49654b", + ), + ( + "xdr/curr/Stellar-contract-meta.x", + "f01532c11ca044e19d9f9f16fe373e9af64835da473be556b9a807ee3319ae0d", + ), + ( + "xdr/curr/Stellar-contract-spec.x", + "c7ffa21d2e91afb8e666b33524d307955426ff553a486d670c29217ed9888d49", + ), + ( + "xdr/curr/Stellar-contract.x", + "234d2adf0c9bdf7c42ea64a2650884d8e36ed31cd1cbe13fb8d12b335fb4e5c3", + ), ( "xdr/curr/Stellar-internal.x", "368706dd6e2efafd16a8f63daf3374845b791d097b15c502aa7653a412b68b68", ), ( "xdr/curr/Stellar-ledger-entries.x", - "3aa135c309c2d67883f165961739b4940c90df59240d8aeef55deced8d7708b5", + "73b467bce654c5b19d0fba24008c9ccae77b439320a4c9eef9128e1818fdd76d", ), ( "xdr/curr/Stellar-ledger.x", - "96ac88de23d2b0f2f23a0495527c8aefb8623b4db0e39ba34f357d10a211c214", + "247d1b486d546f5c37f3d8a719b195e3331106302bcdc54cd1f52a6f94a9a7ed", ), ( "xdr/curr/Stellar-overlay.x", - "3093b425866f34b32702d80d5298f9f2dc00736b0fdaac7efa653490a39fb231", + "de3957c58b96ae07968b3d3aebea84f83603e95322d1fa336360e13e3aba737a", ), ( "xdr/curr/Stellar-transaction.x", - "45fdeb428e68d6b07e3e3157b6404567e0efb712c9d4c90a61a1035854c32b90", + "ce8194511afb4cbb165921c720d057381bcd4829999027d42753c11d5dcaa7f8", ), ( "xdr/curr/Stellar-types.x", - "60b7588e573f5e5518766eb5e6b6ea42f0e53144663cbe557e485cceb6306c85", + "6e3b13f0d3e360b09fa5e2b0e55d43f4d974a769df66afb34e8aecbb329d3f15", ), ]; @@ -3099,17 +3124,14 @@ impl WriteXdr for ScpQuorumSet { } } -// StoredTransactionSet is an XDR Union defines as: +// ConfigSettingContractExecutionLanesV0 is an XDR Struct defines as: // -// union StoredTransactionSet switch (int v) +// struct ConfigSettingContractExecutionLanesV0 // { -// case 0: -// TransactionSet txSet; -// case 1: -// GeneralizedTransactionSet generalizedTxSet; +// // maximum number of Soroban transactions per ledger +// uint32 ledgerMaxTxCount; // }; // -// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -3117,100 +3139,205 @@ impl WriteXdr for ScpQuorumSet { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum StoredTransactionSet { - V0(TransactionSet), - V1(GeneralizedTransactionSet), +pub struct ConfigSettingContractExecutionLanesV0 { + pub ledger_max_tx_count: u32, } -impl StoredTransactionSet { - pub const VARIANTS: [i32; 2] = [0, 1]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0(_) => "V0", - Self::V1(_) => "V1", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0(_) => 0, - Self::V1(_) => 1, - } +impl ReadXdr for ConfigSettingContractExecutionLanesV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ledger_max_tx_count: u32::read_xdr(r)?, + }) + }) } +} - #[must_use] - pub const fn variants() -> [i32; 2] { - Self::VARIANTS +impl WriteXdr for ConfigSettingContractExecutionLanesV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ledger_max_tx_count.write_xdr(w)?; + Ok(()) + }) } } -impl Name for StoredTransactionSet { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } +// ConfigSettingContractComputeV0 is an XDR Struct defines as: +// +// struct ConfigSettingContractComputeV0 +// { +// // Maximum instructions per ledger +// int64 ledgerMaxInstructions; +// // Maximum instructions per transaction +// int64 txMaxInstructions; +// // Cost of 10000 instructions +// int64 feeRatePerInstructionsIncrement; +// +// // Memory limit per transaction. Unlike instructions, there is no fee +// // for memory, just the limit. +// uint32 txMemoryLimit; +// }; +// +#[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 ConfigSettingContractComputeV0 { + pub ledger_max_instructions: i64, + pub tx_max_instructions: i64, + pub fee_rate_per_instructions_increment: i64, + pub tx_memory_limit: u32, } -impl Discriminant for StoredTransactionSet { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) +impl ReadXdr for ConfigSettingContractComputeV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ledger_max_instructions: i64::read_xdr(r)?, + tx_max_instructions: i64::read_xdr(r)?, + fee_rate_per_instructions_increment: i64::read_xdr(r)?, + tx_memory_limit: u32::read_xdr(r)?, + }) + }) } } -impl Variants for StoredTransactionSet { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() +impl WriteXdr for ConfigSettingContractComputeV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ledger_max_instructions.write_xdr(w)?; + self.tx_max_instructions.write_xdr(w)?; + self.fee_rate_per_instructions_increment.write_xdr(w)?; + self.tx_memory_limit.write_xdr(w)?; + Ok(()) + }) } } -impl Union for StoredTransactionSet {} +// ConfigSettingContractLedgerCostV0 is an XDR Struct defines as: +// +// struct ConfigSettingContractLedgerCostV0 +// { +// // Maximum number of ledger entry read operations per ledger +// uint32 ledgerMaxReadLedgerEntries; +// // Maximum number of bytes that can be read per ledger +// uint32 ledgerMaxReadBytes; +// // Maximum number of ledger entry write operations per ledger +// uint32 ledgerMaxWriteLedgerEntries; +// // Maximum number of bytes that can be written per ledger +// uint32 ledgerMaxWriteBytes; +// +// // Maximum number of ledger entry read operations per transaction +// uint32 txMaxReadLedgerEntries; +// // Maximum number of bytes that can be read per transaction +// uint32 txMaxReadBytes; +// // Maximum number of ledger entry write operations per transaction +// uint32 txMaxWriteLedgerEntries; +// // Maximum number of bytes that can be written per transaction +// uint32 txMaxWriteBytes; +// +// int64 feeReadLedgerEntry; // Fee per ledger entry read +// int64 feeWriteLedgerEntry; // Fee per ledger entry write +// +// int64 feeRead1KB; // Fee for reading 1KB +// +// // The following parameters determine the write fee per 1KB. +// // Write fee grows linearly until bucket list reaches this size +// int64 bucketListTargetSizeBytes; +// // Fee per 1KB write when the bucket list is empty +// int64 writeFee1KBBucketListLow; +// // Fee per 1KB write when the bucket list has reached `bucketListTargetSizeBytes` +// int64 writeFee1KBBucketListHigh; +// // Write fee multiplier for any additional data past the first `bucketListTargetSizeBytes` +// uint32 bucketListWriteFeeGrowthFactor; +// }; +// +#[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 ConfigSettingContractLedgerCostV0 { + pub ledger_max_read_ledger_entries: u32, + pub ledger_max_read_bytes: u32, + pub ledger_max_write_ledger_entries: u32, + pub ledger_max_write_bytes: u32, + pub tx_max_read_ledger_entries: u32, + pub tx_max_read_bytes: u32, + pub tx_max_write_ledger_entries: u32, + pub tx_max_write_bytes: u32, + pub fee_read_ledger_entry: i64, + pub fee_write_ledger_entry: i64, + pub fee_read1_kb: i64, + pub bucket_list_target_size_bytes: i64, + pub write_fee1_kb_bucket_list_low: i64, + pub write_fee1_kb_bucket_list_high: i64, + pub bucket_list_write_fee_growth_factor: u32, +} -impl ReadXdr for StoredTransactionSet { +impl ReadXdr for ConfigSettingContractLedgerCostV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0(TransactionSet::read_xdr(r)?), - 1 => Self::V1(GeneralizedTransactionSet::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + ledger_max_read_ledger_entries: u32::read_xdr(r)?, + ledger_max_read_bytes: u32::read_xdr(r)?, + ledger_max_write_ledger_entries: u32::read_xdr(r)?, + ledger_max_write_bytes: u32::read_xdr(r)?, + tx_max_read_ledger_entries: u32::read_xdr(r)?, + tx_max_read_bytes: u32::read_xdr(r)?, + tx_max_write_ledger_entries: u32::read_xdr(r)?, + tx_max_write_bytes: u32::read_xdr(r)?, + fee_read_ledger_entry: i64::read_xdr(r)?, + fee_write_ledger_entry: i64::read_xdr(r)?, + fee_read1_kb: i64::read_xdr(r)?, + bucket_list_target_size_bytes: i64::read_xdr(r)?, + write_fee1_kb_bucket_list_low: i64::read_xdr(r)?, + write_fee1_kb_bucket_list_high: i64::read_xdr(r)?, + bucket_list_write_fee_growth_factor: u32::read_xdr(r)?, + }) }) } } -impl WriteXdr for StoredTransactionSet { +impl WriteXdr for ConfigSettingContractLedgerCostV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0(v) => v.write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, - }; + self.ledger_max_read_ledger_entries.write_xdr(w)?; + self.ledger_max_read_bytes.write_xdr(w)?; + self.ledger_max_write_ledger_entries.write_xdr(w)?; + self.ledger_max_write_bytes.write_xdr(w)?; + self.tx_max_read_ledger_entries.write_xdr(w)?; + self.tx_max_read_bytes.write_xdr(w)?; + self.tx_max_write_ledger_entries.write_xdr(w)?; + self.tx_max_write_bytes.write_xdr(w)?; + self.fee_read_ledger_entry.write_xdr(w)?; + self.fee_write_ledger_entry.write_xdr(w)?; + self.fee_read1_kb.write_xdr(w)?; + self.bucket_list_target_size_bytes.write_xdr(w)?; + self.write_fee1_kb_bucket_list_low.write_xdr(w)?; + self.write_fee1_kb_bucket_list_high.write_xdr(w)?; + self.bucket_list_write_fee_growth_factor.write_xdr(w)?; Ok(()) }) } } -// PersistedScpStateV0 is an XDR Struct defines as: +// ConfigSettingContractHistoricalDataV0 is an XDR Struct defines as: // -// struct PersistedSCPStateV0 +// struct ConfigSettingContractHistoricalDataV0 // { -// SCPEnvelope scpEnvelopes<>; -// SCPQuorumSet quorumSets<>; -// StoredTransactionSet txSets<>; +// int64 feeHistorical1KB; // Fee for storing 1KB in archives // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -3220,44 +3347,39 @@ impl WriteXdr for StoredTransactionSet { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PersistedScpStateV0 { - pub scp_envelopes: VecM, - pub quorum_sets: VecM, - pub tx_sets: VecM, +pub struct ConfigSettingContractHistoricalDataV0 { + pub fee_historical1_kb: i64, } -impl ReadXdr for PersistedScpStateV0 { +impl ReadXdr for ConfigSettingContractHistoricalDataV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - scp_envelopes: VecM::::read_xdr(r)?, - quorum_sets: VecM::::read_xdr(r)?, - tx_sets: VecM::::read_xdr(r)?, + fee_historical1_kb: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for PersistedScpStateV0 { +impl WriteXdr for ConfigSettingContractHistoricalDataV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.scp_envelopes.write_xdr(w)?; - self.quorum_sets.write_xdr(w)?; - self.tx_sets.write_xdr(w)?; + self.fee_historical1_kb.write_xdr(w)?; Ok(()) }) } } -// PersistedScpStateV1 is an XDR Struct defines as: +// ConfigSettingContractEventsV0 is an XDR Struct defines as: // -// struct PersistedSCPStateV1 +// struct ConfigSettingContractEventsV0 // { -// // Tx sets are saved separately -// SCPEnvelope scpEnvelopes<>; -// SCPQuorumSet quorumSets<>; +// // Maximum size of events that a contract call can emit. +// uint32 txMaxContractEventsSizeBytes; +// // Fee for generating 1KB of contract events. +// int64 feeContractEvents1KB; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -3267,45 +3389,47 @@ impl WriteXdr for PersistedScpStateV0 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PersistedScpStateV1 { - pub scp_envelopes: VecM, - pub quorum_sets: VecM, +pub struct ConfigSettingContractEventsV0 { + pub tx_max_contract_events_size_bytes: u32, + pub fee_contract_events1_kb: i64, } -impl ReadXdr for PersistedScpStateV1 { +impl ReadXdr for ConfigSettingContractEventsV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - scp_envelopes: VecM::::read_xdr(r)?, - quorum_sets: VecM::::read_xdr(r)?, + tx_max_contract_events_size_bytes: u32::read_xdr(r)?, + fee_contract_events1_kb: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for PersistedScpStateV1 { +impl WriteXdr for ConfigSettingContractEventsV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.scp_envelopes.write_xdr(w)?; - self.quorum_sets.write_xdr(w)?; + self.tx_max_contract_events_size_bytes.write_xdr(w)?; + self.fee_contract_events1_kb.write_xdr(w)?; Ok(()) }) } } -// PersistedScpState is an XDR Union defines as: +// ConfigSettingContractBandwidthV0 is an XDR Struct defines as: // -// union PersistedSCPState switch (int v) +// struct ConfigSettingContractBandwidthV0 // { -// case 0: -// PersistedSCPStateV0 v0; -// case 1: -// PersistedSCPStateV1 v1; +// // Maximum sum of all transaction sizes in the ledger in bytes +// uint32 ledgerMaxTxsSizeBytes; +// // Maximum size in bytes for a transaction +// uint32 txMaxSizeBytes; +// +// // Fee for 1 KB of transaction size +// int64 feeTxSize1KB; // }; // -// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -3313,266 +3437,516 @@ impl WriteXdr for PersistedScpStateV1 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum PersistedScpState { - V0(PersistedScpStateV0), - V1(PersistedScpStateV1), +pub struct ConfigSettingContractBandwidthV0 { + pub ledger_max_txs_size_bytes: u32, + pub tx_max_size_bytes: u32, + pub fee_tx_size1_kb: i64, } -impl PersistedScpState { - pub const VARIANTS: [i32; 2] = [0, 1]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0(_) => "V0", - Self::V1(_) => "V1", - } +impl ReadXdr for ConfigSettingContractBandwidthV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ledger_max_txs_size_bytes: u32::read_xdr(r)?, + tx_max_size_bytes: u32::read_xdr(r)?, + fee_tx_size1_kb: i64::read_xdr(r)?, + }) + }) } +} - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0(_) => 0, - Self::V1(_) => 1, - } +impl WriteXdr for ConfigSettingContractBandwidthV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ledger_max_txs_size_bytes.write_xdr(w)?; + self.tx_max_size_bytes.write_xdr(w)?; + self.fee_tx_size1_kb.write_xdr(w)?; + Ok(()) + }) } +} + +// ContractCostType is an XDR Enum defines as: +// +// enum ContractCostType { +// // Cost of running 1 wasm instruction +// WasmInsnExec = 0, +// // Cost of growing wasm linear memory by 1 page +// WasmMemAlloc = 1, +// // Cost of allocating a chuck of host memory (in bytes) +// HostMemAlloc = 2, +// // Cost of copying a chuck of bytes into a pre-allocated host memory +// HostMemCpy = 3, +// // Cost of comparing two slices of host memory +// HostMemCmp = 4, +// // Cost of a host function dispatch, not including the actual work done by +// // the function nor the cost of VM invocation machinary +// DispatchHostFunction = 5, +// // Cost of visiting a host object from the host object storage. Exists to +// // make sure some baseline cost coverage, i.e. repeatly visiting objects +// // by the guest will always incur some charges. +// VisitObject = 6, +// // Cost of serializing an xdr object to bytes +// ValSer = 7, +// // Cost of deserializing an xdr object from bytes +// ValDeser = 8, +// // Cost of computing the sha256 hash from bytes +// ComputeSha256Hash = 9, +// // Cost of computing the ed25519 pubkey from bytes +// ComputeEd25519PubKey = 10, +// // Cost of accessing an entry in a Map. +// MapEntry = 11, +// // Cost of accessing an entry in a Vec +// VecEntry = 12, +// // Cost of verifying ed25519 signature of a payload. +// VerifyEd25519Sig = 13, +// // Cost of reading a slice of vm linear memory +// VmMemRead = 14, +// // Cost of writing to a slice of vm linear memory +// VmMemWrite = 15, +// // Cost of instantiation a VM from wasm bytes code. +// VmInstantiation = 16, +// // Cost of instantiation a VM from a cached state. +// VmCachedInstantiation = 17, +// // Cost of invoking a function on the VM. If the function is a host function, +// // additional cost will be covered by `DispatchHostFunction`. +// InvokeVmFunction = 18, +// // Cost of computing a keccak256 hash from bytes. +// ComputeKeccak256Hash = 19, +// // Cost of computing an ECDSA secp256k1 pubkey from bytes. +// ComputeEcdsaSecp256k1Key = 20, +// // Cost of computing an ECDSA secp256k1 signature from bytes. +// ComputeEcdsaSecp256k1Sig = 21, +// // Cost of recovering an ECDSA secp256k1 key from a signature. +// RecoverEcdsaSecp256k1Key = 22, +// // Cost of int256 addition (`+`) and subtraction (`-`) operations +// Int256AddSub = 23, +// // Cost of int256 multiplication (`*`) operation +// Int256Mul = 24, +// // Cost of int256 division (`/`) operation +// Int256Div = 25, +// // Cost of int256 power (`exp`) operation +// Int256Pow = 26, +// // Cost of int256 shift (`shl`, `shr`) operation +// Int256Shift = 27 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ContractCostType { + WasmInsnExec = 0, + WasmMemAlloc = 1, + HostMemAlloc = 2, + HostMemCpy = 3, + HostMemCmp = 4, + DispatchHostFunction = 5, + VisitObject = 6, + ValSer = 7, + ValDeser = 8, + ComputeSha256Hash = 9, + ComputeEd25519PubKey = 10, + MapEntry = 11, + VecEntry = 12, + VerifyEd25519Sig = 13, + VmMemRead = 14, + VmMemWrite = 15, + VmInstantiation = 16, + VmCachedInstantiation = 17, + InvokeVmFunction = 18, + ComputeKeccak256Hash = 19, + ComputeEcdsaSecp256k1Key = 20, + ComputeEcdsaSecp256k1Sig = 21, + RecoverEcdsaSecp256k1Key = 22, + Int256AddSub = 23, + Int256Mul = 24, + Int256Div = 25, + Int256Pow = 26, + Int256Shift = 27, +} + +impl ContractCostType { + pub const VARIANTS: [ContractCostType; 28] = [ + ContractCostType::WasmInsnExec, + ContractCostType::WasmMemAlloc, + ContractCostType::HostMemAlloc, + ContractCostType::HostMemCpy, + ContractCostType::HostMemCmp, + ContractCostType::DispatchHostFunction, + ContractCostType::VisitObject, + ContractCostType::ValSer, + ContractCostType::ValDeser, + ContractCostType::ComputeSha256Hash, + ContractCostType::ComputeEd25519PubKey, + ContractCostType::MapEntry, + ContractCostType::VecEntry, + ContractCostType::VerifyEd25519Sig, + ContractCostType::VmMemRead, + ContractCostType::VmMemWrite, + ContractCostType::VmInstantiation, + ContractCostType::VmCachedInstantiation, + ContractCostType::InvokeVmFunction, + ContractCostType::ComputeKeccak256Hash, + ContractCostType::ComputeEcdsaSecp256k1Key, + ContractCostType::ComputeEcdsaSecp256k1Sig, + ContractCostType::RecoverEcdsaSecp256k1Key, + ContractCostType::Int256AddSub, + ContractCostType::Int256Mul, + ContractCostType::Int256Div, + ContractCostType::Int256Pow, + ContractCostType::Int256Shift, + ]; + pub const VARIANTS_STR: [&'static str; 28] = [ + "WasmInsnExec", + "WasmMemAlloc", + "HostMemAlloc", + "HostMemCpy", + "HostMemCmp", + "DispatchHostFunction", + "VisitObject", + "ValSer", + "ValDeser", + "ComputeSha256Hash", + "ComputeEd25519PubKey", + "MapEntry", + "VecEntry", + "VerifyEd25519Sig", + "VmMemRead", + "VmMemWrite", + "VmInstantiation", + "VmCachedInstantiation", + "InvokeVmFunction", + "ComputeKeccak256Hash", + "ComputeEcdsaSecp256k1Key", + "ComputeEcdsaSecp256k1Sig", + "RecoverEcdsaSecp256k1Key", + "Int256AddSub", + "Int256Mul", + "Int256Div", + "Int256Pow", + "Int256Shift", + ]; #[must_use] - pub const fn variants() -> [i32; 2] { + pub const fn name(&self) -> &'static str { + match self { + Self::WasmInsnExec => "WasmInsnExec", + Self::WasmMemAlloc => "WasmMemAlloc", + Self::HostMemAlloc => "HostMemAlloc", + Self::HostMemCpy => "HostMemCpy", + Self::HostMemCmp => "HostMemCmp", + Self::DispatchHostFunction => "DispatchHostFunction", + Self::VisitObject => "VisitObject", + Self::ValSer => "ValSer", + Self::ValDeser => "ValDeser", + Self::ComputeSha256Hash => "ComputeSha256Hash", + Self::ComputeEd25519PubKey => "ComputeEd25519PubKey", + Self::MapEntry => "MapEntry", + Self::VecEntry => "VecEntry", + Self::VerifyEd25519Sig => "VerifyEd25519Sig", + Self::VmMemRead => "VmMemRead", + Self::VmMemWrite => "VmMemWrite", + Self::VmInstantiation => "VmInstantiation", + Self::VmCachedInstantiation => "VmCachedInstantiation", + Self::InvokeVmFunction => "InvokeVmFunction", + Self::ComputeKeccak256Hash => "ComputeKeccak256Hash", + Self::ComputeEcdsaSecp256k1Key => "ComputeEcdsaSecp256k1Key", + Self::ComputeEcdsaSecp256k1Sig => "ComputeEcdsaSecp256k1Sig", + Self::RecoverEcdsaSecp256k1Key => "RecoverEcdsaSecp256k1Key", + Self::Int256AddSub => "Int256AddSub", + Self::Int256Mul => "Int256Mul", + Self::Int256Div => "Int256Div", + Self::Int256Pow => "Int256Pow", + Self::Int256Shift => "Int256Shift", + } + } + + #[must_use] + pub const fn variants() -> [ContractCostType; 28] { Self::VARIANTS } } -impl Name for PersistedScpState { +impl Name for ContractCostType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for PersistedScpState { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) +impl Variants for ContractCostType { + fn variants() -> slice::Iter<'static, ContractCostType> { + Self::VARIANTS.iter() } } -impl Variants for PersistedScpState { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() +impl Enum for ContractCostType {} + +impl fmt::Display for ContractCostType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl Union for PersistedScpState {} +impl TryFrom for ContractCostType { + type Error = Error; -impl ReadXdr for PersistedScpState { + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ContractCostType::WasmInsnExec, + 1 => ContractCostType::WasmMemAlloc, + 2 => ContractCostType::HostMemAlloc, + 3 => ContractCostType::HostMemCpy, + 4 => ContractCostType::HostMemCmp, + 5 => ContractCostType::DispatchHostFunction, + 6 => ContractCostType::VisitObject, + 7 => ContractCostType::ValSer, + 8 => ContractCostType::ValDeser, + 9 => ContractCostType::ComputeSha256Hash, + 10 => ContractCostType::ComputeEd25519PubKey, + 11 => ContractCostType::MapEntry, + 12 => ContractCostType::VecEntry, + 13 => ContractCostType::VerifyEd25519Sig, + 14 => ContractCostType::VmMemRead, + 15 => ContractCostType::VmMemWrite, + 16 => ContractCostType::VmInstantiation, + 17 => ContractCostType::VmCachedInstantiation, + 18 => ContractCostType::InvokeVmFunction, + 19 => ContractCostType::ComputeKeccak256Hash, + 20 => ContractCostType::ComputeEcdsaSecp256k1Key, + 21 => ContractCostType::ComputeEcdsaSecp256k1Sig, + 22 => ContractCostType::RecoverEcdsaSecp256k1Key, + 23 => ContractCostType::Int256AddSub, + 24 => ContractCostType::Int256Mul, + 25 => ContractCostType::Int256Div, + 26 => ContractCostType::Int256Pow, + 27 => ContractCostType::Int256Shift, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ContractCostType) -> Self { + e as Self + } +} + +impl ReadXdr for ContractCostType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0(PersistedScpStateV0::read_xdr(r)?), - 1 => Self::V1(PersistedScpStateV1::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; Ok(v) }) } } -impl WriteXdr for PersistedScpState { +impl WriteXdr for ContractCostType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0(v) => v.write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, - }; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// AccountId is an XDR Typedef defines as: +// ContractCostParamEntry is an XDR Struct defines as: // -// typedef PublicKey AccountID; +// struct ContractCostParamEntry { +// // use `ext` to add more terms (e.g. higher order polynomials) in the future +// ExtensionPoint ext; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// int64 constTerm; +// int64 linearTerm; +// }; +// +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct AccountId(pub PublicKey); - -impl From for PublicKey { - #[must_use] - fn from(x: AccountId) -> Self { - x.0 - } -} - -impl From for AccountId { - #[must_use] - fn from(x: PublicKey) -> Self { - AccountId(x) - } -} - -impl AsRef for AccountId { - #[must_use] - fn as_ref(&self) -> &PublicKey { - &self.0 - } +pub struct ContractCostParamEntry { + pub ext: ExtensionPoint, + pub const_term: i64, + pub linear_term: i64, } -impl ReadXdr for AccountId { +impl ReadXdr for ContractCostParamEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = PublicKey::read_xdr(r)?; - let v = AccountId(i); - Ok(v) + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + const_term: i64::read_xdr(r)?, + linear_term: i64::read_xdr(r)?, + }) }) } } -impl WriteXdr for AccountId { +impl WriteXdr for ContractCostParamEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.const_term.write_xdr(w)?; + self.linear_term.write_xdr(w)?; + Ok(()) + }) } } -// Thresholds is an XDR Typedef defines as: +// StateExpirationSettings is an XDR Struct defines as: // -// typedef opaque Thresholds[4]; +// struct StateExpirationSettings { +// uint32 maxEntryExpiration; +// uint32 minTempEntryExpiration; +// uint32 minPersistentEntryExpiration; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// // rent_fee = wfee_rate_average / rent_rate_denominator_for_type +// int64 persistentRentRateDenominator; +// int64 tempRentRateDenominator; +// +// // max number of entries that emit expiration meta in a single ledger +// uint32 maxEntriesToExpire; +// +// // Number of snapshots to use when calculating average BucketList size +// uint32 bucketListSizeWindowSampleSize; +// +// // Maximum number of bytes that we scan for eviction per ledger +// uint64 evictionScanSize; +// +// // Lowest BucketList level to be scanned to evict entries +// uint32 startingEvictionScanLevel; +// }; +// +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( all(feature = "serde", feature = "alloc"), - derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr) + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") )] -pub struct Thresholds(pub [u8; 4]); - -impl core::fmt::Display for Thresholds { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let v = &self.0; - for b in v { - write!(f, "{b:02x}")?; - } - Ok(()) - } -} - -impl core::fmt::Debug for Thresholds { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let v = &self.0; - write!(f, "Thresholds(")?; - for b in v { - write!(f, "{b:02x}")?; - } - write!(f, ")")?; - Ok(()) - } -} - -#[cfg(feature = "alloc")] -impl core::str::FromStr for Thresholds { - type Err = Error; - fn from_str(s: &str) -> core::result::Result { - hex::decode(s).map_err(|_| Error::InvalidHex)?.try_into() - } -} -impl From for [u8; 4] { - #[must_use] - fn from(x: Thresholds) -> Self { - x.0 - } +pub struct StateExpirationSettings { + pub max_entry_expiration: u32, + pub min_temp_entry_expiration: u32, + pub min_persistent_entry_expiration: u32, + pub persistent_rent_rate_denominator: i64, + pub temp_rent_rate_denominator: i64, + pub max_entries_to_expire: u32, + pub bucket_list_size_window_sample_size: u32, + pub eviction_scan_size: u64, + pub starting_eviction_scan_level: u32, } -impl From<[u8; 4]> for Thresholds { - #[must_use] - fn from(x: [u8; 4]) -> Self { - Thresholds(x) - } -} - -impl AsRef<[u8; 4]> for Thresholds { - #[must_use] - fn as_ref(&self) -> &[u8; 4] { - &self.0 - } -} - -impl ReadXdr for Thresholds { +impl ReadXdr for StateExpirationSettings { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = <[u8; 4]>::read_xdr(r)?; - let v = Thresholds(i); - Ok(v) + Ok(Self { + max_entry_expiration: u32::read_xdr(r)?, + min_temp_entry_expiration: u32::read_xdr(r)?, + min_persistent_entry_expiration: u32::read_xdr(r)?, + persistent_rent_rate_denominator: i64::read_xdr(r)?, + temp_rent_rate_denominator: i64::read_xdr(r)?, + max_entries_to_expire: u32::read_xdr(r)?, + bucket_list_size_window_sample_size: u32::read_xdr(r)?, + eviction_scan_size: u64::read_xdr(r)?, + starting_eviction_scan_level: u32::read_xdr(r)?, + }) }) } } -impl WriteXdr for Thresholds { +impl WriteXdr for StateExpirationSettings { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} - -impl Thresholds { - #[must_use] - pub fn as_slice(&self) -> &[u8] { - &self.0 + w.with_limited_depth(|w| { + self.max_entry_expiration.write_xdr(w)?; + self.min_temp_entry_expiration.write_xdr(w)?; + self.min_persistent_entry_expiration.write_xdr(w)?; + self.persistent_rent_rate_denominator.write_xdr(w)?; + self.temp_rent_rate_denominator.write_xdr(w)?; + self.max_entries_to_expire.write_xdr(w)?; + self.bucket_list_size_window_sample_size.write_xdr(w)?; + self.eviction_scan_size.write_xdr(w)?; + self.starting_eviction_scan_level.write_xdr(w)?; + Ok(()) + }) } } -#[cfg(feature = "alloc")] -impl TryFrom> for Thresholds { - type Error = Error; - fn try_from(x: Vec) -> Result { - x.as_slice().try_into() - } +// EvictionIterator is an XDR Struct defines as: +// +// struct EvictionIterator { +// uint32 bucketListLevel; +// bool isCurrBucket; +// uint64 bucketFileOffset; +// }; +// +#[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 EvictionIterator { + pub bucket_list_level: u32, + pub is_curr_bucket: bool, + pub bucket_file_offset: u64, } -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for Thresholds { - type Error = Error; - fn try_from(x: &Vec) -> Result { - x.as_slice().try_into() +impl ReadXdr for EvictionIterator { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + bucket_list_level: u32::read_xdr(r)?, + is_curr_bucket: bool::read_xdr(r)?, + bucket_file_offset: u64::read_xdr(r)?, + }) + }) } } -impl TryFrom<&[u8]> for Thresholds { - type Error = Error; - fn try_from(x: &[u8]) -> Result { - Ok(Thresholds(x.try_into()?)) +impl WriteXdr for EvictionIterator { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.bucket_list_level.write_xdr(w)?; + self.is_curr_bucket.write_xdr(w)?; + self.bucket_file_offset.write_xdr(w)?; + Ok(()) + }) } } -impl AsRef<[u8]> for Thresholds { - #[must_use] - fn as_ref(&self) -> &[u8] { - &self.0 - } -} +// ContractCostCountLimit is an XDR Const defines as: +// +// const CONTRACT_COST_COUNT_LIMIT = 1024; +// +pub const CONTRACT_COST_COUNT_LIMIT: u64 = 1024; -// String32 is an XDR Typedef defines as: +// ContractCostParams is an XDR Typedef defines as: // -// typedef string string32<32>; +// typedef ContractCostParamEntry ContractCostParams; // #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -3582,877 +3956,1355 @@ impl AsRef<[u8]> for Thresholds { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct String32(pub StringM<32>); +pub struct ContractCostParams(pub VecM); -impl From for StringM<32> { +impl From for VecM { #[must_use] - fn from(x: String32) -> Self { + fn from(x: ContractCostParams) -> Self { x.0 } } -impl From> for String32 { +impl From> for ContractCostParams { #[must_use] - fn from(x: StringM<32>) -> Self { - String32(x) + fn from(x: VecM) -> Self { + ContractCostParams(x) } } -impl AsRef> for String32 { +impl AsRef> for ContractCostParams { #[must_use] - fn as_ref(&self) -> &StringM<32> { + fn as_ref(&self) -> &VecM { &self.0 } } -impl ReadXdr for String32 { +impl ReadXdr for ContractCostParams { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = StringM::<32>::read_xdr(r)?; - let v = String32(i); + let i = VecM::::read_xdr(r)?; + let v = ContractCostParams(i); Ok(v) }) } } -impl WriteXdr for String32 { +impl WriteXdr for ContractCostParams { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| self.0.write_xdr(w)) } } -impl Deref for String32 { - type Target = StringM<32>; +impl Deref for ContractCostParams { + type Target = VecM; fn deref(&self) -> &Self::Target { &self.0 } } -impl From for Vec { +impl From for Vec { #[must_use] - fn from(x: String32) -> Self { + fn from(x: ContractCostParams) -> Self { x.0 .0 } } -impl TryFrom> for String32 { +impl TryFrom> for ContractCostParams { type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(String32(x.try_into()?)) + fn try_from(x: Vec) -> Result { + Ok(ContractCostParams(x.try_into()?)) } } #[cfg(feature = "alloc")] -impl TryFrom<&Vec> for String32 { +impl TryFrom<&Vec> for ContractCostParams { type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(String32(x.try_into()?)) + fn try_from(x: &Vec) -> Result { + Ok(ContractCostParams(x.try_into()?)) } } -impl AsRef> for String32 { +impl AsRef> for ContractCostParams { #[must_use] - fn as_ref(&self) -> &Vec { + fn as_ref(&self) -> &Vec { &self.0 .0 } } -impl AsRef<[u8]> for String32 { +impl AsRef<[ContractCostParamEntry]> for ContractCostParams { #[cfg(feature = "alloc")] #[must_use] - fn as_ref(&self) -> &[u8] { + fn as_ref(&self) -> &[ContractCostParamEntry] { &self.0 .0 } #[cfg(not(feature = "alloc"))] #[must_use] - fn as_ref(&self) -> &[u8] { + fn as_ref(&self) -> &[ContractCostParamEntry] { self.0 .0 } } -// String64 is an XDR Typedef defines as: +// ConfigSettingId is an XDR Enum defines as: // -// typedef string string64<64>; +// enum ConfigSettingID +// { +// CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES = 0, +// CONFIG_SETTING_CONTRACT_COMPUTE_V0 = 1, +// CONFIG_SETTING_CONTRACT_LEDGER_COST_V0 = 2, +// CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0 = 3, +// CONFIG_SETTING_CONTRACT_EVENTS_V0 = 4, +// CONFIG_SETTING_CONTRACT_BANDWIDTH_V0 = 5, +// CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS = 6, +// CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES = 7, +// CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES = 8, +// CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES = 9, +// CONFIG_SETTING_STATE_EXPIRATION = 10, +// CONFIG_SETTING_CONTRACT_EXECUTION_LANES = 11, +// CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW = 12, +// CONFIG_SETTING_EVICTION_ITERATOR = 13 +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct String64(pub StringM<64>); +#[repr(i32)] +pub enum ConfigSettingId { + ContractMaxSizeBytes = 0, + ContractComputeV0 = 1, + ContractLedgerCostV0 = 2, + ContractHistoricalDataV0 = 3, + ContractEventsV0 = 4, + ContractBandwidthV0 = 5, + ContractCostParamsCpuInstructions = 6, + ContractCostParamsMemoryBytes = 7, + ContractDataKeySizeBytes = 8, + ContractDataEntrySizeBytes = 9, + StateExpiration = 10, + ContractExecutionLanes = 11, + BucketlistSizeWindow = 12, + EvictionIterator = 13, +} + +impl ConfigSettingId { + pub const VARIANTS: [ConfigSettingId; 14] = [ + ConfigSettingId::ContractMaxSizeBytes, + ConfigSettingId::ContractComputeV0, + ConfigSettingId::ContractLedgerCostV0, + ConfigSettingId::ContractHistoricalDataV0, + ConfigSettingId::ContractEventsV0, + ConfigSettingId::ContractBandwidthV0, + ConfigSettingId::ContractCostParamsCpuInstructions, + ConfigSettingId::ContractCostParamsMemoryBytes, + ConfigSettingId::ContractDataKeySizeBytes, + ConfigSettingId::ContractDataEntrySizeBytes, + ConfigSettingId::StateExpiration, + ConfigSettingId::ContractExecutionLanes, + ConfigSettingId::BucketlistSizeWindow, + ConfigSettingId::EvictionIterator, + ]; + pub const VARIANTS_STR: [&'static str; 14] = [ + "ContractMaxSizeBytes", + "ContractComputeV0", + "ContractLedgerCostV0", + "ContractHistoricalDataV0", + "ContractEventsV0", + "ContractBandwidthV0", + "ContractCostParamsCpuInstructions", + "ContractCostParamsMemoryBytes", + "ContractDataKeySizeBytes", + "ContractDataEntrySizeBytes", + "StateExpiration", + "ContractExecutionLanes", + "BucketlistSizeWindow", + "EvictionIterator", + ]; -impl From for StringM<64> { #[must_use] - fn from(x: String64) -> Self { - x.0 + pub const fn name(&self) -> &'static str { + match self { + Self::ContractMaxSizeBytes => "ContractMaxSizeBytes", + Self::ContractComputeV0 => "ContractComputeV0", + Self::ContractLedgerCostV0 => "ContractLedgerCostV0", + Self::ContractHistoricalDataV0 => "ContractHistoricalDataV0", + Self::ContractEventsV0 => "ContractEventsV0", + Self::ContractBandwidthV0 => "ContractBandwidthV0", + Self::ContractCostParamsCpuInstructions => "ContractCostParamsCpuInstructions", + Self::ContractCostParamsMemoryBytes => "ContractCostParamsMemoryBytes", + Self::ContractDataKeySizeBytes => "ContractDataKeySizeBytes", + Self::ContractDataEntrySizeBytes => "ContractDataEntrySizeBytes", + Self::StateExpiration => "StateExpiration", + Self::ContractExecutionLanes => "ContractExecutionLanes", + Self::BucketlistSizeWindow => "BucketlistSizeWindow", + Self::EvictionIterator => "EvictionIterator", + } } -} -impl From> for String64 { #[must_use] - fn from(x: StringM<64>) -> Self { - String64(x) + pub const fn variants() -> [ConfigSettingId; 14] { + Self::VARIANTS } } -impl AsRef> for String64 { +impl Name for ConfigSettingId { #[must_use] - fn as_ref(&self) -> &StringM<64> { - &self.0 + fn name(&self) -> &'static str { + Self::name(self) } } -impl ReadXdr for String64 { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let i = StringM::<64>::read_xdr(r)?; - let v = String64(i); - Ok(v) - }) +impl Variants for ConfigSettingId { + fn variants() -> slice::Iter<'static, ConfigSettingId> { + Self::VARIANTS.iter() } } -impl WriteXdr for String64 { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} +impl Enum for ConfigSettingId {} -impl Deref for String64 { - type Target = StringM<64>; - fn deref(&self) -> &Self::Target { - &self.0 +impl fmt::Display for ConfigSettingId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl From for Vec { - #[must_use] - fn from(x: String64) -> Self { - x.0 .0 - } -} - -impl TryFrom> for String64 { +impl TryFrom for ConfigSettingId { type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(String64(x.try_into()?)) - } -} -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for String64 { - type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(String64(x.try_into()?)) + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ConfigSettingId::ContractMaxSizeBytes, + 1 => ConfigSettingId::ContractComputeV0, + 2 => ConfigSettingId::ContractLedgerCostV0, + 3 => ConfigSettingId::ContractHistoricalDataV0, + 4 => ConfigSettingId::ContractEventsV0, + 5 => ConfigSettingId::ContractBandwidthV0, + 6 => ConfigSettingId::ContractCostParamsCpuInstructions, + 7 => ConfigSettingId::ContractCostParamsMemoryBytes, + 8 => ConfigSettingId::ContractDataKeySizeBytes, + 9 => ConfigSettingId::ContractDataEntrySizeBytes, + 10 => ConfigSettingId::StateExpiration, + 11 => ConfigSettingId::ContractExecutionLanes, + 12 => ConfigSettingId::BucketlistSizeWindow, + 13 => ConfigSettingId::EvictionIterator, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -impl AsRef> for String64 { +impl From for i32 { #[must_use] - fn as_ref(&self) -> &Vec { - &self.0 .0 + fn from(e: ConfigSettingId) -> Self { + e as Self } } -impl AsRef<[u8]> for String64 { - #[cfg(feature = "alloc")] - #[must_use] - fn as_ref(&self) -> &[u8] { - &self.0 .0 +impl ReadXdr for ConfigSettingId { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) } - #[cfg(not(feature = "alloc"))] - #[must_use] - fn as_ref(&self) -> &[u8] { - self.0 .0 +} + +impl WriteXdr for ConfigSettingId { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) } } -// SequenceNumber is an XDR Typedef defines as: +// ConfigSettingEntry is an XDR Union defines as: // -// typedef int64 SequenceNumber; +// union ConfigSettingEntry switch (ConfigSettingID configSettingID) +// { +// case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES: +// uint32 contractMaxSizeBytes; +// case CONFIG_SETTING_CONTRACT_COMPUTE_V0: +// ConfigSettingContractComputeV0 contractCompute; +// case CONFIG_SETTING_CONTRACT_LEDGER_COST_V0: +// ConfigSettingContractLedgerCostV0 contractLedgerCost; +// case CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0: +// ConfigSettingContractHistoricalDataV0 contractHistoricalData; +// case CONFIG_SETTING_CONTRACT_EVENTS_V0: +// ConfigSettingContractEventsV0 contractEvents; +// case CONFIG_SETTING_CONTRACT_BANDWIDTH_V0: +// ConfigSettingContractBandwidthV0 contractBandwidth; +// case CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS: +// ContractCostParams contractCostParamsCpuInsns; +// case CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES: +// ContractCostParams contractCostParamsMemBytes; +// case CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES: +// uint32 contractDataKeySizeBytes; +// case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: +// uint32 contractDataEntrySizeBytes; +// case CONFIG_SETTING_STATE_EXPIRATION: +// StateExpirationSettings stateExpirationSettings; +// case CONFIG_SETTING_CONTRACT_EXECUTION_LANES: +// ConfigSettingContractExecutionLanesV0 contractExecutionLanes; +// case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: +// uint64 bucketListSizeWindow<>; +// case CONFIG_SETTING_EVICTION_ITERATOR: +// EvictionIterator evictionIterator; +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant ConfigSettingId +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SequenceNumber(pub i64); +#[allow(clippy::large_enum_variant)] +pub enum ConfigSettingEntry { + ContractMaxSizeBytes(u32), + ContractComputeV0(ConfigSettingContractComputeV0), + ContractLedgerCostV0(ConfigSettingContractLedgerCostV0), + ContractHistoricalDataV0(ConfigSettingContractHistoricalDataV0), + ContractEventsV0(ConfigSettingContractEventsV0), + ContractBandwidthV0(ConfigSettingContractBandwidthV0), + ContractCostParamsCpuInstructions(ContractCostParams), + ContractCostParamsMemoryBytes(ContractCostParams), + ContractDataKeySizeBytes(u32), + ContractDataEntrySizeBytes(u32), + StateExpiration(StateExpirationSettings), + ContractExecutionLanes(ConfigSettingContractExecutionLanesV0), + BucketlistSizeWindow(VecM), + EvictionIterator(EvictionIterator), +} + +impl ConfigSettingEntry { + pub const VARIANTS: [ConfigSettingId; 14] = [ + ConfigSettingId::ContractMaxSizeBytes, + ConfigSettingId::ContractComputeV0, + ConfigSettingId::ContractLedgerCostV0, + ConfigSettingId::ContractHistoricalDataV0, + ConfigSettingId::ContractEventsV0, + ConfigSettingId::ContractBandwidthV0, + ConfigSettingId::ContractCostParamsCpuInstructions, + ConfigSettingId::ContractCostParamsMemoryBytes, + ConfigSettingId::ContractDataKeySizeBytes, + ConfigSettingId::ContractDataEntrySizeBytes, + ConfigSettingId::StateExpiration, + ConfigSettingId::ContractExecutionLanes, + ConfigSettingId::BucketlistSizeWindow, + ConfigSettingId::EvictionIterator, + ]; + pub const VARIANTS_STR: [&'static str; 14] = [ + "ContractMaxSizeBytes", + "ContractComputeV0", + "ContractLedgerCostV0", + "ContractHistoricalDataV0", + "ContractEventsV0", + "ContractBandwidthV0", + "ContractCostParamsCpuInstructions", + "ContractCostParamsMemoryBytes", + "ContractDataKeySizeBytes", + "ContractDataEntrySizeBytes", + "StateExpiration", + "ContractExecutionLanes", + "BucketlistSizeWindow", + "EvictionIterator", + ]; -impl From for i64 { #[must_use] - fn from(x: SequenceNumber) -> Self { - x.0 + pub const fn name(&self) -> &'static str { + match self { + Self::ContractMaxSizeBytes(_) => "ContractMaxSizeBytes", + Self::ContractComputeV0(_) => "ContractComputeV0", + Self::ContractLedgerCostV0(_) => "ContractLedgerCostV0", + Self::ContractHistoricalDataV0(_) => "ContractHistoricalDataV0", + Self::ContractEventsV0(_) => "ContractEventsV0", + Self::ContractBandwidthV0(_) => "ContractBandwidthV0", + Self::ContractCostParamsCpuInstructions(_) => "ContractCostParamsCpuInstructions", + Self::ContractCostParamsMemoryBytes(_) => "ContractCostParamsMemoryBytes", + Self::ContractDataKeySizeBytes(_) => "ContractDataKeySizeBytes", + Self::ContractDataEntrySizeBytes(_) => "ContractDataEntrySizeBytes", + Self::StateExpiration(_) => "StateExpiration", + Self::ContractExecutionLanes(_) => "ContractExecutionLanes", + Self::BucketlistSizeWindow(_) => "BucketlistSizeWindow", + Self::EvictionIterator(_) => "EvictionIterator", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ConfigSettingId { + #[allow(clippy::match_same_arms)] + match self { + Self::ContractMaxSizeBytes(_) => ConfigSettingId::ContractMaxSizeBytes, + Self::ContractComputeV0(_) => ConfigSettingId::ContractComputeV0, + Self::ContractLedgerCostV0(_) => ConfigSettingId::ContractLedgerCostV0, + Self::ContractHistoricalDataV0(_) => ConfigSettingId::ContractHistoricalDataV0, + Self::ContractEventsV0(_) => ConfigSettingId::ContractEventsV0, + Self::ContractBandwidthV0(_) => ConfigSettingId::ContractBandwidthV0, + Self::ContractCostParamsCpuInstructions(_) => { + ConfigSettingId::ContractCostParamsCpuInstructions + } + Self::ContractCostParamsMemoryBytes(_) => { + ConfigSettingId::ContractCostParamsMemoryBytes + } + Self::ContractDataKeySizeBytes(_) => ConfigSettingId::ContractDataKeySizeBytes, + Self::ContractDataEntrySizeBytes(_) => ConfigSettingId::ContractDataEntrySizeBytes, + Self::StateExpiration(_) => ConfigSettingId::StateExpiration, + Self::ContractExecutionLanes(_) => ConfigSettingId::ContractExecutionLanes, + Self::BucketlistSizeWindow(_) => ConfigSettingId::BucketlistSizeWindow, + Self::EvictionIterator(_) => ConfigSettingId::EvictionIterator, + } + } + + #[must_use] + pub const fn variants() -> [ConfigSettingId; 14] { + Self::VARIANTS } } -impl From for SequenceNumber { +impl Name for ConfigSettingEntry { #[must_use] - fn from(x: i64) -> Self { - SequenceNumber(x) + fn name(&self) -> &'static str { + Self::name(self) } } -impl AsRef for SequenceNumber { +impl Discriminant for ConfigSettingEntry { #[must_use] - fn as_ref(&self) -> &i64 { - &self.0 + fn discriminant(&self) -> ConfigSettingId { + Self::discriminant(self) } } -impl ReadXdr for SequenceNumber { +impl Variants for ConfigSettingEntry { + fn variants() -> slice::Iter<'static, ConfigSettingId> { + Self::VARIANTS.iter() + } +} + +impl Union for ConfigSettingEntry {} + +impl ReadXdr for ConfigSettingEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = i64::read_xdr(r)?; - let v = SequenceNumber(i); + let dv: ConfigSettingId = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ConfigSettingId::ContractMaxSizeBytes => { + Self::ContractMaxSizeBytes(u32::read_xdr(r)?) + } + ConfigSettingId::ContractComputeV0 => { + Self::ContractComputeV0(ConfigSettingContractComputeV0::read_xdr(r)?) + } + ConfigSettingId::ContractLedgerCostV0 => { + Self::ContractLedgerCostV0(ConfigSettingContractLedgerCostV0::read_xdr(r)?) + } + ConfigSettingId::ContractHistoricalDataV0 => Self::ContractHistoricalDataV0( + ConfigSettingContractHistoricalDataV0::read_xdr(r)?, + ), + ConfigSettingId::ContractEventsV0 => { + Self::ContractEventsV0(ConfigSettingContractEventsV0::read_xdr(r)?) + } + ConfigSettingId::ContractBandwidthV0 => { + Self::ContractBandwidthV0(ConfigSettingContractBandwidthV0::read_xdr(r)?) + } + ConfigSettingId::ContractCostParamsCpuInstructions => { + Self::ContractCostParamsCpuInstructions(ContractCostParams::read_xdr(r)?) + } + ConfigSettingId::ContractCostParamsMemoryBytes => { + Self::ContractCostParamsMemoryBytes(ContractCostParams::read_xdr(r)?) + } + ConfigSettingId::ContractDataKeySizeBytes => { + Self::ContractDataKeySizeBytes(u32::read_xdr(r)?) + } + ConfigSettingId::ContractDataEntrySizeBytes => { + Self::ContractDataEntrySizeBytes(u32::read_xdr(r)?) + } + ConfigSettingId::StateExpiration => { + Self::StateExpiration(StateExpirationSettings::read_xdr(r)?) + } + ConfigSettingId::ContractExecutionLanes => Self::ContractExecutionLanes( + ConfigSettingContractExecutionLanesV0::read_xdr(r)?, + ), + ConfigSettingId::BucketlistSizeWindow => { + Self::BucketlistSizeWindow(VecM::::read_xdr(r)?) + } + ConfigSettingId::EvictionIterator => { + Self::EvictionIterator(EvictionIterator::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for SequenceNumber { +impl WriteXdr for ConfigSettingEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::ContractMaxSizeBytes(v) => v.write_xdr(w)?, + Self::ContractComputeV0(v) => v.write_xdr(w)?, + Self::ContractLedgerCostV0(v) => v.write_xdr(w)?, + Self::ContractHistoricalDataV0(v) => v.write_xdr(w)?, + Self::ContractEventsV0(v) => v.write_xdr(w)?, + Self::ContractBandwidthV0(v) => v.write_xdr(w)?, + Self::ContractCostParamsCpuInstructions(v) => v.write_xdr(w)?, + Self::ContractCostParamsMemoryBytes(v) => v.write_xdr(w)?, + Self::ContractDataKeySizeBytes(v) => v.write_xdr(w)?, + Self::ContractDataEntrySizeBytes(v) => v.write_xdr(w)?, + Self::StateExpiration(v) => v.write_xdr(w)?, + Self::ContractExecutionLanes(v) => v.write_xdr(w)?, + Self::BucketlistSizeWindow(v) => v.write_xdr(w)?, + Self::EvictionIterator(v) => v.write_xdr(w)?, + }; + Ok(()) + }) } } -// TimePoint is an XDR Typedef defines as: +// ScEnvMetaKind is an XDR Enum defines as: // -// typedef uint64 TimePoint; +// enum SCEnvMetaKind +// { +// SC_ENV_META_KIND_INTERFACE_VERSION = 0 +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TimePoint(pub u64); +#[repr(i32)] +pub enum ScEnvMetaKind { + ScEnvMetaKindInterfaceVersion = 0, +} + +impl ScEnvMetaKind { + pub const VARIANTS: [ScEnvMetaKind; 1] = [ScEnvMetaKind::ScEnvMetaKindInterfaceVersion]; + pub const VARIANTS_STR: [&'static str; 1] = ["ScEnvMetaKindInterfaceVersion"]; -impl From for u64 { #[must_use] - fn from(x: TimePoint) -> Self { - x.0 + pub const fn name(&self) -> &'static str { + match self { + Self::ScEnvMetaKindInterfaceVersion => "ScEnvMetaKindInterfaceVersion", + } + } + + #[must_use] + pub const fn variants() -> [ScEnvMetaKind; 1] { + Self::VARIANTS } } -impl From for TimePoint { +impl Name for ScEnvMetaKind { #[must_use] - fn from(x: u64) -> Self { - TimePoint(x) + fn name(&self) -> &'static str { + Self::name(self) } } -impl AsRef for TimePoint { +impl Variants for ScEnvMetaKind { + fn variants() -> slice::Iter<'static, ScEnvMetaKind> { + Self::VARIANTS.iter() + } +} + +impl Enum for ScEnvMetaKind {} + +impl fmt::Display for ScEnvMetaKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ScEnvMetaKind { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ScEnvMetaKind::ScEnvMetaKindInterfaceVersion, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { #[must_use] - fn as_ref(&self) -> &u64 { - &self.0 + fn from(e: ScEnvMetaKind) -> Self { + e as Self } } -impl ReadXdr for TimePoint { +impl ReadXdr for ScEnvMetaKind { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = u64::read_xdr(r)?; - let v = TimePoint(i); + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; Ok(v) }) } } -impl WriteXdr for TimePoint { +impl WriteXdr for ScEnvMetaKind { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) } } -// Duration is an XDR Typedef defines as: +// ScEnvMetaEntry is an XDR Union defines as: // -// typedef uint64 Duration; +// union SCEnvMetaEntry switch (SCEnvMetaKind kind) +// { +// case SC_ENV_META_KIND_INTERFACE_VERSION: +// uint64 interfaceVersion; +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant ScEnvMetaKind +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct Duration(pub u64); +#[allow(clippy::large_enum_variant)] +pub enum ScEnvMetaEntry { + ScEnvMetaKindInterfaceVersion(u64), +} + +impl ScEnvMetaEntry { + pub const VARIANTS: [ScEnvMetaKind; 1] = [ScEnvMetaKind::ScEnvMetaKindInterfaceVersion]; + pub const VARIANTS_STR: [&'static str; 1] = ["ScEnvMetaKindInterfaceVersion"]; -impl From for u64 { #[must_use] - fn from(x: Duration) -> Self { - x.0 + pub const fn name(&self) -> &'static str { + match self { + Self::ScEnvMetaKindInterfaceVersion(_) => "ScEnvMetaKindInterfaceVersion", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ScEnvMetaKind { + #[allow(clippy::match_same_arms)] + match self { + Self::ScEnvMetaKindInterfaceVersion(_) => ScEnvMetaKind::ScEnvMetaKindInterfaceVersion, + } + } + + #[must_use] + pub const fn variants() -> [ScEnvMetaKind; 1] { + Self::VARIANTS } } -impl From for Duration { +impl Name for ScEnvMetaEntry { #[must_use] - fn from(x: u64) -> Self { - Duration(x) + fn name(&self) -> &'static str { + Self::name(self) } } -impl AsRef for Duration { +impl Discriminant for ScEnvMetaEntry { #[must_use] - fn as_ref(&self) -> &u64 { - &self.0 + fn discriminant(&self) -> ScEnvMetaKind { + Self::discriminant(self) } } -impl ReadXdr for Duration { +impl Variants for ScEnvMetaEntry { + fn variants() -> slice::Iter<'static, ScEnvMetaKind> { + Self::VARIANTS.iter() + } +} + +impl Union for ScEnvMetaEntry {} + +impl ReadXdr for ScEnvMetaEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = u64::read_xdr(r)?; - let v = Duration(i); + let dv: ScEnvMetaKind = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ScEnvMetaKind::ScEnvMetaKindInterfaceVersion => { + Self::ScEnvMetaKindInterfaceVersion(u64::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for Duration { +impl WriteXdr for ScEnvMetaEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::ScEnvMetaKindInterfaceVersion(v) => v.write_xdr(w)?, + }; + Ok(()) + }) } } -// DataValue is an XDR Typedef defines as: +// ScMetaV0 is an XDR Struct defines as: // -// typedef opaque DataValue<64>; +// struct SCMetaV0 +// { +// string key<>; +// string val<>; +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct DataValue(pub BytesM<64>); - -impl From for BytesM<64> { - #[must_use] - fn from(x: DataValue) -> Self { - x.0 - } -} - -impl From> for DataValue { - #[must_use] - fn from(x: BytesM<64>) -> Self { - DataValue(x) - } -} - -impl AsRef> for DataValue { - #[must_use] - fn as_ref(&self) -> &BytesM<64> { - &self.0 - } +pub struct ScMetaV0 { + pub key: StringM, + pub val: StringM, } -impl ReadXdr for DataValue { +impl ReadXdr for ScMetaV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = BytesM::<64>::read_xdr(r)?; - let v = DataValue(i); - Ok(v) + Ok(Self { + key: StringM::read_xdr(r)?, + val: StringM::read_xdr(r)?, + }) }) } } -impl WriteXdr for DataValue { +impl WriteXdr for ScMetaV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + w.with_limited_depth(|w| { + self.key.write_xdr(w)?; + self.val.write_xdr(w)?; + Ok(()) + }) } } -impl Deref for DataValue { - type Target = BytesM<64>; - fn deref(&self) -> &Self::Target { - &self.0 +// ScMetaKind is an XDR Enum defines as: +// +// enum SCMetaKind +// { +// SC_META_V0 = 0 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ScMetaKind { + ScMetaV0 = 0, +} + +impl ScMetaKind { + pub const VARIANTS: [ScMetaKind; 1] = [ScMetaKind::ScMetaV0]; + pub const VARIANTS_STR: [&'static str; 1] = ["ScMetaV0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ScMetaV0 => "ScMetaV0", + } + } + + #[must_use] + pub const fn variants() -> [ScMetaKind; 1] { + Self::VARIANTS } } -impl From for Vec { +impl Name for ScMetaKind { #[must_use] - fn from(x: DataValue) -> Self { - x.0 .0 + fn name(&self) -> &'static str { + Self::name(self) } } -impl TryFrom> for DataValue { - type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(DataValue(x.try_into()?)) +impl Variants for ScMetaKind { + fn variants() -> slice::Iter<'static, ScMetaKind> { + Self::VARIANTS.iter() } } -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for DataValue { +impl Enum for ScMetaKind {} + +impl fmt::Display for ScMetaKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ScMetaKind { type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(DataValue(x.try_into()?)) + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ScMetaKind::ScMetaV0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -impl AsRef> for DataValue { +impl From for i32 { #[must_use] - fn as_ref(&self) -> &Vec { - &self.0 .0 + fn from(e: ScMetaKind) -> Self { + e as Self } } -impl AsRef<[u8]> for DataValue { - #[cfg(feature = "alloc")] - #[must_use] - fn as_ref(&self) -> &[u8] { - &self.0 .0 +impl ReadXdr for ScMetaKind { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) } - #[cfg(not(feature = "alloc"))] - #[must_use] - fn as_ref(&self) -> &[u8] { - self.0 .0 +} + +impl WriteXdr for ScMetaKind { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) } } -// PoolId is an XDR Typedef defines as: +// ScMetaEntry is an XDR Union defines as: // -// typedef Hash PoolID; +// union SCMetaEntry switch (SCMetaKind kind) +// { +// case SC_META_V0: +// SCMetaV0 v0; +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant ScMetaKind +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PoolId(pub Hash); +#[allow(clippy::large_enum_variant)] +pub enum ScMetaEntry { + ScMetaV0(ScMetaV0), +} + +impl ScMetaEntry { + pub const VARIANTS: [ScMetaKind; 1] = [ScMetaKind::ScMetaV0]; + pub const VARIANTS_STR: [&'static str; 1] = ["ScMetaV0"]; -impl From for Hash { #[must_use] - fn from(x: PoolId) -> Self { - x.0 + pub const fn name(&self) -> &'static str { + match self { + Self::ScMetaV0(_) => "ScMetaV0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ScMetaKind { + #[allow(clippy::match_same_arms)] + match self { + Self::ScMetaV0(_) => ScMetaKind::ScMetaV0, + } + } + + #[must_use] + pub const fn variants() -> [ScMetaKind; 1] { + Self::VARIANTS } } -impl From for PoolId { +impl Name for ScMetaEntry { #[must_use] - fn from(x: Hash) -> Self { - PoolId(x) + fn name(&self) -> &'static str { + Self::name(self) } } -impl AsRef for PoolId { +impl Discriminant for ScMetaEntry { #[must_use] - fn as_ref(&self) -> &Hash { - &self.0 + fn discriminant(&self) -> ScMetaKind { + Self::discriminant(self) } } -impl ReadXdr for PoolId { +impl Variants for ScMetaEntry { + fn variants() -> slice::Iter<'static, ScMetaKind> { + Self::VARIANTS.iter() + } +} + +impl Union for ScMetaEntry {} + +impl ReadXdr for ScMetaEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = Hash::read_xdr(r)?; - let v = PoolId(i); + let dv: ScMetaKind = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ScMetaKind::ScMetaV0 => Self::ScMetaV0(ScMetaV0::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for PoolId { +impl WriteXdr for ScMetaEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::ScMetaV0(v) => v.write_xdr(w)?, + }; + Ok(()) + }) } } -// AssetCode4 is an XDR Typedef defines as: +// ScSpecDocLimit is an XDR Const defines as: // -// typedef opaque AssetCode4[4]; +// const SC_SPEC_DOC_LIMIT = 1024; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub const SC_SPEC_DOC_LIMIT: u64 = 1024; + +// ScSpecType is an XDR Enum defines as: +// +// enum SCSpecType +// { +// SC_SPEC_TYPE_VAL = 0, +// +// // Types with no parameters. +// SC_SPEC_TYPE_BOOL = 1, +// SC_SPEC_TYPE_VOID = 2, +// SC_SPEC_TYPE_ERROR = 3, +// SC_SPEC_TYPE_U32 = 4, +// SC_SPEC_TYPE_I32 = 5, +// SC_SPEC_TYPE_U64 = 6, +// SC_SPEC_TYPE_I64 = 7, +// SC_SPEC_TYPE_TIMEPOINT = 8, +// SC_SPEC_TYPE_DURATION = 9, +// SC_SPEC_TYPE_U128 = 10, +// SC_SPEC_TYPE_I128 = 11, +// SC_SPEC_TYPE_U256 = 12, +// SC_SPEC_TYPE_I256 = 13, +// SC_SPEC_TYPE_BYTES = 14, +// SC_SPEC_TYPE_STRING = 16, +// SC_SPEC_TYPE_SYMBOL = 17, +// SC_SPEC_TYPE_ADDRESS = 19, +// +// // Types with parameters. +// SC_SPEC_TYPE_OPTION = 1000, +// SC_SPEC_TYPE_RESULT = 1001, +// SC_SPEC_TYPE_VEC = 1002, +// SC_SPEC_TYPE_MAP = 1004, +// SC_SPEC_TYPE_TUPLE = 1005, +// SC_SPEC_TYPE_BYTES_N = 1006, +// +// // User defined types. +// SC_SPEC_TYPE_UDT = 2000 +// }; +// +// enum +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( all(feature = "serde", feature = "alloc"), - derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr) + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") )] -pub struct AssetCode4(pub [u8; 4]); +#[repr(i32)] +pub enum ScSpecType { + Val = 0, + Bool = 1, + Void = 2, + Error = 3, + U32 = 4, + I32 = 5, + U64 = 6, + I64 = 7, + Timepoint = 8, + Duration = 9, + U128 = 10, + I128 = 11, + U256 = 12, + I256 = 13, + Bytes = 14, + String = 16, + Symbol = 17, + Address = 19, + Option = 1000, + Result = 1001, + Vec = 1002, + Map = 1004, + Tuple = 1005, + BytesN = 1006, + Udt = 2000, +} + +impl ScSpecType { + pub const VARIANTS: [ScSpecType; 25] = [ + ScSpecType::Val, + ScSpecType::Bool, + ScSpecType::Void, + ScSpecType::Error, + ScSpecType::U32, + ScSpecType::I32, + ScSpecType::U64, + ScSpecType::I64, + ScSpecType::Timepoint, + ScSpecType::Duration, + ScSpecType::U128, + ScSpecType::I128, + ScSpecType::U256, + ScSpecType::I256, + ScSpecType::Bytes, + ScSpecType::String, + ScSpecType::Symbol, + ScSpecType::Address, + ScSpecType::Option, + ScSpecType::Result, + ScSpecType::Vec, + ScSpecType::Map, + ScSpecType::Tuple, + ScSpecType::BytesN, + ScSpecType::Udt, + ]; + pub const VARIANTS_STR: [&'static str; 25] = [ + "Val", + "Bool", + "Void", + "Error", + "U32", + "I32", + "U64", + "I64", + "Timepoint", + "Duration", + "U128", + "I128", + "U256", + "I256", + "Bytes", + "String", + "Symbol", + "Address", + "Option", + "Result", + "Vec", + "Map", + "Tuple", + "BytesN", + "Udt", + ]; -impl core::fmt::Display for AssetCode4 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let v = &self.0; - for b in v { - write!(f, "{b:02x}")?; - } - Ok(()) + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Val => "Val", + Self::Bool => "Bool", + Self::Void => "Void", + Self::Error => "Error", + Self::U32 => "U32", + Self::I32 => "I32", + Self::U64 => "U64", + Self::I64 => "I64", + Self::Timepoint => "Timepoint", + Self::Duration => "Duration", + Self::U128 => "U128", + Self::I128 => "I128", + Self::U256 => "U256", + Self::I256 => "I256", + Self::Bytes => "Bytes", + Self::String => "String", + Self::Symbol => "Symbol", + Self::Address => "Address", + Self::Option => "Option", + Self::Result => "Result", + Self::Vec => "Vec", + Self::Map => "Map", + Self::Tuple => "Tuple", + Self::BytesN => "BytesN", + Self::Udt => "Udt", + } + } + + #[must_use] + pub const fn variants() -> [ScSpecType; 25] { + Self::VARIANTS } } -impl core::fmt::Debug for AssetCode4 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let v = &self.0; - write!(f, "AssetCode4(")?; - for b in v { - write!(f, "{b:02x}")?; - } - write!(f, ")")?; - Ok(()) +impl Name for ScSpecType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) } } -#[cfg(feature = "alloc")] -impl core::str::FromStr for AssetCode4 { - type Err = Error; - fn from_str(s: &str) -> core::result::Result { - hex::decode(s).map_err(|_| Error::InvalidHex)?.try_into() +impl Variants for ScSpecType { + fn variants() -> slice::Iter<'static, ScSpecType> { + Self::VARIANTS.iter() } } -impl From for [u8; 4] { - #[must_use] - fn from(x: AssetCode4) -> Self { - x.0 + +impl Enum for ScSpecType {} + +impl fmt::Display for ScSpecType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl From<[u8; 4]> for AssetCode4 { - #[must_use] - fn from(x: [u8; 4]) -> Self { - AssetCode4(x) +impl TryFrom for ScSpecType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ScSpecType::Val, + 1 => ScSpecType::Bool, + 2 => ScSpecType::Void, + 3 => ScSpecType::Error, + 4 => ScSpecType::U32, + 5 => ScSpecType::I32, + 6 => ScSpecType::U64, + 7 => ScSpecType::I64, + 8 => ScSpecType::Timepoint, + 9 => ScSpecType::Duration, + 10 => ScSpecType::U128, + 11 => ScSpecType::I128, + 12 => ScSpecType::U256, + 13 => ScSpecType::I256, + 14 => ScSpecType::Bytes, + 16 => ScSpecType::String, + 17 => ScSpecType::Symbol, + 19 => ScSpecType::Address, + 1000 => ScSpecType::Option, + 1001 => ScSpecType::Result, + 1002 => ScSpecType::Vec, + 1004 => ScSpecType::Map, + 1005 => ScSpecType::Tuple, + 1006 => ScSpecType::BytesN, + 2000 => ScSpecType::Udt, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -impl AsRef<[u8; 4]> for AssetCode4 { +impl From for i32 { #[must_use] - fn as_ref(&self) -> &[u8; 4] { - &self.0 + fn from(e: ScSpecType) -> Self { + e as Self } } -impl ReadXdr for AssetCode4 { +impl ReadXdr for ScSpecType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = <[u8; 4]>::read_xdr(r)?; - let v = AssetCode4(i); + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; Ok(v) }) } } -impl WriteXdr for AssetCode4 { +impl WriteXdr for ScSpecType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} - -impl AssetCode4 { - #[must_use] - pub fn as_slice(&self) -> &[u8] { - &self.0 + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) } } -#[cfg(feature = "alloc")] -impl TryFrom> for AssetCode4 { - type Error = Error; - fn try_from(x: Vec) -> Result { - x.as_slice().try_into() - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for AssetCode4 { - type Error = Error; - fn try_from(x: &Vec) -> Result { - x.as_slice().try_into() - } -} - -impl TryFrom<&[u8]> for AssetCode4 { - type Error = Error; - fn try_from(x: &[u8]) -> Result { - Ok(AssetCode4(x.try_into()?)) - } -} - -impl AsRef<[u8]> for AssetCode4 { - #[must_use] - fn as_ref(&self) -> &[u8] { - &self.0 - } -} - -// AssetCode12 is an XDR Typedef defines as: +// ScSpecTypeOption is an XDR Struct defines as: // -// typedef opaque AssetCode12[12]; +// struct SCSpecTypeOption +// { +// SCSpecTypeDef valueType; +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( all(feature = "serde", feature = "alloc"), - derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr) + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") )] -pub struct AssetCode12(pub [u8; 12]); - -impl core::fmt::Display for AssetCode12 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let v = &self.0; - for b in v { - write!(f, "{b:02x}")?; - } - Ok(()) - } -} - -impl core::fmt::Debug for AssetCode12 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let v = &self.0; - write!(f, "AssetCode12(")?; - for b in v { - write!(f, "{b:02x}")?; - } - write!(f, ")")?; - Ok(()) - } -} - -#[cfg(feature = "alloc")] -impl core::str::FromStr for AssetCode12 { - type Err = Error; - fn from_str(s: &str) -> core::result::Result { - hex::decode(s).map_err(|_| Error::InvalidHex)?.try_into() - } -} -impl From for [u8; 12] { - #[must_use] - fn from(x: AssetCode12) -> Self { - x.0 - } -} - -impl From<[u8; 12]> for AssetCode12 { - #[must_use] - fn from(x: [u8; 12]) -> Self { - AssetCode12(x) - } -} - -impl AsRef<[u8; 12]> for AssetCode12 { - #[must_use] - fn as_ref(&self) -> &[u8; 12] { - &self.0 - } +pub struct ScSpecTypeOption { + pub value_type: Box, } -impl ReadXdr for AssetCode12 { +impl ReadXdr for ScSpecTypeOption { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = <[u8; 12]>::read_xdr(r)?; - let v = AssetCode12(i); - Ok(v) + Ok(Self { + value_type: Box::::read_xdr(r)?, + }) }) } } -impl WriteXdr for AssetCode12 { +impl WriteXdr for ScSpecTypeOption { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} - -impl AssetCode12 { - #[must_use] - pub fn as_slice(&self) -> &[u8] { - &self.0 - } -} - -#[cfg(feature = "alloc")] -impl TryFrom> for AssetCode12 { - type Error = Error; - fn try_from(x: Vec) -> Result { - x.as_slice().try_into() - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for AssetCode12 { - type Error = Error; - fn try_from(x: &Vec) -> Result { - x.as_slice().try_into() - } -} - -impl TryFrom<&[u8]> for AssetCode12 { - type Error = Error; - fn try_from(x: &[u8]) -> Result { - Ok(AssetCode12(x.try_into()?)) - } -} - -impl AsRef<[u8]> for AssetCode12 { - #[must_use] - fn as_ref(&self) -> &[u8] { - &self.0 + w.with_limited_depth(|w| { + self.value_type.write_xdr(w)?; + Ok(()) + }) } } -// AssetType is an XDR Enum defines as: +// ScSpecTypeResult is an XDR Struct defines as: // -// enum AssetType +// struct SCSpecTypeResult // { -// ASSET_TYPE_NATIVE = 0, -// ASSET_TYPE_CREDIT_ALPHANUM4 = 1, -// ASSET_TYPE_CREDIT_ALPHANUM12 = 2, -// ASSET_TYPE_POOL_SHARE = 3 +// SCSpecTypeDef okType; +// SCSpecTypeDef errorType; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[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") )] -#[repr(i32)] -pub enum AssetType { - Native = 0, - CreditAlphanum4 = 1, - CreditAlphanum12 = 2, - PoolShare = 3, -} - -impl AssetType { - pub const VARIANTS: [AssetType; 4] = [ - AssetType::Native, - AssetType::CreditAlphanum4, - AssetType::CreditAlphanum12, - AssetType::PoolShare, - ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Native", "CreditAlphanum4", "CreditAlphanum12", "PoolShare"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::Native => "Native", - Self::CreditAlphanum4 => "CreditAlphanum4", - Self::CreditAlphanum12 => "CreditAlphanum12", - Self::PoolShare => "PoolShare", - } - } - - #[must_use] - pub const fn variants() -> [AssetType; 4] { - Self::VARIANTS - } -} - -impl Name for AssetType { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Variants for AssetType { - fn variants() -> slice::Iter<'static, AssetType> { - Self::VARIANTS.iter() - } +pub struct ScSpecTypeResult { + pub ok_type: Box, + pub error_type: Box, } -impl Enum for AssetType {} - -impl fmt::Display for AssetType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl ReadXdr for ScSpecTypeResult { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ok_type: Box::::read_xdr(r)?, + error_type: Box::::read_xdr(r)?, + }) + }) } } -impl TryFrom for AssetType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => AssetType::Native, - 1 => AssetType::CreditAlphanum4, - 2 => AssetType::CreditAlphanum12, - 3 => AssetType::PoolShare, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl WriteXdr for ScSpecTypeResult { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ok_type.write_xdr(w)?; + self.error_type.write_xdr(w)?; + Ok(()) + }) } } -impl From for i32 { - #[must_use] - fn from(e: AssetType) -> Self { - e as Self - } +// ScSpecTypeVec is an XDR Struct defines as: +// +// struct SCSpecTypeVec +// { +// SCSpecTypeDef elementType; +// }; +// +#[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 ScSpecTypeVec { + pub element_type: Box, } -impl ReadXdr for AssetType { +impl ReadXdr for ScSpecTypeVec { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) + Ok(Self { + element_type: Box::::read_xdr(r)?, + }) }) } } -impl WriteXdr for AssetType { +impl WriteXdr for ScSpecTypeVec { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.element_type.write_xdr(w)?; + Ok(()) }) } } -// AssetCode is an XDR Union defines as: +// ScSpecTypeMap is an XDR Struct defines as: // -// union AssetCode switch (AssetType type) +// struct SCSpecTypeMap // { -// case ASSET_TYPE_CREDIT_ALPHANUM4: -// AssetCode4 assetCode4; -// -// case ASSET_TYPE_CREDIT_ALPHANUM12: -// AssetCode12 assetCode12; -// -// // add other asset types here in the future +// SCSpecTypeDef keyType; +// SCSpecTypeDef valueType; // }; // -// union with discriminant AssetType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -4460,99 +5312,78 @@ impl WriteXdr for AssetType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum AssetCode { - CreditAlphanum4(AssetCode4), - CreditAlphanum12(AssetCode12), -} - -impl AssetCode { - pub const VARIANTS: [AssetType; 2] = [AssetType::CreditAlphanum4, AssetType::CreditAlphanum12]; - pub const VARIANTS_STR: [&'static str; 2] = ["CreditAlphanum4", "CreditAlphanum12"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::CreditAlphanum4(_) => "CreditAlphanum4", - Self::CreditAlphanum12(_) => "CreditAlphanum12", - } - } - - #[must_use] - pub const fn discriminant(&self) -> AssetType { - #[allow(clippy::match_same_arms)] - match self { - Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, - Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, - } - } - - #[must_use] - pub const fn variants() -> [AssetType; 2] { - Self::VARIANTS - } +pub struct ScSpecTypeMap { + pub key_type: Box, + pub value_type: Box, } -impl Name for AssetCode { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) +impl ReadXdr for ScSpecTypeMap { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + key_type: Box::::read_xdr(r)?, + value_type: Box::::read_xdr(r)?, + }) + }) } } -impl Discriminant for AssetCode { - #[must_use] - fn discriminant(&self) -> AssetType { - Self::discriminant(self) +impl WriteXdr for ScSpecTypeMap { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.key_type.write_xdr(w)?; + self.value_type.write_xdr(w)?; + Ok(()) + }) } } -impl Variants for AssetCode { - fn variants() -> slice::Iter<'static, AssetType> { - Self::VARIANTS.iter() - } +// ScSpecTypeTuple is an XDR Struct defines as: +// +// struct SCSpecTypeTuple +// { +// SCSpecTypeDef valueTypes<12>; +// }; +// +#[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 ScSpecTypeTuple { + pub value_types: VecM, } -impl Union for AssetCode {} - -impl ReadXdr for AssetCode { +impl ReadXdr for ScSpecTypeTuple { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: AssetType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AssetCode4::read_xdr(r)?), - AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AssetCode12::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + value_types: VecM::::read_xdr(r)?, + }) }) } } -impl WriteXdr for AssetCode { +impl WriteXdr for ScSpecTypeTuple { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::CreditAlphanum4(v) => v.write_xdr(w)?, - Self::CreditAlphanum12(v) => v.write_xdr(w)?, - }; + self.value_types.write_xdr(w)?; Ok(()) }) } } -// AlphaNum4 is an XDR Struct defines as: +// ScSpecTypeBytesN is an XDR Struct defines as: // -// struct AlphaNum4 +// struct SCSpecTypeBytesN // { -// AssetCode4 assetCode; -// AccountID issuer; +// uint32 n; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -4562,40 +5393,36 @@ impl WriteXdr for AssetCode { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct AlphaNum4 { - pub asset_code: AssetCode4, - pub issuer: AccountId, +pub struct ScSpecTypeBytesN { + pub n: u32, } -impl ReadXdr for AlphaNum4 { +impl ReadXdr for ScSpecTypeBytesN { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - asset_code: AssetCode4::read_xdr(r)?, - issuer: AccountId::read_xdr(r)?, + n: u32::read_xdr(r)?, }) }) } } -impl WriteXdr for AlphaNum4 { +impl WriteXdr for ScSpecTypeBytesN { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.asset_code.write_xdr(w)?; - self.issuer.write_xdr(w)?; + self.n.write_xdr(w)?; Ok(()) }) } } -// AlphaNum12 is an XDR Struct defines as: +// ScSpecTypeUdt is an XDR Struct defines as: // -// struct AlphaNum12 +// struct SCSpecTypeUDT // { -// AssetCode12 assetCode; -// AccountID issuer; +// string name<60>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -4605,51 +5432,71 @@ impl WriteXdr for AlphaNum4 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct AlphaNum12 { - pub asset_code: AssetCode12, - pub issuer: AccountId, +pub struct ScSpecTypeUdt { + pub name: StringM<60>, } -impl ReadXdr for AlphaNum12 { +impl ReadXdr for ScSpecTypeUdt { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - asset_code: AssetCode12::read_xdr(r)?, - issuer: AccountId::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, }) }) } } -impl WriteXdr for AlphaNum12 { +impl WriteXdr for ScSpecTypeUdt { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.asset_code.write_xdr(w)?; - self.issuer.write_xdr(w)?; + self.name.write_xdr(w)?; Ok(()) }) } } -// Asset is an XDR Union defines as: +// ScSpecTypeDef is an XDR Union defines as: // -// union Asset switch (AssetType type) +// union SCSpecTypeDef switch (SCSpecType type) // { -// case ASSET_TYPE_NATIVE: // Not credit +// case SC_SPEC_TYPE_VAL: +// case SC_SPEC_TYPE_BOOL: +// case SC_SPEC_TYPE_VOID: +// case SC_SPEC_TYPE_ERROR: +// case SC_SPEC_TYPE_U32: +// case SC_SPEC_TYPE_I32: +// case SC_SPEC_TYPE_U64: +// case SC_SPEC_TYPE_I64: +// case SC_SPEC_TYPE_TIMEPOINT: +// case SC_SPEC_TYPE_DURATION: +// case SC_SPEC_TYPE_U128: +// case SC_SPEC_TYPE_I128: +// case SC_SPEC_TYPE_U256: +// case SC_SPEC_TYPE_I256: +// case SC_SPEC_TYPE_BYTES: +// case SC_SPEC_TYPE_STRING: +// case SC_SPEC_TYPE_SYMBOL: +// case SC_SPEC_TYPE_ADDRESS: // void; -// -// case ASSET_TYPE_CREDIT_ALPHANUM4: -// AlphaNum4 alphaNum4; -// -// case ASSET_TYPE_CREDIT_ALPHANUM12: -// AlphaNum12 alphaNum12; -// -// // add other asset types here in the future +// case SC_SPEC_TYPE_OPTION: +// SCSpecTypeOption option; +// case SC_SPEC_TYPE_RESULT: +// SCSpecTypeResult result; +// case SC_SPEC_TYPE_VEC: +// SCSpecTypeVec vec; +// case SC_SPEC_TYPE_MAP: +// SCSpecTypeMap map; +// case SC_SPEC_TYPE_TUPLE: +// SCSpecTypeTuple tuple; +// case SC_SPEC_TYPE_BYTES_N: +// SCSpecTypeBytesN bytesN; +// case SC_SPEC_TYPE_UDT: +// SCSpecTypeUDT udt; // }; // -// union with discriminant AssetType +// union with discriminant ScSpecType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -4658,77 +5505,213 @@ impl WriteXdr for AlphaNum12 { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum Asset { - Native, - CreditAlphanum4(AlphaNum4), - CreditAlphanum12(AlphaNum12), -} - -impl Asset { - pub const VARIANTS: [AssetType; 3] = [ - AssetType::Native, - AssetType::CreditAlphanum4, - AssetType::CreditAlphanum12, +pub enum ScSpecTypeDef { + Val, + Bool, + Void, + Error, + U32, + I32, + U64, + I64, + Timepoint, + Duration, + U128, + I128, + U256, + I256, + Bytes, + String, + Symbol, + Address, + Option(Box), + Result(Box), + Vec(Box), + Map(Box), + Tuple(Box), + BytesN(ScSpecTypeBytesN), + Udt(ScSpecTypeUdt), +} + +impl ScSpecTypeDef { + pub const VARIANTS: [ScSpecType; 25] = [ + ScSpecType::Val, + ScSpecType::Bool, + ScSpecType::Void, + ScSpecType::Error, + ScSpecType::U32, + ScSpecType::I32, + ScSpecType::U64, + ScSpecType::I64, + ScSpecType::Timepoint, + ScSpecType::Duration, + ScSpecType::U128, + ScSpecType::I128, + ScSpecType::U256, + ScSpecType::I256, + ScSpecType::Bytes, + ScSpecType::String, + ScSpecType::Symbol, + ScSpecType::Address, + ScSpecType::Option, + ScSpecType::Result, + ScSpecType::Vec, + ScSpecType::Map, + ScSpecType::Tuple, + ScSpecType::BytesN, + ScSpecType::Udt, + ]; + pub const VARIANTS_STR: [&'static str; 25] = [ + "Val", + "Bool", + "Void", + "Error", + "U32", + "I32", + "U64", + "I64", + "Timepoint", + "Duration", + "U128", + "I128", + "U256", + "I256", + "Bytes", + "String", + "Symbol", + "Address", + "Option", + "Result", + "Vec", + "Map", + "Tuple", + "BytesN", + "Udt", ]; - pub const VARIANTS_STR: [&'static str; 3] = ["Native", "CreditAlphanum4", "CreditAlphanum12"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Native => "Native", - Self::CreditAlphanum4(_) => "CreditAlphanum4", - Self::CreditAlphanum12(_) => "CreditAlphanum12", - } - } - - #[must_use] - pub const fn discriminant(&self) -> AssetType { + Self::Val => "Val", + Self::Bool => "Bool", + Self::Void => "Void", + Self::Error => "Error", + Self::U32 => "U32", + Self::I32 => "I32", + Self::U64 => "U64", + Self::I64 => "I64", + Self::Timepoint => "Timepoint", + Self::Duration => "Duration", + Self::U128 => "U128", + Self::I128 => "I128", + Self::U256 => "U256", + Self::I256 => "I256", + Self::Bytes => "Bytes", + Self::String => "String", + Self::Symbol => "Symbol", + Self::Address => "Address", + Self::Option(_) => "Option", + Self::Result(_) => "Result", + Self::Vec(_) => "Vec", + Self::Map(_) => "Map", + Self::Tuple(_) => "Tuple", + Self::BytesN(_) => "BytesN", + Self::Udt(_) => "Udt", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ScSpecType { #[allow(clippy::match_same_arms)] match self { - Self::Native => AssetType::Native, - Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, - Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, - } - } - - #[must_use] - pub const fn variants() -> [AssetType; 3] { + Self::Val => ScSpecType::Val, + Self::Bool => ScSpecType::Bool, + Self::Void => ScSpecType::Void, + Self::Error => ScSpecType::Error, + Self::U32 => ScSpecType::U32, + Self::I32 => ScSpecType::I32, + Self::U64 => ScSpecType::U64, + Self::I64 => ScSpecType::I64, + Self::Timepoint => ScSpecType::Timepoint, + Self::Duration => ScSpecType::Duration, + Self::U128 => ScSpecType::U128, + Self::I128 => ScSpecType::I128, + Self::U256 => ScSpecType::U256, + Self::I256 => ScSpecType::I256, + Self::Bytes => ScSpecType::Bytes, + Self::String => ScSpecType::String, + Self::Symbol => ScSpecType::Symbol, + Self::Address => ScSpecType::Address, + Self::Option(_) => ScSpecType::Option, + Self::Result(_) => ScSpecType::Result, + Self::Vec(_) => ScSpecType::Vec, + Self::Map(_) => ScSpecType::Map, + Self::Tuple(_) => ScSpecType::Tuple, + Self::BytesN(_) => ScSpecType::BytesN, + Self::Udt(_) => ScSpecType::Udt, + } + } + + #[must_use] + pub const fn variants() -> [ScSpecType; 25] { Self::VARIANTS } } -impl Name for Asset { +impl Name for ScSpecTypeDef { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for Asset { +impl Discriminant for ScSpecTypeDef { #[must_use] - fn discriminant(&self) -> AssetType { + fn discriminant(&self) -> ScSpecType { Self::discriminant(self) } } -impl Variants for Asset { - fn variants() -> slice::Iter<'static, AssetType> { +impl Variants for ScSpecTypeDef { + fn variants() -> slice::Iter<'static, ScSpecType> { Self::VARIANTS.iter() } } -impl Union for Asset {} +impl Union for ScSpecTypeDef {} -impl ReadXdr for Asset { +impl ReadXdr for ScSpecTypeDef { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: AssetType = ::read_xdr(r)?; + let dv: ScSpecType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - AssetType::Native => Self::Native, - AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AlphaNum4::read_xdr(r)?), - AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AlphaNum12::read_xdr(r)?), + ScSpecType::Val => Self::Val, + ScSpecType::Bool => Self::Bool, + ScSpecType::Void => Self::Void, + ScSpecType::Error => Self::Error, + ScSpecType::U32 => Self::U32, + ScSpecType::I32 => Self::I32, + ScSpecType::U64 => Self::U64, + ScSpecType::I64 => Self::I64, + ScSpecType::Timepoint => Self::Timepoint, + ScSpecType::Duration => Self::Duration, + ScSpecType::U128 => Self::U128, + ScSpecType::I128 => Self::I128, + ScSpecType::U256 => Self::U256, + ScSpecType::I256 => Self::I256, + ScSpecType::Bytes => Self::Bytes, + ScSpecType::String => Self::String, + ScSpecType::Symbol => Self::Symbol, + ScSpecType::Address => Self::Address, + ScSpecType::Option => Self::Option(Box::::read_xdr(r)?), + ScSpecType::Result => Self::Result(Box::::read_xdr(r)?), + ScSpecType::Vec => Self::Vec(Box::::read_xdr(r)?), + 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::Udt => Self::Udt(ScSpecTypeUdt::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -4737,28 +5720,51 @@ impl ReadXdr for Asset { } } -impl WriteXdr for Asset { +impl WriteXdr for ScSpecTypeDef { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Native => ().write_xdr(w)?, - Self::CreditAlphanum4(v) => v.write_xdr(w)?, - Self::CreditAlphanum12(v) => v.write_xdr(w)?, + Self::Val => ().write_xdr(w)?, + Self::Bool => ().write_xdr(w)?, + Self::Void => ().write_xdr(w)?, + Self::Error => ().write_xdr(w)?, + Self::U32 => ().write_xdr(w)?, + Self::I32 => ().write_xdr(w)?, + Self::U64 => ().write_xdr(w)?, + Self::I64 => ().write_xdr(w)?, + Self::Timepoint => ().write_xdr(w)?, + Self::Duration => ().write_xdr(w)?, + Self::U128 => ().write_xdr(w)?, + Self::I128 => ().write_xdr(w)?, + Self::U256 => ().write_xdr(w)?, + Self::I256 => ().write_xdr(w)?, + Self::Bytes => ().write_xdr(w)?, + Self::String => ().write_xdr(w)?, + Self::Symbol => ().write_xdr(w)?, + Self::Address => ().write_xdr(w)?, + Self::Option(v) => v.write_xdr(w)?, + Self::Result(v) => v.write_xdr(w)?, + Self::Vec(v) => v.write_xdr(w)?, + Self::Map(v) => v.write_xdr(w)?, + Self::Tuple(v) => v.write_xdr(w)?, + Self::BytesN(v) => v.write_xdr(w)?, + Self::Udt(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// Price is an XDR Struct defines as: +// ScSpecUdtStructFieldV0 is an XDR Struct defines as: // -// struct Price +// struct SCSpecUDTStructFieldV0 // { -// int32 n; // numerator -// int32 d; // denominator +// string doc; +// string name<30>; +// SCSpecTypeDef type; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -4768,40 +5774,45 @@ impl WriteXdr for Asset { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct Price { - pub n: i32, - pub d: i32, +pub struct ScSpecUdtStructFieldV0 { + pub doc: StringM<1024>, + pub name: StringM<30>, + pub type_: ScSpecTypeDef, } -impl ReadXdr for Price { +impl ReadXdr for ScSpecUdtStructFieldV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - n: i32::read_xdr(r)?, - d: i32::read_xdr(r)?, + doc: StringM::<1024>::read_xdr(r)?, + name: StringM::<30>::read_xdr(r)?, + type_: ScSpecTypeDef::read_xdr(r)?, }) }) } } -impl WriteXdr for Price { +impl WriteXdr for ScSpecUdtStructFieldV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.n.write_xdr(w)?; - self.d.write_xdr(w)?; + self.doc.write_xdr(w)?; + self.name.write_xdr(w)?; + self.type_.write_xdr(w)?; Ok(()) }) } } -// Liabilities is an XDR Struct defines as: +// ScSpecUdtStructV0 is an XDR Struct defines as: // -// struct Liabilities +// struct SCSpecUDTStructV0 // { -// int64 buying; -// int64 selling; +// string doc; +// string lib<80>; +// string name<60>; +// SCSpecUDTStructFieldV0 fields<40>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -4811,160 +5822,136 @@ impl WriteXdr for Price { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct Liabilities { - pub buying: i64, - pub selling: i64, +pub struct ScSpecUdtStructV0 { + pub doc: StringM<1024>, + pub lib: StringM<80>, + pub name: StringM<60>, + pub fields: VecM, } -impl ReadXdr for Liabilities { +impl ReadXdr for ScSpecUdtStructV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - buying: i64::read_xdr(r)?, - selling: i64::read_xdr(r)?, + doc: StringM::<1024>::read_xdr(r)?, + lib: StringM::<80>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + fields: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for Liabilities { +impl WriteXdr for ScSpecUdtStructV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.buying.write_xdr(w)?; - self.selling.write_xdr(w)?; + self.doc.write_xdr(w)?; + self.lib.write_xdr(w)?; + self.name.write_xdr(w)?; + self.fields.write_xdr(w)?; Ok(()) }) } } -// ThresholdIndexes is an XDR Enum defines as: +// ScSpecUdtUnionCaseVoidV0 is an XDR Struct defines as: // -// enum ThresholdIndexes +// struct SCSpecUDTUnionCaseVoidV0 // { -// THRESHOLD_MASTER_WEIGHT = 0, -// THRESHOLD_LOW = 1, -// THRESHOLD_MED = 2, -// THRESHOLD_HIGH = 3 +// string doc; +// string name<60>; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[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") )] -#[repr(i32)] -pub enum ThresholdIndexes { - MasterWeight = 0, - Low = 1, - Med = 2, - High = 3, +pub struct ScSpecUdtUnionCaseVoidV0 { + pub doc: StringM<1024>, + pub name: StringM<60>, } -impl ThresholdIndexes { - pub const VARIANTS: [ThresholdIndexes; 4] = [ - ThresholdIndexes::MasterWeight, - ThresholdIndexes::Low, - ThresholdIndexes::Med, - ThresholdIndexes::High, - ]; - pub const VARIANTS_STR: [&'static str; 4] = ["MasterWeight", "Low", "Med", "High"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::MasterWeight => "MasterWeight", - Self::Low => "Low", - Self::Med => "Med", - Self::High => "High", - } - } - - #[must_use] - pub const fn variants() -> [ThresholdIndexes; 4] { - Self::VARIANTS +impl ReadXdr for ScSpecUdtUnionCaseVoidV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + doc: StringM::<1024>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + }) + }) } } -impl Name for ThresholdIndexes { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) +impl WriteXdr for ScSpecUdtUnionCaseVoidV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.doc.write_xdr(w)?; + self.name.write_xdr(w)?; + Ok(()) + }) } } -impl Variants for ThresholdIndexes { - fn variants() -> slice::Iter<'static, ThresholdIndexes> { - Self::VARIANTS.iter() - } -} - -impl Enum for ThresholdIndexes {} - -impl fmt::Display for ThresholdIndexes { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) - } -} - -impl TryFrom for ThresholdIndexes { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => ThresholdIndexes::MasterWeight, - 1 => ThresholdIndexes::Low, - 2 => ThresholdIndexes::Med, - 3 => ThresholdIndexes::High, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) - } -} - -impl From for i32 { - #[must_use] - fn from(e: ThresholdIndexes) -> Self { - e as Self - } +// ScSpecUdtUnionCaseTupleV0 is an XDR Struct defines as: +// +// struct SCSpecUDTUnionCaseTupleV0 +// { +// string doc; +// string name<60>; +// SCSpecTypeDef type<12>; +// }; +// +#[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 ScSpecUdtUnionCaseTupleV0 { + pub doc: StringM<1024>, + pub name: StringM<60>, + pub type_: VecM, } -impl ReadXdr for ThresholdIndexes { +impl ReadXdr for ScSpecUdtUnionCaseTupleV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) + Ok(Self { + doc: StringM::<1024>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + type_: VecM::::read_xdr(r)?, + }) }) } } -impl WriteXdr for ThresholdIndexes { +impl WriteXdr for ScSpecUdtUnionCaseTupleV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.doc.write_xdr(w)?; + self.name.write_xdr(w)?; + self.type_.write_xdr(w)?; + Ok(()) }) } } -// LedgerEntryType is an XDR Enum defines as: +// ScSpecUdtUnionCaseV0Kind is an XDR Enum defines as: // -// enum LedgerEntryType +// enum SCSpecUDTUnionCaseV0Kind // { -// ACCOUNT = 0, -// TRUSTLINE = 1, -// OFFER = 2, -// DATA = 3, -// CLAIMABLE_BALANCE = 4, -// LIQUIDITY_POOL = 5 +// SC_SPEC_UDT_UNION_CASE_VOID_V0 = 0, +// SC_SPEC_UDT_UNION_CASE_TUPLE_V0 = 1 // }; // // enum @@ -4976,83 +5963,60 @@ impl WriteXdr for ThresholdIndexes { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum LedgerEntryType { - Account = 0, - Trustline = 1, - Offer = 2, - Data = 3, - ClaimableBalance = 4, - LiquidityPool = 5, +pub enum ScSpecUdtUnionCaseV0Kind { + VoidV0 = 0, + TupleV0 = 1, } -impl LedgerEntryType { - pub const VARIANTS: [LedgerEntryType; 6] = [ - LedgerEntryType::Account, - LedgerEntryType::Trustline, - LedgerEntryType::Offer, - LedgerEntryType::Data, - LedgerEntryType::ClaimableBalance, - LedgerEntryType::LiquidityPool, - ]; - pub const VARIANTS_STR: [&'static str; 6] = [ - "Account", - "Trustline", - "Offer", - "Data", - "ClaimableBalance", - "LiquidityPool", +impl ScSpecUdtUnionCaseV0Kind { + pub const VARIANTS: [ScSpecUdtUnionCaseV0Kind; 2] = [ + ScSpecUdtUnionCaseV0Kind::VoidV0, + ScSpecUdtUnionCaseV0Kind::TupleV0, ]; + pub const VARIANTS_STR: [&'static str; 2] = ["VoidV0", "TupleV0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Account => "Account", - Self::Trustline => "Trustline", - Self::Offer => "Offer", - Self::Data => "Data", - Self::ClaimableBalance => "ClaimableBalance", - Self::LiquidityPool => "LiquidityPool", + Self::VoidV0 => "VoidV0", + Self::TupleV0 => "TupleV0", } } #[must_use] - pub const fn variants() -> [LedgerEntryType; 6] { + pub const fn variants() -> [ScSpecUdtUnionCaseV0Kind; 2] { Self::VARIANTS } } -impl Name for LedgerEntryType { +impl Name for ScSpecUdtUnionCaseV0Kind { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for LedgerEntryType { - fn variants() -> slice::Iter<'static, LedgerEntryType> { +impl Variants for ScSpecUdtUnionCaseV0Kind { + fn variants() -> slice::Iter<'static, ScSpecUdtUnionCaseV0Kind> { Self::VARIANTS.iter() } } -impl Enum for LedgerEntryType {} +impl Enum for ScSpecUdtUnionCaseV0Kind {} -impl fmt::Display for LedgerEntryType { +impl fmt::Display for ScSpecUdtUnionCaseV0Kind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for LedgerEntryType { +impl TryFrom for ScSpecUdtUnionCaseV0Kind { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => LedgerEntryType::Account, - 1 => LedgerEntryType::Trustline, - 2 => LedgerEntryType::Offer, - 3 => LedgerEntryType::Data, - 4 => LedgerEntryType::ClaimableBalance, - 5 => LedgerEntryType::LiquidityPool, + 0 => ScSpecUdtUnionCaseV0Kind::VoidV0, + 1 => ScSpecUdtUnionCaseV0Kind::TupleV0, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -5060,14 +6024,14 @@ impl TryFrom for LedgerEntryType { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: LedgerEntryType) -> Self { + fn from(e: ScSpecUdtUnionCaseV0Kind) -> Self { e as Self } } -impl ReadXdr for LedgerEntryType { +impl ReadXdr for ScSpecUdtUnionCaseV0Kind { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -5078,7 +6042,7 @@ impl ReadXdr for LedgerEntryType { } } -impl WriteXdr for LedgerEntryType { +impl WriteXdr for ScSpecUdtUnionCaseV0Kind { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -5088,14 +6052,17 @@ impl WriteXdr for LedgerEntryType { } } -// Signer is an XDR Struct defines as: +// ScSpecUdtUnionCaseV0 is an XDR Union defines as: // -// struct Signer +// union SCSpecUDTUnionCaseV0 switch (SCSpecUDTUnionCaseV0Kind kind) // { -// SignerKey key; -// uint32 weight; // really only need 1 byte +// case SC_SPEC_UDT_UNION_CASE_VOID_V0: +// SCSpecUDTUnionCaseVoidV0 voidCase; +// case SC_SPEC_UDT_UNION_CASE_TUPLE_V0: +// SCSpecUDTUnionCaseTupleV0 tupleCase; // }; // +// union with discriminant ScSpecUdtUnionCaseV0Kind #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -5103,249 +6070,206 @@ impl WriteXdr for LedgerEntryType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct Signer { - pub key: SignerKey, - pub weight: u32, -} - -impl ReadXdr for Signer { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - key: SignerKey::read_xdr(r)?, - weight: u32::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for Signer { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.key.write_xdr(w)?; - self.weight.write_xdr(w)?; - Ok(()) - }) - } -} - -// AccountFlags is an XDR Enum defines as: -// -// enum AccountFlags -// { // masks for each flag -// -// // Flags set on issuer accounts -// // TrustLines are created with authorized set to "false" requiring -// // the issuer to set it for each TrustLine -// AUTH_REQUIRED_FLAG = 0x1, -// // If set, the authorized flag in TrustLines can be cleared -// // otherwise, authorization cannot be revoked -// AUTH_REVOCABLE_FLAG = 0x2, -// // Once set, causes all AUTH_* flags to be read-only -// AUTH_IMMUTABLE_FLAG = 0x4, -// // Trustlines are created with clawback enabled set to "true", -// // and claimable balances created from those trustlines are created -// // with clawback enabled set to "true" -// AUTH_CLAWBACK_ENABLED_FLAG = 0x8 -// }; -// -// enum -#[derive(Clone, Copy, 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") -)] -#[repr(i32)] -pub enum AccountFlags { - RequiredFlag = 1, - RevocableFlag = 2, - ImmutableFlag = 4, - ClawbackEnabledFlag = 8, +#[allow(clippy::large_enum_variant)] +pub enum ScSpecUdtUnionCaseV0 { + VoidV0(ScSpecUdtUnionCaseVoidV0), + TupleV0(ScSpecUdtUnionCaseTupleV0), } -impl AccountFlags { - pub const VARIANTS: [AccountFlags; 4] = [ - AccountFlags::RequiredFlag, - AccountFlags::RevocableFlag, - AccountFlags::ImmutableFlag, - AccountFlags::ClawbackEnabledFlag, - ]; - pub const VARIANTS_STR: [&'static str; 4] = [ - "RequiredFlag", - "RevocableFlag", - "ImmutableFlag", - "ClawbackEnabledFlag", +impl ScSpecUdtUnionCaseV0 { + pub const VARIANTS: [ScSpecUdtUnionCaseV0Kind; 2] = [ + ScSpecUdtUnionCaseV0Kind::VoidV0, + ScSpecUdtUnionCaseV0Kind::TupleV0, ]; + pub const VARIANTS_STR: [&'static str; 2] = ["VoidV0", "TupleV0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::RequiredFlag => "RequiredFlag", - Self::RevocableFlag => "RevocableFlag", - Self::ImmutableFlag => "ImmutableFlag", - Self::ClawbackEnabledFlag => "ClawbackEnabledFlag", + Self::VoidV0(_) => "VoidV0", + Self::TupleV0(_) => "TupleV0", } } #[must_use] - pub const fn variants() -> [AccountFlags; 4] { + pub const fn discriminant(&self) -> ScSpecUdtUnionCaseV0Kind { + #[allow(clippy::match_same_arms)] + match self { + Self::VoidV0(_) => ScSpecUdtUnionCaseV0Kind::VoidV0, + Self::TupleV0(_) => ScSpecUdtUnionCaseV0Kind::TupleV0, + } + } + + #[must_use] + pub const fn variants() -> [ScSpecUdtUnionCaseV0Kind; 2] { Self::VARIANTS } } -impl Name for AccountFlags { +impl Name for ScSpecUdtUnionCaseV0 { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for AccountFlags { - fn variants() -> slice::Iter<'static, AccountFlags> { - Self::VARIANTS.iter() - } -} - -impl Enum for AccountFlags {} - -impl fmt::Display for AccountFlags { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Discriminant for ScSpecUdtUnionCaseV0 { + #[must_use] + fn discriminant(&self) -> ScSpecUdtUnionCaseV0Kind { + Self::discriminant(self) } } -impl TryFrom for AccountFlags { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 1 => AccountFlags::RequiredFlag, - 2 => AccountFlags::RevocableFlag, - 4 => AccountFlags::ImmutableFlag, - 8 => AccountFlags::ClawbackEnabledFlag, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl Variants for ScSpecUdtUnionCaseV0 { + fn variants() -> slice::Iter<'static, ScSpecUdtUnionCaseV0Kind> { + Self::VARIANTS.iter() } } -impl From for i32 { - #[must_use] - fn from(e: AccountFlags) -> Self { - e as Self - } -} +impl Union for ScSpecUdtUnionCaseV0 {} -impl ReadXdr for AccountFlags { +impl ReadXdr for ScSpecUdtUnionCaseV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; + let dv: ScSpecUdtUnionCaseV0Kind = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ScSpecUdtUnionCaseV0Kind::VoidV0 => { + Self::VoidV0(ScSpecUdtUnionCaseVoidV0::read_xdr(r)?) + } + ScSpecUdtUnionCaseV0Kind::TupleV0 => { + Self::TupleV0(ScSpecUdtUnionCaseTupleV0::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for AccountFlags { +impl WriteXdr for ScSpecUdtUnionCaseV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::VoidV0(v) => v.write_xdr(w)?, + Self::TupleV0(v) => v.write_xdr(w)?, + }; + Ok(()) }) } } -// MaskAccountFlags is an XDR Const defines as: -// -// const MASK_ACCOUNT_FLAGS = 0x7; -// -pub const MASK_ACCOUNT_FLAGS: u64 = 0x7; - -// MaskAccountFlagsV17 is an XDR Const defines as: -// -// const MASK_ACCOUNT_FLAGS_V17 = 0xF; -// -pub const MASK_ACCOUNT_FLAGS_V17: u64 = 0xF; - -// MaxSigners is an XDR Const defines as: -// -// const MAX_SIGNERS = 20; -// -pub const MAX_SIGNERS: u64 = 20; - -// SponsorshipDescriptor is an XDR Typedef defines as: +// ScSpecUdtUnionV0 is an XDR Struct defines as: // -// typedef AccountID* SponsorshipDescriptor; +// struct SCSpecUDTUnionV0 +// { +// string doc; +// string lib<80>; +// string name<60>; +// SCSpecUDTUnionCaseV0 cases<50>; +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SponsorshipDescriptor(pub Option); +pub struct ScSpecUdtUnionV0 { + pub doc: StringM<1024>, + pub lib: StringM<80>, + pub name: StringM<60>, + pub cases: VecM, +} -impl From for Option { - #[must_use] - fn from(x: SponsorshipDescriptor) -> Self { - x.0 +impl ReadXdr for ScSpecUdtUnionV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + doc: StringM::<1024>::read_xdr(r)?, + lib: StringM::<80>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + cases: VecM::::read_xdr(r)?, + }) + }) } } -impl From> for SponsorshipDescriptor { - #[must_use] - fn from(x: Option) -> Self { - SponsorshipDescriptor(x) +impl WriteXdr for ScSpecUdtUnionV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.doc.write_xdr(w)?; + self.lib.write_xdr(w)?; + self.name.write_xdr(w)?; + self.cases.write_xdr(w)?; + Ok(()) + }) } } -impl AsRef> for SponsorshipDescriptor { - #[must_use] - fn as_ref(&self) -> &Option { - &self.0 - } +// ScSpecUdtEnumCaseV0 is an XDR Struct defines as: +// +// struct SCSpecUDTEnumCaseV0 +// { +// string doc; +// string name<60>; +// uint32 value; +// }; +// +#[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 ScSpecUdtEnumCaseV0 { + pub doc: StringM<1024>, + pub name: StringM<60>, + pub value: u32, } -impl ReadXdr for SponsorshipDescriptor { +impl ReadXdr for ScSpecUdtEnumCaseV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = Option::::read_xdr(r)?; - let v = SponsorshipDescriptor(i); - Ok(v) + Ok(Self { + doc: StringM::<1024>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + value: u32::read_xdr(r)?, + }) }) } } -impl WriteXdr for SponsorshipDescriptor { +impl WriteXdr for ScSpecUdtEnumCaseV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + w.with_limited_depth(|w| { + self.doc.write_xdr(w)?; + self.name.write_xdr(w)?; + self.value.write_xdr(w)?; + Ok(()) + }) } } -// AccountEntryExtensionV3 is an XDR Struct defines as: +// ScSpecUdtEnumV0 is an XDR Struct defines as: // -// struct AccountEntryExtensionV3 +// struct SCSpecUDTEnumV0 // { -// // We can use this to add more fields, or because it is first, to -// // change AccountEntryExtensionV3 into a union. -// ExtensionPoint ext; -// -// // Ledger number at which `seqNum` took on its present value. -// uint32 seqLedger; -// -// // Time at which `seqNum` took on its present value. -// TimePoint seqTime; +// string doc; +// string lib<80>; +// string name<60>; +// SCSpecUDTEnumCaseV0 cases<50>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -5355,48 +6279,49 @@ impl WriteXdr for SponsorshipDescriptor { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct AccountEntryExtensionV3 { - pub ext: ExtensionPoint, - pub seq_ledger: u32, - pub seq_time: TimePoint, +pub struct ScSpecUdtEnumV0 { + pub doc: StringM<1024>, + pub lib: StringM<80>, + pub name: StringM<60>, + pub cases: VecM, } -impl ReadXdr for AccountEntryExtensionV3 { +impl ReadXdr for ScSpecUdtEnumV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - ext: ExtensionPoint::read_xdr(r)?, - seq_ledger: u32::read_xdr(r)?, - seq_time: TimePoint::read_xdr(r)?, + doc: StringM::<1024>::read_xdr(r)?, + lib: StringM::<80>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + cases: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for AccountEntryExtensionV3 { +impl WriteXdr for ScSpecUdtEnumV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ext.write_xdr(w)?; - self.seq_ledger.write_xdr(w)?; - self.seq_time.write_xdr(w)?; + self.doc.write_xdr(w)?; + self.lib.write_xdr(w)?; + self.name.write_xdr(w)?; + self.cases.write_xdr(w)?; Ok(()) }) } } -// AccountEntryExtensionV2Ext is an XDR NestedUnion defines as: +// ScSpecUdtErrorEnumCaseV0 is an XDR Struct defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 3: -// AccountEntryExtensionV3 v3; -// } +// struct SCSpecUDTErrorEnumCaseV0 +// { +// string doc; +// string name<60>; +// uint32 value; +// }; // -// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -5404,109 +6329,143 @@ impl WriteXdr for AccountEntryExtensionV3 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum AccountEntryExtensionV2Ext { - V0, - V3(AccountEntryExtensionV3), +pub struct ScSpecUdtErrorEnumCaseV0 { + pub doc: StringM<1024>, + pub name: StringM<60>, + pub value: u32, } -impl AccountEntryExtensionV2Ext { - pub const VARIANTS: [i32; 2] = [0, 3]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V3"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0 => "V0", - Self::V3(_) => "V3", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, - Self::V3(_) => 3, - } +impl ReadXdr for ScSpecUdtErrorEnumCaseV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + doc: StringM::<1024>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + value: u32::read_xdr(r)?, + }) + }) } +} - #[must_use] - pub const fn variants() -> [i32; 2] { - Self::VARIANTS +impl WriteXdr for ScSpecUdtErrorEnumCaseV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.doc.write_xdr(w)?; + self.name.write_xdr(w)?; + self.value.write_xdr(w)?; + Ok(()) + }) } } -impl Name for AccountEntryExtensionV2Ext { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } +// ScSpecUdtErrorEnumV0 is an XDR Struct defines as: +// +// struct SCSpecUDTErrorEnumV0 +// { +// string doc; +// string lib<80>; +// string name<60>; +// SCSpecUDTErrorEnumCaseV0 cases<50>; +// }; +// +#[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 ScSpecUdtErrorEnumV0 { + pub doc: StringM<1024>, + pub lib: StringM<80>, + pub name: StringM<60>, + pub cases: VecM, } -impl Discriminant for AccountEntryExtensionV2Ext { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) +impl ReadXdr for ScSpecUdtErrorEnumV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + doc: StringM::<1024>::read_xdr(r)?, + lib: StringM::<80>::read_xdr(r)?, + name: StringM::<60>::read_xdr(r)?, + cases: VecM::::read_xdr(r)?, + }) + }) } } -impl Variants for AccountEntryExtensionV2Ext { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() +impl WriteXdr for ScSpecUdtErrorEnumV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.doc.write_xdr(w)?; + self.lib.write_xdr(w)?; + self.name.write_xdr(w)?; + self.cases.write_xdr(w)?; + Ok(()) + }) } } -impl Union for AccountEntryExtensionV2Ext {} +// ScSpecFunctionInputV0 is an XDR Struct defines as: +// +// struct SCSpecFunctionInputV0 +// { +// string doc; +// string name<30>; +// SCSpecTypeDef type; +// }; +// +#[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 ScSpecFunctionInputV0 { + pub doc: StringM<1024>, + pub name: StringM<30>, + pub type_: ScSpecTypeDef, +} -impl ReadXdr for AccountEntryExtensionV2Ext { +impl ReadXdr for ScSpecFunctionInputV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - 3 => Self::V3(AccountEntryExtensionV3::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + doc: StringM::<1024>::read_xdr(r)?, + name: StringM::<30>::read_xdr(r)?, + type_: ScSpecTypeDef::read_xdr(r)?, + }) }) } } -impl WriteXdr for AccountEntryExtensionV2Ext { +impl WriteXdr for ScSpecFunctionInputV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - Self::V3(v) => v.write_xdr(w)?, - }; + self.doc.write_xdr(w)?; + self.name.write_xdr(w)?; + self.type_.write_xdr(w)?; Ok(()) }) } } -// AccountEntryExtensionV2 is an XDR Struct defines as: +// ScSpecFunctionV0 is an XDR Struct defines as: // -// struct AccountEntryExtensionV2 +// struct SCSpecFunctionV0 // { -// uint32 numSponsored; -// uint32 numSponsoring; -// SponsorshipDescriptor signerSponsoringIDs; -// -// union switch (int v) -// { -// case 0: -// void; -// case 3: -// AccountEntryExtensionV3 v3; -// } -// ext; +// string doc; +// SCSymbol name; +// SCSpecFunctionInputV0 inputs<10>; +// SCSpecTypeDef outputs<1>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -5516,207 +6475,184 @@ impl WriteXdr for AccountEntryExtensionV2Ext { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct AccountEntryExtensionV2 { - pub num_sponsored: u32, - pub num_sponsoring: u32, - pub signer_sponsoring_i_ds: VecM, - pub ext: AccountEntryExtensionV2Ext, +pub struct ScSpecFunctionV0 { + pub doc: StringM<1024>, + pub name: ScSymbol, + pub inputs: VecM, + pub outputs: VecM, } -impl ReadXdr for AccountEntryExtensionV2 { +impl ReadXdr for ScSpecFunctionV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - num_sponsored: u32::read_xdr(r)?, - num_sponsoring: u32::read_xdr(r)?, - signer_sponsoring_i_ds: VecM::::read_xdr(r)?, - ext: AccountEntryExtensionV2Ext::read_xdr(r)?, + doc: StringM::<1024>::read_xdr(r)?, + name: ScSymbol::read_xdr(r)?, + inputs: VecM::::read_xdr(r)?, + outputs: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for AccountEntryExtensionV2 { +impl WriteXdr for ScSpecFunctionV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.num_sponsored.write_xdr(w)?; - self.num_sponsoring.write_xdr(w)?; - self.signer_sponsoring_i_ds.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.doc.write_xdr(w)?; + self.name.write_xdr(w)?; + self.inputs.write_xdr(w)?; + self.outputs.write_xdr(w)?; Ok(()) }) } } -// AccountEntryExtensionV1Ext is an XDR NestedUnion defines as: +// ScSpecEntryKind is an XDR Enum defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 2: -// AccountEntryExtensionV2 v2; -// } +// enum SCSpecEntryKind +// { +// SC_SPEC_ENTRY_FUNCTION_V0 = 0, +// SC_SPEC_ENTRY_UDT_STRUCT_V0 = 1, +// SC_SPEC_ENTRY_UDT_UNION_V0 = 2, +// SC_SPEC_ENTRY_UDT_ENUM_V0 = 3, +// SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0 = 4 +// }; // -// union with discriminant i32 -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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") )] -#[allow(clippy::large_enum_variant)] -pub enum AccountEntryExtensionV1Ext { - V0, - V2(AccountEntryExtensionV2), -} - -impl AccountEntryExtensionV1Ext { - pub const VARIANTS: [i32; 2] = [0, 2]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V2"]; +#[repr(i32)] +pub enum ScSpecEntryKind { + FunctionV0 = 0, + UdtStructV0 = 1, + UdtUnionV0 = 2, + UdtEnumV0 = 3, + UdtErrorEnumV0 = 4, +} + +impl ScSpecEntryKind { + pub const VARIANTS: [ScSpecEntryKind; 5] = [ + ScSpecEntryKind::FunctionV0, + ScSpecEntryKind::UdtStructV0, + ScSpecEntryKind::UdtUnionV0, + ScSpecEntryKind::UdtEnumV0, + ScSpecEntryKind::UdtErrorEnumV0, + ]; + pub const VARIANTS_STR: [&'static str; 5] = [ + "FunctionV0", + "UdtStructV0", + "UdtUnionV0", + "UdtEnumV0", + "UdtErrorEnumV0", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", - Self::V2(_) => "V2", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, - Self::V2(_) => 2, + Self::FunctionV0 => "FunctionV0", + Self::UdtStructV0 => "UdtStructV0", + Self::UdtUnionV0 => "UdtUnionV0", + Self::UdtEnumV0 => "UdtEnumV0", + Self::UdtErrorEnumV0 => "UdtErrorEnumV0", } } #[must_use] - pub const fn variants() -> [i32; 2] { + pub const fn variants() -> [ScSpecEntryKind; 5] { Self::VARIANTS } } -impl Name for AccountEntryExtensionV1Ext { +impl Name for ScSpecEntryKind { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for AccountEntryExtensionV1Ext { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) - } -} - -impl Variants for AccountEntryExtensionV1Ext { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for ScSpecEntryKind { + fn variants() -> slice::Iter<'static, ScSpecEntryKind> { Self::VARIANTS.iter() } } -impl Union for AccountEntryExtensionV1Ext {} +impl Enum for ScSpecEntryKind {} -impl ReadXdr for AccountEntryExtensionV1Ext { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - 2 => Self::V2(AccountEntryExtensionV2::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) - }) +impl fmt::Display for ScSpecEntryKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl WriteXdr for AccountEntryExtensionV1Ext { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - Self::V2(v) => v.write_xdr(w)?, - }; - Ok(()) - }) +impl TryFrom for ScSpecEntryKind { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ScSpecEntryKind::FunctionV0, + 1 => ScSpecEntryKind::UdtStructV0, + 2 => ScSpecEntryKind::UdtUnionV0, + 3 => ScSpecEntryKind::UdtEnumV0, + 4 => ScSpecEntryKind::UdtErrorEnumV0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -// AccountEntryExtensionV1 is an XDR Struct defines as: -// -// struct AccountEntryExtensionV1 -// { -// Liabilities liabilities; -// -// union switch (int v) -// { -// case 0: -// void; -// case 2: -// AccountEntryExtensionV2 v2; -// } -// ext; -// }; -// -#[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 AccountEntryExtensionV1 { - pub liabilities: Liabilities, - pub ext: AccountEntryExtensionV1Ext, +impl From for i32 { + #[must_use] + fn from(e: ScSpecEntryKind) -> Self { + e as Self + } } -impl ReadXdr for AccountEntryExtensionV1 { +impl ReadXdr for ScSpecEntryKind { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - liabilities: Liabilities::read_xdr(r)?, - ext: AccountEntryExtensionV1Ext::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for AccountEntryExtensionV1 { +impl WriteXdr for ScSpecEntryKind { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.liabilities.write_xdr(w)?; - self.ext.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// AccountEntryExt is an XDR NestedUnion defines as: +// ScSpecEntry is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// AccountEntryExtensionV1 v1; -// } +// union SCSpecEntry switch (SCSpecEntryKind kind) +// { +// case SC_SPEC_ENTRY_FUNCTION_V0: +// SCSpecFunctionV0 functionV0; +// case SC_SPEC_ENTRY_UDT_STRUCT_V0: +// SCSpecUDTStructV0 udtStructV0; +// case SC_SPEC_ENTRY_UDT_UNION_V0: +// SCSpecUDTUnionV0 udtUnionV0; +// case SC_SPEC_ENTRY_UDT_ENUM_V0: +// SCSpecUDTEnumV0 udtEnumV0; +// case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: +// SCSpecUDTErrorEnumV0 udtErrorEnumV0; +// }; // -// union with discriminant i32 +// union with discriminant ScSpecEntryKind #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -5725,69 +6661,95 @@ impl WriteXdr for AccountEntryExtensionV1 { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum AccountEntryExt { - V0, - V1(AccountEntryExtensionV1), -} - -impl AccountEntryExt { - pub const VARIANTS: [i32; 2] = [0, 1]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; +pub enum ScSpecEntry { + FunctionV0(ScSpecFunctionV0), + UdtStructV0(ScSpecUdtStructV0), + UdtUnionV0(ScSpecUdtUnionV0), + UdtEnumV0(ScSpecUdtEnumV0), + UdtErrorEnumV0(ScSpecUdtErrorEnumV0), +} + +impl ScSpecEntry { + pub const VARIANTS: [ScSpecEntryKind; 5] = [ + ScSpecEntryKind::FunctionV0, + ScSpecEntryKind::UdtStructV0, + ScSpecEntryKind::UdtUnionV0, + ScSpecEntryKind::UdtEnumV0, + ScSpecEntryKind::UdtErrorEnumV0, + ]; + pub const VARIANTS_STR: [&'static str; 5] = [ + "FunctionV0", + "UdtStructV0", + "UdtUnionV0", + "UdtEnumV0", + "UdtErrorEnumV0", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", - Self::V1(_) => "V1", + Self::FunctionV0(_) => "FunctionV0", + Self::UdtStructV0(_) => "UdtStructV0", + Self::UdtUnionV0(_) => "UdtUnionV0", + Self::UdtEnumV0(_) => "UdtEnumV0", + Self::UdtErrorEnumV0(_) => "UdtErrorEnumV0", } } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> ScSpecEntryKind { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, - Self::V1(_) => 1, + Self::FunctionV0(_) => ScSpecEntryKind::FunctionV0, + Self::UdtStructV0(_) => ScSpecEntryKind::UdtStructV0, + Self::UdtUnionV0(_) => ScSpecEntryKind::UdtUnionV0, + Self::UdtEnumV0(_) => ScSpecEntryKind::UdtEnumV0, + Self::UdtErrorEnumV0(_) => ScSpecEntryKind::UdtErrorEnumV0, } } #[must_use] - pub const fn variants() -> [i32; 2] { + pub const fn variants() -> [ScSpecEntryKind; 5] { Self::VARIANTS } } -impl Name for AccountEntryExt { +impl Name for ScSpecEntry { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for AccountEntryExt { +impl Discriminant for ScSpecEntry { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> ScSpecEntryKind { Self::discriminant(self) } } -impl Variants for AccountEntryExt { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for ScSpecEntry { + fn variants() -> slice::Iter<'static, ScSpecEntryKind> { Self::VARIANTS.iter() } } -impl Union for AccountEntryExt {} +impl Union for ScSpecEntry {} -impl ReadXdr for AccountEntryExt { +impl ReadXdr for ScSpecEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: ScSpecEntryKind = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, - 1 => Self::V1(AccountEntryExtensionV1::read_xdr(r)?), + ScSpecEntryKind::FunctionV0 => Self::FunctionV0(ScSpecFunctionV0::read_xdr(r)?), + ScSpecEntryKind::UdtStructV0 => Self::UdtStructV0(ScSpecUdtStructV0::read_xdr(r)?), + ScSpecEntryKind::UdtUnionV0 => Self::UdtUnionV0(ScSpecUdtUnionV0::read_xdr(r)?), + ScSpecEntryKind::UdtEnumV0 => Self::UdtEnumV0(ScSpecUdtEnumV0::read_xdr(r)?), + ScSpecEntryKind::UdtErrorEnumV0 => { + Self::UdtErrorEnumV0(ScSpecUdtErrorEnumV0::read_xdr(r)?) + } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -5796,123 +6758,79 @@ impl ReadXdr for AccountEntryExt { } } -impl WriteXdr for AccountEntryExt { +impl WriteXdr for ScSpecEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, + Self::FunctionV0(v) => v.write_xdr(w)?, + Self::UdtStructV0(v) => v.write_xdr(w)?, + Self::UdtUnionV0(v) => v.write_xdr(w)?, + Self::UdtEnumV0(v) => v.write_xdr(w)?, + Self::UdtErrorEnumV0(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// AccountEntry is an XDR Struct defines as: -// -// struct AccountEntry -// { -// AccountID accountID; // master public key for this account -// int64 balance; // in stroops -// SequenceNumber seqNum; // last sequence number used for this account -// uint32 numSubEntries; // number of sub-entries this account has -// // drives the reserve -// AccountID* inflationDest; // Account to vote for during inflation -// uint32 flags; // see AccountFlags -// -// string32 homeDomain; // can be used for reverse federation and memo lookup -// -// // fields used for signatures -// // thresholds stores unsigned bytes: [weight of master|low|medium|high] -// Thresholds thresholds; -// -// Signer signers; // possible signers for this account -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// AccountEntryExtensionV1 v1; -// } -// ext; -// }; -// -#[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 AccountEntry { - pub account_id: AccountId, - pub balance: i64, - pub seq_num: SequenceNumber, - pub num_sub_entries: u32, - pub inflation_dest: Option, - pub flags: u32, - pub home_domain: String32, - pub thresholds: Thresholds, - pub signers: VecM, - pub ext: AccountEntryExt, -} - -impl ReadXdr for AccountEntry { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - account_id: AccountId::read_xdr(r)?, - balance: i64::read_xdr(r)?, - seq_num: SequenceNumber::read_xdr(r)?, - num_sub_entries: u32::read_xdr(r)?, - inflation_dest: Option::::read_xdr(r)?, - flags: u32::read_xdr(r)?, - home_domain: String32::read_xdr(r)?, - thresholds: Thresholds::read_xdr(r)?, - signers: VecM::::read_xdr(r)?, - ext: AccountEntryExt::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for AccountEntry { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.account_id.write_xdr(w)?; - self.balance.write_xdr(w)?; - self.seq_num.write_xdr(w)?; - self.num_sub_entries.write_xdr(w)?; - self.inflation_dest.write_xdr(w)?; - self.flags.write_xdr(w)?; - self.home_domain.write_xdr(w)?; - self.thresholds.write_xdr(w)?; - self.signers.write_xdr(w)?; - self.ext.write_xdr(w)?; - Ok(()) - }) - } -} - -// TrustLineFlags is an XDR Enum defines as: +// ScValType is an XDR Enum defines as: // -// enum TrustLineFlags +// enum SCValType // { -// // issuer has authorized account to perform transactions with its credit -// AUTHORIZED_FLAG = 1, -// // issuer has authorized account to maintain and reduce liabilities for its -// // credit -// AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG = 2, -// // issuer has specified that it may clawback its credit, and that claimable -// // balances created with its credit may also be clawed back -// TRUSTLINE_CLAWBACK_ENABLED_FLAG = 4 +// SCV_BOOL = 0, +// SCV_VOID = 1, +// SCV_ERROR = 2, +// +// // 32 bits is the smallest type in WASM or XDR; no need for u8/u16. +// SCV_U32 = 3, +// SCV_I32 = 4, +// +// // 64 bits is naturally supported by both WASM and XDR also. +// SCV_U64 = 5, +// SCV_I64 = 6, +// +// // Time-related u64 subtypes with their own functions and formatting. +// SCV_TIMEPOINT = 7, +// SCV_DURATION = 8, +// +// // 128 bits is naturally supported by Rust and we use it for Soroban +// // fixed-point arithmetic prices / balances / similar "quantities". These +// // are represented in XDR as a pair of 2 u64s. +// SCV_U128 = 9, +// SCV_I128 = 10, +// +// // 256 bits is the size of sha256 output, ed25519 keys, and the EVM machine +// // word, so for interop use we include this even though it requires a small +// // amount of Rust guest and/or host library code. +// SCV_U256 = 11, +// SCV_I256 = 12, +// +// // Bytes come in 3 flavors, 2 of which have meaningfully different +// // formatting and validity-checking / domain-restriction. +// SCV_BYTES = 13, +// SCV_STRING = 14, +// SCV_SYMBOL = 15, +// +// // Vecs and maps are just polymorphic containers of other ScVals. +// SCV_VEC = 16, +// SCV_MAP = 17, +// +// // Address is the universal identifier for contracts and classic +// // accounts. +// SCV_ADDRESS = 18, +// +// // The following are the internal SCVal variants that are not +// // exposed to the contracts. +// SCV_CONTRACT_INSTANCE = 19, +// +// // SCV_LEDGER_KEY_CONTRACT_INSTANCE and SCV_LEDGER_KEY_NONCE are unique +// // symbolic SCVals used as the key for ledger entries for a contract's +// // instance and an address' nonce, respectively. +// SCV_LEDGER_KEY_CONTRACT_INSTANCE = 20, +// SCV_LEDGER_KEY_NONCE = 21 // }; // // enum @@ -5924,68 +6842,163 @@ impl WriteXdr for AccountEntry { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum TrustLineFlags { - AuthorizedFlag = 1, - AuthorizedToMaintainLiabilitiesFlag = 2, - TrustlineClawbackEnabledFlag = 4, -} - -impl TrustLineFlags { - pub const VARIANTS: [TrustLineFlags; 3] = [ - TrustLineFlags::AuthorizedFlag, - TrustLineFlags::AuthorizedToMaintainLiabilitiesFlag, - TrustLineFlags::TrustlineClawbackEnabledFlag, +pub enum ScValType { + Bool = 0, + Void = 1, + Error = 2, + U32 = 3, + I32 = 4, + U64 = 5, + I64 = 6, + Timepoint = 7, + Duration = 8, + U128 = 9, + I128 = 10, + U256 = 11, + I256 = 12, + Bytes = 13, + String = 14, + Symbol = 15, + Vec = 16, + Map = 17, + Address = 18, + ContractInstance = 19, + LedgerKeyContractInstance = 20, + LedgerKeyNonce = 21, +} + +impl ScValType { + pub const VARIANTS: [ScValType; 22] = [ + ScValType::Bool, + ScValType::Void, + ScValType::Error, + ScValType::U32, + ScValType::I32, + ScValType::U64, + ScValType::I64, + ScValType::Timepoint, + ScValType::Duration, + ScValType::U128, + ScValType::I128, + ScValType::U256, + ScValType::I256, + ScValType::Bytes, + ScValType::String, + ScValType::Symbol, + ScValType::Vec, + ScValType::Map, + ScValType::Address, + ScValType::ContractInstance, + ScValType::LedgerKeyContractInstance, + ScValType::LedgerKeyNonce, ]; - pub const VARIANTS_STR: [&'static str; 3] = [ - "AuthorizedFlag", - "AuthorizedToMaintainLiabilitiesFlag", - "TrustlineClawbackEnabledFlag", + pub const VARIANTS_STR: [&'static str; 22] = [ + "Bool", + "Void", + "Error", + "U32", + "I32", + "U64", + "I64", + "Timepoint", + "Duration", + "U128", + "I128", + "U256", + "I256", + "Bytes", + "String", + "Symbol", + "Vec", + "Map", + "Address", + "ContractInstance", + "LedgerKeyContractInstance", + "LedgerKeyNonce", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::AuthorizedFlag => "AuthorizedFlag", - Self::AuthorizedToMaintainLiabilitiesFlag => "AuthorizedToMaintainLiabilitiesFlag", - Self::TrustlineClawbackEnabledFlag => "TrustlineClawbackEnabledFlag", + Self::Bool => "Bool", + Self::Void => "Void", + Self::Error => "Error", + Self::U32 => "U32", + Self::I32 => "I32", + Self::U64 => "U64", + Self::I64 => "I64", + Self::Timepoint => "Timepoint", + Self::Duration => "Duration", + Self::U128 => "U128", + Self::I128 => "I128", + Self::U256 => "U256", + Self::I256 => "I256", + Self::Bytes => "Bytes", + Self::String => "String", + Self::Symbol => "Symbol", + Self::Vec => "Vec", + Self::Map => "Map", + Self::Address => "Address", + Self::ContractInstance => "ContractInstance", + Self::LedgerKeyContractInstance => "LedgerKeyContractInstance", + Self::LedgerKeyNonce => "LedgerKeyNonce", } } #[must_use] - pub const fn variants() -> [TrustLineFlags; 3] { + pub const fn variants() -> [ScValType; 22] { Self::VARIANTS } } -impl Name for TrustLineFlags { +impl Name for ScValType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for TrustLineFlags { - fn variants() -> slice::Iter<'static, TrustLineFlags> { +impl Variants for ScValType { + fn variants() -> slice::Iter<'static, ScValType> { Self::VARIANTS.iter() } } -impl Enum for TrustLineFlags {} +impl Enum for ScValType {} -impl fmt::Display for TrustLineFlags { +impl fmt::Display for ScValType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for TrustLineFlags { +impl TryFrom for ScValType { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 1 => TrustLineFlags::AuthorizedFlag, - 2 => TrustLineFlags::AuthorizedToMaintainLiabilitiesFlag, - 4 => TrustLineFlags::TrustlineClawbackEnabledFlag, + 0 => ScValType::Bool, + 1 => ScValType::Void, + 2 => ScValType::Error, + 3 => ScValType::U32, + 4 => ScValType::I32, + 5 => ScValType::U64, + 6 => ScValType::I64, + 7 => ScValType::Timepoint, + 8 => ScValType::Duration, + 9 => ScValType::U128, + 10 => ScValType::I128, + 11 => ScValType::U256, + 12 => ScValType::I256, + 13 => ScValType::Bytes, + 14 => ScValType::String, + 15 => ScValType::Symbol, + 16 => ScValType::Vec, + 17 => ScValType::Map, + 18 => ScValType::Address, + 19 => ScValType::ContractInstance, + 20 => ScValType::LedgerKeyContractInstance, + 21 => ScValType::LedgerKeyNonce, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -5993,14 +7006,14 @@ impl TryFrom for TrustLineFlags { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: TrustLineFlags) -> Self { + fn from(e: ScValType) -> Self { e as Self } } -impl ReadXdr for TrustLineFlags { +impl ReadXdr for ScValType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -6011,7 +7024,7 @@ impl ReadXdr for TrustLineFlags { } } -impl WriteXdr for TrustLineFlags { +impl WriteXdr for ScValType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -6021,29 +7034,20 @@ impl WriteXdr for TrustLineFlags { } } -// MaskTrustlineFlags is an XDR Const defines as: -// -// const MASK_TRUSTLINE_FLAGS = 1; -// -pub const MASK_TRUSTLINE_FLAGS: u64 = 1; - -// MaskTrustlineFlagsV13 is an XDR Const defines as: -// -// const MASK_TRUSTLINE_FLAGS_V13 = 3; -// -pub const MASK_TRUSTLINE_FLAGS_V13: u64 = 3; - -// MaskTrustlineFlagsV17 is an XDR Const defines as: -// -// const MASK_TRUSTLINE_FLAGS_V17 = 7; -// -pub const MASK_TRUSTLINE_FLAGS_V17: u64 = 7; - -// LiquidityPoolType is an XDR Enum defines as: +// ScErrorType is an XDR Enum defines as: // -// enum LiquidityPoolType +// enum SCErrorType // { -// LIQUIDITY_POOL_CONSTANT_PRODUCT = 0 +// SCE_CONTRACT = 0, // Contract-specific, user-defined codes. +// SCE_WASM_VM = 1, // Errors while interpreting WASM bytecode. +// SCE_CONTEXT = 2, // Errors in the contract's host context. +// SCE_STORAGE = 3, // Errors accessing host storage. +// SCE_OBJECT = 4, // Errors working with host objects. +// SCE_CRYPTO = 5, // Errors in cryptographic operations. +// SCE_EVENTS = 6, // Errors while emitting events. +// SCE_BUDGET = 7, // Errors relating to budget limits. +// SCE_VALUE = 8, // Errors working with host values or SCVals. +// SCE_AUTH = 9 // Errors from the authentication subsystem. // }; // // enum @@ -6055,54 +7059,95 @@ pub const MASK_TRUSTLINE_FLAGS_V17: u64 = 7; serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum LiquidityPoolType { - LiquidityPoolConstantProduct = 0, -} - -impl LiquidityPoolType { - pub const VARIANTS: [LiquidityPoolType; 1] = [LiquidityPoolType::LiquidityPoolConstantProduct]; - pub const VARIANTS_STR: [&'static str; 1] = ["LiquidityPoolConstantProduct"]; +pub enum ScErrorType { + Contract = 0, + WasmVm = 1, + Context = 2, + Storage = 3, + Object = 4, + Crypto = 5, + Events = 6, + Budget = 7, + Value = 8, + Auth = 9, +} + +impl ScErrorType { + pub const VARIANTS: [ScErrorType; 10] = [ + ScErrorType::Contract, + ScErrorType::WasmVm, + ScErrorType::Context, + ScErrorType::Storage, + ScErrorType::Object, + ScErrorType::Crypto, + ScErrorType::Events, + ScErrorType::Budget, + ScErrorType::Value, + ScErrorType::Auth, + ]; + pub const VARIANTS_STR: [&'static str; 10] = [ + "Contract", "WasmVm", "Context", "Storage", "Object", "Crypto", "Events", "Budget", + "Value", "Auth", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::LiquidityPoolConstantProduct => "LiquidityPoolConstantProduct", + Self::Contract => "Contract", + Self::WasmVm => "WasmVm", + Self::Context => "Context", + Self::Storage => "Storage", + Self::Object => "Object", + Self::Crypto => "Crypto", + Self::Events => "Events", + Self::Budget => "Budget", + Self::Value => "Value", + Self::Auth => "Auth", } } #[must_use] - pub const fn variants() -> [LiquidityPoolType; 1] { + pub const fn variants() -> [ScErrorType; 10] { Self::VARIANTS } } -impl Name for LiquidityPoolType { +impl Name for ScErrorType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for LiquidityPoolType { - fn variants() -> slice::Iter<'static, LiquidityPoolType> { +impl Variants for ScErrorType { + fn variants() -> slice::Iter<'static, ScErrorType> { Self::VARIANTS.iter() } } -impl Enum for LiquidityPoolType {} +impl Enum for ScErrorType {} -impl fmt::Display for LiquidityPoolType { +impl fmt::Display for ScErrorType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for LiquidityPoolType { +impl TryFrom for ScErrorType { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => LiquidityPoolType::LiquidityPoolConstantProduct, + 0 => ScErrorType::Contract, + 1 => ScErrorType::WasmVm, + 2 => ScErrorType::Context, + 3 => ScErrorType::Storage, + 4 => ScErrorType::Object, + 5 => ScErrorType::Crypto, + 6 => ScErrorType::Events, + 7 => ScErrorType::Budget, + 8 => ScErrorType::Value, + 9 => ScErrorType::Auth, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -6110,14 +7155,14 @@ impl TryFrom for LiquidityPoolType { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: LiquidityPoolType) -> Self { + fn from(e: ScErrorType) -> Self { e as Self } } -impl ReadXdr for LiquidityPoolType { +impl ReadXdr for ScErrorType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -6128,7 +7173,7 @@ impl ReadXdr for LiquidityPoolType { } } -impl WriteXdr for LiquidityPoolType { +impl WriteXdr for ScErrorType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -6138,145 +7183,182 @@ impl WriteXdr for LiquidityPoolType { } } -// TrustLineAsset is an XDR Union defines as: +// ScErrorCode is an XDR Enum defines as: // -// union TrustLineAsset switch (AssetType type) +// enum SCErrorCode // { -// case ASSET_TYPE_NATIVE: // Not credit -// void; -// -// case ASSET_TYPE_CREDIT_ALPHANUM4: -// AlphaNum4 alphaNum4; -// -// case ASSET_TYPE_CREDIT_ALPHANUM12: -// AlphaNum12 alphaNum12; -// -// case ASSET_TYPE_POOL_SHARE: -// PoolID liquidityPoolID; -// -// // add other asset types here in the future +// SCEC_ARITH_DOMAIN = 0, // Some arithmetic was undefined (overflow, divide-by-zero). +// SCEC_INDEX_BOUNDS = 1, // Something was indexed beyond its bounds. +// SCEC_INVALID_INPUT = 2, // User provided some otherwise-bad data. +// SCEC_MISSING_VALUE = 3, // Some value was required but not provided. +// SCEC_EXISTING_VALUE = 4, // Some value was provided where not allowed. +// SCEC_EXCEEDED_LIMIT = 5, // Some arbitrary limit -- gas or otherwise -- was hit. +// SCEC_INVALID_ACTION = 6, // Data was valid but action requested was not. +// SCEC_INTERNAL_ERROR = 7, // The host detected an error in its own logic. +// SCEC_UNEXPECTED_TYPE = 8, // Some type wasn't as expected. +// SCEC_UNEXPECTED_SIZE = 9 // Something's size wasn't as expected. // }; // -// union with discriminant AssetType -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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") )] -#[allow(clippy::large_enum_variant)] -pub enum TrustLineAsset { - Native, - CreditAlphanum4(AlphaNum4), - CreditAlphanum12(AlphaNum12), - PoolShare(PoolId), -} - -impl TrustLineAsset { - pub const VARIANTS: [AssetType; 4] = [ - AssetType::Native, - AssetType::CreditAlphanum4, - AssetType::CreditAlphanum12, - AssetType::PoolShare, +#[repr(i32)] +pub enum ScErrorCode { + ArithDomain = 0, + IndexBounds = 1, + InvalidInput = 2, + MissingValue = 3, + ExistingValue = 4, + ExceededLimit = 5, + InvalidAction = 6, + InternalError = 7, + UnexpectedType = 8, + UnexpectedSize = 9, +} + +impl ScErrorCode { + pub const VARIANTS: [ScErrorCode; 10] = [ + ScErrorCode::ArithDomain, + ScErrorCode::IndexBounds, + ScErrorCode::InvalidInput, + ScErrorCode::MissingValue, + ScErrorCode::ExistingValue, + ScErrorCode::ExceededLimit, + ScErrorCode::InvalidAction, + ScErrorCode::InternalError, + ScErrorCode::UnexpectedType, + ScErrorCode::UnexpectedSize, + ]; + pub const VARIANTS_STR: [&'static str; 10] = [ + "ArithDomain", + "IndexBounds", + "InvalidInput", + "MissingValue", + "ExistingValue", + "ExceededLimit", + "InvalidAction", + "InternalError", + "UnexpectedType", + "UnexpectedSize", ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Native", "CreditAlphanum4", "CreditAlphanum12", "PoolShare"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Native => "Native", - Self::CreditAlphanum4(_) => "CreditAlphanum4", - Self::CreditAlphanum12(_) => "CreditAlphanum12", - Self::PoolShare(_) => "PoolShare", - } - } - - #[must_use] - pub const fn discriminant(&self) -> AssetType { - #[allow(clippy::match_same_arms)] - match self { - Self::Native => AssetType::Native, - Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, - Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, - Self::PoolShare(_) => AssetType::PoolShare, + Self::ArithDomain => "ArithDomain", + Self::IndexBounds => "IndexBounds", + Self::InvalidInput => "InvalidInput", + Self::MissingValue => "MissingValue", + Self::ExistingValue => "ExistingValue", + Self::ExceededLimit => "ExceededLimit", + Self::InvalidAction => "InvalidAction", + Self::InternalError => "InternalError", + Self::UnexpectedType => "UnexpectedType", + Self::UnexpectedSize => "UnexpectedSize", } } #[must_use] - pub const fn variants() -> [AssetType; 4] { + pub const fn variants() -> [ScErrorCode; 10] { Self::VARIANTS } } -impl Name for TrustLineAsset { +impl Name for ScErrorCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for TrustLineAsset { - #[must_use] - fn discriminant(&self) -> AssetType { - Self::discriminant(self) +impl Variants for ScErrorCode { + fn variants() -> slice::Iter<'static, ScErrorCode> { + Self::VARIANTS.iter() } } -impl Variants for TrustLineAsset { - fn variants() -> slice::Iter<'static, AssetType> { - Self::VARIANTS.iter() +impl Enum for ScErrorCode {} + +impl fmt::Display for ScErrorCode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl Union for TrustLineAsset {} +impl TryFrom for ScErrorCode { + type Error = Error; -impl ReadXdr for TrustLineAsset { + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ScErrorCode::ArithDomain, + 1 => ScErrorCode::IndexBounds, + 2 => ScErrorCode::InvalidInput, + 3 => ScErrorCode::MissingValue, + 4 => ScErrorCode::ExistingValue, + 5 => ScErrorCode::ExceededLimit, + 6 => ScErrorCode::InvalidAction, + 7 => ScErrorCode::InternalError, + 8 => ScErrorCode::UnexpectedType, + 9 => ScErrorCode::UnexpectedSize, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ScErrorCode) -> Self { + e as Self + } +} + +impl ReadXdr for ScErrorCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: AssetType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - AssetType::Native => Self::Native, - AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AlphaNum4::read_xdr(r)?), - AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AlphaNum12::read_xdr(r)?), - AssetType::PoolShare => Self::PoolShare(PoolId::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; Ok(v) }) } } -impl WriteXdr for TrustLineAsset { +impl WriteXdr for ScErrorCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::Native => ().write_xdr(w)?, - Self::CreditAlphanum4(v) => v.write_xdr(w)?, - Self::CreditAlphanum12(v) => v.write_xdr(w)?, - Self::PoolShare(v) => v.write_xdr(w)?, - }; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// TrustLineEntryExtensionV2Ext is an XDR NestedUnion defines as: +// ScError is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// union SCError switch (SCErrorType type) +// { +// case SCE_CONTRACT: +// uint32 contractCode; +// case SCE_WASM_VM: +// case SCE_CONTEXT: +// case SCE_STORAGE: +// case SCE_OBJECT: +// case SCE_CRYPTO: +// case SCE_EVENTS: +// case SCE_BUDGET: +// case SCE_VALUE: +// case SCE_AUTH: +// SCErrorCode code; +// }; // -// union with discriminant i32 +// union with discriminant ScErrorType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -6285,65 +7367,115 @@ impl WriteXdr for TrustLineAsset { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum TrustLineEntryExtensionV2Ext { - V0, -} - -impl TrustLineEntryExtensionV2Ext { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +pub enum ScError { + Contract(u32), + WasmVm(ScErrorCode), + Context(ScErrorCode), + Storage(ScErrorCode), + Object(ScErrorCode), + Crypto(ScErrorCode), + Events(ScErrorCode), + Budget(ScErrorCode), + Value(ScErrorCode), + Auth(ScErrorCode), +} + +impl ScError { + pub const VARIANTS: [ScErrorType; 10] = [ + ScErrorType::Contract, + ScErrorType::WasmVm, + ScErrorType::Context, + ScErrorType::Storage, + ScErrorType::Object, + ScErrorType::Crypto, + ScErrorType::Events, + ScErrorType::Budget, + ScErrorType::Value, + ScErrorType::Auth, + ]; + pub const VARIANTS_STR: [&'static str; 10] = [ + "Contract", "WasmVm", "Context", "Storage", "Object", "Crypto", "Events", "Budget", + "Value", "Auth", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::Contract(_) => "Contract", + Self::WasmVm(_) => "WasmVm", + Self::Context(_) => "Context", + Self::Storage(_) => "Storage", + Self::Object(_) => "Object", + Self::Crypto(_) => "Crypto", + Self::Events(_) => "Events", + Self::Budget(_) => "Budget", + Self::Value(_) => "Value", + Self::Auth(_) => "Auth", } } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> ScErrorType { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::Contract(_) => ScErrorType::Contract, + Self::WasmVm(_) => ScErrorType::WasmVm, + Self::Context(_) => ScErrorType::Context, + Self::Storage(_) => ScErrorType::Storage, + Self::Object(_) => ScErrorType::Object, + Self::Crypto(_) => ScErrorType::Crypto, + Self::Events(_) => ScErrorType::Events, + Self::Budget(_) => ScErrorType::Budget, + Self::Value(_) => ScErrorType::Value, + Self::Auth(_) => ScErrorType::Auth, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [ScErrorType; 10] { Self::VARIANTS } } -impl Name for TrustLineEntryExtensionV2Ext { +impl Name for ScError { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for TrustLineEntryExtensionV2Ext { +impl Discriminant for ScError { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> ScErrorType { Self::discriminant(self) } } -impl Variants for TrustLineEntryExtensionV2Ext { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for ScError { + fn variants() -> slice::Iter<'static, ScErrorType> { Self::VARIANTS.iter() } } -impl Union for TrustLineEntryExtensionV2Ext {} +impl Union for ScError {} -impl ReadXdr for TrustLineEntryExtensionV2Ext { +impl ReadXdr for ScError { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: ScErrorType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, + ScErrorType::Contract => Self::Contract(u32::read_xdr(r)?), + ScErrorType::WasmVm => Self::WasmVm(ScErrorCode::read_xdr(r)?), + ScErrorType::Context => Self::Context(ScErrorCode::read_xdr(r)?), + ScErrorType::Storage => Self::Storage(ScErrorCode::read_xdr(r)?), + ScErrorType::Object => Self::Object(ScErrorCode::read_xdr(r)?), + ScErrorType::Crypto => Self::Crypto(ScErrorCode::read_xdr(r)?), + ScErrorType::Events => Self::Events(ScErrorCode::read_xdr(r)?), + ScErrorType::Budget => Self::Budget(ScErrorCode::read_xdr(r)?), + ScErrorType::Value => Self::Value(ScErrorCode::read_xdr(r)?), + ScErrorType::Auth => Self::Auth(ScErrorCode::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -6352,32 +7484,34 @@ impl ReadXdr for TrustLineEntryExtensionV2Ext { } } -impl WriteXdr for TrustLineEntryExtensionV2Ext { +impl WriteXdr for ScError { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::Contract(v) => v.write_xdr(w)?, + Self::WasmVm(v) => v.write_xdr(w)?, + Self::Context(v) => v.write_xdr(w)?, + Self::Storage(v) => v.write_xdr(w)?, + Self::Object(v) => v.write_xdr(w)?, + Self::Crypto(v) => v.write_xdr(w)?, + Self::Events(v) => v.write_xdr(w)?, + Self::Budget(v) => v.write_xdr(w)?, + Self::Value(v) => v.write_xdr(w)?, + Self::Auth(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// TrustLineEntryExtensionV2 is an XDR Struct defines as: +// UInt128Parts is an XDR Struct defines as: // -// struct TrustLineEntryExtensionV2 -// { -// int32 liquidityPoolUseCount; -// -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// struct UInt128Parts { +// uint64 hi; +// uint64 lo; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -6387,45 +7521,41 @@ impl WriteXdr for TrustLineEntryExtensionV2Ext { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TrustLineEntryExtensionV2 { - pub liquidity_pool_use_count: i32, - pub ext: TrustLineEntryExtensionV2Ext, +pub struct UInt128Parts { + pub hi: u64, + pub lo: u64, } -impl ReadXdr for TrustLineEntryExtensionV2 { +impl ReadXdr for UInt128Parts { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - liquidity_pool_use_count: i32::read_xdr(r)?, - ext: TrustLineEntryExtensionV2Ext::read_xdr(r)?, + hi: u64::read_xdr(r)?, + lo: u64::read_xdr(r)?, }) }) } } -impl WriteXdr for TrustLineEntryExtensionV2 { +impl WriteXdr for UInt128Parts { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.liquidity_pool_use_count.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.hi.write_xdr(w)?; + self.lo.write_xdr(w)?; Ok(()) }) } } -// TrustLineEntryV1Ext is an XDR NestedUnion defines as: +// Int128Parts is an XDR Struct defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 2: -// TrustLineEntryExtensionV2 v2; -// } +// struct Int128Parts { +// int64 hi; +// uint64 lo; +// }; // -// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -6433,167 +7563,43 @@ impl WriteXdr for TrustLineEntryExtensionV2 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum TrustLineEntryV1Ext { - V0, - V2(TrustLineEntryExtensionV2), +pub struct Int128Parts { + pub hi: i64, + pub lo: u64, } -impl TrustLineEntryV1Ext { - pub const VARIANTS: [i32; 2] = [0, 2]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V2"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0 => "V0", - Self::V2(_) => "V2", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, - Self::V2(_) => 2, - } - } - - #[must_use] - pub const fn variants() -> [i32; 2] { - Self::VARIANTS - } -} - -impl Name for TrustLineEntryV1Ext { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Discriminant for TrustLineEntryV1Ext { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) - } -} - -impl Variants for TrustLineEntryV1Ext { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() - } -} - -impl Union for TrustLineEntryV1Ext {} - -impl ReadXdr for TrustLineEntryV1Ext { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - 2 => Self::V2(TrustLineEntryExtensionV2::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) - }) - } -} - -impl WriteXdr for TrustLineEntryV1Ext { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - Self::V2(v) => v.write_xdr(w)?, - }; - Ok(()) - }) - } -} - -// TrustLineEntryV1 is an XDR NestedStruct defines as: -// -// struct -// { -// Liabilities liabilities; -// -// union switch (int v) -// { -// case 0: -// void; -// case 2: -// TrustLineEntryExtensionV2 v2; -// } -// ext; -// } -// -#[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 TrustLineEntryV1 { - pub liabilities: Liabilities, - pub ext: TrustLineEntryV1Ext, -} - -impl ReadXdr for TrustLineEntryV1 { +impl ReadXdr for Int128Parts { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - liabilities: Liabilities::read_xdr(r)?, - ext: TrustLineEntryV1Ext::read_xdr(r)?, + hi: i64::read_xdr(r)?, + lo: u64::read_xdr(r)?, }) }) } } -impl WriteXdr for TrustLineEntryV1 { +impl WriteXdr for Int128Parts { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.liabilities.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.hi.write_xdr(w)?; + self.lo.write_xdr(w)?; Ok(()) }) } } -// TrustLineEntryExt is an XDR NestedUnion defines as: -// -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// struct -// { -// Liabilities liabilities; +// UInt256Parts is an XDR Struct defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 2: -// TrustLineEntryExtensionV2 v2; -// } -// ext; -// } v1; -// } +// struct UInt256Parts { +// uint64 hi_hi; +// uint64 hi_lo; +// uint64 lo_hi; +// uint64 lo_lo; +// }; // -// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -6601,126 +7607,47 @@ impl WriteXdr for TrustLineEntryV1 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum TrustLineEntryExt { - V0, - V1(TrustLineEntryV1), -} - -impl TrustLineEntryExt { - pub const VARIANTS: [i32; 2] = [0, 1]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0 => "V0", - Self::V1(_) => "V1", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, - Self::V1(_) => 1, - } - } - - #[must_use] - pub const fn variants() -> [i32; 2] { - Self::VARIANTS - } -} - -impl Name for TrustLineEntryExt { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Discriminant for TrustLineEntryExt { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) - } -} - -impl Variants for TrustLineEntryExt { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() - } +pub struct UInt256Parts { + pub hi_hi: u64, + pub hi_lo: u64, + pub lo_hi: u64, + pub lo_lo: u64, } -impl Union for TrustLineEntryExt {} - -impl ReadXdr for TrustLineEntryExt { +impl ReadXdr for UInt256Parts { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - 1 => Self::V1(TrustLineEntryV1::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + hi_hi: u64::read_xdr(r)?, + hi_lo: u64::read_xdr(r)?, + lo_hi: u64::read_xdr(r)?, + lo_lo: u64::read_xdr(r)?, + }) }) } } -impl WriteXdr for TrustLineEntryExt { +impl WriteXdr for UInt256Parts { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, - }; + self.hi_hi.write_xdr(w)?; + self.hi_lo.write_xdr(w)?; + self.lo_hi.write_xdr(w)?; + self.lo_lo.write_xdr(w)?; Ok(()) }) } } -// TrustLineEntry is an XDR Struct defines as: -// -// struct TrustLineEntry -// { -// AccountID accountID; // account this trustline belongs to -// TrustLineAsset asset; // type of asset (with issuer) -// int64 balance; // how much of this asset the user has. -// // Asset defines the unit for this; -// -// int64 limit; // balance cannot be above this -// uint32 flags; // see TrustLineFlags -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// struct -// { -// Liabilities liabilities; +// Int256Parts is an XDR Struct defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 2: -// TrustLineEntryExtensionV2 v2; -// } -// ext; -// } v1; -// } -// ext; +// struct Int256Parts { +// int64 hi_hi; +// uint64 hi_lo; +// uint64 lo_hi; +// uint64 lo_lo; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -6730,53 +7657,46 @@ impl WriteXdr for TrustLineEntryExt { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TrustLineEntry { - pub account_id: AccountId, - pub asset: TrustLineAsset, - pub balance: i64, - pub limit: i64, - pub flags: u32, - pub ext: TrustLineEntryExt, +pub struct Int256Parts { + pub hi_hi: i64, + pub hi_lo: u64, + pub lo_hi: u64, + pub lo_lo: u64, } -impl ReadXdr for TrustLineEntry { +impl ReadXdr for Int256Parts { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - account_id: AccountId::read_xdr(r)?, - asset: TrustLineAsset::read_xdr(r)?, - balance: i64::read_xdr(r)?, - limit: i64::read_xdr(r)?, - flags: u32::read_xdr(r)?, - ext: TrustLineEntryExt::read_xdr(r)?, + hi_hi: i64::read_xdr(r)?, + hi_lo: u64::read_xdr(r)?, + lo_hi: u64::read_xdr(r)?, + lo_lo: u64::read_xdr(r)?, }) }) } } -impl WriteXdr for TrustLineEntry { +impl WriteXdr for Int256Parts { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.account_id.write_xdr(w)?; - self.asset.write_xdr(w)?; - self.balance.write_xdr(w)?; - self.limit.write_xdr(w)?; - self.flags.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.hi_hi.write_xdr(w)?; + self.hi_lo.write_xdr(w)?; + self.lo_hi.write_xdr(w)?; + self.lo_lo.write_xdr(w)?; Ok(()) }) } } -// OfferEntryFlags is an XDR Enum defines as: +// ContractExecutableType is an XDR Enum defines as: // -// enum OfferEntryFlags +// enum ContractExecutableType // { -// // an offer with this flag will not act on and take a reverse offer of equal -// // price -// PASSIVE_FLAG = 1 +// CONTRACT_EXECUTABLE_WASM = 0, +// CONTRACT_EXECUTABLE_TOKEN = 1 // }; // // enum @@ -6788,54 +7708,58 @@ impl WriteXdr for TrustLineEntry { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum OfferEntryFlags { - PassiveFlag = 1, +pub enum ContractExecutableType { + Wasm = 0, + Token = 1, } -impl OfferEntryFlags { - pub const VARIANTS: [OfferEntryFlags; 1] = [OfferEntryFlags::PassiveFlag]; - pub const VARIANTS_STR: [&'static str; 1] = ["PassiveFlag"]; +impl ContractExecutableType { + pub const VARIANTS: [ContractExecutableType; 2] = + [ContractExecutableType::Wasm, ContractExecutableType::Token]; + pub const VARIANTS_STR: [&'static str; 2] = ["Wasm", "Token"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::PassiveFlag => "PassiveFlag", + Self::Wasm => "Wasm", + Self::Token => "Token", } } #[must_use] - pub const fn variants() -> [OfferEntryFlags; 1] { + pub const fn variants() -> [ContractExecutableType; 2] { Self::VARIANTS } } -impl Name for OfferEntryFlags { +impl Name for ContractExecutableType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for OfferEntryFlags { - fn variants() -> slice::Iter<'static, OfferEntryFlags> { +impl Variants for ContractExecutableType { + fn variants() -> slice::Iter<'static, ContractExecutableType> { Self::VARIANTS.iter() } } -impl Enum for OfferEntryFlags {} +impl Enum for ContractExecutableType {} -impl fmt::Display for OfferEntryFlags { +impl fmt::Display for ContractExecutableType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for OfferEntryFlags { +impl TryFrom for ContractExecutableType { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 1 => OfferEntryFlags::PassiveFlag, + 0 => ContractExecutableType::Wasm, + 1 => ContractExecutableType::Token, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -6843,14 +7767,14 @@ impl TryFrom for OfferEntryFlags { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: OfferEntryFlags) -> Self { + fn from(e: ContractExecutableType) -> Self { e as Self } } -impl ReadXdr for OfferEntryFlags { +impl ReadXdr for ContractExecutableType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -6861,7 +7785,7 @@ impl ReadXdr for OfferEntryFlags { } } -impl WriteXdr for OfferEntryFlags { +impl WriteXdr for ContractExecutableType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -6871,21 +7795,17 @@ impl WriteXdr for OfferEntryFlags { } } -// MaskOfferentryFlags is an XDR Const defines as: -// -// const MASK_OFFERENTRY_FLAGS = 1; -// -pub const MASK_OFFERENTRY_FLAGS: u64 = 1; - -// OfferEntryExt is an XDR NestedUnion defines as: +// ContractExecutable is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// union ContractExecutable switch (ContractExecutableType type) +// { +// case CONTRACT_EXECUTABLE_WASM: +// Hash wasm_hash; +// case CONTRACT_EXECUTABLE_TOKEN: +// void; +// }; // -// union with discriminant i32 +// union with discriminant ContractExecutableType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -6894,65 +7814,70 @@ pub const MASK_OFFERENTRY_FLAGS: u64 = 1; serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum OfferEntryExt { - V0, +pub enum ContractExecutable { + Wasm(Hash), + Token, } -impl OfferEntryExt { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl ContractExecutable { + pub const VARIANTS: [ContractExecutableType; 2] = + [ContractExecutableType::Wasm, ContractExecutableType::Token]; + pub const VARIANTS_STR: [&'static str; 2] = ["Wasm", "Token"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::Wasm(_) => "Wasm", + Self::Token => "Token", } } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> ContractExecutableType { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::Wasm(_) => ContractExecutableType::Wasm, + Self::Token => ContractExecutableType::Token, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [ContractExecutableType; 2] { Self::VARIANTS } } -impl Name for OfferEntryExt { +impl Name for ContractExecutable { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for OfferEntryExt { +impl Discriminant for ContractExecutable { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> ContractExecutableType { Self::discriminant(self) } } -impl Variants for OfferEntryExt { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for ContractExecutable { + fn variants() -> slice::Iter<'static, ContractExecutableType> { Self::VARIANTS.iter() } } -impl Union for OfferEntryExt {} +impl Union for ContractExecutable {} -impl ReadXdr for OfferEntryExt { +impl ReadXdr for ContractExecutable { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: ContractExecutableType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, + ContractExecutableType::Wasm => Self::Wasm(Hash::read_xdr(r)?), + ContractExecutableType::Token => Self::Token, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -6961,109 +7886,135 @@ impl ReadXdr for OfferEntryExt { } } -impl WriteXdr for OfferEntryExt { +impl WriteXdr for ContractExecutable { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::Wasm(v) => v.write_xdr(w)?, + Self::Token => ().write_xdr(w)?, }; Ok(()) }) } } -// OfferEntry is an XDR Struct defines as: +// ScAddressType is an XDR Enum defines as: // -// struct OfferEntry +// enum SCAddressType // { -// AccountID sellerID; -// int64 offerID; -// Asset selling; // A -// Asset buying; // B -// int64 amount; // amount of A -// -// /* price for this offer: -// price of A in terms of B -// price=AmountB/AmountA=priceNumerator/priceDenominator -// price is after fees -// */ -// Price price; -// uint32 flags; // see OfferEntryFlags -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// SC_ADDRESS_TYPE_ACCOUNT = 0, +// SC_ADDRESS_TYPE_CONTRACT = 1 // }; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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 OfferEntry { - pub seller_id: AccountId, - pub offer_id: i64, - pub selling: Asset, - pub buying: Asset, - pub amount: i64, - pub price: Price, - pub flags: u32, - pub ext: OfferEntryExt, +#[repr(i32)] +pub enum ScAddressType { + Account = 0, + Contract = 1, } -impl ReadXdr for OfferEntry { +impl ScAddressType { + pub const VARIANTS: [ScAddressType; 2] = [ScAddressType::Account, ScAddressType::Contract]; + pub const VARIANTS_STR: [&'static str; 2] = ["Account", "Contract"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Account => "Account", + Self::Contract => "Contract", + } + } + + #[must_use] + pub const fn variants() -> [ScAddressType; 2] { + Self::VARIANTS + } +} + +impl Name for ScAddressType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ScAddressType { + fn variants() -> slice::Iter<'static, ScAddressType> { + Self::VARIANTS.iter() + } +} + +impl Enum for ScAddressType {} + +impl fmt::Display for ScAddressType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ScAddressType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ScAddressType::Account, + 1 => ScAddressType::Contract, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ScAddressType) -> Self { + e as Self + } +} + +impl ReadXdr for ScAddressType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - seller_id: AccountId::read_xdr(r)?, - offer_id: i64::read_xdr(r)?, - selling: Asset::read_xdr(r)?, - buying: Asset::read_xdr(r)?, - amount: i64::read_xdr(r)?, - price: Price::read_xdr(r)?, - flags: u32::read_xdr(r)?, - ext: OfferEntryExt::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for OfferEntry { +impl WriteXdr for ScAddressType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.seller_id.write_xdr(w)?; - self.offer_id.write_xdr(w)?; - self.selling.write_xdr(w)?; - self.buying.write_xdr(w)?; - self.amount.write_xdr(w)?; - self.price.write_xdr(w)?; - self.flags.write_xdr(w)?; - self.ext.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// DataEntryExt is an XDR NestedUnion defines as: +// ScAddress is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// union SCAddress switch (SCAddressType type) +// { +// case SC_ADDRESS_TYPE_ACCOUNT: +// AccountID accountId; +// case SC_ADDRESS_TYPE_CONTRACT: +// Hash contractId; +// }; // -// union with discriminant i32 +// union with discriminant ScAddressType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -7072,65 +8023,69 @@ impl WriteXdr for OfferEntry { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum DataEntryExt { - V0, +pub enum ScAddress { + Account(AccountId), + Contract(Hash), } -impl DataEntryExt { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl ScAddress { + pub const VARIANTS: [ScAddressType; 2] = [ScAddressType::Account, ScAddressType::Contract]; + pub const VARIANTS_STR: [&'static str; 2] = ["Account", "Contract"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::Account(_) => "Account", + Self::Contract(_) => "Contract", } } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> ScAddressType { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::Account(_) => ScAddressType::Account, + Self::Contract(_) => ScAddressType::Contract, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [ScAddressType; 2] { Self::VARIANTS } } -impl Name for DataEntryExt { +impl Name for ScAddress { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for DataEntryExt { +impl Discriminant for ScAddress { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> ScAddressType { Self::discriminant(self) } } -impl Variants for DataEntryExt { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for ScAddress { + fn variants() -> slice::Iter<'static, ScAddressType> { Self::VARIANTS.iter() } } -impl Union for DataEntryExt {} +impl Union for ScAddress {} -impl ReadXdr for DataEntryExt { +impl ReadXdr for ScAddress { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: ScAddressType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, + ScAddressType::Account => Self::Account(AccountId::read_xdr(r)?), + ScAddressType::Contract => Self::Contract(Hash::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -7139,469 +8094,542 @@ impl ReadXdr for DataEntryExt { } } -impl WriteXdr for DataEntryExt { +impl WriteXdr for ScAddress { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::Account(v) => v.write_xdr(w)?, + Self::Contract(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// DataEntry is an XDR Struct defines as: +// ScsymbolLimit is an XDR Const defines as: // -// struct DataEntry -// { -// AccountID accountID; // account this data belongs to -// string64 dataName; -// DataValue dataValue; +// const SCSYMBOL_LIMIT = 32; // -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; -// }; +pub const SCSYMBOL_LIMIT: u64 = 32; + +// ScVec is an XDR Typedef defines as: // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// typedef SCVal SCVec<>; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct DataEntry { - pub account_id: AccountId, - pub data_name: String64, - pub data_value: DataValue, - pub ext: DataEntryExt, +pub struct ScVec(pub VecM); + +impl From for VecM { + #[must_use] + fn from(x: ScVec) -> Self { + x.0 + } } -impl ReadXdr for DataEntry { +impl From> for ScVec { + #[must_use] + fn from(x: VecM) -> Self { + ScVec(x) + } +} + +impl AsRef> for ScVec { + #[must_use] + fn as_ref(&self) -> &VecM { + &self.0 + } +} + +impl ReadXdr for ScVec { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - account_id: AccountId::read_xdr(r)?, - data_name: String64::read_xdr(r)?, - data_value: DataValue::read_xdr(r)?, - ext: DataEntryExt::read_xdr(r)?, - }) + let i = VecM::::read_xdr(r)?; + let v = ScVec(i); + Ok(v) }) } } -impl WriteXdr for DataEntry { +impl WriteXdr for ScVec { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.account_id.write_xdr(w)?; - self.data_name.write_xdr(w)?; - self.data_value.write_xdr(w)?; - self.ext.write_xdr(w)?; - Ok(()) - }) + w.with_limited_depth(|w| self.0.write_xdr(w)) } } -// ClaimPredicateType is an XDR Enum defines as: -// -// enum ClaimPredicateType -// { -// CLAIM_PREDICATE_UNCONDITIONAL = 0, -// CLAIM_PREDICATE_AND = 1, -// CLAIM_PREDICATE_OR = 2, -// CLAIM_PREDICATE_NOT = 3, -// CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME = 4, -// CLAIM_PREDICATE_BEFORE_RELATIVE_TIME = 5 -// }; -// -// enum -#[derive(Clone, Copy, 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") -)] -#[repr(i32)] -pub enum ClaimPredicateType { - Unconditional = 0, - And = 1, - Or = 2, - Not = 3, - BeforeAbsoluteTime = 4, - BeforeRelativeTime = 5, +impl Deref for ScVec { + type Target = VecM; + fn deref(&self) -> &Self::Target { + &self.0 + } } -impl ClaimPredicateType { - pub const VARIANTS: [ClaimPredicateType; 6] = [ - ClaimPredicateType::Unconditional, - ClaimPredicateType::And, - ClaimPredicateType::Or, - ClaimPredicateType::Not, - ClaimPredicateType::BeforeAbsoluteTime, - ClaimPredicateType::BeforeRelativeTime, - ]; - pub const VARIANTS_STR: [&'static str; 6] = [ - "Unconditional", - "And", - "Or", - "Not", - "BeforeAbsoluteTime", - "BeforeRelativeTime", - ]; - +impl From for Vec { #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::Unconditional => "Unconditional", - Self::And => "And", - Self::Or => "Or", - Self::Not => "Not", - Self::BeforeAbsoluteTime => "BeforeAbsoluteTime", - Self::BeforeRelativeTime => "BeforeRelativeTime", - } + fn from(x: ScVec) -> Self { + x.0 .0 } +} - #[must_use] - pub const fn variants() -> [ClaimPredicateType; 6] { - Self::VARIANTS +impl TryFrom> for ScVec { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(ScVec(x.try_into()?)) } } -impl Name for ClaimPredicateType { +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for ScVec { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(ScVec(x.try_into()?)) + } +} + +impl AsRef> for ScVec { #[must_use] - fn name(&self) -> &'static str { - Self::name(self) + fn as_ref(&self) -> &Vec { + &self.0 .0 } } -impl Variants for ClaimPredicateType { - fn variants() -> slice::Iter<'static, ClaimPredicateType> { - Self::VARIANTS.iter() +impl AsRef<[ScVal]> for ScVec { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[ScVal] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[ScVal] { + self.0 .0 } } -impl Enum for ClaimPredicateType {} +// ScMap is an XDR Typedef defines as: +// +// typedef SCMapEntry SCMap<>; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct ScMap(pub VecM); -impl fmt::Display for ClaimPredicateType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl From for VecM { + #[must_use] + fn from(x: ScMap) -> Self { + x.0 } } -impl TryFrom for ClaimPredicateType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => ClaimPredicateType::Unconditional, - 1 => ClaimPredicateType::And, - 2 => ClaimPredicateType::Or, - 3 => ClaimPredicateType::Not, - 4 => ClaimPredicateType::BeforeAbsoluteTime, - 5 => ClaimPredicateType::BeforeRelativeTime, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl From> for ScMap { + #[must_use] + fn from(x: VecM) -> Self { + ScMap(x) } } -impl From for i32 { +impl AsRef> for ScMap { #[must_use] - fn from(e: ClaimPredicateType) -> Self { - e as Self + fn as_ref(&self) -> &VecM { + &self.0 } } -impl ReadXdr for ClaimPredicateType { +impl ReadXdr for ScMap { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; + let i = VecM::::read_xdr(r)?; + let v = ScMap(i); Ok(v) }) } } -impl WriteXdr for ClaimPredicateType { +impl WriteXdr for ScMap { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) - }) + w.with_limited_depth(|w| self.0.write_xdr(w)) } } -// ClaimPredicate is an XDR Union defines as: +impl Deref for ScMap { + type Target = VecM; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for Vec { + #[must_use] + fn from(x: ScMap) -> Self { + x.0 .0 + } +} + +impl TryFrom> for ScMap { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(ScMap(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for ScMap { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(ScMap(x.try_into()?)) + } +} + +impl AsRef> for ScMap { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 + } +} + +impl AsRef<[ScMapEntry]> for ScMap { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[ScMapEntry] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[ScMapEntry] { + self.0 .0 + } +} + +// ScBytes is an XDR Typedef defines as: // -// union ClaimPredicate switch (ClaimPredicateType type) -// { -// case CLAIM_PREDICATE_UNCONDITIONAL: -// void; -// case CLAIM_PREDICATE_AND: -// ClaimPredicate andPredicates<2>; -// case CLAIM_PREDICATE_OR: -// ClaimPredicate orPredicates<2>; -// case CLAIM_PREDICATE_NOT: -// ClaimPredicate* notPredicate; -// case CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME: -// int64 absBefore; // Predicate will be true if closeTime < absBefore -// case CLAIM_PREDICATE_BEFORE_RELATIVE_TIME: -// int64 relBefore; // Seconds since closeTime of the ledger in which the -// // ClaimableBalanceEntry was created -// }; +// typedef opaque SCBytes<>; // -// union with discriminant ClaimPredicateType -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum ClaimPredicate { - Unconditional, - And(VecM), - Or(VecM), - Not(Option>), - BeforeAbsoluteTime(i64), - BeforeRelativeTime(i64), +pub struct ScBytes(pub BytesM); + +impl From for BytesM { + #[must_use] + fn from(x: ScBytes) -> Self { + x.0 + } } -impl ClaimPredicate { - pub const VARIANTS: [ClaimPredicateType; 6] = [ - ClaimPredicateType::Unconditional, - ClaimPredicateType::And, - ClaimPredicateType::Or, - ClaimPredicateType::Not, - ClaimPredicateType::BeforeAbsoluteTime, - ClaimPredicateType::BeforeRelativeTime, - ]; - pub const VARIANTS_STR: [&'static str; 6] = [ - "Unconditional", - "And", - "Or", - "Not", - "BeforeAbsoluteTime", - "BeforeRelativeTime", - ]; +impl From for ScBytes { + #[must_use] + fn from(x: BytesM) -> Self { + ScBytes(x) + } +} +impl AsRef for ScBytes { #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::Unconditional => "Unconditional", - Self::And(_) => "And", - Self::Or(_) => "Or", - Self::Not(_) => "Not", - Self::BeforeAbsoluteTime(_) => "BeforeAbsoluteTime", - Self::BeforeRelativeTime(_) => "BeforeRelativeTime", - } + fn as_ref(&self) -> &BytesM { + &self.0 + } +} + +impl ReadXdr for ScBytes { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = BytesM::read_xdr(r)?; + let v = ScBytes(i); + Ok(v) + }) + } +} + +impl WriteXdr for ScBytes { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl Deref for ScBytes { + type Target = BytesM; + fn deref(&self) -> &Self::Target { + &self.0 } +} +impl From for Vec { #[must_use] - pub const fn discriminant(&self) -> ClaimPredicateType { - #[allow(clippy::match_same_arms)] - match self { - Self::Unconditional => ClaimPredicateType::Unconditional, - Self::And(_) => ClaimPredicateType::And, - Self::Or(_) => ClaimPredicateType::Or, - Self::Not(_) => ClaimPredicateType::Not, - Self::BeforeAbsoluteTime(_) => ClaimPredicateType::BeforeAbsoluteTime, - Self::BeforeRelativeTime(_) => ClaimPredicateType::BeforeRelativeTime, - } + fn from(x: ScBytes) -> Self { + x.0 .0 + } +} + +impl TryFrom> for ScBytes { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(ScBytes(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for ScBytes { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(ScBytes(x.try_into()?)) } +} +impl AsRef> for ScBytes { #[must_use] - pub const fn variants() -> [ClaimPredicateType; 6] { - Self::VARIANTS + fn as_ref(&self) -> &Vec { + &self.0 .0 } } -impl Name for ClaimPredicate { +impl AsRef<[u8]> for ScBytes { + #[cfg(feature = "alloc")] #[must_use] - fn name(&self) -> &'static str { - Self::name(self) + fn as_ref(&self) -> &[u8] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[u8] { + self.0 .0 } } -impl Discriminant for ClaimPredicate { +// ScString is an XDR Typedef defines as: +// +// typedef string SCString<>; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct ScString(pub StringM); + +impl From for StringM { #[must_use] - fn discriminant(&self) -> ClaimPredicateType { - Self::discriminant(self) + fn from(x: ScString) -> Self { + x.0 } } -impl Variants for ClaimPredicate { - fn variants() -> slice::Iter<'static, ClaimPredicateType> { - Self::VARIANTS.iter() +impl From for ScString { + #[must_use] + fn from(x: StringM) -> Self { + ScString(x) } } -impl Union for ClaimPredicate {} +impl AsRef for ScString { + #[must_use] + fn as_ref(&self) -> &StringM { + &self.0 + } +} -impl ReadXdr for ClaimPredicate { +impl ReadXdr for ScString { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ClaimPredicateType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - ClaimPredicateType::Unconditional => Self::Unconditional, - ClaimPredicateType::And => Self::And(VecM::::read_xdr(r)?), - ClaimPredicateType::Or => Self::Or(VecM::::read_xdr(r)?), - ClaimPredicateType::Not => Self::Not(Option::>::read_xdr(r)?), - ClaimPredicateType::BeforeAbsoluteTime => { - Self::BeforeAbsoluteTime(i64::read_xdr(r)?) - } - ClaimPredicateType::BeforeRelativeTime => { - Self::BeforeRelativeTime(i64::read_xdr(r)?) - } - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; + let i = StringM::read_xdr(r)?; + let v = ScString(i); Ok(v) }) } } -impl WriteXdr for ClaimPredicate { +impl WriteXdr for ScString { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::Unconditional => ().write_xdr(w)?, - Self::And(v) => v.write_xdr(w)?, - Self::Or(v) => v.write_xdr(w)?, - Self::Not(v) => v.write_xdr(w)?, - Self::BeforeAbsoluteTime(v) => v.write_xdr(w)?, - Self::BeforeRelativeTime(v) => v.write_xdr(w)?, - }; - Ok(()) - }) + w.with_limited_depth(|w| self.0.write_xdr(w)) } } -// ClaimantType is an XDR Enum defines as: +impl Deref for ScString { + type Target = StringM; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for Vec { + #[must_use] + fn from(x: ScString) -> Self { + x.0 .0 + } +} + +impl TryFrom> for ScString { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(ScString(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for ScString { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(ScString(x.try_into()?)) + } +} + +impl AsRef> for ScString { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 + } +} + +impl AsRef<[u8]> for ScString { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[u8] { + self.0 .0 + } +} + +// ScSymbol is an XDR Typedef defines as: // -// enum ClaimantType -// { -// CLAIMANT_TYPE_V0 = 0 -// }; +// typedef string SCSymbol; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[repr(i32)] -pub enum ClaimantType { - ClaimantTypeV0 = 0, -} - -impl ClaimantType { - pub const VARIANTS: [ClaimantType; 1] = [ClaimantType::ClaimantTypeV0]; - pub const VARIANTS_STR: [&'static str; 1] = ["ClaimantTypeV0"]; +pub struct ScSymbol(pub StringM<32>); +impl From for StringM<32> { #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::ClaimantTypeV0 => "ClaimantTypeV0", - } + fn from(x: ScSymbol) -> Self { + x.0 } +} +impl From> for ScSymbol { #[must_use] - pub const fn variants() -> [ClaimantType; 1] { - Self::VARIANTS + fn from(x: StringM<32>) -> Self { + ScSymbol(x) } } -impl Name for ClaimantType { +impl AsRef> for ScSymbol { #[must_use] - fn name(&self) -> &'static str { - Self::name(self) + fn as_ref(&self) -> &StringM<32> { + &self.0 } } -impl Variants for ClaimantType { - fn variants() -> slice::Iter<'static, ClaimantType> { - Self::VARIANTS.iter() +impl ReadXdr for ScSymbol { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = StringM::<32>::read_xdr(r)?; + let v = ScSymbol(i); + Ok(v) + }) } } -impl Enum for ClaimantType {} +impl WriteXdr for ScSymbol { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} -impl fmt::Display for ClaimantType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Deref for ScSymbol { + type Target = StringM<32>; + fn deref(&self) -> &Self::Target { + &self.0 } } -impl TryFrom for ClaimantType { - type Error = Error; +impl From for Vec { + #[must_use] + fn from(x: ScSymbol) -> Self { + x.0 .0 + } +} - fn try_from(i: i32) -> Result { - let e = match i { - 0 => ClaimantType::ClaimantTypeV0, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl TryFrom> for ScSymbol { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(ScSymbol(x.try_into()?)) } } -impl From for i32 { - #[must_use] - fn from(e: ClaimantType) -> Self { - e as Self +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for ScSymbol { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(ScSymbol(x.try_into()?)) } } -impl ReadXdr for ClaimantType { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) - }) +impl AsRef> for ScSymbol { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 } } -impl WriteXdr for ClaimantType { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) - }) +impl AsRef<[u8]> for ScSymbol { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[u8] { + self.0 .0 } } -// ClaimantV0 is an XDR NestedStruct defines as: +// ScNonceKey is an XDR Struct defines as: // -// struct -// { -// AccountID destination; // The account that can use this condition -// ClaimPredicate predicate; // Claimable if predicate is true -// } +// struct SCNonceKey { +// int64 nonce; +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -7610,47 +8638,38 @@ impl WriteXdr for ClaimantType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ClaimantV0 { - pub destination: AccountId, - pub predicate: ClaimPredicate, +pub struct ScNonceKey { + pub nonce: i64, } -impl ReadXdr for ClaimantV0 { +impl ReadXdr for ScNonceKey { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - destination: AccountId::read_xdr(r)?, - predicate: ClaimPredicate::read_xdr(r)?, + nonce: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for ClaimantV0 { +impl WriteXdr for ScNonceKey { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.destination.write_xdr(w)?; - self.predicate.write_xdr(w)?; + self.nonce.write_xdr(w)?; Ok(()) }) } } -// Claimant is an XDR Union defines as: +// ScContractInstance is an XDR Struct defines as: // -// union Claimant switch (ClaimantType type) -// { -// case CLAIMANT_TYPE_V0: -// struct -// { -// AccountID destination; // The account that can use this condition -// ClaimPredicate predicate; // Claimable if predicate is true -// } v0; +// struct SCContractInstance { +// ContractExecutable executable; +// SCMap* storage; // }; // -// union with discriminant ClaimantType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -7658,197 +8677,99 @@ impl WriteXdr for ClaimantV0 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum Claimant { - ClaimantTypeV0(ClaimantV0), +pub struct ScContractInstance { + pub executable: ContractExecutable, + pub storage: Option, } -impl Claimant { - pub const VARIANTS: [ClaimantType; 1] = [ClaimantType::ClaimantTypeV0]; - pub const VARIANTS_STR: [&'static str; 1] = ["ClaimantTypeV0"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::ClaimantTypeV0(_) => "ClaimantTypeV0", - } - } - - #[must_use] - pub const fn discriminant(&self) -> ClaimantType { - #[allow(clippy::match_same_arms)] - match self { - Self::ClaimantTypeV0(_) => ClaimantType::ClaimantTypeV0, - } - } - - #[must_use] - pub const fn variants() -> [ClaimantType; 1] { - Self::VARIANTS - } -} - -impl Name for Claimant { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Discriminant for Claimant { - #[must_use] - fn discriminant(&self) -> ClaimantType { - Self::discriminant(self) - } -} - -impl Variants for Claimant { - fn variants() -> slice::Iter<'static, ClaimantType> { - Self::VARIANTS.iter() - } -} - -impl Union for Claimant {} - -impl ReadXdr for Claimant { +impl ReadXdr for ScContractInstance { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ClaimantType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - ClaimantType::ClaimantTypeV0 => Self::ClaimantTypeV0(ClaimantV0::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + executable: ContractExecutable::read_xdr(r)?, + storage: Option::::read_xdr(r)?, + }) }) } } -impl WriteXdr for Claimant { +impl WriteXdr for ScContractInstance { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::ClaimantTypeV0(v) => v.write_xdr(w)?, - }; + self.executable.write_xdr(w)?; + self.storage.write_xdr(w)?; Ok(()) }) } } -// ClaimableBalanceIdType is an XDR Enum defines as: +// ScVal is an XDR Union defines as: // -// enum ClaimableBalanceIDType +// union SCVal switch (SCValType type) // { -// CLAIMABLE_BALANCE_ID_TYPE_V0 = 0 -// }; // -// enum -#[derive(Clone, Copy, 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") -)] -#[repr(i32)] -pub enum ClaimableBalanceIdType { - ClaimableBalanceIdTypeV0 = 0, -} - -impl ClaimableBalanceIdType { - pub const VARIANTS: [ClaimableBalanceIdType; 1] = - [ClaimableBalanceIdType::ClaimableBalanceIdTypeV0]; - pub const VARIANTS_STR: [&'static str; 1] = ["ClaimableBalanceIdTypeV0"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::ClaimableBalanceIdTypeV0 => "ClaimableBalanceIdTypeV0", - } - } - - #[must_use] - pub const fn variants() -> [ClaimableBalanceIdType; 1] { - Self::VARIANTS - } -} - -impl Name for ClaimableBalanceIdType { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Variants for ClaimableBalanceIdType { - fn variants() -> slice::Iter<'static, ClaimableBalanceIdType> { - Self::VARIANTS.iter() - } -} - -impl Enum for ClaimableBalanceIdType {} - -impl fmt::Display for ClaimableBalanceIdType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) - } -} - -impl TryFrom for ClaimableBalanceIdType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => ClaimableBalanceIdType::ClaimableBalanceIdTypeV0, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) - } -} - -impl From for i32 { - #[must_use] - fn from(e: ClaimableBalanceIdType) -> Self { - e as Self - } -} - -impl ReadXdr for ClaimableBalanceIdType { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) - }) - } -} - -impl WriteXdr for ClaimableBalanceIdType { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) - }) - } -} - -// ClaimableBalanceId is an XDR Union defines as: +// case SCV_BOOL: +// bool b; +// case SCV_VOID: +// void; +// case SCV_ERROR: +// SCError error; +// +// case SCV_U32: +// uint32 u32; +// case SCV_I32: +// int32 i32; +// +// case SCV_U64: +// uint64 u64; +// case SCV_I64: +// int64 i64; +// case SCV_TIMEPOINT: +// TimePoint timepoint; +// case SCV_DURATION: +// Duration duration; +// +// case SCV_U128: +// UInt128Parts u128; +// case SCV_I128: +// Int128Parts i128; +// +// case SCV_U256: +// UInt256Parts u256; +// case SCV_I256: +// Int256Parts i256; +// +// case SCV_BYTES: +// SCBytes bytes; +// case SCV_STRING: +// SCString str; +// case SCV_SYMBOL: +// SCSymbol sym; +// +// // Vec and Map are recursive so need to live +// // behind an option, due to xdrpp limitations. +// case SCV_VEC: +// SCVec *vec; +// case SCV_MAP: +// SCMap *map; +// +// case SCV_ADDRESS: +// SCAddress address; +// +// // Special SCVals reserved for system-constructed contract-data +// // ledger keys, not generally usable elsewhere. +// case SCV_LEDGER_KEY_CONTRACT_INSTANCE: +// void; +// case SCV_LEDGER_KEY_NONCE: +// SCNonceKey nonce_key; // -// union ClaimableBalanceID switch (ClaimableBalanceIDType type) -// { -// case CLAIMABLE_BALANCE_ID_TYPE_V0: -// Hash v0; +// case SCV_CONTRACT_INSTANCE: +// SCContractInstance instance; // }; // -// union with discriminant ClaimableBalanceIdType +// union with discriminant ScValType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -7857,67 +8778,196 @@ impl WriteXdr for ClaimableBalanceIdType { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ClaimableBalanceId { - ClaimableBalanceIdTypeV0(Hash), -} - -impl ClaimableBalanceId { - pub const VARIANTS: [ClaimableBalanceIdType; 1] = - [ClaimableBalanceIdType::ClaimableBalanceIdTypeV0]; - pub const VARIANTS_STR: [&'static str; 1] = ["ClaimableBalanceIdTypeV0"]; +pub enum ScVal { + Bool(bool), + Void, + Error(ScError), + U32(u32), + I32(i32), + U64(u64), + I64(i64), + Timepoint(TimePoint), + Duration(Duration), + U128(UInt128Parts), + I128(Int128Parts), + U256(UInt256Parts), + I256(Int256Parts), + Bytes(ScBytes), + String(ScString), + Symbol(ScSymbol), + Vec(Option), + Map(Option), + Address(ScAddress), + LedgerKeyContractInstance, + LedgerKeyNonce(ScNonceKey), + ContractInstance(ScContractInstance), +} + +impl ScVal { + pub const VARIANTS: [ScValType; 22] = [ + ScValType::Bool, + ScValType::Void, + ScValType::Error, + ScValType::U32, + ScValType::I32, + ScValType::U64, + ScValType::I64, + ScValType::Timepoint, + ScValType::Duration, + ScValType::U128, + ScValType::I128, + ScValType::U256, + ScValType::I256, + ScValType::Bytes, + ScValType::String, + ScValType::Symbol, + ScValType::Vec, + ScValType::Map, + ScValType::Address, + ScValType::LedgerKeyContractInstance, + ScValType::LedgerKeyNonce, + ScValType::ContractInstance, + ]; + pub const VARIANTS_STR: [&'static str; 22] = [ + "Bool", + "Void", + "Error", + "U32", + "I32", + "U64", + "I64", + "Timepoint", + "Duration", + "U128", + "I128", + "U256", + "I256", + "Bytes", + "String", + "Symbol", + "Vec", + "Map", + "Address", + "LedgerKeyContractInstance", + "LedgerKeyNonce", + "ContractInstance", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::ClaimableBalanceIdTypeV0(_) => "ClaimableBalanceIdTypeV0", + Self::Bool(_) => "Bool", + Self::Void => "Void", + Self::Error(_) => "Error", + Self::U32(_) => "U32", + Self::I32(_) => "I32", + Self::U64(_) => "U64", + Self::I64(_) => "I64", + Self::Timepoint(_) => "Timepoint", + Self::Duration(_) => "Duration", + Self::U128(_) => "U128", + Self::I128(_) => "I128", + Self::U256(_) => "U256", + Self::I256(_) => "I256", + Self::Bytes(_) => "Bytes", + Self::String(_) => "String", + Self::Symbol(_) => "Symbol", + Self::Vec(_) => "Vec", + Self::Map(_) => "Map", + Self::Address(_) => "Address", + Self::LedgerKeyContractInstance => "LedgerKeyContractInstance", + Self::LedgerKeyNonce(_) => "LedgerKeyNonce", + Self::ContractInstance(_) => "ContractInstance", } } #[must_use] - pub const fn discriminant(&self) -> ClaimableBalanceIdType { + pub const fn discriminant(&self) -> ScValType { #[allow(clippy::match_same_arms)] match self { - Self::ClaimableBalanceIdTypeV0(_) => ClaimableBalanceIdType::ClaimableBalanceIdTypeV0, - } - } - - #[must_use] - pub const fn variants() -> [ClaimableBalanceIdType; 1] { + Self::Bool(_) => ScValType::Bool, + Self::Void => ScValType::Void, + Self::Error(_) => ScValType::Error, + Self::U32(_) => ScValType::U32, + Self::I32(_) => ScValType::I32, + Self::U64(_) => ScValType::U64, + Self::I64(_) => ScValType::I64, + Self::Timepoint(_) => ScValType::Timepoint, + Self::Duration(_) => ScValType::Duration, + Self::U128(_) => ScValType::U128, + Self::I128(_) => ScValType::I128, + Self::U256(_) => ScValType::U256, + Self::I256(_) => ScValType::I256, + Self::Bytes(_) => ScValType::Bytes, + Self::String(_) => ScValType::String, + Self::Symbol(_) => ScValType::Symbol, + Self::Vec(_) => ScValType::Vec, + Self::Map(_) => ScValType::Map, + Self::Address(_) => ScValType::Address, + Self::LedgerKeyContractInstance => ScValType::LedgerKeyContractInstance, + Self::LedgerKeyNonce(_) => ScValType::LedgerKeyNonce, + Self::ContractInstance(_) => ScValType::ContractInstance, + } + } + + #[must_use] + pub const fn variants() -> [ScValType; 22] { Self::VARIANTS } } -impl Name for ClaimableBalanceId { +impl Name for ScVal { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ClaimableBalanceId { +impl Discriminant for ScVal { #[must_use] - fn discriminant(&self) -> ClaimableBalanceIdType { + fn discriminant(&self) -> ScValType { Self::discriminant(self) } } -impl Variants for ClaimableBalanceId { - fn variants() -> slice::Iter<'static, ClaimableBalanceIdType> { +impl Variants for ScVal { + fn variants() -> slice::Iter<'static, ScValType> { Self::VARIANTS.iter() } } -impl Union for ClaimableBalanceId {} +impl Union for ScVal {} -impl ReadXdr for ClaimableBalanceId { +impl ReadXdr for ScVal { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ClaimableBalanceIdType = ::read_xdr(r)?; + let dv: ScValType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ClaimableBalanceIdType::ClaimableBalanceIdTypeV0 => { - Self::ClaimableBalanceIdTypeV0(Hash::read_xdr(r)?) + ScValType::Bool => Self::Bool(bool::read_xdr(r)?), + ScValType::Void => Self::Void, + ScValType::Error => Self::Error(ScError::read_xdr(r)?), + ScValType::U32 => Self::U32(u32::read_xdr(r)?), + ScValType::I32 => Self::I32(i32::read_xdr(r)?), + ScValType::U64 => Self::U64(u64::read_xdr(r)?), + ScValType::I64 => Self::I64(i64::read_xdr(r)?), + ScValType::Timepoint => Self::Timepoint(TimePoint::read_xdr(r)?), + ScValType::Duration => Self::Duration(Duration::read_xdr(r)?), + ScValType::U128 => Self::U128(UInt128Parts::read_xdr(r)?), + ScValType::I128 => Self::I128(Int128Parts::read_xdr(r)?), + ScValType::U256 => Self::U256(UInt256Parts::read_xdr(r)?), + ScValType::I256 => Self::I256(Int256Parts::read_xdr(r)?), + ScValType::Bytes => Self::Bytes(ScBytes::read_xdr(r)?), + ScValType::String => Self::String(ScString::read_xdr(r)?), + ScValType::Symbol => Self::Symbol(ScSymbol::read_xdr(r)?), + ScValType::Vec => Self::Vec(Option::::read_xdr(r)?), + ScValType::Map => Self::Map(Option::::read_xdr(r)?), + ScValType::Address => Self::Address(ScAddress::read_xdr(r)?), + ScValType::LedgerKeyContractInstance => Self::LedgerKeyContractInstance, + ScValType::LedgerKeyNonce => Self::LedgerKeyNonce(ScNonceKey::read_xdr(r)?), + ScValType::ContractInstance => { + Self::ContractInstance(ScContractInstance::read_xdr(r)?) } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), @@ -7927,135 +8977,93 @@ impl ReadXdr for ClaimableBalanceId { } } -impl WriteXdr for ClaimableBalanceId { +impl WriteXdr for ScVal { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::ClaimableBalanceIdTypeV0(v) => v.write_xdr(w)?, + Self::Bool(v) => v.write_xdr(w)?, + Self::Void => ().write_xdr(w)?, + Self::Error(v) => v.write_xdr(w)?, + Self::U32(v) => v.write_xdr(w)?, + Self::I32(v) => v.write_xdr(w)?, + Self::U64(v) => v.write_xdr(w)?, + Self::I64(v) => v.write_xdr(w)?, + Self::Timepoint(v) => v.write_xdr(w)?, + Self::Duration(v) => v.write_xdr(w)?, + Self::U128(v) => v.write_xdr(w)?, + Self::I128(v) => v.write_xdr(w)?, + Self::U256(v) => v.write_xdr(w)?, + Self::I256(v) => v.write_xdr(w)?, + Self::Bytes(v) => v.write_xdr(w)?, + Self::String(v) => v.write_xdr(w)?, + Self::Symbol(v) => v.write_xdr(w)?, + Self::Vec(v) => v.write_xdr(w)?, + Self::Map(v) => v.write_xdr(w)?, + Self::Address(v) => v.write_xdr(w)?, + Self::LedgerKeyContractInstance => ().write_xdr(w)?, + Self::LedgerKeyNonce(v) => v.write_xdr(w)?, + Self::ContractInstance(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// ClaimableBalanceFlags is an XDR Enum defines as: +// ScMapEntry is an XDR Struct defines as: // -// enum ClaimableBalanceFlags +// struct SCMapEntry // { -// // If set, the issuer account of the asset held by the claimable balance may -// // clawback the claimable balance -// CLAIMABLE_BALANCE_CLAWBACK_ENABLED_FLAG = 0x1 +// SCVal key; +// SCVal val; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[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") )] -#[repr(i32)] -pub enum ClaimableBalanceFlags { - ClaimableBalanceClawbackEnabledFlag = 1, -} - -impl ClaimableBalanceFlags { - pub const VARIANTS: [ClaimableBalanceFlags; 1] = - [ClaimableBalanceFlags::ClaimableBalanceClawbackEnabledFlag]; - pub const VARIANTS_STR: [&'static str; 1] = ["ClaimableBalanceClawbackEnabledFlag"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::ClaimableBalanceClawbackEnabledFlag => "ClaimableBalanceClawbackEnabledFlag", - } - } - - #[must_use] - pub const fn variants() -> [ClaimableBalanceFlags; 1] { - Self::VARIANTS - } -} - -impl Name for ClaimableBalanceFlags { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Variants for ClaimableBalanceFlags { - fn variants() -> slice::Iter<'static, ClaimableBalanceFlags> { - Self::VARIANTS.iter() - } -} - -impl Enum for ClaimableBalanceFlags {} - -impl fmt::Display for ClaimableBalanceFlags { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) - } -} - -impl TryFrom for ClaimableBalanceFlags { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 1 => ClaimableBalanceFlags::ClaimableBalanceClawbackEnabledFlag, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) - } -} - -impl From for i32 { - #[must_use] - fn from(e: ClaimableBalanceFlags) -> Self { - e as Self - } +pub struct ScMapEntry { + pub key: ScVal, + pub val: ScVal, } -impl ReadXdr for ClaimableBalanceFlags { +impl ReadXdr for ScMapEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) + Ok(Self { + key: ScVal::read_xdr(r)?, + val: ScVal::read_xdr(r)?, + }) }) } } -impl WriteXdr for ClaimableBalanceFlags { +impl WriteXdr for ScMapEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.key.write_xdr(w)?; + self.val.write_xdr(w)?; + Ok(()) }) } } -// MaskClaimableBalanceFlags is an XDR Const defines as: -// -// const MASK_CLAIMABLE_BALANCE_FLAGS = 0x1; -// -pub const MASK_CLAIMABLE_BALANCE_FLAGS: u64 = 0x1; - -// ClaimableBalanceEntryExtensionV1Ext is an XDR NestedUnion defines as: +// StoredTransactionSet is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// union StoredTransactionSet switch (int v) +// { +// case 0: +// TransactionSet txSet; +// case 1: +// GeneralizedTransactionSet generalizedTxSet; +// }; // // union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -8066,18 +9074,20 @@ pub const MASK_CLAIMABLE_BALANCE_FLAGS: u64 = 0x1; serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ClaimableBalanceEntryExtensionV1Ext { - V0, +pub enum StoredTransactionSet { + V0(TransactionSet), + V1(GeneralizedTransactionSet), } -impl ClaimableBalanceEntryExtensionV1Ext { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl StoredTransactionSet { + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::V0(_) => "V0", + Self::V1(_) => "V1", } } @@ -8085,46 +9095,48 @@ impl ClaimableBalanceEntryExtensionV1Ext { pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::V0(_) => 0, + Self::V1(_) => 1, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [i32; 2] { Self::VARIANTS } } -impl Name for ClaimableBalanceEntryExtensionV1Ext { +impl Name for StoredTransactionSet { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ClaimableBalanceEntryExtensionV1Ext { +impl Discriminant for StoredTransactionSet { #[must_use] fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for ClaimableBalanceEntryExtensionV1Ext { +impl Variants for StoredTransactionSet { fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for ClaimableBalanceEntryExtensionV1Ext {} +impl Union for StoredTransactionSet {} -impl ReadXdr for ClaimableBalanceEntryExtensionV1Ext { +impl ReadXdr for StoredTransactionSet { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, + 0 => Self::V0(TransactionSet::read_xdr(r)?), + 1 => Self::V1(GeneralizedTransactionSet::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -8133,32 +9145,75 @@ impl ReadXdr for ClaimableBalanceEntryExtensionV1Ext { } } -impl WriteXdr for ClaimableBalanceEntryExtensionV1Ext { +impl WriteXdr for StoredTransactionSet { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// ClaimableBalanceEntryExtensionV1 is an XDR Struct defines as: +// PersistedScpStateV0 is an XDR Struct defines as: // -// struct ClaimableBalanceEntryExtensionV1 +// struct PersistedSCPStateV0 // { -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// SCPEnvelope scpEnvelopes<>; +// SCPQuorumSet quorumSets<>; +// StoredTransactionSet txSets<>; +// }; // -// uint32 flags; // see ClaimableBalanceFlags +#[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 PersistedScpStateV0 { + pub scp_envelopes: VecM, + pub quorum_sets: VecM, + pub tx_sets: VecM, +} + +impl ReadXdr for PersistedScpStateV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + scp_envelopes: VecM::::read_xdr(r)?, + quorum_sets: VecM::::read_xdr(r)?, + tx_sets: VecM::::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for PersistedScpStateV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.scp_envelopes.write_xdr(w)?; + self.quorum_sets.write_xdr(w)?; + self.tx_sets.write_xdr(w)?; + Ok(()) + }) + } +} + +// PersistedScpStateV1 is an XDR Struct defines as: +// +// struct PersistedSCPStateV1 +// { +// // Tx sets are saved separately +// SCPEnvelope scpEnvelopes<>; +// SCPQuorumSet quorumSets<>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -8168,43 +9223,43 @@ impl WriteXdr for ClaimableBalanceEntryExtensionV1Ext { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ClaimableBalanceEntryExtensionV1 { - pub ext: ClaimableBalanceEntryExtensionV1Ext, - pub flags: u32, +pub struct PersistedScpStateV1 { + pub scp_envelopes: VecM, + pub quorum_sets: VecM, } -impl ReadXdr for ClaimableBalanceEntryExtensionV1 { +impl ReadXdr for PersistedScpStateV1 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - ext: ClaimableBalanceEntryExtensionV1Ext::read_xdr(r)?, - flags: u32::read_xdr(r)?, + scp_envelopes: VecM::::read_xdr(r)?, + quorum_sets: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for ClaimableBalanceEntryExtensionV1 { +impl WriteXdr for PersistedScpStateV1 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ext.write_xdr(w)?; - self.flags.write_xdr(w)?; + self.scp_envelopes.write_xdr(w)?; + self.quorum_sets.write_xdr(w)?; Ok(()) }) } } -// ClaimableBalanceEntryExt is an XDR NestedUnion defines as: +// PersistedScpState is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// ClaimableBalanceEntryExtensionV1 v1; -// } +// union PersistedSCPState switch (int v) +// { +// case 0: +// PersistedSCPStateV0 v0; +// case 1: +// PersistedSCPStateV1 v1; +// }; // // union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -8215,19 +9270,19 @@ impl WriteXdr for ClaimableBalanceEntryExtensionV1 { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ClaimableBalanceEntryExt { - V0, - V1(ClaimableBalanceEntryExtensionV1), +pub enum PersistedScpState { + V0(PersistedScpStateV0), + V1(PersistedScpStateV1), } -impl ClaimableBalanceEntryExt { +impl PersistedScpState { pub const VARIANTS: [i32; 2] = [0, 1]; pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::V0(_) => "V0", Self::V1(_) => "V1", } } @@ -8236,7 +9291,7 @@ impl ClaimableBalanceEntryExt { pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::V0(_) => 0, Self::V1(_) => 1, } } @@ -8247,37 +9302,37 @@ impl ClaimableBalanceEntryExt { } } -impl Name for ClaimableBalanceEntryExt { +impl Name for PersistedScpState { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ClaimableBalanceEntryExt { +impl Discriminant for PersistedScpState { #[must_use] fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for ClaimableBalanceEntryExt { +impl Variants for PersistedScpState { fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for ClaimableBalanceEntryExt {} +impl Union for PersistedScpState {} -impl ReadXdr for ClaimableBalanceEntryExt { +impl ReadXdr for PersistedScpState { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, - 1 => Self::V1(ClaimableBalanceEntryExtensionV1::read_xdr(r)?), + 0 => Self::V0(PersistedScpStateV0::read_xdr(r)?), + 1 => Self::V1(PersistedScpStateV1::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -8286,14 +9341,14 @@ impl ReadXdr for ClaimableBalanceEntryExt { } } -impl WriteXdr for ClaimableBalanceEntryExt { +impl WriteXdr for PersistedScpState { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, Self::V1(v) => v.write_xdr(w)?, }; Ok(()) @@ -8301,84 +9356,7945 @@ impl WriteXdr for ClaimableBalanceEntryExt { } } -// ClaimableBalanceEntry is an XDR Struct defines as: -// -// struct ClaimableBalanceEntry -// { -// // Unique identifier for this ClaimableBalanceEntry -// ClaimableBalanceID balanceID; -// -// // List of claimants with associated predicate -// Claimant claimants<10>; -// -// // Any asset including native -// Asset asset; -// -// // Amount of asset -// int64 amount; +// Thresholds is an XDR Typedef defines as: // -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// ClaimableBalanceEntryExtensionV1 v1; -// } -// ext; -// }; +// typedef opaque Thresholds[4]; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, 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") + derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr) )] -pub struct ClaimableBalanceEntry { - pub balance_id: ClaimableBalanceId, - pub claimants: VecM, - pub asset: Asset, - pub amount: i64, - pub ext: ClaimableBalanceEntryExt, +pub struct Thresholds(pub [u8; 4]); + +impl core::fmt::Display for Thresholds { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let v = &self.0; + for b in v { + write!(f, "{b:02x}")?; + } + Ok(()) + } } -impl ReadXdr for ClaimableBalanceEntry { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { +impl core::fmt::Debug for Thresholds { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let v = &self.0; + write!(f, "Thresholds(")?; + for b in v { + write!(f, "{b:02x}")?; + } + write!(f, ")")?; + Ok(()) + } +} + +#[cfg(feature = "alloc")] +impl core::str::FromStr for Thresholds { + type Err = Error; + fn from_str(s: &str) -> core::result::Result { + hex::decode(s).map_err(|_| Error::InvalidHex)?.try_into() + } +} +impl From for [u8; 4] { + #[must_use] + fn from(x: Thresholds) -> Self { + x.0 + } +} + +impl From<[u8; 4]> for Thresholds { + #[must_use] + fn from(x: [u8; 4]) -> Self { + Thresholds(x) + } +} + +impl AsRef<[u8; 4]> for Thresholds { + #[must_use] + fn as_ref(&self) -> &[u8; 4] { + &self.0 + } +} + +impl ReadXdr for Thresholds { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = <[u8; 4]>::read_xdr(r)?; + let v = Thresholds(i); + Ok(v) + }) + } +} + +impl WriteXdr for Thresholds { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl Thresholds { + #[must_use] + pub fn as_slice(&self) -> &[u8] { + &self.0 + } +} + +#[cfg(feature = "alloc")] +impl TryFrom> for Thresholds { + type Error = Error; + fn try_from(x: Vec) -> Result { + x.as_slice().try_into() + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for Thresholds { + type Error = Error; + fn try_from(x: &Vec) -> Result { + x.as_slice().try_into() + } +} + +impl TryFrom<&[u8]> for Thresholds { + type Error = Error; + fn try_from(x: &[u8]) -> Result { + Ok(Thresholds(x.try_into()?)) + } +} + +impl AsRef<[u8]> for Thresholds { + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +// String32 is an XDR Typedef defines as: +// +// typedef string string32<32>; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct String32(pub StringM<32>); + +impl From for StringM<32> { + #[must_use] + fn from(x: String32) -> Self { + x.0 + } +} + +impl From> for String32 { + #[must_use] + fn from(x: StringM<32>) -> Self { + String32(x) + } +} + +impl AsRef> for String32 { + #[must_use] + fn as_ref(&self) -> &StringM<32> { + &self.0 + } +} + +impl ReadXdr for String32 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = StringM::<32>::read_xdr(r)?; + let v = String32(i); + Ok(v) + }) + } +} + +impl WriteXdr for String32 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl Deref for String32 { + type Target = StringM<32>; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for Vec { + #[must_use] + fn from(x: String32) -> Self { + x.0 .0 + } +} + +impl TryFrom> for String32 { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(String32(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for String32 { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(String32(x.try_into()?)) + } +} + +impl AsRef> for String32 { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 + } +} + +impl AsRef<[u8]> for String32 { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[u8] { + self.0 .0 + } +} + +// String64 is an XDR Typedef defines as: +// +// typedef string string64<64>; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct String64(pub StringM<64>); + +impl From for StringM<64> { + #[must_use] + fn from(x: String64) -> Self { + x.0 + } +} + +impl From> for String64 { + #[must_use] + fn from(x: StringM<64>) -> Self { + String64(x) + } +} + +impl AsRef> for String64 { + #[must_use] + fn as_ref(&self) -> &StringM<64> { + &self.0 + } +} + +impl ReadXdr for String64 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = StringM::<64>::read_xdr(r)?; + let v = String64(i); + Ok(v) + }) + } +} + +impl WriteXdr for String64 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl Deref for String64 { + type Target = StringM<64>; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for Vec { + #[must_use] + fn from(x: String64) -> Self { + x.0 .0 + } +} + +impl TryFrom> for String64 { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(String64(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for String64 { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(String64(x.try_into()?)) + } +} + +impl AsRef> for String64 { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 + } +} + +impl AsRef<[u8]> for String64 { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[u8] { + self.0 .0 + } +} + +// SequenceNumber is an XDR Typedef defines as: +// +// typedef int64 SequenceNumber; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct SequenceNumber(pub i64); + +impl From for i64 { + #[must_use] + fn from(x: SequenceNumber) -> Self { + x.0 + } +} + +impl From for SequenceNumber { + #[must_use] + fn from(x: i64) -> Self { + SequenceNumber(x) + } +} + +impl AsRef for SequenceNumber { + #[must_use] + fn as_ref(&self) -> &i64 { + &self.0 + } +} + +impl ReadXdr for SequenceNumber { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = i64::read_xdr(r)?; + let v = SequenceNumber(i); + Ok(v) + }) + } +} + +impl WriteXdr for SequenceNumber { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +// DataValue is an XDR Typedef defines as: +// +// typedef opaque DataValue<64>; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct DataValue(pub BytesM<64>); + +impl From for BytesM<64> { + #[must_use] + fn from(x: DataValue) -> Self { + x.0 + } +} + +impl From> for DataValue { + #[must_use] + fn from(x: BytesM<64>) -> Self { + DataValue(x) + } +} + +impl AsRef> for DataValue { + #[must_use] + fn as_ref(&self) -> &BytesM<64> { + &self.0 + } +} + +impl ReadXdr for DataValue { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = BytesM::<64>::read_xdr(r)?; + let v = DataValue(i); + Ok(v) + }) + } +} + +impl WriteXdr for DataValue { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl Deref for DataValue { + type Target = BytesM<64>; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for Vec { + #[must_use] + fn from(x: DataValue) -> Self { + x.0 .0 + } +} + +impl TryFrom> for DataValue { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(DataValue(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for DataValue { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(DataValue(x.try_into()?)) + } +} + +impl AsRef> for DataValue { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 + } +} + +impl AsRef<[u8]> for DataValue { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[u8] { + self.0 .0 + } +} + +// PoolId is an XDR Typedef defines as: +// +// typedef Hash PoolID; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct PoolId(pub Hash); + +impl From for Hash { + #[must_use] + fn from(x: PoolId) -> Self { + x.0 + } +} + +impl From for PoolId { + #[must_use] + fn from(x: Hash) -> Self { + PoolId(x) + } +} + +impl AsRef for PoolId { + #[must_use] + fn as_ref(&self) -> &Hash { + &self.0 + } +} + +impl ReadXdr for PoolId { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = Hash::read_xdr(r)?; + let v = PoolId(i); + Ok(v) + }) + } +} + +impl WriteXdr for PoolId { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +// AssetCode4 is an XDR Typedef defines as: +// +// typedef opaque AssetCode4[4]; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr) +)] +pub struct AssetCode4(pub [u8; 4]); + +impl core::fmt::Display for AssetCode4 { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let v = &self.0; + for b in v { + write!(f, "{b:02x}")?; + } + Ok(()) + } +} + +impl core::fmt::Debug for AssetCode4 { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let v = &self.0; + write!(f, "AssetCode4(")?; + for b in v { + write!(f, "{b:02x}")?; + } + write!(f, ")")?; + Ok(()) + } +} + +#[cfg(feature = "alloc")] +impl core::str::FromStr for AssetCode4 { + type Err = Error; + fn from_str(s: &str) -> core::result::Result { + hex::decode(s).map_err(|_| Error::InvalidHex)?.try_into() + } +} +impl From for [u8; 4] { + #[must_use] + fn from(x: AssetCode4) -> Self { + x.0 + } +} + +impl From<[u8; 4]> for AssetCode4 { + #[must_use] + fn from(x: [u8; 4]) -> Self { + AssetCode4(x) + } +} + +impl AsRef<[u8; 4]> for AssetCode4 { + #[must_use] + fn as_ref(&self) -> &[u8; 4] { + &self.0 + } +} + +impl ReadXdr for AssetCode4 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = <[u8; 4]>::read_xdr(r)?; + let v = AssetCode4(i); + Ok(v) + }) + } +} + +impl WriteXdr for AssetCode4 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl AssetCode4 { + #[must_use] + pub fn as_slice(&self) -> &[u8] { + &self.0 + } +} + +#[cfg(feature = "alloc")] +impl TryFrom> for AssetCode4 { + type Error = Error; + fn try_from(x: Vec) -> Result { + x.as_slice().try_into() + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for AssetCode4 { + type Error = Error; + fn try_from(x: &Vec) -> Result { + x.as_slice().try_into() + } +} + +impl TryFrom<&[u8]> for AssetCode4 { + type Error = Error; + fn try_from(x: &[u8]) -> Result { + Ok(AssetCode4(x.try_into()?)) + } +} + +impl AsRef<[u8]> for AssetCode4 { + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +// AssetCode12 is an XDR Typedef defines as: +// +// typedef opaque AssetCode12[12]; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr) +)] +pub struct AssetCode12(pub [u8; 12]); + +impl core::fmt::Display for AssetCode12 { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let v = &self.0; + for b in v { + write!(f, "{b:02x}")?; + } + Ok(()) + } +} + +impl core::fmt::Debug for AssetCode12 { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let v = &self.0; + write!(f, "AssetCode12(")?; + for b in v { + write!(f, "{b:02x}")?; + } + write!(f, ")")?; + Ok(()) + } +} + +#[cfg(feature = "alloc")] +impl core::str::FromStr for AssetCode12 { + type Err = Error; + fn from_str(s: &str) -> core::result::Result { + hex::decode(s).map_err(|_| Error::InvalidHex)?.try_into() + } +} +impl From for [u8; 12] { + #[must_use] + fn from(x: AssetCode12) -> Self { + x.0 + } +} + +impl From<[u8; 12]> for AssetCode12 { + #[must_use] + fn from(x: [u8; 12]) -> Self { + AssetCode12(x) + } +} + +impl AsRef<[u8; 12]> for AssetCode12 { + #[must_use] + fn as_ref(&self) -> &[u8; 12] { + &self.0 + } +} + +impl ReadXdr for AssetCode12 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = <[u8; 12]>::read_xdr(r)?; + let v = AssetCode12(i); + Ok(v) + }) + } +} + +impl WriteXdr for AssetCode12 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl AssetCode12 { + #[must_use] + pub fn as_slice(&self) -> &[u8] { + &self.0 + } +} + +#[cfg(feature = "alloc")] +impl TryFrom> for AssetCode12 { + type Error = Error; + fn try_from(x: Vec) -> Result { + x.as_slice().try_into() + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for AssetCode12 { + type Error = Error; + fn try_from(x: &Vec) -> Result { + x.as_slice().try_into() + } +} + +impl TryFrom<&[u8]> for AssetCode12 { + type Error = Error; + fn try_from(x: &[u8]) -> Result { + Ok(AssetCode12(x.try_into()?)) + } +} + +impl AsRef<[u8]> for AssetCode12 { + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +// AssetType is an XDR Enum defines as: +// +// enum AssetType +// { +// ASSET_TYPE_NATIVE = 0, +// ASSET_TYPE_CREDIT_ALPHANUM4 = 1, +// ASSET_TYPE_CREDIT_ALPHANUM12 = 2, +// ASSET_TYPE_POOL_SHARE = 3 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum AssetType { + Native = 0, + CreditAlphanum4 = 1, + CreditAlphanum12 = 2, + PoolShare = 3, +} + +impl AssetType { + pub const VARIANTS: [AssetType; 4] = [ + AssetType::Native, + AssetType::CreditAlphanum4, + AssetType::CreditAlphanum12, + AssetType::PoolShare, + ]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Native", "CreditAlphanum4", "CreditAlphanum12", "PoolShare"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Native => "Native", + Self::CreditAlphanum4 => "CreditAlphanum4", + Self::CreditAlphanum12 => "CreditAlphanum12", + Self::PoolShare => "PoolShare", + } + } + + #[must_use] + pub const fn variants() -> [AssetType; 4] { + Self::VARIANTS + } +} + +impl Name for AssetType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for AssetType { + fn variants() -> slice::Iter<'static, AssetType> { + Self::VARIANTS.iter() + } +} + +impl Enum for AssetType {} + +impl fmt::Display for AssetType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for AssetType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => AssetType::Native, + 1 => AssetType::CreditAlphanum4, + 2 => AssetType::CreditAlphanum12, + 3 => AssetType::PoolShare, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: AssetType) -> Self { + e as Self + } +} + +impl ReadXdr for AssetType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for AssetType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// AssetCode is an XDR Union defines as: +// +// union AssetCode switch (AssetType type) +// { +// case ASSET_TYPE_CREDIT_ALPHANUM4: +// AssetCode4 assetCode4; +// +// case ASSET_TYPE_CREDIT_ALPHANUM12: +// AssetCode12 assetCode12; +// +// // add other asset types here in the future +// }; +// +// union with discriminant AssetType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum AssetCode { + CreditAlphanum4(AssetCode4), + CreditAlphanum12(AssetCode12), +} + +impl AssetCode { + pub const VARIANTS: [AssetType; 2] = [AssetType::CreditAlphanum4, AssetType::CreditAlphanum12]; + pub const VARIANTS_STR: [&'static str; 2] = ["CreditAlphanum4", "CreditAlphanum12"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::CreditAlphanum4(_) => "CreditAlphanum4", + Self::CreditAlphanum12(_) => "CreditAlphanum12", + } + } + + #[must_use] + pub const fn discriminant(&self) -> AssetType { + #[allow(clippy::match_same_arms)] + match self { + Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, + Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, + } + } + + #[must_use] + pub const fn variants() -> [AssetType; 2] { + Self::VARIANTS + } +} + +impl Name for AssetCode { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for AssetCode { + #[must_use] + fn discriminant(&self) -> AssetType { + Self::discriminant(self) + } +} + +impl Variants for AssetCode { + fn variants() -> slice::Iter<'static, AssetType> { + Self::VARIANTS.iter() + } +} + +impl Union for AssetCode {} + +impl ReadXdr for AssetCode { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: AssetType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AssetCode4::read_xdr(r)?), + AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AssetCode12::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for AssetCode { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::CreditAlphanum4(v) => v.write_xdr(w)?, + Self::CreditAlphanum12(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// AlphaNum4 is an XDR Struct defines as: +// +// struct AlphaNum4 +// { +// AssetCode4 assetCode; +// AccountID issuer; +// }; +// +#[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 AlphaNum4 { + pub asset_code: AssetCode4, + pub issuer: AccountId, +} + +impl ReadXdr for AlphaNum4 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + asset_code: AssetCode4::read_xdr(r)?, + issuer: AccountId::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for AlphaNum4 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.asset_code.write_xdr(w)?; + self.issuer.write_xdr(w)?; + Ok(()) + }) + } +} + +// AlphaNum12 is an XDR Struct defines as: +// +// struct AlphaNum12 +// { +// AssetCode12 assetCode; +// AccountID issuer; +// }; +// +#[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 AlphaNum12 { + pub asset_code: AssetCode12, + pub issuer: AccountId, +} + +impl ReadXdr for AlphaNum12 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + asset_code: AssetCode12::read_xdr(r)?, + issuer: AccountId::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for AlphaNum12 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.asset_code.write_xdr(w)?; + self.issuer.write_xdr(w)?; + Ok(()) + }) + } +} + +// Asset is an XDR Union defines as: +// +// union Asset switch (AssetType type) +// { +// case ASSET_TYPE_NATIVE: // Not credit +// void; +// +// case ASSET_TYPE_CREDIT_ALPHANUM4: +// AlphaNum4 alphaNum4; +// +// case ASSET_TYPE_CREDIT_ALPHANUM12: +// AlphaNum12 alphaNum12; +// +// // add other asset types here in the future +// }; +// +// union with discriminant AssetType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum Asset { + Native, + CreditAlphanum4(AlphaNum4), + CreditAlphanum12(AlphaNum12), +} + +impl Asset { + pub const VARIANTS: [AssetType; 3] = [ + AssetType::Native, + AssetType::CreditAlphanum4, + AssetType::CreditAlphanum12, + ]; + pub const VARIANTS_STR: [&'static str; 3] = ["Native", "CreditAlphanum4", "CreditAlphanum12"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Native => "Native", + Self::CreditAlphanum4(_) => "CreditAlphanum4", + Self::CreditAlphanum12(_) => "CreditAlphanum12", + } + } + + #[must_use] + pub const fn discriminant(&self) -> AssetType { + #[allow(clippy::match_same_arms)] + match self { + Self::Native => AssetType::Native, + Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, + Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, + } + } + + #[must_use] + pub const fn variants() -> [AssetType; 3] { + Self::VARIANTS + } +} + +impl Name for Asset { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for Asset { + #[must_use] + fn discriminant(&self) -> AssetType { + Self::discriminant(self) + } +} + +impl Variants for Asset { + fn variants() -> slice::Iter<'static, AssetType> { + Self::VARIANTS.iter() + } +} + +impl Union for Asset {} + +impl ReadXdr for Asset { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: AssetType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + AssetType::Native => Self::Native, + AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AlphaNum4::read_xdr(r)?), + AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AlphaNum12::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for Asset { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Native => ().write_xdr(w)?, + Self::CreditAlphanum4(v) => v.write_xdr(w)?, + Self::CreditAlphanum12(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// Price is an XDR Struct defines as: +// +// struct Price +// { +// int32 n; // numerator +// int32 d; // denominator +// }; +// +#[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 Price { + pub n: i32, + pub d: i32, +} + +impl ReadXdr for Price { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + n: i32::read_xdr(r)?, + d: i32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for Price { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.n.write_xdr(w)?; + self.d.write_xdr(w)?; + Ok(()) + }) + } +} + +// Liabilities is an XDR Struct defines as: +// +// struct Liabilities +// { +// int64 buying; +// int64 selling; +// }; +// +#[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 Liabilities { + pub buying: i64, + pub selling: i64, +} + +impl ReadXdr for Liabilities { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + buying: i64::read_xdr(r)?, + selling: i64::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for Liabilities { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.buying.write_xdr(w)?; + self.selling.write_xdr(w)?; + Ok(()) + }) + } +} + +// ThresholdIndexes is an XDR Enum defines as: +// +// enum ThresholdIndexes +// { +// THRESHOLD_MASTER_WEIGHT = 0, +// THRESHOLD_LOW = 1, +// THRESHOLD_MED = 2, +// THRESHOLD_HIGH = 3 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ThresholdIndexes { + MasterWeight = 0, + Low = 1, + Med = 2, + High = 3, +} + +impl ThresholdIndexes { + pub const VARIANTS: [ThresholdIndexes; 4] = [ + ThresholdIndexes::MasterWeight, + ThresholdIndexes::Low, + ThresholdIndexes::Med, + ThresholdIndexes::High, + ]; + pub const VARIANTS_STR: [&'static str; 4] = ["MasterWeight", "Low", "Med", "High"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::MasterWeight => "MasterWeight", + Self::Low => "Low", + Self::Med => "Med", + Self::High => "High", + } + } + + #[must_use] + pub const fn variants() -> [ThresholdIndexes; 4] { + Self::VARIANTS + } +} + +impl Name for ThresholdIndexes { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ThresholdIndexes { + fn variants() -> slice::Iter<'static, ThresholdIndexes> { + Self::VARIANTS.iter() + } +} + +impl Enum for ThresholdIndexes {} + +impl fmt::Display for ThresholdIndexes { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ThresholdIndexes { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ThresholdIndexes::MasterWeight, + 1 => ThresholdIndexes::Low, + 2 => ThresholdIndexes::Med, + 3 => ThresholdIndexes::High, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ThresholdIndexes) -> Self { + e as Self + } +} + +impl ReadXdr for ThresholdIndexes { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ThresholdIndexes { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// LedgerEntryType is an XDR Enum defines as: +// +// enum LedgerEntryType +// { +// ACCOUNT = 0, +// TRUSTLINE = 1, +// OFFER = 2, +// DATA = 3, +// CLAIMABLE_BALANCE = 4, +// LIQUIDITY_POOL = 5, +// CONTRACT_DATA = 6, +// CONTRACT_CODE = 7, +// CONFIG_SETTING = 8, +// EXPIRATION = 9 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum LedgerEntryType { + Account = 0, + Trustline = 1, + Offer = 2, + Data = 3, + ClaimableBalance = 4, + LiquidityPool = 5, + ContractData = 6, + ContractCode = 7, + ConfigSetting = 8, + Expiration = 9, +} + +impl LedgerEntryType { + pub const VARIANTS: [LedgerEntryType; 10] = [ + LedgerEntryType::Account, + LedgerEntryType::Trustline, + LedgerEntryType::Offer, + LedgerEntryType::Data, + LedgerEntryType::ClaimableBalance, + LedgerEntryType::LiquidityPool, + LedgerEntryType::ContractData, + LedgerEntryType::ContractCode, + LedgerEntryType::ConfigSetting, + LedgerEntryType::Expiration, + ]; + pub const VARIANTS_STR: [&'static str; 10] = [ + "Account", + "Trustline", + "Offer", + "Data", + "ClaimableBalance", + "LiquidityPool", + "ContractData", + "ContractCode", + "ConfigSetting", + "Expiration", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Account => "Account", + Self::Trustline => "Trustline", + Self::Offer => "Offer", + Self::Data => "Data", + Self::ClaimableBalance => "ClaimableBalance", + Self::LiquidityPool => "LiquidityPool", + Self::ContractData => "ContractData", + Self::ContractCode => "ContractCode", + Self::ConfigSetting => "ConfigSetting", + Self::Expiration => "Expiration", + } + } + + #[must_use] + pub const fn variants() -> [LedgerEntryType; 10] { + Self::VARIANTS + } +} + +impl Name for LedgerEntryType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for LedgerEntryType { + fn variants() -> slice::Iter<'static, LedgerEntryType> { + Self::VARIANTS.iter() + } +} + +impl Enum for LedgerEntryType {} + +impl fmt::Display for LedgerEntryType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for LedgerEntryType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => LedgerEntryType::Account, + 1 => LedgerEntryType::Trustline, + 2 => LedgerEntryType::Offer, + 3 => LedgerEntryType::Data, + 4 => LedgerEntryType::ClaimableBalance, + 5 => LedgerEntryType::LiquidityPool, + 6 => LedgerEntryType::ContractData, + 7 => LedgerEntryType::ContractCode, + 8 => LedgerEntryType::ConfigSetting, + 9 => LedgerEntryType::Expiration, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: LedgerEntryType) -> Self { + e as Self + } +} + +impl ReadXdr for LedgerEntryType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerEntryType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// Signer is an XDR Struct defines as: +// +// struct Signer +// { +// SignerKey key; +// uint32 weight; // really only need 1 byte +// }; +// +#[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 Signer { + pub key: SignerKey, + pub weight: u32, +} + +impl ReadXdr for Signer { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + key: SignerKey::read_xdr(r)?, + weight: u32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for Signer { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.key.write_xdr(w)?; + self.weight.write_xdr(w)?; + Ok(()) + }) + } +} + +// AccountFlags is an XDR Enum defines as: +// +// enum AccountFlags +// { // masks for each flag +// +// // Flags set on issuer accounts +// // TrustLines are created with authorized set to "false" requiring +// // the issuer to set it for each TrustLine +// AUTH_REQUIRED_FLAG = 0x1, +// // If set, the authorized flag in TrustLines can be cleared +// // otherwise, authorization cannot be revoked +// AUTH_REVOCABLE_FLAG = 0x2, +// // Once set, causes all AUTH_* flags to be read-only +// AUTH_IMMUTABLE_FLAG = 0x4, +// // Trustlines are created with clawback enabled set to "true", +// // and claimable balances created from those trustlines are created +// // with clawback enabled set to "true" +// AUTH_CLAWBACK_ENABLED_FLAG = 0x8 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum AccountFlags { + RequiredFlag = 1, + RevocableFlag = 2, + ImmutableFlag = 4, + ClawbackEnabledFlag = 8, +} + +impl AccountFlags { + pub const VARIANTS: [AccountFlags; 4] = [ + AccountFlags::RequiredFlag, + AccountFlags::RevocableFlag, + AccountFlags::ImmutableFlag, + AccountFlags::ClawbackEnabledFlag, + ]; + pub const VARIANTS_STR: [&'static str; 4] = [ + "RequiredFlag", + "RevocableFlag", + "ImmutableFlag", + "ClawbackEnabledFlag", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::RequiredFlag => "RequiredFlag", + Self::RevocableFlag => "RevocableFlag", + Self::ImmutableFlag => "ImmutableFlag", + Self::ClawbackEnabledFlag => "ClawbackEnabledFlag", + } + } + + #[must_use] + pub const fn variants() -> [AccountFlags; 4] { + Self::VARIANTS + } +} + +impl Name for AccountFlags { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for AccountFlags { + fn variants() -> slice::Iter<'static, AccountFlags> { + Self::VARIANTS.iter() + } +} + +impl Enum for AccountFlags {} + +impl fmt::Display for AccountFlags { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for AccountFlags { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 1 => AccountFlags::RequiredFlag, + 2 => AccountFlags::RevocableFlag, + 4 => AccountFlags::ImmutableFlag, + 8 => AccountFlags::ClawbackEnabledFlag, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: AccountFlags) -> Self { + e as Self + } +} + +impl ReadXdr for AccountFlags { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for AccountFlags { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// MaskAccountFlags is an XDR Const defines as: +// +// const MASK_ACCOUNT_FLAGS = 0x7; +// +pub const MASK_ACCOUNT_FLAGS: u64 = 0x7; + +// MaskAccountFlagsV17 is an XDR Const defines as: +// +// const MASK_ACCOUNT_FLAGS_V17 = 0xF; +// +pub const MASK_ACCOUNT_FLAGS_V17: u64 = 0xF; + +// MaxSigners is an XDR Const defines as: +// +// const MAX_SIGNERS = 20; +// +pub const MAX_SIGNERS: u64 = 20; + +// SponsorshipDescriptor is an XDR Typedef defines as: +// +// typedef AccountID* SponsorshipDescriptor; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct SponsorshipDescriptor(pub Option); + +impl From for Option { + #[must_use] + fn from(x: SponsorshipDescriptor) -> Self { + x.0 + } +} + +impl From> for SponsorshipDescriptor { + #[must_use] + fn from(x: Option) -> Self { + SponsorshipDescriptor(x) + } +} + +impl AsRef> for SponsorshipDescriptor { + #[must_use] + fn as_ref(&self) -> &Option { + &self.0 + } +} + +impl ReadXdr for SponsorshipDescriptor { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = Option::::read_xdr(r)?; + let v = SponsorshipDescriptor(i); + Ok(v) + }) + } +} + +impl WriteXdr for SponsorshipDescriptor { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +// AccountEntryExtensionV3 is an XDR Struct defines as: +// +// struct AccountEntryExtensionV3 +// { +// // We can use this to add more fields, or because it is first, to +// // change AccountEntryExtensionV3 into a union. +// ExtensionPoint ext; +// +// // Ledger number at which `seqNum` took on its present value. +// uint32 seqLedger; +// +// // Time at which `seqNum` took on its present value. +// TimePoint seqTime; +// }; +// +#[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 AccountEntryExtensionV3 { + pub ext: ExtensionPoint, + pub seq_ledger: u32, + pub seq_time: TimePoint, +} + +impl ReadXdr for AccountEntryExtensionV3 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + seq_ledger: u32::read_xdr(r)?, + seq_time: TimePoint::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for AccountEntryExtensionV3 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.seq_ledger.write_xdr(w)?; + self.seq_time.write_xdr(w)?; + Ok(()) + }) + } +} + +// AccountEntryExtensionV2Ext is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 3: +// AccountEntryExtensionV3 v3; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum AccountEntryExtensionV2Ext { + V0, + V3(AccountEntryExtensionV3), +} + +impl AccountEntryExtensionV2Ext { + pub const VARIANTS: [i32; 2] = [0, 3]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V3"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V3(_) => "V3", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V3(_) => 3, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for AccountEntryExtensionV2Ext { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for AccountEntryExtensionV2Ext { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for AccountEntryExtensionV2Ext { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for AccountEntryExtensionV2Ext {} + +impl ReadXdr for AccountEntryExtensionV2Ext { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 3 => Self::V3(AccountEntryExtensionV3::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for AccountEntryExtensionV2Ext { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V3(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// AccountEntryExtensionV2 is an XDR Struct defines as: +// +// struct AccountEntryExtensionV2 +// { +// uint32 numSponsored; +// uint32 numSponsoring; +// SponsorshipDescriptor signerSponsoringIDs; +// +// union switch (int v) +// { +// case 0: +// void; +// case 3: +// AccountEntryExtensionV3 v3; +// } +// ext; +// }; +// +#[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 AccountEntryExtensionV2 { + pub num_sponsored: u32, + pub num_sponsoring: u32, + pub signer_sponsoring_i_ds: VecM, + pub ext: AccountEntryExtensionV2Ext, +} + +impl ReadXdr for AccountEntryExtensionV2 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + num_sponsored: u32::read_xdr(r)?, + num_sponsoring: u32::read_xdr(r)?, + signer_sponsoring_i_ds: VecM::::read_xdr(r)?, + ext: AccountEntryExtensionV2Ext::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for AccountEntryExtensionV2 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.num_sponsored.write_xdr(w)?; + self.num_sponsoring.write_xdr(w)?; + self.signer_sponsoring_i_ds.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// AccountEntryExtensionV1Ext is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 2: +// AccountEntryExtensionV2 v2; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum AccountEntryExtensionV1Ext { + V0, + V2(AccountEntryExtensionV2), +} + +impl AccountEntryExtensionV1Ext { + pub const VARIANTS: [i32; 2] = [0, 2]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V2"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V2(_) => "V2", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V2(_) => 2, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for AccountEntryExtensionV1Ext { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for AccountEntryExtensionV1Ext { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for AccountEntryExtensionV1Ext { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for AccountEntryExtensionV1Ext {} + +impl ReadXdr for AccountEntryExtensionV1Ext { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 2 => Self::V2(AccountEntryExtensionV2::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for AccountEntryExtensionV1Ext { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V2(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// AccountEntryExtensionV1 is an XDR Struct defines as: +// +// struct AccountEntryExtensionV1 +// { +// Liabilities liabilities; +// +// union switch (int v) +// { +// case 0: +// void; +// case 2: +// AccountEntryExtensionV2 v2; +// } +// ext; +// }; +// +#[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 AccountEntryExtensionV1 { + pub liabilities: Liabilities, + pub ext: AccountEntryExtensionV1Ext, +} + +impl ReadXdr for AccountEntryExtensionV1 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + liabilities: Liabilities::read_xdr(r)?, + ext: AccountEntryExtensionV1Ext::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for AccountEntryExtensionV1 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.liabilities.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// AccountEntryExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// AccountEntryExtensionV1 v1; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum AccountEntryExt { + V0, + V1(AccountEntryExtensionV1), +} + +impl AccountEntryExt { + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V1(_) => "V1", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V1(_) => 1, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for AccountEntryExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for AccountEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for AccountEntryExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for AccountEntryExt {} + +impl ReadXdr for AccountEntryExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 1 => Self::V1(AccountEntryExtensionV1::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for AccountEntryExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// AccountEntry is an XDR Struct defines as: +// +// struct AccountEntry +// { +// AccountID accountID; // master public key for this account +// int64 balance; // in stroops +// SequenceNumber seqNum; // last sequence number used for this account +// uint32 numSubEntries; // number of sub-entries this account has +// // drives the reserve +// AccountID* inflationDest; // Account to vote for during inflation +// uint32 flags; // see AccountFlags +// +// string32 homeDomain; // can be used for reverse federation and memo lookup +// +// // fields used for signatures +// // thresholds stores unsigned bytes: [weight of master|low|medium|high] +// Thresholds thresholds; +// +// Signer signers; // possible signers for this account +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// AccountEntryExtensionV1 v1; +// } +// ext; +// }; +// +#[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 AccountEntry { + pub account_id: AccountId, + pub balance: i64, + pub seq_num: SequenceNumber, + pub num_sub_entries: u32, + pub inflation_dest: Option, + pub flags: u32, + pub home_domain: String32, + pub thresholds: Thresholds, + pub signers: VecM, + pub ext: AccountEntryExt, +} + +impl ReadXdr for AccountEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + account_id: AccountId::read_xdr(r)?, + balance: i64::read_xdr(r)?, + seq_num: SequenceNumber::read_xdr(r)?, + num_sub_entries: u32::read_xdr(r)?, + inflation_dest: Option::::read_xdr(r)?, + flags: u32::read_xdr(r)?, + home_domain: String32::read_xdr(r)?, + thresholds: Thresholds::read_xdr(r)?, + signers: VecM::::read_xdr(r)?, + ext: AccountEntryExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for AccountEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.account_id.write_xdr(w)?; + self.balance.write_xdr(w)?; + self.seq_num.write_xdr(w)?; + self.num_sub_entries.write_xdr(w)?; + self.inflation_dest.write_xdr(w)?; + self.flags.write_xdr(w)?; + self.home_domain.write_xdr(w)?; + self.thresholds.write_xdr(w)?; + self.signers.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// TrustLineFlags is an XDR Enum defines as: +// +// enum TrustLineFlags +// { +// // issuer has authorized account to perform transactions with its credit +// AUTHORIZED_FLAG = 1, +// // issuer has authorized account to maintain and reduce liabilities for its +// // credit +// AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG = 2, +// // issuer has specified that it may clawback its credit, and that claimable +// // balances created with its credit may also be clawed back +// TRUSTLINE_CLAWBACK_ENABLED_FLAG = 4 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum TrustLineFlags { + AuthorizedFlag = 1, + AuthorizedToMaintainLiabilitiesFlag = 2, + TrustlineClawbackEnabledFlag = 4, +} + +impl TrustLineFlags { + pub const VARIANTS: [TrustLineFlags; 3] = [ + TrustLineFlags::AuthorizedFlag, + TrustLineFlags::AuthorizedToMaintainLiabilitiesFlag, + TrustLineFlags::TrustlineClawbackEnabledFlag, + ]; + pub const VARIANTS_STR: [&'static str; 3] = [ + "AuthorizedFlag", + "AuthorizedToMaintainLiabilitiesFlag", + "TrustlineClawbackEnabledFlag", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::AuthorizedFlag => "AuthorizedFlag", + Self::AuthorizedToMaintainLiabilitiesFlag => "AuthorizedToMaintainLiabilitiesFlag", + Self::TrustlineClawbackEnabledFlag => "TrustlineClawbackEnabledFlag", + } + } + + #[must_use] + pub const fn variants() -> [TrustLineFlags; 3] { + Self::VARIANTS + } +} + +impl Name for TrustLineFlags { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for TrustLineFlags { + fn variants() -> slice::Iter<'static, TrustLineFlags> { + Self::VARIANTS.iter() + } +} + +impl Enum for TrustLineFlags {} + +impl fmt::Display for TrustLineFlags { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for TrustLineFlags { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 1 => TrustLineFlags::AuthorizedFlag, + 2 => TrustLineFlags::AuthorizedToMaintainLiabilitiesFlag, + 4 => TrustLineFlags::TrustlineClawbackEnabledFlag, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: TrustLineFlags) -> Self { + e as Self + } +} + +impl ReadXdr for TrustLineFlags { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for TrustLineFlags { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// MaskTrustlineFlags is an XDR Const defines as: +// +// const MASK_TRUSTLINE_FLAGS = 1; +// +pub const MASK_TRUSTLINE_FLAGS: u64 = 1; + +// MaskTrustlineFlagsV13 is an XDR Const defines as: +// +// const MASK_TRUSTLINE_FLAGS_V13 = 3; +// +pub const MASK_TRUSTLINE_FLAGS_V13: u64 = 3; + +// MaskTrustlineFlagsV17 is an XDR Const defines as: +// +// const MASK_TRUSTLINE_FLAGS_V17 = 7; +// +pub const MASK_TRUSTLINE_FLAGS_V17: u64 = 7; + +// LiquidityPoolType is an XDR Enum defines as: +// +// enum LiquidityPoolType +// { +// LIQUIDITY_POOL_CONSTANT_PRODUCT = 0 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum LiquidityPoolType { + LiquidityPoolConstantProduct = 0, +} + +impl LiquidityPoolType { + pub const VARIANTS: [LiquidityPoolType; 1] = [LiquidityPoolType::LiquidityPoolConstantProduct]; + pub const VARIANTS_STR: [&'static str; 1] = ["LiquidityPoolConstantProduct"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::LiquidityPoolConstantProduct => "LiquidityPoolConstantProduct", + } + } + + #[must_use] + pub const fn variants() -> [LiquidityPoolType; 1] { + Self::VARIANTS + } +} + +impl Name for LiquidityPoolType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for LiquidityPoolType { + fn variants() -> slice::Iter<'static, LiquidityPoolType> { + Self::VARIANTS.iter() + } +} + +impl Enum for LiquidityPoolType {} + +impl fmt::Display for LiquidityPoolType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for LiquidityPoolType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => LiquidityPoolType::LiquidityPoolConstantProduct, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: LiquidityPoolType) -> Self { + e as Self + } +} + +impl ReadXdr for LiquidityPoolType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for LiquidityPoolType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// TrustLineAsset is an XDR Union defines as: +// +// union TrustLineAsset switch (AssetType type) +// { +// case ASSET_TYPE_NATIVE: // Not credit +// void; +// +// case ASSET_TYPE_CREDIT_ALPHANUM4: +// AlphaNum4 alphaNum4; +// +// case ASSET_TYPE_CREDIT_ALPHANUM12: +// AlphaNum12 alphaNum12; +// +// case ASSET_TYPE_POOL_SHARE: +// PoolID liquidityPoolID; +// +// // add other asset types here in the future +// }; +// +// union with discriminant AssetType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum TrustLineAsset { + Native, + CreditAlphanum4(AlphaNum4), + CreditAlphanum12(AlphaNum12), + PoolShare(PoolId), +} + +impl TrustLineAsset { + pub const VARIANTS: [AssetType; 4] = [ + AssetType::Native, + AssetType::CreditAlphanum4, + AssetType::CreditAlphanum12, + AssetType::PoolShare, + ]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Native", "CreditAlphanum4", "CreditAlphanum12", "PoolShare"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Native => "Native", + Self::CreditAlphanum4(_) => "CreditAlphanum4", + Self::CreditAlphanum12(_) => "CreditAlphanum12", + Self::PoolShare(_) => "PoolShare", + } + } + + #[must_use] + pub const fn discriminant(&self) -> AssetType { + #[allow(clippy::match_same_arms)] + match self { + Self::Native => AssetType::Native, + Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, + Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, + Self::PoolShare(_) => AssetType::PoolShare, + } + } + + #[must_use] + pub const fn variants() -> [AssetType; 4] { + Self::VARIANTS + } +} + +impl Name for TrustLineAsset { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for TrustLineAsset { + #[must_use] + fn discriminant(&self) -> AssetType { + Self::discriminant(self) + } +} + +impl Variants for TrustLineAsset { + fn variants() -> slice::Iter<'static, AssetType> { + Self::VARIANTS.iter() + } +} + +impl Union for TrustLineAsset {} + +impl ReadXdr for TrustLineAsset { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: AssetType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + AssetType::Native => Self::Native, + AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AlphaNum4::read_xdr(r)?), + AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AlphaNum12::read_xdr(r)?), + AssetType::PoolShare => Self::PoolShare(PoolId::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for TrustLineAsset { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Native => ().write_xdr(w)?, + Self::CreditAlphanum4(v) => v.write_xdr(w)?, + Self::CreditAlphanum12(v) => v.write_xdr(w)?, + Self::PoolShare(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// TrustLineEntryExtensionV2Ext is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum TrustLineEntryExtensionV2Ext { + V0, +} + +impl TrustLineEntryExtensionV2Ext { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + } + } + + #[must_use] + pub const fn variants() -> [i32; 1] { + Self::VARIANTS + } +} + +impl Name for TrustLineEntryExtensionV2Ext { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for TrustLineEntryExtensionV2Ext { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for TrustLineEntryExtensionV2Ext { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for TrustLineEntryExtensionV2Ext {} + +impl ReadXdr for TrustLineEntryExtensionV2Ext { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for TrustLineEntryExtensionV2Ext { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// TrustLineEntryExtensionV2 is an XDR Struct defines as: +// +// struct TrustLineEntryExtensionV2 +// { +// int32 liquidityPoolUseCount; +// +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +// +#[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 TrustLineEntryExtensionV2 { + pub liquidity_pool_use_count: i32, + pub ext: TrustLineEntryExtensionV2Ext, +} + +impl ReadXdr for TrustLineEntryExtensionV2 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + liquidity_pool_use_count: i32::read_xdr(r)?, + ext: TrustLineEntryExtensionV2Ext::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for TrustLineEntryExtensionV2 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.liquidity_pool_use_count.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// TrustLineEntryV1Ext is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 2: +// TrustLineEntryExtensionV2 v2; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum TrustLineEntryV1Ext { + V0, + V2(TrustLineEntryExtensionV2), +} + +impl TrustLineEntryV1Ext { + pub const VARIANTS: [i32; 2] = [0, 2]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V2"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V2(_) => "V2", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V2(_) => 2, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for TrustLineEntryV1Ext { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for TrustLineEntryV1Ext { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for TrustLineEntryV1Ext { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for TrustLineEntryV1Ext {} + +impl ReadXdr for TrustLineEntryV1Ext { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 2 => Self::V2(TrustLineEntryExtensionV2::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for TrustLineEntryV1Ext { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V2(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// TrustLineEntryV1 is an XDR NestedStruct defines as: +// +// struct +// { +// Liabilities liabilities; +// +// union switch (int v) +// { +// case 0: +// void; +// case 2: +// TrustLineEntryExtensionV2 v2; +// } +// ext; +// } +// +#[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 TrustLineEntryV1 { + pub liabilities: Liabilities, + pub ext: TrustLineEntryV1Ext, +} + +impl ReadXdr for TrustLineEntryV1 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + liabilities: Liabilities::read_xdr(r)?, + ext: TrustLineEntryV1Ext::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for TrustLineEntryV1 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.liabilities.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// TrustLineEntryExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// struct +// { +// Liabilities liabilities; +// +// union switch (int v) +// { +// case 0: +// void; +// case 2: +// TrustLineEntryExtensionV2 v2; +// } +// ext; +// } v1; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum TrustLineEntryExt { + V0, + V1(TrustLineEntryV1), +} + +impl TrustLineEntryExt { + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V1(_) => "V1", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V1(_) => 1, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for TrustLineEntryExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for TrustLineEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for TrustLineEntryExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for TrustLineEntryExt {} + +impl ReadXdr for TrustLineEntryExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 1 => Self::V1(TrustLineEntryV1::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for TrustLineEntryExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// TrustLineEntry is an XDR Struct defines as: +// +// struct TrustLineEntry +// { +// AccountID accountID; // account this trustline belongs to +// TrustLineAsset asset; // type of asset (with issuer) +// int64 balance; // how much of this asset the user has. +// // Asset defines the unit for this; +// +// int64 limit; // balance cannot be above this +// uint32 flags; // see TrustLineFlags +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// struct +// { +// Liabilities liabilities; +// +// union switch (int v) +// { +// case 0: +// void; +// case 2: +// TrustLineEntryExtensionV2 v2; +// } +// ext; +// } v1; +// } +// ext; +// }; +// +#[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 TrustLineEntry { + pub account_id: AccountId, + pub asset: TrustLineAsset, + pub balance: i64, + pub limit: i64, + pub flags: u32, + pub ext: TrustLineEntryExt, +} + +impl ReadXdr for TrustLineEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + account_id: AccountId::read_xdr(r)?, + asset: TrustLineAsset::read_xdr(r)?, + balance: i64::read_xdr(r)?, + limit: i64::read_xdr(r)?, + flags: u32::read_xdr(r)?, + ext: TrustLineEntryExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for TrustLineEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.account_id.write_xdr(w)?; + self.asset.write_xdr(w)?; + self.balance.write_xdr(w)?; + self.limit.write_xdr(w)?; + self.flags.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// OfferEntryFlags is an XDR Enum defines as: +// +// enum OfferEntryFlags +// { +// // an offer with this flag will not act on and take a reverse offer of equal +// // price +// PASSIVE_FLAG = 1 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum OfferEntryFlags { + PassiveFlag = 1, +} + +impl OfferEntryFlags { + pub const VARIANTS: [OfferEntryFlags; 1] = [OfferEntryFlags::PassiveFlag]; + pub const VARIANTS_STR: [&'static str; 1] = ["PassiveFlag"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::PassiveFlag => "PassiveFlag", + } + } + + #[must_use] + pub const fn variants() -> [OfferEntryFlags; 1] { + Self::VARIANTS + } +} + +impl Name for OfferEntryFlags { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for OfferEntryFlags { + fn variants() -> slice::Iter<'static, OfferEntryFlags> { + Self::VARIANTS.iter() + } +} + +impl Enum for OfferEntryFlags {} + +impl fmt::Display for OfferEntryFlags { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for OfferEntryFlags { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 1 => OfferEntryFlags::PassiveFlag, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: OfferEntryFlags) -> Self { + e as Self + } +} + +impl ReadXdr for OfferEntryFlags { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for OfferEntryFlags { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// MaskOfferentryFlags is an XDR Const defines as: +// +// const MASK_OFFERENTRY_FLAGS = 1; +// +pub const MASK_OFFERENTRY_FLAGS: u64 = 1; + +// OfferEntryExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum OfferEntryExt { + V0, +} + +impl OfferEntryExt { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + } + } + + #[must_use] + pub const fn variants() -> [i32; 1] { + Self::VARIANTS + } +} + +impl Name for OfferEntryExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for OfferEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for OfferEntryExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for OfferEntryExt {} + +impl ReadXdr for OfferEntryExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for OfferEntryExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// OfferEntry is an XDR Struct defines as: +// +// struct OfferEntry +// { +// AccountID sellerID; +// int64 offerID; +// Asset selling; // A +// Asset buying; // B +// int64 amount; // amount of A +// +// /* price for this offer: +// price of A in terms of B +// price=AmountB/AmountA=priceNumerator/priceDenominator +// price is after fees +// */ +// Price price; +// uint32 flags; // see OfferEntryFlags +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +// +#[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 OfferEntry { + pub seller_id: AccountId, + pub offer_id: i64, + pub selling: Asset, + pub buying: Asset, + pub amount: i64, + pub price: Price, + pub flags: u32, + pub ext: OfferEntryExt, +} + +impl ReadXdr for OfferEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + seller_id: AccountId::read_xdr(r)?, + offer_id: i64::read_xdr(r)?, + selling: Asset::read_xdr(r)?, + buying: Asset::read_xdr(r)?, + amount: i64::read_xdr(r)?, + price: Price::read_xdr(r)?, + flags: u32::read_xdr(r)?, + ext: OfferEntryExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for OfferEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.seller_id.write_xdr(w)?; + self.offer_id.write_xdr(w)?; + self.selling.write_xdr(w)?; + self.buying.write_xdr(w)?; + self.amount.write_xdr(w)?; + self.price.write_xdr(w)?; + self.flags.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// DataEntryExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum DataEntryExt { + V0, +} + +impl DataEntryExt { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + } + } + + #[must_use] + pub const fn variants() -> [i32; 1] { + Self::VARIANTS + } +} + +impl Name for DataEntryExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for DataEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for DataEntryExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for DataEntryExt {} + +impl ReadXdr for DataEntryExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for DataEntryExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// DataEntry is an XDR Struct defines as: +// +// struct DataEntry +// { +// AccountID accountID; // account this data belongs to +// string64 dataName; +// DataValue dataValue; +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +// +#[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 DataEntry { + pub account_id: AccountId, + pub data_name: String64, + pub data_value: DataValue, + pub ext: DataEntryExt, +} + +impl ReadXdr for DataEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + account_id: AccountId::read_xdr(r)?, + data_name: String64::read_xdr(r)?, + data_value: DataValue::read_xdr(r)?, + ext: DataEntryExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for DataEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.account_id.write_xdr(w)?; + self.data_name.write_xdr(w)?; + self.data_value.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// ClaimPredicateType is an XDR Enum defines as: +// +// enum ClaimPredicateType +// { +// CLAIM_PREDICATE_UNCONDITIONAL = 0, +// CLAIM_PREDICATE_AND = 1, +// CLAIM_PREDICATE_OR = 2, +// CLAIM_PREDICATE_NOT = 3, +// CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME = 4, +// CLAIM_PREDICATE_BEFORE_RELATIVE_TIME = 5 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ClaimPredicateType { + Unconditional = 0, + And = 1, + Or = 2, + Not = 3, + BeforeAbsoluteTime = 4, + BeforeRelativeTime = 5, +} + +impl ClaimPredicateType { + pub const VARIANTS: [ClaimPredicateType; 6] = [ + ClaimPredicateType::Unconditional, + ClaimPredicateType::And, + ClaimPredicateType::Or, + ClaimPredicateType::Not, + ClaimPredicateType::BeforeAbsoluteTime, + ClaimPredicateType::BeforeRelativeTime, + ]; + pub const VARIANTS_STR: [&'static str; 6] = [ + "Unconditional", + "And", + "Or", + "Not", + "BeforeAbsoluteTime", + "BeforeRelativeTime", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Unconditional => "Unconditional", + Self::And => "And", + Self::Or => "Or", + Self::Not => "Not", + Self::BeforeAbsoluteTime => "BeforeAbsoluteTime", + Self::BeforeRelativeTime => "BeforeRelativeTime", + } + } + + #[must_use] + pub const fn variants() -> [ClaimPredicateType; 6] { + Self::VARIANTS + } +} + +impl Name for ClaimPredicateType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ClaimPredicateType { + fn variants() -> slice::Iter<'static, ClaimPredicateType> { + Self::VARIANTS.iter() + } +} + +impl Enum for ClaimPredicateType {} + +impl fmt::Display for ClaimPredicateType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ClaimPredicateType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ClaimPredicateType::Unconditional, + 1 => ClaimPredicateType::And, + 2 => ClaimPredicateType::Or, + 3 => ClaimPredicateType::Not, + 4 => ClaimPredicateType::BeforeAbsoluteTime, + 5 => ClaimPredicateType::BeforeRelativeTime, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ClaimPredicateType) -> Self { + e as Self + } +} + +impl ReadXdr for ClaimPredicateType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimPredicateType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ClaimPredicate is an XDR Union defines as: +// +// union ClaimPredicate switch (ClaimPredicateType type) +// { +// case CLAIM_PREDICATE_UNCONDITIONAL: +// void; +// case CLAIM_PREDICATE_AND: +// ClaimPredicate andPredicates<2>; +// case CLAIM_PREDICATE_OR: +// ClaimPredicate orPredicates<2>; +// case CLAIM_PREDICATE_NOT: +// ClaimPredicate* notPredicate; +// case CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME: +// int64 absBefore; // Predicate will be true if closeTime < absBefore +// case CLAIM_PREDICATE_BEFORE_RELATIVE_TIME: +// int64 relBefore; // Seconds since closeTime of the ledger in which the +// // ClaimableBalanceEntry was created +// }; +// +// union with discriminant ClaimPredicateType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum ClaimPredicate { + Unconditional, + And(VecM), + Or(VecM), + Not(Option>), + BeforeAbsoluteTime(i64), + BeforeRelativeTime(i64), +} + +impl ClaimPredicate { + pub const VARIANTS: [ClaimPredicateType; 6] = [ + ClaimPredicateType::Unconditional, + ClaimPredicateType::And, + ClaimPredicateType::Or, + ClaimPredicateType::Not, + ClaimPredicateType::BeforeAbsoluteTime, + ClaimPredicateType::BeforeRelativeTime, + ]; + pub const VARIANTS_STR: [&'static str; 6] = [ + "Unconditional", + "And", + "Or", + "Not", + "BeforeAbsoluteTime", + "BeforeRelativeTime", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Unconditional => "Unconditional", + Self::And(_) => "And", + Self::Or(_) => "Or", + Self::Not(_) => "Not", + Self::BeforeAbsoluteTime(_) => "BeforeAbsoluteTime", + Self::BeforeRelativeTime(_) => "BeforeRelativeTime", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ClaimPredicateType { + #[allow(clippy::match_same_arms)] + match self { + Self::Unconditional => ClaimPredicateType::Unconditional, + Self::And(_) => ClaimPredicateType::And, + Self::Or(_) => ClaimPredicateType::Or, + Self::Not(_) => ClaimPredicateType::Not, + Self::BeforeAbsoluteTime(_) => ClaimPredicateType::BeforeAbsoluteTime, + Self::BeforeRelativeTime(_) => ClaimPredicateType::BeforeRelativeTime, + } + } + + #[must_use] + pub const fn variants() -> [ClaimPredicateType; 6] { + Self::VARIANTS + } +} + +impl Name for ClaimPredicate { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for ClaimPredicate { + #[must_use] + fn discriminant(&self) -> ClaimPredicateType { + Self::discriminant(self) + } +} + +impl Variants for ClaimPredicate { + fn variants() -> slice::Iter<'static, ClaimPredicateType> { + Self::VARIANTS.iter() + } +} + +impl Union for ClaimPredicate {} + +impl ReadXdr for ClaimPredicate { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: ClaimPredicateType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ClaimPredicateType::Unconditional => Self::Unconditional, + ClaimPredicateType::And => Self::And(VecM::::read_xdr(r)?), + ClaimPredicateType::Or => Self::Or(VecM::::read_xdr(r)?), + ClaimPredicateType::Not => Self::Not(Option::>::read_xdr(r)?), + ClaimPredicateType::BeforeAbsoluteTime => { + Self::BeforeAbsoluteTime(i64::read_xdr(r)?) + } + ClaimPredicateType::BeforeRelativeTime => { + Self::BeforeRelativeTime(i64::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimPredicate { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Unconditional => ().write_xdr(w)?, + Self::And(v) => v.write_xdr(w)?, + Self::Or(v) => v.write_xdr(w)?, + Self::Not(v) => v.write_xdr(w)?, + Self::BeforeAbsoluteTime(v) => v.write_xdr(w)?, + Self::BeforeRelativeTime(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// ClaimantType is an XDR Enum defines as: +// +// enum ClaimantType +// { +// CLAIMANT_TYPE_V0 = 0 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ClaimantType { + ClaimantTypeV0 = 0, +} + +impl ClaimantType { + pub const VARIANTS: [ClaimantType; 1] = [ClaimantType::ClaimantTypeV0]; + pub const VARIANTS_STR: [&'static str; 1] = ["ClaimantTypeV0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ClaimantTypeV0 => "ClaimantTypeV0", + } + } + + #[must_use] + pub const fn variants() -> [ClaimantType; 1] { + Self::VARIANTS + } +} + +impl Name for ClaimantType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ClaimantType { + fn variants() -> slice::Iter<'static, ClaimantType> { + Self::VARIANTS.iter() + } +} + +impl Enum for ClaimantType {} + +impl fmt::Display for ClaimantType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ClaimantType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ClaimantType::ClaimantTypeV0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ClaimantType) -> Self { + e as Self + } +} + +impl ReadXdr for ClaimantType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimantType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ClaimantV0 is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID destination; // The account that can use this condition +// ClaimPredicate predicate; // Claimable if predicate is true +// } +// +#[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 ClaimantV0 { + pub destination: AccountId, + pub predicate: ClaimPredicate, +} + +impl ReadXdr for ClaimantV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + destination: AccountId::read_xdr(r)?, + predicate: ClaimPredicate::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ClaimantV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.destination.write_xdr(w)?; + self.predicate.write_xdr(w)?; + Ok(()) + }) + } +} + +// Claimant is an XDR Union defines as: +// +// union Claimant switch (ClaimantType type) +// { +// case CLAIMANT_TYPE_V0: +// struct +// { +// AccountID destination; // The account that can use this condition +// ClaimPredicate predicate; // Claimable if predicate is true +// } v0; +// }; +// +// union with discriminant ClaimantType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum Claimant { + ClaimantTypeV0(ClaimantV0), +} + +impl Claimant { + pub const VARIANTS: [ClaimantType; 1] = [ClaimantType::ClaimantTypeV0]; + pub const VARIANTS_STR: [&'static str; 1] = ["ClaimantTypeV0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ClaimantTypeV0(_) => "ClaimantTypeV0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ClaimantType { + #[allow(clippy::match_same_arms)] + match self { + Self::ClaimantTypeV0(_) => ClaimantType::ClaimantTypeV0, + } + } + + #[must_use] + pub const fn variants() -> [ClaimantType; 1] { + Self::VARIANTS + } +} + +impl Name for Claimant { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for Claimant { + #[must_use] + fn discriminant(&self) -> ClaimantType { + Self::discriminant(self) + } +} + +impl Variants for Claimant { + fn variants() -> slice::Iter<'static, ClaimantType> { + Self::VARIANTS.iter() + } +} + +impl Union for Claimant {} + +impl ReadXdr for Claimant { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: ClaimantType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ClaimantType::ClaimantTypeV0 => Self::ClaimantTypeV0(ClaimantV0::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for Claimant { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::ClaimantTypeV0(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// ClaimableBalanceIdType is an XDR Enum defines as: +// +// enum ClaimableBalanceIDType +// { +// CLAIMABLE_BALANCE_ID_TYPE_V0 = 0 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ClaimableBalanceIdType { + ClaimableBalanceIdTypeV0 = 0, +} + +impl ClaimableBalanceIdType { + pub const VARIANTS: [ClaimableBalanceIdType; 1] = + [ClaimableBalanceIdType::ClaimableBalanceIdTypeV0]; + pub const VARIANTS_STR: [&'static str; 1] = ["ClaimableBalanceIdTypeV0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ClaimableBalanceIdTypeV0 => "ClaimableBalanceIdTypeV0", + } + } + + #[must_use] + pub const fn variants() -> [ClaimableBalanceIdType; 1] { + Self::VARIANTS + } +} + +impl Name for ClaimableBalanceIdType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ClaimableBalanceIdType { + fn variants() -> slice::Iter<'static, ClaimableBalanceIdType> { + Self::VARIANTS.iter() + } +} + +impl Enum for ClaimableBalanceIdType {} + +impl fmt::Display for ClaimableBalanceIdType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ClaimableBalanceIdType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ClaimableBalanceIdType::ClaimableBalanceIdTypeV0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ClaimableBalanceIdType) -> Self { + e as Self + } +} + +impl ReadXdr for ClaimableBalanceIdType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimableBalanceIdType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ClaimableBalanceId is an XDR Union defines as: +// +// union ClaimableBalanceID switch (ClaimableBalanceIDType type) +// { +// case CLAIMABLE_BALANCE_ID_TYPE_V0: +// Hash v0; +// }; +// +// union with discriminant ClaimableBalanceIdType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum ClaimableBalanceId { + ClaimableBalanceIdTypeV0(Hash), +} + +impl ClaimableBalanceId { + pub const VARIANTS: [ClaimableBalanceIdType; 1] = + [ClaimableBalanceIdType::ClaimableBalanceIdTypeV0]; + pub const VARIANTS_STR: [&'static str; 1] = ["ClaimableBalanceIdTypeV0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ClaimableBalanceIdTypeV0(_) => "ClaimableBalanceIdTypeV0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ClaimableBalanceIdType { + #[allow(clippy::match_same_arms)] + match self { + Self::ClaimableBalanceIdTypeV0(_) => ClaimableBalanceIdType::ClaimableBalanceIdTypeV0, + } + } + + #[must_use] + pub const fn variants() -> [ClaimableBalanceIdType; 1] { + Self::VARIANTS + } +} + +impl Name for ClaimableBalanceId { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for ClaimableBalanceId { + #[must_use] + fn discriminant(&self) -> ClaimableBalanceIdType { + Self::discriminant(self) + } +} + +impl Variants for ClaimableBalanceId { + fn variants() -> slice::Iter<'static, ClaimableBalanceIdType> { + Self::VARIANTS.iter() + } +} + +impl Union for ClaimableBalanceId {} + +impl ReadXdr for ClaimableBalanceId { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: ClaimableBalanceIdType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ClaimableBalanceIdType::ClaimableBalanceIdTypeV0 => { + Self::ClaimableBalanceIdTypeV0(Hash::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimableBalanceId { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::ClaimableBalanceIdTypeV0(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// ClaimableBalanceFlags is an XDR Enum defines as: +// +// enum ClaimableBalanceFlags +// { +// // If set, the issuer account of the asset held by the claimable balance may +// // clawback the claimable balance +// CLAIMABLE_BALANCE_CLAWBACK_ENABLED_FLAG = 0x1 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ClaimableBalanceFlags { + ClaimableBalanceClawbackEnabledFlag = 1, +} + +impl ClaimableBalanceFlags { + pub const VARIANTS: [ClaimableBalanceFlags; 1] = + [ClaimableBalanceFlags::ClaimableBalanceClawbackEnabledFlag]; + pub const VARIANTS_STR: [&'static str; 1] = ["ClaimableBalanceClawbackEnabledFlag"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ClaimableBalanceClawbackEnabledFlag => "ClaimableBalanceClawbackEnabledFlag", + } + } + + #[must_use] + pub const fn variants() -> [ClaimableBalanceFlags; 1] { + Self::VARIANTS + } +} + +impl Name for ClaimableBalanceFlags { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ClaimableBalanceFlags { + fn variants() -> slice::Iter<'static, ClaimableBalanceFlags> { + Self::VARIANTS.iter() + } +} + +impl Enum for ClaimableBalanceFlags {} + +impl fmt::Display for ClaimableBalanceFlags { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ClaimableBalanceFlags { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 1 => ClaimableBalanceFlags::ClaimableBalanceClawbackEnabledFlag, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ClaimableBalanceFlags) -> Self { + e as Self + } +} + +impl ReadXdr for ClaimableBalanceFlags { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimableBalanceFlags { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// MaskClaimableBalanceFlags is an XDR Const defines as: +// +// const MASK_CLAIMABLE_BALANCE_FLAGS = 0x1; +// +pub const MASK_CLAIMABLE_BALANCE_FLAGS: u64 = 0x1; + +// ClaimableBalanceEntryExtensionV1Ext is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum ClaimableBalanceEntryExtensionV1Ext { + V0, +} + +impl ClaimableBalanceEntryExtensionV1Ext { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + } + } + + #[must_use] + pub const fn variants() -> [i32; 1] { + Self::VARIANTS + } +} + +impl Name for ClaimableBalanceEntryExtensionV1Ext { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for ClaimableBalanceEntryExtensionV1Ext { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for ClaimableBalanceEntryExtensionV1Ext { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for ClaimableBalanceEntryExtensionV1Ext {} + +impl ReadXdr for ClaimableBalanceEntryExtensionV1Ext { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimableBalanceEntryExtensionV1Ext { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// ClaimableBalanceEntryExtensionV1 is an XDR Struct defines as: +// +// struct ClaimableBalanceEntryExtensionV1 +// { +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// +// uint32 flags; // see ClaimableBalanceFlags +// }; +// +#[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 ClaimableBalanceEntryExtensionV1 { + pub ext: ClaimableBalanceEntryExtensionV1Ext, + pub flags: u32, +} + +impl ReadXdr for ClaimableBalanceEntryExtensionV1 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ext: ClaimableBalanceEntryExtensionV1Ext::read_xdr(r)?, + flags: u32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ClaimableBalanceEntryExtensionV1 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.flags.write_xdr(w)?; + Ok(()) + }) + } +} + +// ClaimableBalanceEntryExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// ClaimableBalanceEntryExtensionV1 v1; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum ClaimableBalanceEntryExt { + V0, + V1(ClaimableBalanceEntryExtensionV1), +} + +impl ClaimableBalanceEntryExt { + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V1(_) => "V1", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V1(_) => 1, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for ClaimableBalanceEntryExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for ClaimableBalanceEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for ClaimableBalanceEntryExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for ClaimableBalanceEntryExt {} + +impl ReadXdr for ClaimableBalanceEntryExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 1 => Self::V1(ClaimableBalanceEntryExtensionV1::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for ClaimableBalanceEntryExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// ClaimableBalanceEntry is an XDR Struct defines as: +// +// struct ClaimableBalanceEntry +// { +// // Unique identifier for this ClaimableBalanceEntry +// ClaimableBalanceID balanceID; +// +// // List of claimants with associated predicate +// Claimant claimants<10>; +// +// // Any asset including native +// Asset asset; +// +// // Amount of asset +// int64 amount; +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// ClaimableBalanceEntryExtensionV1 v1; +// } +// ext; +// }; +// +#[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 ClaimableBalanceEntry { + pub balance_id: ClaimableBalanceId, + pub claimants: VecM, + pub asset: Asset, + pub amount: i64, + pub ext: ClaimableBalanceEntryExt, +} + +impl ReadXdr for ClaimableBalanceEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + balance_id: ClaimableBalanceId::read_xdr(r)?, + claimants: VecM::::read_xdr(r)?, + asset: Asset::read_xdr(r)?, + amount: i64::read_xdr(r)?, + ext: ClaimableBalanceEntryExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ClaimableBalanceEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.balance_id.write_xdr(w)?; + self.claimants.write_xdr(w)?; + self.asset.write_xdr(w)?; + self.amount.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// LiquidityPoolConstantProductParameters is an XDR Struct defines as: +// +// struct LiquidityPoolConstantProductParameters +// { +// Asset assetA; // assetA < assetB +// Asset assetB; +// int32 fee; // Fee is in basis points, so the actual rate is (fee/100)% +// }; +// +#[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 LiquidityPoolConstantProductParameters { + pub asset_a: Asset, + pub asset_b: Asset, + pub fee: i32, +} + +impl ReadXdr for LiquidityPoolConstantProductParameters { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + asset_a: Asset::read_xdr(r)?, + asset_b: Asset::read_xdr(r)?, + fee: i32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LiquidityPoolConstantProductParameters { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.asset_a.write_xdr(w)?; + self.asset_b.write_xdr(w)?; + self.fee.write_xdr(w)?; + Ok(()) + }) + } +} + +// LiquidityPoolEntryConstantProduct is an XDR NestedStruct defines as: +// +// struct +// { +// LiquidityPoolConstantProductParameters params; +// +// int64 reserveA; // amount of A in the pool +// int64 reserveB; // amount of B in the pool +// int64 totalPoolShares; // total number of pool shares issued +// int64 poolSharesTrustLineCount; // number of trust lines for the +// // associated pool shares +// } +// +#[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 LiquidityPoolEntryConstantProduct { + pub params: LiquidityPoolConstantProductParameters, + pub reserve_a: i64, + pub reserve_b: i64, + pub total_pool_shares: i64, + pub pool_shares_trust_line_count: i64, +} + +impl ReadXdr for LiquidityPoolEntryConstantProduct { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + params: LiquidityPoolConstantProductParameters::read_xdr(r)?, + reserve_a: i64::read_xdr(r)?, + reserve_b: i64::read_xdr(r)?, + total_pool_shares: i64::read_xdr(r)?, + pool_shares_trust_line_count: i64::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LiquidityPoolEntryConstantProduct { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.params.write_xdr(w)?; + self.reserve_a.write_xdr(w)?; + self.reserve_b.write_xdr(w)?; + self.total_pool_shares.write_xdr(w)?; + self.pool_shares_trust_line_count.write_xdr(w)?; + Ok(()) + }) + } +} + +// LiquidityPoolEntryBody is an XDR NestedUnion defines as: +// +// union switch (LiquidityPoolType type) +// { +// case LIQUIDITY_POOL_CONSTANT_PRODUCT: +// struct +// { +// LiquidityPoolConstantProductParameters params; +// +// int64 reserveA; // amount of A in the pool +// int64 reserveB; // amount of B in the pool +// int64 totalPoolShares; // total number of pool shares issued +// int64 poolSharesTrustLineCount; // number of trust lines for the +// // associated pool shares +// } constantProduct; +// } +// +// union with discriminant LiquidityPoolType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LiquidityPoolEntryBody { + LiquidityPoolConstantProduct(LiquidityPoolEntryConstantProduct), +} + +impl LiquidityPoolEntryBody { + pub const VARIANTS: [LiquidityPoolType; 1] = [LiquidityPoolType::LiquidityPoolConstantProduct]; + pub const VARIANTS_STR: [&'static str; 1] = ["LiquidityPoolConstantProduct"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::LiquidityPoolConstantProduct(_) => "LiquidityPoolConstantProduct", + } + } + + #[must_use] + pub const fn discriminant(&self) -> LiquidityPoolType { + #[allow(clippy::match_same_arms)] + match self { + Self::LiquidityPoolConstantProduct(_) => { + LiquidityPoolType::LiquidityPoolConstantProduct + } + } + } + + #[must_use] + pub const fn variants() -> [LiquidityPoolType; 1] { + Self::VARIANTS + } +} + +impl Name for LiquidityPoolEntryBody { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LiquidityPoolEntryBody { + #[must_use] + fn discriminant(&self) -> LiquidityPoolType { + Self::discriminant(self) + } +} + +impl Variants for LiquidityPoolEntryBody { + fn variants() -> slice::Iter<'static, LiquidityPoolType> { + Self::VARIANTS.iter() + } +} + +impl Union for LiquidityPoolEntryBody {} + +impl ReadXdr for LiquidityPoolEntryBody { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: LiquidityPoolType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + LiquidityPoolType::LiquidityPoolConstantProduct => { + Self::LiquidityPoolConstantProduct(LiquidityPoolEntryConstantProduct::read_xdr( + r, + )?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LiquidityPoolEntryBody { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::LiquidityPoolConstantProduct(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// LiquidityPoolEntry is an XDR Struct defines as: +// +// struct LiquidityPoolEntry +// { +// PoolID liquidityPoolID; +// +// union switch (LiquidityPoolType type) +// { +// case LIQUIDITY_POOL_CONSTANT_PRODUCT: +// struct +// { +// LiquidityPoolConstantProductParameters params; +// +// int64 reserveA; // amount of A in the pool +// int64 reserveB; // amount of B in the pool +// int64 totalPoolShares; // total number of pool shares issued +// int64 poolSharesTrustLineCount; // number of trust lines for the +// // associated pool shares +// } constantProduct; +// } +// body; +// }; +// +#[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 LiquidityPoolEntry { + pub liquidity_pool_id: PoolId, + pub body: LiquidityPoolEntryBody, +} + +impl ReadXdr for LiquidityPoolEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + liquidity_pool_id: PoolId::read_xdr(r)?, + body: LiquidityPoolEntryBody::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LiquidityPoolEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.liquidity_pool_id.write_xdr(w)?; + self.body.write_xdr(w)?; + Ok(()) + }) + } +} + +// ContractDataDurability is an XDR Enum defines as: +// +// enum ContractDataDurability { +// TEMPORARY = 0, +// PERSISTENT = 1 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ContractDataDurability { + Temporary = 0, + Persistent = 1, +} + +impl ContractDataDurability { + pub const VARIANTS: [ContractDataDurability; 2] = [ + ContractDataDurability::Temporary, + ContractDataDurability::Persistent, + ]; + pub const VARIANTS_STR: [&'static str; 2] = ["Temporary", "Persistent"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Temporary => "Temporary", + Self::Persistent => "Persistent", + } + } + + #[must_use] + pub const fn variants() -> [ContractDataDurability; 2] { + Self::VARIANTS + } +} + +impl Name for ContractDataDurability { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ContractDataDurability { + fn variants() -> slice::Iter<'static, ContractDataDurability> { + Self::VARIANTS.iter() + } +} + +impl Enum for ContractDataDurability {} + +impl fmt::Display for ContractDataDurability { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ContractDataDurability { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ContractDataDurability::Temporary, + 1 => ContractDataDurability::Persistent, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ContractDataDurability) -> Self { + e as Self + } +} + +impl ReadXdr for ContractDataDurability { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ContractDataDurability { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ContractDataEntry is an XDR Struct defines as: +// +// struct ContractDataEntry { +// ExtensionPoint ext; +// +// SCAddress contract; +// SCVal key; +// ContractDataDurability durability; +// SCVal val; +// }; +// +#[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 ContractDataEntry { + pub ext: ExtensionPoint, + pub contract: ScAddress, + pub key: ScVal, + pub durability: ContractDataDurability, + pub val: ScVal, +} + +impl ReadXdr for ContractDataEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + contract: ScAddress::read_xdr(r)?, + key: ScVal::read_xdr(r)?, + durability: ContractDataDurability::read_xdr(r)?, + val: ScVal::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ContractDataEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.contract.write_xdr(w)?; + self.key.write_xdr(w)?; + self.durability.write_xdr(w)?; + self.val.write_xdr(w)?; + Ok(()) + }) + } +} + +// ContractCodeEntry is an XDR Struct defines as: +// +// struct ContractCodeEntry { +// ExtensionPoint ext; +// +// Hash hash; +// opaque code<>; +// }; +// +#[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 ContractCodeEntry { + pub ext: ExtensionPoint, + pub hash: Hash, + pub code: BytesM, +} + +impl ReadXdr for ContractCodeEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + hash: Hash::read_xdr(r)?, + code: BytesM::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ContractCodeEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.hash.write_xdr(w)?; + self.code.write_xdr(w)?; + Ok(()) + }) + } +} + +// ExpirationEntry is an XDR Struct defines as: +// +// struct ExpirationEntry { +// // Hash of the LedgerKey that is associated with this ExpirationEntry +// Hash keyHash; +// uint32 expirationLedgerSeq; +// }; +// +#[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 ExpirationEntry { + pub key_hash: Hash, + pub expiration_ledger_seq: u32, +} + +impl ReadXdr for ExpirationEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + key_hash: Hash::read_xdr(r)?, + expiration_ledger_seq: u32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ExpirationEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.key_hash.write_xdr(w)?; + self.expiration_ledger_seq.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerEntryExtensionV1Ext is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LedgerEntryExtensionV1Ext { + V0, +} + +impl LedgerEntryExtensionV1Ext { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + } + } + + #[must_use] + pub const fn variants() -> [i32; 1] { + Self::VARIANTS + } +} + +impl Name for LedgerEntryExtensionV1Ext { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LedgerEntryExtensionV1Ext { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for LedgerEntryExtensionV1Ext { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for LedgerEntryExtensionV1Ext {} + +impl ReadXdr for LedgerEntryExtensionV1Ext { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerEntryExtensionV1Ext { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// LedgerEntryExtensionV1 is an XDR Struct defines as: +// +// struct LedgerEntryExtensionV1 +// { +// SponsorshipDescriptor sponsoringID; +// +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +// +#[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 LedgerEntryExtensionV1 { + pub sponsoring_id: SponsorshipDescriptor, + pub ext: LedgerEntryExtensionV1Ext, +} + +impl ReadXdr for LedgerEntryExtensionV1 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + sponsoring_id: SponsorshipDescriptor::read_xdr(r)?, + ext: LedgerEntryExtensionV1Ext::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerEntryExtensionV1 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.sponsoring_id.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerEntryData is an XDR NestedUnion defines as: +// +// union switch (LedgerEntryType type) +// { +// case ACCOUNT: +// AccountEntry account; +// case TRUSTLINE: +// TrustLineEntry trustLine; +// case OFFER: +// OfferEntry offer; +// case DATA: +// DataEntry data; +// case CLAIMABLE_BALANCE: +// ClaimableBalanceEntry claimableBalance; +// case LIQUIDITY_POOL: +// LiquidityPoolEntry liquidityPool; +// case CONTRACT_DATA: +// ContractDataEntry contractData; +// case CONTRACT_CODE: +// ContractCodeEntry contractCode; +// case CONFIG_SETTING: +// ConfigSettingEntry configSetting; +// case EXPIRATION: +// ExpirationEntry expiration; +// } +// +// union with discriminant LedgerEntryType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LedgerEntryData { + Account(AccountEntry), + Trustline(TrustLineEntry), + Offer(OfferEntry), + Data(DataEntry), + ClaimableBalance(ClaimableBalanceEntry), + LiquidityPool(LiquidityPoolEntry), + ContractData(ContractDataEntry), + ContractCode(ContractCodeEntry), + ConfigSetting(ConfigSettingEntry), + Expiration(ExpirationEntry), +} + +impl LedgerEntryData { + pub const VARIANTS: [LedgerEntryType; 10] = [ + LedgerEntryType::Account, + LedgerEntryType::Trustline, + LedgerEntryType::Offer, + LedgerEntryType::Data, + LedgerEntryType::ClaimableBalance, + LedgerEntryType::LiquidityPool, + LedgerEntryType::ContractData, + LedgerEntryType::ContractCode, + LedgerEntryType::ConfigSetting, + LedgerEntryType::Expiration, + ]; + pub const VARIANTS_STR: [&'static str; 10] = [ + "Account", + "Trustline", + "Offer", + "Data", + "ClaimableBalance", + "LiquidityPool", + "ContractData", + "ContractCode", + "ConfigSetting", + "Expiration", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Account(_) => "Account", + Self::Trustline(_) => "Trustline", + Self::Offer(_) => "Offer", + Self::Data(_) => "Data", + Self::ClaimableBalance(_) => "ClaimableBalance", + Self::LiquidityPool(_) => "LiquidityPool", + Self::ContractData(_) => "ContractData", + Self::ContractCode(_) => "ContractCode", + Self::ConfigSetting(_) => "ConfigSetting", + Self::Expiration(_) => "Expiration", + } + } + + #[must_use] + pub const fn discriminant(&self) -> LedgerEntryType { + #[allow(clippy::match_same_arms)] + match self { + Self::Account(_) => LedgerEntryType::Account, + Self::Trustline(_) => LedgerEntryType::Trustline, + Self::Offer(_) => LedgerEntryType::Offer, + Self::Data(_) => LedgerEntryType::Data, + Self::ClaimableBalance(_) => LedgerEntryType::ClaimableBalance, + Self::LiquidityPool(_) => LedgerEntryType::LiquidityPool, + Self::ContractData(_) => LedgerEntryType::ContractData, + Self::ContractCode(_) => LedgerEntryType::ContractCode, + Self::ConfigSetting(_) => LedgerEntryType::ConfigSetting, + Self::Expiration(_) => LedgerEntryType::Expiration, + } + } + + #[must_use] + pub const fn variants() -> [LedgerEntryType; 10] { + Self::VARIANTS + } +} + +impl Name for LedgerEntryData { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LedgerEntryData { + #[must_use] + fn discriminant(&self) -> LedgerEntryType { + Self::discriminant(self) + } +} + +impl Variants for LedgerEntryData { + fn variants() -> slice::Iter<'static, LedgerEntryType> { + Self::VARIANTS.iter() + } +} + +impl Union for LedgerEntryData {} + +impl ReadXdr for LedgerEntryData { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: LedgerEntryType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + LedgerEntryType::Account => Self::Account(AccountEntry::read_xdr(r)?), + LedgerEntryType::Trustline => Self::Trustline(TrustLineEntry::read_xdr(r)?), + LedgerEntryType::Offer => Self::Offer(OfferEntry::read_xdr(r)?), + LedgerEntryType::Data => Self::Data(DataEntry::read_xdr(r)?), + LedgerEntryType::ClaimableBalance => { + Self::ClaimableBalance(ClaimableBalanceEntry::read_xdr(r)?) + } + LedgerEntryType::LiquidityPool => { + Self::LiquidityPool(LiquidityPoolEntry::read_xdr(r)?) + } + LedgerEntryType::ContractData => { + Self::ContractData(ContractDataEntry::read_xdr(r)?) + } + LedgerEntryType::ContractCode => { + Self::ContractCode(ContractCodeEntry::read_xdr(r)?) + } + LedgerEntryType::ConfigSetting => { + Self::ConfigSetting(ConfigSettingEntry::read_xdr(r)?) + } + LedgerEntryType::Expiration => Self::Expiration(ExpirationEntry::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerEntryData { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Account(v) => v.write_xdr(w)?, + Self::Trustline(v) => v.write_xdr(w)?, + Self::Offer(v) => v.write_xdr(w)?, + Self::Data(v) => v.write_xdr(w)?, + Self::ClaimableBalance(v) => v.write_xdr(w)?, + Self::LiquidityPool(v) => v.write_xdr(w)?, + Self::ContractData(v) => v.write_xdr(w)?, + Self::ContractCode(v) => v.write_xdr(w)?, + Self::ConfigSetting(v) => v.write_xdr(w)?, + Self::Expiration(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// LedgerEntryExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// LedgerEntryExtensionV1 v1; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LedgerEntryExt { + V0, + V1(LedgerEntryExtensionV1), +} + +impl LedgerEntryExt { + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V1(_) => "V1", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V1(_) => 1, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for LedgerEntryExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LedgerEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for LedgerEntryExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for LedgerEntryExt {} + +impl ReadXdr for LedgerEntryExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 1 => Self::V1(LedgerEntryExtensionV1::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerEntryExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// LedgerEntry is an XDR Struct defines as: +// +// struct LedgerEntry +// { +// uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed +// +// union switch (LedgerEntryType type) +// { +// case ACCOUNT: +// AccountEntry account; +// case TRUSTLINE: +// TrustLineEntry trustLine; +// case OFFER: +// OfferEntry offer; +// case DATA: +// DataEntry data; +// case CLAIMABLE_BALANCE: +// ClaimableBalanceEntry claimableBalance; +// case LIQUIDITY_POOL: +// LiquidityPoolEntry liquidityPool; +// case CONTRACT_DATA: +// ContractDataEntry contractData; +// case CONTRACT_CODE: +// ContractCodeEntry contractCode; +// case CONFIG_SETTING: +// ConfigSettingEntry configSetting; +// case EXPIRATION: +// ExpirationEntry expiration; +// } +// data; +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// LedgerEntryExtensionV1 v1; +// } +// ext; +// }; +// +#[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 LedgerEntry { + pub last_modified_ledger_seq: u32, + pub data: LedgerEntryData, + pub ext: LedgerEntryExt, +} + +impl ReadXdr for LedgerEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + last_modified_ledger_seq: u32::read_xdr(r)?, + data: LedgerEntryData::read_xdr(r)?, + ext: LedgerEntryExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.last_modified_ledger_seq.write_xdr(w)?; + self.data.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyAccount is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID accountID; +// } +// +#[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 LedgerKeyAccount { + pub account_id: AccountId, +} + +impl ReadXdr for LedgerKeyAccount { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + account_id: AccountId::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyAccount { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.account_id.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyTrustLine is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID accountID; +// TrustLineAsset asset; +// } +// +#[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 LedgerKeyTrustLine { + pub account_id: AccountId, + pub asset: TrustLineAsset, +} + +impl ReadXdr for LedgerKeyTrustLine { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + account_id: AccountId::read_xdr(r)?, + asset: TrustLineAsset::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyTrustLine { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.account_id.write_xdr(w)?; + self.asset.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyOffer is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID sellerID; +// int64 offerID; +// } +// +#[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 LedgerKeyOffer { + pub seller_id: AccountId, + pub offer_id: i64, +} + +impl ReadXdr for LedgerKeyOffer { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + seller_id: AccountId::read_xdr(r)?, + offer_id: i64::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyOffer { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.seller_id.write_xdr(w)?; + self.offer_id.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyData is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID accountID; +// string64 dataName; +// } +// +#[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 LedgerKeyData { + pub account_id: AccountId, + pub data_name: String64, +} + +impl ReadXdr for LedgerKeyData { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + account_id: AccountId::read_xdr(r)?, + data_name: String64::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyData { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.account_id.write_xdr(w)?; + self.data_name.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyClaimableBalance is an XDR NestedStruct defines as: +// +// struct +// { +// ClaimableBalanceID balanceID; +// } +// +#[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 LedgerKeyClaimableBalance { + pub balance_id: ClaimableBalanceId, +} + +impl ReadXdr for LedgerKeyClaimableBalance { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { balance_id: ClaimableBalanceId::read_xdr(r)?, - claimants: VecM::::read_xdr(r)?, - asset: Asset::read_xdr(r)?, - amount: i64::read_xdr(r)?, - ext: ClaimableBalanceEntryExt::read_xdr(r)?, }) }) } } -impl WriteXdr for ClaimableBalanceEntry { +impl WriteXdr for LedgerKeyClaimableBalance { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.balance_id.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyLiquidityPool is an XDR NestedStruct defines as: +// +// struct +// { +// PoolID liquidityPoolID; +// } +// +#[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 LedgerKeyLiquidityPool { + pub liquidity_pool_id: PoolId, +} + +impl ReadXdr for LedgerKeyLiquidityPool { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + liquidity_pool_id: PoolId::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyLiquidityPool { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.liquidity_pool_id.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyContractData is an XDR NestedStruct defines as: +// +// struct +// { +// SCAddress contract; +// SCVal key; +// ContractDataDurability durability; +// } +// +#[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 LedgerKeyContractData { + pub contract: ScAddress, + pub key: ScVal, + pub durability: ContractDataDurability, +} + +impl ReadXdr for LedgerKeyContractData { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + contract: ScAddress::read_xdr(r)?, + key: ScVal::read_xdr(r)?, + durability: ContractDataDurability::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyContractData { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.contract.write_xdr(w)?; + self.key.write_xdr(w)?; + self.durability.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyContractCode is an XDR NestedStruct defines as: +// +// struct +// { +// Hash hash; +// } +// +#[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 LedgerKeyContractCode { + pub hash: Hash, +} + +impl ReadXdr for LedgerKeyContractCode { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + hash: Hash::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyContractCode { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.hash.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyConfigSetting is an XDR NestedStruct defines as: +// +// struct +// { +// ConfigSettingID configSettingID; +// } +// +#[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 LedgerKeyConfigSetting { + pub config_setting_id: ConfigSettingId, +} + +impl ReadXdr for LedgerKeyConfigSetting { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + config_setting_id: ConfigSettingId::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyConfigSetting { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.config_setting_id.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKeyExpiration is an XDR NestedStruct defines as: +// +// struct +// { +// // Hash of the LedgerKey that is associated with this ExpirationEntry +// Hash keyHash; +// } +// +#[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 LedgerKeyExpiration { + pub key_hash: Hash, +} + +impl ReadXdr for LedgerKeyExpiration { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + key_hash: Hash::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerKeyExpiration { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.key_hash.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerKey is an XDR Union defines as: +// +// union LedgerKey switch (LedgerEntryType type) +// { +// case ACCOUNT: +// struct +// { +// AccountID accountID; +// } account; +// +// case TRUSTLINE: +// struct +// { +// AccountID accountID; +// TrustLineAsset asset; +// } trustLine; +// +// case OFFER: +// struct +// { +// AccountID sellerID; +// int64 offerID; +// } offer; +// +// case DATA: +// struct +// { +// AccountID accountID; +// string64 dataName; +// } data; +// +// case CLAIMABLE_BALANCE: +// struct +// { +// ClaimableBalanceID balanceID; +// } claimableBalance; +// +// case LIQUIDITY_POOL: +// struct +// { +// PoolID liquidityPoolID; +// } liquidityPool; +// case CONTRACT_DATA: +// struct +// { +// SCAddress contract; +// SCVal key; +// ContractDataDurability durability; +// } contractData; +// case CONTRACT_CODE: +// struct +// { +// Hash hash; +// } contractCode; +// case CONFIG_SETTING: +// struct +// { +// ConfigSettingID configSettingID; +// } configSetting; +// case EXPIRATION: +// struct +// { +// // Hash of the LedgerKey that is associated with this ExpirationEntry +// Hash keyHash; +// } expiration; +// }; +// +// union with discriminant LedgerEntryType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LedgerKey { + Account(LedgerKeyAccount), + Trustline(LedgerKeyTrustLine), + Offer(LedgerKeyOffer), + Data(LedgerKeyData), + ClaimableBalance(LedgerKeyClaimableBalance), + LiquidityPool(LedgerKeyLiquidityPool), + ContractData(LedgerKeyContractData), + ContractCode(LedgerKeyContractCode), + ConfigSetting(LedgerKeyConfigSetting), + Expiration(LedgerKeyExpiration), +} + +impl LedgerKey { + pub const VARIANTS: [LedgerEntryType; 10] = [ + LedgerEntryType::Account, + LedgerEntryType::Trustline, + LedgerEntryType::Offer, + LedgerEntryType::Data, + LedgerEntryType::ClaimableBalance, + LedgerEntryType::LiquidityPool, + LedgerEntryType::ContractData, + LedgerEntryType::ContractCode, + LedgerEntryType::ConfigSetting, + LedgerEntryType::Expiration, + ]; + pub const VARIANTS_STR: [&'static str; 10] = [ + "Account", + "Trustline", + "Offer", + "Data", + "ClaimableBalance", + "LiquidityPool", + "ContractData", + "ContractCode", + "ConfigSetting", + "Expiration", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Account(_) => "Account", + Self::Trustline(_) => "Trustline", + Self::Offer(_) => "Offer", + Self::Data(_) => "Data", + Self::ClaimableBalance(_) => "ClaimableBalance", + Self::LiquidityPool(_) => "LiquidityPool", + Self::ContractData(_) => "ContractData", + Self::ContractCode(_) => "ContractCode", + Self::ConfigSetting(_) => "ConfigSetting", + Self::Expiration(_) => "Expiration", + } + } + + #[must_use] + pub const fn discriminant(&self) -> LedgerEntryType { + #[allow(clippy::match_same_arms)] + match self { + Self::Account(_) => LedgerEntryType::Account, + Self::Trustline(_) => LedgerEntryType::Trustline, + Self::Offer(_) => LedgerEntryType::Offer, + Self::Data(_) => LedgerEntryType::Data, + Self::ClaimableBalance(_) => LedgerEntryType::ClaimableBalance, + Self::LiquidityPool(_) => LedgerEntryType::LiquidityPool, + Self::ContractData(_) => LedgerEntryType::ContractData, + Self::ContractCode(_) => LedgerEntryType::ContractCode, + Self::ConfigSetting(_) => LedgerEntryType::ConfigSetting, + Self::Expiration(_) => LedgerEntryType::Expiration, + } + } + + #[must_use] + pub const fn variants() -> [LedgerEntryType; 10] { + Self::VARIANTS + } +} + +impl Name for LedgerKey { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LedgerKey { + #[must_use] + fn discriminant(&self) -> LedgerEntryType { + Self::discriminant(self) + } +} + +impl Variants for LedgerKey { + fn variants() -> slice::Iter<'static, LedgerEntryType> { + Self::VARIANTS.iter() + } +} + +impl Union for LedgerKey {} + +impl ReadXdr for LedgerKey { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: LedgerEntryType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + LedgerEntryType::Account => Self::Account(LedgerKeyAccount::read_xdr(r)?), + LedgerEntryType::Trustline => Self::Trustline(LedgerKeyTrustLine::read_xdr(r)?), + LedgerEntryType::Offer => Self::Offer(LedgerKeyOffer::read_xdr(r)?), + LedgerEntryType::Data => Self::Data(LedgerKeyData::read_xdr(r)?), + LedgerEntryType::ClaimableBalance => { + Self::ClaimableBalance(LedgerKeyClaimableBalance::read_xdr(r)?) + } + LedgerEntryType::LiquidityPool => { + Self::LiquidityPool(LedgerKeyLiquidityPool::read_xdr(r)?) + } + LedgerEntryType::ContractData => { + Self::ContractData(LedgerKeyContractData::read_xdr(r)?) + } + LedgerEntryType::ContractCode => { + Self::ContractCode(LedgerKeyContractCode::read_xdr(r)?) + } + LedgerEntryType::ConfigSetting => { + Self::ConfigSetting(LedgerKeyConfigSetting::read_xdr(r)?) + } + LedgerEntryType::Expiration => Self::Expiration(LedgerKeyExpiration::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerKey { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Account(v) => v.write_xdr(w)?, + Self::Trustline(v) => v.write_xdr(w)?, + Self::Offer(v) => v.write_xdr(w)?, + Self::Data(v) => v.write_xdr(w)?, + Self::ClaimableBalance(v) => v.write_xdr(w)?, + Self::LiquidityPool(v) => v.write_xdr(w)?, + Self::ContractData(v) => v.write_xdr(w)?, + Self::ContractCode(v) => v.write_xdr(w)?, + Self::ConfigSetting(v) => v.write_xdr(w)?, + Self::Expiration(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// EnvelopeType is an XDR Enum defines as: +// +// enum EnvelopeType +// { +// ENVELOPE_TYPE_TX_V0 = 0, +// ENVELOPE_TYPE_SCP = 1, +// ENVELOPE_TYPE_TX = 2, +// ENVELOPE_TYPE_AUTH = 3, +// ENVELOPE_TYPE_SCPVALUE = 4, +// ENVELOPE_TYPE_TX_FEE_BUMP = 5, +// ENVELOPE_TYPE_OP_ID = 6, +// ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7, +// ENVELOPE_TYPE_CONTRACT_ID = 8, +// ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum EnvelopeType { + TxV0 = 0, + Scp = 1, + Tx = 2, + Auth = 3, + Scpvalue = 4, + TxFeeBump = 5, + OpId = 6, + PoolRevokeOpId = 7, + ContractId = 8, + SorobanAuthorization = 9, +} + +impl EnvelopeType { + pub const VARIANTS: [EnvelopeType; 10] = [ + EnvelopeType::TxV0, + EnvelopeType::Scp, + EnvelopeType::Tx, + EnvelopeType::Auth, + EnvelopeType::Scpvalue, + EnvelopeType::TxFeeBump, + EnvelopeType::OpId, + EnvelopeType::PoolRevokeOpId, + EnvelopeType::ContractId, + EnvelopeType::SorobanAuthorization, + ]; + pub const VARIANTS_STR: [&'static str; 10] = [ + "TxV0", + "Scp", + "Tx", + "Auth", + "Scpvalue", + "TxFeeBump", + "OpId", + "PoolRevokeOpId", + "ContractId", + "SorobanAuthorization", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::TxV0 => "TxV0", + Self::Scp => "Scp", + Self::Tx => "Tx", + Self::Auth => "Auth", + Self::Scpvalue => "Scpvalue", + Self::TxFeeBump => "TxFeeBump", + Self::OpId => "OpId", + Self::PoolRevokeOpId => "PoolRevokeOpId", + Self::ContractId => "ContractId", + Self::SorobanAuthorization => "SorobanAuthorization", + } + } + + #[must_use] + pub const fn variants() -> [EnvelopeType; 10] { + Self::VARIANTS + } +} + +impl Name for EnvelopeType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for EnvelopeType { + fn variants() -> slice::Iter<'static, EnvelopeType> { + Self::VARIANTS.iter() + } +} + +impl Enum for EnvelopeType {} + +impl fmt::Display for EnvelopeType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for EnvelopeType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => EnvelopeType::TxV0, + 1 => EnvelopeType::Scp, + 2 => EnvelopeType::Tx, + 3 => EnvelopeType::Auth, + 4 => EnvelopeType::Scpvalue, + 5 => EnvelopeType::TxFeeBump, + 6 => EnvelopeType::OpId, + 7 => EnvelopeType::PoolRevokeOpId, + 8 => EnvelopeType::ContractId, + 9 => EnvelopeType::SorobanAuthorization, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: EnvelopeType) -> Self { + e as Self + } +} + +impl ReadXdr for EnvelopeType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for EnvelopeType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// UpgradeType is an XDR Typedef defines as: +// +// typedef opaque UpgradeType<128>; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct UpgradeType(pub BytesM<128>); + +impl From for BytesM<128> { + #[must_use] + fn from(x: UpgradeType) -> Self { + x.0 + } +} + +impl From> for UpgradeType { + #[must_use] + fn from(x: BytesM<128>) -> Self { + UpgradeType(x) + } +} + +impl AsRef> for UpgradeType { + #[must_use] + fn as_ref(&self) -> &BytesM<128> { + &self.0 + } +} + +impl ReadXdr for UpgradeType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = BytesM::<128>::read_xdr(r)?; + let v = UpgradeType(i); + Ok(v) + }) + } +} + +impl WriteXdr for UpgradeType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +impl Deref for UpgradeType { + type Target = BytesM<128>; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for Vec { + #[must_use] + fn from(x: UpgradeType) -> Self { + x.0 .0 + } +} + +impl TryFrom> for UpgradeType { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(UpgradeType(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for UpgradeType { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(UpgradeType(x.try_into()?)) + } +} + +impl AsRef> for UpgradeType { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 + } +} + +impl AsRef<[u8]> for UpgradeType { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[u8] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[u8] { + self.0 .0 + } +} + +// StellarValueType is an XDR Enum defines as: +// +// enum StellarValueType +// { +// STELLAR_VALUE_BASIC = 0, +// STELLAR_VALUE_SIGNED = 1 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum StellarValueType { + Basic = 0, + Signed = 1, +} + +impl StellarValueType { + pub const VARIANTS: [StellarValueType; 2] = [StellarValueType::Basic, StellarValueType::Signed]; + pub const VARIANTS_STR: [&'static str; 2] = ["Basic", "Signed"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Basic => "Basic", + Self::Signed => "Signed", + } + } + + #[must_use] + pub const fn variants() -> [StellarValueType; 2] { + Self::VARIANTS + } +} + +impl Name for StellarValueType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for StellarValueType { + fn variants() -> slice::Iter<'static, StellarValueType> { + Self::VARIANTS.iter() + } +} + +impl Enum for StellarValueType {} + +impl fmt::Display for StellarValueType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for StellarValueType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => StellarValueType::Basic, + 1 => StellarValueType::Signed, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: StellarValueType) -> Self { + e as Self + } +} + +impl ReadXdr for StellarValueType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for StellarValueType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// LedgerCloseValueSignature is an XDR Struct defines as: +// +// struct LedgerCloseValueSignature +// { +// NodeID nodeID; // which node introduced the value +// Signature signature; // nodeID's signature +// }; +// +#[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 LedgerCloseValueSignature { + pub node_id: NodeId, + pub signature: Signature, +} + +impl ReadXdr for LedgerCloseValueSignature { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + node_id: NodeId::read_xdr(r)?, + signature: Signature::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerCloseValueSignature { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.node_id.write_xdr(w)?; + self.signature.write_xdr(w)?; + Ok(()) + }) + } +} + +// StellarValueExt is an XDR NestedUnion defines as: +// +// union switch (StellarValueType v) +// { +// case STELLAR_VALUE_BASIC: +// void; +// case STELLAR_VALUE_SIGNED: +// LedgerCloseValueSignature lcValueSignature; +// } +// +// union with discriminant StellarValueType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum StellarValueExt { + Basic, + Signed(LedgerCloseValueSignature), +} + +impl StellarValueExt { + pub const VARIANTS: [StellarValueType; 2] = [StellarValueType::Basic, StellarValueType::Signed]; + pub const VARIANTS_STR: [&'static str; 2] = ["Basic", "Signed"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Basic => "Basic", + Self::Signed(_) => "Signed", + } + } + + #[must_use] + pub const fn discriminant(&self) -> StellarValueType { + #[allow(clippy::match_same_arms)] + match self { + Self::Basic => StellarValueType::Basic, + Self::Signed(_) => StellarValueType::Signed, + } + } + + #[must_use] + pub const fn variants() -> [StellarValueType; 2] { + Self::VARIANTS + } +} + +impl Name for StellarValueExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for StellarValueExt { + #[must_use] + fn discriminant(&self) -> StellarValueType { + Self::discriminant(self) + } +} + +impl Variants for StellarValueExt { + fn variants() -> slice::Iter<'static, StellarValueType> { + Self::VARIANTS.iter() + } +} + +impl Union for StellarValueExt {} + +impl ReadXdr for StellarValueExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: StellarValueType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + StellarValueType::Basic => Self::Basic, + StellarValueType::Signed => Self::Signed(LedgerCloseValueSignature::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for StellarValueExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Basic => ().write_xdr(w)?, + Self::Signed(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// StellarValue is an XDR Struct defines as: +// +// struct StellarValue +// { +// Hash txSetHash; // transaction set to apply to previous ledger +// TimePoint closeTime; // network close time +// +// // upgrades to apply to the previous ledger (usually empty) +// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop +// // unknown steps during consensus if needed. +// // see notes below on 'LedgerUpgrade' for more detail +// // max size is dictated by number of upgrade types (+ room for future) +// UpgradeType upgrades<6>; +// +// // reserved for future use +// union switch (StellarValueType v) +// { +// case STELLAR_VALUE_BASIC: +// void; +// case STELLAR_VALUE_SIGNED: +// LedgerCloseValueSignature lcValueSignature; +// } +// ext; +// }; +// +#[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 StellarValue { + pub tx_set_hash: Hash, + pub close_time: TimePoint, + pub upgrades: VecM, + pub ext: StellarValueExt, +} + +impl ReadXdr for StellarValue { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + tx_set_hash: Hash::read_xdr(r)?, + close_time: TimePoint::read_xdr(r)?, + upgrades: VecM::::read_xdr(r)?, + ext: StellarValueExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for StellarValue { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.tx_set_hash.write_xdr(w)?; + self.close_time.write_xdr(w)?; + self.upgrades.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// MaskLedgerHeaderFlags is an XDR Const defines as: +// +// const MASK_LEDGER_HEADER_FLAGS = 0x7; +// +pub const MASK_LEDGER_HEADER_FLAGS: u64 = 0x7; + +// LedgerHeaderFlags is an XDR Enum defines as: +// +// enum LedgerHeaderFlags +// { +// DISABLE_LIQUIDITY_POOL_TRADING_FLAG = 0x1, +// DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG = 0x2, +// DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 0x4 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum LedgerHeaderFlags { + TradingFlag = 1, + DepositFlag = 2, + WithdrawalFlag = 4, +} + +impl LedgerHeaderFlags { + pub const VARIANTS: [LedgerHeaderFlags; 3] = [ + LedgerHeaderFlags::TradingFlag, + LedgerHeaderFlags::DepositFlag, + LedgerHeaderFlags::WithdrawalFlag, + ]; + pub const VARIANTS_STR: [&'static str; 3] = ["TradingFlag", "DepositFlag", "WithdrawalFlag"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::TradingFlag => "TradingFlag", + Self::DepositFlag => "DepositFlag", + Self::WithdrawalFlag => "WithdrawalFlag", + } + } + + #[must_use] + pub const fn variants() -> [LedgerHeaderFlags; 3] { + Self::VARIANTS + } +} + +impl Name for LedgerHeaderFlags { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for LedgerHeaderFlags { + fn variants() -> slice::Iter<'static, LedgerHeaderFlags> { + Self::VARIANTS.iter() + } +} + +impl Enum for LedgerHeaderFlags {} + +impl fmt::Display for LedgerHeaderFlags { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for LedgerHeaderFlags { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 1 => LedgerHeaderFlags::TradingFlag, + 2 => LedgerHeaderFlags::DepositFlag, + 4 => LedgerHeaderFlags::WithdrawalFlag, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: LedgerHeaderFlags) -> Self { + e as Self + } +} + +impl ReadXdr for LedgerHeaderFlags { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerHeaderFlags { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// LedgerHeaderExtensionV1Ext is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LedgerHeaderExtensionV1Ext { + V0, +} + +impl LedgerHeaderExtensionV1Ext { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + } + } + + #[must_use] + pub const fn variants() -> [i32; 1] { + Self::VARIANTS + } +} + +impl Name for LedgerHeaderExtensionV1Ext { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LedgerHeaderExtensionV1Ext { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for LedgerHeaderExtensionV1Ext { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for LedgerHeaderExtensionV1Ext {} + +impl ReadXdr for LedgerHeaderExtensionV1Ext { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerHeaderExtensionV1Ext { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// LedgerHeaderExtensionV1 is an XDR Struct defines as: +// +// struct LedgerHeaderExtensionV1 +// { +// uint32 flags; // LedgerHeaderFlags +// +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +// +#[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 LedgerHeaderExtensionV1 { + pub flags: u32, + pub ext: LedgerHeaderExtensionV1Ext, +} + +impl ReadXdr for LedgerHeaderExtensionV1 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + flags: u32::read_xdr(r)?, + ext: LedgerHeaderExtensionV1Ext::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerHeaderExtensionV1 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.flags.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerHeaderExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// LedgerHeaderExtensionV1 v1; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LedgerHeaderExt { + V0, + V1(LedgerHeaderExtensionV1), +} + +impl LedgerHeaderExt { + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V0 => "V0", + Self::V1(_) => "V1", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + Self::V1(_) => 1, + } + } + + #[must_use] + pub const fn variants() -> [i32; 2] { + Self::VARIANTS + } +} + +impl Name for LedgerHeaderExt { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LedgerHeaderExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for LedgerHeaderExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } +} + +impl Union for LedgerHeaderExt {} + +impl ReadXdr for LedgerHeaderExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + 1 => Self::V1(LedgerHeaderExtensionV1::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerHeaderExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// LedgerHeader is an XDR Struct defines as: +// +// struct LedgerHeader +// { +// uint32 ledgerVersion; // the protocol version of the ledger +// Hash previousLedgerHash; // hash of the previous ledger header +// StellarValue scpValue; // what consensus agreed to +// Hash txSetResultHash; // the TransactionResultSet that led to this ledger +// Hash bucketListHash; // hash of the ledger state +// +// uint32 ledgerSeq; // sequence number of this ledger +// +// int64 totalCoins; // total number of stroops in existence. +// // 10,000,000 stroops in 1 XLM +// +// int64 feePool; // fees burned since last inflation run +// uint32 inflationSeq; // inflation sequence number +// +// uint64 idPool; // last used global ID, used for generating objects +// +// uint32 baseFee; // base fee per operation in stroops +// uint32 baseReserve; // account base reserve in stroops +// +// uint32 maxTxSetSize; // maximum size a transaction set can be +// +// Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back +// // in time without walking the chain back ledger by ledger +// // each slot contains the oldest ledger that is mod of +// // either 50 5000 50000 or 500000 depending on index +// // skipList[0] mod(50), skipList[1] mod(5000), etc +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// LedgerHeaderExtensionV1 v1; +// } +// ext; +// }; +// +#[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 LedgerHeader { + pub ledger_version: u32, + pub previous_ledger_hash: Hash, + pub scp_value: StellarValue, + pub tx_set_result_hash: Hash, + pub bucket_list_hash: Hash, + pub ledger_seq: u32, + pub total_coins: i64, + pub fee_pool: i64, + pub inflation_seq: u32, + pub id_pool: u64, + pub base_fee: u32, + pub base_reserve: u32, + pub max_tx_set_size: u32, + pub skip_list: [Hash; 4], + pub ext: LedgerHeaderExt, +} + +impl ReadXdr for LedgerHeader { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ledger_version: u32::read_xdr(r)?, + previous_ledger_hash: Hash::read_xdr(r)?, + scp_value: StellarValue::read_xdr(r)?, + tx_set_result_hash: Hash::read_xdr(r)?, + bucket_list_hash: Hash::read_xdr(r)?, + ledger_seq: u32::read_xdr(r)?, + total_coins: i64::read_xdr(r)?, + fee_pool: i64::read_xdr(r)?, + inflation_seq: u32::read_xdr(r)?, + id_pool: u64::read_xdr(r)?, + base_fee: u32::read_xdr(r)?, + base_reserve: u32::read_xdr(r)?, + max_tx_set_size: u32::read_xdr(r)?, + skip_list: <[Hash; 4]>::read_xdr(r)?, + ext: LedgerHeaderExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerHeader { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ledger_version.write_xdr(w)?; + self.previous_ledger_hash.write_xdr(w)?; + self.scp_value.write_xdr(w)?; + self.tx_set_result_hash.write_xdr(w)?; + self.bucket_list_hash.write_xdr(w)?; + self.ledger_seq.write_xdr(w)?; + self.total_coins.write_xdr(w)?; + self.fee_pool.write_xdr(w)?; + self.inflation_seq.write_xdr(w)?; + self.id_pool.write_xdr(w)?; + self.base_fee.write_xdr(w)?; + self.base_reserve.write_xdr(w)?; + self.max_tx_set_size.write_xdr(w)?; + self.skip_list.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerUpgradeType is an XDR Enum defines as: +// +// enum LedgerUpgradeType +// { +// LEDGER_UPGRADE_VERSION = 1, +// LEDGER_UPGRADE_BASE_FEE = 2, +// LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3, +// LEDGER_UPGRADE_BASE_RESERVE = 4, +// LEDGER_UPGRADE_FLAGS = 5, +// LEDGER_UPGRADE_CONFIG = 6, +// LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE = 7 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum LedgerUpgradeType { + Version = 1, + BaseFee = 2, + MaxTxSetSize = 3, + BaseReserve = 4, + Flags = 5, + Config = 6, + MaxSorobanTxSetSize = 7, +} + +impl LedgerUpgradeType { + pub const VARIANTS: [LedgerUpgradeType; 7] = [ + LedgerUpgradeType::Version, + LedgerUpgradeType::BaseFee, + LedgerUpgradeType::MaxTxSetSize, + LedgerUpgradeType::BaseReserve, + LedgerUpgradeType::Flags, + LedgerUpgradeType::Config, + LedgerUpgradeType::MaxSorobanTxSetSize, + ]; + pub const VARIANTS_STR: [&'static str; 7] = [ + "Version", + "BaseFee", + "MaxTxSetSize", + "BaseReserve", + "Flags", + "Config", + "MaxSorobanTxSetSize", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Version => "Version", + Self::BaseFee => "BaseFee", + Self::MaxTxSetSize => "MaxTxSetSize", + Self::BaseReserve => "BaseReserve", + Self::Flags => "Flags", + Self::Config => "Config", + Self::MaxSorobanTxSetSize => "MaxSorobanTxSetSize", + } + } + + #[must_use] + pub const fn variants() -> [LedgerUpgradeType; 7] { + Self::VARIANTS + } +} + +impl Name for LedgerUpgradeType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for LedgerUpgradeType { + fn variants() -> slice::Iter<'static, LedgerUpgradeType> { + Self::VARIANTS.iter() + } +} + +impl Enum for LedgerUpgradeType {} + +impl fmt::Display for LedgerUpgradeType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for LedgerUpgradeType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 1 => LedgerUpgradeType::Version, + 2 => LedgerUpgradeType::BaseFee, + 3 => LedgerUpgradeType::MaxTxSetSize, + 4 => LedgerUpgradeType::BaseReserve, + 5 => LedgerUpgradeType::Flags, + 6 => LedgerUpgradeType::Config, + 7 => LedgerUpgradeType::MaxSorobanTxSetSize, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: LedgerUpgradeType) -> Self { + e as Self + } +} + +impl ReadXdr for LedgerUpgradeType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerUpgradeType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ConfigUpgradeSetKey is an XDR Struct defines as: +// +// struct ConfigUpgradeSetKey { +// Hash contractID; +// Hash contentHash; +// }; +// +#[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 ConfigUpgradeSetKey { + pub contract_id: Hash, + pub content_hash: Hash, +} + +impl ReadXdr for ConfigUpgradeSetKey { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + contract_id: Hash::read_xdr(r)?, + content_hash: Hash::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ConfigUpgradeSetKey { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.contract_id.write_xdr(w)?; + self.content_hash.write_xdr(w)?; + Ok(()) + }) + } +} + +// LedgerUpgrade is an XDR Union defines as: +// +// union LedgerUpgrade switch (LedgerUpgradeType type) +// { +// case LEDGER_UPGRADE_VERSION: +// uint32 newLedgerVersion; // update ledgerVersion +// case LEDGER_UPGRADE_BASE_FEE: +// uint32 newBaseFee; // update baseFee +// case LEDGER_UPGRADE_MAX_TX_SET_SIZE: +// uint32 newMaxTxSetSize; // update maxTxSetSize +// case LEDGER_UPGRADE_BASE_RESERVE: +// uint32 newBaseReserve; // update baseReserve +// case LEDGER_UPGRADE_FLAGS: +// uint32 newFlags; // update flags +// case LEDGER_UPGRADE_CONFIG: +// // Update arbitrary `ConfigSetting` entries identified by the key. +// ConfigUpgradeSetKey newConfig; +// case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: +// // Update ConfigSettingContractExecutionLanesV0.ledgerMaxTxCount without +// // using `LEDGER_UPGRADE_CONFIG`. +// uint32 newMaxSorobanTxSetSize; +// }; +// +// union with discriminant LedgerUpgradeType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum LedgerUpgrade { + Version(u32), + BaseFee(u32), + MaxTxSetSize(u32), + BaseReserve(u32), + Flags(u32), + Config(ConfigUpgradeSetKey), + MaxSorobanTxSetSize(u32), +} + +impl LedgerUpgrade { + pub const VARIANTS: [LedgerUpgradeType; 7] = [ + LedgerUpgradeType::Version, + LedgerUpgradeType::BaseFee, + LedgerUpgradeType::MaxTxSetSize, + LedgerUpgradeType::BaseReserve, + LedgerUpgradeType::Flags, + LedgerUpgradeType::Config, + LedgerUpgradeType::MaxSorobanTxSetSize, + ]; + pub const VARIANTS_STR: [&'static str; 7] = [ + "Version", + "BaseFee", + "MaxTxSetSize", + "BaseReserve", + "Flags", + "Config", + "MaxSorobanTxSetSize", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Version(_) => "Version", + Self::BaseFee(_) => "BaseFee", + Self::MaxTxSetSize(_) => "MaxTxSetSize", + Self::BaseReserve(_) => "BaseReserve", + Self::Flags(_) => "Flags", + Self::Config(_) => "Config", + Self::MaxSorobanTxSetSize(_) => "MaxSorobanTxSetSize", + } + } + + #[must_use] + pub const fn discriminant(&self) -> LedgerUpgradeType { + #[allow(clippy::match_same_arms)] + match self { + Self::Version(_) => LedgerUpgradeType::Version, + Self::BaseFee(_) => LedgerUpgradeType::BaseFee, + Self::MaxTxSetSize(_) => LedgerUpgradeType::MaxTxSetSize, + Self::BaseReserve(_) => LedgerUpgradeType::BaseReserve, + Self::Flags(_) => LedgerUpgradeType::Flags, + Self::Config(_) => LedgerUpgradeType::Config, + Self::MaxSorobanTxSetSize(_) => LedgerUpgradeType::MaxSorobanTxSetSize, + } + } + + #[must_use] + pub const fn variants() -> [LedgerUpgradeType; 7] { + Self::VARIANTS + } +} + +impl Name for LedgerUpgrade { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for LedgerUpgrade { + #[must_use] + fn discriminant(&self) -> LedgerUpgradeType { + Self::discriminant(self) + } +} + +impl Variants for LedgerUpgrade { + fn variants() -> slice::Iter<'static, LedgerUpgradeType> { + Self::VARIANTS.iter() + } +} + +impl Union for LedgerUpgrade {} + +impl ReadXdr for LedgerUpgrade { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: LedgerUpgradeType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + LedgerUpgradeType::Version => Self::Version(u32::read_xdr(r)?), + LedgerUpgradeType::BaseFee => Self::BaseFee(u32::read_xdr(r)?), + LedgerUpgradeType::MaxTxSetSize => Self::MaxTxSetSize(u32::read_xdr(r)?), + LedgerUpgradeType::BaseReserve => Self::BaseReserve(u32::read_xdr(r)?), + LedgerUpgradeType::Flags => Self::Flags(u32::read_xdr(r)?), + LedgerUpgradeType::Config => Self::Config(ConfigUpgradeSetKey::read_xdr(r)?), + LedgerUpgradeType::MaxSorobanTxSetSize => { + Self::MaxSorobanTxSetSize(u32::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for LedgerUpgrade { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.balance_id.write_xdr(w)?; - self.claimants.write_xdr(w)?; - self.asset.write_xdr(w)?; - self.amount.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Version(v) => v.write_xdr(w)?, + Self::BaseFee(v) => v.write_xdr(w)?, + Self::MaxTxSetSize(v) => v.write_xdr(w)?, + Self::BaseReserve(v) => v.write_xdr(w)?, + Self::Flags(v) => v.write_xdr(w)?, + Self::Config(v) => v.write_xdr(w)?, + Self::MaxSorobanTxSetSize(v) => v.write_xdr(w)?, + }; Ok(()) }) } } -// LiquidityPoolConstantProductParameters is an XDR Struct defines as: +// ConfigUpgradeSet is an XDR Struct defines as: // -// struct LiquidityPoolConstantProductParameters -// { -// Asset assetA; // assetA < assetB -// Asset assetB; -// int32 fee; // Fee is in basis points, so the actual rate is (fee/100)% +// struct ConfigUpgradeSet { +// ConfigSettingEntry updatedEntry<>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -8388,112 +17304,159 @@ impl WriteXdr for ClaimableBalanceEntry { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LiquidityPoolConstantProductParameters { - pub asset_a: Asset, - pub asset_b: Asset, - pub fee: i32, +pub struct ConfigUpgradeSet { + pub updated_entry: VecM, } -impl ReadXdr for LiquidityPoolConstantProductParameters { +impl ReadXdr for ConfigUpgradeSet { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - asset_a: Asset::read_xdr(r)?, - asset_b: Asset::read_xdr(r)?, - fee: i32::read_xdr(r)?, + updated_entry: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for LiquidityPoolConstantProductParameters { +impl WriteXdr for ConfigUpgradeSet { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.asset_a.write_xdr(w)?; - self.asset_b.write_xdr(w)?; - self.fee.write_xdr(w)?; + self.updated_entry.write_xdr(w)?; Ok(()) }) } } -// LiquidityPoolEntryConstantProduct is an XDR NestedStruct defines as: -// -// struct -// { -// LiquidityPoolConstantProductParameters params; +// BucketEntryType is an XDR Enum defines as: // -// int64 reserveA; // amount of A in the pool -// int64 reserveB; // amount of B in the pool -// int64 totalPoolShares; // total number of pool shares issued -// int64 poolSharesTrustLineCount; // number of trust lines for the -// // associated pool shares -// } +// enum BucketEntryType +// { +// METAENTRY = +// -1, // At-and-after protocol 11: bucket metadata, should come first. +// LIVEENTRY = 0, // Before protocol 11: created-or-updated; +// // At-and-after protocol 11: only updated. +// DEADENTRY = 1, +// INITENTRY = 2 // At-and-after protocol 11: only created. +// }; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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 LiquidityPoolEntryConstantProduct { - pub params: LiquidityPoolConstantProductParameters, - pub reserve_a: i64, - pub reserve_b: i64, - pub total_pool_shares: i64, - pub pool_shares_trust_line_count: i64, +#[repr(i32)] +pub enum BucketEntryType { + Metaentry = -1, + Liveentry = 0, + Deadentry = 1, + Initentry = 2, } -impl ReadXdr for LiquidityPoolEntryConstantProduct { +impl BucketEntryType { + pub const VARIANTS: [BucketEntryType; 4] = [ + BucketEntryType::Metaentry, + BucketEntryType::Liveentry, + BucketEntryType::Deadentry, + BucketEntryType::Initentry, + ]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Metaentry", "Liveentry", "Deadentry", "Initentry"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Metaentry => "Metaentry", + Self::Liveentry => "Liveentry", + Self::Deadentry => "Deadentry", + Self::Initentry => "Initentry", + } + } + + #[must_use] + pub const fn variants() -> [BucketEntryType; 4] { + Self::VARIANTS + } +} + +impl Name for BucketEntryType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for BucketEntryType { + fn variants() -> slice::Iter<'static, BucketEntryType> { + Self::VARIANTS.iter() + } +} + +impl Enum for BucketEntryType {} + +impl fmt::Display for BucketEntryType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for BucketEntryType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + -1 => BucketEntryType::Metaentry, + 0 => BucketEntryType::Liveentry, + 1 => BucketEntryType::Deadentry, + 2 => BucketEntryType::Initentry, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: BucketEntryType) -> Self { + e as Self + } +} + +impl ReadXdr for BucketEntryType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - params: LiquidityPoolConstantProductParameters::read_xdr(r)?, - reserve_a: i64::read_xdr(r)?, - reserve_b: i64::read_xdr(r)?, - total_pool_shares: i64::read_xdr(r)?, - pool_shares_trust_line_count: i64::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for LiquidityPoolEntryConstantProduct { +impl WriteXdr for BucketEntryType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.params.write_xdr(w)?; - self.reserve_a.write_xdr(w)?; - self.reserve_b.write_xdr(w)?; - self.total_pool_shares.write_xdr(w)?; - self.pool_shares_trust_line_count.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// LiquidityPoolEntryBody is an XDR NestedUnion defines as: +// BucketMetadataExt is an XDR NestedUnion defines as: // -// union switch (LiquidityPoolType type) +// union switch (int v) // { -// case LIQUIDITY_POOL_CONSTANT_PRODUCT: -// struct -// { -// LiquidityPoolConstantProductParameters params; -// -// int64 reserveA; // amount of A in the pool -// int64 reserveB; // amount of B in the pool -// int64 totalPoolShares; // total number of pool shares issued -// int64 poolSharesTrustLineCount; // number of trust lines for the -// // associated pool shares -// } constantProduct; +// case 0: +// void; // } // -// union with discriminant LiquidityPoolType +// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -8502,71 +17465,65 @@ impl WriteXdr for LiquidityPoolEntryConstantProduct { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LiquidityPoolEntryBody { - LiquidityPoolConstantProduct(LiquidityPoolEntryConstantProduct), +pub enum BucketMetadataExt { + V0, } -impl LiquidityPoolEntryBody { - pub const VARIANTS: [LiquidityPoolType; 1] = [LiquidityPoolType::LiquidityPoolConstantProduct]; - pub const VARIANTS_STR: [&'static str; 1] = ["LiquidityPoolConstantProduct"]; +impl BucketMetadataExt { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::LiquidityPoolConstantProduct(_) => "LiquidityPoolConstantProduct", + Self::V0 => "V0", } } #[must_use] - pub const fn discriminant(&self) -> LiquidityPoolType { + pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::LiquidityPoolConstantProduct(_) => { - LiquidityPoolType::LiquidityPoolConstantProduct - } + Self::V0 => 0, } } #[must_use] - pub const fn variants() -> [LiquidityPoolType; 1] { + pub const fn variants() -> [i32; 1] { Self::VARIANTS } } -impl Name for LiquidityPoolEntryBody { +impl Name for BucketMetadataExt { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LiquidityPoolEntryBody { +impl Discriminant for BucketMetadataExt { #[must_use] - fn discriminant(&self) -> LiquidityPoolType { + fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for LiquidityPoolEntryBody { - fn variants() -> slice::Iter<'static, LiquidityPoolType> { +impl Variants for BucketMetadataExt { + fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for LiquidityPoolEntryBody {} +impl Union for BucketMetadataExt {} -impl ReadXdr for LiquidityPoolEntryBody { +impl ReadXdr for BucketMetadataExt { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LiquidityPoolType = ::read_xdr(r)?; + let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - LiquidityPoolType::LiquidityPoolConstantProduct => { - Self::LiquidityPoolConstantProduct(LiquidityPoolEntryConstantProduct::read_xdr( - r, - )?) - } + 0 => Self::V0, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -8575,41 +17532,34 @@ impl ReadXdr for LiquidityPoolEntryBody { } } -impl WriteXdr for LiquidityPoolEntryBody { +impl WriteXdr for BucketMetadataExt { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::LiquidityPoolConstantProduct(v) => v.write_xdr(w)?, + Self::V0 => ().write_xdr(w)?, }; Ok(()) }) } } -// LiquidityPoolEntry is an XDR Struct defines as: +// BucketMetadata is an XDR Struct defines as: // -// struct LiquidityPoolEntry +// struct BucketMetadata // { -// PoolID liquidityPoolID; +// // Indicates the protocol version used to create / merge this bucket. +// uint32 ledgerVersion; // -// union switch (LiquidityPoolType type) +// // reserved for future use +// union switch (int v) // { -// case LIQUIDITY_POOL_CONSTANT_PRODUCT: -// struct -// { -// LiquidityPoolConstantProductParameters params; -// -// int64 reserveA; // amount of A in the pool -// int64 reserveB; // amount of B in the pool -// int64 totalPoolShares; // total number of pool shares issued -// int64 poolSharesTrustLineCount; // number of trust lines for the -// // associated pool shares -// } constantProduct; +// case 0: +// void; // } -// body; +// ext; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -8619,43 +17569,49 @@ impl WriteXdr for LiquidityPoolEntryBody { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LiquidityPoolEntry { - pub liquidity_pool_id: PoolId, - pub body: LiquidityPoolEntryBody, +pub struct BucketMetadata { + pub ledger_version: u32, + pub ext: BucketMetadataExt, } -impl ReadXdr for LiquidityPoolEntry { +impl ReadXdr for BucketMetadata { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - liquidity_pool_id: PoolId::read_xdr(r)?, - body: LiquidityPoolEntryBody::read_xdr(r)?, + ledger_version: u32::read_xdr(r)?, + ext: BucketMetadataExt::read_xdr(r)?, }) }) } } -impl WriteXdr for LiquidityPoolEntry { +impl WriteXdr for BucketMetadata { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.liquidity_pool_id.write_xdr(w)?; - self.body.write_xdr(w)?; + self.ledger_version.write_xdr(w)?; + self.ext.write_xdr(w)?; Ok(()) }) } } -// LedgerEntryExtensionV1Ext is an XDR NestedUnion defines as: +// BucketEntry is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// union BucketEntry switch (BucketEntryType type) +// { +// case LIVEENTRY: +// case INITENTRY: +// LedgerEntry liveEntry; // -// union with discriminant i32 +// case DEADENTRY: +// LedgerKey deadEntry; +// case METAENTRY: +// BucketMetadata metaEntry; +// }; +// +// union with discriminant BucketEntryType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -8664,65 +17620,83 @@ impl WriteXdr for LiquidityPoolEntry { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerEntryExtensionV1Ext { - V0, +pub enum BucketEntry { + Liveentry(LedgerEntry), + Initentry(LedgerEntry), + Deadentry(LedgerKey), + Metaentry(BucketMetadata), } -impl LedgerEntryExtensionV1Ext { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl BucketEntry { + pub const VARIANTS: [BucketEntryType; 4] = [ + BucketEntryType::Liveentry, + BucketEntryType::Initentry, + BucketEntryType::Deadentry, + BucketEntryType::Metaentry, + ]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Liveentry", "Initentry", "Deadentry", "Metaentry"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::Liveentry(_) => "Liveentry", + Self::Initentry(_) => "Initentry", + Self::Deadentry(_) => "Deadentry", + Self::Metaentry(_) => "Metaentry", } } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> BucketEntryType { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::Liveentry(_) => BucketEntryType::Liveentry, + Self::Initentry(_) => BucketEntryType::Initentry, + Self::Deadentry(_) => BucketEntryType::Deadentry, + Self::Metaentry(_) => BucketEntryType::Metaentry, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [BucketEntryType; 4] { Self::VARIANTS } } -impl Name for LedgerEntryExtensionV1Ext { +impl Name for BucketEntry { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerEntryExtensionV1Ext { +impl Discriminant for BucketEntry { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> BucketEntryType { Self::discriminant(self) } } -impl Variants for LedgerEntryExtensionV1Ext { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for BucketEntry { + fn variants() -> slice::Iter<'static, BucketEntryType> { Self::VARIANTS.iter() } } -impl Union for LedgerEntryExtensionV1Ext {} +impl Union for BucketEntry {} -impl ReadXdr for LedgerEntryExtensionV1Ext { +impl ReadXdr for BucketEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: BucketEntryType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, + BucketEntryType::Liveentry => Self::Liveentry(LedgerEntry::read_xdr(r)?), + BucketEntryType::Initentry => Self::Initentry(LedgerEntry::read_xdr(r)?), + BucketEntryType::Deadentry => Self::Deadentry(LedgerKey::read_xdr(r)?), + BucketEntryType::Metaentry => Self::Metaentry(BucketMetadata::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -8731,34 +17705,133 @@ impl ReadXdr for LedgerEntryExtensionV1Ext { } } -impl WriteXdr for LedgerEntryExtensionV1Ext { +impl WriteXdr for BucketEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::Liveentry(v) => v.write_xdr(w)?, + Self::Initentry(v) => v.write_xdr(w)?, + Self::Deadentry(v) => v.write_xdr(w)?, + Self::Metaentry(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// LedgerEntryExtensionV1 is an XDR Struct defines as: +// TxSetComponentType is an XDR Enum defines as: // -// struct LedgerEntryExtensionV1 +// enum TxSetComponentType // { -// SponsorshipDescriptor sponsoringID; -// -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// // txs with effective fee <= bid derived from a base fee (if any). +// // If base fee is not specified, no discount is applied. +// TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE = 0 // }; // +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum TxSetComponentType { + TxsetCompTxsMaybeDiscountedFee = 0, +} + +impl TxSetComponentType { + pub const VARIANTS: [TxSetComponentType; 1] = + [TxSetComponentType::TxsetCompTxsMaybeDiscountedFee]; + pub const VARIANTS_STR: [&'static str; 1] = ["TxsetCompTxsMaybeDiscountedFee"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::TxsetCompTxsMaybeDiscountedFee => "TxsetCompTxsMaybeDiscountedFee", + } + } + + #[must_use] + pub const fn variants() -> [TxSetComponentType; 1] { + Self::VARIANTS + } +} + +impl Name for TxSetComponentType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for TxSetComponentType { + fn variants() -> slice::Iter<'static, TxSetComponentType> { + Self::VARIANTS.iter() + } +} + +impl Enum for TxSetComponentType {} + +impl fmt::Display for TxSetComponentType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for TxSetComponentType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => TxSetComponentType::TxsetCompTxsMaybeDiscountedFee, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: TxSetComponentType) -> Self { + e as Self + } +} + +impl ReadXdr for TxSetComponentType { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for TxSetComponentType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// TxSetComponentTxsMaybeDiscountedFee is an XDR NestedStruct defines as: +// +// struct +// { +// int64* baseFee; +// TransactionEnvelope txs<>; +// } +// #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -8766,53 +17839,47 @@ impl WriteXdr for LedgerEntryExtensionV1Ext { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerEntryExtensionV1 { - pub sponsoring_id: SponsorshipDescriptor, - pub ext: LedgerEntryExtensionV1Ext, +pub struct TxSetComponentTxsMaybeDiscountedFee { + pub base_fee: Option, + pub txs: VecM, } -impl ReadXdr for LedgerEntryExtensionV1 { +impl ReadXdr for TxSetComponentTxsMaybeDiscountedFee { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - sponsoring_id: SponsorshipDescriptor::read_xdr(r)?, - ext: LedgerEntryExtensionV1Ext::read_xdr(r)?, + base_fee: Option::::read_xdr(r)?, + txs: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerEntryExtensionV1 { +impl WriteXdr for TxSetComponentTxsMaybeDiscountedFee { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.sponsoring_id.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.base_fee.write_xdr(w)?; + self.txs.write_xdr(w)?; Ok(()) }) } } -// LedgerEntryData is an XDR NestedUnion defines as: +// TxSetComponent is an XDR Union defines as: // -// union switch (LedgerEntryType type) -// { -// case ACCOUNT: -// AccountEntry account; -// case TRUSTLINE: -// TrustLineEntry trustLine; -// case OFFER: -// OfferEntry offer; -// case DATA: -// DataEntry data; -// case CLAIMABLE_BALANCE: -// ClaimableBalanceEntry claimableBalance; -// case LIQUIDITY_POOL: -// LiquidityPoolEntry liquidityPool; -// } +// union TxSetComponent switch (TxSetComponentType type) +// { +// case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: +// struct +// { +// int64* baseFee; +// TransactionEnvelope txs<>; +// } txsMaybeDiscountedFee; +// }; // -// union with discriminant LedgerEntryType +// union with discriminant TxSetComponentType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -8821,102 +17888,71 @@ impl WriteXdr for LedgerEntryExtensionV1 { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerEntryData { - Account(AccountEntry), - Trustline(TrustLineEntry), - Offer(OfferEntry), - Data(DataEntry), - ClaimableBalance(ClaimableBalanceEntry), - LiquidityPool(LiquidityPoolEntry), +pub enum TxSetComponent { + TxsetCompTxsMaybeDiscountedFee(TxSetComponentTxsMaybeDiscountedFee), } -impl LedgerEntryData { - pub const VARIANTS: [LedgerEntryType; 6] = [ - LedgerEntryType::Account, - LedgerEntryType::Trustline, - LedgerEntryType::Offer, - LedgerEntryType::Data, - LedgerEntryType::ClaimableBalance, - LedgerEntryType::LiquidityPool, - ]; - pub const VARIANTS_STR: [&'static str; 6] = [ - "Account", - "Trustline", - "Offer", - "Data", - "ClaimableBalance", - "LiquidityPool", - ]; +impl TxSetComponent { + pub const VARIANTS: [TxSetComponentType; 1] = + [TxSetComponentType::TxsetCompTxsMaybeDiscountedFee]; + pub const VARIANTS_STR: [&'static str; 1] = ["TxsetCompTxsMaybeDiscountedFee"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Account(_) => "Account", - Self::Trustline(_) => "Trustline", - Self::Offer(_) => "Offer", - Self::Data(_) => "Data", - Self::ClaimableBalance(_) => "ClaimableBalance", - Self::LiquidityPool(_) => "LiquidityPool", + Self::TxsetCompTxsMaybeDiscountedFee(_) => "TxsetCompTxsMaybeDiscountedFee", } } #[must_use] - pub const fn discriminant(&self) -> LedgerEntryType { + pub const fn discriminant(&self) -> TxSetComponentType { #[allow(clippy::match_same_arms)] match self { - Self::Account(_) => LedgerEntryType::Account, - Self::Trustline(_) => LedgerEntryType::Trustline, - Self::Offer(_) => LedgerEntryType::Offer, - Self::Data(_) => LedgerEntryType::Data, - Self::ClaimableBalance(_) => LedgerEntryType::ClaimableBalance, - Self::LiquidityPool(_) => LedgerEntryType::LiquidityPool, + Self::TxsetCompTxsMaybeDiscountedFee(_) => { + TxSetComponentType::TxsetCompTxsMaybeDiscountedFee + } } } #[must_use] - pub const fn variants() -> [LedgerEntryType; 6] { + pub const fn variants() -> [TxSetComponentType; 1] { Self::VARIANTS } } -impl Name for LedgerEntryData { +impl Name for TxSetComponent { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerEntryData { +impl Discriminant for TxSetComponent { #[must_use] - fn discriminant(&self) -> LedgerEntryType { + fn discriminant(&self) -> TxSetComponentType { Self::discriminant(self) } } -impl Variants for LedgerEntryData { - fn variants() -> slice::Iter<'static, LedgerEntryType> { +impl Variants for TxSetComponent { + fn variants() -> slice::Iter<'static, TxSetComponentType> { Self::VARIANTS.iter() } } -impl Union for LedgerEntryData {} +impl Union for TxSetComponent {} -impl ReadXdr for LedgerEntryData { +impl ReadXdr for TxSetComponent { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LedgerEntryType = ::read_xdr(r)?; + let dv: TxSetComponentType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - LedgerEntryType::Account => Self::Account(AccountEntry::read_xdr(r)?), - LedgerEntryType::Trustline => Self::Trustline(TrustLineEntry::read_xdr(r)?), - LedgerEntryType::Offer => Self::Offer(OfferEntry::read_xdr(r)?), - LedgerEntryType::Data => Self::Data(DataEntry::read_xdr(r)?), - LedgerEntryType::ClaimableBalance => { - Self::ClaimableBalance(ClaimableBalanceEntry::read_xdr(r)?) - } - LedgerEntryType::LiquidityPool => { - Self::LiquidityPool(LiquidityPoolEntry::read_xdr(r)?) + TxSetComponentType::TxsetCompTxsMaybeDiscountedFee => { + Self::TxsetCompTxsMaybeDiscountedFee( + TxSetComponentTxsMaybeDiscountedFee::read_xdr(r)?, + ) } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), @@ -8926,34 +17962,27 @@ impl ReadXdr for LedgerEntryData { } } -impl WriteXdr for LedgerEntryData { +impl WriteXdr for TxSetComponent { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Account(v) => v.write_xdr(w)?, - Self::Trustline(v) => v.write_xdr(w)?, - Self::Offer(v) => v.write_xdr(w)?, - Self::Data(v) => v.write_xdr(w)?, - Self::ClaimableBalance(v) => v.write_xdr(w)?, - Self::LiquidityPool(v) => v.write_xdr(w)?, + Self::TxsetCompTxsMaybeDiscountedFee(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// LedgerEntryExt is an XDR NestedUnion defines as: +// TransactionPhase is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// LedgerEntryExtensionV1 v1; -// } +// union TransactionPhase switch (int v) +// { +// case 0: +// TxSetComponent v0Components<>; +// }; // // union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -8964,20 +17993,18 @@ impl WriteXdr for LedgerEntryData { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerEntryExt { - V0, - V1(LedgerEntryExtensionV1), +pub enum TransactionPhase { + V0(VecM), } -impl LedgerEntryExt { - pub const VARIANTS: [i32; 2] = [0, 1]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; +impl TransactionPhase { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", - Self::V1(_) => "V1", + Self::V0(_) => "V0", } } @@ -8985,48 +18012,46 @@ impl LedgerEntryExt { pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, - Self::V1(_) => 1, + Self::V0(_) => 0, } } #[must_use] - pub const fn variants() -> [i32; 2] { + pub const fn variants() -> [i32; 1] { Self::VARIANTS } } -impl Name for LedgerEntryExt { +impl Name for TransactionPhase { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerEntryExt { +impl Discriminant for TransactionPhase { #[must_use] fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for LedgerEntryExt { +impl Variants for TransactionPhase { fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for LedgerEntryExt {} +impl Union for TransactionPhase {} -impl ReadXdr for LedgerEntryExt { +impl ReadXdr for TransactionPhase { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, - 1 => Self::V1(LedgerEntryExtensionV1::read_xdr(r)?), + 0 => Self::V0(VecM::::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -9035,53 +18060,26 @@ impl ReadXdr for LedgerEntryExt { } } -impl WriteXdr for LedgerEntryExt { +impl WriteXdr for TransactionPhase { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// LedgerEntry is an XDR Struct defines as: +// TransactionSet is an XDR Struct defines as: // -// struct LedgerEntry +// struct TransactionSet // { -// uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed -// -// union switch (LedgerEntryType type) -// { -// case ACCOUNT: -// AccountEntry account; -// case TRUSTLINE: -// TrustLineEntry trustLine; -// case OFFER: -// OfferEntry offer; -// case DATA: -// DataEntry data; -// case CLAIMABLE_BALANCE: -// ClaimableBalanceEntry claimableBalance; -// case LIQUIDITY_POOL: -// LiquidityPoolEntry liquidityPool; -// } -// data; -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// LedgerEntryExtensionV1 v1; -// } -// ext; +// Hash previousLedgerHash; +// TransactionEnvelope txs<>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -9091,43 +18089,41 @@ impl WriteXdr for LedgerEntryExt { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerEntry { - pub last_modified_ledger_seq: u32, - pub data: LedgerEntryData, - pub ext: LedgerEntryExt, +pub struct TransactionSet { + pub previous_ledger_hash: Hash, + pub txs: VecM, } -impl ReadXdr for LedgerEntry { +impl ReadXdr for TransactionSet { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - last_modified_ledger_seq: u32::read_xdr(r)?, - data: LedgerEntryData::read_xdr(r)?, - ext: LedgerEntryExt::read_xdr(r)?, + previous_ledger_hash: Hash::read_xdr(r)?, + txs: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerEntry { +impl WriteXdr for TransactionSet { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.last_modified_ledger_seq.write_xdr(w)?; - self.data.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.previous_ledger_hash.write_xdr(w)?; + self.txs.write_xdr(w)?; Ok(()) }) } } -// LedgerKeyAccount is an XDR NestedStruct defines as: +// TransactionSetV1 is an XDR Struct defines as: // -// struct -// { -// AccountID accountID; -// } +// struct TransactionSetV1 +// { +// Hash previousLedgerHash; +// TransactionPhase phases<>; +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -9136,39 +18132,44 @@ impl WriteXdr for LedgerEntry { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerKeyAccount { - pub account_id: AccountId, +pub struct TransactionSetV1 { + pub previous_ledger_hash: Hash, + pub phases: VecM, } -impl ReadXdr for LedgerKeyAccount { +impl ReadXdr for TransactionSetV1 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - account_id: AccountId::read_xdr(r)?, + previous_ledger_hash: Hash::read_xdr(r)?, + phases: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerKeyAccount { +impl WriteXdr for TransactionSetV1 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.account_id.write_xdr(w)?; + self.previous_ledger_hash.write_xdr(w)?; + self.phases.write_xdr(w)?; Ok(()) }) } } -// LedgerKeyTrustLine is an XDR NestedStruct defines as: +// GeneralizedTransactionSet is an XDR Union defines as: // -// struct -// { -// AccountID accountID; -// TrustLineAsset asset; -// } +// union GeneralizedTransactionSet switch (int v) +// { +// // We consider the legacy TransactionSet to be v0. +// case 1: +// TransactionSetV1 v1TxSet; +// }; // +// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -9176,126 +18177,95 @@ impl WriteXdr for LedgerKeyAccount { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerKeyTrustLine { - pub account_id: AccountId, - pub asset: TrustLineAsset, +#[allow(clippy::large_enum_variant)] +pub enum GeneralizedTransactionSet { + V1(TransactionSetV1), } -impl ReadXdr for LedgerKeyTrustLine { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - account_id: AccountId::read_xdr(r)?, - asset: TrustLineAsset::read_xdr(r)?, - }) - }) +impl GeneralizedTransactionSet { + pub const VARIANTS: [i32; 1] = [1]; + pub const VARIANTS_STR: [&'static str; 1] = ["V1"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::V1(_) => "V1", + } } -} -impl WriteXdr for LedgerKeyTrustLine { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.account_id.write_xdr(w)?; - self.asset.write_xdr(w)?; - Ok(()) - }) + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V1(_) => 1, + } } -} -// LedgerKeyOffer is an XDR NestedStruct defines as: -// -// struct -// { -// AccountID sellerID; -// int64 offerID; -// } -// -#[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 LedgerKeyOffer { - pub seller_id: AccountId, - pub offer_id: i64, + #[must_use] + pub const fn variants() -> [i32; 1] { + Self::VARIANTS + } } -impl ReadXdr for LedgerKeyOffer { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - seller_id: AccountId::read_xdr(r)?, - offer_id: i64::read_xdr(r)?, - }) - }) +impl Name for GeneralizedTransactionSet { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) } } -impl WriteXdr for LedgerKeyOffer { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.seller_id.write_xdr(w)?; - self.offer_id.write_xdr(w)?; - Ok(()) - }) +impl Discriminant for GeneralizedTransactionSet { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) } } -// LedgerKeyData is an XDR NestedStruct defines as: -// -// struct -// { -// AccountID accountID; -// string64 dataName; -// } -// -#[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 LedgerKeyData { - pub account_id: AccountId, - pub data_name: String64, +impl Variants for GeneralizedTransactionSet { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() + } } -impl ReadXdr for LedgerKeyData { +impl Union for GeneralizedTransactionSet {} + +impl ReadXdr for GeneralizedTransactionSet { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - account_id: AccountId::read_xdr(r)?, - data_name: String64::read_xdr(r)?, - }) + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 1 => Self::V1(TransactionSetV1::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) }) } } -impl WriteXdr for LedgerKeyData { +impl WriteXdr for GeneralizedTransactionSet { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.account_id.write_xdr(w)?; - self.data_name.write_xdr(w)?; + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V1(v) => v.write_xdr(w)?, + }; Ok(()) }) } } -// LedgerKeyClaimableBalance is an XDR NestedStruct defines as: +// TransactionResultPair is an XDR Struct defines as: // -// struct -// { -// ClaimableBalanceID balanceID; -// } +// struct TransactionResultPair +// { +// Hash transactionHash; +// TransactionResult result; // result for the transaction +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -9304,37 +18274,40 @@ impl WriteXdr for LedgerKeyData { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerKeyClaimableBalance { - pub balance_id: ClaimableBalanceId, +pub struct TransactionResultPair { + pub transaction_hash: Hash, + pub result: TransactionResult, } -impl ReadXdr for LedgerKeyClaimableBalance { +impl ReadXdr for TransactionResultPair { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - balance_id: ClaimableBalanceId::read_xdr(r)?, + transaction_hash: Hash::read_xdr(r)?, + result: TransactionResult::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerKeyClaimableBalance { +impl WriteXdr for TransactionResultPair { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.balance_id.write_xdr(w)?; + self.transaction_hash.write_xdr(w)?; + self.result.write_xdr(w)?; Ok(()) }) } } -// LedgerKeyLiquidityPool is an XDR NestedStruct defines as: +// TransactionResultSet is an XDR Struct defines as: // -// struct -// { -// PoolID liquidityPoolID; -// } +// struct TransactionResultSet +// { +// TransactionResultPair results<>; +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -9343,76 +18316,42 @@ impl WriteXdr for LedgerKeyClaimableBalance { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerKeyLiquidityPool { - pub liquidity_pool_id: PoolId, +pub struct TransactionResultSet { + pub results: VecM, } -impl ReadXdr for LedgerKeyLiquidityPool { +impl ReadXdr for TransactionResultSet { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - liquidity_pool_id: PoolId::read_xdr(r)?, + results: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerKeyLiquidityPool { +impl WriteXdr for TransactionResultSet { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.liquidity_pool_id.write_xdr(w)?; + self.results.write_xdr(w)?; Ok(()) }) } } -// LedgerKey is an XDR Union defines as: -// -// union LedgerKey switch (LedgerEntryType type) -// { -// case ACCOUNT: -// struct -// { -// AccountID accountID; -// } account; -// -// case TRUSTLINE: -// struct -// { -// AccountID accountID; -// TrustLineAsset asset; -// } trustLine; -// -// case OFFER: -// struct -// { -// AccountID sellerID; -// int64 offerID; -// } offer; -// -// case DATA: -// struct -// { -// AccountID accountID; -// string64 dataName; -// } data; -// -// case CLAIMABLE_BALANCE: -// struct -// { -// ClaimableBalanceID balanceID; -// } claimableBalance; +// TransactionHistoryEntryExt is an XDR NestedUnion defines as: // -// case LIQUIDITY_POOL: -// struct +// union switch (int v) // { -// PoolID liquidityPoolID; -// } liquidityPool; -// }; +// case 0: +// void; +// case 1: +// GeneralizedTransactionSet generalizedTxSet; +// } // -// union with discriminant LedgerEntryType +// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -9421,103 +18360,69 @@ impl WriteXdr for LedgerKeyLiquidityPool { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerKey { - Account(LedgerKeyAccount), - Trustline(LedgerKeyTrustLine), - Offer(LedgerKeyOffer), - Data(LedgerKeyData), - ClaimableBalance(LedgerKeyClaimableBalance), - LiquidityPool(LedgerKeyLiquidityPool), +pub enum TransactionHistoryEntryExt { + V0, + V1(GeneralizedTransactionSet), } -impl LedgerKey { - pub const VARIANTS: [LedgerEntryType; 6] = [ - LedgerEntryType::Account, - LedgerEntryType::Trustline, - LedgerEntryType::Offer, - LedgerEntryType::Data, - LedgerEntryType::ClaimableBalance, - LedgerEntryType::LiquidityPool, - ]; - pub const VARIANTS_STR: [&'static str; 6] = [ - "Account", - "Trustline", - "Offer", - "Data", - "ClaimableBalance", - "LiquidityPool", - ]; +impl TransactionHistoryEntryExt { + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Account(_) => "Account", - Self::Trustline(_) => "Trustline", - Self::Offer(_) => "Offer", - Self::Data(_) => "Data", - Self::ClaimableBalance(_) => "ClaimableBalance", - Self::LiquidityPool(_) => "LiquidityPool", + Self::V0 => "V0", + Self::V1(_) => "V1", } } #[must_use] - pub const fn discriminant(&self) -> LedgerEntryType { + pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::Account(_) => LedgerEntryType::Account, - Self::Trustline(_) => LedgerEntryType::Trustline, - Self::Offer(_) => LedgerEntryType::Offer, - Self::Data(_) => LedgerEntryType::Data, - Self::ClaimableBalance(_) => LedgerEntryType::ClaimableBalance, - Self::LiquidityPool(_) => LedgerEntryType::LiquidityPool, + Self::V0 => 0, + Self::V1(_) => 1, } } #[must_use] - pub const fn variants() -> [LedgerEntryType; 6] { + pub const fn variants() -> [i32; 2] { Self::VARIANTS } } -impl Name for LedgerKey { +impl Name for TransactionHistoryEntryExt { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerKey { +impl Discriminant for TransactionHistoryEntryExt { #[must_use] - fn discriminant(&self) -> LedgerEntryType { + fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for LedgerKey { - fn variants() -> slice::Iter<'static, LedgerEntryType> { +impl Variants for TransactionHistoryEntryExt { + fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for LedgerKey {} +impl Union for TransactionHistoryEntryExt {} -impl ReadXdr for LedgerKey { +impl ReadXdr for TransactionHistoryEntryExt { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LedgerEntryType = ::read_xdr(r)?; + let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - LedgerEntryType::Account => Self::Account(LedgerKeyAccount::read_xdr(r)?), - LedgerEntryType::Trustline => Self::Trustline(LedgerKeyTrustLine::read_xdr(r)?), - LedgerEntryType::Offer => Self::Offer(LedgerKeyOffer::read_xdr(r)?), - LedgerEntryType::Data => Self::Data(LedgerKeyData::read_xdr(r)?), - LedgerEntryType::ClaimableBalance => { - Self::ClaimableBalance(LedgerKeyClaimableBalance::read_xdr(r)?) - } - LedgerEntryType::LiquidityPool => { - Self::LiquidityPool(LedgerKeyLiquidityPool::read_xdr(r)?) - } + 0 => Self::V0, + 1 => Self::V1(GeneralizedTransactionSet::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -9526,381 +18431,430 @@ impl ReadXdr for LedgerKey { } } -impl WriteXdr for LedgerKey { +impl WriteXdr for TransactionHistoryEntryExt { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Account(v) => v.write_xdr(w)?, - Self::Trustline(v) => v.write_xdr(w)?, - Self::Offer(v) => v.write_xdr(w)?, - Self::Data(v) => v.write_xdr(w)?, - Self::ClaimableBalance(v) => v.write_xdr(w)?, - Self::LiquidityPool(v) => v.write_xdr(w)?, + Self::V0 => ().write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// EnvelopeType is an XDR Enum defines as: +// TransactionHistoryEntry is an XDR Struct defines as: // -// enum EnvelopeType +// struct TransactionHistoryEntry // { -// ENVELOPE_TYPE_TX_V0 = 0, -// ENVELOPE_TYPE_SCP = 1, -// ENVELOPE_TYPE_TX = 2, -// ENVELOPE_TYPE_AUTH = 3, -// ENVELOPE_TYPE_SCPVALUE = 4, -// ENVELOPE_TYPE_TX_FEE_BUMP = 5, -// ENVELOPE_TYPE_OP_ID = 6, -// ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7 +// uint32 ledgerSeq; +// TransactionSet txSet; +// +// // when v != 0, txSet must be empty +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// GeneralizedTransactionSet generalizedTxSet; +// } +// ext; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[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") )] -#[repr(i32)] -pub enum EnvelopeType { - TxV0 = 0, - Scp = 1, - Tx = 2, - Auth = 3, - Scpvalue = 4, - TxFeeBump = 5, - OpId = 6, - PoolRevokeOpId = 7, +pub struct TransactionHistoryEntry { + pub ledger_seq: u32, + pub tx_set: TransactionSet, + pub ext: TransactionHistoryEntryExt, } -impl EnvelopeType { - pub const VARIANTS: [EnvelopeType; 8] = [ - EnvelopeType::TxV0, - EnvelopeType::Scp, - EnvelopeType::Tx, - EnvelopeType::Auth, - EnvelopeType::Scpvalue, - EnvelopeType::TxFeeBump, - EnvelopeType::OpId, - EnvelopeType::PoolRevokeOpId, - ]; - pub const VARIANTS_STR: [&'static str; 8] = [ - "TxV0", - "Scp", - "Tx", - "Auth", - "Scpvalue", - "TxFeeBump", - "OpId", - "PoolRevokeOpId", - ]; +impl ReadXdr for TransactionHistoryEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ledger_seq: u32::read_xdr(r)?, + tx_set: TransactionSet::read_xdr(r)?, + ext: TransactionHistoryEntryExt::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for TransactionHistoryEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ledger_seq.write_xdr(w)?; + self.tx_set.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) + } +} + +// TransactionHistoryResultEntryExt is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// void; +// } +// +// union with discriminant i32 +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum TransactionHistoryResultEntryExt { + V0, +} + +impl TransactionHistoryResultEntryExt { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::TxV0 => "TxV0", - Self::Scp => "Scp", - Self::Tx => "Tx", - Self::Auth => "Auth", - Self::Scpvalue => "Scpvalue", - Self::TxFeeBump => "TxFeeBump", - Self::OpId => "OpId", - Self::PoolRevokeOpId => "PoolRevokeOpId", + Self::V0 => "V0", + } + } + + #[must_use] + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, } } #[must_use] - pub const fn variants() -> [EnvelopeType; 8] { + pub const fn variants() -> [i32; 1] { Self::VARIANTS } } -impl Name for EnvelopeType { +impl Name for TransactionHistoryResultEntryExt { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for EnvelopeType { - fn variants() -> slice::Iter<'static, EnvelopeType> { - Self::VARIANTS.iter() - } -} - -impl Enum for EnvelopeType {} - -impl fmt::Display for EnvelopeType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Discriminant for TransactionHistoryResultEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) } } -impl TryFrom for EnvelopeType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => EnvelopeType::TxV0, - 1 => EnvelopeType::Scp, - 2 => EnvelopeType::Tx, - 3 => EnvelopeType::Auth, - 4 => EnvelopeType::Scpvalue, - 5 => EnvelopeType::TxFeeBump, - 6 => EnvelopeType::OpId, - 7 => EnvelopeType::PoolRevokeOpId, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl Variants for TransactionHistoryResultEntryExt { + fn variants() -> slice::Iter<'static, i32> { + Self::VARIANTS.iter() } } -impl From for i32 { - #[must_use] - fn from(e: EnvelopeType) -> Self { - e as Self - } -} +impl Union for TransactionHistoryResultEntryExt {} -impl ReadXdr for EnvelopeType { +impl ReadXdr for TransactionHistoryResultEntryExt { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for EnvelopeType { +impl WriteXdr for TransactionHistoryResultEntryExt { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) }) } } -// UpgradeType is an XDR Typedef defines as: +// TransactionHistoryResultEntry is an XDR Struct defines as: // -// typedef opaque UpgradeType<128>; +// struct TransactionHistoryResultEntry +// { +// uint32 ledgerSeq; +// TransactionResultSet txResultSet; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +// +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct UpgradeType(pub BytesM<128>); - -impl From for BytesM<128> { - #[must_use] - fn from(x: UpgradeType) -> Self { - x.0 - } -} - -impl From> for UpgradeType { - #[must_use] - fn from(x: BytesM<128>) -> Self { - UpgradeType(x) - } -} - -impl AsRef> for UpgradeType { - #[must_use] - fn as_ref(&self) -> &BytesM<128> { - &self.0 - } +pub struct TransactionHistoryResultEntry { + pub ledger_seq: u32, + pub tx_result_set: TransactionResultSet, + pub ext: TransactionHistoryResultEntryExt, } -impl ReadXdr for UpgradeType { +impl ReadXdr for TransactionHistoryResultEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = BytesM::<128>::read_xdr(r)?; - let v = UpgradeType(i); - Ok(v) + Ok(Self { + ledger_seq: u32::read_xdr(r)?, + tx_result_set: TransactionResultSet::read_xdr(r)?, + ext: TransactionHistoryResultEntryExt::read_xdr(r)?, + }) }) } } -impl WriteXdr for UpgradeType { +impl WriteXdr for TransactionHistoryResultEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} - -impl Deref for UpgradeType { - type Target = BytesM<128>; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From for Vec { - #[must_use] - fn from(x: UpgradeType) -> Self { - x.0 .0 - } -} - -impl TryFrom> for UpgradeType { - type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(UpgradeType(x.try_into()?)) - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for UpgradeType { - type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(UpgradeType(x.try_into()?)) - } -} - -impl AsRef> for UpgradeType { - #[must_use] - fn as_ref(&self) -> &Vec { - &self.0 .0 - } -} - -impl AsRef<[u8]> for UpgradeType { - #[cfg(feature = "alloc")] - #[must_use] - fn as_ref(&self) -> &[u8] { - &self.0 .0 - } - #[cfg(not(feature = "alloc"))] - #[must_use] - fn as_ref(&self) -> &[u8] { - self.0 .0 + w.with_limited_depth(|w| { + self.ledger_seq.write_xdr(w)?; + self.tx_result_set.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) } } -// StellarValueType is an XDR Enum defines as: +// LedgerHeaderHistoryEntryExt is an XDR NestedUnion defines as: // -// enum StellarValueType -// { -// STELLAR_VALUE_BASIC = 0, -// STELLAR_VALUE_SIGNED = 1 -// }; +// union switch (int v) +// { +// case 0: +// void; +// } // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant i32 +#[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") )] -#[repr(i32)] -pub enum StellarValueType { - Basic = 0, - Signed = 1, +#[allow(clippy::large_enum_variant)] +pub enum LedgerHeaderHistoryEntryExt { + V0, } -impl StellarValueType { - pub const VARIANTS: [StellarValueType; 2] = [StellarValueType::Basic, StellarValueType::Signed]; - pub const VARIANTS_STR: [&'static str; 2] = ["Basic", "Signed"]; +impl LedgerHeaderHistoryEntryExt { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Basic => "Basic", - Self::Signed => "Signed", + Self::V0 => "V0", } } #[must_use] - pub const fn variants() -> [StellarValueType; 2] { + pub const fn discriminant(&self) -> i32 { + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => 0, + } + } + + #[must_use] + pub const fn variants() -> [i32; 1] { Self::VARIANTS } } -impl Name for StellarValueType { +impl Name for LedgerHeaderHistoryEntryExt { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for StellarValueType { - fn variants() -> slice::Iter<'static, StellarValueType> { +impl Discriminant for LedgerHeaderHistoryEntryExt { + #[must_use] + fn discriminant(&self) -> i32 { + Self::discriminant(self) + } +} + +impl Variants for LedgerHeaderHistoryEntryExt { + fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Enum for StellarValueType {} +impl Union for LedgerHeaderHistoryEntryExt {} -impl fmt::Display for StellarValueType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl ReadXdr for LedgerHeaderHistoryEntryExt { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: i32 = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + 0 => Self::V0, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) } } -impl TryFrom for StellarValueType { - type Error = Error; +impl WriteXdr for LedgerHeaderHistoryEntryExt { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::V0 => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} - fn try_from(i: i32) -> Result { - let e = match i { - 0 => StellarValueType::Basic, - 1 => StellarValueType::Signed, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +// LedgerHeaderHistoryEntry is an XDR Struct defines as: +// +// struct LedgerHeaderHistoryEntry +// { +// Hash hash; +// LedgerHeader header; +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +// +#[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 LedgerHeaderHistoryEntry { + pub hash: Hash, + pub header: LedgerHeader, + pub ext: LedgerHeaderHistoryEntryExt, +} + +impl ReadXdr for LedgerHeaderHistoryEntry { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + hash: Hash::read_xdr(r)?, + header: LedgerHeader::read_xdr(r)?, + ext: LedgerHeaderHistoryEntryExt::read_xdr(r)?, + }) + }) } } -impl From for i32 { - #[must_use] - fn from(e: StellarValueType) -> Self { - e as Self +impl WriteXdr for LedgerHeaderHistoryEntry { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.hash.write_xdr(w)?; + self.header.write_xdr(w)?; + self.ext.write_xdr(w)?; + Ok(()) + }) } } -impl ReadXdr for StellarValueType { +// LedgerScpMessages is an XDR Struct defines as: +// +// struct LedgerSCPMessages +// { +// uint32 ledgerSeq; +// SCPEnvelope messages<>; +// }; +// +#[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 LedgerScpMessages { + pub ledger_seq: u32, + pub messages: VecM, +} + +impl ReadXdr for LedgerScpMessages { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) + Ok(Self { + ledger_seq: u32::read_xdr(r)?, + messages: VecM::::read_xdr(r)?, + }) }) } } -impl WriteXdr for StellarValueType { +impl WriteXdr for LedgerScpMessages { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.ledger_seq.write_xdr(w)?; + self.messages.write_xdr(w)?; + Ok(()) }) } } -// LedgerCloseValueSignature is an XDR Struct defines as: +// ScpHistoryEntryV0 is an XDR Struct defines as: // -// struct LedgerCloseValueSignature +// struct SCPHistoryEntryV0 // { -// NodeID nodeID; // which node introduced the value -// Signature signature; // nodeID's signature +// SCPQuorumSet quorumSets<>; // additional quorum sets used by ledgerMessages +// LedgerSCPMessages ledgerMessages; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -9910,45 +18864,43 @@ impl WriteXdr for StellarValueType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerCloseValueSignature { - pub node_id: NodeId, - pub signature: Signature, +pub struct ScpHistoryEntryV0 { + pub quorum_sets: VecM, + pub ledger_messages: LedgerScpMessages, } -impl ReadXdr for LedgerCloseValueSignature { +impl ReadXdr for ScpHistoryEntryV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - node_id: NodeId::read_xdr(r)?, - signature: Signature::read_xdr(r)?, + quorum_sets: VecM::::read_xdr(r)?, + ledger_messages: LedgerScpMessages::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerCloseValueSignature { +impl WriteXdr for ScpHistoryEntryV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.node_id.write_xdr(w)?; - self.signature.write_xdr(w)?; + self.quorum_sets.write_xdr(w)?; + self.ledger_messages.write_xdr(w)?; Ok(()) }) } } -// StellarValueExt is an XDR NestedUnion defines as: +// ScpHistoryEntry is an XDR Union defines as: // -// union switch (StellarValueType v) -// { -// case STELLAR_VALUE_BASIC: -// void; -// case STELLAR_VALUE_SIGNED: -// LedgerCloseValueSignature lcValueSignature; -// } +// union SCPHistoryEntry switch (int v) +// { +// case 0: +// SCPHistoryEntryV0 v0; +// }; // -// union with discriminant StellarValueType +// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -9957,69 +18909,65 @@ impl WriteXdr for LedgerCloseValueSignature { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum StellarValueExt { - Basic, - Signed(LedgerCloseValueSignature), +pub enum ScpHistoryEntry { + V0(ScpHistoryEntryV0), } -impl StellarValueExt { - pub const VARIANTS: [StellarValueType; 2] = [StellarValueType::Basic, StellarValueType::Signed]; - pub const VARIANTS_STR: [&'static str; 2] = ["Basic", "Signed"]; +impl ScpHistoryEntry { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Basic => "Basic", - Self::Signed(_) => "Signed", + Self::V0(_) => "V0", } } #[must_use] - pub const fn discriminant(&self) -> StellarValueType { + pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::Basic => StellarValueType::Basic, - Self::Signed(_) => StellarValueType::Signed, + Self::V0(_) => 0, } } #[must_use] - pub const fn variants() -> [StellarValueType; 2] { + pub const fn variants() -> [i32; 1] { Self::VARIANTS } } -impl Name for StellarValueExt { +impl Name for ScpHistoryEntry { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for StellarValueExt { +impl Discriminant for ScpHistoryEntry { #[must_use] - fn discriminant(&self) -> StellarValueType { + fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for StellarValueExt { - fn variants() -> slice::Iter<'static, StellarValueType> { +impl Variants for ScpHistoryEntry { + fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for StellarValueExt {} +impl Union for ScpHistoryEntry {} -impl ReadXdr for StellarValueExt { +impl ReadXdr for ScpHistoryEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: StellarValueType = ::read_xdr(r)?; + let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - StellarValueType::Basic => Self::Basic, - StellarValueType::Signed => Self::Signed(LedgerCloseValueSignature::read_xdr(r)?), + 0 => Self::V0(ScpHistoryEntryV0::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -10028,100 +18976,28 @@ impl ReadXdr for StellarValueExt { } } -impl WriteXdr for StellarValueExt { +impl WriteXdr for ScpHistoryEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Basic => ().write_xdr(w)?, - Self::Signed(v) => v.write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// StellarValue is an XDR Struct defines as: -// -// struct StellarValue -// { -// Hash txSetHash; // transaction set to apply to previous ledger -// TimePoint closeTime; // network close time -// -// // upgrades to apply to the previous ledger (usually empty) -// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop -// // unknown steps during consensus if needed. -// // see notes below on 'LedgerUpgrade' for more detail -// // max size is dictated by number of upgrade types (+ room for future) -// UpgradeType upgrades<6>; -// -// // reserved for future use -// union switch (StellarValueType v) -// { -// case STELLAR_VALUE_BASIC: -// void; -// case STELLAR_VALUE_SIGNED: -// LedgerCloseValueSignature lcValueSignature; -// } -// ext; -// }; -// -#[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 StellarValue { - pub tx_set_hash: Hash, - pub close_time: TimePoint, - pub upgrades: VecM, - pub ext: StellarValueExt, -} - -impl ReadXdr for StellarValue { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - tx_set_hash: Hash::read_xdr(r)?, - close_time: TimePoint::read_xdr(r)?, - upgrades: VecM::::read_xdr(r)?, - ext: StellarValueExt::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for StellarValue { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.tx_set_hash.write_xdr(w)?; - self.close_time.write_xdr(w)?; - self.upgrades.write_xdr(w)?; - self.ext.write_xdr(w)?; - Ok(()) - }) - } -} - -// MaskLedgerHeaderFlags is an XDR Const defines as: -// -// const MASK_LEDGER_HEADER_FLAGS = 0x7; -// -pub const MASK_LEDGER_HEADER_FLAGS: u64 = 0x7; - -// LedgerHeaderFlags is an XDR Enum defines as: +// LedgerEntryChangeType is an XDR Enum defines as: // -// enum LedgerHeaderFlags +// enum LedgerEntryChangeType // { -// DISABLE_LIQUIDITY_POOL_TRADING_FLAG = 0x1, -// DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG = 0x2, -// DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 0x4 +// LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger +// LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger +// LEDGER_ENTRY_REMOVED = 2, // entry was removed from the ledger +// LEDGER_ENTRY_STATE = 3 // value of the entry // }; // // enum @@ -10133,64 +19009,68 @@ pub const MASK_LEDGER_HEADER_FLAGS: u64 = 0x7; serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum LedgerHeaderFlags { - TradingFlag = 1, - DepositFlag = 2, - WithdrawalFlag = 4, +pub enum LedgerEntryChangeType { + Created = 0, + Updated = 1, + Removed = 2, + State = 3, } -impl LedgerHeaderFlags { - pub const VARIANTS: [LedgerHeaderFlags; 3] = [ - LedgerHeaderFlags::TradingFlag, - LedgerHeaderFlags::DepositFlag, - LedgerHeaderFlags::WithdrawalFlag, +impl LedgerEntryChangeType { + pub const VARIANTS: [LedgerEntryChangeType; 4] = [ + LedgerEntryChangeType::Created, + LedgerEntryChangeType::Updated, + LedgerEntryChangeType::Removed, + LedgerEntryChangeType::State, ]; - pub const VARIANTS_STR: [&'static str; 3] = ["TradingFlag", "DepositFlag", "WithdrawalFlag"]; + pub const VARIANTS_STR: [&'static str; 4] = ["Created", "Updated", "Removed", "State"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::TradingFlag => "TradingFlag", - Self::DepositFlag => "DepositFlag", - Self::WithdrawalFlag => "WithdrawalFlag", + Self::Created => "Created", + Self::Updated => "Updated", + Self::Removed => "Removed", + Self::State => "State", } } #[must_use] - pub const fn variants() -> [LedgerHeaderFlags; 3] { + pub const fn variants() -> [LedgerEntryChangeType; 4] { Self::VARIANTS } } -impl Name for LedgerHeaderFlags { +impl Name for LedgerEntryChangeType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for LedgerHeaderFlags { - fn variants() -> slice::Iter<'static, LedgerHeaderFlags> { +impl Variants for LedgerEntryChangeType { + fn variants() -> slice::Iter<'static, LedgerEntryChangeType> { Self::VARIANTS.iter() } } -impl Enum for LedgerHeaderFlags {} +impl Enum for LedgerEntryChangeType {} -impl fmt::Display for LedgerHeaderFlags { +impl fmt::Display for LedgerEntryChangeType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for LedgerHeaderFlags { +impl TryFrom for LedgerEntryChangeType { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 1 => LedgerHeaderFlags::TradingFlag, - 2 => LedgerHeaderFlags::DepositFlag, - 4 => LedgerHeaderFlags::WithdrawalFlag, + 0 => LedgerEntryChangeType::Created, + 1 => LedgerEntryChangeType::Updated, + 2 => LedgerEntryChangeType::Removed, + 3 => LedgerEntryChangeType::State, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -10198,14 +19078,14 @@ impl TryFrom for LedgerHeaderFlags { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: LedgerHeaderFlags) -> Self { + fn from(e: LedgerEntryChangeType) -> Self { e as Self } } -impl ReadXdr for LedgerHeaderFlags { +impl ReadXdr for LedgerEntryChangeType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -10216,7 +19096,7 @@ impl ReadXdr for LedgerHeaderFlags { } } -impl WriteXdr for LedgerHeaderFlags { +impl WriteXdr for LedgerEntryChangeType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -10226,15 +19106,21 @@ impl WriteXdr for LedgerHeaderFlags { } } -// LedgerHeaderExtensionV1Ext is an XDR NestedUnion defines as: +// LedgerEntryChange is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// union LedgerEntryChange switch (LedgerEntryChangeType type) +// { +// case LEDGER_ENTRY_CREATED: +// LedgerEntry created; +// case LEDGER_ENTRY_UPDATED: +// LedgerEntry updated; +// case LEDGER_ENTRY_REMOVED: +// LedgerKey removed; +// case LEDGER_ENTRY_STATE: +// LedgerEntry state; +// }; // -// union with discriminant i32 +// union with discriminant LedgerEntryChangeType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -10243,65 +19129,82 @@ impl WriteXdr for LedgerHeaderFlags { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerHeaderExtensionV1Ext { - V0, +pub enum LedgerEntryChange { + Created(LedgerEntry), + Updated(LedgerEntry), + Removed(LedgerKey), + State(LedgerEntry), } -impl LedgerHeaderExtensionV1Ext { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl LedgerEntryChange { + pub const VARIANTS: [LedgerEntryChangeType; 4] = [ + LedgerEntryChangeType::Created, + LedgerEntryChangeType::Updated, + LedgerEntryChangeType::Removed, + LedgerEntryChangeType::State, + ]; + pub const VARIANTS_STR: [&'static str; 4] = ["Created", "Updated", "Removed", "State"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::Created(_) => "Created", + Self::Updated(_) => "Updated", + Self::Removed(_) => "Removed", + Self::State(_) => "State", } } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> LedgerEntryChangeType { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::Created(_) => LedgerEntryChangeType::Created, + Self::Updated(_) => LedgerEntryChangeType::Updated, + Self::Removed(_) => LedgerEntryChangeType::Removed, + Self::State(_) => LedgerEntryChangeType::State, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [LedgerEntryChangeType; 4] { Self::VARIANTS } } -impl Name for LedgerHeaderExtensionV1Ext { +impl Name for LedgerEntryChange { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerHeaderExtensionV1Ext { +impl Discriminant for LedgerEntryChange { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> LedgerEntryChangeType { Self::discriminant(self) } } -impl Variants for LedgerHeaderExtensionV1Ext { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for LedgerEntryChange { + fn variants() -> slice::Iter<'static, LedgerEntryChangeType> { Self::VARIANTS.iter() } } -impl Union for LedgerHeaderExtensionV1Ext {} +impl Union for LedgerEntryChange {} -impl ReadXdr for LedgerHeaderExtensionV1Ext { +impl ReadXdr for LedgerEntryChange { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: LedgerEntryChangeType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, + LedgerEntryChangeType::Created => Self::Created(LedgerEntry::read_xdr(r)?), + LedgerEntryChangeType::Updated => Self::Updated(LedgerEntry::read_xdr(r)?), + LedgerEntryChangeType::Removed => Self::Removed(LedgerKey::read_xdr(r)?), + LedgerEntryChangeType::State => Self::State(LedgerEntry::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -10310,214 +19213,216 @@ impl ReadXdr for LedgerHeaderExtensionV1Ext { } } -impl WriteXdr for LedgerHeaderExtensionV1Ext { +impl WriteXdr for LedgerEntryChange { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::Created(v) => v.write_xdr(w)?, + Self::Updated(v) => v.write_xdr(w)?, + Self::Removed(v) => v.write_xdr(w)?, + Self::State(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// LedgerHeaderExtensionV1 is an XDR Struct defines as: -// -// struct LedgerHeaderExtensionV1 -// { -// uint32 flags; // LedgerHeaderFlags +// LedgerEntryChanges is an XDR Typedef defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; -// }; +// typedef LedgerEntryChange LedgerEntryChanges<>; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerHeaderExtensionV1 { - pub flags: u32, - pub ext: LedgerHeaderExtensionV1Ext, +pub struct LedgerEntryChanges(pub VecM); + +impl From for VecM { + #[must_use] + fn from(x: LedgerEntryChanges) -> Self { + x.0 + } } -impl ReadXdr for LedgerHeaderExtensionV1 { +impl From> for LedgerEntryChanges { + #[must_use] + fn from(x: VecM) -> Self { + LedgerEntryChanges(x) + } +} + +impl AsRef> for LedgerEntryChanges { + #[must_use] + fn as_ref(&self) -> &VecM { + &self.0 + } +} + +impl ReadXdr for LedgerEntryChanges { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - flags: u32::read_xdr(r)?, - ext: LedgerHeaderExtensionV1Ext::read_xdr(r)?, - }) + let i = VecM::::read_xdr(r)?; + let v = LedgerEntryChanges(i); + Ok(v) }) } } -impl WriteXdr for LedgerHeaderExtensionV1 { +impl WriteXdr for LedgerEntryChanges { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.flags.write_xdr(w)?; - self.ext.write_xdr(w)?; - Ok(()) - }) + w.with_limited_depth(|w| self.0.write_xdr(w)) } } -// LedgerHeaderExt is an XDR NestedUnion defines as: -// -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// LedgerHeaderExtensionV1 v1; -// } -// -// union with discriminant i32 -#[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") -)] -#[allow(clippy::large_enum_variant)] -pub enum LedgerHeaderExt { - V0, - V1(LedgerHeaderExtensionV1), +impl Deref for LedgerEntryChanges { + type Target = VecM; + fn deref(&self) -> &Self::Target { + &self.0 + } } -impl LedgerHeaderExt { - pub const VARIANTS: [i32; 2] = [0, 1]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; - +impl From for Vec { #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0 => "V0", - Self::V1(_) => "V1", - } + fn from(x: LedgerEntryChanges) -> Self { + x.0 .0 } +} - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, - Self::V1(_) => 1, - } +impl TryFrom> for LedgerEntryChanges { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(LedgerEntryChanges(x.try_into()?)) } +} - #[must_use] - pub const fn variants() -> [i32; 2] { - Self::VARIANTS +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for LedgerEntryChanges { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(LedgerEntryChanges(x.try_into()?)) } } -impl Name for LedgerHeaderExt { +impl AsRef> for LedgerEntryChanges { #[must_use] - fn name(&self) -> &'static str { - Self::name(self) + fn as_ref(&self) -> &Vec { + &self.0 .0 } } -impl Discriminant for LedgerHeaderExt { +impl AsRef<[LedgerEntryChange]> for LedgerEntryChanges { + #[cfg(feature = "alloc")] #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) + fn as_ref(&self) -> &[LedgerEntryChange] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[LedgerEntryChange] { + self.0 .0 } } -impl Variants for LedgerHeaderExt { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() +// OperationMeta is an XDR Struct defines as: +// +// struct OperationMeta +// { +// LedgerEntryChanges changes; +// }; +// +#[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 OperationMeta { + pub changes: LedgerEntryChanges, +} + +impl ReadXdr for OperationMeta { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + changes: LedgerEntryChanges::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for OperationMeta { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.changes.write_xdr(w)?; + Ok(()) + }) } } -impl Union for LedgerHeaderExt {} - -impl ReadXdr for LedgerHeaderExt { +// TransactionMetaV1 is an XDR Struct defines as: +// +// struct TransactionMetaV1 +// { +// LedgerEntryChanges txChanges; // tx level changes if any +// OperationMeta operations<>; // meta for each operation +// }; +// +#[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 TransactionMetaV1 { + pub tx_changes: LedgerEntryChanges, + pub operations: VecM, +} + +impl ReadXdr for TransactionMetaV1 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - 1 => Self::V1(LedgerHeaderExtensionV1::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + tx_changes: LedgerEntryChanges::read_xdr(r)?, + operations: VecM::::read_xdr(r)?, + }) }) } } -impl WriteXdr for LedgerHeaderExt { +impl WriteXdr for TransactionMetaV1 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, - }; + self.tx_changes.write_xdr(w)?; + self.operations.write_xdr(w)?; Ok(()) }) } } -// LedgerHeader is an XDR Struct defines as: +// TransactionMetaV2 is an XDR Struct defines as: // -// struct LedgerHeader +// struct TransactionMetaV2 // { -// uint32 ledgerVersion; // the protocol version of the ledger -// Hash previousLedgerHash; // hash of the previous ledger header -// StellarValue scpValue; // what consensus agreed to -// Hash txSetResultHash; // the TransactionResultSet that led to this ledger -// Hash bucketListHash; // hash of the ledger state -// -// uint32 ledgerSeq; // sequence number of this ledger -// -// int64 totalCoins; // total number of stroops in existence. -// // 10,000,000 stroops in 1 XLM -// -// int64 feePool; // fees burned since last inflation run -// uint32 inflationSeq; // inflation sequence number -// -// uint64 idPool; // last used global ID, used for generating objects -// -// uint32 baseFee; // base fee per operation in stroops -// uint32 baseReserve; // account base reserve in stroops -// -// uint32 maxTxSetSize; // maximum size a transaction set can be -// -// Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back -// // in time without walking the chain back ledger by ledger -// // each slot contains the oldest ledger that is mod of -// // either 50 5000 50000 or 500000 depending on index -// // skipList[0] mod(50), skipList[1] mod(5000), etc -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// LedgerHeaderExtensionV1 v1; -// } -// ext; +// LedgerEntryChanges txChangesBefore; // tx level changes before operations +// // are applied if any +// OperationMeta operations<>; // meta for each operation +// LedgerEntryChanges txChangesAfter; // tx level changes after operations are +// // applied if any // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -10527,82 +19432,44 @@ impl WriteXdr for LedgerHeaderExt { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerHeader { - pub ledger_version: u32, - pub previous_ledger_hash: Hash, - pub scp_value: StellarValue, - pub tx_set_result_hash: Hash, - pub bucket_list_hash: Hash, - pub ledger_seq: u32, - pub total_coins: i64, - pub fee_pool: i64, - pub inflation_seq: u32, - pub id_pool: u64, - pub base_fee: u32, - pub base_reserve: u32, - pub max_tx_set_size: u32, - pub skip_list: [Hash; 4], - pub ext: LedgerHeaderExt, +pub struct TransactionMetaV2 { + pub tx_changes_before: LedgerEntryChanges, + pub operations: VecM, + pub tx_changes_after: LedgerEntryChanges, } -impl ReadXdr for LedgerHeader { +impl ReadXdr for TransactionMetaV2 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - ledger_version: u32::read_xdr(r)?, - previous_ledger_hash: Hash::read_xdr(r)?, - scp_value: StellarValue::read_xdr(r)?, - tx_set_result_hash: Hash::read_xdr(r)?, - bucket_list_hash: Hash::read_xdr(r)?, - ledger_seq: u32::read_xdr(r)?, - total_coins: i64::read_xdr(r)?, - fee_pool: i64::read_xdr(r)?, - inflation_seq: u32::read_xdr(r)?, - id_pool: u64::read_xdr(r)?, - base_fee: u32::read_xdr(r)?, - base_reserve: u32::read_xdr(r)?, - max_tx_set_size: u32::read_xdr(r)?, - skip_list: <[Hash; 4]>::read_xdr(r)?, - ext: LedgerHeaderExt::read_xdr(r)?, + tx_changes_before: LedgerEntryChanges::read_xdr(r)?, + operations: VecM::::read_xdr(r)?, + tx_changes_after: LedgerEntryChanges::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerHeader { +impl WriteXdr for TransactionMetaV2 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ledger_version.write_xdr(w)?; - self.previous_ledger_hash.write_xdr(w)?; - self.scp_value.write_xdr(w)?; - self.tx_set_result_hash.write_xdr(w)?; - self.bucket_list_hash.write_xdr(w)?; - self.ledger_seq.write_xdr(w)?; - self.total_coins.write_xdr(w)?; - self.fee_pool.write_xdr(w)?; - self.inflation_seq.write_xdr(w)?; - self.id_pool.write_xdr(w)?; - self.base_fee.write_xdr(w)?; - self.base_reserve.write_xdr(w)?; - self.max_tx_set_size.write_xdr(w)?; - self.skip_list.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.tx_changes_before.write_xdr(w)?; + self.operations.write_xdr(w)?; + self.tx_changes_after.write_xdr(w)?; Ok(()) }) } } -// LedgerUpgradeType is an XDR Enum defines as: +// ContractEventType is an XDR Enum defines as: // -// enum LedgerUpgradeType +// enum ContractEventType // { -// LEDGER_UPGRADE_VERSION = 1, -// LEDGER_UPGRADE_BASE_FEE = 2, -// LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3, -// LEDGER_UPGRADE_BASE_RESERVE = 4, -// LEDGER_UPGRADE_FLAGS = 5 +// SYSTEM = 0, +// CONTRACT = 1, +// DIAGNOSTIC = 2 // }; // // enum @@ -10614,73 +19481,64 @@ impl WriteXdr for LedgerHeader { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum LedgerUpgradeType { - Version = 1, - BaseFee = 2, - MaxTxSetSize = 3, - BaseReserve = 4, - Flags = 5, +pub enum ContractEventType { + System = 0, + Contract = 1, + Diagnostic = 2, } -impl LedgerUpgradeType { - pub const VARIANTS: [LedgerUpgradeType; 5] = [ - LedgerUpgradeType::Version, - LedgerUpgradeType::BaseFee, - LedgerUpgradeType::MaxTxSetSize, - LedgerUpgradeType::BaseReserve, - LedgerUpgradeType::Flags, +impl ContractEventType { + pub const VARIANTS: [ContractEventType; 3] = [ + ContractEventType::System, + ContractEventType::Contract, + ContractEventType::Diagnostic, ]; - pub const VARIANTS_STR: [&'static str; 5] = - ["Version", "BaseFee", "MaxTxSetSize", "BaseReserve", "Flags"]; + pub const VARIANTS_STR: [&'static str; 3] = ["System", "Contract", "Diagnostic"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Version => "Version", - Self::BaseFee => "BaseFee", - Self::MaxTxSetSize => "MaxTxSetSize", - Self::BaseReserve => "BaseReserve", - Self::Flags => "Flags", + Self::System => "System", + Self::Contract => "Contract", + Self::Diagnostic => "Diagnostic", } } #[must_use] - pub const fn variants() -> [LedgerUpgradeType; 5] { + pub const fn variants() -> [ContractEventType; 3] { Self::VARIANTS } } -impl Name for LedgerUpgradeType { +impl Name for ContractEventType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for LedgerUpgradeType { - fn variants() -> slice::Iter<'static, LedgerUpgradeType> { +impl Variants for ContractEventType { + fn variants() -> slice::Iter<'static, ContractEventType> { Self::VARIANTS.iter() } } -impl Enum for LedgerUpgradeType {} +impl Enum for ContractEventType {} -impl fmt::Display for LedgerUpgradeType { +impl fmt::Display for ContractEventType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for LedgerUpgradeType { +impl TryFrom for ContractEventType { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 1 => LedgerUpgradeType::Version, - 2 => LedgerUpgradeType::BaseFee, - 3 => LedgerUpgradeType::MaxTxSetSize, - 4 => LedgerUpgradeType::BaseReserve, - 5 => LedgerUpgradeType::Flags, + 0 => ContractEventType::System, + 1 => ContractEventType::Contract, + 2 => ContractEventType::Diagnostic, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -10688,14 +19546,14 @@ impl TryFrom for LedgerUpgradeType { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: LedgerUpgradeType) -> Self { + fn from(e: ContractEventType) -> Self { e as Self } } -impl ReadXdr for LedgerUpgradeType { +impl ReadXdr for ContractEventType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -10706,7 +19564,7 @@ impl ReadXdr for LedgerUpgradeType { } } -impl WriteXdr for LedgerUpgradeType { +impl WriteXdr for ContractEventType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -10716,23 +19574,62 @@ impl WriteXdr for LedgerUpgradeType { } } -// LedgerUpgrade is an XDR Union defines as: +// ContractEventV0 is an XDR NestedStruct defines as: // -// union LedgerUpgrade switch (LedgerUpgradeType type) -// { -// case LEDGER_UPGRADE_VERSION: -// uint32 newLedgerVersion; // update ledgerVersion -// case LEDGER_UPGRADE_BASE_FEE: -// uint32 newBaseFee; // update baseFee -// case LEDGER_UPGRADE_MAX_TX_SET_SIZE: -// uint32 newMaxTxSetSize; // update maxTxSetSize -// case LEDGER_UPGRADE_BASE_RESERVE: -// uint32 newBaseReserve; // update baseReserve -// case LEDGER_UPGRADE_FLAGS: -// uint32 newFlags; // update flags -// }; +// struct +// { +// SCVal topics<>; +// SCVal data; +// } // -// union with discriminant LedgerUpgradeType +#[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 ContractEventV0 { + pub topics: VecM, + pub data: ScVal, +} + +impl ReadXdr for ContractEventV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + topics: VecM::::read_xdr(r)?, + data: ScVal::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for ContractEventV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.topics.write_xdr(w)?; + self.data.write_xdr(w)?; + Ok(()) + }) + } +} + +// ContractEventBody is an XDR NestedUnion defines as: +// +// union switch (int v) +// { +// case 0: +// struct +// { +// SCVal topics<>; +// SCVal data; +// } v0; +// } +// +// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -10741,88 +19638,65 @@ impl WriteXdr for LedgerUpgradeType { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerUpgrade { - Version(u32), - BaseFee(u32), - MaxTxSetSize(u32), - BaseReserve(u32), - Flags(u32), +pub enum ContractEventBody { + V0(ContractEventV0), } -impl LedgerUpgrade { - pub const VARIANTS: [LedgerUpgradeType; 5] = [ - LedgerUpgradeType::Version, - LedgerUpgradeType::BaseFee, - LedgerUpgradeType::MaxTxSetSize, - LedgerUpgradeType::BaseReserve, - LedgerUpgradeType::Flags, - ]; - pub const VARIANTS_STR: [&'static str; 5] = - ["Version", "BaseFee", "MaxTxSetSize", "BaseReserve", "Flags"]; +impl ContractEventBody { + pub const VARIANTS: [i32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Version(_) => "Version", - Self::BaseFee(_) => "BaseFee", - Self::MaxTxSetSize(_) => "MaxTxSetSize", - Self::BaseReserve(_) => "BaseReserve", - Self::Flags(_) => "Flags", + Self::V0(_) => "V0", } } #[must_use] - pub const fn discriminant(&self) -> LedgerUpgradeType { + pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::Version(_) => LedgerUpgradeType::Version, - Self::BaseFee(_) => LedgerUpgradeType::BaseFee, - Self::MaxTxSetSize(_) => LedgerUpgradeType::MaxTxSetSize, - Self::BaseReserve(_) => LedgerUpgradeType::BaseReserve, - Self::Flags(_) => LedgerUpgradeType::Flags, + Self::V0(_) => 0, } } #[must_use] - pub const fn variants() -> [LedgerUpgradeType; 5] { + pub const fn variants() -> [i32; 1] { Self::VARIANTS } } -impl Name for LedgerUpgrade { +impl Name for ContractEventBody { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerUpgrade { +impl Discriminant for ContractEventBody { #[must_use] - fn discriminant(&self) -> LedgerUpgradeType { + fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for LedgerUpgrade { - fn variants() -> slice::Iter<'static, LedgerUpgradeType> { +impl Variants for ContractEventBody { + fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for LedgerUpgrade {} +impl Union for ContractEventBody {} -impl ReadXdr for LedgerUpgrade { +impl ReadXdr for ContractEventBody { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LedgerUpgradeType = ::read_xdr(r)?; + let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - LedgerUpgradeType::Version => Self::Version(u32::read_xdr(r)?), - LedgerUpgradeType::BaseFee => Self::BaseFee(u32::read_xdr(r)?), - LedgerUpgradeType::MaxTxSetSize => Self::MaxTxSetSize(u32::read_xdr(r)?), - LedgerUpgradeType::BaseReserve => Self::BaseReserve(u32::read_xdr(r)?), - LedgerUpgradeType::Flags => Self::Flags(u32::read_xdr(r)?), + 0 => Self::V0(ContractEventV0::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -10831,152 +19705,143 @@ impl ReadXdr for LedgerUpgrade { } } -impl WriteXdr for LedgerUpgrade { +impl WriteXdr for ContractEventBody { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Version(v) => v.write_xdr(w)?, - Self::BaseFee(v) => v.write_xdr(w)?, - Self::MaxTxSetSize(v) => v.write_xdr(w)?, - Self::BaseReserve(v) => v.write_xdr(w)?, - Self::Flags(v) => v.write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// BucketEntryType is an XDR Enum defines as: +// ContractEvent is an XDR Struct defines as: // -// enum BucketEntryType +// struct ContractEvent // { -// METAENTRY = -// -1, // At-and-after protocol 11: bucket metadata, should come first. -// LIVEENTRY = 0, // Before protocol 11: created-or-updated; -// // At-and-after protocol 11: only updated. -// DEADENTRY = 1, -// INITENTRY = 2 // At-and-after protocol 11: only created. +// // We can use this to add more fields, or because it +// // is first, to change ContractEvent into a union. +// ExtensionPoint ext; +// +// Hash* contractID; +// ContractEventType type; +// +// union switch (int v) +// { +// case 0: +// struct +// { +// SCVal topics<>; +// SCVal data; +// } v0; +// } +// body; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[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") )] -#[repr(i32)] -pub enum BucketEntryType { - Metaentry = -1, - Liveentry = 0, - Deadentry = 1, - Initentry = 2, -} - -impl BucketEntryType { - pub const VARIANTS: [BucketEntryType; 4] = [ - BucketEntryType::Metaentry, - BucketEntryType::Liveentry, - BucketEntryType::Deadentry, - BucketEntryType::Initentry, - ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Metaentry", "Liveentry", "Deadentry", "Initentry"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::Metaentry => "Metaentry", - Self::Liveentry => "Liveentry", - Self::Deadentry => "Deadentry", - Self::Initentry => "Initentry", - } - } - - #[must_use] - pub const fn variants() -> [BucketEntryType; 4] { - Self::VARIANTS - } -} - -impl Name for BucketEntryType { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Variants for BucketEntryType { - fn variants() -> slice::Iter<'static, BucketEntryType> { - Self::VARIANTS.iter() - } +pub struct ContractEvent { + pub ext: ExtensionPoint, + pub contract_id: Option, + pub type_: ContractEventType, + pub body: ContractEventBody, } -impl Enum for BucketEntryType {} - -impl fmt::Display for BucketEntryType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl ReadXdr for ContractEvent { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + contract_id: Option::::read_xdr(r)?, + type_: ContractEventType::read_xdr(r)?, + body: ContractEventBody::read_xdr(r)?, + }) + }) } } -impl TryFrom for BucketEntryType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - -1 => BucketEntryType::Metaentry, - 0 => BucketEntryType::Liveentry, - 1 => BucketEntryType::Deadentry, - 2 => BucketEntryType::Initentry, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl WriteXdr for ContractEvent { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.contract_id.write_xdr(w)?; + self.type_.write_xdr(w)?; + self.body.write_xdr(w)?; + Ok(()) + }) } } -impl From for i32 { - #[must_use] - fn from(e: BucketEntryType) -> Self { - e as Self - } +// DiagnosticEvent is an XDR Struct defines as: +// +// struct DiagnosticEvent +// { +// bool inSuccessfulContractCall; +// ContractEvent event; +// }; +// +#[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 DiagnosticEvent { + pub in_successful_contract_call: bool, + pub event: ContractEvent, } -impl ReadXdr for BucketEntryType { +impl ReadXdr for DiagnosticEvent { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) + Ok(Self { + in_successful_contract_call: bool::read_xdr(r)?, + event: ContractEvent::read_xdr(r)?, + }) }) } } -impl WriteXdr for BucketEntryType { +impl WriteXdr for DiagnosticEvent { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.in_successful_contract_call.write_xdr(w)?; + self.event.write_xdr(w)?; + Ok(()) }) } } -// BucketMetadataExt is an XDR NestedUnion defines as: +// SorobanTransactionMeta is an XDR Struct defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// struct SorobanTransactionMeta +// { +// ExtensionPoint ext; +// +// ContractEvent events<>; // custom events populated by the +// // contracts themselves. +// SCVal returnValue; // return value of the host fn invocation +// +// // Diagnostics events that are not hashed. +// // This will contain all contract and diagnostic events. Even ones +// // that were emitted in a failed contract call. +// DiagnosticEvent diagnosticEvents<>; +// }; // -// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -10984,102 +19849,105 @@ impl WriteXdr for BucketEntryType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum BucketMetadataExt { - V0, -} - -impl BucketMetadataExt { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0 => "V0", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, - } - } - - #[must_use] - pub const fn variants() -> [i32; 1] { - Self::VARIANTS - } +pub struct SorobanTransactionMeta { + pub ext: ExtensionPoint, + pub events: VecM, + pub return_value: ScVal, + pub diagnostic_events: VecM, } -impl Name for BucketMetadataExt { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) +impl ReadXdr for SorobanTransactionMeta { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + events: VecM::::read_xdr(r)?, + return_value: ScVal::read_xdr(r)?, + diagnostic_events: VecM::::read_xdr(r)?, + }) + }) } } -impl Discriminant for BucketMetadataExt { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) +impl WriteXdr for SorobanTransactionMeta { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.events.write_xdr(w)?; + self.return_value.write_xdr(w)?; + self.diagnostic_events.write_xdr(w)?; + Ok(()) + }) } } -impl Variants for BucketMetadataExt { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() - } +// TransactionMetaV3 is an XDR Struct defines as: +// +// struct TransactionMetaV3 +// { +// ExtensionPoint ext; +// +// LedgerEntryChanges txChangesBefore; // tx level changes before operations +// // are applied if any +// OperationMeta operations<>; // meta for each operation +// LedgerEntryChanges txChangesAfter; // tx level changes after operations are +// // applied if any +// SorobanTransactionMeta* sorobanMeta; // Soroban-specific meta (only for +// // Soroban transactions). +// }; +// +#[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 TransactionMetaV3 { + pub ext: ExtensionPoint, + pub tx_changes_before: LedgerEntryChanges, + pub operations: VecM, + pub tx_changes_after: LedgerEntryChanges, + pub soroban_meta: Option, } -impl Union for BucketMetadataExt {} - -impl ReadXdr for BucketMetadataExt { +impl ReadXdr for TransactionMetaV3 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + tx_changes_before: LedgerEntryChanges::read_xdr(r)?, + operations: VecM::::read_xdr(r)?, + tx_changes_after: LedgerEntryChanges::read_xdr(r)?, + soroban_meta: Option::::read_xdr(r)?, + }) }) } } -impl WriteXdr for BucketMetadataExt { +impl WriteXdr for TransactionMetaV3 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - }; + self.ext.write_xdr(w)?; + self.tx_changes_before.write_xdr(w)?; + self.operations.write_xdr(w)?; + self.tx_changes_after.write_xdr(w)?; + self.soroban_meta.write_xdr(w)?; Ok(()) }) } } -// BucketMetadata is an XDR Struct defines as: +// InvokeHostFunctionSuccessPreImage is an XDR Struct defines as: // -// struct BucketMetadata +// struct InvokeHostFunctionSuccessPreImage // { -// // Indicates the protocol version used to create / merge this bucket. -// uint32 ledgerVersion; -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// SCVal returnValue; +// ContractEvent events<>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -11089,49 +19957,49 @@ impl WriteXdr for BucketMetadataExt { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct BucketMetadata { - pub ledger_version: u32, - pub ext: BucketMetadataExt, +pub struct InvokeHostFunctionSuccessPreImage { + pub return_value: ScVal, + pub events: VecM, } -impl ReadXdr for BucketMetadata { +impl ReadXdr for InvokeHostFunctionSuccessPreImage { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - ledger_version: u32::read_xdr(r)?, - ext: BucketMetadataExt::read_xdr(r)?, + return_value: ScVal::read_xdr(r)?, + events: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for BucketMetadata { +impl WriteXdr for InvokeHostFunctionSuccessPreImage { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ledger_version.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.return_value.write_xdr(w)?; + self.events.write_xdr(w)?; Ok(()) }) } } -// BucketEntry is an XDR Union defines as: +// TransactionMeta is an XDR Union defines as: // -// union BucketEntry switch (BucketEntryType type) +// union TransactionMeta switch (int v) // { -// case LIVEENTRY: -// case INITENTRY: -// LedgerEntry liveEntry; -// -// case DEADENTRY: -// LedgerKey deadEntry; -// case METAENTRY: -// BucketMetadata metaEntry; +// case 0: +// OperationMeta operations<>; +// case 1: +// TransactionMetaV1 v1; +// case 2: +// TransactionMetaV2 v2; +// case 3: +// TransactionMetaV3 v3; // }; // -// union with discriminant BucketEntryType +// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -11140,83 +20008,77 @@ impl WriteXdr for BucketMetadata { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum BucketEntry { - Liveentry(LedgerEntry), - Initentry(LedgerEntry), - Deadentry(LedgerKey), - Metaentry(BucketMetadata), +pub enum TransactionMeta { + V0(VecM), + V1(TransactionMetaV1), + V2(TransactionMetaV2), + V3(TransactionMetaV3), } -impl BucketEntry { - pub const VARIANTS: [BucketEntryType; 4] = [ - BucketEntryType::Liveentry, - BucketEntryType::Initentry, - BucketEntryType::Deadentry, - BucketEntryType::Metaentry, - ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Liveentry", "Initentry", "Deadentry", "Metaentry"]; +impl TransactionMeta { + pub const VARIANTS: [i32; 4] = [0, 1, 2, 3]; + pub const VARIANTS_STR: [&'static str; 4] = ["V0", "V1", "V2", "V3"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Liveentry(_) => "Liveentry", - Self::Initentry(_) => "Initentry", - Self::Deadentry(_) => "Deadentry", - Self::Metaentry(_) => "Metaentry", + Self::V0(_) => "V0", + Self::V1(_) => "V1", + Self::V2(_) => "V2", + Self::V3(_) => "V3", } } #[must_use] - pub const fn discriminant(&self) -> BucketEntryType { + pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::Liveentry(_) => BucketEntryType::Liveentry, - Self::Initentry(_) => BucketEntryType::Initentry, - Self::Deadentry(_) => BucketEntryType::Deadentry, - Self::Metaentry(_) => BucketEntryType::Metaentry, + Self::V0(_) => 0, + Self::V1(_) => 1, + Self::V2(_) => 2, + Self::V3(_) => 3, } } #[must_use] - pub const fn variants() -> [BucketEntryType; 4] { + pub const fn variants() -> [i32; 4] { Self::VARIANTS } } -impl Name for BucketEntry { +impl Name for TransactionMeta { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for BucketEntry { +impl Discriminant for TransactionMeta { #[must_use] - fn discriminant(&self) -> BucketEntryType { + fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for BucketEntry { - fn variants() -> slice::Iter<'static, BucketEntryType> { +impl Variants for TransactionMeta { + fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for BucketEntry {} +impl Union for TransactionMeta {} -impl ReadXdr for BucketEntry { +impl ReadXdr for TransactionMeta { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: BucketEntryType = ::read_xdr(r)?; + let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - BucketEntryType::Liveentry => Self::Liveentry(LedgerEntry::read_xdr(r)?), - BucketEntryType::Initentry => Self::Initentry(LedgerEntry::read_xdr(r)?), - BucketEntryType::Deadentry => Self::Deadentry(LedgerKey::read_xdr(r)?), - BucketEntryType::Metaentry => Self::Metaentry(BucketMetadata::read_xdr(r)?), + 0 => Self::V0(VecM::::read_xdr(r)?), + 1 => Self::V1(TransactionMetaV1::read_xdr(r)?), + 2 => Self::V2(TransactionMetaV2::read_xdr(r)?), + 3 => Self::V3(TransactionMetaV3::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -11225,132 +20087,275 @@ impl ReadXdr for BucketEntry { } } -impl WriteXdr for BucketEntry { +impl WriteXdr for TransactionMeta { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Liveentry(v) => v.write_xdr(w)?, - Self::Initentry(v) => v.write_xdr(w)?, - Self::Deadentry(v) => v.write_xdr(w)?, - Self::Metaentry(v) => v.write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, + Self::V2(v) => v.write_xdr(w)?, + Self::V3(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// TxSetComponentType is an XDR Enum defines as: +// TransactionResultMeta is an XDR Struct defines as: // -// enum TxSetComponentType +// struct TransactionResultMeta // { -// // txs with effective fee <= bid derived from a base fee (if any). -// // If base fee is not specified, no discount is applied. -// TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE = 0 +// TransactionResultPair result; +// LedgerEntryChanges feeProcessing; +// TransactionMeta txApplyProcessing; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[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") )] -#[repr(i32)] -pub enum TxSetComponentType { - TxsetCompTxsMaybeDiscountedFee = 0, +pub struct TransactionResultMeta { + pub result: TransactionResultPair, + pub fee_processing: LedgerEntryChanges, + pub tx_apply_processing: TransactionMeta, } -impl TxSetComponentType { - pub const VARIANTS: [TxSetComponentType; 1] = - [TxSetComponentType::TxsetCompTxsMaybeDiscountedFee]; - pub const VARIANTS_STR: [&'static str; 1] = ["TxsetCompTxsMaybeDiscountedFee"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::TxsetCompTxsMaybeDiscountedFee => "TxsetCompTxsMaybeDiscountedFee", - } +impl ReadXdr for TransactionResultMeta { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + result: TransactionResultPair::read_xdr(r)?, + fee_processing: LedgerEntryChanges::read_xdr(r)?, + tx_apply_processing: TransactionMeta::read_xdr(r)?, + }) + }) } +} - #[must_use] - pub const fn variants() -> [TxSetComponentType; 1] { - Self::VARIANTS +impl WriteXdr for TransactionResultMeta { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.result.write_xdr(w)?; + self.fee_processing.write_xdr(w)?; + self.tx_apply_processing.write_xdr(w)?; + Ok(()) + }) } } -impl Name for TxSetComponentType { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } +// UpgradeEntryMeta is an XDR Struct defines as: +// +// struct UpgradeEntryMeta +// { +// LedgerUpgrade upgrade; +// LedgerEntryChanges changes; +// }; +// +#[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 UpgradeEntryMeta { + pub upgrade: LedgerUpgrade, + pub changes: LedgerEntryChanges, } -impl Variants for TxSetComponentType { - fn variants() -> slice::Iter<'static, TxSetComponentType> { - Self::VARIANTS.iter() +impl ReadXdr for UpgradeEntryMeta { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + upgrade: LedgerUpgrade::read_xdr(r)?, + changes: LedgerEntryChanges::read_xdr(r)?, + }) + }) } } -impl Enum for TxSetComponentType {} - -impl fmt::Display for TxSetComponentType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl WriteXdr for UpgradeEntryMeta { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.upgrade.write_xdr(w)?; + self.changes.write_xdr(w)?; + Ok(()) + }) } } -impl TryFrom for TxSetComponentType { - type Error = Error; +// LedgerCloseMetaV0 is an XDR Struct defines as: +// +// struct LedgerCloseMetaV0 +// { +// LedgerHeaderHistoryEntry ledgerHeader; +// // NB: txSet is sorted in "Hash order" +// TransactionSet txSet; +// +// // NB: transactions are sorted in apply order here +// // fees for all transactions are processed first +// // followed by applying transactions +// TransactionResultMeta txProcessing<>; +// +// // upgrades are applied last +// UpgradeEntryMeta upgradesProcessing<>; +// +// // other misc information attached to the ledger close +// SCPHistoryEntry scpInfo<>; +// }; +// +#[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 LedgerCloseMetaV0 { + pub ledger_header: LedgerHeaderHistoryEntry, + pub tx_set: TransactionSet, + pub tx_processing: VecM, + pub upgrades_processing: VecM, + pub scp_info: VecM, +} - fn try_from(i: i32) -> Result { - let e = match i { - 0 => TxSetComponentType::TxsetCompTxsMaybeDiscountedFee, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl ReadXdr for LedgerCloseMetaV0 { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ledger_header: LedgerHeaderHistoryEntry::read_xdr(r)?, + tx_set: TransactionSet::read_xdr(r)?, + tx_processing: VecM::::read_xdr(r)?, + upgrades_processing: VecM::::read_xdr(r)?, + scp_info: VecM::::read_xdr(r)?, + }) + }) } } -impl From for i32 { - #[must_use] - fn from(e: TxSetComponentType) -> Self { - e as Self +impl WriteXdr for LedgerCloseMetaV0 { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ledger_header.write_xdr(w)?; + self.tx_set.write_xdr(w)?; + self.tx_processing.write_xdr(w)?; + self.upgrades_processing.write_xdr(w)?; + self.scp_info.write_xdr(w)?; + Ok(()) + }) } } -impl ReadXdr for TxSetComponentType { +// LedgerCloseMetaV1 is an XDR Struct defines as: +// +// struct LedgerCloseMetaV1 +// { +// LedgerHeaderHistoryEntry ledgerHeader; +// +// GeneralizedTransactionSet txSet; +// +// // NB: transactions are sorted in apply order here +// // fees for all transactions are processed first +// // followed by applying transactions +// TransactionResultMeta txProcessing<>; +// +// // upgrades are applied last +// UpgradeEntryMeta upgradesProcessing<>; +// +// // other misc information attached to the ledger close +// SCPHistoryEntry scpInfo<>; +// }; +// +#[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 LedgerCloseMetaV1 { + pub ledger_header: LedgerHeaderHistoryEntry, + pub tx_set: GeneralizedTransactionSet, + pub tx_processing: VecM, + pub upgrades_processing: VecM, + pub scp_info: VecM, +} + +impl ReadXdr for LedgerCloseMetaV1 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) + Ok(Self { + ledger_header: LedgerHeaderHistoryEntry::read_xdr(r)?, + tx_set: GeneralizedTransactionSet::read_xdr(r)?, + tx_processing: VecM::::read_xdr(r)?, + upgrades_processing: VecM::::read_xdr(r)?, + scp_info: VecM::::read_xdr(r)?, + }) }) } } -impl WriteXdr for TxSetComponentType { +impl WriteXdr for LedgerCloseMetaV1 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.ledger_header.write_xdr(w)?; + self.tx_set.write_xdr(w)?; + self.tx_processing.write_xdr(w)?; + self.upgrades_processing.write_xdr(w)?; + self.scp_info.write_xdr(w)?; + Ok(()) }) } } -// TxSetComponentTxsMaybeDiscountedFee is an XDR NestedStruct defines as: +// LedgerCloseMetaV2 is an XDR Struct defines as: // -// struct -// { -// int64* baseFee; -// TransactionEnvelope txs<>; -// } +// struct LedgerCloseMetaV2 +// { +// // We forgot to add an ExtensionPoint in v1 but at least +// // we can add one now in v2. +// ExtensionPoint ext; +// +// LedgerHeaderHistoryEntry ledgerHeader; +// +// GeneralizedTransactionSet txSet; +// +// // NB: transactions are sorted in apply order here +// // fees for all transactions are processed first +// // followed by applying transactions +// TransactionResultMeta txProcessing<>; +// +// // upgrades are applied last +// UpgradeEntryMeta upgradesProcessing<>; +// +// // other misc information attached to the ledger close +// SCPHistoryEntry scpInfo<>; +// +// // Size in bytes of BucketList, to support downstream +// // systems calculating storage fees correctly. +// uint64 totalByteSizeOfBucketList; +// +// // Expired temp keys that are being evicted at this ledger. +// LedgerKey evictedTemporaryLedgerKeys<>; +// +// // Expired restorable ledger entries that are being +// // evicted at this ledger. +// LedgerEntry evictedPersistentLedgerEntries<>; +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -11359,47 +20364,68 @@ impl WriteXdr for TxSetComponentType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TxSetComponentTxsMaybeDiscountedFee { - pub base_fee: Option, - pub txs: VecM, +pub struct LedgerCloseMetaV2 { + pub ext: ExtensionPoint, + pub ledger_header: LedgerHeaderHistoryEntry, + pub tx_set: GeneralizedTransactionSet, + pub tx_processing: VecM, + pub upgrades_processing: VecM, + pub scp_info: VecM, + pub total_byte_size_of_bucket_list: u64, + pub evicted_temporary_ledger_keys: VecM, + pub evicted_persistent_ledger_entries: VecM, } -impl ReadXdr for TxSetComponentTxsMaybeDiscountedFee { +impl ReadXdr for LedgerCloseMetaV2 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - base_fee: Option::::read_xdr(r)?, - txs: VecM::::read_xdr(r)?, + ext: ExtensionPoint::read_xdr(r)?, + ledger_header: LedgerHeaderHistoryEntry::read_xdr(r)?, + tx_set: GeneralizedTransactionSet::read_xdr(r)?, + tx_processing: VecM::::read_xdr(r)?, + upgrades_processing: VecM::::read_xdr(r)?, + scp_info: VecM::::read_xdr(r)?, + total_byte_size_of_bucket_list: u64::read_xdr(r)?, + evicted_temporary_ledger_keys: VecM::::read_xdr(r)?, + evicted_persistent_ledger_entries: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for TxSetComponentTxsMaybeDiscountedFee { +impl WriteXdr for LedgerCloseMetaV2 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.base_fee.write_xdr(w)?; - self.txs.write_xdr(w)?; + self.ext.write_xdr(w)?; + self.ledger_header.write_xdr(w)?; + self.tx_set.write_xdr(w)?; + self.tx_processing.write_xdr(w)?; + self.upgrades_processing.write_xdr(w)?; + self.scp_info.write_xdr(w)?; + self.total_byte_size_of_bucket_list.write_xdr(w)?; + self.evicted_temporary_ledger_keys.write_xdr(w)?; + self.evicted_persistent_ledger_entries.write_xdr(w)?; Ok(()) }) } } -// TxSetComponent is an XDR Union defines as: +// LedgerCloseMeta is an XDR Union defines as: // -// union TxSetComponent switch (TxSetComponentType type) +// union LedgerCloseMeta switch (int v) // { -// case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: -// struct -// { -// int64* baseFee; -// TransactionEnvelope txs<>; -// } txsMaybeDiscountedFee; +// case 0: +// LedgerCloseMetaV0 v0; +// case 1: +// LedgerCloseMetaV1 v1; +// case 2: +// LedgerCloseMetaV2 v2; // }; // -// union with discriminant TxSetComponentType +// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -11408,72 +20434,73 @@ impl WriteXdr for TxSetComponentTxsMaybeDiscountedFee { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum TxSetComponent { - TxsetCompTxsMaybeDiscountedFee(TxSetComponentTxsMaybeDiscountedFee), +pub enum LedgerCloseMeta { + V0(LedgerCloseMetaV0), + V1(LedgerCloseMetaV1), + V2(LedgerCloseMetaV2), } -impl TxSetComponent { - pub const VARIANTS: [TxSetComponentType; 1] = - [TxSetComponentType::TxsetCompTxsMaybeDiscountedFee]; - pub const VARIANTS_STR: [&'static str; 1] = ["TxsetCompTxsMaybeDiscountedFee"]; +impl LedgerCloseMeta { + pub const VARIANTS: [i32; 3] = [0, 1, 2]; + pub const VARIANTS_STR: [&'static str; 3] = ["V0", "V1", "V2"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::TxsetCompTxsMaybeDiscountedFee(_) => "TxsetCompTxsMaybeDiscountedFee", + Self::V0(_) => "V0", + Self::V1(_) => "V1", + Self::V2(_) => "V2", } } #[must_use] - pub const fn discriminant(&self) -> TxSetComponentType { + pub const fn discriminant(&self) -> i32 { #[allow(clippy::match_same_arms)] match self { - Self::TxsetCompTxsMaybeDiscountedFee(_) => { - TxSetComponentType::TxsetCompTxsMaybeDiscountedFee - } + Self::V0(_) => 0, + Self::V1(_) => 1, + Self::V2(_) => 2, } } #[must_use] - pub const fn variants() -> [TxSetComponentType; 1] { + pub const fn variants() -> [i32; 3] { Self::VARIANTS } } -impl Name for TxSetComponent { +impl Name for LedgerCloseMeta { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for TxSetComponent { +impl Discriminant for LedgerCloseMeta { #[must_use] - fn discriminant(&self) -> TxSetComponentType { + fn discriminant(&self) -> i32 { Self::discriminant(self) } } -impl Variants for TxSetComponent { - fn variants() -> slice::Iter<'static, TxSetComponentType> { +impl Variants for LedgerCloseMeta { + fn variants() -> slice::Iter<'static, i32> { Self::VARIANTS.iter() } } -impl Union for TxSetComponent {} +impl Union for LedgerCloseMeta {} -impl ReadXdr for TxSetComponent { +impl ReadXdr for LedgerCloseMeta { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: TxSetComponentType = ::read_xdr(r)?; + let dv: i32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - TxSetComponentType::TxsetCompTxsMaybeDiscountedFee => { - Self::TxsetCompTxsMaybeDiscountedFee( - TxSetComponentTxsMaybeDiscountedFee::read_xdr(r)?, - ) - } + 0 => Self::V0(LedgerCloseMetaV0::read_xdr(r)?), + 1 => Self::V1(LedgerCloseMetaV1::read_xdr(r)?), + 2 => Self::V2(LedgerCloseMetaV2::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -11482,124 +20509,149 @@ impl ReadXdr for TxSetComponent { } } -impl WriteXdr for TxSetComponent { +impl WriteXdr for LedgerCloseMeta { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::TxsetCompTxsMaybeDiscountedFee(v) => v.write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, + Self::V2(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// TransactionPhase is an XDR Union defines as: +// ErrorCode is an XDR Enum defines as: // -// union TransactionPhase switch (int v) +// enum ErrorCode // { -// case 0: -// TxSetComponent v0Components<>; +// ERR_MISC = 0, // Unspecific error +// ERR_DATA = 1, // Malformed data +// ERR_CONF = 2, // Misconfiguration error +// ERR_AUTH = 3, // Authentication failure +// ERR_LOAD = 4 // System overloaded // }; // -// union with discriminant i32 -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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") )] -#[allow(clippy::large_enum_variant)] -pub enum TransactionPhase { - V0(VecM), +#[repr(i32)] +pub enum ErrorCode { + Misc = 0, + Data = 1, + Conf = 2, + Auth = 3, + Load = 4, } -impl TransactionPhase { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl ErrorCode { + pub const VARIANTS: [ErrorCode; 5] = [ + ErrorCode::Misc, + ErrorCode::Data, + ErrorCode::Conf, + ErrorCode::Auth, + ErrorCode::Load, + ]; + pub const VARIANTS_STR: [&'static str; 5] = ["Misc", "Data", "Conf", "Auth", "Load"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0(_) => "V0", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0(_) => 0, + Self::Misc => "Misc", + Self::Data => "Data", + Self::Conf => "Conf", + Self::Auth => "Auth", + Self::Load => "Load", } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [ErrorCode; 5] { Self::VARIANTS } } -impl Name for TransactionPhase { +impl Name for ErrorCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for TransactionPhase { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) +impl Variants for ErrorCode { + fn variants() -> slice::Iter<'static, ErrorCode> { + Self::VARIANTS.iter() } } -impl Variants for TransactionPhase { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() +impl Enum for ErrorCode {} + +impl fmt::Display for ErrorCode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl Union for TransactionPhase {} +impl TryFrom for ErrorCode { + type Error = Error; -impl ReadXdr for TransactionPhase { + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ErrorCode::Misc, + 1 => ErrorCode::Data, + 2 => ErrorCode::Conf, + 3 => ErrorCode::Auth, + 4 => ErrorCode::Load, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ErrorCode) -> Self { + e as Self + } +} + +impl ReadXdr for ErrorCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0(VecM::::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; Ok(v) }) } } -impl WriteXdr for TransactionPhase { +impl WriteXdr for ErrorCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0(v) => v.write_xdr(w)?, - }; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// TransactionSet is an XDR Struct defines as: +// SError is an XDR Struct defines as: // -// struct TransactionSet +// struct Error // { -// Hash previousLedgerHash; -// TransactionEnvelope txs<>; +// ErrorCode code; +// string msg<100>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -11609,40 +20661,39 @@ impl WriteXdr for TransactionPhase { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TransactionSet { - pub previous_ledger_hash: Hash, - pub txs: VecM, +pub struct SError { + pub code: ErrorCode, + pub msg: StringM<100>, } -impl ReadXdr for TransactionSet { +impl ReadXdr for SError { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - previous_ledger_hash: Hash::read_xdr(r)?, - txs: VecM::::read_xdr(r)?, + code: ErrorCode::read_xdr(r)?, + msg: StringM::<100>::read_xdr(r)?, }) }) } } -impl WriteXdr for TransactionSet { +impl WriteXdr for SError { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.previous_ledger_hash.write_xdr(w)?; - self.txs.write_xdr(w)?; + self.code.write_xdr(w)?; + self.msg.write_xdr(w)?; Ok(()) }) } } -// TransactionSetV1 is an XDR Struct defines as: +// SendMore is an XDR Struct defines as: // -// struct TransactionSetV1 +// struct SendMore // { -// Hash previousLedgerHash; -// TransactionPhase phases<>; +// uint32 numMessages; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -11652,44 +20703,39 @@ impl WriteXdr for TransactionSet { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TransactionSetV1 { - pub previous_ledger_hash: Hash, - pub phases: VecM, +pub struct SendMore { + pub num_messages: u32, } -impl ReadXdr for TransactionSetV1 { +impl ReadXdr for SendMore { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - previous_ledger_hash: Hash::read_xdr(r)?, - phases: VecM::::read_xdr(r)?, + num_messages: u32::read_xdr(r)?, }) }) } } -impl WriteXdr for TransactionSetV1 { +impl WriteXdr for SendMore { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.previous_ledger_hash.write_xdr(w)?; - self.phases.write_xdr(w)?; + self.num_messages.write_xdr(w)?; Ok(()) }) } } -// GeneralizedTransactionSet is an XDR Union defines as: +// SendMoreExtended is an XDR Struct defines as: // -// union GeneralizedTransactionSet switch (int v) +// struct SendMoreExtended // { -// // We consider the legacy TransactionSet to be v0. -// case 1: -// TransactionSetV1 v1TxSet; +// uint32 numMessages; +// uint32 numBytes; // }; // -// union with discriminant i32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -11697,94 +20743,41 @@ impl WriteXdr for TransactionSetV1 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum GeneralizedTransactionSet { - V1(TransactionSetV1), -} - -impl GeneralizedTransactionSet { - pub const VARIANTS: [i32; 1] = [1]; - pub const VARIANTS_STR: [&'static str; 1] = ["V1"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V1(_) => "V1", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V1(_) => 1, - } - } - - #[must_use] - pub const fn variants() -> [i32; 1] { - Self::VARIANTS - } -} - -impl Name for GeneralizedTransactionSet { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Discriminant for GeneralizedTransactionSet { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) - } -} - -impl Variants for GeneralizedTransactionSet { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() - } +pub struct SendMoreExtended { + pub num_messages: u32, + pub num_bytes: u32, } -impl Union for GeneralizedTransactionSet {} - -impl ReadXdr for GeneralizedTransactionSet { +impl ReadXdr for SendMoreExtended { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 1 => Self::V1(TransactionSetV1::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + num_messages: u32::read_xdr(r)?, + num_bytes: u32::read_xdr(r)?, + }) }) } } -impl WriteXdr for GeneralizedTransactionSet { +impl WriteXdr for SendMoreExtended { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V1(v) => v.write_xdr(w)?, - }; + self.num_messages.write_xdr(w)?; + self.num_bytes.write_xdr(w)?; Ok(()) }) } } -// TransactionResultPair is an XDR Struct defines as: +// AuthCert is an XDR Struct defines as: // -// struct TransactionResultPair +// struct AuthCert // { -// Hash transactionHash; -// TransactionResult result; // result for the transaction +// Curve25519Public pubkey; +// uint64 expiration; +// Signature sig; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -11794,39 +20787,50 @@ impl WriteXdr for GeneralizedTransactionSet { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TransactionResultPair { - pub transaction_hash: Hash, - pub result: TransactionResult, +pub struct AuthCert { + pub pubkey: Curve25519Public, + pub expiration: u64, + pub sig: Signature, } -impl ReadXdr for TransactionResultPair { +impl ReadXdr for AuthCert { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - transaction_hash: Hash::read_xdr(r)?, - result: TransactionResult::read_xdr(r)?, + pubkey: Curve25519Public::read_xdr(r)?, + expiration: u64::read_xdr(r)?, + sig: Signature::read_xdr(r)?, }) }) } } -impl WriteXdr for TransactionResultPair { +impl WriteXdr for AuthCert { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.transaction_hash.write_xdr(w)?; - self.result.write_xdr(w)?; + self.pubkey.write_xdr(w)?; + self.expiration.write_xdr(w)?; + self.sig.write_xdr(w)?; Ok(()) }) } } -// TransactionResultSet is an XDR Struct defines as: +// Hello is an XDR Struct defines as: // -// struct TransactionResultSet +// struct Hello // { -// TransactionResultPair results<>; +// uint32 ledgerVersion; +// uint32 overlayVersion; +// uint32 overlayMinVersion; +// Hash networkID; +// string versionStr<100>; +// int listeningPort; +// NodeID peerID; +// AuthCert cert; +// uint256 nonce; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -11836,152 +20840,66 @@ impl WriteXdr for TransactionResultPair { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TransactionResultSet { - pub results: VecM, +pub struct Hello { + pub ledger_version: u32, + pub overlay_version: u32, + pub overlay_min_version: u32, + pub network_id: Hash, + pub version_str: StringM<100>, + pub listening_port: i32, + pub peer_id: NodeId, + pub cert: AuthCert, + pub nonce: Uint256, } -impl ReadXdr for TransactionResultSet { +impl ReadXdr for Hello { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - results: VecM::::read_xdr(r)?, + ledger_version: u32::read_xdr(r)?, + overlay_version: u32::read_xdr(r)?, + overlay_min_version: u32::read_xdr(r)?, + network_id: Hash::read_xdr(r)?, + version_str: StringM::<100>::read_xdr(r)?, + listening_port: i32::read_xdr(r)?, + peer_id: NodeId::read_xdr(r)?, + cert: AuthCert::read_xdr(r)?, + nonce: Uint256::read_xdr(r)?, }) }) } } -impl WriteXdr for TransactionResultSet { +impl WriteXdr for Hello { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.results.write_xdr(w)?; + self.ledger_version.write_xdr(w)?; + self.overlay_version.write_xdr(w)?; + self.overlay_min_version.write_xdr(w)?; + self.network_id.write_xdr(w)?; + self.version_str.write_xdr(w)?; + self.listening_port.write_xdr(w)?; + self.peer_id.write_xdr(w)?; + self.cert.write_xdr(w)?; + self.nonce.write_xdr(w)?; Ok(()) }) } } -// TransactionHistoryEntryExt is an XDR NestedUnion defines as: +// AuthMsgFlagFlowControlBytesRequested is an XDR Const defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// GeneralizedTransactionSet generalizedTxSet; -// } +// const AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED = 200; // -// union with discriminant i32 -#[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") -)] -#[allow(clippy::large_enum_variant)] -pub enum TransactionHistoryEntryExt { - V0, - V1(GeneralizedTransactionSet), -} - -impl TransactionHistoryEntryExt { - pub const VARIANTS: [i32; 2] = [0, 1]; - pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0 => "V0", - Self::V1(_) => "V1", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, - Self::V1(_) => 1, - } - } - - #[must_use] - pub const fn variants() -> [i32; 2] { - Self::VARIANTS - } -} - -impl Name for TransactionHistoryEntryExt { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Discriminant for TransactionHistoryEntryExt { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) - } -} - -impl Variants for TransactionHistoryEntryExt { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() - } -} - -impl Union for TransactionHistoryEntryExt {} - -impl ReadXdr for TransactionHistoryEntryExt { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - 1 => Self::V1(GeneralizedTransactionSet::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) - }) - } -} - -impl WriteXdr for TransactionHistoryEntryExt { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, - }; - Ok(()) - }) - } -} +pub const AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED: u64 = 200; -// TransactionHistoryEntry is an XDR Struct defines as: +// Auth is an XDR Struct defines as: // -// struct TransactionHistoryEntry +// struct Auth // { -// uint32 ledgerSeq; -// TransactionSet txSet; -// -// // when v != 0, txSet must be empty -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// GeneralizedTransactionSet generalizedTxSet; -// } -// ext; +// int flags; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -11991,198 +20909,145 @@ impl WriteXdr for TransactionHistoryEntryExt { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TransactionHistoryEntry { - pub ledger_seq: u32, - pub tx_set: TransactionSet, - pub ext: TransactionHistoryEntryExt, +pub struct Auth { + pub flags: i32, } -impl ReadXdr for TransactionHistoryEntry { +impl ReadXdr for Auth { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - ledger_seq: u32::read_xdr(r)?, - tx_set: TransactionSet::read_xdr(r)?, - ext: TransactionHistoryEntryExt::read_xdr(r)?, + flags: i32::read_xdr(r)?, }) }) } } -impl WriteXdr for TransactionHistoryEntry { +impl WriteXdr for Auth { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ledger_seq.write_xdr(w)?; - self.tx_set.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.flags.write_xdr(w)?; Ok(()) }) } } -// TransactionHistoryResultEntryExt is an XDR NestedUnion defines as: +// IpAddrType is an XDR Enum defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } +// enum IPAddrType +// { +// IPv4 = 0, +// IPv6 = 1 +// }; // -// union with discriminant i32 -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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") )] -#[allow(clippy::large_enum_variant)] -pub enum TransactionHistoryResultEntryExt { - V0, +#[repr(i32)] +pub enum IpAddrType { + IPv4 = 0, + IPv6 = 1, } -impl TransactionHistoryResultEntryExt { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl IpAddrType { + pub const VARIANTS: [IpAddrType; 2] = [IpAddrType::IPv4, IpAddrType::IPv6]; + pub const VARIANTS_STR: [&'static str; 2] = ["IPv4", "IPv6"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => 0, + Self::IPv4 => "IPv4", + Self::IPv6 => "IPv6", } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [IpAddrType; 2] { Self::VARIANTS } } -impl Name for TransactionHistoryResultEntryExt { +impl Name for IpAddrType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for TransactionHistoryResultEntryExt { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) - } -} - -impl Variants for TransactionHistoryResultEntryExt { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for IpAddrType { + fn variants() -> slice::Iter<'static, IpAddrType> { Self::VARIANTS.iter() } } -impl Union for TransactionHistoryResultEntryExt {} +impl Enum for IpAddrType {} -impl ReadXdr for TransactionHistoryResultEntryExt { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) - }) +impl fmt::Display for IpAddrType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl WriteXdr for TransactionHistoryResultEntryExt { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0 => ().write_xdr(w)?, - }; - Ok(()) - }) +impl TryFrom for IpAddrType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => IpAddrType::IPv4, + 1 => IpAddrType::IPv6, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -// TransactionHistoryResultEntry is an XDR Struct defines as: -// -// struct TransactionHistoryResultEntry -// { -// uint32 ledgerSeq; -// TransactionResultSet txResultSet; -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; -// }; -// -#[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 TransactionHistoryResultEntry { - pub ledger_seq: u32, - pub tx_result_set: TransactionResultSet, - pub ext: TransactionHistoryResultEntryExt, +impl From for i32 { + #[must_use] + fn from(e: IpAddrType) -> Self { + e as Self + } } -impl ReadXdr for TransactionHistoryResultEntry { +impl ReadXdr for IpAddrType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - ledger_seq: u32::read_xdr(r)?, - tx_result_set: TransactionResultSet::read_xdr(r)?, - ext: TransactionHistoryResultEntryExt::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for TransactionHistoryResultEntry { +impl WriteXdr for IpAddrType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ledger_seq.write_xdr(w)?; - self.tx_result_set.write_xdr(w)?; - self.ext.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// LedgerHeaderHistoryEntryExt is an XDR NestedUnion defines as: +// PeerAddressIp is an XDR NestedUnion defines as: // -// union switch (int v) +// union switch (IPAddrType type) // { -// case 0: -// void; +// case IPv4: +// opaque ipv4[4]; +// case IPv6: +// opaque ipv6[16]; // } // -// union with discriminant i32 +// union with discriminant IpAddrType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -12191,65 +21056,69 @@ impl WriteXdr for TransactionHistoryResultEntry { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerHeaderHistoryEntryExt { - V0, +pub enum PeerAddressIp { + IPv4([u8; 4]), + IPv6([u8; 16]), } -impl LedgerHeaderHistoryEntryExt { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl PeerAddressIp { + pub const VARIANTS: [IpAddrType; 2] = [IpAddrType::IPv4, IpAddrType::IPv6]; + pub const VARIANTS_STR: [&'static str; 2] = ["IPv4", "IPv6"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0 => "V0", + Self::IPv4(_) => "IPv4", + Self::IPv6(_) => "IPv6", } } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> IpAddrType { #[allow(clippy::match_same_arms)] match self { - Self::V0 => 0, + Self::IPv4(_) => IpAddrType::IPv4, + Self::IPv6(_) => IpAddrType::IPv6, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [IpAddrType; 2] { Self::VARIANTS } } -impl Name for LedgerHeaderHistoryEntryExt { +impl Name for PeerAddressIp { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerHeaderHistoryEntryExt { +impl Discriminant for PeerAddressIp { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> IpAddrType { Self::discriminant(self) } } -impl Variants for LedgerHeaderHistoryEntryExt { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for PeerAddressIp { + fn variants() -> slice::Iter<'static, IpAddrType> { Self::VARIANTS.iter() } } -impl Union for LedgerHeaderHistoryEntryExt {} +impl Union for PeerAddressIp {} -impl ReadXdr for LedgerHeaderHistoryEntryExt { +impl ReadXdr for PeerAddressIp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: IpAddrType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0, + IpAddrType::IPv4 => Self::IPv4(<[u8; 4]>::read_xdr(r)?), + IpAddrType::IPv6 => Self::IPv6(<[u8; 16]>::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -12258,34 +21127,35 @@ impl ReadXdr for LedgerHeaderHistoryEntryExt { } } -impl WriteXdr for LedgerHeaderHistoryEntryExt { +impl WriteXdr for PeerAddressIp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::V0 => ().write_xdr(w)?, + Self::IPv4(v) => v.write_xdr(w)?, + Self::IPv6(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// LedgerHeaderHistoryEntry is an XDR Struct defines as: +// PeerAddress is an XDR Struct defines as: // -// struct LedgerHeaderHistoryEntry +// struct PeerAddress // { -// Hash hash; -// LedgerHeader header; -// -// // reserved for future use -// union switch (int v) +// union switch (IPAddrType type) // { -// case 0: -// void; +// case IPv4: +// opaque ipv4[4]; +// case IPv6: +// opaque ipv6[16]; // } -// ext; +// ip; +// uint32 port; +// uint32 numFailures; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -12295,86 +21165,270 @@ impl WriteXdr for LedgerHeaderHistoryEntryExt { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerHeaderHistoryEntry { - pub hash: Hash, - pub header: LedgerHeader, - pub ext: LedgerHeaderHistoryEntryExt, +pub struct PeerAddress { + pub ip: PeerAddressIp, + pub port: u32, + pub num_failures: u32, } -impl ReadXdr for LedgerHeaderHistoryEntry { +impl ReadXdr for PeerAddress { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - hash: Hash::read_xdr(r)?, - header: LedgerHeader::read_xdr(r)?, - ext: LedgerHeaderHistoryEntryExt::read_xdr(r)?, + ip: PeerAddressIp::read_xdr(r)?, + port: u32::read_xdr(r)?, + num_failures: u32::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerHeaderHistoryEntry { +impl WriteXdr for PeerAddress { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.hash.write_xdr(w)?; - self.header.write_xdr(w)?; - self.ext.write_xdr(w)?; + self.ip.write_xdr(w)?; + self.port.write_xdr(w)?; + self.num_failures.write_xdr(w)?; Ok(()) }) } } -// LedgerScpMessages is an XDR Struct defines as: +// MessageType is an XDR Enum defines as: // -// struct LedgerSCPMessages +// enum MessageType // { -// uint32 ledgerSeq; -// SCPEnvelope messages<>; +// ERROR_MSG = 0, +// AUTH = 2, +// DONT_HAVE = 3, +// +// GET_PEERS = 4, // gets a list of peers this guy knows about +// PEERS = 5, +// +// GET_TX_SET = 6, // gets a particular txset by hash +// TX_SET = 7, +// GENERALIZED_TX_SET = 17, +// +// TRANSACTION = 8, // pass on a tx you have heard about +// +// // SCP +// GET_SCP_QUORUMSET = 9, +// SCP_QUORUMSET = 10, +// SCP_MESSAGE = 11, +// GET_SCP_STATE = 12, +// +// // new messages +// HELLO = 13, +// +// SURVEY_REQUEST = 14, +// SURVEY_RESPONSE = 15, +// +// SEND_MORE = 16, +// SEND_MORE_EXTENDED = 20, +// +// FLOOD_ADVERT = 18, +// FLOOD_DEMAND = 19 // }; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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 LedgerScpMessages { - pub ledger_seq: u32, - pub messages: VecM, +#[repr(i32)] +pub enum MessageType { + ErrorMsg = 0, + Auth = 2, + DontHave = 3, + GetPeers = 4, + Peers = 5, + GetTxSet = 6, + TxSet = 7, + GeneralizedTxSet = 17, + Transaction = 8, + GetScpQuorumset = 9, + ScpQuorumset = 10, + ScpMessage = 11, + GetScpState = 12, + Hello = 13, + SurveyRequest = 14, + SurveyResponse = 15, + SendMore = 16, + SendMoreExtended = 20, + FloodAdvert = 18, + FloodDemand = 19, } -impl ReadXdr for LedgerScpMessages { +impl MessageType { + pub const VARIANTS: [MessageType; 20] = [ + MessageType::ErrorMsg, + MessageType::Auth, + MessageType::DontHave, + MessageType::GetPeers, + MessageType::Peers, + MessageType::GetTxSet, + MessageType::TxSet, + MessageType::GeneralizedTxSet, + MessageType::Transaction, + MessageType::GetScpQuorumset, + MessageType::ScpQuorumset, + MessageType::ScpMessage, + MessageType::GetScpState, + MessageType::Hello, + MessageType::SurveyRequest, + MessageType::SurveyResponse, + MessageType::SendMore, + MessageType::SendMoreExtended, + MessageType::FloodAdvert, + MessageType::FloodDemand, + ]; + pub const VARIANTS_STR: [&'static str; 20] = [ + "ErrorMsg", + "Auth", + "DontHave", + "GetPeers", + "Peers", + "GetTxSet", + "TxSet", + "GeneralizedTxSet", + "Transaction", + "GetScpQuorumset", + "ScpQuorumset", + "ScpMessage", + "GetScpState", + "Hello", + "SurveyRequest", + "SurveyResponse", + "SendMore", + "SendMoreExtended", + "FloodAdvert", + "FloodDemand", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ErrorMsg => "ErrorMsg", + Self::Auth => "Auth", + Self::DontHave => "DontHave", + Self::GetPeers => "GetPeers", + Self::Peers => "Peers", + Self::GetTxSet => "GetTxSet", + Self::TxSet => "TxSet", + Self::GeneralizedTxSet => "GeneralizedTxSet", + Self::Transaction => "Transaction", + Self::GetScpQuorumset => "GetScpQuorumset", + Self::ScpQuorumset => "ScpQuorumset", + Self::ScpMessage => "ScpMessage", + Self::GetScpState => "GetScpState", + Self::Hello => "Hello", + Self::SurveyRequest => "SurveyRequest", + Self::SurveyResponse => "SurveyResponse", + Self::SendMore => "SendMore", + Self::SendMoreExtended => "SendMoreExtended", + Self::FloodAdvert => "FloodAdvert", + Self::FloodDemand => "FloodDemand", + } + } + + #[must_use] + pub const fn variants() -> [MessageType; 20] { + Self::VARIANTS + } +} + +impl Name for MessageType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for MessageType { + fn variants() -> slice::Iter<'static, MessageType> { + Self::VARIANTS.iter() + } +} + +impl Enum for MessageType {} + +impl fmt::Display for MessageType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for MessageType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => MessageType::ErrorMsg, + 2 => MessageType::Auth, + 3 => MessageType::DontHave, + 4 => MessageType::GetPeers, + 5 => MessageType::Peers, + 6 => MessageType::GetTxSet, + 7 => MessageType::TxSet, + 17 => MessageType::GeneralizedTxSet, + 8 => MessageType::Transaction, + 9 => MessageType::GetScpQuorumset, + 10 => MessageType::ScpQuorumset, + 11 => MessageType::ScpMessage, + 12 => MessageType::GetScpState, + 13 => MessageType::Hello, + 14 => MessageType::SurveyRequest, + 15 => MessageType::SurveyResponse, + 16 => MessageType::SendMore, + 20 => MessageType::SendMoreExtended, + 18 => MessageType::FloodAdvert, + 19 => MessageType::FloodDemand, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: MessageType) -> Self { + e as Self + } +} + +impl ReadXdr for MessageType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - ledger_seq: u32::read_xdr(r)?, - messages: VecM::::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for LedgerScpMessages { +impl WriteXdr for MessageType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ledger_seq.write_xdr(w)?; - self.messages.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// ScpHistoryEntryV0 is an XDR Struct defines as: +// DontHave is an XDR Struct defines as: // -// struct SCPHistoryEntryV0 +// struct DontHave // { -// SCPQuorumSet quorumSets<>; // additional quorum sets used by ledgerMessages -// LedgerSCPMessages ledgerMessages; +// MessageType type; +// uint256 reqHash; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -12384,140 +21438,139 @@ impl WriteXdr for LedgerScpMessages { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ScpHistoryEntryV0 { - pub quorum_sets: VecM, - pub ledger_messages: LedgerScpMessages, +pub struct DontHave { + pub type_: MessageType, + pub req_hash: Uint256, } -impl ReadXdr for ScpHistoryEntryV0 { +impl ReadXdr for DontHave { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - quorum_sets: VecM::::read_xdr(r)?, - ledger_messages: LedgerScpMessages::read_xdr(r)?, + type_: MessageType::read_xdr(r)?, + req_hash: Uint256::read_xdr(r)?, }) }) } } -impl WriteXdr for ScpHistoryEntryV0 { +impl WriteXdr for DontHave { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.quorum_sets.write_xdr(w)?; - self.ledger_messages.write_xdr(w)?; + self.type_.write_xdr(w)?; + self.req_hash.write_xdr(w)?; Ok(()) }) } } -// ScpHistoryEntry is an XDR Union defines as: +// SurveyMessageCommandType is an XDR Enum defines as: // -// union SCPHistoryEntry switch (int v) +// enum SurveyMessageCommandType // { -// case 0: -// SCPHistoryEntryV0 v0; +// SURVEY_TOPOLOGY = 0 // }; // -// union with discriminant i32 -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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") )] -#[allow(clippy::large_enum_variant)] -pub enum ScpHistoryEntry { - V0(ScpHistoryEntryV0), +#[repr(i32)] +pub enum SurveyMessageCommandType { + SurveyTopology = 0, } -impl ScpHistoryEntry { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; +impl SurveyMessageCommandType { + pub const VARIANTS: [SurveyMessageCommandType; 1] = [SurveyMessageCommandType::SurveyTopology]; + pub const VARIANTS_STR: [&'static str; 1] = ["SurveyTopology"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::V0(_) => "V0", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0(_) => 0, + Self::SurveyTopology => "SurveyTopology", } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [SurveyMessageCommandType; 1] { Self::VARIANTS } } -impl Name for ScpHistoryEntry { +impl Name for SurveyMessageCommandType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ScpHistoryEntry { - #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) +impl Variants for SurveyMessageCommandType { + fn variants() -> slice::Iter<'static, SurveyMessageCommandType> { + Self::VARIANTS.iter() } } -impl Variants for ScpHistoryEntry { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() +impl Enum for SurveyMessageCommandType {} + +impl fmt::Display for SurveyMessageCommandType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl Union for ScpHistoryEntry {} +impl TryFrom for SurveyMessageCommandType { + type Error = Error; -impl ReadXdr for ScpHistoryEntry { + fn try_from(i: i32) -> Result { + let e = match i { + 0 => SurveyMessageCommandType::SurveyTopology, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: SurveyMessageCommandType) -> Self { + e as Self + } +} + +impl ReadXdr for SurveyMessageCommandType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0(ScpHistoryEntryV0::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; Ok(v) }) } } -impl WriteXdr for ScpHistoryEntry { +impl WriteXdr for SurveyMessageCommandType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0(v) => v.write_xdr(w)?, - }; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// LedgerEntryChangeType is an XDR Enum defines as: +// SurveyMessageResponseType is an XDR Enum defines as: // -// enum LedgerEntryChangeType +// enum SurveyMessageResponseType // { -// LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger -// LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger -// LEDGER_ENTRY_REMOVED = 2, // entry was removed from the ledger -// LEDGER_ENTRY_STATE = 3 // value of the entry +// SURVEY_TOPOLOGY_RESPONSE_V0 = 0, +// SURVEY_TOPOLOGY_RESPONSE_V1 = 1 // }; // // enum @@ -12529,68 +21582,58 @@ impl WriteXdr for ScpHistoryEntry { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum LedgerEntryChangeType { - Created = 0, - Updated = 1, - Removed = 2, - State = 3, +pub enum SurveyMessageResponseType { + V0 = 0, + V1 = 1, } -impl LedgerEntryChangeType { - pub const VARIANTS: [LedgerEntryChangeType; 4] = [ - LedgerEntryChangeType::Created, - LedgerEntryChangeType::Updated, - LedgerEntryChangeType::Removed, - LedgerEntryChangeType::State, - ]; - pub const VARIANTS_STR: [&'static str; 4] = ["Created", "Updated", "Removed", "State"]; +impl SurveyMessageResponseType { + pub const VARIANTS: [SurveyMessageResponseType; 2] = + [SurveyMessageResponseType::V0, SurveyMessageResponseType::V1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Created => "Created", - Self::Updated => "Updated", - Self::Removed => "Removed", - Self::State => "State", + Self::V0 => "V0", + Self::V1 => "V1", } } #[must_use] - pub const fn variants() -> [LedgerEntryChangeType; 4] { + pub const fn variants() -> [SurveyMessageResponseType; 2] { Self::VARIANTS } } -impl Name for LedgerEntryChangeType { +impl Name for SurveyMessageResponseType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for LedgerEntryChangeType { - fn variants() -> slice::Iter<'static, LedgerEntryChangeType> { +impl Variants for SurveyMessageResponseType { + fn variants() -> slice::Iter<'static, SurveyMessageResponseType> { Self::VARIANTS.iter() } } -impl Enum for LedgerEntryChangeType {} +impl Enum for SurveyMessageResponseType {} -impl fmt::Display for LedgerEntryChangeType { +impl fmt::Display for SurveyMessageResponseType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for LedgerEntryChangeType { +impl TryFrom for SurveyMessageResponseType { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => LedgerEntryChangeType::Created, - 1 => LedgerEntryChangeType::Updated, - 2 => LedgerEntryChangeType::Removed, - 3 => LedgerEntryChangeType::State, + 0 => SurveyMessageResponseType::V0, + 1 => SurveyMessageResponseType::V1, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -12598,14 +21641,14 @@ impl TryFrom for LedgerEntryChangeType { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: LedgerEntryChangeType) -> Self { + fn from(e: SurveyMessageResponseType) -> Self { e as Self } } -impl ReadXdr for LedgerEntryChangeType { +impl ReadXdr for SurveyMessageResponseType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -12616,7 +21659,7 @@ impl ReadXdr for LedgerEntryChangeType { } } -impl WriteXdr for LedgerEntryChangeType { +impl WriteXdr for SurveyMessageResponseType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -12626,21 +21669,17 @@ impl WriteXdr for LedgerEntryChangeType { } } -// LedgerEntryChange is an XDR Union defines as: +// SurveyRequestMessage is an XDR Struct defines as: // -// union LedgerEntryChange switch (LedgerEntryChangeType type) +// struct SurveyRequestMessage // { -// case LEDGER_ENTRY_CREATED: -// LedgerEntry created; -// case LEDGER_ENTRY_UPDATED: -// LedgerEntry updated; -// case LEDGER_ENTRY_REMOVED: -// LedgerKey removed; -// case LEDGER_ENTRY_STATE: -// LedgerEntry state; +// NodeID surveyorPeerID; +// NodeID surveyedPeerID; +// uint32 ledgerNum; +// Curve25519Public encryptionKey; +// SurveyMessageCommandType commandType; // }; // -// union with discriminant LedgerEntryChangeType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -12648,111 +21687,89 @@ impl WriteXdr for LedgerEntryChangeType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum LedgerEntryChange { - Created(LedgerEntry), - Updated(LedgerEntry), - Removed(LedgerKey), - State(LedgerEntry), -} - -impl LedgerEntryChange { - pub const VARIANTS: [LedgerEntryChangeType; 4] = [ - LedgerEntryChangeType::Created, - LedgerEntryChangeType::Updated, - LedgerEntryChangeType::Removed, - LedgerEntryChangeType::State, - ]; - pub const VARIANTS_STR: [&'static str; 4] = ["Created", "Updated", "Removed", "State"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::Created(_) => "Created", - Self::Updated(_) => "Updated", - Self::Removed(_) => "Removed", - Self::State(_) => "State", - } - } - - #[must_use] - pub const fn discriminant(&self) -> LedgerEntryChangeType { - #[allow(clippy::match_same_arms)] - match self { - Self::Created(_) => LedgerEntryChangeType::Created, - Self::Updated(_) => LedgerEntryChangeType::Updated, - Self::Removed(_) => LedgerEntryChangeType::Removed, - Self::State(_) => LedgerEntryChangeType::State, - } - } - - #[must_use] - pub const fn variants() -> [LedgerEntryChangeType; 4] { - Self::VARIANTS - } +pub struct SurveyRequestMessage { + pub surveyor_peer_id: NodeId, + pub surveyed_peer_id: NodeId, + pub ledger_num: u32, + pub encryption_key: Curve25519Public, + pub command_type: SurveyMessageCommandType, } -impl Name for LedgerEntryChange { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) +impl ReadXdr for SurveyRequestMessage { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + surveyor_peer_id: NodeId::read_xdr(r)?, + surveyed_peer_id: NodeId::read_xdr(r)?, + ledger_num: u32::read_xdr(r)?, + encryption_key: Curve25519Public::read_xdr(r)?, + command_type: SurveyMessageCommandType::read_xdr(r)?, + }) + }) } } -impl Discriminant for LedgerEntryChange { - #[must_use] - fn discriminant(&self) -> LedgerEntryChangeType { - Self::discriminant(self) +impl WriteXdr for SurveyRequestMessage { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.surveyor_peer_id.write_xdr(w)?; + self.surveyed_peer_id.write_xdr(w)?; + self.ledger_num.write_xdr(w)?; + self.encryption_key.write_xdr(w)?; + self.command_type.write_xdr(w)?; + Ok(()) + }) } } -impl Variants for LedgerEntryChange { - fn variants() -> slice::Iter<'static, LedgerEntryChangeType> { - Self::VARIANTS.iter() - } +// SignedSurveyRequestMessage is an XDR Struct defines as: +// +// struct SignedSurveyRequestMessage +// { +// Signature requestSignature; +// SurveyRequestMessage request; +// }; +// +#[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 SignedSurveyRequestMessage { + pub request_signature: Signature, + pub request: SurveyRequestMessage, } -impl Union for LedgerEntryChange {} - -impl ReadXdr for LedgerEntryChange { +impl ReadXdr for SignedSurveyRequestMessage { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LedgerEntryChangeType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - LedgerEntryChangeType::Created => Self::Created(LedgerEntry::read_xdr(r)?), - LedgerEntryChangeType::Updated => Self::Updated(LedgerEntry::read_xdr(r)?), - LedgerEntryChangeType::Removed => Self::Removed(LedgerKey::read_xdr(r)?), - LedgerEntryChangeType::State => Self::State(LedgerEntry::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + request_signature: Signature::read_xdr(r)?, + request: SurveyRequestMessage::read_xdr(r)?, + }) }) } } -impl WriteXdr for LedgerEntryChange { +impl WriteXdr for SignedSurveyRequestMessage { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::Created(v) => v.write_xdr(w)?, - Self::Updated(v) => v.write_xdr(w)?, - Self::Removed(v) => v.write_xdr(w)?, - Self::State(v) => v.write_xdr(w)?, - }; + self.request_signature.write_xdr(w)?; + self.request.write_xdr(w)?; Ok(()) }) } } -// LedgerEntryChanges is an XDR Typedef defines as: +// EncryptedBody is an XDR Typedef defines as: // -// typedef LedgerEntryChange LedgerEntryChanges<>; +// typedef opaque EncryptedBody<64000>; // #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -12762,101 +21779,105 @@ impl WriteXdr for LedgerEntryChange { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerEntryChanges(pub VecM); +pub struct EncryptedBody(pub BytesM<64000>); -impl From for VecM { +impl From for BytesM<64000> { #[must_use] - fn from(x: LedgerEntryChanges) -> Self { + fn from(x: EncryptedBody) -> Self { x.0 } } -impl From> for LedgerEntryChanges { +impl From> for EncryptedBody { #[must_use] - fn from(x: VecM) -> Self { - LedgerEntryChanges(x) + fn from(x: BytesM<64000>) -> Self { + EncryptedBody(x) } } -impl AsRef> for LedgerEntryChanges { +impl AsRef> for EncryptedBody { #[must_use] - fn as_ref(&self) -> &VecM { + fn as_ref(&self) -> &BytesM<64000> { &self.0 } } -impl ReadXdr for LedgerEntryChanges { +impl ReadXdr for EncryptedBody { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = VecM::::read_xdr(r)?; - let v = LedgerEntryChanges(i); + let i = BytesM::<64000>::read_xdr(r)?; + let v = EncryptedBody(i); Ok(v) }) } } -impl WriteXdr for LedgerEntryChanges { +impl WriteXdr for EncryptedBody { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| self.0.write_xdr(w)) } } -impl Deref for LedgerEntryChanges { - type Target = VecM; +impl Deref for EncryptedBody { + type Target = BytesM<64000>; fn deref(&self) -> &Self::Target { &self.0 } } -impl From for Vec { +impl From for Vec { #[must_use] - fn from(x: LedgerEntryChanges) -> Self { + fn from(x: EncryptedBody) -> Self { x.0 .0 } } -impl TryFrom> for LedgerEntryChanges { +impl TryFrom> for EncryptedBody { type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(LedgerEntryChanges(x.try_into()?)) + fn try_from(x: Vec) -> Result { + Ok(EncryptedBody(x.try_into()?)) } } #[cfg(feature = "alloc")] -impl TryFrom<&Vec> for LedgerEntryChanges { +impl TryFrom<&Vec> for EncryptedBody { type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(LedgerEntryChanges(x.try_into()?)) + fn try_from(x: &Vec) -> Result { + Ok(EncryptedBody(x.try_into()?)) } } -impl AsRef> for LedgerEntryChanges { +impl AsRef> for EncryptedBody { #[must_use] - fn as_ref(&self) -> &Vec { + fn as_ref(&self) -> &Vec { &self.0 .0 } } -impl AsRef<[LedgerEntryChange]> for LedgerEntryChanges { +impl AsRef<[u8]> for EncryptedBody { #[cfg(feature = "alloc")] #[must_use] - fn as_ref(&self) -> &[LedgerEntryChange] { + fn as_ref(&self) -> &[u8] { &self.0 .0 } #[cfg(not(feature = "alloc"))] #[must_use] - fn as_ref(&self) -> &[LedgerEntryChange] { + fn as_ref(&self) -> &[u8] { self.0 .0 } } -// OperationMeta is an XDR Struct defines as: +// SurveyResponseMessage is an XDR Struct defines as: // -// struct OperationMeta +// struct SurveyResponseMessage // { -// LedgerEntryChanges changes; +// NodeID surveyorPeerID; +// NodeID surveyedPeerID; +// uint32 ledgerNum; +// SurveyMessageCommandType commandType; +// EncryptedBody encryptedBody; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -12866,37 +21887,49 @@ impl AsRef<[LedgerEntryChange]> for LedgerEntryChanges { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct OperationMeta { - pub changes: LedgerEntryChanges, +pub struct SurveyResponseMessage { + pub surveyor_peer_id: NodeId, + pub surveyed_peer_id: NodeId, + pub ledger_num: u32, + pub command_type: SurveyMessageCommandType, + pub encrypted_body: EncryptedBody, } -impl ReadXdr for OperationMeta { +impl ReadXdr for SurveyResponseMessage { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - changes: LedgerEntryChanges::read_xdr(r)?, + surveyor_peer_id: NodeId::read_xdr(r)?, + surveyed_peer_id: NodeId::read_xdr(r)?, + ledger_num: u32::read_xdr(r)?, + command_type: SurveyMessageCommandType::read_xdr(r)?, + encrypted_body: EncryptedBody::read_xdr(r)?, }) }) } } -impl WriteXdr for OperationMeta { +impl WriteXdr for SurveyResponseMessage { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.changes.write_xdr(w)?; + self.surveyor_peer_id.write_xdr(w)?; + self.surveyed_peer_id.write_xdr(w)?; + self.ledger_num.write_xdr(w)?; + self.command_type.write_xdr(w)?; + self.encrypted_body.write_xdr(w)?; Ok(()) }) } } -// TransactionMetaV1 is an XDR Struct defines as: +// SignedSurveyResponseMessage is an XDR Struct defines as: // -// struct TransactionMetaV1 +// struct SignedSurveyResponseMessage // { -// LedgerEntryChanges txChanges; // tx level changes if any -// OperationMeta operations<>; // meta for each operation +// Signature responseSignature; +// SurveyResponseMessage response; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -12906,43 +21939,55 @@ impl WriteXdr for OperationMeta { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TransactionMetaV1 { - pub tx_changes: LedgerEntryChanges, - pub operations: VecM, +pub struct SignedSurveyResponseMessage { + pub response_signature: Signature, + pub response: SurveyResponseMessage, } -impl ReadXdr for TransactionMetaV1 { +impl ReadXdr for SignedSurveyResponseMessage { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - tx_changes: LedgerEntryChanges::read_xdr(r)?, - operations: VecM::::read_xdr(r)?, + response_signature: Signature::read_xdr(r)?, + response: SurveyResponseMessage::read_xdr(r)?, }) }) } } -impl WriteXdr for TransactionMetaV1 { +impl WriteXdr for SignedSurveyResponseMessage { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.tx_changes.write_xdr(w)?; - self.operations.write_xdr(w)?; + self.response_signature.write_xdr(w)?; + self.response.write_xdr(w)?; Ok(()) }) } } -// TransactionMetaV2 is an XDR Struct defines as: +// PeerStats is an XDR Struct defines as: // -// struct TransactionMetaV2 +// struct PeerStats // { -// LedgerEntryChanges txChangesBefore; // tx level changes before operations -// // are applied if any -// OperationMeta operations<>; // meta for each operation -// LedgerEntryChanges txChangesAfter; // tx level changes after operations are -// // applied if any +// NodeID id; +// string versionStr<100>; +// uint64 messagesRead; +// uint64 messagesWritten; +// uint64 bytesRead; +// uint64 bytesWritten; +// uint64 secondsConnected; +// +// uint64 uniqueFloodBytesRecv; +// uint64 duplicateFloodBytesRecv; +// uint64 uniqueFetchBytesRecv; +// uint64 duplicateFetchBytesRecv; +// +// uint64 uniqueFloodMessageRecv; +// uint64 duplicateFloodMessageRecv; +// uint64 uniqueFetchMessageRecv; +// uint64 duplicateFetchMessageRecv; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -12952,257 +21997,184 @@ impl WriteXdr for TransactionMetaV1 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TransactionMetaV2 { - pub tx_changes_before: LedgerEntryChanges, - pub operations: VecM, - pub tx_changes_after: LedgerEntryChanges, +pub struct PeerStats { + pub id: NodeId, + pub version_str: StringM<100>, + pub messages_read: u64, + pub messages_written: u64, + pub bytes_read: u64, + pub bytes_written: u64, + pub seconds_connected: u64, + pub unique_flood_bytes_recv: u64, + pub duplicate_flood_bytes_recv: u64, + pub unique_fetch_bytes_recv: u64, + pub duplicate_fetch_bytes_recv: u64, + pub unique_flood_message_recv: u64, + pub duplicate_flood_message_recv: u64, + pub unique_fetch_message_recv: u64, + pub duplicate_fetch_message_recv: u64, } -impl ReadXdr for TransactionMetaV2 { +impl ReadXdr for PeerStats { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - tx_changes_before: LedgerEntryChanges::read_xdr(r)?, - operations: VecM::::read_xdr(r)?, - tx_changes_after: LedgerEntryChanges::read_xdr(r)?, + id: NodeId::read_xdr(r)?, + version_str: StringM::<100>::read_xdr(r)?, + messages_read: u64::read_xdr(r)?, + messages_written: u64::read_xdr(r)?, + bytes_read: u64::read_xdr(r)?, + bytes_written: u64::read_xdr(r)?, + seconds_connected: u64::read_xdr(r)?, + unique_flood_bytes_recv: u64::read_xdr(r)?, + duplicate_flood_bytes_recv: u64::read_xdr(r)?, + unique_fetch_bytes_recv: u64::read_xdr(r)?, + duplicate_fetch_bytes_recv: u64::read_xdr(r)?, + unique_flood_message_recv: u64::read_xdr(r)?, + duplicate_flood_message_recv: u64::read_xdr(r)?, + unique_fetch_message_recv: u64::read_xdr(r)?, + duplicate_fetch_message_recv: u64::read_xdr(r)?, }) }) } } -impl WriteXdr for TransactionMetaV2 { +impl WriteXdr for PeerStats { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.tx_changes_before.write_xdr(w)?; - self.operations.write_xdr(w)?; - self.tx_changes_after.write_xdr(w)?; + self.id.write_xdr(w)?; + self.version_str.write_xdr(w)?; + self.messages_read.write_xdr(w)?; + self.messages_written.write_xdr(w)?; + self.bytes_read.write_xdr(w)?; + self.bytes_written.write_xdr(w)?; + self.seconds_connected.write_xdr(w)?; + self.unique_flood_bytes_recv.write_xdr(w)?; + self.duplicate_flood_bytes_recv.write_xdr(w)?; + self.unique_fetch_bytes_recv.write_xdr(w)?; + self.duplicate_fetch_bytes_recv.write_xdr(w)?; + self.unique_flood_message_recv.write_xdr(w)?; + self.duplicate_flood_message_recv.write_xdr(w)?; + self.unique_fetch_message_recv.write_xdr(w)?; + self.duplicate_fetch_message_recv.write_xdr(w)?; Ok(()) }) } } -// TransactionMeta is an XDR Union defines as: +// PeerStatList is an XDR Typedef defines as: // -// union TransactionMeta switch (int v) -// { -// case 0: -// OperationMeta operations<>; -// case 1: -// TransactionMetaV1 v1; -// case 2: -// TransactionMetaV2 v2; -// }; +// typedef PeerStats PeerStatList<25>; // -// union with discriminant i32 -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum TransactionMeta { - V0(VecM), - V1(TransactionMetaV1), - V2(TransactionMetaV2), -} - -impl TransactionMeta { - pub const VARIANTS: [i32; 3] = [0, 1, 2]; - pub const VARIANTS_STR: [&'static str; 3] = ["V0", "V1", "V2"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0(_) => "V0", - Self::V1(_) => "V1", - Self::V2(_) => "V2", - } - } - - #[must_use] - pub const fn discriminant(&self) -> i32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0(_) => 0, - Self::V1(_) => 1, - Self::V2(_) => 2, - } - } +pub struct PeerStatList(pub VecM); +impl From for VecM { #[must_use] - pub const fn variants() -> [i32; 3] { - Self::VARIANTS + fn from(x: PeerStatList) -> Self { + x.0 } } -impl Name for TransactionMeta { +impl From> for PeerStatList { #[must_use] - fn name(&self) -> &'static str { - Self::name(self) + fn from(x: VecM) -> Self { + PeerStatList(x) } } -impl Discriminant for TransactionMeta { +impl AsRef> for PeerStatList { #[must_use] - fn discriminant(&self) -> i32 { - Self::discriminant(self) - } -} - -impl Variants for TransactionMeta { - fn variants() -> slice::Iter<'static, i32> { - Self::VARIANTS.iter() + fn as_ref(&self) -> &VecM { + &self.0 } } -impl Union for TransactionMeta {} - -impl ReadXdr for TransactionMeta { +impl ReadXdr for PeerStatList { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0(VecM::::read_xdr(r)?), - 1 => Self::V1(TransactionMetaV1::read_xdr(r)?), - 2 => Self::V2(TransactionMetaV2::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; + let i = VecM::::read_xdr(r)?; + let v = PeerStatList(i); Ok(v) }) } } -impl WriteXdr for TransactionMeta { +impl WriteXdr for PeerStatList { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0(v) => v.write_xdr(w)?, - Self::V1(v) => v.write_xdr(w)?, - Self::V2(v) => v.write_xdr(w)?, - }; - Ok(()) - }) + w.with_limited_depth(|w| self.0.write_xdr(w)) } } -// TransactionResultMeta is an XDR Struct defines as: -// -// struct TransactionResultMeta -// { -// TransactionResultPair result; -// LedgerEntryChanges feeProcessing; -// TransactionMeta txApplyProcessing; -// }; -// -#[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 TransactionResultMeta { - pub result: TransactionResultPair, - pub fee_processing: LedgerEntryChanges, - pub tx_apply_processing: TransactionMeta, +impl Deref for PeerStatList { + type Target = VecM; + fn deref(&self) -> &Self::Target { + &self.0 + } } -impl ReadXdr for TransactionResultMeta { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - result: TransactionResultPair::read_xdr(r)?, - fee_processing: LedgerEntryChanges::read_xdr(r)?, - tx_apply_processing: TransactionMeta::read_xdr(r)?, - }) - }) +impl From for Vec { + #[must_use] + fn from(x: PeerStatList) -> Self { + x.0 .0 } } -impl WriteXdr for TransactionResultMeta { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.result.write_xdr(w)?; - self.fee_processing.write_xdr(w)?; - self.tx_apply_processing.write_xdr(w)?; - Ok(()) - }) +impl TryFrom> for PeerStatList { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(PeerStatList(x.try_into()?)) } } -// UpgradeEntryMeta is an XDR Struct defines as: -// -// struct UpgradeEntryMeta -// { -// LedgerUpgrade upgrade; -// LedgerEntryChanges changes; -// }; -// -#[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 UpgradeEntryMeta { - pub upgrade: LedgerUpgrade, - pub changes: LedgerEntryChanges, +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for PeerStatList { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(PeerStatList(x.try_into()?)) + } } -impl ReadXdr for UpgradeEntryMeta { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - upgrade: LedgerUpgrade::read_xdr(r)?, - changes: LedgerEntryChanges::read_xdr(r)?, - }) - }) +impl AsRef> for PeerStatList { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 } } -impl WriteXdr for UpgradeEntryMeta { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.upgrade.write_xdr(w)?; - self.changes.write_xdr(w)?; - Ok(()) - }) +impl AsRef<[PeerStats]> for PeerStatList { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[PeerStats] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[PeerStats] { + self.0 .0 } } -// LedgerCloseMetaV0 is an XDR Struct defines as: +// TopologyResponseBodyV0 is an XDR Struct defines as: // -// struct LedgerCloseMetaV0 +// struct TopologyResponseBodyV0 // { -// LedgerHeaderHistoryEntry ledgerHeader; -// // NB: txSet is sorted in "Hash order" -// TransactionSet txSet; -// -// // NB: transactions are sorted in apply order here -// // fees for all transactions are processed first -// // followed by applying transactions -// TransactionResultMeta txProcessing<>; -// -// // upgrades are applied last -// UpgradeEntryMeta upgradesProcessing<>; +// PeerStatList inboundPeers; +// PeerStatList outboundPeers; // -// // other misc information attached to the ledger close -// SCPHistoryEntry scpInfo<>; +// uint32 totalInboundPeerCount; +// uint32 totalOutboundPeerCount; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -13212,61 +22184,52 @@ impl WriteXdr for UpgradeEntryMeta { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerCloseMetaV0 { - pub ledger_header: LedgerHeaderHistoryEntry, - pub tx_set: TransactionSet, - pub tx_processing: VecM, - pub upgrades_processing: VecM, - pub scp_info: VecM, +pub struct TopologyResponseBodyV0 { + pub inbound_peers: PeerStatList, + pub outbound_peers: PeerStatList, + pub total_inbound_peer_count: u32, + pub total_outbound_peer_count: u32, } -impl ReadXdr for LedgerCloseMetaV0 { +impl ReadXdr for TopologyResponseBodyV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - ledger_header: LedgerHeaderHistoryEntry::read_xdr(r)?, - tx_set: TransactionSet::read_xdr(r)?, - tx_processing: VecM::::read_xdr(r)?, - upgrades_processing: VecM::::read_xdr(r)?, - scp_info: VecM::::read_xdr(r)?, + inbound_peers: PeerStatList::read_xdr(r)?, + outbound_peers: PeerStatList::read_xdr(r)?, + total_inbound_peer_count: u32::read_xdr(r)?, + total_outbound_peer_count: u32::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerCloseMetaV0 { +impl WriteXdr for TopologyResponseBodyV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ledger_header.write_xdr(w)?; - self.tx_set.write_xdr(w)?; - self.tx_processing.write_xdr(w)?; - self.upgrades_processing.write_xdr(w)?; - self.scp_info.write_xdr(w)?; + self.inbound_peers.write_xdr(w)?; + self.outbound_peers.write_xdr(w)?; + self.total_inbound_peer_count.write_xdr(w)?; + self.total_outbound_peer_count.write_xdr(w)?; Ok(()) }) } } -// LedgerCloseMetaV1 is an XDR Struct defines as: +// TopologyResponseBodyV1 is an XDR Struct defines as: // -// struct LedgerCloseMetaV1 +// struct TopologyResponseBodyV1 // { -// LedgerHeaderHistoryEntry ledgerHeader; -// -// GeneralizedTransactionSet txSet; -// -// // NB: transactions are sorted in apply order here -// // fees for all transactions are processed first -// // followed by applying transactions -// TransactionResultMeta txProcessing<>; +// PeerStatList inboundPeers; +// PeerStatList outboundPeers; // -// // upgrades are applied last -// UpgradeEntryMeta upgradesProcessing<>; +// uint32 totalInboundPeerCount; +// uint32 totalOutboundPeerCount; // -// // other misc information attached to the ledger close -// SCPHistoryEntry scpInfo<>; +// uint32 maxInboundPeerCount; +// uint32 maxOutboundPeerCount; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -13276,54 +22239,57 @@ impl WriteXdr for LedgerCloseMetaV0 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LedgerCloseMetaV1 { - pub ledger_header: LedgerHeaderHistoryEntry, - pub tx_set: GeneralizedTransactionSet, - pub tx_processing: VecM, - pub upgrades_processing: VecM, - pub scp_info: VecM, +pub struct TopologyResponseBodyV1 { + pub inbound_peers: PeerStatList, + pub outbound_peers: PeerStatList, + pub total_inbound_peer_count: u32, + pub total_outbound_peer_count: u32, + pub max_inbound_peer_count: u32, + pub max_outbound_peer_count: u32, } -impl ReadXdr for LedgerCloseMetaV1 { +impl ReadXdr for TopologyResponseBodyV1 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - ledger_header: LedgerHeaderHistoryEntry::read_xdr(r)?, - tx_set: GeneralizedTransactionSet::read_xdr(r)?, - tx_processing: VecM::::read_xdr(r)?, - upgrades_processing: VecM::::read_xdr(r)?, - scp_info: VecM::::read_xdr(r)?, + inbound_peers: PeerStatList::read_xdr(r)?, + outbound_peers: PeerStatList::read_xdr(r)?, + total_inbound_peer_count: u32::read_xdr(r)?, + total_outbound_peer_count: u32::read_xdr(r)?, + max_inbound_peer_count: u32::read_xdr(r)?, + max_outbound_peer_count: u32::read_xdr(r)?, }) }) } } -impl WriteXdr for LedgerCloseMetaV1 { +impl WriteXdr for TopologyResponseBodyV1 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.ledger_header.write_xdr(w)?; - self.tx_set.write_xdr(w)?; - self.tx_processing.write_xdr(w)?; - self.upgrades_processing.write_xdr(w)?; - self.scp_info.write_xdr(w)?; + self.inbound_peers.write_xdr(w)?; + self.outbound_peers.write_xdr(w)?; + self.total_inbound_peer_count.write_xdr(w)?; + self.total_outbound_peer_count.write_xdr(w)?; + self.max_inbound_peer_count.write_xdr(w)?; + self.max_outbound_peer_count.write_xdr(w)?; Ok(()) }) } } -// LedgerCloseMeta is an XDR Union defines as: +// SurveyResponseBody is an XDR Union defines as: // -// union LedgerCloseMeta switch (int v) +// union SurveyResponseBody switch (SurveyMessageResponseType type) // { -// case 0: -// LedgerCloseMetaV0 v0; -// case 1: -// LedgerCloseMetaV1 v1; +// case SURVEY_TOPOLOGY_RESPONSE_V0: +// TopologyResponseBodyV0 topologyResponseBodyV0; +// case SURVEY_TOPOLOGY_RESPONSE_V1: +// TopologyResponseBodyV1 topologyResponseBodyV1; // }; // -// union with discriminant i32 +// union with discriminant SurveyMessageResponseType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -13332,13 +22298,14 @@ impl WriteXdr for LedgerCloseMetaV1 { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LedgerCloseMeta { - V0(LedgerCloseMetaV0), - V1(LedgerCloseMetaV1), +pub enum SurveyResponseBody { + V0(TopologyResponseBodyV0), + V1(TopologyResponseBodyV1), } -impl LedgerCloseMeta { - pub const VARIANTS: [i32; 2] = [0, 1]; +impl SurveyResponseBody { + pub const VARIANTS: [SurveyMessageResponseType; 2] = + [SurveyMessageResponseType::V0, SurveyMessageResponseType::V1]; pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; #[must_use] @@ -13350,51 +22317,52 @@ impl LedgerCloseMeta { } #[must_use] - pub const fn discriminant(&self) -> i32 { + pub const fn discriminant(&self) -> SurveyMessageResponseType { #[allow(clippy::match_same_arms)] match self { - Self::V0(_) => 0, - Self::V1(_) => 1, + Self::V0(_) => SurveyMessageResponseType::V0, + Self::V1(_) => SurveyMessageResponseType::V1, } } #[must_use] - pub const fn variants() -> [i32; 2] { + pub const fn variants() -> [SurveyMessageResponseType; 2] { Self::VARIANTS } } -impl Name for LedgerCloseMeta { +impl Name for SurveyResponseBody { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LedgerCloseMeta { +impl Discriminant for SurveyResponseBody { #[must_use] - fn discriminant(&self) -> i32 { + fn discriminant(&self) -> SurveyMessageResponseType { Self::discriminant(self) } } -impl Variants for LedgerCloseMeta { - fn variants() -> slice::Iter<'static, i32> { +impl Variants for SurveyResponseBody { + fn variants() -> slice::Iter<'static, SurveyMessageResponseType> { Self::VARIANTS.iter() } } -impl Union for LedgerCloseMeta {} +impl Union for SurveyResponseBody {} -impl ReadXdr for LedgerCloseMeta { +impl ReadXdr for SurveyResponseBody { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: i32 = ::read_xdr(r)?; + let dv: SurveyMessageResponseType = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - 0 => Self::V0(LedgerCloseMetaV0::read_xdr(r)?), - 1 => Self::V1(LedgerCloseMetaV1::read_xdr(r)?), + SurveyMessageResponseType::V0 => Self::V0(TopologyResponseBodyV0::read_xdr(r)?), + SurveyMessageResponseType::V1 => Self::V1(TopologyResponseBodyV1::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -13403,7 +22371,7 @@ impl ReadXdr for LedgerCloseMeta { } } -impl WriteXdr for LedgerCloseMeta { +impl WriteXdr for SurveyResponseBody { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -13418,133 +22386,119 @@ impl WriteXdr for LedgerCloseMeta { } } -// ErrorCode is an XDR Enum defines as: +// TxAdvertVectorMaxSize is an XDR Const defines as: // -// enum ErrorCode -// { -// ERR_MISC = 0, // Unspecific error -// ERR_DATA = 1, // Malformed data -// ERR_CONF = 2, // Misconfiguration error -// ERR_AUTH = 3, // Authentication failure -// ERR_LOAD = 4 // System overloaded -// }; +// const TX_ADVERT_VECTOR_MAX_SIZE = 1000; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub const TX_ADVERT_VECTOR_MAX_SIZE: u64 = 1000; + +// TxAdvertVector is an XDR Typedef defines as: +// +// typedef Hash TxAdvertVector; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[repr(i32)] -pub enum ErrorCode { - Misc = 0, - Data = 1, - Conf = 2, - Auth = 3, - Load = 4, -} - -impl ErrorCode { - pub const VARIANTS: [ErrorCode; 5] = [ - ErrorCode::Misc, - ErrorCode::Data, - ErrorCode::Conf, - ErrorCode::Auth, - ErrorCode::Load, - ]; - pub const VARIANTS_STR: [&'static str; 5] = ["Misc", "Data", "Conf", "Auth", "Load"]; +pub struct TxAdvertVector(pub VecM); +impl From for VecM { #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::Misc => "Misc", - Self::Data => "Data", - Self::Conf => "Conf", - Self::Auth => "Auth", - Self::Load => "Load", - } + fn from(x: TxAdvertVector) -> Self { + x.0 } +} +impl From> for TxAdvertVector { #[must_use] - pub const fn variants() -> [ErrorCode; 5] { - Self::VARIANTS + fn from(x: VecM) -> Self { + TxAdvertVector(x) } } -impl Name for ErrorCode { +impl AsRef> for TxAdvertVector { #[must_use] - fn name(&self) -> &'static str { - Self::name(self) + fn as_ref(&self) -> &VecM { + &self.0 } } -impl Variants for ErrorCode { - fn variants() -> slice::Iter<'static, ErrorCode> { - Self::VARIANTS.iter() +impl ReadXdr for TxAdvertVector { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = VecM::::read_xdr(r)?; + let v = TxAdvertVector(i); + Ok(v) + }) } } -impl Enum for ErrorCode {} +impl WriteXdr for TxAdvertVector { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} -impl fmt::Display for ErrorCode { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Deref for TxAdvertVector { + type Target = VecM; + fn deref(&self) -> &Self::Target { + &self.0 } } -impl TryFrom for ErrorCode { - type Error = Error; +impl From for Vec { + #[must_use] + fn from(x: TxAdvertVector) -> Self { + x.0 .0 + } +} - fn try_from(i: i32) -> Result { - let e = match i { - 0 => ErrorCode::Misc, - 1 => ErrorCode::Data, - 2 => ErrorCode::Conf, - 3 => ErrorCode::Auth, - 4 => ErrorCode::Load, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl TryFrom> for TxAdvertVector { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(TxAdvertVector(x.try_into()?)) } } -impl From for i32 { - #[must_use] - fn from(e: ErrorCode) -> Self { - e as Self +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for TxAdvertVector { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(TxAdvertVector(x.try_into()?)) } } -impl ReadXdr for ErrorCode { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) - }) +impl AsRef> for TxAdvertVector { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 } } -impl WriteXdr for ErrorCode { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) - }) +impl AsRef<[Hash]> for TxAdvertVector { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[Hash] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[Hash] { + self.0 .0 } } -// SError is an XDR Struct defines as: +// FloodAdvert is an XDR Struct defines as: // -// struct Error +// struct FloodAdvert // { -// ErrorCode code; -// string msg<100>; +// TxAdvertVector txHashes; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -13554,202 +22508,144 @@ impl WriteXdr for ErrorCode { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SError { - pub code: ErrorCode, - pub msg: StringM<100>, +pub struct FloodAdvert { + pub tx_hashes: TxAdvertVector, } -impl ReadXdr for SError { +impl ReadXdr for FloodAdvert { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - code: ErrorCode::read_xdr(r)?, - msg: StringM::<100>::read_xdr(r)?, + tx_hashes: TxAdvertVector::read_xdr(r)?, }) }) } } -impl WriteXdr for SError { +impl WriteXdr for FloodAdvert { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.code.write_xdr(w)?; - self.msg.write_xdr(w)?; + self.tx_hashes.write_xdr(w)?; Ok(()) }) } } -// SendMore is an XDR Struct defines as: +// TxDemandVectorMaxSize is an XDR Const defines as: // -// struct SendMore -// { -// uint32 numMessages; -// }; +// const TX_DEMAND_VECTOR_MAX_SIZE = 1000; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub const TX_DEMAND_VECTOR_MAX_SIZE: u64 = 1000; + +// TxDemandVector is an XDR Typedef defines as: +// +// typedef Hash TxDemandVector; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SendMore { - pub num_messages: u32, -} +pub struct TxDemandVector(pub VecM); -impl ReadXdr for SendMore { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - num_messages: u32::read_xdr(r)?, - }) - }) +impl From for VecM { + #[must_use] + fn from(x: TxDemandVector) -> Self { + x.0 } } -impl WriteXdr for SendMore { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.num_messages.write_xdr(w)?; - Ok(()) - }) +impl From> for TxDemandVector { + #[must_use] + fn from(x: VecM) -> Self { + TxDemandVector(x) } } -// AuthCert is an XDR Struct defines as: -// -// struct AuthCert -// { -// Curve25519Public pubkey; -// uint64 expiration; -// Signature sig; -// }; -// -#[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 AuthCert { - pub pubkey: Curve25519Public, - pub expiration: u64, - pub sig: Signature, +impl AsRef> for TxDemandVector { + #[must_use] + fn as_ref(&self) -> &VecM { + &self.0 + } } -impl ReadXdr for AuthCert { +impl ReadXdr for TxDemandVector { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - pubkey: Curve25519Public::read_xdr(r)?, - expiration: u64::read_xdr(r)?, - sig: Signature::read_xdr(r)?, - }) + let i = VecM::::read_xdr(r)?; + let v = TxDemandVector(i); + Ok(v) }) } } -impl WriteXdr for AuthCert { +impl WriteXdr for TxDemandVector { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.pubkey.write_xdr(w)?; - self.expiration.write_xdr(w)?; - self.sig.write_xdr(w)?; - Ok(()) - }) + w.with_limited_depth(|w| self.0.write_xdr(w)) } } -// Hello is an XDR Struct defines as: -// -// struct Hello -// { -// uint32 ledgerVersion; -// uint32 overlayVersion; -// uint32 overlayMinVersion; -// Hash networkID; -// string versionStr<100>; -// int listeningPort; -// NodeID peerID; -// AuthCert cert; -// uint256 nonce; -// }; -// -#[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 Hello { - pub ledger_version: u32, - pub overlay_version: u32, - pub overlay_min_version: u32, - pub network_id: Hash, - pub version_str: StringM<100>, - pub listening_port: i32, - pub peer_id: NodeId, - pub cert: AuthCert, - pub nonce: Uint256, +impl Deref for TxDemandVector { + type Target = VecM; + fn deref(&self) -> &Self::Target { + &self.0 + } } -impl ReadXdr for Hello { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - ledger_version: u32::read_xdr(r)?, - overlay_version: u32::read_xdr(r)?, - overlay_min_version: u32::read_xdr(r)?, - network_id: Hash::read_xdr(r)?, - version_str: StringM::<100>::read_xdr(r)?, - listening_port: i32::read_xdr(r)?, - peer_id: NodeId::read_xdr(r)?, - cert: AuthCert::read_xdr(r)?, - nonce: Uint256::read_xdr(r)?, - }) - }) +impl From for Vec { + #[must_use] + fn from(x: TxDemandVector) -> Self { + x.0 .0 + } +} + +impl TryFrom> for TxDemandVector { + type Error = Error; + fn try_from(x: Vec) -> Result { + Ok(TxDemandVector(x.try_into()?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for TxDemandVector { + type Error = Error; + fn try_from(x: &Vec) -> Result { + Ok(TxDemandVector(x.try_into()?)) } } -impl WriteXdr for Hello { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.ledger_version.write_xdr(w)?; - self.overlay_version.write_xdr(w)?; - self.overlay_min_version.write_xdr(w)?; - self.network_id.write_xdr(w)?; - self.version_str.write_xdr(w)?; - self.listening_port.write_xdr(w)?; - self.peer_id.write_xdr(w)?; - self.cert.write_xdr(w)?; - self.nonce.write_xdr(w)?; - Ok(()) - }) +impl AsRef> for TxDemandVector { + #[must_use] + fn as_ref(&self) -> &Vec { + &self.0 .0 } } -// AuthMsgFlagPullModeRequested is an XDR Const defines as: -// -// const AUTH_MSG_FLAG_PULL_MODE_REQUESTED = 100; -// -pub const AUTH_MSG_FLAG_PULL_MODE_REQUESTED: u64 = 100; +impl AsRef<[Hash]> for TxDemandVector { + #[cfg(feature = "alloc")] + #[must_use] + fn as_ref(&self) -> &[Hash] { + &self.0 .0 + } + #[cfg(not(feature = "alloc"))] + #[must_use] + fn as_ref(&self) -> &[Hash] { + self.0 .0 + } +} -// Auth is an XDR Struct defines as: +// FloodDemand is an XDR Struct defines as: // -// struct Auth +// struct FloodDemand // { -// int flags; +// TxDemandVector txHashes; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -13759,145 +22655,380 @@ pub const AUTH_MSG_FLAG_PULL_MODE_REQUESTED: u64 = 100; derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct Auth { - pub flags: i32, +pub struct FloodDemand { + pub tx_hashes: TxDemandVector, } -impl ReadXdr for Auth { +impl ReadXdr for FloodDemand { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - flags: i32::read_xdr(r)?, + tx_hashes: TxDemandVector::read_xdr(r)?, }) }) } } -impl WriteXdr for Auth { +impl WriteXdr for FloodDemand { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.flags.write_xdr(w)?; + self.tx_hashes.write_xdr(w)?; Ok(()) }) } } -// IpAddrType is an XDR Enum defines as: +// StellarMessage is an XDR Union defines as: // -// enum IPAddrType +// union StellarMessage switch (MessageType type) // { -// IPv4 = 0, -// IPv6 = 1 +// case ERROR_MSG: +// Error error; +// case HELLO: +// Hello hello; +// case AUTH: +// Auth auth; +// case DONT_HAVE: +// DontHave dontHave; +// case GET_PEERS: +// void; +// case PEERS: +// PeerAddress peers<100>; +// +// case GET_TX_SET: +// uint256 txSetHash; +// case TX_SET: +// TransactionSet txSet; +// case GENERALIZED_TX_SET: +// GeneralizedTransactionSet generalizedTxSet; +// +// case TRANSACTION: +// TransactionEnvelope transaction; +// +// case SURVEY_REQUEST: +// SignedSurveyRequestMessage signedSurveyRequestMessage; +// +// case SURVEY_RESPONSE: +// SignedSurveyResponseMessage signedSurveyResponseMessage; +// +// // SCP +// case GET_SCP_QUORUMSET: +// uint256 qSetHash; +// case SCP_QUORUMSET: +// SCPQuorumSet qSet; +// case SCP_MESSAGE: +// SCPEnvelope envelope; +// case GET_SCP_STATE: +// uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest +// case SEND_MORE: +// SendMore sendMoreMessage; +// case SEND_MORE_EXTENDED: +// SendMoreExtended sendMoreExtendedMessage; +// // Pull mode +// case FLOOD_ADVERT: +// FloodAdvert floodAdvert; +// case FLOOD_DEMAND: +// FloodDemand floodDemand; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant MessageType +#[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") )] -#[repr(i32)] -pub enum IpAddrType { - IPv4 = 0, - IPv6 = 1, +#[allow(clippy::large_enum_variant)] +pub enum StellarMessage { + ErrorMsg(SError), + Hello(Hello), + Auth(Auth), + DontHave(DontHave), + GetPeers, + Peers(VecM), + GetTxSet(Uint256), + TxSet(TransactionSet), + GeneralizedTxSet(GeneralizedTransactionSet), + Transaction(TransactionEnvelope), + SurveyRequest(SignedSurveyRequestMessage), + SurveyResponse(SignedSurveyResponseMessage), + GetScpQuorumset(Uint256), + ScpQuorumset(ScpQuorumSet), + ScpMessage(ScpEnvelope), + GetScpState(u32), + SendMore(SendMore), + SendMoreExtended(SendMoreExtended), + FloodAdvert(FloodAdvert), + FloodDemand(FloodDemand), } -impl IpAddrType { - pub const VARIANTS: [IpAddrType; 2] = [IpAddrType::IPv4, IpAddrType::IPv6]; - pub const VARIANTS_STR: [&'static str; 2] = ["IPv4", "IPv6"]; +impl StellarMessage { + pub const VARIANTS: [MessageType; 20] = [ + MessageType::ErrorMsg, + MessageType::Hello, + MessageType::Auth, + MessageType::DontHave, + MessageType::GetPeers, + MessageType::Peers, + MessageType::GetTxSet, + MessageType::TxSet, + MessageType::GeneralizedTxSet, + MessageType::Transaction, + MessageType::SurveyRequest, + MessageType::SurveyResponse, + MessageType::GetScpQuorumset, + MessageType::ScpQuorumset, + MessageType::ScpMessage, + MessageType::GetScpState, + MessageType::SendMore, + MessageType::SendMoreExtended, + MessageType::FloodAdvert, + MessageType::FloodDemand, + ]; + pub const VARIANTS_STR: [&'static str; 20] = [ + "ErrorMsg", + "Hello", + "Auth", + "DontHave", + "GetPeers", + "Peers", + "GetTxSet", + "TxSet", + "GeneralizedTxSet", + "Transaction", + "SurveyRequest", + "SurveyResponse", + "GetScpQuorumset", + "ScpQuorumset", + "ScpMessage", + "GetScpState", + "SendMore", + "SendMoreExtended", + "FloodAdvert", + "FloodDemand", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::IPv4 => "IPv4", - Self::IPv6 => "IPv6", + Self::ErrorMsg(_) => "ErrorMsg", + Self::Hello(_) => "Hello", + Self::Auth(_) => "Auth", + Self::DontHave(_) => "DontHave", + Self::GetPeers => "GetPeers", + Self::Peers(_) => "Peers", + Self::GetTxSet(_) => "GetTxSet", + Self::TxSet(_) => "TxSet", + Self::GeneralizedTxSet(_) => "GeneralizedTxSet", + Self::Transaction(_) => "Transaction", + Self::SurveyRequest(_) => "SurveyRequest", + Self::SurveyResponse(_) => "SurveyResponse", + Self::GetScpQuorumset(_) => "GetScpQuorumset", + Self::ScpQuorumset(_) => "ScpQuorumset", + Self::ScpMessage(_) => "ScpMessage", + Self::GetScpState(_) => "GetScpState", + Self::SendMore(_) => "SendMore", + Self::SendMoreExtended(_) => "SendMoreExtended", + Self::FloodAdvert(_) => "FloodAdvert", + Self::FloodDemand(_) => "FloodDemand", } } #[must_use] - pub const fn variants() -> [IpAddrType; 2] { + pub const fn discriminant(&self) -> MessageType { + #[allow(clippy::match_same_arms)] + match self { + Self::ErrorMsg(_) => MessageType::ErrorMsg, + Self::Hello(_) => MessageType::Hello, + Self::Auth(_) => MessageType::Auth, + Self::DontHave(_) => MessageType::DontHave, + Self::GetPeers => MessageType::GetPeers, + Self::Peers(_) => MessageType::Peers, + Self::GetTxSet(_) => MessageType::GetTxSet, + Self::TxSet(_) => MessageType::TxSet, + Self::GeneralizedTxSet(_) => MessageType::GeneralizedTxSet, + Self::Transaction(_) => MessageType::Transaction, + Self::SurveyRequest(_) => MessageType::SurveyRequest, + Self::SurveyResponse(_) => MessageType::SurveyResponse, + Self::GetScpQuorumset(_) => MessageType::GetScpQuorumset, + Self::ScpQuorumset(_) => MessageType::ScpQuorumset, + Self::ScpMessage(_) => MessageType::ScpMessage, + Self::GetScpState(_) => MessageType::GetScpState, + Self::SendMore(_) => MessageType::SendMore, + Self::SendMoreExtended(_) => MessageType::SendMoreExtended, + Self::FloodAdvert(_) => MessageType::FloodAdvert, + Self::FloodDemand(_) => MessageType::FloodDemand, + } + } + + #[must_use] + pub const fn variants() -> [MessageType; 20] { Self::VARIANTS } } -impl Name for IpAddrType { +impl Name for StellarMessage { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for IpAddrType { - fn variants() -> slice::Iter<'static, IpAddrType> { - Self::VARIANTS.iter() +impl Discriminant for StellarMessage { + #[must_use] + fn discriminant(&self) -> MessageType { + Self::discriminant(self) } } -impl Enum for IpAddrType {} - -impl fmt::Display for IpAddrType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Variants for StellarMessage { + fn variants() -> slice::Iter<'static, MessageType> { + Self::VARIANTS.iter() } } -impl TryFrom for IpAddrType { - type Error = Error; +impl Union for StellarMessage {} - fn try_from(i: i32) -> Result { - let e = match i { - 0 => IpAddrType::IPv4, - 1 => IpAddrType::IPv6, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl ReadXdr for StellarMessage { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: MessageType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + MessageType::ErrorMsg => Self::ErrorMsg(SError::read_xdr(r)?), + MessageType::Hello => Self::Hello(Hello::read_xdr(r)?), + MessageType::Auth => Self::Auth(Auth::read_xdr(r)?), + MessageType::DontHave => Self::DontHave(DontHave::read_xdr(r)?), + MessageType::GetPeers => Self::GetPeers, + MessageType::Peers => Self::Peers(VecM::::read_xdr(r)?), + MessageType::GetTxSet => Self::GetTxSet(Uint256::read_xdr(r)?), + MessageType::TxSet => Self::TxSet(TransactionSet::read_xdr(r)?), + MessageType::GeneralizedTxSet => { + Self::GeneralizedTxSet(GeneralizedTransactionSet::read_xdr(r)?) + } + MessageType::Transaction => Self::Transaction(TransactionEnvelope::read_xdr(r)?), + MessageType::SurveyRequest => { + Self::SurveyRequest(SignedSurveyRequestMessage::read_xdr(r)?) + } + MessageType::SurveyResponse => { + Self::SurveyResponse(SignedSurveyResponseMessage::read_xdr(r)?) + } + MessageType::GetScpQuorumset => Self::GetScpQuorumset(Uint256::read_xdr(r)?), + MessageType::ScpQuorumset => Self::ScpQuorumset(ScpQuorumSet::read_xdr(r)?), + MessageType::ScpMessage => Self::ScpMessage(ScpEnvelope::read_xdr(r)?), + MessageType::GetScpState => Self::GetScpState(u32::read_xdr(r)?), + MessageType::SendMore => Self::SendMore(SendMore::read_xdr(r)?), + MessageType::SendMoreExtended => { + Self::SendMoreExtended(SendMoreExtended::read_xdr(r)?) + } + MessageType::FloodAdvert => Self::FloodAdvert(FloodAdvert::read_xdr(r)?), + MessageType::FloodDemand => Self::FloodDemand(FloodDemand::read_xdr(r)?), + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) } } -impl From for i32 { - #[must_use] - fn from(e: IpAddrType) -> Self { - e as Self +impl WriteXdr for StellarMessage { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::ErrorMsg(v) => v.write_xdr(w)?, + Self::Hello(v) => v.write_xdr(w)?, + Self::Auth(v) => v.write_xdr(w)?, + Self::DontHave(v) => v.write_xdr(w)?, + Self::GetPeers => ().write_xdr(w)?, + Self::Peers(v) => v.write_xdr(w)?, + Self::GetTxSet(v) => v.write_xdr(w)?, + Self::TxSet(v) => v.write_xdr(w)?, + Self::GeneralizedTxSet(v) => v.write_xdr(w)?, + Self::Transaction(v) => v.write_xdr(w)?, + Self::SurveyRequest(v) => v.write_xdr(w)?, + Self::SurveyResponse(v) => v.write_xdr(w)?, + Self::GetScpQuorumset(v) => v.write_xdr(w)?, + Self::ScpQuorumset(v) => v.write_xdr(w)?, + Self::ScpMessage(v) => v.write_xdr(w)?, + Self::GetScpState(v) => v.write_xdr(w)?, + Self::SendMore(v) => v.write_xdr(w)?, + Self::SendMoreExtended(v) => v.write_xdr(w)?, + Self::FloodAdvert(v) => v.write_xdr(w)?, + Self::FloodDemand(v) => v.write_xdr(w)?, + }; + Ok(()) + }) } } -impl ReadXdr for IpAddrType { +// AuthenticatedMessageV0 is an XDR NestedStruct defines as: +// +// struct +// { +// uint64 sequence; +// StellarMessage message; +// HmacSha256Mac mac; +// } +// +#[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 AuthenticatedMessageV0 { + pub sequence: u64, + pub message: StellarMessage, + pub mac: HmacSha256Mac, +} + +impl ReadXdr for AuthenticatedMessageV0 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; - Ok(v) + Ok(Self { + sequence: u64::read_xdr(r)?, + message: StellarMessage::read_xdr(r)?, + mac: HmacSha256Mac::read_xdr(r)?, + }) }) } } -impl WriteXdr for IpAddrType { +impl WriteXdr for AuthenticatedMessageV0 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.sequence.write_xdr(w)?; + self.message.write_xdr(w)?; + self.mac.write_xdr(w)?; + Ok(()) }) } } -// PeerAddressIp is an XDR NestedUnion defines as: +// AuthenticatedMessage is an XDR Union defines as: // -// union switch (IPAddrType type) +// union AuthenticatedMessage switch (uint32 v) +// { +// case 0: +// struct // { -// case IPv4: -// opaque ipv4[4]; -// case IPv6: -// opaque ipv6[16]; -// } +// uint64 sequence; +// StellarMessage message; +// HmacSha256Mac mac; +// } v0; +// }; // -// union with discriminant IpAddrType +// union with discriminant u32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -13906,69 +23037,65 @@ impl WriteXdr for IpAddrType { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum PeerAddressIp { - IPv4([u8; 4]), - IPv6([u8; 16]), +pub enum AuthenticatedMessage { + V0(AuthenticatedMessageV0), } -impl PeerAddressIp { - pub const VARIANTS: [IpAddrType; 2] = [IpAddrType::IPv4, IpAddrType::IPv6]; - pub const VARIANTS_STR: [&'static str; 2] = ["IPv4", "IPv6"]; +impl AuthenticatedMessage { + pub const VARIANTS: [u32; 1] = [0]; + pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::IPv4(_) => "IPv4", - Self::IPv6(_) => "IPv6", + Self::V0(_) => "V0", } } #[must_use] - pub const fn discriminant(&self) -> IpAddrType { + pub const fn discriminant(&self) -> u32 { #[allow(clippy::match_same_arms)] match self { - Self::IPv4(_) => IpAddrType::IPv4, - Self::IPv6(_) => IpAddrType::IPv6, + Self::V0(_) => 0, } } #[must_use] - pub const fn variants() -> [IpAddrType; 2] { + pub const fn variants() -> [u32; 1] { Self::VARIANTS } } -impl Name for PeerAddressIp { +impl Name for AuthenticatedMessage { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for PeerAddressIp { +impl Discriminant for AuthenticatedMessage { #[must_use] - fn discriminant(&self) -> IpAddrType { + fn discriminant(&self) -> u32 { Self::discriminant(self) } } -impl Variants for PeerAddressIp { - fn variants() -> slice::Iter<'static, IpAddrType> { +impl Variants for AuthenticatedMessage { + fn variants() -> slice::Iter<'static, u32> { Self::VARIANTS.iter() } } -impl Union for PeerAddressIp {} +impl Union for AuthenticatedMessage {} -impl ReadXdr for PeerAddressIp { +impl ReadXdr for AuthenticatedMessage { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: IpAddrType = ::read_xdr(r)?; + let dv: u32 = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - IpAddrType::IPv4 => Self::IPv4(<[u8; 4]>::read_xdr(r)?), - IpAddrType::IPv6 => Self::IPv6(<[u8; 16]>::read_xdr(r)?), + 0 => Self::V0(AuthenticatedMessageV0::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -13977,302 +23104,137 @@ impl ReadXdr for PeerAddressIp { } } -impl WriteXdr for PeerAddressIp { +impl WriteXdr for AuthenticatedMessage { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::IPv4(v) => v.write_xdr(w)?, - Self::IPv6(v) => v.write_xdr(w)?, + Self::V0(v) => v.write_xdr(w)?, }; - Ok(()) - }) - } -} - -// PeerAddress is an XDR Struct defines as: -// -// struct PeerAddress -// { -// union switch (IPAddrType type) -// { -// case IPv4: -// opaque ipv4[4]; -// case IPv6: -// opaque ipv6[16]; -// } -// ip; -// uint32 port; -// uint32 numFailures; -// }; -// -#[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 PeerAddress { - pub ip: PeerAddressIp, - pub port: u32, - pub num_failures: u32, -} - -impl ReadXdr for PeerAddress { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - ip: PeerAddressIp::read_xdr(r)?, - port: u32::read_xdr(r)?, - num_failures: u32::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for PeerAddress { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.ip.write_xdr(w)?; - self.port.write_xdr(w)?; - self.num_failures.write_xdr(w)?; - Ok(()) - }) - } -} - -// MessageType is an XDR Enum defines as: -// -// enum MessageType -// { -// ERROR_MSG = 0, -// AUTH = 2, -// DONT_HAVE = 3, -// -// GET_PEERS = 4, // gets a list of peers this guy knows about -// PEERS = 5, -// -// GET_TX_SET = 6, // gets a particular txset by hash -// TX_SET = 7, -// GENERALIZED_TX_SET = 17, -// -// TRANSACTION = 8, // pass on a tx you have heard about -// -// // SCP -// GET_SCP_QUORUMSET = 9, -// SCP_QUORUMSET = 10, -// SCP_MESSAGE = 11, -// GET_SCP_STATE = 12, + Ok(()) + }) + } +} + +// MaxOpsPerTx is an XDR Const defines as: // -// // new messages -// HELLO = 13, +// const MAX_OPS_PER_TX = 100; // -// SURVEY_REQUEST = 14, -// SURVEY_RESPONSE = 15, +pub const MAX_OPS_PER_TX: u64 = 100; + +// LiquidityPoolParameters is an XDR Union defines as: // -// SEND_MORE = 16, -// FLOOD_ADVERT = 18, -// FLOOD_DEMAND = 19 +// union LiquidityPoolParameters switch (LiquidityPoolType type) +// { +// case LIQUIDITY_POOL_CONSTANT_PRODUCT: +// LiquidityPoolConstantProductParameters constantProduct; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant LiquidityPoolType +#[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") )] -#[repr(i32)] -pub enum MessageType { - ErrorMsg = 0, - Auth = 2, - DontHave = 3, - GetPeers = 4, - Peers = 5, - GetTxSet = 6, - TxSet = 7, - GeneralizedTxSet = 17, - Transaction = 8, - GetScpQuorumset = 9, - ScpQuorumset = 10, - ScpMessage = 11, - GetScpState = 12, - Hello = 13, - SurveyRequest = 14, - SurveyResponse = 15, - SendMore = 16, - FloodAdvert = 18, - FloodDemand = 19, +#[allow(clippy::large_enum_variant)] +pub enum LiquidityPoolParameters { + LiquidityPoolConstantProduct(LiquidityPoolConstantProductParameters), } -impl MessageType { - pub const VARIANTS: [MessageType; 19] = [ - MessageType::ErrorMsg, - MessageType::Auth, - MessageType::DontHave, - MessageType::GetPeers, - MessageType::Peers, - MessageType::GetTxSet, - MessageType::TxSet, - MessageType::GeneralizedTxSet, - MessageType::Transaction, - MessageType::GetScpQuorumset, - MessageType::ScpQuorumset, - MessageType::ScpMessage, - MessageType::GetScpState, - MessageType::Hello, - MessageType::SurveyRequest, - MessageType::SurveyResponse, - MessageType::SendMore, - MessageType::FloodAdvert, - MessageType::FloodDemand, - ]; - pub const VARIANTS_STR: [&'static str; 19] = [ - "ErrorMsg", - "Auth", - "DontHave", - "GetPeers", - "Peers", - "GetTxSet", - "TxSet", - "GeneralizedTxSet", - "Transaction", - "GetScpQuorumset", - "ScpQuorumset", - "ScpMessage", - "GetScpState", - "Hello", - "SurveyRequest", - "SurveyResponse", - "SendMore", - "FloodAdvert", - "FloodDemand", - ]; +impl LiquidityPoolParameters { + pub const VARIANTS: [LiquidityPoolType; 1] = [LiquidityPoolType::LiquidityPoolConstantProduct]; + pub const VARIANTS_STR: [&'static str; 1] = ["LiquidityPoolConstantProduct"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::ErrorMsg => "ErrorMsg", - Self::Auth => "Auth", - Self::DontHave => "DontHave", - Self::GetPeers => "GetPeers", - Self::Peers => "Peers", - Self::GetTxSet => "GetTxSet", - Self::TxSet => "TxSet", - Self::GeneralizedTxSet => "GeneralizedTxSet", - Self::Transaction => "Transaction", - Self::GetScpQuorumset => "GetScpQuorumset", - Self::ScpQuorumset => "ScpQuorumset", - Self::ScpMessage => "ScpMessage", - Self::GetScpState => "GetScpState", - Self::Hello => "Hello", - Self::SurveyRequest => "SurveyRequest", - Self::SurveyResponse => "SurveyResponse", - Self::SendMore => "SendMore", - Self::FloodAdvert => "FloodAdvert", - Self::FloodDemand => "FloodDemand", + Self::LiquidityPoolConstantProduct(_) => "LiquidityPoolConstantProduct", + } + } + + #[must_use] + pub const fn discriminant(&self) -> LiquidityPoolType { + #[allow(clippy::match_same_arms)] + match self { + Self::LiquidityPoolConstantProduct(_) => { + LiquidityPoolType::LiquidityPoolConstantProduct + } } } #[must_use] - pub const fn variants() -> [MessageType; 19] { + pub const fn variants() -> [LiquidityPoolType; 1] { Self::VARIANTS } } -impl Name for MessageType { +impl Name for LiquidityPoolParameters { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for MessageType { - fn variants() -> slice::Iter<'static, MessageType> { - Self::VARIANTS.iter() - } -} - -impl Enum for MessageType {} - -impl fmt::Display for MessageType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Discriminant for LiquidityPoolParameters { + #[must_use] + fn discriminant(&self) -> LiquidityPoolType { + Self::discriminant(self) } } -impl TryFrom for MessageType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => MessageType::ErrorMsg, - 2 => MessageType::Auth, - 3 => MessageType::DontHave, - 4 => MessageType::GetPeers, - 5 => MessageType::Peers, - 6 => MessageType::GetTxSet, - 7 => MessageType::TxSet, - 17 => MessageType::GeneralizedTxSet, - 8 => MessageType::Transaction, - 9 => MessageType::GetScpQuorumset, - 10 => MessageType::ScpQuorumset, - 11 => MessageType::ScpMessage, - 12 => MessageType::GetScpState, - 13 => MessageType::Hello, - 14 => MessageType::SurveyRequest, - 15 => MessageType::SurveyResponse, - 16 => MessageType::SendMore, - 18 => MessageType::FloodAdvert, - 19 => MessageType::FloodDemand, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl Variants for LiquidityPoolParameters { + fn variants() -> slice::Iter<'static, LiquidityPoolType> { + Self::VARIANTS.iter() } } -impl From for i32 { - #[must_use] - fn from(e: MessageType) -> Self { - e as Self - } -} +impl Union for LiquidityPoolParameters {} -impl ReadXdr for MessageType { +impl ReadXdr for LiquidityPoolParameters { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; + let dv: LiquidityPoolType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + LiquidityPoolType::LiquidityPoolConstantProduct => { + Self::LiquidityPoolConstantProduct( + LiquidityPoolConstantProductParameters::read_xdr(r)?, + ) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for MessageType { +impl WriteXdr for LiquidityPoolParameters { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::LiquidityPoolConstantProduct(v) => v.write_xdr(w)?, + }; + Ok(()) }) } } -// DontHave is an XDR Struct defines as: +// MuxedAccountMed25519 is an XDR NestedStruct defines as: // -// struct DontHave -// { -// MessageType type; -// uint256 reqHash; -// }; +// struct +// { +// uint64 id; +// uint256 ed25519; +// } // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -14281,142 +23243,151 @@ impl WriteXdr for MessageType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct DontHave { - pub type_: MessageType, - pub req_hash: Uint256, +pub struct MuxedAccountMed25519 { + pub id: u64, + pub ed25519: Uint256, } -impl ReadXdr for DontHave { +impl ReadXdr for MuxedAccountMed25519 { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - type_: MessageType::read_xdr(r)?, - req_hash: Uint256::read_xdr(r)?, + id: u64::read_xdr(r)?, + ed25519: Uint256::read_xdr(r)?, }) }) } } -impl WriteXdr for DontHave { +impl WriteXdr for MuxedAccountMed25519 { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.type_.write_xdr(w)?; - self.req_hash.write_xdr(w)?; + self.id.write_xdr(w)?; + self.ed25519.write_xdr(w)?; Ok(()) }) } } -// SurveyMessageCommandType is an XDR Enum defines as: +// MuxedAccount is an XDR Union defines as: // -// enum SurveyMessageCommandType +// union MuxedAccount switch (CryptoKeyType type) // { -// SURVEY_TOPOLOGY = 0 +// case KEY_TYPE_ED25519: +// uint256 ed25519; +// case KEY_TYPE_MUXED_ED25519: +// struct +// { +// uint64 id; +// uint256 ed25519; +// } med25519; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant CryptoKeyType +#[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") )] -#[repr(i32)] -pub enum SurveyMessageCommandType { - SurveyTopology = 0, +#[allow(clippy::large_enum_variant)] +pub enum MuxedAccount { + Ed25519(Uint256), + MuxedEd25519(MuxedAccountMed25519), } -impl SurveyMessageCommandType { - pub const VARIANTS: [SurveyMessageCommandType; 1] = [SurveyMessageCommandType::SurveyTopology]; - pub const VARIANTS_STR: [&'static str; 1] = ["SurveyTopology"]; +impl MuxedAccount { + pub const VARIANTS: [CryptoKeyType; 2] = [CryptoKeyType::Ed25519, CryptoKeyType::MuxedEd25519]; + pub const VARIANTS_STR: [&'static str; 2] = ["Ed25519", "MuxedEd25519"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::SurveyTopology => "SurveyTopology", + Self::Ed25519(_) => "Ed25519", + Self::MuxedEd25519(_) => "MuxedEd25519", } } #[must_use] - pub const fn variants() -> [SurveyMessageCommandType; 1] { + pub const fn discriminant(&self) -> CryptoKeyType { + #[allow(clippy::match_same_arms)] + match self { + Self::Ed25519(_) => CryptoKeyType::Ed25519, + Self::MuxedEd25519(_) => CryptoKeyType::MuxedEd25519, + } + } + + #[must_use] + pub const fn variants() -> [CryptoKeyType; 2] { Self::VARIANTS } } -impl Name for SurveyMessageCommandType { +impl Name for MuxedAccount { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for SurveyMessageCommandType { - fn variants() -> slice::Iter<'static, SurveyMessageCommandType> { - Self::VARIANTS.iter() - } -} - -impl Enum for SurveyMessageCommandType {} - -impl fmt::Display for SurveyMessageCommandType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Discriminant for MuxedAccount { + #[must_use] + fn discriminant(&self) -> CryptoKeyType { + Self::discriminant(self) } } -impl TryFrom for SurveyMessageCommandType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => SurveyMessageCommandType::SurveyTopology, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl Variants for MuxedAccount { + fn variants() -> slice::Iter<'static, CryptoKeyType> { + Self::VARIANTS.iter() } } -impl From for i32 { - #[must_use] - fn from(e: SurveyMessageCommandType) -> Self { - e as Self - } -} +impl Union for MuxedAccount {} -impl ReadXdr for SurveyMessageCommandType { +impl ReadXdr for MuxedAccount { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; + let dv: CryptoKeyType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + CryptoKeyType::Ed25519 => Self::Ed25519(Uint256::read_xdr(r)?), + CryptoKeyType::MuxedEd25519 => { + Self::MuxedEd25519(MuxedAccountMed25519::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for SurveyMessageCommandType { +impl WriteXdr for MuxedAccount { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Ed25519(v) => v.write_xdr(w)?, + Self::MuxedEd25519(v) => v.write_xdr(w)?, + }; + Ok(()) }) } } -// SurveyRequestMessage is an XDR Struct defines as: +// DecoratedSignature is an XDR Struct defines as: // -// struct SurveyRequestMessage +// struct DecoratedSignature // { -// NodeID surveyorPeerID; -// NodeID surveyedPeerID; -// uint32 ledgerNum; -// Curve25519Public encryptionKey; -// SurveyMessageCommandType commandType; +// SignatureHint hint; // last 4 bytes of the public key, used as a hint +// Signature signature; // actual signature // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -14426,249 +23397,299 @@ impl WriteXdr for SurveyMessageCommandType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SurveyRequestMessage { - pub surveyor_peer_id: NodeId, - pub surveyed_peer_id: NodeId, - pub ledger_num: u32, - pub encryption_key: Curve25519Public, - pub command_type: SurveyMessageCommandType, +pub struct DecoratedSignature { + pub hint: SignatureHint, + pub signature: Signature, } -impl ReadXdr for SurveyRequestMessage { +impl ReadXdr for DecoratedSignature { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - surveyor_peer_id: NodeId::read_xdr(r)?, - surveyed_peer_id: NodeId::read_xdr(r)?, - ledger_num: u32::read_xdr(r)?, - encryption_key: Curve25519Public::read_xdr(r)?, - command_type: SurveyMessageCommandType::read_xdr(r)?, + hint: SignatureHint::read_xdr(r)?, + signature: Signature::read_xdr(r)?, }) }) } } -impl WriteXdr for SurveyRequestMessage { +impl WriteXdr for DecoratedSignature { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.surveyor_peer_id.write_xdr(w)?; - self.surveyed_peer_id.write_xdr(w)?; - self.ledger_num.write_xdr(w)?; - self.encryption_key.write_xdr(w)?; - self.command_type.write_xdr(w)?; + self.hint.write_xdr(w)?; + self.signature.write_xdr(w)?; Ok(()) }) } } -// SignedSurveyRequestMessage is an XDR Struct defines as: +// OperationType is an XDR Enum defines as: // -// struct SignedSurveyRequestMessage +// enum OperationType // { -// Signature requestSignature; -// SurveyRequestMessage request; +// CREATE_ACCOUNT = 0, +// PAYMENT = 1, +// PATH_PAYMENT_STRICT_RECEIVE = 2, +// MANAGE_SELL_OFFER = 3, +// CREATE_PASSIVE_SELL_OFFER = 4, +// SET_OPTIONS = 5, +// CHANGE_TRUST = 6, +// ALLOW_TRUST = 7, +// ACCOUNT_MERGE = 8, +// INFLATION = 9, +// MANAGE_DATA = 10, +// BUMP_SEQUENCE = 11, +// MANAGE_BUY_OFFER = 12, +// PATH_PAYMENT_STRICT_SEND = 13, +// CREATE_CLAIMABLE_BALANCE = 14, +// CLAIM_CLAIMABLE_BALANCE = 15, +// BEGIN_SPONSORING_FUTURE_RESERVES = 16, +// END_SPONSORING_FUTURE_RESERVES = 17, +// REVOKE_SPONSORSHIP = 18, +// CLAWBACK = 19, +// CLAWBACK_CLAIMABLE_BALANCE = 20, +// SET_TRUST_LINE_FLAGS = 21, +// LIQUIDITY_POOL_DEPOSIT = 22, +// LIQUIDITY_POOL_WITHDRAW = 23, +// INVOKE_HOST_FUNCTION = 24, +// BUMP_FOOTPRINT_EXPIRATION = 25, +// RESTORE_FOOTPRINT = 26 // }; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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 SignedSurveyRequestMessage { - pub request_signature: Signature, - pub request: SurveyRequestMessage, -} - -impl ReadXdr for SignedSurveyRequestMessage { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - request_signature: Signature::read_xdr(r)?, - request: SurveyRequestMessage::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for SignedSurveyRequestMessage { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.request_signature.write_xdr(w)?; - self.request.write_xdr(w)?; - Ok(()) - }) - } +#[repr(i32)] +pub enum OperationType { + CreateAccount = 0, + Payment = 1, + PathPaymentStrictReceive = 2, + ManageSellOffer = 3, + CreatePassiveSellOffer = 4, + SetOptions = 5, + ChangeTrust = 6, + AllowTrust = 7, + AccountMerge = 8, + Inflation = 9, + ManageData = 10, + BumpSequence = 11, + ManageBuyOffer = 12, + PathPaymentStrictSend = 13, + CreateClaimableBalance = 14, + ClaimClaimableBalance = 15, + BeginSponsoringFutureReserves = 16, + EndSponsoringFutureReserves = 17, + RevokeSponsorship = 18, + Clawback = 19, + ClawbackClaimableBalance = 20, + SetTrustLineFlags = 21, + LiquidityPoolDeposit = 22, + LiquidityPoolWithdraw = 23, + InvokeHostFunction = 24, + BumpFootprintExpiration = 25, + RestoreFootprint = 26, } -// EncryptedBody is an XDR Typedef defines as: -// -// typedef opaque EncryptedBody<64000>; -// -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Default, Debug)] -#[cfg_attr( - all(feature = "serde", feature = "alloc"), - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "snake_case") -)] -pub struct EncryptedBody(pub BytesM<64000>); +impl OperationType { + pub const VARIANTS: [OperationType; 27] = [ + OperationType::CreateAccount, + OperationType::Payment, + OperationType::PathPaymentStrictReceive, + OperationType::ManageSellOffer, + OperationType::CreatePassiveSellOffer, + OperationType::SetOptions, + OperationType::ChangeTrust, + OperationType::AllowTrust, + OperationType::AccountMerge, + OperationType::Inflation, + OperationType::ManageData, + OperationType::BumpSequence, + OperationType::ManageBuyOffer, + OperationType::PathPaymentStrictSend, + OperationType::CreateClaimableBalance, + OperationType::ClaimClaimableBalance, + OperationType::BeginSponsoringFutureReserves, + OperationType::EndSponsoringFutureReserves, + OperationType::RevokeSponsorship, + OperationType::Clawback, + OperationType::ClawbackClaimableBalance, + OperationType::SetTrustLineFlags, + OperationType::LiquidityPoolDeposit, + OperationType::LiquidityPoolWithdraw, + OperationType::InvokeHostFunction, + OperationType::BumpFootprintExpiration, + OperationType::RestoreFootprint, + ]; + pub const VARIANTS_STR: [&'static str; 27] = [ + "CreateAccount", + "Payment", + "PathPaymentStrictReceive", + "ManageSellOffer", + "CreatePassiveSellOffer", + "SetOptions", + "ChangeTrust", + "AllowTrust", + "AccountMerge", + "Inflation", + "ManageData", + "BumpSequence", + "ManageBuyOffer", + "PathPaymentStrictSend", + "CreateClaimableBalance", + "ClaimClaimableBalance", + "BeginSponsoringFutureReserves", + "EndSponsoringFutureReserves", + "RevokeSponsorship", + "Clawback", + "ClawbackClaimableBalance", + "SetTrustLineFlags", + "LiquidityPoolDeposit", + "LiquidityPoolWithdraw", + "InvokeHostFunction", + "BumpFootprintExpiration", + "RestoreFootprint", + ]; -impl From for BytesM<64000> { #[must_use] - fn from(x: EncryptedBody) -> Self { - x.0 + pub const fn name(&self) -> &'static str { + match self { + Self::CreateAccount => "CreateAccount", + Self::Payment => "Payment", + Self::PathPaymentStrictReceive => "PathPaymentStrictReceive", + Self::ManageSellOffer => "ManageSellOffer", + Self::CreatePassiveSellOffer => "CreatePassiveSellOffer", + Self::SetOptions => "SetOptions", + Self::ChangeTrust => "ChangeTrust", + Self::AllowTrust => "AllowTrust", + Self::AccountMerge => "AccountMerge", + Self::Inflation => "Inflation", + Self::ManageData => "ManageData", + Self::BumpSequence => "BumpSequence", + Self::ManageBuyOffer => "ManageBuyOffer", + Self::PathPaymentStrictSend => "PathPaymentStrictSend", + Self::CreateClaimableBalance => "CreateClaimableBalance", + Self::ClaimClaimableBalance => "ClaimClaimableBalance", + Self::BeginSponsoringFutureReserves => "BeginSponsoringFutureReserves", + Self::EndSponsoringFutureReserves => "EndSponsoringFutureReserves", + Self::RevokeSponsorship => "RevokeSponsorship", + Self::Clawback => "Clawback", + Self::ClawbackClaimableBalance => "ClawbackClaimableBalance", + Self::SetTrustLineFlags => "SetTrustLineFlags", + Self::LiquidityPoolDeposit => "LiquidityPoolDeposit", + Self::LiquidityPoolWithdraw => "LiquidityPoolWithdraw", + Self::InvokeHostFunction => "InvokeHostFunction", + Self::BumpFootprintExpiration => "BumpFootprintExpiration", + Self::RestoreFootprint => "RestoreFootprint", + } } -} -impl From> for EncryptedBody { #[must_use] - fn from(x: BytesM<64000>) -> Self { - EncryptedBody(x) + pub const fn variants() -> [OperationType; 27] { + Self::VARIANTS } } -impl AsRef> for EncryptedBody { +impl Name for OperationType { #[must_use] - fn as_ref(&self) -> &BytesM<64000> { - &self.0 - } -} - -impl ReadXdr for EncryptedBody { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let i = BytesM::<64000>::read_xdr(r)?; - let v = EncryptedBody(i); - Ok(v) - }) - } -} - -impl WriteXdr for EncryptedBody { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) + fn name(&self) -> &'static str { + Self::name(self) } } -impl Deref for EncryptedBody { - type Target = BytesM<64000>; - fn deref(&self) -> &Self::Target { - &self.0 +impl Variants for OperationType { + fn variants() -> slice::Iter<'static, OperationType> { + Self::VARIANTS.iter() } } -impl From for Vec { - #[must_use] - fn from(x: EncryptedBody) -> Self { - x.0 .0 - } -} +impl Enum for OperationType {} -impl TryFrom> for EncryptedBody { - type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(EncryptedBody(x.try_into()?)) +impl fmt::Display for OperationType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for EncryptedBody { +impl TryFrom for OperationType { type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(EncryptedBody(x.try_into()?)) - } -} -impl AsRef> for EncryptedBody { - #[must_use] - fn as_ref(&self) -> &Vec { - &self.0 .0 + fn try_from(i: i32) -> Result { + let e = match i { + 0 => OperationType::CreateAccount, + 1 => OperationType::Payment, + 2 => OperationType::PathPaymentStrictReceive, + 3 => OperationType::ManageSellOffer, + 4 => OperationType::CreatePassiveSellOffer, + 5 => OperationType::SetOptions, + 6 => OperationType::ChangeTrust, + 7 => OperationType::AllowTrust, + 8 => OperationType::AccountMerge, + 9 => OperationType::Inflation, + 10 => OperationType::ManageData, + 11 => OperationType::BumpSequence, + 12 => OperationType::ManageBuyOffer, + 13 => OperationType::PathPaymentStrictSend, + 14 => OperationType::CreateClaimableBalance, + 15 => OperationType::ClaimClaimableBalance, + 16 => OperationType::BeginSponsoringFutureReserves, + 17 => OperationType::EndSponsoringFutureReserves, + 18 => OperationType::RevokeSponsorship, + 19 => OperationType::Clawback, + 20 => OperationType::ClawbackClaimableBalance, + 21 => OperationType::SetTrustLineFlags, + 22 => OperationType::LiquidityPoolDeposit, + 23 => OperationType::LiquidityPoolWithdraw, + 24 => OperationType::InvokeHostFunction, + 25 => OperationType::BumpFootprintExpiration, + 26 => OperationType::RestoreFootprint, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -impl AsRef<[u8]> for EncryptedBody { - #[cfg(feature = "alloc")] - #[must_use] - fn as_ref(&self) -> &[u8] { - &self.0 .0 - } - #[cfg(not(feature = "alloc"))] +impl From for i32 { #[must_use] - fn as_ref(&self) -> &[u8] { - self.0 .0 + fn from(e: OperationType) -> Self { + e as Self } } -// SurveyResponseMessage is an XDR Struct defines as: -// -// struct SurveyResponseMessage -// { -// NodeID surveyorPeerID; -// NodeID surveyedPeerID; -// uint32 ledgerNum; -// SurveyMessageCommandType commandType; -// EncryptedBody encryptedBody; -// }; -// -#[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 SurveyResponseMessage { - pub surveyor_peer_id: NodeId, - pub surveyed_peer_id: NodeId, - pub ledger_num: u32, - pub command_type: SurveyMessageCommandType, - pub encrypted_body: EncryptedBody, -} - -impl ReadXdr for SurveyResponseMessage { +impl ReadXdr for OperationType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - surveyor_peer_id: NodeId::read_xdr(r)?, - surveyed_peer_id: NodeId::read_xdr(r)?, - ledger_num: u32::read_xdr(r)?, - command_type: SurveyMessageCommandType::read_xdr(r)?, - encrypted_body: EncryptedBody::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for SurveyResponseMessage { +impl WriteXdr for OperationType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.surveyor_peer_id.write_xdr(w)?; - self.surveyed_peer_id.write_xdr(w)?; - self.ledger_num.write_xdr(w)?; - self.command_type.write_xdr(w)?; - self.encrypted_body.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// SignedSurveyResponseMessage is an XDR Struct defines as: +// CreateAccountOp is an XDR Struct defines as: // -// struct SignedSurveyResponseMessage +// struct CreateAccountOp // { -// Signature responseSignature; -// SurveyResponseMessage response; +// AccountID destination; // account to create +// int64 startingBalance; // amount they end up with // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -14678,55 +23699,41 @@ impl WriteXdr for SurveyResponseMessage { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SignedSurveyResponseMessage { - pub response_signature: Signature, - pub response: SurveyResponseMessage, +pub struct CreateAccountOp { + pub destination: AccountId, + pub starting_balance: i64, } -impl ReadXdr for SignedSurveyResponseMessage { +impl ReadXdr for CreateAccountOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - response_signature: Signature::read_xdr(r)?, - response: SurveyResponseMessage::read_xdr(r)?, + destination: AccountId::read_xdr(r)?, + starting_balance: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for SignedSurveyResponseMessage { +impl WriteXdr for CreateAccountOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.response_signature.write_xdr(w)?; - self.response.write_xdr(w)?; + self.destination.write_xdr(w)?; + self.starting_balance.write_xdr(w)?; Ok(()) }) } } -// PeerStats is an XDR Struct defines as: +// PaymentOp is an XDR Struct defines as: // -// struct PeerStats +// struct PaymentOp // { -// NodeID id; -// string versionStr<100>; -// uint64 messagesRead; -// uint64 messagesWritten; -// uint64 bytesRead; -// uint64 bytesWritten; -// uint64 secondsConnected; -// -// uint64 uniqueFloodBytesRecv; -// uint64 duplicateFloodBytesRecv; -// uint64 uniqueFetchBytesRecv; -// uint64 duplicateFetchBytesRecv; -// -// uint64 uniqueFloodMessageRecv; -// uint64 duplicateFloodMessageRecv; -// uint64 uniqueFetchMessageRecv; -// uint64 duplicateFetchMessageRecv; +// MuxedAccount destination; // recipient of the payment +// Asset asset; // what they end up with +// int64 amount; // amount they end up with // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -14736,184 +23743,51 @@ impl WriteXdr for SignedSurveyResponseMessage { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PeerStats { - pub id: NodeId, - pub version_str: StringM<100>, - pub messages_read: u64, - pub messages_written: u64, - pub bytes_read: u64, - pub bytes_written: u64, - pub seconds_connected: u64, - pub unique_flood_bytes_recv: u64, - pub duplicate_flood_bytes_recv: u64, - pub unique_fetch_bytes_recv: u64, - pub duplicate_fetch_bytes_recv: u64, - pub unique_flood_message_recv: u64, - pub duplicate_flood_message_recv: u64, - pub unique_fetch_message_recv: u64, - pub duplicate_fetch_message_recv: u64, +pub struct PaymentOp { + pub destination: MuxedAccount, + pub asset: Asset, + pub amount: i64, } -impl ReadXdr for PeerStats { +impl ReadXdr for PaymentOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - id: NodeId::read_xdr(r)?, - version_str: StringM::<100>::read_xdr(r)?, - messages_read: u64::read_xdr(r)?, - messages_written: u64::read_xdr(r)?, - bytes_read: u64::read_xdr(r)?, - bytes_written: u64::read_xdr(r)?, - seconds_connected: u64::read_xdr(r)?, - unique_flood_bytes_recv: u64::read_xdr(r)?, - duplicate_flood_bytes_recv: u64::read_xdr(r)?, - unique_fetch_bytes_recv: u64::read_xdr(r)?, - duplicate_fetch_bytes_recv: u64::read_xdr(r)?, - unique_flood_message_recv: u64::read_xdr(r)?, - duplicate_flood_message_recv: u64::read_xdr(r)?, - unique_fetch_message_recv: u64::read_xdr(r)?, - duplicate_fetch_message_recv: u64::read_xdr(r)?, + destination: MuxedAccount::read_xdr(r)?, + asset: Asset::read_xdr(r)?, + amount: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for PeerStats { +impl WriteXdr for PaymentOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.id.write_xdr(w)?; - self.version_str.write_xdr(w)?; - self.messages_read.write_xdr(w)?; - self.messages_written.write_xdr(w)?; - self.bytes_read.write_xdr(w)?; - self.bytes_written.write_xdr(w)?; - self.seconds_connected.write_xdr(w)?; - self.unique_flood_bytes_recv.write_xdr(w)?; - self.duplicate_flood_bytes_recv.write_xdr(w)?; - self.unique_fetch_bytes_recv.write_xdr(w)?; - self.duplicate_fetch_bytes_recv.write_xdr(w)?; - self.unique_flood_message_recv.write_xdr(w)?; - self.duplicate_flood_message_recv.write_xdr(w)?; - self.unique_fetch_message_recv.write_xdr(w)?; - self.duplicate_fetch_message_recv.write_xdr(w)?; + self.destination.write_xdr(w)?; + self.asset.write_xdr(w)?; + self.amount.write_xdr(w)?; Ok(()) }) } } -// PeerStatList is an XDR Typedef defines as: -// -// typedef PeerStats PeerStatList<25>; -// -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Default, Debug)] -#[cfg_attr( - all(feature = "serde", feature = "alloc"), - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "snake_case") -)] -pub struct PeerStatList(pub VecM); - -impl From for VecM { - #[must_use] - fn from(x: PeerStatList) -> Self { - x.0 - } -} - -impl From> for PeerStatList { - #[must_use] - fn from(x: VecM) -> Self { - PeerStatList(x) - } -} - -impl AsRef> for PeerStatList { - #[must_use] - fn as_ref(&self) -> &VecM { - &self.0 - } -} - -impl ReadXdr for PeerStatList { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - let i = VecM::::read_xdr(r)?; - let v = PeerStatList(i); - Ok(v) - }) - } -} - -impl WriteXdr for PeerStatList { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} - -impl Deref for PeerStatList { - type Target = VecM; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From for Vec { - #[must_use] - fn from(x: PeerStatList) -> Self { - x.0 .0 - } -} - -impl TryFrom> for PeerStatList { - type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(PeerStatList(x.try_into()?)) - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for PeerStatList { - type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(PeerStatList(x.try_into()?)) - } -} - -impl AsRef> for PeerStatList { - #[must_use] - fn as_ref(&self) -> &Vec { - &self.0 .0 - } -} - -impl AsRef<[PeerStats]> for PeerStatList { - #[cfg(feature = "alloc")] - #[must_use] - fn as_ref(&self) -> &[PeerStats] { - &self.0 .0 - } - #[cfg(not(feature = "alloc"))] - #[must_use] - fn as_ref(&self) -> &[PeerStats] { - self.0 .0 - } -} - -// TopologyResponseBody is an XDR Struct defines as: +// PathPaymentStrictReceiveOp is an XDR Struct defines as: // -// struct TopologyResponseBody +// struct PathPaymentStrictReceiveOp // { -// PeerStatList inboundPeers; -// PeerStatList outboundPeers; +// Asset sendAsset; // asset we pay with +// int64 sendMax; // the maximum amount of sendAsset to +// // send (excluding fees). +// // The operation will fail if can't be met // -// uint32 totalInboundPeerCount; -// uint32 totalOutboundPeerCount; +// MuxedAccount destination; // recipient of the payment +// Asset destAsset; // what they end up with +// int64 destAmount; // amount they end up with +// +// Asset path<5>; // additional hops it must go through to get there // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -14923,253 +23797,178 @@ impl AsRef<[PeerStats]> for PeerStatList { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TopologyResponseBody { - pub inbound_peers: PeerStatList, - pub outbound_peers: PeerStatList, - pub total_inbound_peer_count: u32, - pub total_outbound_peer_count: u32, +pub struct PathPaymentStrictReceiveOp { + pub send_asset: Asset, + pub send_max: i64, + pub destination: MuxedAccount, + pub dest_asset: Asset, + pub dest_amount: i64, + pub path: VecM, } -impl ReadXdr for TopologyResponseBody { +impl ReadXdr for PathPaymentStrictReceiveOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - inbound_peers: PeerStatList::read_xdr(r)?, - outbound_peers: PeerStatList::read_xdr(r)?, - total_inbound_peer_count: u32::read_xdr(r)?, - total_outbound_peer_count: u32::read_xdr(r)?, + send_asset: Asset::read_xdr(r)?, + send_max: i64::read_xdr(r)?, + destination: MuxedAccount::read_xdr(r)?, + dest_asset: Asset::read_xdr(r)?, + dest_amount: i64::read_xdr(r)?, + path: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for TopologyResponseBody { +impl WriteXdr for PathPaymentStrictReceiveOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.inbound_peers.write_xdr(w)?; - self.outbound_peers.write_xdr(w)?; - self.total_inbound_peer_count.write_xdr(w)?; - self.total_outbound_peer_count.write_xdr(w)?; + self.send_asset.write_xdr(w)?; + self.send_max.write_xdr(w)?; + self.destination.write_xdr(w)?; + self.dest_asset.write_xdr(w)?; + self.dest_amount.write_xdr(w)?; + self.path.write_xdr(w)?; Ok(()) }) } } -// SurveyResponseBody is an XDR Union defines as: +// PathPaymentStrictSendOp is an XDR Struct defines as: // -// union SurveyResponseBody switch (SurveyMessageCommandType type) +// struct PathPaymentStrictSendOp // { -// case SURVEY_TOPOLOGY: -// TopologyResponseBody topologyResponseBody; +// Asset sendAsset; // asset we pay with +// int64 sendAmount; // amount of sendAsset to send (excluding fees) +// +// MuxedAccount destination; // recipient of the payment +// Asset destAsset; // what they end up with +// int64 destMin; // the minimum amount of dest asset to +// // be received +// // The operation will fail if it can't be met +// +// Asset path<5>; // additional hops it must go through to get there // }; // -// union with discriminant SurveyMessageCommandType #[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") -)] -#[allow(clippy::large_enum_variant)] -pub enum SurveyResponseBody { - SurveyTopology(TopologyResponseBody), -} - -impl SurveyResponseBody { - pub const VARIANTS: [SurveyMessageCommandType; 1] = [SurveyMessageCommandType::SurveyTopology]; - pub const VARIANTS_STR: [&'static str; 1] = ["SurveyTopology"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::SurveyTopology(_) => "SurveyTopology", - } - } - - #[must_use] - pub const fn discriminant(&self) -> SurveyMessageCommandType { - #[allow(clippy::match_same_arms)] - match self { - Self::SurveyTopology(_) => SurveyMessageCommandType::SurveyTopology, - } - } - - #[must_use] - pub const fn variants() -> [SurveyMessageCommandType; 1] { - Self::VARIANTS - } -} - -impl Name for SurveyResponseBody { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } -} - -impl Discriminant for SurveyResponseBody { - #[must_use] - fn discriminant(&self) -> SurveyMessageCommandType { - Self::discriminant(self) - } -} - -impl Variants for SurveyResponseBody { - fn variants() -> slice::Iter<'static, SurveyMessageCommandType> { - Self::VARIANTS.iter() - } + serde(rename_all = "snake_case") +)] +pub struct PathPaymentStrictSendOp { + pub send_asset: Asset, + pub send_amount: i64, + pub destination: MuxedAccount, + pub dest_asset: Asset, + pub dest_min: i64, + pub path: VecM, } -impl Union for SurveyResponseBody {} - -impl ReadXdr for SurveyResponseBody { +impl ReadXdr for PathPaymentStrictSendOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: SurveyMessageCommandType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - SurveyMessageCommandType::SurveyTopology => { - Self::SurveyTopology(TopologyResponseBody::read_xdr(r)?) - } - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + send_asset: Asset::read_xdr(r)?, + send_amount: i64::read_xdr(r)?, + destination: MuxedAccount::read_xdr(r)?, + dest_asset: Asset::read_xdr(r)?, + dest_min: i64::read_xdr(r)?, + path: VecM::::read_xdr(r)?, + }) }) } } -impl WriteXdr for SurveyResponseBody { +impl WriteXdr for PathPaymentStrictSendOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::SurveyTopology(v) => v.write_xdr(w)?, - }; + self.send_asset.write_xdr(w)?; + self.send_amount.write_xdr(w)?; + self.destination.write_xdr(w)?; + self.dest_asset.write_xdr(w)?; + self.dest_min.write_xdr(w)?; + self.path.write_xdr(w)?; Ok(()) }) } } -// TxAdvertVectorMaxSize is an XDR Const defines as: -// -// const TX_ADVERT_VECTOR_MAX_SIZE = 1000; +// ManageSellOfferOp is an XDR Struct defines as: // -pub const TX_ADVERT_VECTOR_MAX_SIZE: u64 = 1000; - -// TxAdvertVector is an XDR Typedef defines as: +// struct ManageSellOfferOp +// { +// Asset selling; +// Asset buying; +// int64 amount; // amount being sold. if set to 0, delete the offer +// Price price; // price of thing being sold in terms of what you are buying // -// typedef Hash TxAdvertVector; +// // 0=create a new offer, otherwise edit an existing offer +// int64 offerID; +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TxAdvertVector(pub VecM); - -impl From for VecM { - #[must_use] - fn from(x: TxAdvertVector) -> Self { - x.0 - } -} - -impl From> for TxAdvertVector { - #[must_use] - fn from(x: VecM) -> Self { - TxAdvertVector(x) - } -} - -impl AsRef> for TxAdvertVector { - #[must_use] - fn as_ref(&self) -> &VecM { - &self.0 - } +pub struct ManageSellOfferOp { + pub selling: Asset, + pub buying: Asset, + pub amount: i64, + pub price: Price, + pub offer_id: i64, } -impl ReadXdr for TxAdvertVector { +impl ReadXdr for ManageSellOfferOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = VecM::::read_xdr(r)?; - let v = TxAdvertVector(i); - Ok(v) + Ok(Self { + selling: Asset::read_xdr(r)?, + buying: Asset::read_xdr(r)?, + amount: i64::read_xdr(r)?, + price: Price::read_xdr(r)?, + offer_id: i64::read_xdr(r)?, + }) }) } } -impl WriteXdr for TxAdvertVector { +impl WriteXdr for ManageSellOfferOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} - -impl Deref for TxAdvertVector { - type Target = VecM; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From for Vec { - #[must_use] - fn from(x: TxAdvertVector) -> Self { - x.0 .0 - } -} - -impl TryFrom> for TxAdvertVector { - type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(TxAdvertVector(x.try_into()?)) - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for TxAdvertVector { - type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(TxAdvertVector(x.try_into()?)) - } -} - -impl AsRef> for TxAdvertVector { - #[must_use] - fn as_ref(&self) -> &Vec { - &self.0 .0 - } -} - -impl AsRef<[Hash]> for TxAdvertVector { - #[cfg(feature = "alloc")] - #[must_use] - fn as_ref(&self) -> &[Hash] { - &self.0 .0 - } - #[cfg(not(feature = "alloc"))] - #[must_use] - fn as_ref(&self) -> &[Hash] { - self.0 .0 + w.with_limited_depth(|w| { + self.selling.write_xdr(w)?; + self.buying.write_xdr(w)?; + self.amount.write_xdr(w)?; + self.price.write_xdr(w)?; + self.offer_id.write_xdr(w)?; + Ok(()) + }) } } -// FloodAdvert is an XDR Struct defines as: +// ManageBuyOfferOp is an XDR Struct defines as: // -// struct FloodAdvert +// struct ManageBuyOfferOp // { -// TxAdvertVector txHashes; +// Asset selling; +// Asset buying; +// int64 buyAmount; // amount being bought. if set to 0, delete the offer +// Price price; // price of thing being bought in terms of what you are +// // selling +// +// // 0=create a new offer, otherwise edit an existing offer +// int64 offerID; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -15179,144 +23978,114 @@ impl AsRef<[Hash]> for TxAdvertVector { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct FloodAdvert { - pub tx_hashes: TxAdvertVector, +pub struct ManageBuyOfferOp { + pub selling: Asset, + pub buying: Asset, + pub buy_amount: i64, + pub price: Price, + pub offer_id: i64, } -impl ReadXdr for FloodAdvert { +impl ReadXdr for ManageBuyOfferOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - tx_hashes: TxAdvertVector::read_xdr(r)?, + selling: Asset::read_xdr(r)?, + buying: Asset::read_xdr(r)?, + buy_amount: i64::read_xdr(r)?, + price: Price::read_xdr(r)?, + offer_id: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for FloodAdvert { +impl WriteXdr for ManageBuyOfferOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.tx_hashes.write_xdr(w)?; + self.selling.write_xdr(w)?; + self.buying.write_xdr(w)?; + self.buy_amount.write_xdr(w)?; + self.price.write_xdr(w)?; + self.offer_id.write_xdr(w)?; Ok(()) }) } } -// TxDemandVectorMaxSize is an XDR Const defines as: -// -// const TX_DEMAND_VECTOR_MAX_SIZE = 1000; -// -pub const TX_DEMAND_VECTOR_MAX_SIZE: u64 = 1000; - -// TxDemandVector is an XDR Typedef defines as: +// CreatePassiveSellOfferOp is an XDR Struct defines as: // -// typedef Hash TxDemandVector; +// struct CreatePassiveSellOfferOp +// { +// Asset selling; // A +// Asset buying; // B +// int64 amount; // amount taker gets +// Price price; // cost of A in terms of B +// }; // -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[derive(Default, Debug)] #[cfg_attr( all(feature = "serde", feature = "alloc"), derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct TxDemandVector(pub VecM); - -impl From for VecM { - #[must_use] - fn from(x: TxDemandVector) -> Self { - x.0 - } -} - -impl From> for TxDemandVector { - #[must_use] - fn from(x: VecM) -> Self { - TxDemandVector(x) - } -} - -impl AsRef> for TxDemandVector { - #[must_use] - fn as_ref(&self) -> &VecM { - &self.0 - } +pub struct CreatePassiveSellOfferOp { + pub selling: Asset, + pub buying: Asset, + pub amount: i64, + pub price: Price, } -impl ReadXdr for TxDemandVector { +impl ReadXdr for CreatePassiveSellOfferOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let i = VecM::::read_xdr(r)?; - let v = TxDemandVector(i); - Ok(v) + Ok(Self { + selling: Asset::read_xdr(r)?, + buying: Asset::read_xdr(r)?, + amount: i64::read_xdr(r)?, + price: Price::read_xdr(r)?, + }) }) } } -impl WriteXdr for TxDemandVector { +impl WriteXdr for CreatePassiveSellOfferOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| self.0.write_xdr(w)) - } -} - -impl Deref for TxDemandVector { - type Target = VecM; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From for Vec { - #[must_use] - fn from(x: TxDemandVector) -> Self { - x.0 .0 - } -} - -impl TryFrom> for TxDemandVector { - type Error = Error; - fn try_from(x: Vec) -> Result { - Ok(TxDemandVector(x.try_into()?)) - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&Vec> for TxDemandVector { - type Error = Error; - fn try_from(x: &Vec) -> Result { - Ok(TxDemandVector(x.try_into()?)) - } -} - -impl AsRef> for TxDemandVector { - #[must_use] - fn as_ref(&self) -> &Vec { - &self.0 .0 - } -} - -impl AsRef<[Hash]> for TxDemandVector { - #[cfg(feature = "alloc")] - #[must_use] - fn as_ref(&self) -> &[Hash] { - &self.0 .0 - } - #[cfg(not(feature = "alloc"))] - #[must_use] - fn as_ref(&self) -> &[Hash] { - self.0 .0 + w.with_limited_depth(|w| { + self.selling.write_xdr(w)?; + self.buying.write_xdr(w)?; + self.amount.write_xdr(w)?; + self.price.write_xdr(w)?; + Ok(()) + }) } } -// FloodDemand is an XDR Struct defines as: +// SetOptionsOp is an XDR Struct defines as: // -// struct FloodDemand +// struct SetOptionsOp // { -// TxDemandVector txHashes; +// AccountID* inflationDest; // sets the inflation destination +// +// uint32* clearFlags; // which flags to clear +// uint32* setFlags; // which flags to set +// +// // account threshold manipulation +// uint32* masterWeight; // weight of the master account +// uint32* lowThreshold; +// uint32* medThreshold; +// uint32* highThreshold; +// +// string32* homeDomain; // sets the home domain +// +// // Add, update or remove a signer for the account +// // signer is deleted if the weight is 0 +// Signer* signer; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -15326,84 +24095,75 @@ impl AsRef<[Hash]> for TxDemandVector { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct FloodDemand { - pub tx_hashes: TxDemandVector, +pub struct SetOptionsOp { + pub inflation_dest: Option, + pub clear_flags: Option, + pub set_flags: Option, + pub master_weight: Option, + pub low_threshold: Option, + pub med_threshold: Option, + pub high_threshold: Option, + pub home_domain: Option, + pub signer: Option, } -impl ReadXdr for FloodDemand { +impl ReadXdr for SetOptionsOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - tx_hashes: TxDemandVector::read_xdr(r)?, + inflation_dest: Option::::read_xdr(r)?, + clear_flags: Option::::read_xdr(r)?, + set_flags: Option::::read_xdr(r)?, + master_weight: Option::::read_xdr(r)?, + low_threshold: Option::::read_xdr(r)?, + med_threshold: Option::::read_xdr(r)?, + high_threshold: Option::::read_xdr(r)?, + home_domain: Option::::read_xdr(r)?, + signer: Option::::read_xdr(r)?, }) }) } } -impl WriteXdr for FloodDemand { +impl WriteXdr for SetOptionsOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.tx_hashes.write_xdr(w)?; + self.inflation_dest.write_xdr(w)?; + self.clear_flags.write_xdr(w)?; + self.set_flags.write_xdr(w)?; + self.master_weight.write_xdr(w)?; + self.low_threshold.write_xdr(w)?; + self.med_threshold.write_xdr(w)?; + self.high_threshold.write_xdr(w)?; + self.home_domain.write_xdr(w)?; + self.signer.write_xdr(w)?; Ok(()) }) } } -// StellarMessage is an XDR Union defines as: +// ChangeTrustAsset is an XDR Union defines as: // -// union StellarMessage switch (MessageType type) +// union ChangeTrustAsset switch (AssetType type) // { -// case ERROR_MSG: -// Error error; -// case HELLO: -// Hello hello; -// case AUTH: -// Auth auth; -// case DONT_HAVE: -// DontHave dontHave; -// case GET_PEERS: +// case ASSET_TYPE_NATIVE: // Not credit // void; -// case PEERS: -// PeerAddress peers<100>; -// -// case GET_TX_SET: -// uint256 txSetHash; -// case TX_SET: -// TransactionSet txSet; -// case GENERALIZED_TX_SET: -// GeneralizedTransactionSet generalizedTxSet; -// -// case TRANSACTION: -// TransactionEnvelope transaction; // -// case SURVEY_REQUEST: -// SignedSurveyRequestMessage signedSurveyRequestMessage; +// case ASSET_TYPE_CREDIT_ALPHANUM4: +// AlphaNum4 alphaNum4; // -// case SURVEY_RESPONSE: -// SignedSurveyResponseMessage signedSurveyResponseMessage; +// case ASSET_TYPE_CREDIT_ALPHANUM12: +// AlphaNum12 alphaNum12; // -// // SCP -// case GET_SCP_QUORUMSET: -// uint256 qSetHash; -// case SCP_QUORUMSET: -// SCPQuorumSet qSet; -// case SCP_MESSAGE: -// SCPEnvelope envelope; -// case GET_SCP_STATE: -// uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest -// case SEND_MORE: -// SendMore sendMoreMessage; +// case ASSET_TYPE_POOL_SHARE: +// LiquidityPoolParameters liquidityPool; // -// // Pull mode -// case FLOOD_ADVERT: -// FloodAdvert floodAdvert; -// case FLOOD_DEMAND: -// FloodDemand floodDemand; +// // add other asset types here in the future // }; // -// union with discriminant MessageType +// union with discriminant AssetType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -15412,183 +24172,83 @@ impl WriteXdr for FloodDemand { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum StellarMessage { - ErrorMsg(SError), - Hello(Hello), - Auth(Auth), - DontHave(DontHave), - GetPeers, - Peers(VecM), - GetTxSet(Uint256), - TxSet(TransactionSet), - GeneralizedTxSet(GeneralizedTransactionSet), - Transaction(TransactionEnvelope), - SurveyRequest(SignedSurveyRequestMessage), - SurveyResponse(SignedSurveyResponseMessage), - GetScpQuorumset(Uint256), - ScpQuorumset(ScpQuorumSet), - ScpMessage(ScpEnvelope), - GetScpState(u32), - SendMore(SendMore), - FloodAdvert(FloodAdvert), - FloodDemand(FloodDemand), -} - -impl StellarMessage { - pub const VARIANTS: [MessageType; 19] = [ - MessageType::ErrorMsg, - MessageType::Hello, - MessageType::Auth, - MessageType::DontHave, - MessageType::GetPeers, - MessageType::Peers, - MessageType::GetTxSet, - MessageType::TxSet, - MessageType::GeneralizedTxSet, - MessageType::Transaction, - MessageType::SurveyRequest, - MessageType::SurveyResponse, - MessageType::GetScpQuorumset, - MessageType::ScpQuorumset, - MessageType::ScpMessage, - MessageType::GetScpState, - MessageType::SendMore, - MessageType::FloodAdvert, - MessageType::FloodDemand, - ]; - pub const VARIANTS_STR: [&'static str; 19] = [ - "ErrorMsg", - "Hello", - "Auth", - "DontHave", - "GetPeers", - "Peers", - "GetTxSet", - "TxSet", - "GeneralizedTxSet", - "Transaction", - "SurveyRequest", - "SurveyResponse", - "GetScpQuorumset", - "ScpQuorumset", - "ScpMessage", - "GetScpState", - "SendMore", - "FloodAdvert", - "FloodDemand", - ]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::ErrorMsg(_) => "ErrorMsg", - Self::Hello(_) => "Hello", - Self::Auth(_) => "Auth", - Self::DontHave(_) => "DontHave", - Self::GetPeers => "GetPeers", - Self::Peers(_) => "Peers", - Self::GetTxSet(_) => "GetTxSet", - Self::TxSet(_) => "TxSet", - Self::GeneralizedTxSet(_) => "GeneralizedTxSet", - Self::Transaction(_) => "Transaction", - Self::SurveyRequest(_) => "SurveyRequest", - Self::SurveyResponse(_) => "SurveyResponse", - Self::GetScpQuorumset(_) => "GetScpQuorumset", - Self::ScpQuorumset(_) => "ScpQuorumset", - Self::ScpMessage(_) => "ScpMessage", - Self::GetScpState(_) => "GetScpState", - Self::SendMore(_) => "SendMore", - Self::FloodAdvert(_) => "FloodAdvert", - Self::FloodDemand(_) => "FloodDemand", +pub enum ChangeTrustAsset { + Native, + CreditAlphanum4(AlphaNum4), + CreditAlphanum12(AlphaNum12), + PoolShare(LiquidityPoolParameters), +} + +impl ChangeTrustAsset { + pub const VARIANTS: [AssetType; 4] = [ + AssetType::Native, + AssetType::CreditAlphanum4, + AssetType::CreditAlphanum12, + AssetType::PoolShare, + ]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Native", "CreditAlphanum4", "CreditAlphanum12", "PoolShare"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Native => "Native", + Self::CreditAlphanum4(_) => "CreditAlphanum4", + Self::CreditAlphanum12(_) => "CreditAlphanum12", + Self::PoolShare(_) => "PoolShare", } } #[must_use] - pub const fn discriminant(&self) -> MessageType { + pub const fn discriminant(&self) -> AssetType { #[allow(clippy::match_same_arms)] match self { - Self::ErrorMsg(_) => MessageType::ErrorMsg, - Self::Hello(_) => MessageType::Hello, - Self::Auth(_) => MessageType::Auth, - Self::DontHave(_) => MessageType::DontHave, - Self::GetPeers => MessageType::GetPeers, - Self::Peers(_) => MessageType::Peers, - Self::GetTxSet(_) => MessageType::GetTxSet, - Self::TxSet(_) => MessageType::TxSet, - Self::GeneralizedTxSet(_) => MessageType::GeneralizedTxSet, - Self::Transaction(_) => MessageType::Transaction, - Self::SurveyRequest(_) => MessageType::SurveyRequest, - Self::SurveyResponse(_) => MessageType::SurveyResponse, - Self::GetScpQuorumset(_) => MessageType::GetScpQuorumset, - Self::ScpQuorumset(_) => MessageType::ScpQuorumset, - Self::ScpMessage(_) => MessageType::ScpMessage, - Self::GetScpState(_) => MessageType::GetScpState, - Self::SendMore(_) => MessageType::SendMore, - Self::FloodAdvert(_) => MessageType::FloodAdvert, - Self::FloodDemand(_) => MessageType::FloodDemand, + Self::Native => AssetType::Native, + Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, + Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, + Self::PoolShare(_) => AssetType::PoolShare, } } #[must_use] - pub const fn variants() -> [MessageType; 19] { + pub const fn variants() -> [AssetType; 4] { Self::VARIANTS } } -impl Name for StellarMessage { +impl Name for ChangeTrustAsset { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for StellarMessage { +impl Discriminant for ChangeTrustAsset { #[must_use] - fn discriminant(&self) -> MessageType { + fn discriminant(&self) -> AssetType { Self::discriminant(self) } } -impl Variants for StellarMessage { - fn variants() -> slice::Iter<'static, MessageType> { +impl Variants for ChangeTrustAsset { + fn variants() -> slice::Iter<'static, AssetType> { Self::VARIANTS.iter() } } -impl Union for StellarMessage {} +impl Union for ChangeTrustAsset {} -impl ReadXdr for StellarMessage { +impl ReadXdr for ChangeTrustAsset { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: MessageType = ::read_xdr(r)?; + let dv: AssetType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - MessageType::ErrorMsg => Self::ErrorMsg(SError::read_xdr(r)?), - MessageType::Hello => Self::Hello(Hello::read_xdr(r)?), - MessageType::Auth => Self::Auth(Auth::read_xdr(r)?), - MessageType::DontHave => Self::DontHave(DontHave::read_xdr(r)?), - MessageType::GetPeers => Self::GetPeers, - MessageType::Peers => Self::Peers(VecM::::read_xdr(r)?), - MessageType::GetTxSet => Self::GetTxSet(Uint256::read_xdr(r)?), - MessageType::TxSet => Self::TxSet(TransactionSet::read_xdr(r)?), - MessageType::GeneralizedTxSet => { - Self::GeneralizedTxSet(GeneralizedTransactionSet::read_xdr(r)?) - } - MessageType::Transaction => Self::Transaction(TransactionEnvelope::read_xdr(r)?), - MessageType::SurveyRequest => { - Self::SurveyRequest(SignedSurveyRequestMessage::read_xdr(r)?) - } - MessageType::SurveyResponse => { - Self::SurveyResponse(SignedSurveyResponseMessage::read_xdr(r)?) - } - MessageType::GetScpQuorumset => Self::GetScpQuorumset(Uint256::read_xdr(r)?), - MessageType::ScpQuorumset => Self::ScpQuorumset(ScpQuorumSet::read_xdr(r)?), - MessageType::ScpMessage => Self::ScpMessage(ScpEnvelope::read_xdr(r)?), - MessageType::GetScpState => Self::GetScpState(u32::read_xdr(r)?), - MessageType::SendMore => Self::SendMore(SendMore::read_xdr(r)?), - MessageType::FloodAdvert => Self::FloodAdvert(FloodAdvert::read_xdr(r)?), - MessageType::FloodDemand => Self::FloodDemand(FloodDemand::read_xdr(r)?), + AssetType::Native => Self::Native, + AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AlphaNum4::read_xdr(r)?), + AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AlphaNum12::read_xdr(r)?), + AssetType::PoolShare => Self::PoolShare(LiquidityPoolParameters::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -15597,46 +24257,32 @@ impl ReadXdr for StellarMessage { } } -impl WriteXdr for StellarMessage { +impl WriteXdr for ChangeTrustAsset { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::ErrorMsg(v) => v.write_xdr(w)?, - Self::Hello(v) => v.write_xdr(w)?, - Self::Auth(v) => v.write_xdr(w)?, - Self::DontHave(v) => v.write_xdr(w)?, - Self::GetPeers => ().write_xdr(w)?, - Self::Peers(v) => v.write_xdr(w)?, - Self::GetTxSet(v) => v.write_xdr(w)?, - Self::TxSet(v) => v.write_xdr(w)?, - Self::GeneralizedTxSet(v) => v.write_xdr(w)?, - Self::Transaction(v) => v.write_xdr(w)?, - Self::SurveyRequest(v) => v.write_xdr(w)?, - Self::SurveyResponse(v) => v.write_xdr(w)?, - Self::GetScpQuorumset(v) => v.write_xdr(w)?, - Self::ScpQuorumset(v) => v.write_xdr(w)?, - Self::ScpMessage(v) => v.write_xdr(w)?, - Self::GetScpState(v) => v.write_xdr(w)?, - Self::SendMore(v) => v.write_xdr(w)?, - Self::FloodAdvert(v) => v.write_xdr(w)?, - Self::FloodDemand(v) => v.write_xdr(w)?, + Self::Native => ().write_xdr(w)?, + Self::CreditAlphanum4(v) => v.write_xdr(w)?, + Self::CreditAlphanum12(v) => v.write_xdr(w)?, + Self::PoolShare(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// AuthenticatedMessageV0 is an XDR NestedStruct defines as: +// ChangeTrustOp is an XDR Struct defines as: // -// struct -// { -// uint64 sequence; -// StellarMessage message; -// HmacSha256Mac mac; -// } +// struct ChangeTrustOp +// { +// ChangeTrustAsset line; +// +// // if limit is set to 0, deletes the trust line +// int64 limit; +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -15645,51 +24291,45 @@ impl WriteXdr for StellarMessage { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct AuthenticatedMessageV0 { - pub sequence: u64, - pub message: StellarMessage, - pub mac: HmacSha256Mac, +pub struct ChangeTrustOp { + pub line: ChangeTrustAsset, + pub limit: i64, } -impl ReadXdr for AuthenticatedMessageV0 { +impl ReadXdr for ChangeTrustOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - sequence: u64::read_xdr(r)?, - message: StellarMessage::read_xdr(r)?, - mac: HmacSha256Mac::read_xdr(r)?, + line: ChangeTrustAsset::read_xdr(r)?, + limit: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for AuthenticatedMessageV0 { +impl WriteXdr for ChangeTrustOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.sequence.write_xdr(w)?; - self.message.write_xdr(w)?; - self.mac.write_xdr(w)?; + self.line.write_xdr(w)?; + self.limit.write_xdr(w)?; Ok(()) }) } } -// AuthenticatedMessage is an XDR Union defines as: +// AllowTrustOp is an XDR Struct defines as: // -// union AuthenticatedMessage switch (uint32 v) +// struct AllowTrustOp // { -// case 0: -// struct -// { -// uint64 sequence; -// StellarMessage message; -// HmacSha256Mac mac; -// } v0; +// AccountID trustor; +// AssetCode asset; +// +// // One of 0, AUTHORIZED_FLAG, or AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG +// uint32 authorize; // }; // -// union with discriminant u32 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -15697,97 +24337,87 @@ impl WriteXdr for AuthenticatedMessageV0 { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum AuthenticatedMessage { - V0(AuthenticatedMessageV0), -} - -impl AuthenticatedMessage { - pub const VARIANTS: [u32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::V0(_) => "V0", - } - } - - #[must_use] - pub const fn discriminant(&self) -> u32 { - #[allow(clippy::match_same_arms)] - match self { - Self::V0(_) => 0, - } - } - - #[must_use] - pub const fn variants() -> [u32; 1] { - Self::VARIANTS - } +pub struct AllowTrustOp { + pub trustor: AccountId, + pub asset: AssetCode, + pub authorize: u32, } -impl Name for AuthenticatedMessage { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) +impl ReadXdr for AllowTrustOp { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + trustor: AccountId::read_xdr(r)?, + asset: AssetCode::read_xdr(r)?, + authorize: u32::read_xdr(r)?, + }) + }) } } -impl Discriminant for AuthenticatedMessage { - #[must_use] - fn discriminant(&self) -> u32 { - Self::discriminant(self) +impl WriteXdr for AllowTrustOp { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.trustor.write_xdr(w)?; + self.asset.write_xdr(w)?; + self.authorize.write_xdr(w)?; + Ok(()) + }) } } -impl Variants for AuthenticatedMessage { - fn variants() -> slice::Iter<'static, u32> { - Self::VARIANTS.iter() - } +// ManageDataOp is an XDR Struct defines as: +// +// struct ManageDataOp +// { +// string64 dataName; +// DataValue* dataValue; // set to null to clear +// }; +// +#[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 ManageDataOp { + pub data_name: String64, + pub data_value: Option, } -impl Union for AuthenticatedMessage {} - -impl ReadXdr for AuthenticatedMessage { +impl ReadXdr for ManageDataOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: u32 = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - 0 => Self::V0(AuthenticatedMessageV0::read_xdr(r)?), - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + data_name: String64::read_xdr(r)?, + data_value: Option::::read_xdr(r)?, + }) }) } } -impl WriteXdr for AuthenticatedMessage { +impl WriteXdr for ManageDataOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::V0(v) => v.write_xdr(w)?, - }; + self.data_name.write_xdr(w)?; + self.data_value.write_xdr(w)?; Ok(()) }) } } -// LiquidityPoolParameters is an XDR Union defines as: +// BumpSequenceOp is an XDR Struct defines as: // -// union LiquidityPoolParameters switch (LiquidityPoolType type) +// struct BumpSequenceOp // { -// case LIQUIDITY_POOL_CONSTANT_PRODUCT: -// LiquidityPoolConstantProductParameters constantProduct; +// SequenceNumber bumpTo; // }; // -// union with discriminant LiquidityPoolType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -15795,101 +24425,123 @@ impl WriteXdr for AuthenticatedMessage { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -#[allow(clippy::large_enum_variant)] -pub enum LiquidityPoolParameters { - LiquidityPoolConstantProduct(LiquidityPoolConstantProductParameters), +pub struct BumpSequenceOp { + pub bump_to: SequenceNumber, } -impl LiquidityPoolParameters { - pub const VARIANTS: [LiquidityPoolType; 1] = [LiquidityPoolType::LiquidityPoolConstantProduct]; - pub const VARIANTS_STR: [&'static str; 1] = ["LiquidityPoolConstantProduct"]; - - #[must_use] - pub const fn name(&self) -> &'static str { - match self { - Self::LiquidityPoolConstantProduct(_) => "LiquidityPoolConstantProduct", - } - } - - #[must_use] - pub const fn discriminant(&self) -> LiquidityPoolType { - #[allow(clippy::match_same_arms)] - match self { - Self::LiquidityPoolConstantProduct(_) => { - LiquidityPoolType::LiquidityPoolConstantProduct - } - } +impl ReadXdr for BumpSequenceOp { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + bump_to: SequenceNumber::read_xdr(r)?, + }) + }) } +} - #[must_use] - pub const fn variants() -> [LiquidityPoolType; 1] { - Self::VARIANTS +impl WriteXdr for BumpSequenceOp { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.bump_to.write_xdr(w)?; + Ok(()) + }) } } -impl Name for LiquidityPoolParameters { - #[must_use] - fn name(&self) -> &'static str { - Self::name(self) - } +// CreateClaimableBalanceOp is an XDR Struct defines as: +// +// struct CreateClaimableBalanceOp +// { +// Asset asset; +// int64 amount; +// Claimant claimants<10>; +// }; +// +#[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 CreateClaimableBalanceOp { + pub asset: Asset, + pub amount: i64, + pub claimants: VecM, } -impl Discriminant for LiquidityPoolParameters { - #[must_use] - fn discriminant(&self) -> LiquidityPoolType { - Self::discriminant(self) +impl ReadXdr for CreateClaimableBalanceOp { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + asset: Asset::read_xdr(r)?, + amount: i64::read_xdr(r)?, + claimants: VecM::::read_xdr(r)?, + }) + }) } } -impl Variants for LiquidityPoolParameters { - fn variants() -> slice::Iter<'static, LiquidityPoolType> { - Self::VARIANTS.iter() +impl WriteXdr for CreateClaimableBalanceOp { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.asset.write_xdr(w)?; + self.amount.write_xdr(w)?; + self.claimants.write_xdr(w)?; + Ok(()) + }) } } -impl Union for LiquidityPoolParameters {} +// ClaimClaimableBalanceOp is an XDR Struct defines as: +// +// struct ClaimClaimableBalanceOp +// { +// ClaimableBalanceID balanceID; +// }; +// +#[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 ClaimClaimableBalanceOp { + pub balance_id: ClaimableBalanceId, +} -impl ReadXdr for LiquidityPoolParameters { +impl ReadXdr for ClaimClaimableBalanceOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LiquidityPoolType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - LiquidityPoolType::LiquidityPoolConstantProduct => { - Self::LiquidityPoolConstantProduct( - LiquidityPoolConstantProductParameters::read_xdr(r)?, - ) - } - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(v) + Ok(Self { + balance_id: ClaimableBalanceId::read_xdr(r)?, + }) }) } } -impl WriteXdr for LiquidityPoolParameters { +impl WriteXdr for ClaimClaimableBalanceOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::LiquidityPoolConstantProduct(v) => v.write_xdr(w)?, - }; + self.balance_id.write_xdr(w)?; Ok(()) }) } } -// MuxedAccountMed25519 is an XDR NestedStruct defines as: +// BeginSponsoringFutureReservesOp is an XDR Struct defines as: // -// struct -// { -// uint64 id; -// uint256 ed25519; -// } +// struct BeginSponsoringFutureReservesOp +// { +// AccountID sponsoredID; +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -15898,152 +24550,144 @@ impl WriteXdr for LiquidityPoolParameters { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct MuxedAccountMed25519 { - pub id: u64, - pub ed25519: Uint256, +pub struct BeginSponsoringFutureReservesOp { + pub sponsored_id: AccountId, } -impl ReadXdr for MuxedAccountMed25519 { +impl ReadXdr for BeginSponsoringFutureReservesOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - id: u64::read_xdr(r)?, - ed25519: Uint256::read_xdr(r)?, + sponsored_id: AccountId::read_xdr(r)?, }) }) } } -impl WriteXdr for MuxedAccountMed25519 { +impl WriteXdr for BeginSponsoringFutureReservesOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.id.write_xdr(w)?; - self.ed25519.write_xdr(w)?; + self.sponsored_id.write_xdr(w)?; Ok(()) }) } } -// MuxedAccount is an XDR Union defines as: +// RevokeSponsorshipType is an XDR Enum defines as: // -// union MuxedAccount switch (CryptoKeyType type) +// enum RevokeSponsorshipType // { -// case KEY_TYPE_ED25519: -// uint256 ed25519; -// case KEY_TYPE_MUXED_ED25519: -// struct -// { -// uint64 id; -// uint256 ed25519; -// } med25519; +// REVOKE_SPONSORSHIP_LEDGER_ENTRY = 0, +// REVOKE_SPONSORSHIP_SIGNER = 1 // }; // -// union with discriminant CryptoKeyType -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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") )] -#[allow(clippy::large_enum_variant)] -pub enum MuxedAccount { - Ed25519(Uint256), - MuxedEd25519(MuxedAccountMed25519), +#[repr(i32)] +pub enum RevokeSponsorshipType { + LedgerEntry = 0, + Signer = 1, } -impl MuxedAccount { - pub const VARIANTS: [CryptoKeyType; 2] = [CryptoKeyType::Ed25519, CryptoKeyType::MuxedEd25519]; - pub const VARIANTS_STR: [&'static str; 2] = ["Ed25519", "MuxedEd25519"]; +impl RevokeSponsorshipType { + pub const VARIANTS: [RevokeSponsorshipType; 2] = [ + RevokeSponsorshipType::LedgerEntry, + RevokeSponsorshipType::Signer, + ]; + pub const VARIANTS_STR: [&'static str; 2] = ["LedgerEntry", "Signer"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Ed25519(_) => "Ed25519", - Self::MuxedEd25519(_) => "MuxedEd25519", - } - } - - #[must_use] - pub const fn discriminant(&self) -> CryptoKeyType { - #[allow(clippy::match_same_arms)] - match self { - Self::Ed25519(_) => CryptoKeyType::Ed25519, - Self::MuxedEd25519(_) => CryptoKeyType::MuxedEd25519, + Self::LedgerEntry => "LedgerEntry", + Self::Signer => "Signer", } } #[must_use] - pub const fn variants() -> [CryptoKeyType; 2] { + pub const fn variants() -> [RevokeSponsorshipType; 2] { Self::VARIANTS } } -impl Name for MuxedAccount { +impl Name for RevokeSponsorshipType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for MuxedAccount { - #[must_use] - fn discriminant(&self) -> CryptoKeyType { - Self::discriminant(self) +impl Variants for RevokeSponsorshipType { + fn variants() -> slice::Iter<'static, RevokeSponsorshipType> { + Self::VARIANTS.iter() + } +} + +impl Enum for RevokeSponsorshipType {} + +impl fmt::Display for RevokeSponsorshipType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) } } -impl Variants for MuxedAccount { - fn variants() -> slice::Iter<'static, CryptoKeyType> { - Self::VARIANTS.iter() +impl TryFrom for RevokeSponsorshipType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => RevokeSponsorshipType::LedgerEntry, + 1 => RevokeSponsorshipType::Signer, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -impl Union for MuxedAccount {} +impl From for i32 { + #[must_use] + fn from(e: RevokeSponsorshipType) -> Self { + e as Self + } +} -impl ReadXdr for MuxedAccount { +impl ReadXdr for RevokeSponsorshipType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: CryptoKeyType = ::read_xdr(r)?; - #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] - let v = match dv { - CryptoKeyType::Ed25519 => Self::Ed25519(Uint256::read_xdr(r)?), - CryptoKeyType::MuxedEd25519 => { - Self::MuxedEd25519(MuxedAccountMed25519::read_xdr(r)?) - } - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; Ok(v) }) } } -impl WriteXdr for MuxedAccount { +impl WriteXdr for RevokeSponsorshipType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::Ed25519(v) => v.write_xdr(w)?, - Self::MuxedEd25519(v) => v.write_xdr(w)?, - }; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// DecoratedSignature is an XDR Struct defines as: +// RevokeSponsorshipOpSigner is an XDR NestedStruct defines as: // -// struct DecoratedSignature -// { -// SignatureHint hint; // last 4 bytes of the public key, used as a hint -// Signature signature; // actual signature -// }; +// struct +// { +// AccountID accountID; +// SignerKey signerKey; +// } // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -16052,281 +24696,155 @@ impl WriteXdr for MuxedAccount { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct DecoratedSignature { - pub hint: SignatureHint, - pub signature: Signature, +pub struct RevokeSponsorshipOpSigner { + pub account_id: AccountId, + pub signer_key: SignerKey, } -impl ReadXdr for DecoratedSignature { +impl ReadXdr for RevokeSponsorshipOpSigner { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - hint: SignatureHint::read_xdr(r)?, - signature: Signature::read_xdr(r)?, + account_id: AccountId::read_xdr(r)?, + signer_key: SignerKey::read_xdr(r)?, }) }) } } -impl WriteXdr for DecoratedSignature { +impl WriteXdr for RevokeSponsorshipOpSigner { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.hint.write_xdr(w)?; - self.signature.write_xdr(w)?; + self.account_id.write_xdr(w)?; + self.signer_key.write_xdr(w)?; Ok(()) }) } } -// OperationType is an XDR Enum defines as: +// RevokeSponsorshipOp is an XDR Union defines as: // -// enum OperationType +// union RevokeSponsorshipOp switch (RevokeSponsorshipType type) // { -// CREATE_ACCOUNT = 0, -// PAYMENT = 1, -// PATH_PAYMENT_STRICT_RECEIVE = 2, -// MANAGE_SELL_OFFER = 3, -// CREATE_PASSIVE_SELL_OFFER = 4, -// SET_OPTIONS = 5, -// CHANGE_TRUST = 6, -// ALLOW_TRUST = 7, -// ACCOUNT_MERGE = 8, -// INFLATION = 9, -// MANAGE_DATA = 10, -// BUMP_SEQUENCE = 11, -// MANAGE_BUY_OFFER = 12, -// PATH_PAYMENT_STRICT_SEND = 13, -// CREATE_CLAIMABLE_BALANCE = 14, -// CLAIM_CLAIMABLE_BALANCE = 15, -// BEGIN_SPONSORING_FUTURE_RESERVES = 16, -// END_SPONSORING_FUTURE_RESERVES = 17, -// REVOKE_SPONSORSHIP = 18, -// CLAWBACK = 19, -// CLAWBACK_CLAIMABLE_BALANCE = 20, -// SET_TRUST_LINE_FLAGS = 21, -// LIQUIDITY_POOL_DEPOSIT = 22, -// LIQUIDITY_POOL_WITHDRAW = 23 +// case REVOKE_SPONSORSHIP_LEDGER_ENTRY: +// LedgerKey ledgerKey; +// case REVOKE_SPONSORSHIP_SIGNER: +// struct +// { +// AccountID accountID; +// SignerKey signerKey; +// } signer; // }; // -// enum -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// union with discriminant RevokeSponsorshipType +#[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") )] -#[repr(i32)] -pub enum OperationType { - CreateAccount = 0, - Payment = 1, - PathPaymentStrictReceive = 2, - ManageSellOffer = 3, - CreatePassiveSellOffer = 4, - SetOptions = 5, - ChangeTrust = 6, - AllowTrust = 7, - AccountMerge = 8, - Inflation = 9, - ManageData = 10, - BumpSequence = 11, - ManageBuyOffer = 12, - PathPaymentStrictSend = 13, - CreateClaimableBalance = 14, - ClaimClaimableBalance = 15, - BeginSponsoringFutureReserves = 16, - EndSponsoringFutureReserves = 17, - RevokeSponsorship = 18, - Clawback = 19, - ClawbackClaimableBalance = 20, - SetTrustLineFlags = 21, - LiquidityPoolDeposit = 22, - LiquidityPoolWithdraw = 23, +#[allow(clippy::large_enum_variant)] +pub enum RevokeSponsorshipOp { + LedgerEntry(LedgerKey), + Signer(RevokeSponsorshipOpSigner), } -impl OperationType { - pub const VARIANTS: [OperationType; 24] = [ - OperationType::CreateAccount, - OperationType::Payment, - OperationType::PathPaymentStrictReceive, - OperationType::ManageSellOffer, - OperationType::CreatePassiveSellOffer, - OperationType::SetOptions, - OperationType::ChangeTrust, - OperationType::AllowTrust, - OperationType::AccountMerge, - OperationType::Inflation, - OperationType::ManageData, - OperationType::BumpSequence, - OperationType::ManageBuyOffer, - OperationType::PathPaymentStrictSend, - OperationType::CreateClaimableBalance, - OperationType::ClaimClaimableBalance, - OperationType::BeginSponsoringFutureReserves, - OperationType::EndSponsoringFutureReserves, - OperationType::RevokeSponsorship, - OperationType::Clawback, - OperationType::ClawbackClaimableBalance, - OperationType::SetTrustLineFlags, - OperationType::LiquidityPoolDeposit, - OperationType::LiquidityPoolWithdraw, - ]; - pub const VARIANTS_STR: [&'static str; 24] = [ - "CreateAccount", - "Payment", - "PathPaymentStrictReceive", - "ManageSellOffer", - "CreatePassiveSellOffer", - "SetOptions", - "ChangeTrust", - "AllowTrust", - "AccountMerge", - "Inflation", - "ManageData", - "BumpSequence", - "ManageBuyOffer", - "PathPaymentStrictSend", - "CreateClaimableBalance", - "ClaimClaimableBalance", - "BeginSponsoringFutureReserves", - "EndSponsoringFutureReserves", - "RevokeSponsorship", - "Clawback", - "ClawbackClaimableBalance", - "SetTrustLineFlags", - "LiquidityPoolDeposit", - "LiquidityPoolWithdraw", +impl RevokeSponsorshipOp { + pub const VARIANTS: [RevokeSponsorshipType; 2] = [ + RevokeSponsorshipType::LedgerEntry, + RevokeSponsorshipType::Signer, ]; + pub const VARIANTS_STR: [&'static str; 2] = ["LedgerEntry", "Signer"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::CreateAccount => "CreateAccount", - Self::Payment => "Payment", - Self::PathPaymentStrictReceive => "PathPaymentStrictReceive", - Self::ManageSellOffer => "ManageSellOffer", - Self::CreatePassiveSellOffer => "CreatePassiveSellOffer", - Self::SetOptions => "SetOptions", - Self::ChangeTrust => "ChangeTrust", - Self::AllowTrust => "AllowTrust", - Self::AccountMerge => "AccountMerge", - Self::Inflation => "Inflation", - Self::ManageData => "ManageData", - Self::BumpSequence => "BumpSequence", - Self::ManageBuyOffer => "ManageBuyOffer", - Self::PathPaymentStrictSend => "PathPaymentStrictSend", - Self::CreateClaimableBalance => "CreateClaimableBalance", - Self::ClaimClaimableBalance => "ClaimClaimableBalance", - Self::BeginSponsoringFutureReserves => "BeginSponsoringFutureReserves", - Self::EndSponsoringFutureReserves => "EndSponsoringFutureReserves", - Self::RevokeSponsorship => "RevokeSponsorship", - Self::Clawback => "Clawback", - Self::ClawbackClaimableBalance => "ClawbackClaimableBalance", - Self::SetTrustLineFlags => "SetTrustLineFlags", - Self::LiquidityPoolDeposit => "LiquidityPoolDeposit", - Self::LiquidityPoolWithdraw => "LiquidityPoolWithdraw", + Self::LedgerEntry(_) => "LedgerEntry", + Self::Signer(_) => "Signer", + } + } + + #[must_use] + pub const fn discriminant(&self) -> RevokeSponsorshipType { + #[allow(clippy::match_same_arms)] + match self { + Self::LedgerEntry(_) => RevokeSponsorshipType::LedgerEntry, + Self::Signer(_) => RevokeSponsorshipType::Signer, } } #[must_use] - pub const fn variants() -> [OperationType; 24] { + pub const fn variants() -> [RevokeSponsorshipType; 2] { Self::VARIANTS } } -impl Name for OperationType { +impl Name for RevokeSponsorshipOp { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for OperationType { - fn variants() -> slice::Iter<'static, OperationType> { - Self::VARIANTS.iter() - } -} - -impl Enum for OperationType {} - -impl fmt::Display for OperationType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Discriminant for RevokeSponsorshipOp { + #[must_use] + fn discriminant(&self) -> RevokeSponsorshipType { + Self::discriminant(self) } } -impl TryFrom for OperationType { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => OperationType::CreateAccount, - 1 => OperationType::Payment, - 2 => OperationType::PathPaymentStrictReceive, - 3 => OperationType::ManageSellOffer, - 4 => OperationType::CreatePassiveSellOffer, - 5 => OperationType::SetOptions, - 6 => OperationType::ChangeTrust, - 7 => OperationType::AllowTrust, - 8 => OperationType::AccountMerge, - 9 => OperationType::Inflation, - 10 => OperationType::ManageData, - 11 => OperationType::BumpSequence, - 12 => OperationType::ManageBuyOffer, - 13 => OperationType::PathPaymentStrictSend, - 14 => OperationType::CreateClaimableBalance, - 15 => OperationType::ClaimClaimableBalance, - 16 => OperationType::BeginSponsoringFutureReserves, - 17 => OperationType::EndSponsoringFutureReserves, - 18 => OperationType::RevokeSponsorship, - 19 => OperationType::Clawback, - 20 => OperationType::ClawbackClaimableBalance, - 21 => OperationType::SetTrustLineFlags, - 22 => OperationType::LiquidityPoolDeposit, - 23 => OperationType::LiquidityPoolWithdraw, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl Variants for RevokeSponsorshipOp { + fn variants() -> slice::Iter<'static, RevokeSponsorshipType> { + Self::VARIANTS.iter() } } -impl From for i32 { - #[must_use] - fn from(e: OperationType) -> Self { - e as Self - } -} +impl Union for RevokeSponsorshipOp {} -impl ReadXdr for OperationType { +impl ReadXdr for RevokeSponsorshipOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; + let dv: RevokeSponsorshipType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + RevokeSponsorshipType::LedgerEntry => Self::LedgerEntry(LedgerKey::read_xdr(r)?), + RevokeSponsorshipType::Signer => { + Self::Signer(RevokeSponsorshipOpSigner::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for OperationType { +impl WriteXdr for RevokeSponsorshipOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::LedgerEntry(v) => v.write_xdr(w)?, + Self::Signer(v) => v.write_xdr(w)?, + }; + Ok(()) }) } } -// CreateAccountOp is an XDR Struct defines as: +// ClawbackOp is an XDR Struct defines as: // -// struct CreateAccountOp +// struct ClawbackOp // { -// AccountID destination; // account to create -// int64 startingBalance; // amount they end up with +// Asset asset; +// MuxedAccount from; +// int64 amount; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -16336,41 +24854,42 @@ impl WriteXdr for OperationType { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct CreateAccountOp { - pub destination: AccountId, - pub starting_balance: i64, +pub struct ClawbackOp { + pub asset: Asset, + pub from: MuxedAccount, + pub amount: i64, } -impl ReadXdr for CreateAccountOp { +impl ReadXdr for ClawbackOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - destination: AccountId::read_xdr(r)?, - starting_balance: i64::read_xdr(r)?, + asset: Asset::read_xdr(r)?, + from: MuxedAccount::read_xdr(r)?, + amount: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for CreateAccountOp { +impl WriteXdr for ClawbackOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.destination.write_xdr(w)?; - self.starting_balance.write_xdr(w)?; + self.asset.write_xdr(w)?; + self.from.write_xdr(w)?; + self.amount.write_xdr(w)?; Ok(()) }) } } -// PaymentOp is an XDR Struct defines as: +// ClawbackClaimableBalanceOp is an XDR Struct defines as: // -// struct PaymentOp +// struct ClawbackClaimableBalanceOp // { -// MuxedAccount destination; // recipient of the payment -// Asset asset; // what they end up with -// int64 amount; // amount they end up with +// ClaimableBalanceID balanceID; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -16380,51 +24899,40 @@ impl WriteXdr for CreateAccountOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PaymentOp { - pub destination: MuxedAccount, - pub asset: Asset, - pub amount: i64, +pub struct ClawbackClaimableBalanceOp { + pub balance_id: ClaimableBalanceId, } -impl ReadXdr for PaymentOp { +impl ReadXdr for ClawbackClaimableBalanceOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - destination: MuxedAccount::read_xdr(r)?, - asset: Asset::read_xdr(r)?, - amount: i64::read_xdr(r)?, + balance_id: ClaimableBalanceId::read_xdr(r)?, }) }) } } -impl WriteXdr for PaymentOp { +impl WriteXdr for ClawbackClaimableBalanceOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.destination.write_xdr(w)?; - self.asset.write_xdr(w)?; - self.amount.write_xdr(w)?; + self.balance_id.write_xdr(w)?; Ok(()) }) } } -// PathPaymentStrictReceiveOp is an XDR Struct defines as: +// SetTrustLineFlagsOp is an XDR Struct defines as: // -// struct PathPaymentStrictReceiveOp +// struct SetTrustLineFlagsOp // { -// Asset sendAsset; // asset we pay with -// int64 sendMax; // the maximum amount of sendAsset to -// // send (excluding fees). -// // The operation will fail if can't be met -// -// MuxedAccount destination; // recipient of the payment -// Asset destAsset; // what they end up with -// int64 destAmount; // amount they end up with +// AccountID trustor; +// Asset asset; // -// Asset path<5>; // additional hops it must go through to get there +// uint32 clearFlags; // which flags to clear +// uint32 setFlags; // which flags to set // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -16434,60 +24942,55 @@ impl WriteXdr for PaymentOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PathPaymentStrictReceiveOp { - pub send_asset: Asset, - pub send_max: i64, - pub destination: MuxedAccount, - pub dest_asset: Asset, - pub dest_amount: i64, - pub path: VecM, +pub struct SetTrustLineFlagsOp { + pub trustor: AccountId, + pub asset: Asset, + pub clear_flags: u32, + pub set_flags: u32, } -impl ReadXdr for PathPaymentStrictReceiveOp { +impl ReadXdr for SetTrustLineFlagsOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - send_asset: Asset::read_xdr(r)?, - send_max: i64::read_xdr(r)?, - destination: MuxedAccount::read_xdr(r)?, - dest_asset: Asset::read_xdr(r)?, - dest_amount: i64::read_xdr(r)?, - path: VecM::::read_xdr(r)?, + trustor: AccountId::read_xdr(r)?, + asset: Asset::read_xdr(r)?, + clear_flags: u32::read_xdr(r)?, + set_flags: u32::read_xdr(r)?, }) }) } } -impl WriteXdr for PathPaymentStrictReceiveOp { +impl WriteXdr for SetTrustLineFlagsOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.send_asset.write_xdr(w)?; - self.send_max.write_xdr(w)?; - self.destination.write_xdr(w)?; - self.dest_asset.write_xdr(w)?; - self.dest_amount.write_xdr(w)?; - self.path.write_xdr(w)?; + self.trustor.write_xdr(w)?; + self.asset.write_xdr(w)?; + self.clear_flags.write_xdr(w)?; + self.set_flags.write_xdr(w)?; Ok(()) }) } } -// PathPaymentStrictSendOp is an XDR Struct defines as: +// LiquidityPoolFeeV18 is an XDR Const defines as: // -// struct PathPaymentStrictSendOp -// { -// Asset sendAsset; // asset we pay with -// int64 sendAmount; // amount of sendAsset to send (excluding fees) +// const LIQUIDITY_POOL_FEE_V18 = 30; // -// MuxedAccount destination; // recipient of the payment -// Asset destAsset; // what they end up with -// int64 destMin; // the minimum amount of dest asset to -// // be received -// // The operation will fail if it can't be met +pub const LIQUIDITY_POOL_FEE_V18: u64 = 30; + +// LiquidityPoolDepositOp is an XDR Struct defines as: // -// Asset path<5>; // additional hops it must go through to get there +// struct LiquidityPoolDepositOp +// { +// PoolID liquidityPoolID; +// int64 maxAmountA; // maximum amount of first asset to deposit +// int64 maxAmountB; // maximum amount of second asset to deposit +// Price minPrice; // minimum depositA/depositB +// Price maxPrice; // maximum depositA/depositB // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -16497,57 +25000,51 @@ impl WriteXdr for PathPaymentStrictReceiveOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PathPaymentStrictSendOp { - pub send_asset: Asset, - pub send_amount: i64, - pub destination: MuxedAccount, - pub dest_asset: Asset, - pub dest_min: i64, - pub path: VecM, +pub struct LiquidityPoolDepositOp { + pub liquidity_pool_id: PoolId, + pub max_amount_a: i64, + pub max_amount_b: i64, + pub min_price: Price, + pub max_price: Price, } -impl ReadXdr for PathPaymentStrictSendOp { +impl ReadXdr for LiquidityPoolDepositOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - send_asset: Asset::read_xdr(r)?, - send_amount: i64::read_xdr(r)?, - destination: MuxedAccount::read_xdr(r)?, - dest_asset: Asset::read_xdr(r)?, - dest_min: i64::read_xdr(r)?, - path: VecM::::read_xdr(r)?, + liquidity_pool_id: PoolId::read_xdr(r)?, + max_amount_a: i64::read_xdr(r)?, + max_amount_b: i64::read_xdr(r)?, + min_price: Price::read_xdr(r)?, + max_price: Price::read_xdr(r)?, }) }) } } -impl WriteXdr for PathPaymentStrictSendOp { +impl WriteXdr for LiquidityPoolDepositOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.send_asset.write_xdr(w)?; - self.send_amount.write_xdr(w)?; - self.destination.write_xdr(w)?; - self.dest_asset.write_xdr(w)?; - self.dest_min.write_xdr(w)?; - self.path.write_xdr(w)?; + self.liquidity_pool_id.write_xdr(w)?; + self.max_amount_a.write_xdr(w)?; + self.max_amount_b.write_xdr(w)?; + self.min_price.write_xdr(w)?; + self.max_price.write_xdr(w)?; Ok(()) }) } } -// ManageSellOfferOp is an XDR Struct defines as: +// LiquidityPoolWithdrawOp is an XDR Struct defines as: // -// struct ManageSellOfferOp +// struct LiquidityPoolWithdrawOp // { -// Asset selling; -// Asset buying; -// int64 amount; // amount being sold. if set to 0, delete the offer -// Price price; // price of thing being sold in terms of what you are buying -// -// // 0=create a new offer, otherwise edit an existing offer -// int64 offerID; +// PoolID liquidityPoolID; +// int64 amount; // amount of pool shares to withdraw +// int64 minAmountA; // minimum amount of first asset to withdraw +// int64 minAmountB; // minimum amount of second asset to withdraw // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -16557,173 +25054,265 @@ impl WriteXdr for PathPaymentStrictSendOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ManageSellOfferOp { - pub selling: Asset, - pub buying: Asset, +pub struct LiquidityPoolWithdrawOp { + pub liquidity_pool_id: PoolId, pub amount: i64, - pub price: Price, - pub offer_id: i64, + pub min_amount_a: i64, + pub min_amount_b: i64, } -impl ReadXdr for ManageSellOfferOp { +impl ReadXdr for LiquidityPoolWithdrawOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - selling: Asset::read_xdr(r)?, - buying: Asset::read_xdr(r)?, + liquidity_pool_id: PoolId::read_xdr(r)?, amount: i64::read_xdr(r)?, - price: Price::read_xdr(r)?, - offer_id: i64::read_xdr(r)?, + min_amount_a: i64::read_xdr(r)?, + min_amount_b: i64::read_xdr(r)?, }) }) } } -impl WriteXdr for ManageSellOfferOp { +impl WriteXdr for LiquidityPoolWithdrawOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.selling.write_xdr(w)?; - self.buying.write_xdr(w)?; + self.liquidity_pool_id.write_xdr(w)?; self.amount.write_xdr(w)?; - self.price.write_xdr(w)?; - self.offer_id.write_xdr(w)?; + self.min_amount_a.write_xdr(w)?; + self.min_amount_b.write_xdr(w)?; Ok(()) }) } } -// ManageBuyOfferOp is an XDR Struct defines as: +// HostFunctionType is an XDR Enum defines as: // -// struct ManageBuyOfferOp +// enum HostFunctionType // { -// Asset selling; -// Asset buying; -// int64 buyAmount; // amount being bought. if set to 0, delete the offer -// Price price; // price of thing being bought in terms of what you are -// // selling -// -// // 0=create a new offer, otherwise edit an existing offer -// int64 offerID; +// HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0, +// HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1, +// HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 // }; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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 ManageBuyOfferOp { - pub selling: Asset, - pub buying: Asset, - pub buy_amount: i64, - pub price: Price, - pub offer_id: i64, +#[repr(i32)] +pub enum HostFunctionType { + InvokeContract = 0, + CreateContract = 1, + UploadContractWasm = 2, } -impl ReadXdr for ManageBuyOfferOp { +impl HostFunctionType { + pub const VARIANTS: [HostFunctionType; 3] = [ + HostFunctionType::InvokeContract, + HostFunctionType::CreateContract, + HostFunctionType::UploadContractWasm, + ]; + pub const VARIANTS_STR: [&'static str; 3] = + ["InvokeContract", "CreateContract", "UploadContractWasm"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::InvokeContract => "InvokeContract", + Self::CreateContract => "CreateContract", + Self::UploadContractWasm => "UploadContractWasm", + } + } + + #[must_use] + pub const fn variants() -> [HostFunctionType; 3] { + Self::VARIANTS + } +} + +impl Name for HostFunctionType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for HostFunctionType { + fn variants() -> slice::Iter<'static, HostFunctionType> { + Self::VARIANTS.iter() + } +} + +impl Enum for HostFunctionType {} + +impl fmt::Display for HostFunctionType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for HostFunctionType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => HostFunctionType::InvokeContract, + 1 => HostFunctionType::CreateContract, + 2 => HostFunctionType::UploadContractWasm, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: HostFunctionType) -> Self { + e as Self + } +} + +impl ReadXdr for HostFunctionType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - selling: Asset::read_xdr(r)?, - buying: Asset::read_xdr(r)?, - buy_amount: i64::read_xdr(r)?, - price: Price::read_xdr(r)?, - offer_id: i64::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for ManageBuyOfferOp { +impl WriteXdr for HostFunctionType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.selling.write_xdr(w)?; - self.buying.write_xdr(w)?; - self.buy_amount.write_xdr(w)?; - self.price.write_xdr(w)?; - self.offer_id.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// CreatePassiveSellOfferOp is an XDR Struct defines as: +// ContractIdPreimageType is an XDR Enum defines as: // -// struct CreatePassiveSellOfferOp +// enum ContractIDPreimageType // { -// Asset selling; // A -// Asset buying; // B -// int64 amount; // amount taker gets -// Price price; // cost of A in terms of B +// CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0, +// CONTRACT_ID_PREIMAGE_FROM_ASSET = 1 // }; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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 CreatePassiveSellOfferOp { - pub selling: Asset, - pub buying: Asset, - pub amount: i64, - pub price: Price, +#[repr(i32)] +pub enum ContractIdPreimageType { + Address = 0, + Asset = 1, } -impl ReadXdr for CreatePassiveSellOfferOp { +impl ContractIdPreimageType { + pub const VARIANTS: [ContractIdPreimageType; 2] = [ + ContractIdPreimageType::Address, + ContractIdPreimageType::Asset, + ]; + pub const VARIANTS_STR: [&'static str; 2] = ["Address", "Asset"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Address => "Address", + Self::Asset => "Asset", + } + } + + #[must_use] + pub const fn variants() -> [ContractIdPreimageType; 2] { + Self::VARIANTS + } +} + +impl Name for ContractIdPreimageType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ContractIdPreimageType { + fn variants() -> slice::Iter<'static, ContractIdPreimageType> { + Self::VARIANTS.iter() + } +} + +impl Enum for ContractIdPreimageType {} + +impl fmt::Display for ContractIdPreimageType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ContractIdPreimageType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ContractIdPreimageType::Address, + 1 => ContractIdPreimageType::Asset, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ContractIdPreimageType) -> Self { + e as Self + } +} + +impl ReadXdr for ContractIdPreimageType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - selling: Asset::read_xdr(r)?, - buying: Asset::read_xdr(r)?, - amount: i64::read_xdr(r)?, - price: Price::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for CreatePassiveSellOfferOp { +impl WriteXdr for ContractIdPreimageType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.selling.write_xdr(w)?; - self.buying.write_xdr(w)?; - self.amount.write_xdr(w)?; - self.price.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// SetOptionsOp is an XDR Struct defines as: -// -// struct SetOptionsOp -// { -// AccountID* inflationDest; // sets the inflation destination -// -// uint32* clearFlags; // which flags to clear -// uint32* setFlags; // which flags to set -// -// // account threshold manipulation -// uint32* masterWeight; // weight of the master account -// uint32* lowThreshold; -// uint32* medThreshold; -// uint32* highThreshold; -// -// string32* homeDomain; // sets the home domain +// ContractIdPreimageFromAddress is an XDR NestedStruct defines as: // -// // Add, update or remove a signer for the account -// // signer is deleted if the weight is 0 -// Signer* signer; -// }; +// struct +// { +// SCAddress address; +// uint256 salt; +// } // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -16732,75 +25321,49 @@ impl WriteXdr for CreatePassiveSellOfferOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SetOptionsOp { - pub inflation_dest: Option, - pub clear_flags: Option, - pub set_flags: Option, - pub master_weight: Option, - pub low_threshold: Option, - pub med_threshold: Option, - pub high_threshold: Option, - pub home_domain: Option, - pub signer: Option, +pub struct ContractIdPreimageFromAddress { + pub address: ScAddress, + pub salt: Uint256, } -impl ReadXdr for SetOptionsOp { +impl ReadXdr for ContractIdPreimageFromAddress { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - inflation_dest: Option::::read_xdr(r)?, - clear_flags: Option::::read_xdr(r)?, - set_flags: Option::::read_xdr(r)?, - master_weight: Option::::read_xdr(r)?, - low_threshold: Option::::read_xdr(r)?, - med_threshold: Option::::read_xdr(r)?, - high_threshold: Option::::read_xdr(r)?, - home_domain: Option::::read_xdr(r)?, - signer: Option::::read_xdr(r)?, + address: ScAddress::read_xdr(r)?, + salt: Uint256::read_xdr(r)?, }) }) } } -impl WriteXdr for SetOptionsOp { +impl WriteXdr for ContractIdPreimageFromAddress { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.inflation_dest.write_xdr(w)?; - self.clear_flags.write_xdr(w)?; - self.set_flags.write_xdr(w)?; - self.master_weight.write_xdr(w)?; - self.low_threshold.write_xdr(w)?; - self.med_threshold.write_xdr(w)?; - self.high_threshold.write_xdr(w)?; - self.home_domain.write_xdr(w)?; - self.signer.write_xdr(w)?; + self.address.write_xdr(w)?; + self.salt.write_xdr(w)?; Ok(()) }) } } -// ChangeTrustAsset is an XDR Union defines as: +// ContractIdPreimage is an XDR Union defines as: // -// union ChangeTrustAsset switch (AssetType type) +// union ContractIDPreimage switch (ContractIDPreimageType type) // { -// case ASSET_TYPE_NATIVE: // Not credit -// void; -// -// case ASSET_TYPE_CREDIT_ALPHANUM4: -// AlphaNum4 alphaNum4; -// -// case ASSET_TYPE_CREDIT_ALPHANUM12: -// AlphaNum12 alphaNum12; -// -// case ASSET_TYPE_POOL_SHARE: -// LiquidityPoolParameters liquidityPool; -// -// // add other asset types here in the future +// case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: +// struct +// { +// SCAddress address; +// uint256 salt; +// } fromAddress; +// case CONTRACT_ID_PREIMAGE_FROM_ASSET: +// Asset fromAsset; // }; // -// union with discriminant AssetType +// union with discriminant ContractIdPreimageType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -16809,83 +25372,74 @@ impl WriteXdr for SetOptionsOp { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ChangeTrustAsset { - Native, - CreditAlphanum4(AlphaNum4), - CreditAlphanum12(AlphaNum12), - PoolShare(LiquidityPoolParameters), +pub enum ContractIdPreimage { + Address(ContractIdPreimageFromAddress), + Asset(Asset), } -impl ChangeTrustAsset { - pub const VARIANTS: [AssetType; 4] = [ - AssetType::Native, - AssetType::CreditAlphanum4, - AssetType::CreditAlphanum12, - AssetType::PoolShare, +impl ContractIdPreimage { + pub const VARIANTS: [ContractIdPreimageType; 2] = [ + ContractIdPreimageType::Address, + ContractIdPreimageType::Asset, ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Native", "CreditAlphanum4", "CreditAlphanum12", "PoolShare"]; + pub const VARIANTS_STR: [&'static str; 2] = ["Address", "Asset"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Native => "Native", - Self::CreditAlphanum4(_) => "CreditAlphanum4", - Self::CreditAlphanum12(_) => "CreditAlphanum12", - Self::PoolShare(_) => "PoolShare", + Self::Address(_) => "Address", + Self::Asset(_) => "Asset", } } #[must_use] - pub const fn discriminant(&self) -> AssetType { + pub const fn discriminant(&self) -> ContractIdPreimageType { #[allow(clippy::match_same_arms)] match self { - Self::Native => AssetType::Native, - Self::CreditAlphanum4(_) => AssetType::CreditAlphanum4, - Self::CreditAlphanum12(_) => AssetType::CreditAlphanum12, - Self::PoolShare(_) => AssetType::PoolShare, + Self::Address(_) => ContractIdPreimageType::Address, + Self::Asset(_) => ContractIdPreimageType::Asset, } } #[must_use] - pub const fn variants() -> [AssetType; 4] { + pub const fn variants() -> [ContractIdPreimageType; 2] { Self::VARIANTS } } -impl Name for ChangeTrustAsset { +impl Name for ContractIdPreimage { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ChangeTrustAsset { +impl Discriminant for ContractIdPreimage { #[must_use] - fn discriminant(&self) -> AssetType { + fn discriminant(&self) -> ContractIdPreimageType { Self::discriminant(self) } } -impl Variants for ChangeTrustAsset { - fn variants() -> slice::Iter<'static, AssetType> { +impl Variants for ContractIdPreimage { + fn variants() -> slice::Iter<'static, ContractIdPreimageType> { Self::VARIANTS.iter() } } -impl Union for ChangeTrustAsset {} +impl Union for ContractIdPreimage {} -impl ReadXdr for ChangeTrustAsset { +impl ReadXdr for ContractIdPreimage { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: AssetType = ::read_xdr(r)?; + let dv: ContractIdPreimageType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - AssetType::Native => Self::Native, - AssetType::CreditAlphanum4 => Self::CreditAlphanum4(AlphaNum4::read_xdr(r)?), - AssetType::CreditAlphanum12 => Self::CreditAlphanum12(AlphaNum12::read_xdr(r)?), - AssetType::PoolShare => Self::PoolShare(LiquidityPoolParameters::read_xdr(r)?), + ContractIdPreimageType::Address => { + Self::Address(ContractIdPreimageFromAddress::read_xdr(r)?) + } + ContractIdPreimageType::Asset => Self::Asset(Asset::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -16894,31 +25448,27 @@ impl ReadXdr for ChangeTrustAsset { } } -impl WriteXdr for ChangeTrustAsset { +impl WriteXdr for ContractIdPreimage { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Native => ().write_xdr(w)?, - Self::CreditAlphanum4(v) => v.write_xdr(w)?, - Self::CreditAlphanum12(v) => v.write_xdr(w)?, - Self::PoolShare(v) => v.write_xdr(w)?, + Self::Address(v) => v.write_xdr(w)?, + Self::Asset(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// ChangeTrustOp is an XDR Struct defines as: +// CreateContractArgs is an XDR Struct defines as: // -// struct ChangeTrustOp +// struct CreateContractArgs // { -// ChangeTrustAsset line; -// -// // if limit is set to 0, deletes the trust line -// int64 limit; +// ContractIDPreimage contractIDPreimage; +// ContractExecutable executable; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -16928,43 +25478,40 @@ impl WriteXdr for ChangeTrustAsset { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ChangeTrustOp { - pub line: ChangeTrustAsset, - pub limit: i64, +pub struct CreateContractArgs { + pub contract_id_preimage: ContractIdPreimage, + pub executable: ContractExecutable, } -impl ReadXdr for ChangeTrustOp { +impl ReadXdr for CreateContractArgs { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - line: ChangeTrustAsset::read_xdr(r)?, - limit: i64::read_xdr(r)?, + contract_id_preimage: ContractIdPreimage::read_xdr(r)?, + executable: ContractExecutable::read_xdr(r)?, }) }) } } -impl WriteXdr for ChangeTrustOp { +impl WriteXdr for CreateContractArgs { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.line.write_xdr(w)?; - self.limit.write_xdr(w)?; + self.contract_id_preimage.write_xdr(w)?; + self.executable.write_xdr(w)?; Ok(()) }) } } -// AllowTrustOp is an XDR Struct defines as: -// -// struct AllowTrustOp -// { -// AccountID trustor; -// AssetCode asset; +// InvokeContractArgs is an XDR Struct defines as: // -// // One of 0, AUTHORIZED_FLAG, or AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG -// uint32 authorize; +// struct InvokeContractArgs { +// SCAddress contractAddress; +// SCSymbol functionName; +// SCVal args<>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -16974,45 +25521,50 @@ impl WriteXdr for ChangeTrustOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct AllowTrustOp { - pub trustor: AccountId, - pub asset: AssetCode, - pub authorize: u32, +pub struct InvokeContractArgs { + pub contract_address: ScAddress, + pub function_name: ScSymbol, + pub args: VecM, } -impl ReadXdr for AllowTrustOp { +impl ReadXdr for InvokeContractArgs { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - trustor: AccountId::read_xdr(r)?, - asset: AssetCode::read_xdr(r)?, - authorize: u32::read_xdr(r)?, + contract_address: ScAddress::read_xdr(r)?, + function_name: ScSymbol::read_xdr(r)?, + args: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for AllowTrustOp { +impl WriteXdr for InvokeContractArgs { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.trustor.write_xdr(w)?; - self.asset.write_xdr(w)?; - self.authorize.write_xdr(w)?; + self.contract_address.write_xdr(w)?; + self.function_name.write_xdr(w)?; + self.args.write_xdr(w)?; Ok(()) }) } } -// ManageDataOp is an XDR Struct defines as: +// HostFunction is an XDR Union defines as: // -// struct ManageDataOp +// union HostFunction switch (HostFunctionType type) // { -// string64 dataName; -// DataValue* dataValue; // set to null to clear +// case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: +// InvokeContractArgs invokeContract; +// case HOST_FUNCTION_TYPE_CREATE_CONTRACT: +// CreateContractArgs createContract; +// case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: +// opaque wasm<>; // }; // +// union with discriminant HostFunctionType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -17020,125 +25572,334 @@ impl WriteXdr for AllowTrustOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ManageDataOp { - pub data_name: String64, - pub data_value: Option, +#[allow(clippy::large_enum_variant)] +pub enum HostFunction { + InvokeContract(InvokeContractArgs), + CreateContract(CreateContractArgs), + UploadContractWasm(BytesM), } -impl ReadXdr for ManageDataOp { +impl HostFunction { + pub const VARIANTS: [HostFunctionType; 3] = [ + HostFunctionType::InvokeContract, + HostFunctionType::CreateContract, + HostFunctionType::UploadContractWasm, + ]; + pub const VARIANTS_STR: [&'static str; 3] = + ["InvokeContract", "CreateContract", "UploadContractWasm"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::InvokeContract(_) => "InvokeContract", + Self::CreateContract(_) => "CreateContract", + Self::UploadContractWasm(_) => "UploadContractWasm", + } + } + + #[must_use] + pub const fn discriminant(&self) -> HostFunctionType { + #[allow(clippy::match_same_arms)] + match self { + Self::InvokeContract(_) => HostFunctionType::InvokeContract, + Self::CreateContract(_) => HostFunctionType::CreateContract, + Self::UploadContractWasm(_) => HostFunctionType::UploadContractWasm, + } + } + + #[must_use] + pub const fn variants() -> [HostFunctionType; 3] { + Self::VARIANTS + } +} + +impl Name for HostFunction { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for HostFunction { + #[must_use] + fn discriminant(&self) -> HostFunctionType { + Self::discriminant(self) + } +} + +impl Variants for HostFunction { + fn variants() -> slice::Iter<'static, HostFunctionType> { + Self::VARIANTS.iter() + } +} + +impl Union for HostFunction {} + +impl ReadXdr for HostFunction { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - data_name: String64::read_xdr(r)?, - data_value: Option::::read_xdr(r)?, - }) + let dv: HostFunctionType = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + HostFunctionType::InvokeContract => { + Self::InvokeContract(InvokeContractArgs::read_xdr(r)?) + } + HostFunctionType::CreateContract => { + Self::CreateContract(CreateContractArgs::read_xdr(r)?) + } + HostFunctionType::UploadContractWasm => { + Self::UploadContractWasm(BytesM::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) }) } } -impl WriteXdr for ManageDataOp { +impl WriteXdr for HostFunction { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.data_name.write_xdr(w)?; - self.data_value.write_xdr(w)?; + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::InvokeContract(v) => v.write_xdr(w)?, + Self::CreateContract(v) => v.write_xdr(w)?, + Self::UploadContractWasm(v) => v.write_xdr(w)?, + }; Ok(()) }) } } -// BumpSequenceOp is an XDR Struct defines as: +// SorobanAuthorizedFunctionType is an XDR Enum defines as: // -// struct BumpSequenceOp +// enum SorobanAuthorizedFunctionType // { -// SequenceNumber bumpTo; +// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, +// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 // }; // -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +// enum +#[derive(Clone, Copy, 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 BumpSequenceOp { - pub bump_to: SequenceNumber, +#[repr(i32)] +pub enum SorobanAuthorizedFunctionType { + ContractFn = 0, + CreateContractHostFn = 1, } -impl ReadXdr for BumpSequenceOp { +impl SorobanAuthorizedFunctionType { + pub const VARIANTS: [SorobanAuthorizedFunctionType; 2] = [ + SorobanAuthorizedFunctionType::ContractFn, + SorobanAuthorizedFunctionType::CreateContractHostFn, + ]; + pub const VARIANTS_STR: [&'static str; 2] = ["ContractFn", "CreateContractHostFn"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ContractFn => "ContractFn", + Self::CreateContractHostFn => "CreateContractHostFn", + } + } + + #[must_use] + pub const fn variants() -> [SorobanAuthorizedFunctionType; 2] { + Self::VARIANTS + } +} + +impl Name for SorobanAuthorizedFunctionType { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for SorobanAuthorizedFunctionType { + fn variants() -> slice::Iter<'static, SorobanAuthorizedFunctionType> { + Self::VARIANTS.iter() + } +} + +impl Enum for SorobanAuthorizedFunctionType {} + +impl fmt::Display for SorobanAuthorizedFunctionType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for SorobanAuthorizedFunctionType { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => SorobanAuthorizedFunctionType::ContractFn, + 1 => SorobanAuthorizedFunctionType::CreateContractHostFn, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: SorobanAuthorizedFunctionType) -> Self { + e as Self + } +} + +impl ReadXdr for SorobanAuthorizedFunctionType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - bump_to: SequenceNumber::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for SorobanAuthorizedFunctionType { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -impl WriteXdr for BumpSequenceOp { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.bump_to.write_xdr(w)?; - Ok(()) - }) +// SorobanAuthorizedFunction is an XDR Union defines as: +// +// union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type) +// { +// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: +// InvokeContractArgs contractFn; +// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: +// CreateContractArgs createContractHostFn; +// }; +// +// union with discriminant SorobanAuthorizedFunctionType +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum SorobanAuthorizedFunction { + ContractFn(InvokeContractArgs), + CreateContractHostFn(CreateContractArgs), +} + +impl SorobanAuthorizedFunction { + pub const VARIANTS: [SorobanAuthorizedFunctionType; 2] = [ + SorobanAuthorizedFunctionType::ContractFn, + SorobanAuthorizedFunctionType::CreateContractHostFn, + ]; + pub const VARIANTS_STR: [&'static str; 2] = ["ContractFn", "CreateContractHostFn"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::ContractFn(_) => "ContractFn", + Self::CreateContractHostFn(_) => "CreateContractHostFn", + } + } + + #[must_use] + pub const fn discriminant(&self) -> SorobanAuthorizedFunctionType { + #[allow(clippy::match_same_arms)] + match self { + Self::ContractFn(_) => SorobanAuthorizedFunctionType::ContractFn, + Self::CreateContractHostFn(_) => SorobanAuthorizedFunctionType::CreateContractHostFn, + } + } + + #[must_use] + pub const fn variants() -> [SorobanAuthorizedFunctionType; 2] { + Self::VARIANTS + } +} + +impl Name for SorobanAuthorizedFunction { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for SorobanAuthorizedFunction { + #[must_use] + fn discriminant(&self) -> SorobanAuthorizedFunctionType { + Self::discriminant(self) + } +} + +impl Variants for SorobanAuthorizedFunction { + fn variants() -> slice::Iter<'static, SorobanAuthorizedFunctionType> { + Self::VARIANTS.iter() } } -// CreateClaimableBalanceOp is an XDR Struct defines as: -// -// struct CreateClaimableBalanceOp -// { -// Asset asset; -// int64 amount; -// Claimant claimants<10>; -// }; -// -#[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 CreateClaimableBalanceOp { - pub asset: Asset, - pub amount: i64, - pub claimants: VecM, -} +impl Union for SorobanAuthorizedFunction {} -impl ReadXdr for CreateClaimableBalanceOp { +impl ReadXdr for SorobanAuthorizedFunction { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - asset: Asset::read_xdr(r)?, - amount: i64::read_xdr(r)?, - claimants: VecM::::read_xdr(r)?, - }) + let dv: SorobanAuthorizedFunctionType = + ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + SorobanAuthorizedFunctionType::ContractFn => { + Self::ContractFn(InvokeContractArgs::read_xdr(r)?) + } + SorobanAuthorizedFunctionType::CreateContractHostFn => { + Self::CreateContractHostFn(CreateContractArgs::read_xdr(r)?) + } + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) }) } } -impl WriteXdr for CreateClaimableBalanceOp { +impl WriteXdr for SorobanAuthorizedFunction { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.asset.write_xdr(w)?; - self.amount.write_xdr(w)?; - self.claimants.write_xdr(w)?; + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::ContractFn(v) => v.write_xdr(w)?, + Self::CreateContractHostFn(v) => v.write_xdr(w)?, + }; Ok(()) }) } } -// ClaimClaimableBalanceOp is an XDR Struct defines as: +// SorobanAuthorizedInvocation is an XDR Struct defines as: // -// struct ClaimClaimableBalanceOp +// struct SorobanAuthorizedInvocation // { -// ClaimableBalanceID balanceID; +// SorobanAuthorizedFunction function; +// SorobanAuthorizedInvocation subInvocations<>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -17148,36 +25909,42 @@ impl WriteXdr for CreateClaimableBalanceOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ClaimClaimableBalanceOp { - pub balance_id: ClaimableBalanceId, +pub struct SorobanAuthorizedInvocation { + pub function: SorobanAuthorizedFunction, + pub sub_invocations: VecM, } -impl ReadXdr for ClaimClaimableBalanceOp { +impl ReadXdr for SorobanAuthorizedInvocation { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - balance_id: ClaimableBalanceId::read_xdr(r)?, + function: SorobanAuthorizedFunction::read_xdr(r)?, + sub_invocations: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for ClaimClaimableBalanceOp { +impl WriteXdr for SorobanAuthorizedInvocation { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.balance_id.write_xdr(w)?; + self.function.write_xdr(w)?; + self.sub_invocations.write_xdr(w)?; Ok(()) }) } } -// BeginSponsoringFutureReservesOp is an XDR Struct defines as: +// SorobanAddressCredentials is an XDR Struct defines as: // -// struct BeginSponsoringFutureReservesOp +// struct SorobanAddressCredentials // { -// AccountID sponsoredID; +// SCAddress address; +// int64 nonce; +// uint32 signatureExpirationLedger; +// SCVal signature; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -17187,37 +25954,46 @@ impl WriteXdr for ClaimClaimableBalanceOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct BeginSponsoringFutureReservesOp { - pub sponsored_id: AccountId, +pub struct SorobanAddressCredentials { + pub address: ScAddress, + pub nonce: i64, + pub signature_expiration_ledger: u32, + pub signature: ScVal, } -impl ReadXdr for BeginSponsoringFutureReservesOp { +impl ReadXdr for SorobanAddressCredentials { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - sponsored_id: AccountId::read_xdr(r)?, + address: ScAddress::read_xdr(r)?, + nonce: i64::read_xdr(r)?, + signature_expiration_ledger: u32::read_xdr(r)?, + signature: ScVal::read_xdr(r)?, }) }) } } -impl WriteXdr for BeginSponsoringFutureReservesOp { +impl WriteXdr for SorobanAddressCredentials { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.sponsored_id.write_xdr(w)?; + self.address.write_xdr(w)?; + self.nonce.write_xdr(w)?; + self.signature_expiration_ledger.write_xdr(w)?; + self.signature.write_xdr(w)?; Ok(()) }) } } -// RevokeSponsorshipType is an XDR Enum defines as: +// SorobanCredentialsType is an XDR Enum defines as: // -// enum RevokeSponsorshipType +// enum SorobanCredentialsType // { -// REVOKE_SPONSORSHIP_LEDGER_ENTRY = 0, -// REVOKE_SPONSORSHIP_SIGNER = 1 +// SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0, +// SOROBAN_CREDENTIALS_ADDRESS = 1 // }; // // enum @@ -17229,60 +26005,60 @@ impl WriteXdr for BeginSponsoringFutureReservesOp { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum RevokeSponsorshipType { - LedgerEntry = 0, - Signer = 1, +pub enum SorobanCredentialsType { + SourceAccount = 0, + Address = 1, } -impl RevokeSponsorshipType { - pub const VARIANTS: [RevokeSponsorshipType; 2] = [ - RevokeSponsorshipType::LedgerEntry, - RevokeSponsorshipType::Signer, +impl SorobanCredentialsType { + pub const VARIANTS: [SorobanCredentialsType; 2] = [ + SorobanCredentialsType::SourceAccount, + SorobanCredentialsType::Address, ]; - pub const VARIANTS_STR: [&'static str; 2] = ["LedgerEntry", "Signer"]; + pub const VARIANTS_STR: [&'static str; 2] = ["SourceAccount", "Address"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::LedgerEntry => "LedgerEntry", - Self::Signer => "Signer", + Self::SourceAccount => "SourceAccount", + Self::Address => "Address", } } #[must_use] - pub const fn variants() -> [RevokeSponsorshipType; 2] { + pub const fn variants() -> [SorobanCredentialsType; 2] { Self::VARIANTS } } -impl Name for RevokeSponsorshipType { +impl Name for SorobanCredentialsType { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for RevokeSponsorshipType { - fn variants() -> slice::Iter<'static, RevokeSponsorshipType> { +impl Variants for SorobanCredentialsType { + fn variants() -> slice::Iter<'static, SorobanCredentialsType> { Self::VARIANTS.iter() } } -impl Enum for RevokeSponsorshipType {} +impl Enum for SorobanCredentialsType {} -impl fmt::Display for RevokeSponsorshipType { +impl fmt::Display for SorobanCredentialsType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for RevokeSponsorshipType { +impl TryFrom for SorobanCredentialsType { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => RevokeSponsorshipType::LedgerEntry, - 1 => RevokeSponsorshipType::Signer, + 0 => SorobanCredentialsType::SourceAccount, + 1 => SorobanCredentialsType::Address, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -17290,14 +26066,14 @@ impl TryFrom for RevokeSponsorshipType { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: RevokeSponsorshipType) -> Self { + fn from(e: SorobanCredentialsType) -> Self { e as Self } } -impl ReadXdr for RevokeSponsorshipType { +impl ReadXdr for SorobanCredentialsType { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -17308,7 +26084,7 @@ impl ReadXdr for RevokeSponsorshipType { } } -impl WriteXdr for RevokeSponsorshipType { +impl WriteXdr for SorobanCredentialsType { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -17318,64 +26094,17 @@ impl WriteXdr for RevokeSponsorshipType { } } -// RevokeSponsorshipOpSigner is an XDR NestedStruct defines as: -// -// struct -// { -// AccountID accountID; -// SignerKey signerKey; -// } -// -#[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 RevokeSponsorshipOpSigner { - pub account_id: AccountId, - pub signer_key: SignerKey, -} - -impl ReadXdr for RevokeSponsorshipOpSigner { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - account_id: AccountId::read_xdr(r)?, - signer_key: SignerKey::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for RevokeSponsorshipOpSigner { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.account_id.write_xdr(w)?; - self.signer_key.write_xdr(w)?; - Ok(()) - }) - } -} - -// RevokeSponsorshipOp is an XDR Union defines as: +// SorobanCredentials is an XDR Union defines as: // -// union RevokeSponsorshipOp switch (RevokeSponsorshipType type) +// union SorobanCredentials switch (SorobanCredentialsType type) // { -// case REVOKE_SPONSORSHIP_LEDGER_ENTRY: -// LedgerKey ledgerKey; -// case REVOKE_SPONSORSHIP_SIGNER: -// struct -// { -// AccountID accountID; -// SignerKey signerKey; -// } signer; +// case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: +// void; +// case SOROBAN_CREDENTIALS_ADDRESS: +// SorobanAddressCredentials address; // }; // -// union with discriminant RevokeSponsorshipType +// union with discriminant SorobanCredentialsType #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -17384,73 +26113,73 @@ impl WriteXdr for RevokeSponsorshipOpSigner { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum RevokeSponsorshipOp { - LedgerEntry(LedgerKey), - Signer(RevokeSponsorshipOpSigner), +pub enum SorobanCredentials { + SourceAccount, + Address(SorobanAddressCredentials), } -impl RevokeSponsorshipOp { - pub const VARIANTS: [RevokeSponsorshipType; 2] = [ - RevokeSponsorshipType::LedgerEntry, - RevokeSponsorshipType::Signer, +impl SorobanCredentials { + pub const VARIANTS: [SorobanCredentialsType; 2] = [ + SorobanCredentialsType::SourceAccount, + SorobanCredentialsType::Address, ]; - pub const VARIANTS_STR: [&'static str; 2] = ["LedgerEntry", "Signer"]; + pub const VARIANTS_STR: [&'static str; 2] = ["SourceAccount", "Address"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::LedgerEntry(_) => "LedgerEntry", - Self::Signer(_) => "Signer", + Self::SourceAccount => "SourceAccount", + Self::Address(_) => "Address", } } #[must_use] - pub const fn discriminant(&self) -> RevokeSponsorshipType { + pub const fn discriminant(&self) -> SorobanCredentialsType { #[allow(clippy::match_same_arms)] match self { - Self::LedgerEntry(_) => RevokeSponsorshipType::LedgerEntry, - Self::Signer(_) => RevokeSponsorshipType::Signer, + Self::SourceAccount => SorobanCredentialsType::SourceAccount, + Self::Address(_) => SorobanCredentialsType::Address, } } #[must_use] - pub const fn variants() -> [RevokeSponsorshipType; 2] { + pub const fn variants() -> [SorobanCredentialsType; 2] { Self::VARIANTS } } -impl Name for RevokeSponsorshipOp { +impl Name for SorobanCredentials { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for RevokeSponsorshipOp { +impl Discriminant for SorobanCredentials { #[must_use] - fn discriminant(&self) -> RevokeSponsorshipType { + fn discriminant(&self) -> SorobanCredentialsType { Self::discriminant(self) } } -impl Variants for RevokeSponsorshipOp { - fn variants() -> slice::Iter<'static, RevokeSponsorshipType> { +impl Variants for SorobanCredentials { + fn variants() -> slice::Iter<'static, SorobanCredentialsType> { Self::VARIANTS.iter() } } -impl Union for RevokeSponsorshipOp {} +impl Union for SorobanCredentials {} -impl ReadXdr for RevokeSponsorshipOp { +impl ReadXdr for SorobanCredentials { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: RevokeSponsorshipType = ::read_xdr(r)?; + let dv: SorobanCredentialsType = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - RevokeSponsorshipType::LedgerEntry => Self::LedgerEntry(LedgerKey::read_xdr(r)?), - RevokeSponsorshipType::Signer => { - Self::Signer(RevokeSponsorshipOpSigner::read_xdr(r)?) + SorobanCredentialsType::SourceAccount => Self::SourceAccount, + SorobanCredentialsType::Address => { + Self::Address(SorobanAddressCredentials::read_xdr(r)?) } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), @@ -17460,73 +26189,27 @@ impl ReadXdr for RevokeSponsorshipOp { } } -impl WriteXdr for RevokeSponsorshipOp { +impl WriteXdr for SorobanCredentials { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::LedgerEntry(v) => v.write_xdr(w)?, - Self::Signer(v) => v.write_xdr(w)?, + Self::SourceAccount => ().write_xdr(w)?, + Self::Address(v) => v.write_xdr(w)?, }; Ok(()) }) } } -// ClawbackOp is an XDR Struct defines as: -// -// struct ClawbackOp -// { -// Asset asset; -// MuxedAccount from; -// int64 amount; -// }; -// -#[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 ClawbackOp { - pub asset: Asset, - pub from: MuxedAccount, - pub amount: i64, -} - -impl ReadXdr for ClawbackOp { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - asset: Asset::read_xdr(r)?, - from: MuxedAccount::read_xdr(r)?, - amount: i64::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for ClawbackOp { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.asset.write_xdr(w)?; - self.from.write_xdr(w)?; - self.amount.write_xdr(w)?; - Ok(()) - }) - } -} - -// ClawbackClaimableBalanceOp is an XDR Struct defines as: +// SorobanAuthorizationEntry is an XDR Struct defines as: // -// struct ClawbackClaimableBalanceOp +// struct SorobanAuthorizationEntry // { -// ClaimableBalanceID balanceID; +// SorobanCredentials credentials; +// SorobanAuthorizedInvocation rootInvocation; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -17536,40 +26219,42 @@ impl WriteXdr for ClawbackOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct ClawbackClaimableBalanceOp { - pub balance_id: ClaimableBalanceId, +pub struct SorobanAuthorizationEntry { + pub credentials: SorobanCredentials, + pub root_invocation: SorobanAuthorizedInvocation, } -impl ReadXdr for ClawbackClaimableBalanceOp { +impl ReadXdr for SorobanAuthorizationEntry { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - balance_id: ClaimableBalanceId::read_xdr(r)?, + credentials: SorobanCredentials::read_xdr(r)?, + root_invocation: SorobanAuthorizedInvocation::read_xdr(r)?, }) }) } } -impl WriteXdr for ClawbackClaimableBalanceOp { +impl WriteXdr for SorobanAuthorizationEntry { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.balance_id.write_xdr(w)?; + self.credentials.write_xdr(w)?; + self.root_invocation.write_xdr(w)?; Ok(()) }) } } -// SetTrustLineFlagsOp is an XDR Struct defines as: +// InvokeHostFunctionOp is an XDR Struct defines as: // -// struct SetTrustLineFlagsOp +// struct InvokeHostFunctionOp // { -// AccountID trustor; -// Asset asset; -// -// uint32 clearFlags; // which flags to clear -// uint32 setFlags; // which flags to set +// // Host function to invoke. +// HostFunction hostFunction; +// // Per-address authorizations for this host function. +// SorobanAuthorizationEntry auth<>; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -17579,55 +26264,40 @@ impl WriteXdr for ClawbackClaimableBalanceOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct SetTrustLineFlagsOp { - pub trustor: AccountId, - pub asset: Asset, - pub clear_flags: u32, - pub set_flags: u32, +pub struct InvokeHostFunctionOp { + pub host_function: HostFunction, + pub auth: VecM, } -impl ReadXdr for SetTrustLineFlagsOp { +impl ReadXdr for InvokeHostFunctionOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - trustor: AccountId::read_xdr(r)?, - asset: Asset::read_xdr(r)?, - clear_flags: u32::read_xdr(r)?, - set_flags: u32::read_xdr(r)?, + host_function: HostFunction::read_xdr(r)?, + auth: VecM::::read_xdr(r)?, }) }) } } -impl WriteXdr for SetTrustLineFlagsOp { +impl WriteXdr for InvokeHostFunctionOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.trustor.write_xdr(w)?; - self.asset.write_xdr(w)?; - self.clear_flags.write_xdr(w)?; - self.set_flags.write_xdr(w)?; + self.host_function.write_xdr(w)?; + self.auth.write_xdr(w)?; Ok(()) }) } } -// LiquidityPoolFeeV18 is an XDR Const defines as: -// -// const LIQUIDITY_POOL_FEE_V18 = 30; -// -pub const LIQUIDITY_POOL_FEE_V18: u64 = 30; - -// LiquidityPoolDepositOp is an XDR Struct defines as: +// BumpFootprintExpirationOp is an XDR Struct defines as: // -// struct LiquidityPoolDepositOp +// struct BumpFootprintExpirationOp // { -// PoolID liquidityPoolID; -// int64 maxAmountA; // maximum amount of first asset to deposit -// int64 maxAmountB; // maximum amount of second asset to deposit -// Price minPrice; // minimum depositA/depositB -// Price maxPrice; // maximum depositA/depositB +// ExtensionPoint ext; +// uint32 ledgersToExpire; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -17637,51 +26307,39 @@ pub const LIQUIDITY_POOL_FEE_V18: u64 = 30; derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LiquidityPoolDepositOp { - pub liquidity_pool_id: PoolId, - pub max_amount_a: i64, - pub max_amount_b: i64, - pub min_price: Price, - pub max_price: Price, +pub struct BumpFootprintExpirationOp { + pub ext: ExtensionPoint, + pub ledgers_to_expire: u32, } -impl ReadXdr for LiquidityPoolDepositOp { +impl ReadXdr for BumpFootprintExpirationOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - liquidity_pool_id: PoolId::read_xdr(r)?, - max_amount_a: i64::read_xdr(r)?, - max_amount_b: i64::read_xdr(r)?, - min_price: Price::read_xdr(r)?, - max_price: Price::read_xdr(r)?, + ext: ExtensionPoint::read_xdr(r)?, + ledgers_to_expire: u32::read_xdr(r)?, }) }) } } -impl WriteXdr for LiquidityPoolDepositOp { +impl WriteXdr for BumpFootprintExpirationOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.liquidity_pool_id.write_xdr(w)?; - self.max_amount_a.write_xdr(w)?; - self.max_amount_b.write_xdr(w)?; - self.min_price.write_xdr(w)?; - self.max_price.write_xdr(w)?; + self.ext.write_xdr(w)?; + self.ledgers_to_expire.write_xdr(w)?; Ok(()) }) } } -// LiquidityPoolWithdrawOp is an XDR Struct defines as: +// RestoreFootprintOp is an XDR Struct defines as: // -// struct LiquidityPoolWithdrawOp +// struct RestoreFootprintOp // { -// PoolID liquidityPoolID; -// int64 amount; // amount of pool shares to withdraw -// int64 minAmountA; // minimum amount of first asset to withdraw -// int64 minAmountB; // minimum amount of second asset to withdraw +// ExtensionPoint ext; // }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -17691,35 +26349,26 @@ impl WriteXdr for LiquidityPoolDepositOp { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct LiquidityPoolWithdrawOp { - pub liquidity_pool_id: PoolId, - pub amount: i64, - pub min_amount_a: i64, - pub min_amount_b: i64, +pub struct RestoreFootprintOp { + pub ext: ExtensionPoint, } -impl ReadXdr for LiquidityPoolWithdrawOp { +impl ReadXdr for RestoreFootprintOp { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - liquidity_pool_id: PoolId::read_xdr(r)?, - amount: i64::read_xdr(r)?, - min_amount_a: i64::read_xdr(r)?, - min_amount_b: i64::read_xdr(r)?, + ext: ExtensionPoint::read_xdr(r)?, }) }) } } -impl WriteXdr for LiquidityPoolWithdrawOp { +impl WriteXdr for RestoreFootprintOp { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.liquidity_pool_id.write_xdr(w)?; - self.amount.write_xdr(w)?; - self.min_amount_a.write_xdr(w)?; - self.min_amount_b.write_xdr(w)?; + self.ext.write_xdr(w)?; Ok(()) }) } @@ -17777,6 +26426,12 @@ impl WriteXdr for LiquidityPoolWithdrawOp { // LiquidityPoolDepositOp liquidityPoolDepositOp; // case LIQUIDITY_POOL_WITHDRAW: // LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; +// case INVOKE_HOST_FUNCTION: +// InvokeHostFunctionOp invokeHostFunctionOp; +// case BUMP_FOOTPRINT_EXPIRATION: +// BumpFootprintExpirationOp bumpFootprintExpirationOp; +// case RESTORE_FOOTPRINT: +// RestoreFootprintOp restoreFootprintOp; // } // // union with discriminant OperationType @@ -17813,10 +26468,13 @@ pub enum OperationBody { SetTrustLineFlags(SetTrustLineFlagsOp), LiquidityPoolDeposit(LiquidityPoolDepositOp), LiquidityPoolWithdraw(LiquidityPoolWithdrawOp), + InvokeHostFunction(InvokeHostFunctionOp), + BumpFootprintExpiration(BumpFootprintExpirationOp), + RestoreFootprint(RestoreFootprintOp), } impl OperationBody { - pub const VARIANTS: [OperationType; 24] = [ + pub const VARIANTS: [OperationType; 27] = [ OperationType::CreateAccount, OperationType::Payment, OperationType::PathPaymentStrictReceive, @@ -17841,8 +26499,11 @@ impl OperationBody { OperationType::SetTrustLineFlags, OperationType::LiquidityPoolDeposit, OperationType::LiquidityPoolWithdraw, + OperationType::InvokeHostFunction, + OperationType::BumpFootprintExpiration, + OperationType::RestoreFootprint, ]; - pub const VARIANTS_STR: [&'static str; 24] = [ + pub const VARIANTS_STR: [&'static str; 27] = [ "CreateAccount", "Payment", "PathPaymentStrictReceive", @@ -17867,6 +26528,9 @@ impl OperationBody { "SetTrustLineFlags", "LiquidityPoolDeposit", "LiquidityPoolWithdraw", + "InvokeHostFunction", + "BumpFootprintExpiration", + "RestoreFootprint", ]; #[must_use] @@ -17896,6 +26560,9 @@ impl OperationBody { Self::SetTrustLineFlags(_) => "SetTrustLineFlags", Self::LiquidityPoolDeposit(_) => "LiquidityPoolDeposit", Self::LiquidityPoolWithdraw(_) => "LiquidityPoolWithdraw", + Self::InvokeHostFunction(_) => "InvokeHostFunction", + Self::BumpFootprintExpiration(_) => "BumpFootprintExpiration", + Self::RestoreFootprint(_) => "RestoreFootprint", } } @@ -17927,11 +26594,14 @@ impl OperationBody { Self::SetTrustLineFlags(_) => OperationType::SetTrustLineFlags, Self::LiquidityPoolDeposit(_) => OperationType::LiquidityPoolDeposit, Self::LiquidityPoolWithdraw(_) => OperationType::LiquidityPoolWithdraw, + Self::InvokeHostFunction(_) => OperationType::InvokeHostFunction, + Self::BumpFootprintExpiration(_) => OperationType::BumpFootprintExpiration, + Self::RestoreFootprint(_) => OperationType::RestoreFootprint, } } #[must_use] - pub const fn variants() -> [OperationType; 24] { + pub const fn variants() -> [OperationType; 27] { Self::VARIANTS } } @@ -18017,6 +26687,15 @@ impl ReadXdr for OperationBody { OperationType::LiquidityPoolWithdraw => { Self::LiquidityPoolWithdraw(LiquidityPoolWithdrawOp::read_xdr(r)?) } + OperationType::InvokeHostFunction => { + Self::InvokeHostFunction(InvokeHostFunctionOp::read_xdr(r)?) + } + OperationType::BumpFootprintExpiration => { + Self::BumpFootprintExpiration(BumpFootprintExpirationOp::read_xdr(r)?) + } + OperationType::RestoreFootprint => { + Self::RestoreFootprint(RestoreFootprintOp::read_xdr(r)?) + } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -18056,6 +26735,9 @@ impl WriteXdr for OperationBody { Self::SetTrustLineFlags(v) => v.write_xdr(w)?, Self::LiquidityPoolDeposit(v) => v.write_xdr(w)?, Self::LiquidityPoolWithdraw(v) => v.write_xdr(w)?, + Self::InvokeHostFunction(v) => v.write_xdr(w)?, + Self::BumpFootprintExpiration(v) => v.write_xdr(w)?, + Self::RestoreFootprint(v) => v.write_xdr(w)?, }; Ok(()) }) @@ -18121,6 +26803,12 @@ impl WriteXdr for OperationBody { // LiquidityPoolDepositOp liquidityPoolDepositOp; // case LIQUIDITY_POOL_WITHDRAW: // LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; +// case INVOKE_HOST_FUNCTION: +// InvokeHostFunctionOp invokeHostFunctionOp; +// case BUMP_FOOTPRINT_EXPIRATION: +// BumpFootprintExpirationOp bumpFootprintExpirationOp; +// case RESTORE_FOOTPRINT: +// RestoreFootprintOp restoreFootprintOp; // } // body; // }; @@ -18262,6 +26950,100 @@ impl WriteXdr for HashIdPreimageRevokeId { } } +// HashIdPreimageContractId is an XDR NestedStruct defines as: +// +// struct +// { +// Hash networkID; +// ContractIDPreimage contractIDPreimage; +// } +// +#[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 HashIdPreimageContractId { + pub network_id: Hash, + pub contract_id_preimage: ContractIdPreimage, +} + +impl ReadXdr for HashIdPreimageContractId { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + network_id: Hash::read_xdr(r)?, + contract_id_preimage: ContractIdPreimage::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for HashIdPreimageContractId { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.network_id.write_xdr(w)?; + self.contract_id_preimage.write_xdr(w)?; + Ok(()) + }) + } +} + +// HashIdPreimageSorobanAuthorization is an XDR NestedStruct defines as: +// +// struct +// { +// Hash networkID; +// int64 nonce; +// uint32 signatureExpirationLedger; +// SorobanAuthorizedInvocation invocation; +// } +// +#[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 HashIdPreimageSorobanAuthorization { + pub network_id: Hash, + pub nonce: i64, + pub signature_expiration_ledger: u32, + pub invocation: SorobanAuthorizedInvocation, +} + +impl ReadXdr for HashIdPreimageSorobanAuthorization { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + 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)?, + invocation: SorobanAuthorizedInvocation::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for HashIdPreimageSorobanAuthorization { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.network_id.write_xdr(w)?; + self.nonce.write_xdr(w)?; + self.signature_expiration_ledger.write_xdr(w)?; + self.invocation.write_xdr(w)?; + Ok(()) + }) + } +} + // HashIdPreimage is an XDR Union defines as: // // union HashIDPreimage switch (EnvelopeType type) @@ -18282,6 +27064,20 @@ impl WriteXdr for HashIdPreimageRevokeId { // PoolID liquidityPoolID; // Asset asset; // } revokeID; +// case ENVELOPE_TYPE_CONTRACT_ID: +// struct +// { +// Hash networkID; +// ContractIDPreimage contractIDPreimage; +// } contractID; +// case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: +// struct +// { +// Hash networkID; +// int64 nonce; +// uint32 signatureExpirationLedger; +// SorobanAuthorizedInvocation invocation; +// } sorobanAuthorization; // }; // // union with discriminant EnvelopeType @@ -18296,17 +27092,31 @@ impl WriteXdr for HashIdPreimageRevokeId { pub enum HashIdPreimage { OpId(HashIdPreimageOperationId), PoolRevokeOpId(HashIdPreimageRevokeId), + ContractId(HashIdPreimageContractId), + SorobanAuthorization(HashIdPreimageSorobanAuthorization), } impl HashIdPreimage { - pub const VARIANTS: [EnvelopeType; 2] = [EnvelopeType::OpId, EnvelopeType::PoolRevokeOpId]; - pub const VARIANTS_STR: [&'static str; 2] = ["OpId", "PoolRevokeOpId"]; + pub const VARIANTS: [EnvelopeType; 4] = [ + EnvelopeType::OpId, + EnvelopeType::PoolRevokeOpId, + EnvelopeType::ContractId, + EnvelopeType::SorobanAuthorization, + ]; + pub const VARIANTS_STR: [&'static str; 4] = [ + "OpId", + "PoolRevokeOpId", + "ContractId", + "SorobanAuthorization", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::OpId(_) => "OpId", Self::PoolRevokeOpId(_) => "PoolRevokeOpId", + Self::ContractId(_) => "ContractId", + Self::SorobanAuthorization(_) => "SorobanAuthorization", } } @@ -18316,11 +27126,13 @@ impl HashIdPreimage { match self { Self::OpId(_) => EnvelopeType::OpId, Self::PoolRevokeOpId(_) => EnvelopeType::PoolRevokeOpId, + Self::ContractId(_) => EnvelopeType::ContractId, + Self::SorobanAuthorization(_) => EnvelopeType::SorobanAuthorization, } } #[must_use] - pub const fn variants() -> [EnvelopeType; 2] { + pub const fn variants() -> [EnvelopeType; 4] { Self::VARIANTS } } @@ -18358,6 +27170,12 @@ impl ReadXdr for HashIdPreimage { EnvelopeType::PoolRevokeOpId => { Self::PoolRevokeOpId(HashIdPreimageRevokeId::read_xdr(r)?) } + EnvelopeType::ContractId => { + Self::ContractId(HashIdPreimageContractId::read_xdr(r)?) + } + EnvelopeType::SorobanAuthorization => { + Self::SorobanAuthorization(HashIdPreimageSorobanAuthorization::read_xdr(r)?) + } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -18375,6 +27193,8 @@ impl WriteXdr for HashIdPreimage { match self { Self::OpId(v) => v.write_xdr(w)?, Self::PoolRevokeOpId(v) => v.write_xdr(w)?, + Self::ContractId(v) => v.write_xdr(w)?, + Self::SorobanAuthorization(v) => v.write_xdr(w)?, }; Ok(()) }) @@ -19029,11 +27849,152 @@ impl WriteXdr for Preconditions { } } -// MaxOpsPerTx is an XDR Const defines as: +// LedgerFootprint is an XDR Struct defines as: // -// const MAX_OPS_PER_TX = 100; +// struct LedgerFootprint +// { +// LedgerKey readOnly<>; +// LedgerKey readWrite<>; +// }; // -pub const MAX_OPS_PER_TX: u64 = 100; +#[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 LedgerFootprint { + pub read_only: VecM, + pub read_write: VecM, +} + +impl ReadXdr for LedgerFootprint { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + read_only: VecM::::read_xdr(r)?, + read_write: VecM::::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for LedgerFootprint { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.read_only.write_xdr(w)?; + self.read_write.write_xdr(w)?; + Ok(()) + }) + } +} + +// SorobanResources is an XDR Struct defines as: +// +// struct SorobanResources +// { +// // The ledger footprint of the transaction. +// LedgerFootprint footprint; +// // The maximum number of instructions this transaction can use +// uint32 instructions; +// +// // The maximum number of bytes this transaction can read from ledger +// uint32 readBytes; +// // The maximum number of bytes this transaction can write to ledger +// uint32 writeBytes; +// }; +// +#[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 SorobanResources { + pub footprint: LedgerFootprint, + pub instructions: u32, + pub read_bytes: u32, + pub write_bytes: u32, +} + +impl ReadXdr for SorobanResources { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + footprint: LedgerFootprint::read_xdr(r)?, + instructions: u32::read_xdr(r)?, + read_bytes: u32::read_xdr(r)?, + write_bytes: u32::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for SorobanResources { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.footprint.write_xdr(w)?; + self.instructions.write_xdr(w)?; + self.read_bytes.write_xdr(w)?; + self.write_bytes.write_xdr(w)?; + Ok(()) + }) + } +} + +// SorobanTransactionData is an XDR Struct defines as: +// +// struct SorobanTransactionData +// { +// ExtensionPoint ext; +// SorobanResources resources; +// // Portion of transaction `fee` allocated to refundable fees. +// int64 refundableFee; +// }; +// +#[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 SorobanTransactionData { + pub ext: ExtensionPoint, + pub resources: SorobanResources, + pub refundable_fee: i64, +} + +impl ReadXdr for SorobanTransactionData { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + ext: ExtensionPoint::read_xdr(r)?, + resources: SorobanResources::read_xdr(r)?, + refundable_fee: i64::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for SorobanTransactionData { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.ext.write_xdr(w)?; + self.resources.write_xdr(w)?; + self.refundable_fee.write_xdr(w)?; + Ok(()) + }) + } +} // TransactionV0Ext is an XDR NestedUnion defines as: // @@ -19252,6 +28213,8 @@ impl WriteXdr for TransactionV0Envelope { // { // case 0: // void; +// case 1: +// SorobanTransactionData sorobanData; // } // // union with discriminant i32 @@ -19265,16 +28228,18 @@ impl WriteXdr for TransactionV0Envelope { #[allow(clippy::large_enum_variant)] pub enum TransactionExt { V0, + V1(SorobanTransactionData), } impl TransactionExt { - pub const VARIANTS: [i32; 1] = [0]; - pub const VARIANTS_STR: [&'static str; 1] = ["V0"]; + pub const VARIANTS: [i32; 2] = [0, 1]; + pub const VARIANTS_STR: [&'static str; 2] = ["V0", "V1"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::V0 => "V0", + Self::V1(_) => "V1", } } @@ -19283,11 +28248,12 @@ impl TransactionExt { #[allow(clippy::match_same_arms)] match self { Self::V0 => 0, + Self::V1(_) => 1, } } #[must_use] - pub const fn variants() -> [i32; 1] { + pub const fn variants() -> [i32; 2] { Self::VARIANTS } } @@ -19322,6 +28288,7 @@ impl ReadXdr for TransactionExt { #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { 0 => Self::V0, + 1 => Self::V1(SorobanTransactionData::read_xdr(r)?), #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -19338,6 +28305,7 @@ impl WriteXdr for TransactionExt { #[allow(clippy::match_same_arms)] match self { Self::V0 => ().write_xdr(w)?, + Self::V1(v) => v.write_xdr(w)?, }; Ok(()) }) @@ -19369,6 +28337,8 @@ impl WriteXdr for TransactionExt { // { // case 0: // void; +// case 1: +// SorobanTransactionData sorobanData; // } // ext; // }; @@ -21421,7 +30391,444 @@ impl PathPaymentStrictReceiveResult { "NoIssuer", "TooFewOffers", "OfferCrossSelf", - "OverSendmax", + "OverSendmax", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Success(_) => "Success", + Self::Malformed => "Malformed", + Self::Underfunded => "Underfunded", + Self::SrcNoTrust => "SrcNoTrust", + Self::SrcNotAuthorized => "SrcNotAuthorized", + Self::NoDestination => "NoDestination", + Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", + Self::LineFull => "LineFull", + Self::NoIssuer(_) => "NoIssuer", + Self::TooFewOffers => "TooFewOffers", + Self::OfferCrossSelf => "OfferCrossSelf", + Self::OverSendmax => "OverSendmax", + } + } + + #[must_use] + pub const fn discriminant(&self) -> PathPaymentStrictReceiveResultCode { + #[allow(clippy::match_same_arms)] + match self { + Self::Success(_) => PathPaymentStrictReceiveResultCode::Success, + Self::Malformed => PathPaymentStrictReceiveResultCode::Malformed, + Self::Underfunded => PathPaymentStrictReceiveResultCode::Underfunded, + Self::SrcNoTrust => PathPaymentStrictReceiveResultCode::SrcNoTrust, + Self::SrcNotAuthorized => PathPaymentStrictReceiveResultCode::SrcNotAuthorized, + Self::NoDestination => PathPaymentStrictReceiveResultCode::NoDestination, + Self::NoTrust => PathPaymentStrictReceiveResultCode::NoTrust, + Self::NotAuthorized => PathPaymentStrictReceiveResultCode::NotAuthorized, + Self::LineFull => PathPaymentStrictReceiveResultCode::LineFull, + Self::NoIssuer(_) => PathPaymentStrictReceiveResultCode::NoIssuer, + Self::TooFewOffers => PathPaymentStrictReceiveResultCode::TooFewOffers, + Self::OfferCrossSelf => PathPaymentStrictReceiveResultCode::OfferCrossSelf, + Self::OverSendmax => PathPaymentStrictReceiveResultCode::OverSendmax, + } + } + + #[must_use] + pub const fn variants() -> [PathPaymentStrictReceiveResultCode; 13] { + Self::VARIANTS + } +} + +impl Name for PathPaymentStrictReceiveResult { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for PathPaymentStrictReceiveResult { + #[must_use] + fn discriminant(&self) -> PathPaymentStrictReceiveResultCode { + Self::discriminant(self) + } +} + +impl Variants for PathPaymentStrictReceiveResult { + fn variants() -> slice::Iter<'static, PathPaymentStrictReceiveResultCode> { + Self::VARIANTS.iter() + } +} + +impl Union for PathPaymentStrictReceiveResult {} + +impl ReadXdr for PathPaymentStrictReceiveResult { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: PathPaymentStrictReceiveResultCode = + ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + PathPaymentStrictReceiveResultCode::Success => { + Self::Success(PathPaymentStrictReceiveResultSuccess::read_xdr(r)?) + } + PathPaymentStrictReceiveResultCode::Malformed => Self::Malformed, + PathPaymentStrictReceiveResultCode::Underfunded => Self::Underfunded, + PathPaymentStrictReceiveResultCode::SrcNoTrust => Self::SrcNoTrust, + PathPaymentStrictReceiveResultCode::SrcNotAuthorized => Self::SrcNotAuthorized, + PathPaymentStrictReceiveResultCode::NoDestination => Self::NoDestination, + PathPaymentStrictReceiveResultCode::NoTrust => Self::NoTrust, + PathPaymentStrictReceiveResultCode::NotAuthorized => Self::NotAuthorized, + PathPaymentStrictReceiveResultCode::LineFull => Self::LineFull, + PathPaymentStrictReceiveResultCode::NoIssuer => Self::NoIssuer(Asset::read_xdr(r)?), + PathPaymentStrictReceiveResultCode::TooFewOffers => Self::TooFewOffers, + PathPaymentStrictReceiveResultCode::OfferCrossSelf => Self::OfferCrossSelf, + PathPaymentStrictReceiveResultCode::OverSendmax => Self::OverSendmax, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for PathPaymentStrictReceiveResult { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Success(v) => v.write_xdr(w)?, + Self::Malformed => ().write_xdr(w)?, + Self::Underfunded => ().write_xdr(w)?, + Self::SrcNoTrust => ().write_xdr(w)?, + Self::SrcNotAuthorized => ().write_xdr(w)?, + Self::NoDestination => ().write_xdr(w)?, + Self::NoTrust => ().write_xdr(w)?, + Self::NotAuthorized => ().write_xdr(w)?, + Self::LineFull => ().write_xdr(w)?, + Self::NoIssuer(v) => v.write_xdr(w)?, + Self::TooFewOffers => ().write_xdr(w)?, + Self::OfferCrossSelf => ().write_xdr(w)?, + Self::OverSendmax => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// PathPaymentStrictSendResultCode is an XDR Enum defines as: +// +// enum PathPaymentStrictSendResultCode +// { +// // codes considered as "success" for the operation +// PATH_PAYMENT_STRICT_SEND_SUCCESS = 0, // success +// +// // codes considered as "failure" for the operation +// PATH_PAYMENT_STRICT_SEND_MALFORMED = -1, // bad input +// PATH_PAYMENT_STRICT_SEND_UNDERFUNDED = +// -2, // not enough funds in source account +// PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST = +// -3, // no trust line on source account +// PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED = +// -4, // source not authorized to transfer +// PATH_PAYMENT_STRICT_SEND_NO_DESTINATION = +// -5, // destination account does not exist +// PATH_PAYMENT_STRICT_SEND_NO_TRUST = +// -6, // dest missing a trust line for asset +// PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED = +// -7, // dest not authorized to hold asset +// PATH_PAYMENT_STRICT_SEND_LINE_FULL = -8, // dest would go above their limit +// PATH_PAYMENT_STRICT_SEND_NO_ISSUER = -9, // missing issuer on one asset +// PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS = +// -10, // not enough offers to satisfy path +// PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF = +// -11, // would cross one of its own offers +// PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN = -12 // could not satisfy destMin +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum PathPaymentStrictSendResultCode { + Success = 0, + Malformed = -1, + Underfunded = -2, + SrcNoTrust = -3, + SrcNotAuthorized = -4, + NoDestination = -5, + NoTrust = -6, + NotAuthorized = -7, + LineFull = -8, + NoIssuer = -9, + TooFewOffers = -10, + OfferCrossSelf = -11, + UnderDestmin = -12, +} + +impl PathPaymentStrictSendResultCode { + pub const VARIANTS: [PathPaymentStrictSendResultCode; 13] = [ + PathPaymentStrictSendResultCode::Success, + PathPaymentStrictSendResultCode::Malformed, + PathPaymentStrictSendResultCode::Underfunded, + PathPaymentStrictSendResultCode::SrcNoTrust, + PathPaymentStrictSendResultCode::SrcNotAuthorized, + PathPaymentStrictSendResultCode::NoDestination, + PathPaymentStrictSendResultCode::NoTrust, + PathPaymentStrictSendResultCode::NotAuthorized, + PathPaymentStrictSendResultCode::LineFull, + PathPaymentStrictSendResultCode::NoIssuer, + PathPaymentStrictSendResultCode::TooFewOffers, + PathPaymentStrictSendResultCode::OfferCrossSelf, + PathPaymentStrictSendResultCode::UnderDestmin, + ]; + pub const VARIANTS_STR: [&'static str; 13] = [ + "Success", + "Malformed", + "Underfunded", + "SrcNoTrust", + "SrcNotAuthorized", + "NoDestination", + "NoTrust", + "NotAuthorized", + "LineFull", + "NoIssuer", + "TooFewOffers", + "OfferCrossSelf", + "UnderDestmin", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Success => "Success", + Self::Malformed => "Malformed", + Self::Underfunded => "Underfunded", + Self::SrcNoTrust => "SrcNoTrust", + Self::SrcNotAuthorized => "SrcNotAuthorized", + Self::NoDestination => "NoDestination", + Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", + Self::LineFull => "LineFull", + Self::NoIssuer => "NoIssuer", + Self::TooFewOffers => "TooFewOffers", + Self::OfferCrossSelf => "OfferCrossSelf", + Self::UnderDestmin => "UnderDestmin", + } + } + + #[must_use] + pub const fn variants() -> [PathPaymentStrictSendResultCode; 13] { + Self::VARIANTS + } +} + +impl Name for PathPaymentStrictSendResultCode { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for PathPaymentStrictSendResultCode { + fn variants() -> slice::Iter<'static, PathPaymentStrictSendResultCode> { + Self::VARIANTS.iter() + } +} + +impl Enum for PathPaymentStrictSendResultCode {} + +impl fmt::Display for PathPaymentStrictSendResultCode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for PathPaymentStrictSendResultCode { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => PathPaymentStrictSendResultCode::Success, + -1 => PathPaymentStrictSendResultCode::Malformed, + -2 => PathPaymentStrictSendResultCode::Underfunded, + -3 => PathPaymentStrictSendResultCode::SrcNoTrust, + -4 => PathPaymentStrictSendResultCode::SrcNotAuthorized, + -5 => PathPaymentStrictSendResultCode::NoDestination, + -6 => PathPaymentStrictSendResultCode::NoTrust, + -7 => PathPaymentStrictSendResultCode::NotAuthorized, + -8 => PathPaymentStrictSendResultCode::LineFull, + -9 => PathPaymentStrictSendResultCode::NoIssuer, + -10 => PathPaymentStrictSendResultCode::TooFewOffers, + -11 => PathPaymentStrictSendResultCode::OfferCrossSelf, + -12 => PathPaymentStrictSendResultCode::UnderDestmin, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: PathPaymentStrictSendResultCode) -> Self { + e as Self + } +} + +impl ReadXdr for PathPaymentStrictSendResultCode { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for PathPaymentStrictSendResultCode { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// PathPaymentStrictSendResultSuccess is an XDR NestedStruct defines as: +// +// struct +// { +// ClaimAtom offers<>; +// SimplePaymentResult last; +// } +// +#[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 PathPaymentStrictSendResultSuccess { + pub offers: VecM, + pub last: SimplePaymentResult, +} + +impl ReadXdr for PathPaymentStrictSendResultSuccess { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + offers: VecM::::read_xdr(r)?, + last: SimplePaymentResult::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for PathPaymentStrictSendResultSuccess { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.offers.write_xdr(w)?; + self.last.write_xdr(w)?; + Ok(()) + }) + } +} + +// PathPaymentStrictSendResult is an XDR Union defines as: +// +// union PathPaymentStrictSendResult switch (PathPaymentStrictSendResultCode code) +// { +// case PATH_PAYMENT_STRICT_SEND_SUCCESS: +// struct +// { +// ClaimAtom offers<>; +// SimplePaymentResult last; +// } success; +// case PATH_PAYMENT_STRICT_SEND_MALFORMED: +// case PATH_PAYMENT_STRICT_SEND_UNDERFUNDED: +// case PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST: +// case PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED: +// case PATH_PAYMENT_STRICT_SEND_NO_DESTINATION: +// case PATH_PAYMENT_STRICT_SEND_NO_TRUST: +// case PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED: +// case PATH_PAYMENT_STRICT_SEND_LINE_FULL: +// void; +// case PATH_PAYMENT_STRICT_SEND_NO_ISSUER: +// Asset noIssuer; // the asset that caused the error +// case PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS: +// case PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF: +// case PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN: +// void; +// }; +// +// union with discriminant PathPaymentStrictSendResultCode +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum PathPaymentStrictSendResult { + Success(PathPaymentStrictSendResultSuccess), + Malformed, + Underfunded, + SrcNoTrust, + SrcNotAuthorized, + NoDestination, + NoTrust, + NotAuthorized, + LineFull, + NoIssuer(Asset), + TooFewOffers, + OfferCrossSelf, + UnderDestmin, +} + +impl PathPaymentStrictSendResult { + pub const VARIANTS: [PathPaymentStrictSendResultCode; 13] = [ + PathPaymentStrictSendResultCode::Success, + PathPaymentStrictSendResultCode::Malformed, + PathPaymentStrictSendResultCode::Underfunded, + PathPaymentStrictSendResultCode::SrcNoTrust, + PathPaymentStrictSendResultCode::SrcNotAuthorized, + PathPaymentStrictSendResultCode::NoDestination, + PathPaymentStrictSendResultCode::NoTrust, + PathPaymentStrictSendResultCode::NotAuthorized, + PathPaymentStrictSendResultCode::LineFull, + PathPaymentStrictSendResultCode::NoIssuer, + PathPaymentStrictSendResultCode::TooFewOffers, + PathPaymentStrictSendResultCode::OfferCrossSelf, + PathPaymentStrictSendResultCode::UnderDestmin, + ]; + pub const VARIANTS_STR: [&'static str; 13] = [ + "Success", + "Malformed", + "Underfunded", + "SrcNoTrust", + "SrcNotAuthorized", + "NoDestination", + "NoTrust", + "NotAuthorized", + "LineFull", + "NoIssuer", + "TooFewOffers", + "OfferCrossSelf", + "UnderDestmin", ]; #[must_use] @@ -21439,81 +30846,81 @@ impl PathPaymentStrictReceiveResult { Self::NoIssuer(_) => "NoIssuer", Self::TooFewOffers => "TooFewOffers", Self::OfferCrossSelf => "OfferCrossSelf", - Self::OverSendmax => "OverSendmax", + Self::UnderDestmin => "UnderDestmin", } } #[must_use] - pub const fn discriminant(&self) -> PathPaymentStrictReceiveResultCode { + pub const fn discriminant(&self) -> PathPaymentStrictSendResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success(_) => PathPaymentStrictReceiveResultCode::Success, - Self::Malformed => PathPaymentStrictReceiveResultCode::Malformed, - Self::Underfunded => PathPaymentStrictReceiveResultCode::Underfunded, - Self::SrcNoTrust => PathPaymentStrictReceiveResultCode::SrcNoTrust, - Self::SrcNotAuthorized => PathPaymentStrictReceiveResultCode::SrcNotAuthorized, - Self::NoDestination => PathPaymentStrictReceiveResultCode::NoDestination, - Self::NoTrust => PathPaymentStrictReceiveResultCode::NoTrust, - Self::NotAuthorized => PathPaymentStrictReceiveResultCode::NotAuthorized, - Self::LineFull => PathPaymentStrictReceiveResultCode::LineFull, - Self::NoIssuer(_) => PathPaymentStrictReceiveResultCode::NoIssuer, - Self::TooFewOffers => PathPaymentStrictReceiveResultCode::TooFewOffers, - Self::OfferCrossSelf => PathPaymentStrictReceiveResultCode::OfferCrossSelf, - Self::OverSendmax => PathPaymentStrictReceiveResultCode::OverSendmax, + Self::Success(_) => PathPaymentStrictSendResultCode::Success, + Self::Malformed => PathPaymentStrictSendResultCode::Malformed, + Self::Underfunded => PathPaymentStrictSendResultCode::Underfunded, + Self::SrcNoTrust => PathPaymentStrictSendResultCode::SrcNoTrust, + Self::SrcNotAuthorized => PathPaymentStrictSendResultCode::SrcNotAuthorized, + Self::NoDestination => PathPaymentStrictSendResultCode::NoDestination, + Self::NoTrust => PathPaymentStrictSendResultCode::NoTrust, + Self::NotAuthorized => PathPaymentStrictSendResultCode::NotAuthorized, + Self::LineFull => PathPaymentStrictSendResultCode::LineFull, + Self::NoIssuer(_) => PathPaymentStrictSendResultCode::NoIssuer, + Self::TooFewOffers => PathPaymentStrictSendResultCode::TooFewOffers, + Self::OfferCrossSelf => PathPaymentStrictSendResultCode::OfferCrossSelf, + Self::UnderDestmin => PathPaymentStrictSendResultCode::UnderDestmin, } } #[must_use] - pub const fn variants() -> [PathPaymentStrictReceiveResultCode; 13] { + pub const fn variants() -> [PathPaymentStrictSendResultCode; 13] { Self::VARIANTS } } -impl Name for PathPaymentStrictReceiveResult { +impl Name for PathPaymentStrictSendResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for PathPaymentStrictReceiveResult { +impl Discriminant for PathPaymentStrictSendResult { #[must_use] - fn discriminant(&self) -> PathPaymentStrictReceiveResultCode { + fn discriminant(&self) -> PathPaymentStrictSendResultCode { Self::discriminant(self) } } -impl Variants for PathPaymentStrictReceiveResult { - fn variants() -> slice::Iter<'static, PathPaymentStrictReceiveResultCode> { +impl Variants for PathPaymentStrictSendResult { + fn variants() -> slice::Iter<'static, PathPaymentStrictSendResultCode> { Self::VARIANTS.iter() } } -impl Union for PathPaymentStrictReceiveResult {} +impl Union for PathPaymentStrictSendResult {} -impl ReadXdr for PathPaymentStrictReceiveResult { +impl ReadXdr for PathPaymentStrictSendResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: PathPaymentStrictReceiveResultCode = - ::read_xdr(r)?; + let dv: PathPaymentStrictSendResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - PathPaymentStrictReceiveResultCode::Success => { - Self::Success(PathPaymentStrictReceiveResultSuccess::read_xdr(r)?) + PathPaymentStrictSendResultCode::Success => { + Self::Success(PathPaymentStrictSendResultSuccess::read_xdr(r)?) } - PathPaymentStrictReceiveResultCode::Malformed => Self::Malformed, - PathPaymentStrictReceiveResultCode::Underfunded => Self::Underfunded, - PathPaymentStrictReceiveResultCode::SrcNoTrust => Self::SrcNoTrust, - PathPaymentStrictReceiveResultCode::SrcNotAuthorized => Self::SrcNotAuthorized, - PathPaymentStrictReceiveResultCode::NoDestination => Self::NoDestination, - PathPaymentStrictReceiveResultCode::NoTrust => Self::NoTrust, - PathPaymentStrictReceiveResultCode::NotAuthorized => Self::NotAuthorized, - PathPaymentStrictReceiveResultCode::LineFull => Self::LineFull, - PathPaymentStrictReceiveResultCode::NoIssuer => Self::NoIssuer(Asset::read_xdr(r)?), - PathPaymentStrictReceiveResultCode::TooFewOffers => Self::TooFewOffers, - PathPaymentStrictReceiveResultCode::OfferCrossSelf => Self::OfferCrossSelf, - PathPaymentStrictReceiveResultCode::OverSendmax => Self::OverSendmax, + PathPaymentStrictSendResultCode::Malformed => Self::Malformed, + PathPaymentStrictSendResultCode::Underfunded => Self::Underfunded, + PathPaymentStrictSendResultCode::SrcNoTrust => Self::SrcNoTrust, + PathPaymentStrictSendResultCode::SrcNotAuthorized => Self::SrcNotAuthorized, + PathPaymentStrictSendResultCode::NoDestination => Self::NoDestination, + PathPaymentStrictSendResultCode::NoTrust => Self::NoTrust, + PathPaymentStrictSendResultCode::NotAuthorized => Self::NotAuthorized, + PathPaymentStrictSendResultCode::LineFull => Self::LineFull, + PathPaymentStrictSendResultCode::NoIssuer => Self::NoIssuer(Asset::read_xdr(r)?), + PathPaymentStrictSendResultCode::TooFewOffers => Self::TooFewOffers, + PathPaymentStrictSendResultCode::OfferCrossSelf => Self::OfferCrossSelf, + PathPaymentStrictSendResultCode::UnderDestmin => Self::UnderDestmin, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -21522,7 +30929,7 @@ impl ReadXdr for PathPaymentStrictReceiveResult { } } -impl WriteXdr for PathPaymentStrictReceiveResult { +impl WriteXdr for PathPaymentStrictSendResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -21541,41 +30948,40 @@ impl WriteXdr for PathPaymentStrictReceiveResult { Self::NoIssuer(v) => v.write_xdr(w)?, Self::TooFewOffers => ().write_xdr(w)?, Self::OfferCrossSelf => ().write_xdr(w)?, - Self::OverSendmax => ().write_xdr(w)?, + Self::UnderDestmin => ().write_xdr(w)?, }; Ok(()) }) } } -// PathPaymentStrictSendResultCode is an XDR Enum defines as: +// ManageSellOfferResultCode is an XDR Enum defines as: // -// enum PathPaymentStrictSendResultCode +// enum ManageSellOfferResultCode // { // // codes considered as "success" for the operation -// PATH_PAYMENT_STRICT_SEND_SUCCESS = 0, // success +// MANAGE_SELL_OFFER_SUCCESS = 0, // // // codes considered as "failure" for the operation -// PATH_PAYMENT_STRICT_SEND_MALFORMED = -1, // bad input -// PATH_PAYMENT_STRICT_SEND_UNDERFUNDED = -// -2, // not enough funds in source account -// PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST = -// -3, // no trust line on source account -// PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED = -// -4, // source not authorized to transfer -// PATH_PAYMENT_STRICT_SEND_NO_DESTINATION = -// -5, // destination account does not exist -// PATH_PAYMENT_STRICT_SEND_NO_TRUST = -// -6, // dest missing a trust line for asset -// PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED = -// -7, // dest not authorized to hold asset -// PATH_PAYMENT_STRICT_SEND_LINE_FULL = -8, // dest would go above their limit -// PATH_PAYMENT_STRICT_SEND_NO_ISSUER = -9, // missing issuer on one asset -// PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS = -// -10, // not enough offers to satisfy path -// PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF = -// -11, // would cross one of its own offers -// PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN = -12 // could not satisfy destMin +// MANAGE_SELL_OFFER_MALFORMED = -1, // generated offer would be invalid +// MANAGE_SELL_OFFER_SELL_NO_TRUST = +// -2, // no trust line for what we're selling +// MANAGE_SELL_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying +// MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell +// MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy +// MANAGE_SELL_OFFER_LINE_FULL = -6, // can't receive more of what it's buying +// MANAGE_SELL_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell +// MANAGE_SELL_OFFER_CROSS_SELF = +// -8, // would cross an offer from the same user +// MANAGE_SELL_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling +// MANAGE_SELL_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying +// +// // update errors +// MANAGE_SELL_OFFER_NOT_FOUND = +// -11, // offerID does not match an existing offer +// +// MANAGE_SELL_OFFER_LOW_RESERVE = +// -12 // not enough funds to create a new Offer // }; // // enum @@ -21587,52 +30993,52 @@ impl WriteXdr for PathPaymentStrictReceiveResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum PathPaymentStrictSendResultCode { +pub enum ManageSellOfferResultCode { Success = 0, Malformed = -1, - Underfunded = -2, - SrcNoTrust = -3, - SrcNotAuthorized = -4, - NoDestination = -5, - NoTrust = -6, - NotAuthorized = -7, - LineFull = -8, - NoIssuer = -9, - TooFewOffers = -10, - OfferCrossSelf = -11, - UnderDestmin = -12, + SellNoTrust = -2, + BuyNoTrust = -3, + SellNotAuthorized = -4, + BuyNotAuthorized = -5, + LineFull = -6, + Underfunded = -7, + CrossSelf = -8, + SellNoIssuer = -9, + BuyNoIssuer = -10, + NotFound = -11, + LowReserve = -12, } -impl PathPaymentStrictSendResultCode { - pub const VARIANTS: [PathPaymentStrictSendResultCode; 13] = [ - PathPaymentStrictSendResultCode::Success, - PathPaymentStrictSendResultCode::Malformed, - PathPaymentStrictSendResultCode::Underfunded, - PathPaymentStrictSendResultCode::SrcNoTrust, - PathPaymentStrictSendResultCode::SrcNotAuthorized, - PathPaymentStrictSendResultCode::NoDestination, - PathPaymentStrictSendResultCode::NoTrust, - PathPaymentStrictSendResultCode::NotAuthorized, - PathPaymentStrictSendResultCode::LineFull, - PathPaymentStrictSendResultCode::NoIssuer, - PathPaymentStrictSendResultCode::TooFewOffers, - PathPaymentStrictSendResultCode::OfferCrossSelf, - PathPaymentStrictSendResultCode::UnderDestmin, +impl ManageSellOfferResultCode { + pub const VARIANTS: [ManageSellOfferResultCode; 13] = [ + ManageSellOfferResultCode::Success, + ManageSellOfferResultCode::Malformed, + ManageSellOfferResultCode::SellNoTrust, + ManageSellOfferResultCode::BuyNoTrust, + ManageSellOfferResultCode::SellNotAuthorized, + ManageSellOfferResultCode::BuyNotAuthorized, + ManageSellOfferResultCode::LineFull, + ManageSellOfferResultCode::Underfunded, + ManageSellOfferResultCode::CrossSelf, + ManageSellOfferResultCode::SellNoIssuer, + ManageSellOfferResultCode::BuyNoIssuer, + ManageSellOfferResultCode::NotFound, + ManageSellOfferResultCode::LowReserve, ]; pub const VARIANTS_STR: [&'static str; 13] = [ "Success", "Malformed", - "Underfunded", - "SrcNoTrust", - "SrcNotAuthorized", - "NoDestination", - "NoTrust", - "NotAuthorized", + "SellNoTrust", + "BuyNoTrust", + "SellNotAuthorized", + "BuyNotAuthorized", "LineFull", - "NoIssuer", - "TooFewOffers", - "OfferCrossSelf", - "UnderDestmin", + "Underfunded", + "CrossSelf", + "SellNoIssuer", + "BuyNoIssuer", + "NotFound", + "LowReserve", ]; #[must_use] @@ -21640,65 +31046,65 @@ impl PathPaymentStrictSendResultCode { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::Underfunded => "Underfunded", - Self::SrcNoTrust => "SrcNoTrust", - Self::SrcNotAuthorized => "SrcNotAuthorized", - Self::NoDestination => "NoDestination", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", + Self::SellNoTrust => "SellNoTrust", + Self::BuyNoTrust => "BuyNoTrust", + Self::SellNotAuthorized => "SellNotAuthorized", + Self::BuyNotAuthorized => "BuyNotAuthorized", Self::LineFull => "LineFull", - Self::NoIssuer => "NoIssuer", - Self::TooFewOffers => "TooFewOffers", - Self::OfferCrossSelf => "OfferCrossSelf", - Self::UnderDestmin => "UnderDestmin", + Self::Underfunded => "Underfunded", + Self::CrossSelf => "CrossSelf", + Self::SellNoIssuer => "SellNoIssuer", + Self::BuyNoIssuer => "BuyNoIssuer", + Self::NotFound => "NotFound", + Self::LowReserve => "LowReserve", } } #[must_use] - pub const fn variants() -> [PathPaymentStrictSendResultCode; 13] { + pub const fn variants() -> [ManageSellOfferResultCode; 13] { Self::VARIANTS } } -impl Name for PathPaymentStrictSendResultCode { +impl Name for ManageSellOfferResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for PathPaymentStrictSendResultCode { - fn variants() -> slice::Iter<'static, PathPaymentStrictSendResultCode> { +impl Variants for ManageSellOfferResultCode { + fn variants() -> slice::Iter<'static, ManageSellOfferResultCode> { Self::VARIANTS.iter() } } -impl Enum for PathPaymentStrictSendResultCode {} +impl Enum for ManageSellOfferResultCode {} -impl fmt::Display for PathPaymentStrictSendResultCode { +impl fmt::Display for ManageSellOfferResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for PathPaymentStrictSendResultCode { +impl TryFrom for ManageSellOfferResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => PathPaymentStrictSendResultCode::Success, - -1 => PathPaymentStrictSendResultCode::Malformed, - -2 => PathPaymentStrictSendResultCode::Underfunded, - -3 => PathPaymentStrictSendResultCode::SrcNoTrust, - -4 => PathPaymentStrictSendResultCode::SrcNotAuthorized, - -5 => PathPaymentStrictSendResultCode::NoDestination, - -6 => PathPaymentStrictSendResultCode::NoTrust, - -7 => PathPaymentStrictSendResultCode::NotAuthorized, - -8 => PathPaymentStrictSendResultCode::LineFull, - -9 => PathPaymentStrictSendResultCode::NoIssuer, - -10 => PathPaymentStrictSendResultCode::TooFewOffers, - -11 => PathPaymentStrictSendResultCode::OfferCrossSelf, - -12 => PathPaymentStrictSendResultCode::UnderDestmin, + 0 => ManageSellOfferResultCode::Success, + -1 => ManageSellOfferResultCode::Malformed, + -2 => ManageSellOfferResultCode::SellNoTrust, + -3 => ManageSellOfferResultCode::BuyNoTrust, + -4 => ManageSellOfferResultCode::SellNotAuthorized, + -5 => ManageSellOfferResultCode::BuyNotAuthorized, + -6 => ManageSellOfferResultCode::LineFull, + -7 => ManageSellOfferResultCode::Underfunded, + -8 => ManageSellOfferResultCode::CrossSelf, + -9 => ManageSellOfferResultCode::SellNoIssuer, + -10 => ManageSellOfferResultCode::BuyNoIssuer, + -11 => ManageSellOfferResultCode::NotFound, + -12 => ManageSellOfferResultCode::LowReserve, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -21706,14 +31112,14 @@ impl TryFrom for PathPaymentStrictSendResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: PathPaymentStrictSendResultCode) -> Self { + fn from(e: ManageSellOfferResultCode) -> Self { e as Self } } -impl ReadXdr for PathPaymentStrictSendResultCode { +impl ReadXdr for ManageSellOfferResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -21724,23 +31130,259 @@ impl ReadXdr for PathPaymentStrictSendResultCode { } } -impl WriteXdr for PathPaymentStrictSendResultCode { +impl WriteXdr for ManageSellOfferResultCode { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ManageOfferEffect is an XDR Enum defines as: +// +// enum ManageOfferEffect +// { +// MANAGE_OFFER_CREATED = 0, +// MANAGE_OFFER_UPDATED = 1, +// MANAGE_OFFER_DELETED = 2 +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ManageOfferEffect { + Created = 0, + Updated = 1, + Deleted = 2, +} + +impl ManageOfferEffect { + pub const VARIANTS: [ManageOfferEffect; 3] = [ + ManageOfferEffect::Created, + ManageOfferEffect::Updated, + ManageOfferEffect::Deleted, + ]; + pub const VARIANTS_STR: [&'static str; 3] = ["Created", "Updated", "Deleted"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Created => "Created", + Self::Updated => "Updated", + Self::Deleted => "Deleted", + } + } + + #[must_use] + pub const fn variants() -> [ManageOfferEffect; 3] { + Self::VARIANTS + } +} + +impl Name for ManageOfferEffect { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ManageOfferEffect { + fn variants() -> slice::Iter<'static, ManageOfferEffect> { + Self::VARIANTS.iter() + } +} + +impl Enum for ManageOfferEffect {} + +impl fmt::Display for ManageOfferEffect { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ManageOfferEffect { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ManageOfferEffect::Created, + 1 => ManageOfferEffect::Updated, + 2 => ManageOfferEffect::Deleted, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ManageOfferEffect) -> Self { + e as Self + } +} + +impl ReadXdr for ManageOfferEffect { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ManageOfferEffect { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ManageOfferSuccessResultOffer is an XDR NestedUnion defines as: +// +// union switch (ManageOfferEffect effect) +// { +// case MANAGE_OFFER_CREATED: +// case MANAGE_OFFER_UPDATED: +// OfferEntry offer; +// case MANAGE_OFFER_DELETED: +// void; +// } +// +// union with discriminant ManageOfferEffect +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum ManageOfferSuccessResultOffer { + Created(OfferEntry), + Updated(OfferEntry), + Deleted, +} + +impl ManageOfferSuccessResultOffer { + pub const VARIANTS: [ManageOfferEffect; 3] = [ + ManageOfferEffect::Created, + ManageOfferEffect::Updated, + ManageOfferEffect::Deleted, + ]; + pub const VARIANTS_STR: [&'static str; 3] = ["Created", "Updated", "Deleted"]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Created(_) => "Created", + Self::Updated(_) => "Updated", + Self::Deleted => "Deleted", + } + } + + #[must_use] + pub const fn discriminant(&self) -> ManageOfferEffect { + #[allow(clippy::match_same_arms)] + match self { + Self::Created(_) => ManageOfferEffect::Created, + Self::Updated(_) => ManageOfferEffect::Updated, + Self::Deleted => ManageOfferEffect::Deleted, + } + } + + #[must_use] + pub const fn variants() -> [ManageOfferEffect; 3] { + Self::VARIANTS + } +} + +impl Name for ManageOfferSuccessResultOffer { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Discriminant for ManageOfferSuccessResultOffer { + #[must_use] + fn discriminant(&self) -> ManageOfferEffect { + Self::discriminant(self) + } +} + +impl Variants for ManageOfferSuccessResultOffer { + fn variants() -> slice::Iter<'static, ManageOfferEffect> { + Self::VARIANTS.iter() + } +} + +impl Union for ManageOfferSuccessResultOffer {} + +impl ReadXdr for ManageOfferSuccessResultOffer { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let dv: ManageOfferEffect = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ManageOfferEffect::Created => Self::Created(OfferEntry::read_xdr(r)?), + ManageOfferEffect::Updated => Self::Updated(OfferEntry::read_xdr(r)?), + ManageOfferEffect::Deleted => Self::Deleted, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(v) + }) + } +} + +impl WriteXdr for ManageOfferSuccessResultOffer { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Created(v) => v.write_xdr(w)?, + Self::Updated(v) => v.write_xdr(w)?, + Self::Deleted => ().write_xdr(w)?, + }; + Ok(()) }) } } -// PathPaymentStrictSendResultSuccess is an XDR NestedStruct defines as: +// ManageOfferSuccessResult is an XDR Struct defines as: // -// struct +// struct ManageOfferSuccessResult +// { +// // offers that got claimed while creating this offer +// ClaimAtom offersClaimed<>; +// +// union switch (ManageOfferEffect effect) // { -// ClaimAtom offers<>; -// SimplePaymentResult last; +// case MANAGE_OFFER_CREATED: +// case MANAGE_OFFER_UPDATED: +// OfferEntry offer; +// case MANAGE_OFFER_DELETED: +// void; // } +// offer; +// }; // #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] @@ -21749,62 +31391,56 @@ impl WriteXdr for PathPaymentStrictSendResultCode { derive(serde::Serialize, serde::Deserialize), serde(rename_all = "snake_case") )] -pub struct PathPaymentStrictSendResultSuccess { - pub offers: VecM, - pub last: SimplePaymentResult, +pub struct ManageOfferSuccessResult { + pub offers_claimed: VecM, + pub offer: ManageOfferSuccessResultOffer, } -impl ReadXdr for PathPaymentStrictSendResultSuccess { +impl ReadXdr for ManageOfferSuccessResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { Ok(Self { - offers: VecM::::read_xdr(r)?, - last: SimplePaymentResult::read_xdr(r)?, + offers_claimed: VecM::::read_xdr(r)?, + offer: ManageOfferSuccessResultOffer::read_xdr(r)?, }) }) } } -impl WriteXdr for PathPaymentStrictSendResultSuccess { +impl WriteXdr for ManageOfferSuccessResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.offers.write_xdr(w)?; - self.last.write_xdr(w)?; + self.offers_claimed.write_xdr(w)?; + self.offer.write_xdr(w)?; Ok(()) }) } } -// PathPaymentStrictSendResult is an XDR Union defines as: +// ManageSellOfferResult is an XDR Union defines as: // -// union PathPaymentStrictSendResult switch (PathPaymentStrictSendResultCode code) +// union ManageSellOfferResult switch (ManageSellOfferResultCode code) // { -// case PATH_PAYMENT_STRICT_SEND_SUCCESS: -// struct -// { -// ClaimAtom offers<>; -// SimplePaymentResult last; -// } success; -// case PATH_PAYMENT_STRICT_SEND_MALFORMED: -// case PATH_PAYMENT_STRICT_SEND_UNDERFUNDED: -// case PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST: -// case PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED: -// case PATH_PAYMENT_STRICT_SEND_NO_DESTINATION: -// case PATH_PAYMENT_STRICT_SEND_NO_TRUST: -// case PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED: -// case PATH_PAYMENT_STRICT_SEND_LINE_FULL: -// void; -// case PATH_PAYMENT_STRICT_SEND_NO_ISSUER: -// Asset noIssuer; // the asset that caused the error -// case PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS: -// case PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF: -// case PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN: +// case MANAGE_SELL_OFFER_SUCCESS: +// ManageOfferSuccessResult success; +// case MANAGE_SELL_OFFER_MALFORMED: +// case MANAGE_SELL_OFFER_SELL_NO_TRUST: +// case MANAGE_SELL_OFFER_BUY_NO_TRUST: +// case MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED: +// case MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED: +// case MANAGE_SELL_OFFER_LINE_FULL: +// case MANAGE_SELL_OFFER_UNDERFUNDED: +// case MANAGE_SELL_OFFER_CROSS_SELF: +// case MANAGE_SELL_OFFER_SELL_NO_ISSUER: +// case MANAGE_SELL_OFFER_BUY_NO_ISSUER: +// case MANAGE_SELL_OFFER_NOT_FOUND: +// case MANAGE_SELL_OFFER_LOW_RESERVE: // void; // }; // -// union with discriminant PathPaymentStrictSendResultCode +// union with discriminant ManageSellOfferResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -21813,52 +31449,52 @@ impl WriteXdr for PathPaymentStrictSendResultSuccess { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum PathPaymentStrictSendResult { - Success(PathPaymentStrictSendResultSuccess), +pub enum ManageSellOfferResult { + Success(ManageOfferSuccessResult), Malformed, - Underfunded, - SrcNoTrust, - SrcNotAuthorized, - NoDestination, - NoTrust, - NotAuthorized, + SellNoTrust, + BuyNoTrust, + SellNotAuthorized, + BuyNotAuthorized, LineFull, - NoIssuer(Asset), - TooFewOffers, - OfferCrossSelf, - UnderDestmin, + Underfunded, + CrossSelf, + SellNoIssuer, + BuyNoIssuer, + NotFound, + LowReserve, } -impl PathPaymentStrictSendResult { - pub const VARIANTS: [PathPaymentStrictSendResultCode; 13] = [ - PathPaymentStrictSendResultCode::Success, - PathPaymentStrictSendResultCode::Malformed, - PathPaymentStrictSendResultCode::Underfunded, - PathPaymentStrictSendResultCode::SrcNoTrust, - PathPaymentStrictSendResultCode::SrcNotAuthorized, - PathPaymentStrictSendResultCode::NoDestination, - PathPaymentStrictSendResultCode::NoTrust, - PathPaymentStrictSendResultCode::NotAuthorized, - PathPaymentStrictSendResultCode::LineFull, - PathPaymentStrictSendResultCode::NoIssuer, - PathPaymentStrictSendResultCode::TooFewOffers, - PathPaymentStrictSendResultCode::OfferCrossSelf, - PathPaymentStrictSendResultCode::UnderDestmin, +impl ManageSellOfferResult { + pub const VARIANTS: [ManageSellOfferResultCode; 13] = [ + ManageSellOfferResultCode::Success, + ManageSellOfferResultCode::Malformed, + ManageSellOfferResultCode::SellNoTrust, + ManageSellOfferResultCode::BuyNoTrust, + ManageSellOfferResultCode::SellNotAuthorized, + ManageSellOfferResultCode::BuyNotAuthorized, + ManageSellOfferResultCode::LineFull, + ManageSellOfferResultCode::Underfunded, + ManageSellOfferResultCode::CrossSelf, + ManageSellOfferResultCode::SellNoIssuer, + ManageSellOfferResultCode::BuyNoIssuer, + ManageSellOfferResultCode::NotFound, + ManageSellOfferResultCode::LowReserve, ]; pub const VARIANTS_STR: [&'static str; 13] = [ "Success", "Malformed", - "Underfunded", - "SrcNoTrust", - "SrcNotAuthorized", - "NoDestination", - "NoTrust", - "NotAuthorized", + "SellNoTrust", + "BuyNoTrust", + "SellNotAuthorized", + "BuyNotAuthorized", "LineFull", - "NoIssuer", - "TooFewOffers", - "OfferCrossSelf", - "UnderDestmin", + "Underfunded", + "CrossSelf", + "SellNoIssuer", + "BuyNoIssuer", + "NotFound", + "LowReserve", ]; #[must_use] @@ -21866,91 +31502,91 @@ impl PathPaymentStrictSendResult { match self { Self::Success(_) => "Success", Self::Malformed => "Malformed", - Self::Underfunded => "Underfunded", - Self::SrcNoTrust => "SrcNoTrust", - Self::SrcNotAuthorized => "SrcNotAuthorized", - Self::NoDestination => "NoDestination", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", + Self::SellNoTrust => "SellNoTrust", + Self::BuyNoTrust => "BuyNoTrust", + Self::SellNotAuthorized => "SellNotAuthorized", + Self::BuyNotAuthorized => "BuyNotAuthorized", Self::LineFull => "LineFull", - Self::NoIssuer(_) => "NoIssuer", - Self::TooFewOffers => "TooFewOffers", - Self::OfferCrossSelf => "OfferCrossSelf", - Self::UnderDestmin => "UnderDestmin", + Self::Underfunded => "Underfunded", + Self::CrossSelf => "CrossSelf", + Self::SellNoIssuer => "SellNoIssuer", + Self::BuyNoIssuer => "BuyNoIssuer", + Self::NotFound => "NotFound", + Self::LowReserve => "LowReserve", } } #[must_use] - pub const fn discriminant(&self) -> PathPaymentStrictSendResultCode { + pub const fn discriminant(&self) -> ManageSellOfferResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success(_) => PathPaymentStrictSendResultCode::Success, - Self::Malformed => PathPaymentStrictSendResultCode::Malformed, - Self::Underfunded => PathPaymentStrictSendResultCode::Underfunded, - Self::SrcNoTrust => PathPaymentStrictSendResultCode::SrcNoTrust, - Self::SrcNotAuthorized => PathPaymentStrictSendResultCode::SrcNotAuthorized, - Self::NoDestination => PathPaymentStrictSendResultCode::NoDestination, - Self::NoTrust => PathPaymentStrictSendResultCode::NoTrust, - Self::NotAuthorized => PathPaymentStrictSendResultCode::NotAuthorized, - Self::LineFull => PathPaymentStrictSendResultCode::LineFull, - Self::NoIssuer(_) => PathPaymentStrictSendResultCode::NoIssuer, - Self::TooFewOffers => PathPaymentStrictSendResultCode::TooFewOffers, - Self::OfferCrossSelf => PathPaymentStrictSendResultCode::OfferCrossSelf, - Self::UnderDestmin => PathPaymentStrictSendResultCode::UnderDestmin, + Self::Success(_) => ManageSellOfferResultCode::Success, + Self::Malformed => ManageSellOfferResultCode::Malformed, + Self::SellNoTrust => ManageSellOfferResultCode::SellNoTrust, + Self::BuyNoTrust => ManageSellOfferResultCode::BuyNoTrust, + Self::SellNotAuthorized => ManageSellOfferResultCode::SellNotAuthorized, + Self::BuyNotAuthorized => ManageSellOfferResultCode::BuyNotAuthorized, + Self::LineFull => ManageSellOfferResultCode::LineFull, + Self::Underfunded => ManageSellOfferResultCode::Underfunded, + Self::CrossSelf => ManageSellOfferResultCode::CrossSelf, + Self::SellNoIssuer => ManageSellOfferResultCode::SellNoIssuer, + Self::BuyNoIssuer => ManageSellOfferResultCode::BuyNoIssuer, + Self::NotFound => ManageSellOfferResultCode::NotFound, + Self::LowReserve => ManageSellOfferResultCode::LowReserve, } } #[must_use] - pub const fn variants() -> [PathPaymentStrictSendResultCode; 13] { + pub const fn variants() -> [ManageSellOfferResultCode; 13] { Self::VARIANTS } } -impl Name for PathPaymentStrictSendResult { +impl Name for ManageSellOfferResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for PathPaymentStrictSendResult { +impl Discriminant for ManageSellOfferResult { #[must_use] - fn discriminant(&self) -> PathPaymentStrictSendResultCode { + fn discriminant(&self) -> ManageSellOfferResultCode { Self::discriminant(self) } } -impl Variants for PathPaymentStrictSendResult { - fn variants() -> slice::Iter<'static, PathPaymentStrictSendResultCode> { +impl Variants for ManageSellOfferResult { + fn variants() -> slice::Iter<'static, ManageSellOfferResultCode> { Self::VARIANTS.iter() } } -impl Union for PathPaymentStrictSendResult {} +impl Union for ManageSellOfferResult {} -impl ReadXdr for PathPaymentStrictSendResult { +impl ReadXdr for ManageSellOfferResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: PathPaymentStrictSendResultCode = - ::read_xdr(r)?; + let dv: ManageSellOfferResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - PathPaymentStrictSendResultCode::Success => { - Self::Success(PathPaymentStrictSendResultSuccess::read_xdr(r)?) + ManageSellOfferResultCode::Success => { + Self::Success(ManageOfferSuccessResult::read_xdr(r)?) } - PathPaymentStrictSendResultCode::Malformed => Self::Malformed, - PathPaymentStrictSendResultCode::Underfunded => Self::Underfunded, - PathPaymentStrictSendResultCode::SrcNoTrust => Self::SrcNoTrust, - PathPaymentStrictSendResultCode::SrcNotAuthorized => Self::SrcNotAuthorized, - PathPaymentStrictSendResultCode::NoDestination => Self::NoDestination, - PathPaymentStrictSendResultCode::NoTrust => Self::NoTrust, - PathPaymentStrictSendResultCode::NotAuthorized => Self::NotAuthorized, - PathPaymentStrictSendResultCode::LineFull => Self::LineFull, - PathPaymentStrictSendResultCode::NoIssuer => Self::NoIssuer(Asset::read_xdr(r)?), - PathPaymentStrictSendResultCode::TooFewOffers => Self::TooFewOffers, - PathPaymentStrictSendResultCode::OfferCrossSelf => Self::OfferCrossSelf, - PathPaymentStrictSendResultCode::UnderDestmin => Self::UnderDestmin, + ManageSellOfferResultCode::Malformed => Self::Malformed, + ManageSellOfferResultCode::SellNoTrust => Self::SellNoTrust, + ManageSellOfferResultCode::BuyNoTrust => Self::BuyNoTrust, + ManageSellOfferResultCode::SellNotAuthorized => Self::SellNotAuthorized, + ManageSellOfferResultCode::BuyNotAuthorized => Self::BuyNotAuthorized, + ManageSellOfferResultCode::LineFull => Self::LineFull, + ManageSellOfferResultCode::Underfunded => Self::Underfunded, + ManageSellOfferResultCode::CrossSelf => Self::CrossSelf, + ManageSellOfferResultCode::SellNoIssuer => Self::SellNoIssuer, + ManageSellOfferResultCode::BuyNoIssuer => Self::BuyNoIssuer, + ManageSellOfferResultCode::NotFound => Self::NotFound, + ManageSellOfferResultCode::LowReserve => Self::LowReserve, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -21959,7 +31595,7 @@ impl ReadXdr for PathPaymentStrictSendResult { } } -impl WriteXdr for PathPaymentStrictSendResult { +impl WriteXdr for ManageSellOfferResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -21968,50 +31604,47 @@ impl WriteXdr for PathPaymentStrictSendResult { match self { Self::Success(v) => v.write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::Underfunded => ().write_xdr(w)?, - Self::SrcNoTrust => ().write_xdr(w)?, - Self::SrcNotAuthorized => ().write_xdr(w)?, - Self::NoDestination => ().write_xdr(w)?, - Self::NoTrust => ().write_xdr(w)?, - Self::NotAuthorized => ().write_xdr(w)?, + Self::SellNoTrust => ().write_xdr(w)?, + Self::BuyNoTrust => ().write_xdr(w)?, + Self::SellNotAuthorized => ().write_xdr(w)?, + Self::BuyNotAuthorized => ().write_xdr(w)?, Self::LineFull => ().write_xdr(w)?, - Self::NoIssuer(v) => v.write_xdr(w)?, - Self::TooFewOffers => ().write_xdr(w)?, - Self::OfferCrossSelf => ().write_xdr(w)?, - Self::UnderDestmin => ().write_xdr(w)?, + Self::Underfunded => ().write_xdr(w)?, + Self::CrossSelf => ().write_xdr(w)?, + Self::SellNoIssuer => ().write_xdr(w)?, + Self::BuyNoIssuer => ().write_xdr(w)?, + Self::NotFound => ().write_xdr(w)?, + Self::LowReserve => ().write_xdr(w)?, }; Ok(()) }) } } -// ManageSellOfferResultCode is an XDR Enum defines as: +// ManageBuyOfferResultCode is an XDR Enum defines as: // -// enum ManageSellOfferResultCode +// enum ManageBuyOfferResultCode // { // // codes considered as "success" for the operation -// MANAGE_SELL_OFFER_SUCCESS = 0, +// MANAGE_BUY_OFFER_SUCCESS = 0, // // // codes considered as "failure" for the operation -// MANAGE_SELL_OFFER_MALFORMED = -1, // generated offer would be invalid -// MANAGE_SELL_OFFER_SELL_NO_TRUST = -// -2, // no trust line for what we're selling -// MANAGE_SELL_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying -// MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell -// MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy -// MANAGE_SELL_OFFER_LINE_FULL = -6, // can't receive more of what it's buying -// MANAGE_SELL_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell -// MANAGE_SELL_OFFER_CROSS_SELF = -// -8, // would cross an offer from the same user -// MANAGE_SELL_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling -// MANAGE_SELL_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying +// MANAGE_BUY_OFFER_MALFORMED = -1, // generated offer would be invalid +// MANAGE_BUY_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling +// MANAGE_BUY_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying +// MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell +// MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy +// MANAGE_BUY_OFFER_LINE_FULL = -6, // can't receive more of what it's buying +// MANAGE_BUY_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell +// MANAGE_BUY_OFFER_CROSS_SELF = -8, // would cross an offer from the same user +// MANAGE_BUY_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling +// MANAGE_BUY_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying // // // update errors -// MANAGE_SELL_OFFER_NOT_FOUND = +// MANAGE_BUY_OFFER_NOT_FOUND = // -11, // offerID does not match an existing offer // -// MANAGE_SELL_OFFER_LOW_RESERVE = -// -12 // not enough funds to create a new Offer +// MANAGE_BUY_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer // }; // // enum @@ -22023,7 +31656,7 @@ impl WriteXdr for PathPaymentStrictSendResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ManageSellOfferResultCode { +pub enum ManageBuyOfferResultCode { Success = 0, Malformed = -1, SellNoTrust = -2, @@ -22039,21 +31672,198 @@ pub enum ManageSellOfferResultCode { LowReserve = -12, } -impl ManageSellOfferResultCode { - pub const VARIANTS: [ManageSellOfferResultCode; 13] = [ - ManageSellOfferResultCode::Success, - ManageSellOfferResultCode::Malformed, - ManageSellOfferResultCode::SellNoTrust, - ManageSellOfferResultCode::BuyNoTrust, - ManageSellOfferResultCode::SellNotAuthorized, - ManageSellOfferResultCode::BuyNotAuthorized, - ManageSellOfferResultCode::LineFull, - ManageSellOfferResultCode::Underfunded, - ManageSellOfferResultCode::CrossSelf, - ManageSellOfferResultCode::SellNoIssuer, - ManageSellOfferResultCode::BuyNoIssuer, - ManageSellOfferResultCode::NotFound, - ManageSellOfferResultCode::LowReserve, +impl ManageBuyOfferResultCode { + pub const VARIANTS: [ManageBuyOfferResultCode; 13] = [ + ManageBuyOfferResultCode::Success, + ManageBuyOfferResultCode::Malformed, + ManageBuyOfferResultCode::SellNoTrust, + ManageBuyOfferResultCode::BuyNoTrust, + ManageBuyOfferResultCode::SellNotAuthorized, + ManageBuyOfferResultCode::BuyNotAuthorized, + ManageBuyOfferResultCode::LineFull, + ManageBuyOfferResultCode::Underfunded, + ManageBuyOfferResultCode::CrossSelf, + ManageBuyOfferResultCode::SellNoIssuer, + ManageBuyOfferResultCode::BuyNoIssuer, + ManageBuyOfferResultCode::NotFound, + ManageBuyOfferResultCode::LowReserve, + ]; + pub const VARIANTS_STR: [&'static str; 13] = [ + "Success", + "Malformed", + "SellNoTrust", + "BuyNoTrust", + "SellNotAuthorized", + "BuyNotAuthorized", + "LineFull", + "Underfunded", + "CrossSelf", + "SellNoIssuer", + "BuyNoIssuer", + "NotFound", + "LowReserve", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Success => "Success", + Self::Malformed => "Malformed", + Self::SellNoTrust => "SellNoTrust", + Self::BuyNoTrust => "BuyNoTrust", + Self::SellNotAuthorized => "SellNotAuthorized", + Self::BuyNotAuthorized => "BuyNotAuthorized", + Self::LineFull => "LineFull", + Self::Underfunded => "Underfunded", + Self::CrossSelf => "CrossSelf", + Self::SellNoIssuer => "SellNoIssuer", + Self::BuyNoIssuer => "BuyNoIssuer", + Self::NotFound => "NotFound", + Self::LowReserve => "LowReserve", + } + } + + #[must_use] + pub const fn variants() -> [ManageBuyOfferResultCode; 13] { + Self::VARIANTS + } +} + +impl Name for ManageBuyOfferResultCode { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ManageBuyOfferResultCode { + fn variants() -> slice::Iter<'static, ManageBuyOfferResultCode> { + Self::VARIANTS.iter() + } +} + +impl Enum for ManageBuyOfferResultCode {} + +impl fmt::Display for ManageBuyOfferResultCode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ManageBuyOfferResultCode { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ManageBuyOfferResultCode::Success, + -1 => ManageBuyOfferResultCode::Malformed, + -2 => ManageBuyOfferResultCode::SellNoTrust, + -3 => ManageBuyOfferResultCode::BuyNoTrust, + -4 => ManageBuyOfferResultCode::SellNotAuthorized, + -5 => ManageBuyOfferResultCode::BuyNotAuthorized, + -6 => ManageBuyOfferResultCode::LineFull, + -7 => ManageBuyOfferResultCode::Underfunded, + -8 => ManageBuyOfferResultCode::CrossSelf, + -9 => ManageBuyOfferResultCode::SellNoIssuer, + -10 => ManageBuyOfferResultCode::BuyNoIssuer, + -11 => ManageBuyOfferResultCode::NotFound, + -12 => ManageBuyOfferResultCode::LowReserve, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) + } +} + +impl From for i32 { + #[must_use] + fn from(e: ManageBuyOfferResultCode) -> Self { + e as Self + } +} + +impl ReadXdr for ManageBuyOfferResultCode { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) + }) + } +} + +impl WriteXdr for ManageBuyOfferResultCode { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + let i: i32 = (*self).into(); + i.write_xdr(w) + }) + } +} + +// ManageBuyOfferResult is an XDR Union defines as: +// +// union ManageBuyOfferResult switch (ManageBuyOfferResultCode code) +// { +// case MANAGE_BUY_OFFER_SUCCESS: +// ManageOfferSuccessResult success; +// case MANAGE_BUY_OFFER_MALFORMED: +// case MANAGE_BUY_OFFER_SELL_NO_TRUST: +// case MANAGE_BUY_OFFER_BUY_NO_TRUST: +// case MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED: +// case MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED: +// case MANAGE_BUY_OFFER_LINE_FULL: +// case MANAGE_BUY_OFFER_UNDERFUNDED: +// case MANAGE_BUY_OFFER_CROSS_SELF: +// case MANAGE_BUY_OFFER_SELL_NO_ISSUER: +// case MANAGE_BUY_OFFER_BUY_NO_ISSUER: +// case MANAGE_BUY_OFFER_NOT_FOUND: +// case MANAGE_BUY_OFFER_LOW_RESERVE: +// void; +// }; +// +// union with discriminant ManageBuyOfferResultCode +#[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") +)] +#[allow(clippy::large_enum_variant)] +pub enum ManageBuyOfferResult { + Success(ManageOfferSuccessResult), + Malformed, + SellNoTrust, + BuyNoTrust, + SellNotAuthorized, + BuyNotAuthorized, + LineFull, + Underfunded, + CrossSelf, + SellNoIssuer, + BuyNoIssuer, + NotFound, + LowReserve, +} + +impl ManageBuyOfferResult { + pub const VARIANTS: [ManageBuyOfferResultCode; 13] = [ + ManageBuyOfferResultCode::Success, + ManageBuyOfferResultCode::Malformed, + ManageBuyOfferResultCode::SellNoTrust, + ManageBuyOfferResultCode::BuyNoTrust, + ManageBuyOfferResultCode::SellNotAuthorized, + ManageBuyOfferResultCode::BuyNotAuthorized, + ManageBuyOfferResultCode::LineFull, + ManageBuyOfferResultCode::Underfunded, + ManageBuyOfferResultCode::CrossSelf, + ManageBuyOfferResultCode::SellNoIssuer, + ManageBuyOfferResultCode::BuyNoIssuer, + ManageBuyOfferResultCode::NotFound, + ManageBuyOfferResultCode::LowReserve, ]; pub const VARIANTS_STR: [&'static str; 13] = [ "Success", @@ -22074,7 +31884,7 @@ impl ManageSellOfferResultCode { #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success => "Success", + Self::Success(_) => "Success", Self::Malformed => "Malformed", Self::SellNoTrust => "SellNoTrust", Self::BuyNoTrust => "BuyNoTrust", @@ -22091,92 +31901,127 @@ impl ManageSellOfferResultCode { } #[must_use] - pub const fn variants() -> [ManageSellOfferResultCode; 13] { + pub const fn discriminant(&self) -> ManageBuyOfferResultCode { + #[allow(clippy::match_same_arms)] + match self { + Self::Success(_) => ManageBuyOfferResultCode::Success, + Self::Malformed => ManageBuyOfferResultCode::Malformed, + Self::SellNoTrust => ManageBuyOfferResultCode::SellNoTrust, + Self::BuyNoTrust => ManageBuyOfferResultCode::BuyNoTrust, + Self::SellNotAuthorized => ManageBuyOfferResultCode::SellNotAuthorized, + Self::BuyNotAuthorized => ManageBuyOfferResultCode::BuyNotAuthorized, + Self::LineFull => ManageBuyOfferResultCode::LineFull, + Self::Underfunded => ManageBuyOfferResultCode::Underfunded, + Self::CrossSelf => ManageBuyOfferResultCode::CrossSelf, + Self::SellNoIssuer => ManageBuyOfferResultCode::SellNoIssuer, + Self::BuyNoIssuer => ManageBuyOfferResultCode::BuyNoIssuer, + Self::NotFound => ManageBuyOfferResultCode::NotFound, + Self::LowReserve => ManageBuyOfferResultCode::LowReserve, + } + } + + #[must_use] + pub const fn variants() -> [ManageBuyOfferResultCode; 13] { Self::VARIANTS } } -impl Name for ManageSellOfferResultCode { +impl Name for ManageBuyOfferResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ManageSellOfferResultCode { - fn variants() -> slice::Iter<'static, ManageSellOfferResultCode> { - Self::VARIANTS.iter() - } -} - -impl Enum for ManageSellOfferResultCode {} - -impl fmt::Display for ManageSellOfferResultCode { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.name()) +impl Discriminant for ManageBuyOfferResult { + #[must_use] + fn discriminant(&self) -> ManageBuyOfferResultCode { + Self::discriminant(self) } } -impl TryFrom for ManageSellOfferResultCode { - type Error = Error; - - fn try_from(i: i32) -> Result { - let e = match i { - 0 => ManageSellOfferResultCode::Success, - -1 => ManageSellOfferResultCode::Malformed, - -2 => ManageSellOfferResultCode::SellNoTrust, - -3 => ManageSellOfferResultCode::BuyNoTrust, - -4 => ManageSellOfferResultCode::SellNotAuthorized, - -5 => ManageSellOfferResultCode::BuyNotAuthorized, - -6 => ManageSellOfferResultCode::LineFull, - -7 => ManageSellOfferResultCode::Underfunded, - -8 => ManageSellOfferResultCode::CrossSelf, - -9 => ManageSellOfferResultCode::SellNoIssuer, - -10 => ManageSellOfferResultCode::BuyNoIssuer, - -11 => ManageSellOfferResultCode::NotFound, - -12 => ManageSellOfferResultCode::LowReserve, - #[allow(unreachable_patterns)] - _ => return Err(Error::Invalid), - }; - Ok(e) +impl Variants for ManageBuyOfferResult { + fn variants() -> slice::Iter<'static, ManageBuyOfferResultCode> { + Self::VARIANTS.iter() } } -impl From for i32 { - #[must_use] - fn from(e: ManageSellOfferResultCode) -> Self { - e as Self - } -} +impl Union for ManageBuyOfferResult {} -impl ReadXdr for ManageSellOfferResultCode { +impl ReadXdr for ManageBuyOfferResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let e = i32::read_xdr(r)?; - let v: Self = e.try_into()?; + let dv: ManageBuyOfferResultCode = ::read_xdr(r)?; + #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] + let v = match dv { + ManageBuyOfferResultCode::Success => { + Self::Success(ManageOfferSuccessResult::read_xdr(r)?) + } + ManageBuyOfferResultCode::Malformed => Self::Malformed, + ManageBuyOfferResultCode::SellNoTrust => Self::SellNoTrust, + ManageBuyOfferResultCode::BuyNoTrust => Self::BuyNoTrust, + ManageBuyOfferResultCode::SellNotAuthorized => Self::SellNotAuthorized, + ManageBuyOfferResultCode::BuyNotAuthorized => Self::BuyNotAuthorized, + ManageBuyOfferResultCode::LineFull => Self::LineFull, + ManageBuyOfferResultCode::Underfunded => Self::Underfunded, + ManageBuyOfferResultCode::CrossSelf => Self::CrossSelf, + ManageBuyOfferResultCode::SellNoIssuer => Self::SellNoIssuer, + ManageBuyOfferResultCode::BuyNoIssuer => Self::BuyNoIssuer, + ManageBuyOfferResultCode::NotFound => Self::NotFound, + ManageBuyOfferResultCode::LowReserve => Self::LowReserve, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; Ok(v) }) } } -impl WriteXdr for ManageSellOfferResultCode { +impl WriteXdr for ManageBuyOfferResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - let i: i32 = (*self).into(); - i.write_xdr(w) + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Success(v) => v.write_xdr(w)?, + Self::Malformed => ().write_xdr(w)?, + Self::SellNoTrust => ().write_xdr(w)?, + Self::BuyNoTrust => ().write_xdr(w)?, + Self::SellNotAuthorized => ().write_xdr(w)?, + Self::BuyNotAuthorized => ().write_xdr(w)?, + Self::LineFull => ().write_xdr(w)?, + Self::Underfunded => ().write_xdr(w)?, + Self::CrossSelf => ().write_xdr(w)?, + Self::SellNoIssuer => ().write_xdr(w)?, + Self::BuyNoIssuer => ().write_xdr(w)?, + Self::NotFound => ().write_xdr(w)?, + Self::LowReserve => ().write_xdr(w)?, + }; + Ok(()) }) } } -// ManageOfferEffect is an XDR Enum defines as: +// SetOptionsResultCode is an XDR Enum defines as: // -// enum ManageOfferEffect +// enum SetOptionsResultCode // { -// MANAGE_OFFER_CREATED = 0, -// MANAGE_OFFER_UPDATED = 1, -// MANAGE_OFFER_DELETED = 2 +// // codes considered as "success" for the operation +// SET_OPTIONS_SUCCESS = 0, +// // codes considered as "failure" for the operation +// SET_OPTIONS_LOW_RESERVE = -1, // not enough funds to add a signer +// SET_OPTIONS_TOO_MANY_SIGNERS = -2, // max number of signers already reached +// SET_OPTIONS_BAD_FLAGS = -3, // invalid combination of clear/set flags +// SET_OPTIONS_INVALID_INFLATION = -4, // inflation account does not exist +// SET_OPTIONS_CANT_CHANGE = -5, // can no longer change this option +// SET_OPTIONS_UNKNOWN_FLAG = -6, // can't set an unknown flag +// SET_OPTIONS_THRESHOLD_OUT_OF_RANGE = -7, // bad value for weight/threshold +// SET_OPTIONS_BAD_SIGNER = -8, // signer cannot be masterkey +// SET_OPTIONS_INVALID_HOME_DOMAIN = -9, // malformed home domain +// SET_OPTIONS_AUTH_REVOCABLE_REQUIRED = +// -10 // auth revocable is required for clawback // }; // // enum @@ -22188,64 +32033,108 @@ impl WriteXdr for ManageSellOfferResultCode { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ManageOfferEffect { - Created = 0, - Updated = 1, - Deleted = 2, +pub enum SetOptionsResultCode { + Success = 0, + LowReserve = -1, + TooManySigners = -2, + BadFlags = -3, + InvalidInflation = -4, + CantChange = -5, + UnknownFlag = -6, + ThresholdOutOfRange = -7, + BadSigner = -8, + InvalidHomeDomain = -9, + AuthRevocableRequired = -10, } -impl ManageOfferEffect { - pub const VARIANTS: [ManageOfferEffect; 3] = [ - ManageOfferEffect::Created, - ManageOfferEffect::Updated, - ManageOfferEffect::Deleted, +impl SetOptionsResultCode { + pub const VARIANTS: [SetOptionsResultCode; 11] = [ + SetOptionsResultCode::Success, + SetOptionsResultCode::LowReserve, + SetOptionsResultCode::TooManySigners, + SetOptionsResultCode::BadFlags, + SetOptionsResultCode::InvalidInflation, + SetOptionsResultCode::CantChange, + SetOptionsResultCode::UnknownFlag, + SetOptionsResultCode::ThresholdOutOfRange, + SetOptionsResultCode::BadSigner, + SetOptionsResultCode::InvalidHomeDomain, + SetOptionsResultCode::AuthRevocableRequired, + ]; + pub const VARIANTS_STR: [&'static str; 11] = [ + "Success", + "LowReserve", + "TooManySigners", + "BadFlags", + "InvalidInflation", + "CantChange", + "UnknownFlag", + "ThresholdOutOfRange", + "BadSigner", + "InvalidHomeDomain", + "AuthRevocableRequired", ]; - pub const VARIANTS_STR: [&'static str; 3] = ["Created", "Updated", "Deleted"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Created => "Created", - Self::Updated => "Updated", - Self::Deleted => "Deleted", + Self::Success => "Success", + Self::LowReserve => "LowReserve", + Self::TooManySigners => "TooManySigners", + Self::BadFlags => "BadFlags", + Self::InvalidInflation => "InvalidInflation", + Self::CantChange => "CantChange", + Self::UnknownFlag => "UnknownFlag", + Self::ThresholdOutOfRange => "ThresholdOutOfRange", + Self::BadSigner => "BadSigner", + Self::InvalidHomeDomain => "InvalidHomeDomain", + Self::AuthRevocableRequired => "AuthRevocableRequired", } } #[must_use] - pub const fn variants() -> [ManageOfferEffect; 3] { + pub const fn variants() -> [SetOptionsResultCode; 11] { Self::VARIANTS } } -impl Name for ManageOfferEffect { +impl Name for SetOptionsResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ManageOfferEffect { - fn variants() -> slice::Iter<'static, ManageOfferEffect> { +impl Variants for SetOptionsResultCode { + fn variants() -> slice::Iter<'static, SetOptionsResultCode> { Self::VARIANTS.iter() } } -impl Enum for ManageOfferEffect {} +impl Enum for SetOptionsResultCode {} -impl fmt::Display for ManageOfferEffect { +impl fmt::Display for SetOptionsResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for ManageOfferEffect { +impl TryFrom for SetOptionsResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => ManageOfferEffect::Created, - 1 => ManageOfferEffect::Updated, - 2 => ManageOfferEffect::Deleted, + 0 => SetOptionsResultCode::Success, + -1 => SetOptionsResultCode::LowReserve, + -2 => SetOptionsResultCode::TooManySigners, + -3 => SetOptionsResultCode::BadFlags, + -4 => SetOptionsResultCode::InvalidInflation, + -5 => SetOptionsResultCode::CantChange, + -6 => SetOptionsResultCode::UnknownFlag, + -7 => SetOptionsResultCode::ThresholdOutOfRange, + -8 => SetOptionsResultCode::BadSigner, + -9 => SetOptionsResultCode::InvalidHomeDomain, + -10 => SetOptionsResultCode::AuthRevocableRequired, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -22253,14 +32142,14 @@ impl TryFrom for ManageOfferEffect { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: ManageOfferEffect) -> Self { + fn from(e: SetOptionsResultCode) -> Self { e as Self } } -impl ReadXdr for ManageOfferEffect { +impl ReadXdr for SetOptionsResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -22271,7 +32160,7 @@ impl ReadXdr for ManageOfferEffect { } } -impl WriteXdr for ManageOfferEffect { +impl WriteXdr for SetOptionsResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -22281,18 +32170,26 @@ impl WriteXdr for ManageOfferEffect { } } -// ManageOfferSuccessResultOffer is an XDR NestedUnion defines as: +// SetOptionsResult is an XDR Union defines as: // -// union switch (ManageOfferEffect effect) -// { -// case MANAGE_OFFER_CREATED: -// case MANAGE_OFFER_UPDATED: -// OfferEntry offer; -// case MANAGE_OFFER_DELETED: -// void; -// } +// union SetOptionsResult switch (SetOptionsResultCode code) +// { +// case SET_OPTIONS_SUCCESS: +// void; +// case SET_OPTIONS_LOW_RESERVE: +// case SET_OPTIONS_TOO_MANY_SIGNERS: +// case SET_OPTIONS_BAD_FLAGS: +// case SET_OPTIONS_INVALID_INFLATION: +// case SET_OPTIONS_CANT_CHANGE: +// case SET_OPTIONS_UNKNOWN_FLAG: +// case SET_OPTIONS_THRESHOLD_OUT_OF_RANGE: +// case SET_OPTIONS_BAD_SIGNER: +// case SET_OPTIONS_INVALID_HOME_DOMAIN: +// case SET_OPTIONS_AUTH_REVOCABLE_REQUIRED: +// void; +// }; // -// union with discriminant ManageOfferEffect +// union with discriminant SetOptionsResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -22301,77 +32198,129 @@ impl WriteXdr for ManageOfferEffect { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ManageOfferSuccessResultOffer { - Created(OfferEntry), - Updated(OfferEntry), - Deleted, +pub enum SetOptionsResult { + Success, + LowReserve, + TooManySigners, + BadFlags, + InvalidInflation, + CantChange, + UnknownFlag, + ThresholdOutOfRange, + BadSigner, + InvalidHomeDomain, + AuthRevocableRequired, } -impl ManageOfferSuccessResultOffer { - pub const VARIANTS: [ManageOfferEffect; 3] = [ - ManageOfferEffect::Created, - ManageOfferEffect::Updated, - ManageOfferEffect::Deleted, +impl SetOptionsResult { + pub const VARIANTS: [SetOptionsResultCode; 11] = [ + SetOptionsResultCode::Success, + SetOptionsResultCode::LowReserve, + SetOptionsResultCode::TooManySigners, + SetOptionsResultCode::BadFlags, + SetOptionsResultCode::InvalidInflation, + SetOptionsResultCode::CantChange, + SetOptionsResultCode::UnknownFlag, + SetOptionsResultCode::ThresholdOutOfRange, + SetOptionsResultCode::BadSigner, + SetOptionsResultCode::InvalidHomeDomain, + SetOptionsResultCode::AuthRevocableRequired, + ]; + pub const VARIANTS_STR: [&'static str; 11] = [ + "Success", + "LowReserve", + "TooManySigners", + "BadFlags", + "InvalidInflation", + "CantChange", + "UnknownFlag", + "ThresholdOutOfRange", + "BadSigner", + "InvalidHomeDomain", + "AuthRevocableRequired", ]; - pub const VARIANTS_STR: [&'static str; 3] = ["Created", "Updated", "Deleted"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Created(_) => "Created", - Self::Updated(_) => "Updated", - Self::Deleted => "Deleted", + Self::Success => "Success", + Self::LowReserve => "LowReserve", + Self::TooManySigners => "TooManySigners", + Self::BadFlags => "BadFlags", + Self::InvalidInflation => "InvalidInflation", + Self::CantChange => "CantChange", + Self::UnknownFlag => "UnknownFlag", + Self::ThresholdOutOfRange => "ThresholdOutOfRange", + Self::BadSigner => "BadSigner", + Self::InvalidHomeDomain => "InvalidHomeDomain", + Self::AuthRevocableRequired => "AuthRevocableRequired", } } #[must_use] - pub const fn discriminant(&self) -> ManageOfferEffect { + pub const fn discriminant(&self) -> SetOptionsResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Created(_) => ManageOfferEffect::Created, - Self::Updated(_) => ManageOfferEffect::Updated, - Self::Deleted => ManageOfferEffect::Deleted, + Self::Success => SetOptionsResultCode::Success, + Self::LowReserve => SetOptionsResultCode::LowReserve, + Self::TooManySigners => SetOptionsResultCode::TooManySigners, + Self::BadFlags => SetOptionsResultCode::BadFlags, + Self::InvalidInflation => SetOptionsResultCode::InvalidInflation, + Self::CantChange => SetOptionsResultCode::CantChange, + Self::UnknownFlag => SetOptionsResultCode::UnknownFlag, + Self::ThresholdOutOfRange => SetOptionsResultCode::ThresholdOutOfRange, + Self::BadSigner => SetOptionsResultCode::BadSigner, + Self::InvalidHomeDomain => SetOptionsResultCode::InvalidHomeDomain, + Self::AuthRevocableRequired => SetOptionsResultCode::AuthRevocableRequired, } } #[must_use] - pub const fn variants() -> [ManageOfferEffect; 3] { + pub const fn variants() -> [SetOptionsResultCode; 11] { Self::VARIANTS } } -impl Name for ManageOfferSuccessResultOffer { +impl Name for SetOptionsResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ManageOfferSuccessResultOffer { +impl Discriminant for SetOptionsResult { #[must_use] - fn discriminant(&self) -> ManageOfferEffect { + fn discriminant(&self) -> SetOptionsResultCode { Self::discriminant(self) } } -impl Variants for ManageOfferSuccessResultOffer { - fn variants() -> slice::Iter<'static, ManageOfferEffect> { +impl Variants for SetOptionsResult { + fn variants() -> slice::Iter<'static, SetOptionsResultCode> { Self::VARIANTS.iter() } } -impl Union for ManageOfferSuccessResultOffer {} +impl Union for SetOptionsResult {} -impl ReadXdr for ManageOfferSuccessResultOffer { +impl ReadXdr for SetOptionsResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ManageOfferEffect = ::read_xdr(r)?; + let dv: SetOptionsResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ManageOfferEffect::Created => Self::Created(OfferEntry::read_xdr(r)?), - ManageOfferEffect::Updated => Self::Updated(OfferEntry::read_xdr(r)?), - ManageOfferEffect::Deleted => Self::Deleted, + SetOptionsResultCode::Success => Self::Success, + SetOptionsResultCode::LowReserve => Self::LowReserve, + SetOptionsResultCode::TooManySigners => Self::TooManySigners, + SetOptionsResultCode::BadFlags => Self::BadFlags, + SetOptionsResultCode::InvalidInflation => Self::InvalidInflation, + SetOptionsResultCode::CantChange => Self::CantChange, + SetOptionsResultCode::UnknownFlag => Self::UnknownFlag, + SetOptionsResultCode::ThresholdOutOfRange => Self::ThresholdOutOfRange, + SetOptionsResultCode::BadSigner => Self::BadSigner, + SetOptionsResultCode::InvalidHomeDomain => Self::InvalidHomeDomain, + SetOptionsResultCode::AuthRevocableRequired => Self::AuthRevocableRequired, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -22380,97 +32329,205 @@ impl ReadXdr for ManageOfferSuccessResultOffer { } } -impl WriteXdr for ManageOfferSuccessResultOffer { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.discriminant().write_xdr(w)?; - #[allow(clippy::match_same_arms)] - match self { - Self::Created(v) => v.write_xdr(w)?, - Self::Updated(v) => v.write_xdr(w)?, - Self::Deleted => ().write_xdr(w)?, - }; - Ok(()) - }) +impl WriteXdr for SetOptionsResult { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.discriminant().write_xdr(w)?; + #[allow(clippy::match_same_arms)] + match self { + Self::Success => ().write_xdr(w)?, + Self::LowReserve => ().write_xdr(w)?, + Self::TooManySigners => ().write_xdr(w)?, + Self::BadFlags => ().write_xdr(w)?, + Self::InvalidInflation => ().write_xdr(w)?, + Self::CantChange => ().write_xdr(w)?, + Self::UnknownFlag => ().write_xdr(w)?, + Self::ThresholdOutOfRange => ().write_xdr(w)?, + Self::BadSigner => ().write_xdr(w)?, + Self::InvalidHomeDomain => ().write_xdr(w)?, + Self::AuthRevocableRequired => ().write_xdr(w)?, + }; + Ok(()) + }) + } +} + +// ChangeTrustResultCode is an XDR Enum defines as: +// +// enum ChangeTrustResultCode +// { +// // codes considered as "success" for the operation +// CHANGE_TRUST_SUCCESS = 0, +// // codes considered as "failure" for the operation +// CHANGE_TRUST_MALFORMED = -1, // bad input +// CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer +// CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance +// // cannot create with a limit of 0 +// CHANGE_TRUST_LOW_RESERVE = +// -4, // not enough funds to create a new trust line, +// CHANGE_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed +// CHANGE_TRUST_TRUST_LINE_MISSING = -6, // Asset trustline is missing for pool +// CHANGE_TRUST_CANNOT_DELETE = +// -7, // Asset trustline is still referenced in a pool +// CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES = +// -8 // Asset trustline is deauthorized +// }; +// +// enum +#[derive(Clone, Copy, 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") +)] +#[repr(i32)] +pub enum ChangeTrustResultCode { + Success = 0, + Malformed = -1, + NoIssuer = -2, + InvalidLimit = -3, + LowReserve = -4, + SelfNotAllowed = -5, + TrustLineMissing = -6, + CannotDelete = -7, + NotAuthMaintainLiabilities = -8, +} + +impl ChangeTrustResultCode { + pub const VARIANTS: [ChangeTrustResultCode; 9] = [ + ChangeTrustResultCode::Success, + ChangeTrustResultCode::Malformed, + ChangeTrustResultCode::NoIssuer, + ChangeTrustResultCode::InvalidLimit, + ChangeTrustResultCode::LowReserve, + ChangeTrustResultCode::SelfNotAllowed, + ChangeTrustResultCode::TrustLineMissing, + ChangeTrustResultCode::CannotDelete, + ChangeTrustResultCode::NotAuthMaintainLiabilities, + ]; + pub const VARIANTS_STR: [&'static str; 9] = [ + "Success", + "Malformed", + "NoIssuer", + "InvalidLimit", + "LowReserve", + "SelfNotAllowed", + "TrustLineMissing", + "CannotDelete", + "NotAuthMaintainLiabilities", + ]; + + #[must_use] + pub const fn name(&self) -> &'static str { + match self { + Self::Success => "Success", + Self::Malformed => "Malformed", + Self::NoIssuer => "NoIssuer", + Self::InvalidLimit => "InvalidLimit", + Self::LowReserve => "LowReserve", + Self::SelfNotAllowed => "SelfNotAllowed", + Self::TrustLineMissing => "TrustLineMissing", + Self::CannotDelete => "CannotDelete", + Self::NotAuthMaintainLiabilities => "NotAuthMaintainLiabilities", + } + } + + #[must_use] + pub const fn variants() -> [ChangeTrustResultCode; 9] { + Self::VARIANTS + } +} + +impl Name for ChangeTrustResultCode { + #[must_use] + fn name(&self) -> &'static str { + Self::name(self) + } +} + +impl Variants for ChangeTrustResultCode { + fn variants() -> slice::Iter<'static, ChangeTrustResultCode> { + Self::VARIANTS.iter() + } +} + +impl Enum for ChangeTrustResultCode {} + +impl fmt::Display for ChangeTrustResultCode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.name()) + } +} + +impl TryFrom for ChangeTrustResultCode { + type Error = Error; + + fn try_from(i: i32) -> Result { + let e = match i { + 0 => ChangeTrustResultCode::Success, + -1 => ChangeTrustResultCode::Malformed, + -2 => ChangeTrustResultCode::NoIssuer, + -3 => ChangeTrustResultCode::InvalidLimit, + -4 => ChangeTrustResultCode::LowReserve, + -5 => ChangeTrustResultCode::SelfNotAllowed, + -6 => ChangeTrustResultCode::TrustLineMissing, + -7 => ChangeTrustResultCode::CannotDelete, + -8 => ChangeTrustResultCode::NotAuthMaintainLiabilities, + #[allow(unreachable_patterns)] + _ => return Err(Error::Invalid), + }; + Ok(e) } } -// ManageOfferSuccessResult is an XDR Struct defines as: -// -// struct ManageOfferSuccessResult -// { -// // offers that got claimed while creating this offer -// ClaimAtom offersClaimed<>; -// -// union switch (ManageOfferEffect effect) -// { -// case MANAGE_OFFER_CREATED: -// case MANAGE_OFFER_UPDATED: -// OfferEntry offer; -// case MANAGE_OFFER_DELETED: -// void; -// } -// offer; -// }; -// -#[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 ManageOfferSuccessResult { - pub offers_claimed: VecM, - pub offer: ManageOfferSuccessResultOffer, +impl From for i32 { + #[must_use] + fn from(e: ChangeTrustResultCode) -> Self { + e as Self + } } -impl ReadXdr for ManageOfferSuccessResult { +impl ReadXdr for ChangeTrustResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - Ok(Self { - offers_claimed: VecM::::read_xdr(r)?, - offer: ManageOfferSuccessResultOffer::read_xdr(r)?, - }) + let e = i32::read_xdr(r)?; + let v: Self = e.try_into()?; + Ok(v) }) } } -impl WriteXdr for ManageOfferSuccessResult { +impl WriteXdr for ChangeTrustResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { - self.offers_claimed.write_xdr(w)?; - self.offer.write_xdr(w)?; - Ok(()) + let i: i32 = (*self).into(); + i.write_xdr(w) }) } } -// ManageSellOfferResult is an XDR Union defines as: +// ChangeTrustResult is an XDR Union defines as: // -// union ManageSellOfferResult switch (ManageSellOfferResultCode code) +// union ChangeTrustResult switch (ChangeTrustResultCode code) // { -// case MANAGE_SELL_OFFER_SUCCESS: -// ManageOfferSuccessResult success; -// case MANAGE_SELL_OFFER_MALFORMED: -// case MANAGE_SELL_OFFER_SELL_NO_TRUST: -// case MANAGE_SELL_OFFER_BUY_NO_TRUST: -// case MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED: -// case MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED: -// case MANAGE_SELL_OFFER_LINE_FULL: -// case MANAGE_SELL_OFFER_UNDERFUNDED: -// case MANAGE_SELL_OFFER_CROSS_SELF: -// case MANAGE_SELL_OFFER_SELL_NO_ISSUER: -// case MANAGE_SELL_OFFER_BUY_NO_ISSUER: -// case MANAGE_SELL_OFFER_NOT_FOUND: -// case MANAGE_SELL_OFFER_LOW_RESERVE: +// case CHANGE_TRUST_SUCCESS: +// void; +// case CHANGE_TRUST_MALFORMED: +// case CHANGE_TRUST_NO_ISSUER: +// case CHANGE_TRUST_INVALID_LIMIT: +// case CHANGE_TRUST_LOW_RESERVE: +// case CHANGE_TRUST_SELF_NOT_ALLOWED: +// case CHANGE_TRUST_TRUST_LINE_MISSING: +// case CHANGE_TRUST_CANNOT_DELETE: +// case CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES: // void; // }; // -// union with discriminant ManageSellOfferResultCode +// union with discriminant ChangeTrustResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -22479,144 +32536,119 @@ impl WriteXdr for ManageOfferSuccessResult { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ManageSellOfferResult { - Success(ManageOfferSuccessResult), +pub enum ChangeTrustResult { + Success, Malformed, - SellNoTrust, - BuyNoTrust, - SellNotAuthorized, - BuyNotAuthorized, - LineFull, - Underfunded, - CrossSelf, - SellNoIssuer, - BuyNoIssuer, - NotFound, + NoIssuer, + InvalidLimit, LowReserve, + SelfNotAllowed, + TrustLineMissing, + CannotDelete, + NotAuthMaintainLiabilities, } -impl ManageSellOfferResult { - pub const VARIANTS: [ManageSellOfferResultCode; 13] = [ - ManageSellOfferResultCode::Success, - ManageSellOfferResultCode::Malformed, - ManageSellOfferResultCode::SellNoTrust, - ManageSellOfferResultCode::BuyNoTrust, - ManageSellOfferResultCode::SellNotAuthorized, - ManageSellOfferResultCode::BuyNotAuthorized, - ManageSellOfferResultCode::LineFull, - ManageSellOfferResultCode::Underfunded, - ManageSellOfferResultCode::CrossSelf, - ManageSellOfferResultCode::SellNoIssuer, - ManageSellOfferResultCode::BuyNoIssuer, - ManageSellOfferResultCode::NotFound, - ManageSellOfferResultCode::LowReserve, +impl ChangeTrustResult { + pub const VARIANTS: [ChangeTrustResultCode; 9] = [ + ChangeTrustResultCode::Success, + ChangeTrustResultCode::Malformed, + ChangeTrustResultCode::NoIssuer, + ChangeTrustResultCode::InvalidLimit, + ChangeTrustResultCode::LowReserve, + ChangeTrustResultCode::SelfNotAllowed, + ChangeTrustResultCode::TrustLineMissing, + ChangeTrustResultCode::CannotDelete, + ChangeTrustResultCode::NotAuthMaintainLiabilities, ]; - pub const VARIANTS_STR: [&'static str; 13] = [ + pub const VARIANTS_STR: [&'static str; 9] = [ "Success", "Malformed", - "SellNoTrust", - "BuyNoTrust", - "SellNotAuthorized", - "BuyNotAuthorized", - "LineFull", - "Underfunded", - "CrossSelf", - "SellNoIssuer", - "BuyNoIssuer", - "NotFound", + "NoIssuer", + "InvalidLimit", "LowReserve", + "SelfNotAllowed", + "TrustLineMissing", + "CannotDelete", + "NotAuthMaintainLiabilities", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success(_) => "Success", + Self::Success => "Success", Self::Malformed => "Malformed", - Self::SellNoTrust => "SellNoTrust", - Self::BuyNoTrust => "BuyNoTrust", - Self::SellNotAuthorized => "SellNotAuthorized", - Self::BuyNotAuthorized => "BuyNotAuthorized", - Self::LineFull => "LineFull", - Self::Underfunded => "Underfunded", - Self::CrossSelf => "CrossSelf", - Self::SellNoIssuer => "SellNoIssuer", - Self::BuyNoIssuer => "BuyNoIssuer", - Self::NotFound => "NotFound", + Self::NoIssuer => "NoIssuer", + Self::InvalidLimit => "InvalidLimit", Self::LowReserve => "LowReserve", + Self::SelfNotAllowed => "SelfNotAllowed", + Self::TrustLineMissing => "TrustLineMissing", + Self::CannotDelete => "CannotDelete", + Self::NotAuthMaintainLiabilities => "NotAuthMaintainLiabilities", } } #[must_use] - pub const fn discriminant(&self) -> ManageSellOfferResultCode { + pub const fn discriminant(&self) -> ChangeTrustResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success(_) => ManageSellOfferResultCode::Success, - Self::Malformed => ManageSellOfferResultCode::Malformed, - Self::SellNoTrust => ManageSellOfferResultCode::SellNoTrust, - Self::BuyNoTrust => ManageSellOfferResultCode::BuyNoTrust, - Self::SellNotAuthorized => ManageSellOfferResultCode::SellNotAuthorized, - Self::BuyNotAuthorized => ManageSellOfferResultCode::BuyNotAuthorized, - Self::LineFull => ManageSellOfferResultCode::LineFull, - Self::Underfunded => ManageSellOfferResultCode::Underfunded, - Self::CrossSelf => ManageSellOfferResultCode::CrossSelf, - Self::SellNoIssuer => ManageSellOfferResultCode::SellNoIssuer, - Self::BuyNoIssuer => ManageSellOfferResultCode::BuyNoIssuer, - Self::NotFound => ManageSellOfferResultCode::NotFound, - Self::LowReserve => ManageSellOfferResultCode::LowReserve, + Self::Success => ChangeTrustResultCode::Success, + Self::Malformed => ChangeTrustResultCode::Malformed, + Self::NoIssuer => ChangeTrustResultCode::NoIssuer, + Self::InvalidLimit => ChangeTrustResultCode::InvalidLimit, + Self::LowReserve => ChangeTrustResultCode::LowReserve, + Self::SelfNotAllowed => ChangeTrustResultCode::SelfNotAllowed, + Self::TrustLineMissing => ChangeTrustResultCode::TrustLineMissing, + Self::CannotDelete => ChangeTrustResultCode::CannotDelete, + Self::NotAuthMaintainLiabilities => ChangeTrustResultCode::NotAuthMaintainLiabilities, } } #[must_use] - pub const fn variants() -> [ManageSellOfferResultCode; 13] { + pub const fn variants() -> [ChangeTrustResultCode; 9] { Self::VARIANTS } } -impl Name for ManageSellOfferResult { +impl Name for ChangeTrustResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ManageSellOfferResult { +impl Discriminant for ChangeTrustResult { #[must_use] - fn discriminant(&self) -> ManageSellOfferResultCode { + fn discriminant(&self) -> ChangeTrustResultCode { Self::discriminant(self) } } -impl Variants for ManageSellOfferResult { - fn variants() -> slice::Iter<'static, ManageSellOfferResultCode> { +impl Variants for ChangeTrustResult { + fn variants() -> slice::Iter<'static, ChangeTrustResultCode> { Self::VARIANTS.iter() } } -impl Union for ManageSellOfferResult {} +impl Union for ChangeTrustResult {} -impl ReadXdr for ManageSellOfferResult { +impl ReadXdr for ChangeTrustResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ManageSellOfferResultCode = - ::read_xdr(r)?; + let dv: ChangeTrustResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ManageSellOfferResultCode::Success => { - Self::Success(ManageOfferSuccessResult::read_xdr(r)?) + ChangeTrustResultCode::Success => Self::Success, + ChangeTrustResultCode::Malformed => Self::Malformed, + ChangeTrustResultCode::NoIssuer => Self::NoIssuer, + ChangeTrustResultCode::InvalidLimit => Self::InvalidLimit, + ChangeTrustResultCode::LowReserve => Self::LowReserve, + ChangeTrustResultCode::SelfNotAllowed => Self::SelfNotAllowed, + ChangeTrustResultCode::TrustLineMissing => Self::TrustLineMissing, + ChangeTrustResultCode::CannotDelete => Self::CannotDelete, + ChangeTrustResultCode::NotAuthMaintainLiabilities => { + Self::NotAuthMaintainLiabilities } - ManageSellOfferResultCode::Malformed => Self::Malformed, - ManageSellOfferResultCode::SellNoTrust => Self::SellNoTrust, - ManageSellOfferResultCode::BuyNoTrust => Self::BuyNoTrust, - ManageSellOfferResultCode::SellNotAuthorized => Self::SellNotAuthorized, - ManageSellOfferResultCode::BuyNotAuthorized => Self::BuyNotAuthorized, - ManageSellOfferResultCode::LineFull => Self::LineFull, - ManageSellOfferResultCode::Underfunded => Self::Underfunded, - ManageSellOfferResultCode::CrossSelf => Self::CrossSelf, - ManageSellOfferResultCode::SellNoIssuer => Self::SellNoIssuer, - ManageSellOfferResultCode::BuyNoIssuer => Self::BuyNoIssuer, - ManageSellOfferResultCode::NotFound => Self::NotFound, - ManageSellOfferResultCode::LowReserve => Self::LowReserve, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -22625,56 +32657,43 @@ impl ReadXdr for ManageSellOfferResult { } } -impl WriteXdr for ManageSellOfferResult { +impl WriteXdr for ChangeTrustResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Success(v) => v.write_xdr(w)?, + Self::Success => ().write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::SellNoTrust => ().write_xdr(w)?, - Self::BuyNoTrust => ().write_xdr(w)?, - Self::SellNotAuthorized => ().write_xdr(w)?, - Self::BuyNotAuthorized => ().write_xdr(w)?, - Self::LineFull => ().write_xdr(w)?, - Self::Underfunded => ().write_xdr(w)?, - Self::CrossSelf => ().write_xdr(w)?, - Self::SellNoIssuer => ().write_xdr(w)?, - Self::BuyNoIssuer => ().write_xdr(w)?, - Self::NotFound => ().write_xdr(w)?, + Self::NoIssuer => ().write_xdr(w)?, + Self::InvalidLimit => ().write_xdr(w)?, Self::LowReserve => ().write_xdr(w)?, + Self::SelfNotAllowed => ().write_xdr(w)?, + Self::TrustLineMissing => ().write_xdr(w)?, + Self::CannotDelete => ().write_xdr(w)?, + Self::NotAuthMaintainLiabilities => ().write_xdr(w)?, }; Ok(()) }) } } -// ManageBuyOfferResultCode is an XDR Enum defines as: +// AllowTrustResultCode is an XDR Enum defines as: // -// enum ManageBuyOfferResultCode +// enum AllowTrustResultCode // { // // codes considered as "success" for the operation -// MANAGE_BUY_OFFER_SUCCESS = 0, -// +// ALLOW_TRUST_SUCCESS = 0, // // codes considered as "failure" for the operation -// MANAGE_BUY_OFFER_MALFORMED = -1, // generated offer would be invalid -// MANAGE_BUY_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling -// MANAGE_BUY_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying -// MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell -// MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy -// MANAGE_BUY_OFFER_LINE_FULL = -6, // can't receive more of what it's buying -// MANAGE_BUY_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell -// MANAGE_BUY_OFFER_CROSS_SELF = -8, // would cross an offer from the same user -// MANAGE_BUY_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling -// MANAGE_BUY_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying -// -// // update errors -// MANAGE_BUY_OFFER_NOT_FOUND = -// -11, // offerID does not match an existing offer -// -// MANAGE_BUY_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer +// ALLOW_TRUST_MALFORMED = -1, // asset is not ASSET_TYPE_ALPHANUM +// ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline +// // source account does not require trust +// ALLOW_TRUST_TRUST_NOT_REQUIRED = -3, +// ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust, +// ALLOW_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed +// ALLOW_TRUST_LOW_RESERVE = -6 // claimable balances can't be created +// // on revoke due to low reserves // }; // // enum @@ -22686,51 +32705,33 @@ impl WriteXdr for ManageSellOfferResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ManageBuyOfferResultCode { +pub enum AllowTrustResultCode { Success = 0, Malformed = -1, - SellNoTrust = -2, - BuyNoTrust = -3, - SellNotAuthorized = -4, - BuyNotAuthorized = -5, - LineFull = -6, - Underfunded = -7, - CrossSelf = -8, - SellNoIssuer = -9, - BuyNoIssuer = -10, - NotFound = -11, - LowReserve = -12, + NoTrustLine = -2, + TrustNotRequired = -3, + CantRevoke = -4, + SelfNotAllowed = -5, + LowReserve = -6, } -impl ManageBuyOfferResultCode { - pub const VARIANTS: [ManageBuyOfferResultCode; 13] = [ - ManageBuyOfferResultCode::Success, - ManageBuyOfferResultCode::Malformed, - ManageBuyOfferResultCode::SellNoTrust, - ManageBuyOfferResultCode::BuyNoTrust, - ManageBuyOfferResultCode::SellNotAuthorized, - ManageBuyOfferResultCode::BuyNotAuthorized, - ManageBuyOfferResultCode::LineFull, - ManageBuyOfferResultCode::Underfunded, - ManageBuyOfferResultCode::CrossSelf, - ManageBuyOfferResultCode::SellNoIssuer, - ManageBuyOfferResultCode::BuyNoIssuer, - ManageBuyOfferResultCode::NotFound, - ManageBuyOfferResultCode::LowReserve, +impl AllowTrustResultCode { + pub const VARIANTS: [AllowTrustResultCode; 7] = [ + AllowTrustResultCode::Success, + AllowTrustResultCode::Malformed, + AllowTrustResultCode::NoTrustLine, + AllowTrustResultCode::TrustNotRequired, + AllowTrustResultCode::CantRevoke, + AllowTrustResultCode::SelfNotAllowed, + AllowTrustResultCode::LowReserve, ]; - pub const VARIANTS_STR: [&'static str; 13] = [ + pub const VARIANTS_STR: [&'static str; 7] = [ "Success", "Malformed", - "SellNoTrust", - "BuyNoTrust", - "SellNotAuthorized", - "BuyNotAuthorized", - "LineFull", - "Underfunded", - "CrossSelf", - "SellNoIssuer", - "BuyNoIssuer", - "NotFound", + "NoTrustLine", + "TrustNotRequired", + "CantRevoke", + "SelfNotAllowed", "LowReserve", ]; @@ -22739,65 +32740,53 @@ impl ManageBuyOfferResultCode { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::SellNoTrust => "SellNoTrust", - Self::BuyNoTrust => "BuyNoTrust", - Self::SellNotAuthorized => "SellNotAuthorized", - Self::BuyNotAuthorized => "BuyNotAuthorized", - Self::LineFull => "LineFull", - Self::Underfunded => "Underfunded", - Self::CrossSelf => "CrossSelf", - Self::SellNoIssuer => "SellNoIssuer", - Self::BuyNoIssuer => "BuyNoIssuer", - Self::NotFound => "NotFound", + Self::NoTrustLine => "NoTrustLine", + Self::TrustNotRequired => "TrustNotRequired", + Self::CantRevoke => "CantRevoke", + Self::SelfNotAllowed => "SelfNotAllowed", Self::LowReserve => "LowReserve", } } #[must_use] - pub const fn variants() -> [ManageBuyOfferResultCode; 13] { + pub const fn variants() -> [AllowTrustResultCode; 7] { Self::VARIANTS } } -impl Name for ManageBuyOfferResultCode { +impl Name for AllowTrustResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ManageBuyOfferResultCode { - fn variants() -> slice::Iter<'static, ManageBuyOfferResultCode> { +impl Variants for AllowTrustResultCode { + fn variants() -> slice::Iter<'static, AllowTrustResultCode> { Self::VARIANTS.iter() } } -impl Enum for ManageBuyOfferResultCode {} +impl Enum for AllowTrustResultCode {} -impl fmt::Display for ManageBuyOfferResultCode { +impl fmt::Display for AllowTrustResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for ManageBuyOfferResultCode { +impl TryFrom for AllowTrustResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => ManageBuyOfferResultCode::Success, - -1 => ManageBuyOfferResultCode::Malformed, - -2 => ManageBuyOfferResultCode::SellNoTrust, - -3 => ManageBuyOfferResultCode::BuyNoTrust, - -4 => ManageBuyOfferResultCode::SellNotAuthorized, - -5 => ManageBuyOfferResultCode::BuyNotAuthorized, - -6 => ManageBuyOfferResultCode::LineFull, - -7 => ManageBuyOfferResultCode::Underfunded, - -8 => ManageBuyOfferResultCode::CrossSelf, - -9 => ManageBuyOfferResultCode::SellNoIssuer, - -10 => ManageBuyOfferResultCode::BuyNoIssuer, - -11 => ManageBuyOfferResultCode::NotFound, - -12 => ManageBuyOfferResultCode::LowReserve, + 0 => AllowTrustResultCode::Success, + -1 => AllowTrustResultCode::Malformed, + -2 => AllowTrustResultCode::NoTrustLine, + -3 => AllowTrustResultCode::TrustNotRequired, + -4 => AllowTrustResultCode::CantRevoke, + -5 => AllowTrustResultCode::SelfNotAllowed, + -6 => AllowTrustResultCode::LowReserve, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -22805,14 +32794,14 @@ impl TryFrom for ManageBuyOfferResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: ManageBuyOfferResultCode) -> Self { + fn from(e: AllowTrustResultCode) -> Self { e as Self } } -impl ReadXdr for ManageBuyOfferResultCode { +impl ReadXdr for AllowTrustResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -22823,7 +32812,7 @@ impl ReadXdr for ManageBuyOfferResultCode { } } -impl WriteXdr for ManageBuyOfferResultCode { +impl WriteXdr for AllowTrustResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -22833,28 +32822,22 @@ impl WriteXdr for ManageBuyOfferResultCode { } } -// ManageBuyOfferResult is an XDR Union defines as: +// AllowTrustResult is an XDR Union defines as: // -// union ManageBuyOfferResult switch (ManageBuyOfferResultCode code) +// union AllowTrustResult switch (AllowTrustResultCode code) // { -// case MANAGE_BUY_OFFER_SUCCESS: -// ManageOfferSuccessResult success; -// case MANAGE_BUY_OFFER_MALFORMED: -// case MANAGE_BUY_OFFER_SELL_NO_TRUST: -// case MANAGE_BUY_OFFER_BUY_NO_TRUST: -// case MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED: -// case MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED: -// case MANAGE_BUY_OFFER_LINE_FULL: -// case MANAGE_BUY_OFFER_UNDERFUNDED: -// case MANAGE_BUY_OFFER_CROSS_SELF: -// case MANAGE_BUY_OFFER_SELL_NO_ISSUER: -// case MANAGE_BUY_OFFER_BUY_NO_ISSUER: -// case MANAGE_BUY_OFFER_NOT_FOUND: -// case MANAGE_BUY_OFFER_LOW_RESERVE: +// case ALLOW_TRUST_SUCCESS: +// void; +// case ALLOW_TRUST_MALFORMED: +// case ALLOW_TRUST_NO_TRUST_LINE: +// case ALLOW_TRUST_TRUST_NOT_REQUIRED: +// case ALLOW_TRUST_CANT_REVOKE: +// case ALLOW_TRUST_SELF_NOT_ALLOWED: +// case ALLOW_TRUST_LOW_RESERVE: // void; // }; // -// union with discriminant ManageBuyOfferResultCode +// union with discriminant AllowTrustResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -22863,143 +32846,105 @@ impl WriteXdr for ManageBuyOfferResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ManageBuyOfferResult { - Success(ManageOfferSuccessResult), +pub enum AllowTrustResult { + Success, Malformed, - SellNoTrust, - BuyNoTrust, - SellNotAuthorized, - BuyNotAuthorized, - LineFull, - Underfunded, - CrossSelf, - SellNoIssuer, - BuyNoIssuer, - NotFound, + NoTrustLine, + TrustNotRequired, + CantRevoke, + SelfNotAllowed, LowReserve, } -impl ManageBuyOfferResult { - pub const VARIANTS: [ManageBuyOfferResultCode; 13] = [ - ManageBuyOfferResultCode::Success, - ManageBuyOfferResultCode::Malformed, - ManageBuyOfferResultCode::SellNoTrust, - ManageBuyOfferResultCode::BuyNoTrust, - ManageBuyOfferResultCode::SellNotAuthorized, - ManageBuyOfferResultCode::BuyNotAuthorized, - ManageBuyOfferResultCode::LineFull, - ManageBuyOfferResultCode::Underfunded, - ManageBuyOfferResultCode::CrossSelf, - ManageBuyOfferResultCode::SellNoIssuer, - ManageBuyOfferResultCode::BuyNoIssuer, - ManageBuyOfferResultCode::NotFound, - ManageBuyOfferResultCode::LowReserve, +impl AllowTrustResult { + pub const VARIANTS: [AllowTrustResultCode; 7] = [ + AllowTrustResultCode::Success, + AllowTrustResultCode::Malformed, + AllowTrustResultCode::NoTrustLine, + AllowTrustResultCode::TrustNotRequired, + AllowTrustResultCode::CantRevoke, + AllowTrustResultCode::SelfNotAllowed, + AllowTrustResultCode::LowReserve, ]; - pub const VARIANTS_STR: [&'static str; 13] = [ - "Success", - "Malformed", - "SellNoTrust", - "BuyNoTrust", - "SellNotAuthorized", - "BuyNotAuthorized", - "LineFull", - "Underfunded", - "CrossSelf", - "SellNoIssuer", - "BuyNoIssuer", - "NotFound", + pub const VARIANTS_STR: [&'static str; 7] = [ + "Success", + "Malformed", + "NoTrustLine", + "TrustNotRequired", + "CantRevoke", + "SelfNotAllowed", "LowReserve", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success(_) => "Success", + Self::Success => "Success", Self::Malformed => "Malformed", - Self::SellNoTrust => "SellNoTrust", - Self::BuyNoTrust => "BuyNoTrust", - Self::SellNotAuthorized => "SellNotAuthorized", - Self::BuyNotAuthorized => "BuyNotAuthorized", - Self::LineFull => "LineFull", - Self::Underfunded => "Underfunded", - Self::CrossSelf => "CrossSelf", - Self::SellNoIssuer => "SellNoIssuer", - Self::BuyNoIssuer => "BuyNoIssuer", - Self::NotFound => "NotFound", + Self::NoTrustLine => "NoTrustLine", + Self::TrustNotRequired => "TrustNotRequired", + Self::CantRevoke => "CantRevoke", + Self::SelfNotAllowed => "SelfNotAllowed", Self::LowReserve => "LowReserve", } } #[must_use] - pub const fn discriminant(&self) -> ManageBuyOfferResultCode { + pub const fn discriminant(&self) -> AllowTrustResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success(_) => ManageBuyOfferResultCode::Success, - Self::Malformed => ManageBuyOfferResultCode::Malformed, - Self::SellNoTrust => ManageBuyOfferResultCode::SellNoTrust, - Self::BuyNoTrust => ManageBuyOfferResultCode::BuyNoTrust, - Self::SellNotAuthorized => ManageBuyOfferResultCode::SellNotAuthorized, - Self::BuyNotAuthorized => ManageBuyOfferResultCode::BuyNotAuthorized, - Self::LineFull => ManageBuyOfferResultCode::LineFull, - Self::Underfunded => ManageBuyOfferResultCode::Underfunded, - Self::CrossSelf => ManageBuyOfferResultCode::CrossSelf, - Self::SellNoIssuer => ManageBuyOfferResultCode::SellNoIssuer, - Self::BuyNoIssuer => ManageBuyOfferResultCode::BuyNoIssuer, - Self::NotFound => ManageBuyOfferResultCode::NotFound, - Self::LowReserve => ManageBuyOfferResultCode::LowReserve, + Self::Success => AllowTrustResultCode::Success, + Self::Malformed => AllowTrustResultCode::Malformed, + Self::NoTrustLine => AllowTrustResultCode::NoTrustLine, + Self::TrustNotRequired => AllowTrustResultCode::TrustNotRequired, + Self::CantRevoke => AllowTrustResultCode::CantRevoke, + Self::SelfNotAllowed => AllowTrustResultCode::SelfNotAllowed, + Self::LowReserve => AllowTrustResultCode::LowReserve, } } #[must_use] - pub const fn variants() -> [ManageBuyOfferResultCode; 13] { + pub const fn variants() -> [AllowTrustResultCode; 7] { Self::VARIANTS } } -impl Name for ManageBuyOfferResult { +impl Name for AllowTrustResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ManageBuyOfferResult { +impl Discriminant for AllowTrustResult { #[must_use] - fn discriminant(&self) -> ManageBuyOfferResultCode { + fn discriminant(&self) -> AllowTrustResultCode { Self::discriminant(self) } } -impl Variants for ManageBuyOfferResult { - fn variants() -> slice::Iter<'static, ManageBuyOfferResultCode> { +impl Variants for AllowTrustResult { + fn variants() -> slice::Iter<'static, AllowTrustResultCode> { Self::VARIANTS.iter() } } -impl Union for ManageBuyOfferResult {} +impl Union for AllowTrustResult {} -impl ReadXdr for ManageBuyOfferResult { +impl ReadXdr for AllowTrustResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ManageBuyOfferResultCode = ::read_xdr(r)?; + let dv: AllowTrustResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ManageBuyOfferResultCode::Success => { - Self::Success(ManageOfferSuccessResult::read_xdr(r)?) - } - ManageBuyOfferResultCode::Malformed => Self::Malformed, - ManageBuyOfferResultCode::SellNoTrust => Self::SellNoTrust, - ManageBuyOfferResultCode::BuyNoTrust => Self::BuyNoTrust, - ManageBuyOfferResultCode::SellNotAuthorized => Self::SellNotAuthorized, - ManageBuyOfferResultCode::BuyNotAuthorized => Self::BuyNotAuthorized, - ManageBuyOfferResultCode::LineFull => Self::LineFull, - ManageBuyOfferResultCode::Underfunded => Self::Underfunded, - ManageBuyOfferResultCode::CrossSelf => Self::CrossSelf, - ManageBuyOfferResultCode::SellNoIssuer => Self::SellNoIssuer, - ManageBuyOfferResultCode::BuyNoIssuer => Self::BuyNoIssuer, - ManageBuyOfferResultCode::NotFound => Self::NotFound, - ManageBuyOfferResultCode::LowReserve => Self::LowReserve, + AllowTrustResultCode::Success => Self::Success, + AllowTrustResultCode::Malformed => Self::Malformed, + AllowTrustResultCode::NoTrustLine => Self::NoTrustLine, + AllowTrustResultCode::TrustNotRequired => Self::TrustNotRequired, + AllowTrustResultCode::CantRevoke => Self::CantRevoke, + AllowTrustResultCode::SelfNotAllowed => Self::SelfNotAllowed, + AllowTrustResultCode::LowReserve => Self::LowReserve, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -23008,25 +32953,19 @@ impl ReadXdr for ManageBuyOfferResult { } } -impl WriteXdr for ManageBuyOfferResult { +impl WriteXdr for AllowTrustResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Success(v) => v.write_xdr(w)?, + Self::Success => ().write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::SellNoTrust => ().write_xdr(w)?, - Self::BuyNoTrust => ().write_xdr(w)?, - Self::SellNotAuthorized => ().write_xdr(w)?, - Self::BuyNotAuthorized => ().write_xdr(w)?, - Self::LineFull => ().write_xdr(w)?, - Self::Underfunded => ().write_xdr(w)?, - Self::CrossSelf => ().write_xdr(w)?, - Self::SellNoIssuer => ().write_xdr(w)?, - Self::BuyNoIssuer => ().write_xdr(w)?, - Self::NotFound => ().write_xdr(w)?, + Self::NoTrustLine => ().write_xdr(w)?, + Self::TrustNotRequired => ().write_xdr(w)?, + Self::CantRevoke => ().write_xdr(w)?, + Self::SelfNotAllowed => ().write_xdr(w)?, Self::LowReserve => ().write_xdr(w)?, }; Ok(()) @@ -23034,24 +32973,21 @@ impl WriteXdr for ManageBuyOfferResult { } } -// SetOptionsResultCode is an XDR Enum defines as: +// AccountMergeResultCode is an XDR Enum defines as: // -// enum SetOptionsResultCode +// enum AccountMergeResultCode // { // // codes considered as "success" for the operation -// SET_OPTIONS_SUCCESS = 0, +// ACCOUNT_MERGE_SUCCESS = 0, // // codes considered as "failure" for the operation -// SET_OPTIONS_LOW_RESERVE = -1, // not enough funds to add a signer -// SET_OPTIONS_TOO_MANY_SIGNERS = -2, // max number of signers already reached -// SET_OPTIONS_BAD_FLAGS = -3, // invalid combination of clear/set flags -// SET_OPTIONS_INVALID_INFLATION = -4, // inflation account does not exist -// SET_OPTIONS_CANT_CHANGE = -5, // can no longer change this option -// SET_OPTIONS_UNKNOWN_FLAG = -6, // can't set an unknown flag -// SET_OPTIONS_THRESHOLD_OUT_OF_RANGE = -7, // bad value for weight/threshold -// SET_OPTIONS_BAD_SIGNER = -8, // signer cannot be masterkey -// SET_OPTIONS_INVALID_HOME_DOMAIN = -9, // malformed home domain -// SET_OPTIONS_AUTH_REVOCABLE_REQUIRED = -// -10 // auth revocable is required for clawback +// ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself +// ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist +// ACCOUNT_MERGE_IMMUTABLE_SET = -3, // source account has AUTH_IMMUTABLE set +// ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4, // account has trust lines/offers +// ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5, // sequence number is over max allowed +// ACCOUNT_MERGE_DEST_FULL = -6, // can't add source balance to +// // destination balance +// ACCOUNT_MERGE_IS_SPONSOR = -7 // can't merge account that is a sponsor // }; // // enum @@ -23063,108 +32999,93 @@ impl WriteXdr for ManageBuyOfferResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum SetOptionsResultCode { +pub enum AccountMergeResultCode { Success = 0, - LowReserve = -1, - TooManySigners = -2, - BadFlags = -3, - InvalidInflation = -4, - CantChange = -5, - UnknownFlag = -6, - ThresholdOutOfRange = -7, - BadSigner = -8, - InvalidHomeDomain = -9, - AuthRevocableRequired = -10, + Malformed = -1, + NoAccount = -2, + ImmutableSet = -3, + HasSubEntries = -4, + SeqnumTooFar = -5, + DestFull = -6, + IsSponsor = -7, } -impl SetOptionsResultCode { - pub const VARIANTS: [SetOptionsResultCode; 11] = [ - SetOptionsResultCode::Success, - SetOptionsResultCode::LowReserve, - SetOptionsResultCode::TooManySigners, - SetOptionsResultCode::BadFlags, - SetOptionsResultCode::InvalidInflation, - SetOptionsResultCode::CantChange, - SetOptionsResultCode::UnknownFlag, - SetOptionsResultCode::ThresholdOutOfRange, - SetOptionsResultCode::BadSigner, - SetOptionsResultCode::InvalidHomeDomain, - SetOptionsResultCode::AuthRevocableRequired, +impl AccountMergeResultCode { + pub const VARIANTS: [AccountMergeResultCode; 8] = [ + AccountMergeResultCode::Success, + AccountMergeResultCode::Malformed, + AccountMergeResultCode::NoAccount, + AccountMergeResultCode::ImmutableSet, + AccountMergeResultCode::HasSubEntries, + AccountMergeResultCode::SeqnumTooFar, + AccountMergeResultCode::DestFull, + AccountMergeResultCode::IsSponsor, ]; - pub const VARIANTS_STR: [&'static str; 11] = [ + pub const VARIANTS_STR: [&'static str; 8] = [ "Success", - "LowReserve", - "TooManySigners", - "BadFlags", - "InvalidInflation", - "CantChange", - "UnknownFlag", - "ThresholdOutOfRange", - "BadSigner", - "InvalidHomeDomain", - "AuthRevocableRequired", + "Malformed", + "NoAccount", + "ImmutableSet", + "HasSubEntries", + "SeqnumTooFar", + "DestFull", + "IsSponsor", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::LowReserve => "LowReserve", - Self::TooManySigners => "TooManySigners", - Self::BadFlags => "BadFlags", - Self::InvalidInflation => "InvalidInflation", - Self::CantChange => "CantChange", - Self::UnknownFlag => "UnknownFlag", - Self::ThresholdOutOfRange => "ThresholdOutOfRange", - Self::BadSigner => "BadSigner", - Self::InvalidHomeDomain => "InvalidHomeDomain", - Self::AuthRevocableRequired => "AuthRevocableRequired", + Self::Malformed => "Malformed", + Self::NoAccount => "NoAccount", + Self::ImmutableSet => "ImmutableSet", + Self::HasSubEntries => "HasSubEntries", + Self::SeqnumTooFar => "SeqnumTooFar", + Self::DestFull => "DestFull", + Self::IsSponsor => "IsSponsor", } } #[must_use] - pub const fn variants() -> [SetOptionsResultCode; 11] { + pub const fn variants() -> [AccountMergeResultCode; 8] { Self::VARIANTS } } -impl Name for SetOptionsResultCode { +impl Name for AccountMergeResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for SetOptionsResultCode { - fn variants() -> slice::Iter<'static, SetOptionsResultCode> { +impl Variants for AccountMergeResultCode { + fn variants() -> slice::Iter<'static, AccountMergeResultCode> { Self::VARIANTS.iter() } } -impl Enum for SetOptionsResultCode {} +impl Enum for AccountMergeResultCode {} -impl fmt::Display for SetOptionsResultCode { +impl fmt::Display for AccountMergeResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for SetOptionsResultCode { +impl TryFrom for AccountMergeResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => SetOptionsResultCode::Success, - -1 => SetOptionsResultCode::LowReserve, - -2 => SetOptionsResultCode::TooManySigners, - -3 => SetOptionsResultCode::BadFlags, - -4 => SetOptionsResultCode::InvalidInflation, - -5 => SetOptionsResultCode::CantChange, - -6 => SetOptionsResultCode::UnknownFlag, - -7 => SetOptionsResultCode::ThresholdOutOfRange, - -8 => SetOptionsResultCode::BadSigner, - -9 => SetOptionsResultCode::InvalidHomeDomain, - -10 => SetOptionsResultCode::AuthRevocableRequired, + 0 => AccountMergeResultCode::Success, + -1 => AccountMergeResultCode::Malformed, + -2 => AccountMergeResultCode::NoAccount, + -3 => AccountMergeResultCode::ImmutableSet, + -4 => AccountMergeResultCode::HasSubEntries, + -5 => AccountMergeResultCode::SeqnumTooFar, + -6 => AccountMergeResultCode::DestFull, + -7 => AccountMergeResultCode::IsSponsor, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -23172,14 +33093,14 @@ impl TryFrom for SetOptionsResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: SetOptionsResultCode) -> Self { + fn from(e: AccountMergeResultCode) -> Self { e as Self } } -impl ReadXdr for SetOptionsResultCode { +impl ReadXdr for AccountMergeResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -23190,7 +33111,7 @@ impl ReadXdr for SetOptionsResultCode { } } -impl WriteXdr for SetOptionsResultCode { +impl WriteXdr for AccountMergeResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -23200,26 +33121,23 @@ impl WriteXdr for SetOptionsResultCode { } } -// SetOptionsResult is an XDR Union defines as: +// AccountMergeResult is an XDR Union defines as: // -// union SetOptionsResult switch (SetOptionsResultCode code) +// union AccountMergeResult switch (AccountMergeResultCode code) // { -// case SET_OPTIONS_SUCCESS: -// void; -// case SET_OPTIONS_LOW_RESERVE: -// case SET_OPTIONS_TOO_MANY_SIGNERS: -// case SET_OPTIONS_BAD_FLAGS: -// case SET_OPTIONS_INVALID_INFLATION: -// case SET_OPTIONS_CANT_CHANGE: -// case SET_OPTIONS_UNKNOWN_FLAG: -// case SET_OPTIONS_THRESHOLD_OUT_OF_RANGE: -// case SET_OPTIONS_BAD_SIGNER: -// case SET_OPTIONS_INVALID_HOME_DOMAIN: -// case SET_OPTIONS_AUTH_REVOCABLE_REQUIRED: +// case ACCOUNT_MERGE_SUCCESS: +// int64 sourceAccountBalance; // how much got transferred from source account +// case ACCOUNT_MERGE_MALFORMED: +// case ACCOUNT_MERGE_NO_ACCOUNT: +// case ACCOUNT_MERGE_IMMUTABLE_SET: +// case ACCOUNT_MERGE_HAS_SUB_ENTRIES: +// case ACCOUNT_MERGE_SEQNUM_TOO_FAR: +// case ACCOUNT_MERGE_DEST_FULL: +// case ACCOUNT_MERGE_IS_SPONSOR: // void; // }; // -// union with discriminant SetOptionsResultCode +// union with discriminant AccountMergeResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -23228,129 +33146,111 @@ impl WriteXdr for SetOptionsResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum SetOptionsResult { - Success, - LowReserve, - TooManySigners, - BadFlags, - InvalidInflation, - CantChange, - UnknownFlag, - ThresholdOutOfRange, - BadSigner, - InvalidHomeDomain, - AuthRevocableRequired, +pub enum AccountMergeResult { + Success(i64), + Malformed, + NoAccount, + ImmutableSet, + HasSubEntries, + SeqnumTooFar, + DestFull, + IsSponsor, } -impl SetOptionsResult { - pub const VARIANTS: [SetOptionsResultCode; 11] = [ - SetOptionsResultCode::Success, - SetOptionsResultCode::LowReserve, - SetOptionsResultCode::TooManySigners, - SetOptionsResultCode::BadFlags, - SetOptionsResultCode::InvalidInflation, - SetOptionsResultCode::CantChange, - SetOptionsResultCode::UnknownFlag, - SetOptionsResultCode::ThresholdOutOfRange, - SetOptionsResultCode::BadSigner, - SetOptionsResultCode::InvalidHomeDomain, - SetOptionsResultCode::AuthRevocableRequired, +impl AccountMergeResult { + pub const VARIANTS: [AccountMergeResultCode; 8] = [ + AccountMergeResultCode::Success, + AccountMergeResultCode::Malformed, + AccountMergeResultCode::NoAccount, + AccountMergeResultCode::ImmutableSet, + AccountMergeResultCode::HasSubEntries, + AccountMergeResultCode::SeqnumTooFar, + AccountMergeResultCode::DestFull, + AccountMergeResultCode::IsSponsor, ]; - pub const VARIANTS_STR: [&'static str; 11] = [ + pub const VARIANTS_STR: [&'static str; 8] = [ "Success", - "LowReserve", - "TooManySigners", - "BadFlags", - "InvalidInflation", - "CantChange", - "UnknownFlag", - "ThresholdOutOfRange", - "BadSigner", - "InvalidHomeDomain", - "AuthRevocableRequired", + "Malformed", + "NoAccount", + "ImmutableSet", + "HasSubEntries", + "SeqnumTooFar", + "DestFull", + "IsSponsor", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success => "Success", - Self::LowReserve => "LowReserve", - Self::TooManySigners => "TooManySigners", - Self::BadFlags => "BadFlags", - Self::InvalidInflation => "InvalidInflation", - Self::CantChange => "CantChange", - Self::UnknownFlag => "UnknownFlag", - Self::ThresholdOutOfRange => "ThresholdOutOfRange", - Self::BadSigner => "BadSigner", - Self::InvalidHomeDomain => "InvalidHomeDomain", - Self::AuthRevocableRequired => "AuthRevocableRequired", + Self::Success(_) => "Success", + Self::Malformed => "Malformed", + Self::NoAccount => "NoAccount", + Self::ImmutableSet => "ImmutableSet", + Self::HasSubEntries => "HasSubEntries", + Self::SeqnumTooFar => "SeqnumTooFar", + Self::DestFull => "DestFull", + Self::IsSponsor => "IsSponsor", } } #[must_use] - pub const fn discriminant(&self) -> SetOptionsResultCode { + pub const fn discriminant(&self) -> AccountMergeResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => SetOptionsResultCode::Success, - Self::LowReserve => SetOptionsResultCode::LowReserve, - Self::TooManySigners => SetOptionsResultCode::TooManySigners, - Self::BadFlags => SetOptionsResultCode::BadFlags, - Self::InvalidInflation => SetOptionsResultCode::InvalidInflation, - Self::CantChange => SetOptionsResultCode::CantChange, - Self::UnknownFlag => SetOptionsResultCode::UnknownFlag, - Self::ThresholdOutOfRange => SetOptionsResultCode::ThresholdOutOfRange, - Self::BadSigner => SetOptionsResultCode::BadSigner, - Self::InvalidHomeDomain => SetOptionsResultCode::InvalidHomeDomain, - Self::AuthRevocableRequired => SetOptionsResultCode::AuthRevocableRequired, + Self::Success(_) => AccountMergeResultCode::Success, + Self::Malformed => AccountMergeResultCode::Malformed, + Self::NoAccount => AccountMergeResultCode::NoAccount, + Self::ImmutableSet => AccountMergeResultCode::ImmutableSet, + Self::HasSubEntries => AccountMergeResultCode::HasSubEntries, + Self::SeqnumTooFar => AccountMergeResultCode::SeqnumTooFar, + Self::DestFull => AccountMergeResultCode::DestFull, + Self::IsSponsor => AccountMergeResultCode::IsSponsor, } } #[must_use] - pub const fn variants() -> [SetOptionsResultCode; 11] { + pub const fn variants() -> [AccountMergeResultCode; 8] { Self::VARIANTS } } -impl Name for SetOptionsResult { +impl Name for AccountMergeResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for SetOptionsResult { +impl Discriminant for AccountMergeResult { #[must_use] - fn discriminant(&self) -> SetOptionsResultCode { + fn discriminant(&self) -> AccountMergeResultCode { Self::discriminant(self) } } -impl Variants for SetOptionsResult { - fn variants() -> slice::Iter<'static, SetOptionsResultCode> { +impl Variants for AccountMergeResult { + fn variants() -> slice::Iter<'static, AccountMergeResultCode> { Self::VARIANTS.iter() } } -impl Union for SetOptionsResult {} +impl Union for AccountMergeResult {} -impl ReadXdr for SetOptionsResult { +impl ReadXdr for AccountMergeResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: SetOptionsResultCode = ::read_xdr(r)?; + let dv: AccountMergeResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - SetOptionsResultCode::Success => Self::Success, - SetOptionsResultCode::LowReserve => Self::LowReserve, - SetOptionsResultCode::TooManySigners => Self::TooManySigners, - SetOptionsResultCode::BadFlags => Self::BadFlags, - SetOptionsResultCode::InvalidInflation => Self::InvalidInflation, - SetOptionsResultCode::CantChange => Self::CantChange, - SetOptionsResultCode::UnknownFlag => Self::UnknownFlag, - SetOptionsResultCode::ThresholdOutOfRange => Self::ThresholdOutOfRange, - SetOptionsResultCode::BadSigner => Self::BadSigner, - SetOptionsResultCode::InvalidHomeDomain => Self::InvalidHomeDomain, - SetOptionsResultCode::AuthRevocableRequired => Self::AuthRevocableRequired, + AccountMergeResultCode::Success => Self::Success(i64::read_xdr(r)?), + AccountMergeResultCode::Malformed => Self::Malformed, + AccountMergeResultCode::NoAccount => Self::NoAccount, + AccountMergeResultCode::ImmutableSet => Self::ImmutableSet, + AccountMergeResultCode::HasSubEntries => Self::HasSubEntries, + AccountMergeResultCode::SeqnumTooFar => Self::SeqnumTooFar, + AccountMergeResultCode::DestFull => Self::DestFull, + AccountMergeResultCode::IsSponsor => Self::IsSponsor, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -23359,49 +33259,35 @@ impl ReadXdr for SetOptionsResult { } } -impl WriteXdr for SetOptionsResult { +impl WriteXdr for AccountMergeResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Success => ().write_xdr(w)?, - Self::LowReserve => ().write_xdr(w)?, - Self::TooManySigners => ().write_xdr(w)?, - Self::BadFlags => ().write_xdr(w)?, - Self::InvalidInflation => ().write_xdr(w)?, - Self::CantChange => ().write_xdr(w)?, - Self::UnknownFlag => ().write_xdr(w)?, - Self::ThresholdOutOfRange => ().write_xdr(w)?, - Self::BadSigner => ().write_xdr(w)?, - Self::InvalidHomeDomain => ().write_xdr(w)?, - Self::AuthRevocableRequired => ().write_xdr(w)?, + Self::Success(v) => v.write_xdr(w)?, + Self::Malformed => ().write_xdr(w)?, + Self::NoAccount => ().write_xdr(w)?, + Self::ImmutableSet => ().write_xdr(w)?, + Self::HasSubEntries => ().write_xdr(w)?, + Self::SeqnumTooFar => ().write_xdr(w)?, + Self::DestFull => ().write_xdr(w)?, + Self::IsSponsor => ().write_xdr(w)?, }; Ok(()) }) } } -// ChangeTrustResultCode is an XDR Enum defines as: +// InflationResultCode is an XDR Enum defines as: // -// enum ChangeTrustResultCode +// enum InflationResultCode // { // // codes considered as "success" for the operation -// CHANGE_TRUST_SUCCESS = 0, +// INFLATION_SUCCESS = 0, // // codes considered as "failure" for the operation -// CHANGE_TRUST_MALFORMED = -1, // bad input -// CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer -// CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance -// // cannot create with a limit of 0 -// CHANGE_TRUST_LOW_RESERVE = -// -4, // not enough funds to create a new trust line, -// CHANGE_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed -// CHANGE_TRUST_TRUST_LINE_MISSING = -6, // Asset trustline is missing for pool -// CHANGE_TRUST_CANNOT_DELETE = -// -7, // Asset trustline is still referenced in a pool -// CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES = -// -8 // Asset trustline is deauthorized +// INFLATION_NOT_TIME = -1 // }; // // enum @@ -23413,98 +33299,58 @@ impl WriteXdr for SetOptionsResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ChangeTrustResultCode { +pub enum InflationResultCode { Success = 0, - Malformed = -1, - NoIssuer = -2, - InvalidLimit = -3, - LowReserve = -4, - SelfNotAllowed = -5, - TrustLineMissing = -6, - CannotDelete = -7, - NotAuthMaintainLiabilities = -8, + NotTime = -1, } -impl ChangeTrustResultCode { - pub const VARIANTS: [ChangeTrustResultCode; 9] = [ - ChangeTrustResultCode::Success, - ChangeTrustResultCode::Malformed, - ChangeTrustResultCode::NoIssuer, - ChangeTrustResultCode::InvalidLimit, - ChangeTrustResultCode::LowReserve, - ChangeTrustResultCode::SelfNotAllowed, - ChangeTrustResultCode::TrustLineMissing, - ChangeTrustResultCode::CannotDelete, - ChangeTrustResultCode::NotAuthMaintainLiabilities, - ]; - pub const VARIANTS_STR: [&'static str; 9] = [ - "Success", - "Malformed", - "NoIssuer", - "InvalidLimit", - "LowReserve", - "SelfNotAllowed", - "TrustLineMissing", - "CannotDelete", - "NotAuthMaintainLiabilities", - ]; +impl InflationResultCode { + pub const VARIANTS: [InflationResultCode; 2] = + [InflationResultCode::Success, InflationResultCode::NotTime]; + pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotTime"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::Malformed => "Malformed", - Self::NoIssuer => "NoIssuer", - Self::InvalidLimit => "InvalidLimit", - Self::LowReserve => "LowReserve", - Self::SelfNotAllowed => "SelfNotAllowed", - Self::TrustLineMissing => "TrustLineMissing", - Self::CannotDelete => "CannotDelete", - Self::NotAuthMaintainLiabilities => "NotAuthMaintainLiabilities", + Self::NotTime => "NotTime", } } #[must_use] - pub const fn variants() -> [ChangeTrustResultCode; 9] { + pub const fn variants() -> [InflationResultCode; 2] { Self::VARIANTS } } -impl Name for ChangeTrustResultCode { +impl Name for InflationResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ChangeTrustResultCode { - fn variants() -> slice::Iter<'static, ChangeTrustResultCode> { +impl Variants for InflationResultCode { + fn variants() -> slice::Iter<'static, InflationResultCode> { Self::VARIANTS.iter() } } -impl Enum for ChangeTrustResultCode {} +impl Enum for InflationResultCode {} -impl fmt::Display for ChangeTrustResultCode { +impl fmt::Display for InflationResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for ChangeTrustResultCode { +impl TryFrom for InflationResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => ChangeTrustResultCode::Success, - -1 => ChangeTrustResultCode::Malformed, - -2 => ChangeTrustResultCode::NoIssuer, - -3 => ChangeTrustResultCode::InvalidLimit, - -4 => ChangeTrustResultCode::LowReserve, - -5 => ChangeTrustResultCode::SelfNotAllowed, - -6 => ChangeTrustResultCode::TrustLineMissing, - -7 => ChangeTrustResultCode::CannotDelete, - -8 => ChangeTrustResultCode::NotAuthMaintainLiabilities, + 0 => InflationResultCode::Success, + -1 => InflationResultCode::NotTime, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -23512,14 +33358,14 @@ impl TryFrom for ChangeTrustResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: ChangeTrustResultCode) -> Self { + fn from(e: InflationResultCode) -> Self { e as Self } } -impl ReadXdr for ChangeTrustResultCode { +impl ReadXdr for InflationResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -23530,7 +33376,7 @@ impl ReadXdr for ChangeTrustResultCode { } } -impl WriteXdr for ChangeTrustResultCode { +impl WriteXdr for InflationResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -23540,24 +33386,60 @@ impl WriteXdr for ChangeTrustResultCode { } } -// ChangeTrustResult is an XDR Union defines as: +// InflationPayout is an XDR Struct defines as: // -// union ChangeTrustResult switch (ChangeTrustResultCode code) +// struct InflationPayout // or use PaymentResultAtom to limit types? // { -// case CHANGE_TRUST_SUCCESS: -// void; -// case CHANGE_TRUST_MALFORMED: -// case CHANGE_TRUST_NO_ISSUER: -// case CHANGE_TRUST_INVALID_LIMIT: -// case CHANGE_TRUST_LOW_RESERVE: -// case CHANGE_TRUST_SELF_NOT_ALLOWED: -// case CHANGE_TRUST_TRUST_LINE_MISSING: -// case CHANGE_TRUST_CANNOT_DELETE: -// case CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES: +// AccountID destination; +// int64 amount; +// }; +// +#[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 InflationPayout { + pub destination: AccountId, + pub amount: i64, +} + +impl ReadXdr for InflationPayout { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + Ok(Self { + destination: AccountId::read_xdr(r)?, + amount: i64::read_xdr(r)?, + }) + }) + } +} + +impl WriteXdr for InflationPayout { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| { + self.destination.write_xdr(w)?; + self.amount.write_xdr(w)?; + Ok(()) + }) + } +} + +// InflationResult is an XDR Union defines as: +// +// union InflationResult switch (InflationResultCode code) +// { +// case INFLATION_SUCCESS: +// InflationPayout payouts<>; +// case INFLATION_NOT_TIME: // void; // }; // -// union with discriminant ChangeTrustResultCode +// union with discriminant InflationResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -23566,119 +33448,72 @@ impl WriteXdr for ChangeTrustResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ChangeTrustResult { - Success, - Malformed, - NoIssuer, - InvalidLimit, - LowReserve, - SelfNotAllowed, - TrustLineMissing, - CannotDelete, - NotAuthMaintainLiabilities, +pub enum InflationResult { + Success(VecM), + NotTime, } -impl ChangeTrustResult { - pub const VARIANTS: [ChangeTrustResultCode; 9] = [ - ChangeTrustResultCode::Success, - ChangeTrustResultCode::Malformed, - ChangeTrustResultCode::NoIssuer, - ChangeTrustResultCode::InvalidLimit, - ChangeTrustResultCode::LowReserve, - ChangeTrustResultCode::SelfNotAllowed, - ChangeTrustResultCode::TrustLineMissing, - ChangeTrustResultCode::CannotDelete, - ChangeTrustResultCode::NotAuthMaintainLiabilities, - ]; - pub const VARIANTS_STR: [&'static str; 9] = [ - "Success", - "Malformed", - "NoIssuer", - "InvalidLimit", - "LowReserve", - "SelfNotAllowed", - "TrustLineMissing", - "CannotDelete", - "NotAuthMaintainLiabilities", - ]; +impl InflationResult { + pub const VARIANTS: [InflationResultCode; 2] = + [InflationResultCode::Success, InflationResultCode::NotTime]; + pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotTime"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success => "Success", - Self::Malformed => "Malformed", - Self::NoIssuer => "NoIssuer", - Self::InvalidLimit => "InvalidLimit", - Self::LowReserve => "LowReserve", - Self::SelfNotAllowed => "SelfNotAllowed", - Self::TrustLineMissing => "TrustLineMissing", - Self::CannotDelete => "CannotDelete", - Self::NotAuthMaintainLiabilities => "NotAuthMaintainLiabilities", + Self::Success(_) => "Success", + Self::NotTime => "NotTime", } } #[must_use] - pub const fn discriminant(&self) -> ChangeTrustResultCode { + pub const fn discriminant(&self) -> InflationResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => ChangeTrustResultCode::Success, - Self::Malformed => ChangeTrustResultCode::Malformed, - Self::NoIssuer => ChangeTrustResultCode::NoIssuer, - Self::InvalidLimit => ChangeTrustResultCode::InvalidLimit, - Self::LowReserve => ChangeTrustResultCode::LowReserve, - Self::SelfNotAllowed => ChangeTrustResultCode::SelfNotAllowed, - Self::TrustLineMissing => ChangeTrustResultCode::TrustLineMissing, - Self::CannotDelete => ChangeTrustResultCode::CannotDelete, - Self::NotAuthMaintainLiabilities => ChangeTrustResultCode::NotAuthMaintainLiabilities, + Self::Success(_) => InflationResultCode::Success, + Self::NotTime => InflationResultCode::NotTime, } } #[must_use] - pub const fn variants() -> [ChangeTrustResultCode; 9] { + pub const fn variants() -> [InflationResultCode; 2] { Self::VARIANTS } } -impl Name for ChangeTrustResult { +impl Name for InflationResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ChangeTrustResult { +impl Discriminant for InflationResult { #[must_use] - fn discriminant(&self) -> ChangeTrustResultCode { + fn discriminant(&self) -> InflationResultCode { Self::discriminant(self) } } -impl Variants for ChangeTrustResult { - fn variants() -> slice::Iter<'static, ChangeTrustResultCode> { +impl Variants for InflationResult { + fn variants() -> slice::Iter<'static, InflationResultCode> { Self::VARIANTS.iter() } } -impl Union for ChangeTrustResult {} +impl Union for InflationResult {} -impl ReadXdr for ChangeTrustResult { +impl ReadXdr for InflationResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ChangeTrustResultCode = ::read_xdr(r)?; + let dv: InflationResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ChangeTrustResultCode::Success => Self::Success, - ChangeTrustResultCode::Malformed => Self::Malformed, - ChangeTrustResultCode::NoIssuer => Self::NoIssuer, - ChangeTrustResultCode::InvalidLimit => Self::InvalidLimit, - ChangeTrustResultCode::LowReserve => Self::LowReserve, - ChangeTrustResultCode::SelfNotAllowed => Self::SelfNotAllowed, - ChangeTrustResultCode::TrustLineMissing => Self::TrustLineMissing, - ChangeTrustResultCode::CannotDelete => Self::CannotDelete, - ChangeTrustResultCode::NotAuthMaintainLiabilities => { - Self::NotAuthMaintainLiabilities + InflationResultCode::Success => { + Self::Success(VecM::::read_xdr(r)?) } + InflationResultCode::NotTime => Self::NotTime, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -23687,43 +33522,34 @@ impl ReadXdr for ChangeTrustResult { } } -impl WriteXdr for ChangeTrustResult { +impl WriteXdr for InflationResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Success => ().write_xdr(w)?, - Self::Malformed => ().write_xdr(w)?, - Self::NoIssuer => ().write_xdr(w)?, - Self::InvalidLimit => ().write_xdr(w)?, - Self::LowReserve => ().write_xdr(w)?, - Self::SelfNotAllowed => ().write_xdr(w)?, - Self::TrustLineMissing => ().write_xdr(w)?, - Self::CannotDelete => ().write_xdr(w)?, - Self::NotAuthMaintainLiabilities => ().write_xdr(w)?, + Self::Success(v) => v.write_xdr(w)?, + Self::NotTime => ().write_xdr(w)?, }; Ok(()) }) } } -// AllowTrustResultCode is an XDR Enum defines as: +// ManageDataResultCode is an XDR Enum defines as: // -// enum AllowTrustResultCode +// enum ManageDataResultCode // { // // codes considered as "success" for the operation -// ALLOW_TRUST_SUCCESS = 0, +// MANAGE_DATA_SUCCESS = 0, // // codes considered as "failure" for the operation -// ALLOW_TRUST_MALFORMED = -1, // asset is not ASSET_TYPE_ALPHANUM -// ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline -// // source account does not require trust -// ALLOW_TRUST_TRUST_NOT_REQUIRED = -3, -// ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust, -// ALLOW_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed -// ALLOW_TRUST_LOW_RESERVE = -6 // claimable balances can't be created -// // on revoke due to low reserves +// MANAGE_DATA_NOT_SUPPORTED_YET = +// -1, // The network hasn't moved to this protocol change yet +// MANAGE_DATA_NAME_NOT_FOUND = +// -2, // Trying to remove a Data Entry that isn't there +// MANAGE_DATA_LOW_RESERVE = -3, // not enough funds to create a new Data Entry +// MANAGE_DATA_INVALID_NAME = -4 // Name not a valid string // }; // // enum @@ -23735,88 +33561,78 @@ impl WriteXdr for ChangeTrustResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum AllowTrustResultCode { +pub enum ManageDataResultCode { Success = 0, - Malformed = -1, - NoTrustLine = -2, - TrustNotRequired = -3, - CantRevoke = -4, - SelfNotAllowed = -5, - LowReserve = -6, + NotSupportedYet = -1, + NameNotFound = -2, + LowReserve = -3, + InvalidName = -4, } -impl AllowTrustResultCode { - pub const VARIANTS: [AllowTrustResultCode; 7] = [ - AllowTrustResultCode::Success, - AllowTrustResultCode::Malformed, - AllowTrustResultCode::NoTrustLine, - AllowTrustResultCode::TrustNotRequired, - AllowTrustResultCode::CantRevoke, - AllowTrustResultCode::SelfNotAllowed, - AllowTrustResultCode::LowReserve, +impl ManageDataResultCode { + pub const VARIANTS: [ManageDataResultCode; 5] = [ + ManageDataResultCode::Success, + ManageDataResultCode::NotSupportedYet, + ManageDataResultCode::NameNotFound, + ManageDataResultCode::LowReserve, + ManageDataResultCode::InvalidName, ]; - pub const VARIANTS_STR: [&'static str; 7] = [ + pub const VARIANTS_STR: [&'static str; 5] = [ "Success", - "Malformed", - "NoTrustLine", - "TrustNotRequired", - "CantRevoke", - "SelfNotAllowed", + "NotSupportedYet", + "NameNotFound", "LowReserve", + "InvalidName", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::Malformed => "Malformed", - Self::NoTrustLine => "NoTrustLine", - Self::TrustNotRequired => "TrustNotRequired", - Self::CantRevoke => "CantRevoke", - Self::SelfNotAllowed => "SelfNotAllowed", + Self::NotSupportedYet => "NotSupportedYet", + Self::NameNotFound => "NameNotFound", Self::LowReserve => "LowReserve", + Self::InvalidName => "InvalidName", } } #[must_use] - pub const fn variants() -> [AllowTrustResultCode; 7] { + pub const fn variants() -> [ManageDataResultCode; 5] { Self::VARIANTS } } -impl Name for AllowTrustResultCode { +impl Name for ManageDataResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for AllowTrustResultCode { - fn variants() -> slice::Iter<'static, AllowTrustResultCode> { +impl Variants for ManageDataResultCode { + fn variants() -> slice::Iter<'static, ManageDataResultCode> { Self::VARIANTS.iter() } } -impl Enum for AllowTrustResultCode {} +impl Enum for ManageDataResultCode {} -impl fmt::Display for AllowTrustResultCode { +impl fmt::Display for ManageDataResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for AllowTrustResultCode { +impl TryFrom for ManageDataResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => AllowTrustResultCode::Success, - -1 => AllowTrustResultCode::Malformed, - -2 => AllowTrustResultCode::NoTrustLine, - -3 => AllowTrustResultCode::TrustNotRequired, - -4 => AllowTrustResultCode::CantRevoke, - -5 => AllowTrustResultCode::SelfNotAllowed, - -6 => AllowTrustResultCode::LowReserve, + 0 => ManageDataResultCode::Success, + -1 => ManageDataResultCode::NotSupportedYet, + -2 => ManageDataResultCode::NameNotFound, + -3 => ManageDataResultCode::LowReserve, + -4 => ManageDataResultCode::InvalidName, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -23824,14 +33640,14 @@ impl TryFrom for AllowTrustResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: AllowTrustResultCode) -> Self { + fn from(e: ManageDataResultCode) -> Self { e as Self } } -impl ReadXdr for AllowTrustResultCode { +impl ReadXdr for ManageDataResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -23842,7 +33658,7 @@ impl ReadXdr for AllowTrustResultCode { } } -impl WriteXdr for AllowTrustResultCode { +impl WriteXdr for ManageDataResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -23852,22 +33668,20 @@ impl WriteXdr for AllowTrustResultCode { } } -// AllowTrustResult is an XDR Union defines as: +// ManageDataResult is an XDR Union defines as: // -// union AllowTrustResult switch (AllowTrustResultCode code) +// union ManageDataResult switch (ManageDataResultCode code) // { -// case ALLOW_TRUST_SUCCESS: +// case MANAGE_DATA_SUCCESS: // void; -// case ALLOW_TRUST_MALFORMED: -// case ALLOW_TRUST_NO_TRUST_LINE: -// case ALLOW_TRUST_TRUST_NOT_REQUIRED: -// case ALLOW_TRUST_CANT_REVOKE: -// case ALLOW_TRUST_SELF_NOT_ALLOWED: -// case ALLOW_TRUST_LOW_RESERVE: +// case MANAGE_DATA_NOT_SUPPORTED_YET: +// case MANAGE_DATA_NAME_NOT_FOUND: +// case MANAGE_DATA_LOW_RESERVE: +// case MANAGE_DATA_INVALID_NAME: // void; // }; // -// union with discriminant AllowTrustResultCode +// union with discriminant ManageDataResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -23876,105 +33690,93 @@ impl WriteXdr for AllowTrustResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum AllowTrustResult { +pub enum ManageDataResult { Success, - Malformed, - NoTrustLine, - TrustNotRequired, - CantRevoke, - SelfNotAllowed, + NotSupportedYet, + NameNotFound, LowReserve, + InvalidName, } -impl AllowTrustResult { - pub const VARIANTS: [AllowTrustResultCode; 7] = [ - AllowTrustResultCode::Success, - AllowTrustResultCode::Malformed, - AllowTrustResultCode::NoTrustLine, - AllowTrustResultCode::TrustNotRequired, - AllowTrustResultCode::CantRevoke, - AllowTrustResultCode::SelfNotAllowed, - AllowTrustResultCode::LowReserve, +impl ManageDataResult { + pub const VARIANTS: [ManageDataResultCode; 5] = [ + ManageDataResultCode::Success, + ManageDataResultCode::NotSupportedYet, + ManageDataResultCode::NameNotFound, + ManageDataResultCode::LowReserve, + ManageDataResultCode::InvalidName, ]; - pub const VARIANTS_STR: [&'static str; 7] = [ + pub const VARIANTS_STR: [&'static str; 5] = [ "Success", - "Malformed", - "NoTrustLine", - "TrustNotRequired", - "CantRevoke", - "SelfNotAllowed", + "NotSupportedYet", + "NameNotFound", "LowReserve", + "InvalidName", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::Malformed => "Malformed", - Self::NoTrustLine => "NoTrustLine", - Self::TrustNotRequired => "TrustNotRequired", - Self::CantRevoke => "CantRevoke", - Self::SelfNotAllowed => "SelfNotAllowed", + Self::NotSupportedYet => "NotSupportedYet", + Self::NameNotFound => "NameNotFound", Self::LowReserve => "LowReserve", + Self::InvalidName => "InvalidName", } } #[must_use] - pub const fn discriminant(&self) -> AllowTrustResultCode { + pub const fn discriminant(&self) -> ManageDataResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => AllowTrustResultCode::Success, - Self::Malformed => AllowTrustResultCode::Malformed, - Self::NoTrustLine => AllowTrustResultCode::NoTrustLine, - Self::TrustNotRequired => AllowTrustResultCode::TrustNotRequired, - Self::CantRevoke => AllowTrustResultCode::CantRevoke, - Self::SelfNotAllowed => AllowTrustResultCode::SelfNotAllowed, - Self::LowReserve => AllowTrustResultCode::LowReserve, + Self::Success => ManageDataResultCode::Success, + Self::NotSupportedYet => ManageDataResultCode::NotSupportedYet, + Self::NameNotFound => ManageDataResultCode::NameNotFound, + Self::LowReserve => ManageDataResultCode::LowReserve, + Self::InvalidName => ManageDataResultCode::InvalidName, } } #[must_use] - pub const fn variants() -> [AllowTrustResultCode; 7] { + pub const fn variants() -> [ManageDataResultCode; 5] { Self::VARIANTS } } -impl Name for AllowTrustResult { +impl Name for ManageDataResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for AllowTrustResult { +impl Discriminant for ManageDataResult { #[must_use] - fn discriminant(&self) -> AllowTrustResultCode { + fn discriminant(&self) -> ManageDataResultCode { Self::discriminant(self) } } -impl Variants for AllowTrustResult { - fn variants() -> slice::Iter<'static, AllowTrustResultCode> { +impl Variants for ManageDataResult { + fn variants() -> slice::Iter<'static, ManageDataResultCode> { Self::VARIANTS.iter() } } -impl Union for AllowTrustResult {} +impl Union for ManageDataResult {} -impl ReadXdr for AllowTrustResult { +impl ReadXdr for ManageDataResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: AllowTrustResultCode = ::read_xdr(r)?; + let dv: ManageDataResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - AllowTrustResultCode::Success => Self::Success, - AllowTrustResultCode::Malformed => Self::Malformed, - AllowTrustResultCode::NoTrustLine => Self::NoTrustLine, - AllowTrustResultCode::TrustNotRequired => Self::TrustNotRequired, - AllowTrustResultCode::CantRevoke => Self::CantRevoke, - AllowTrustResultCode::SelfNotAllowed => Self::SelfNotAllowed, - AllowTrustResultCode::LowReserve => Self::LowReserve, + ManageDataResultCode::Success => Self::Success, + ManageDataResultCode::NotSupportedYet => Self::NotSupportedYet, + ManageDataResultCode::NameNotFound => Self::NameNotFound, + ManageDataResultCode::LowReserve => Self::LowReserve, + ManageDataResultCode::InvalidName => Self::InvalidName, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -23983,7 +33785,7 @@ impl ReadXdr for AllowTrustResult { } } -impl WriteXdr for AllowTrustResult { +impl WriteXdr for ManageDataResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -23991,33 +33793,24 @@ impl WriteXdr for AllowTrustResult { #[allow(clippy::match_same_arms)] match self { Self::Success => ().write_xdr(w)?, - Self::Malformed => ().write_xdr(w)?, - Self::NoTrustLine => ().write_xdr(w)?, - Self::TrustNotRequired => ().write_xdr(w)?, - Self::CantRevoke => ().write_xdr(w)?, - Self::SelfNotAllowed => ().write_xdr(w)?, + Self::NotSupportedYet => ().write_xdr(w)?, + Self::NameNotFound => ().write_xdr(w)?, Self::LowReserve => ().write_xdr(w)?, + Self::InvalidName => ().write_xdr(w)?, }; Ok(()) }) } } -// AccountMergeResultCode is an XDR Enum defines as: +// BumpSequenceResultCode is an XDR Enum defines as: // -// enum AccountMergeResultCode +// enum BumpSequenceResultCode // { // // codes considered as "success" for the operation -// ACCOUNT_MERGE_SUCCESS = 0, +// BUMP_SEQUENCE_SUCCESS = 0, // // codes considered as "failure" for the operation -// ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself -// ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist -// ACCOUNT_MERGE_IMMUTABLE_SET = -3, // source account has AUTH_IMMUTABLE set -// ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4, // account has trust lines/offers -// ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5, // sequence number is over max allowed -// ACCOUNT_MERGE_DEST_FULL = -6, // can't add source balance to -// // destination balance -// ACCOUNT_MERGE_IS_SPONSOR = -7 // can't merge account that is a sponsor +// BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds // }; // // enum @@ -24029,93 +33822,60 @@ impl WriteXdr for AllowTrustResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum AccountMergeResultCode { +pub enum BumpSequenceResultCode { Success = 0, - Malformed = -1, - NoAccount = -2, - ImmutableSet = -3, - HasSubEntries = -4, - SeqnumTooFar = -5, - DestFull = -6, - IsSponsor = -7, + BadSeq = -1, } -impl AccountMergeResultCode { - pub const VARIANTS: [AccountMergeResultCode; 8] = [ - AccountMergeResultCode::Success, - AccountMergeResultCode::Malformed, - AccountMergeResultCode::NoAccount, - AccountMergeResultCode::ImmutableSet, - AccountMergeResultCode::HasSubEntries, - AccountMergeResultCode::SeqnumTooFar, - AccountMergeResultCode::DestFull, - AccountMergeResultCode::IsSponsor, - ]; - pub const VARIANTS_STR: [&'static str; 8] = [ - "Success", - "Malformed", - "NoAccount", - "ImmutableSet", - "HasSubEntries", - "SeqnumTooFar", - "DestFull", - "IsSponsor", +impl BumpSequenceResultCode { + pub const VARIANTS: [BumpSequenceResultCode; 2] = [ + BumpSequenceResultCode::Success, + BumpSequenceResultCode::BadSeq, ]; + pub const VARIANTS_STR: [&'static str; 2] = ["Success", "BadSeq"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::Malformed => "Malformed", - Self::NoAccount => "NoAccount", - Self::ImmutableSet => "ImmutableSet", - Self::HasSubEntries => "HasSubEntries", - Self::SeqnumTooFar => "SeqnumTooFar", - Self::DestFull => "DestFull", - Self::IsSponsor => "IsSponsor", + Self::BadSeq => "BadSeq", } } #[must_use] - pub const fn variants() -> [AccountMergeResultCode; 8] { + pub const fn variants() -> [BumpSequenceResultCode; 2] { Self::VARIANTS } } -impl Name for AccountMergeResultCode { +impl Name for BumpSequenceResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for AccountMergeResultCode { - fn variants() -> slice::Iter<'static, AccountMergeResultCode> { +impl Variants for BumpSequenceResultCode { + fn variants() -> slice::Iter<'static, BumpSequenceResultCode> { Self::VARIANTS.iter() } } -impl Enum for AccountMergeResultCode {} +impl Enum for BumpSequenceResultCode {} -impl fmt::Display for AccountMergeResultCode { +impl fmt::Display for BumpSequenceResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for AccountMergeResultCode { +impl TryFrom for BumpSequenceResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => AccountMergeResultCode::Success, - -1 => AccountMergeResultCode::Malformed, - -2 => AccountMergeResultCode::NoAccount, - -3 => AccountMergeResultCode::ImmutableSet, - -4 => AccountMergeResultCode::HasSubEntries, - -5 => AccountMergeResultCode::SeqnumTooFar, - -6 => AccountMergeResultCode::DestFull, - -7 => AccountMergeResultCode::IsSponsor, + 0 => BumpSequenceResultCode::Success, + -1 => BumpSequenceResultCode::BadSeq, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -24123,14 +33883,14 @@ impl TryFrom for AccountMergeResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: AccountMergeResultCode) -> Self { + fn from(e: BumpSequenceResultCode) -> Self { e as Self } } -impl ReadXdr for AccountMergeResultCode { +impl ReadXdr for BumpSequenceResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -24141,7 +33901,7 @@ impl ReadXdr for AccountMergeResultCode { } } -impl WriteXdr for AccountMergeResultCode { +impl WriteXdr for BumpSequenceResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -24150,24 +33910,18 @@ impl WriteXdr for AccountMergeResultCode { }) } } - -// AccountMergeResult is an XDR Union defines as: -// -// union AccountMergeResult switch (AccountMergeResultCode code) -// { -// case ACCOUNT_MERGE_SUCCESS: -// int64 sourceAccountBalance; // how much got transferred from source account -// case ACCOUNT_MERGE_MALFORMED: -// case ACCOUNT_MERGE_NO_ACCOUNT: -// case ACCOUNT_MERGE_IMMUTABLE_SET: -// case ACCOUNT_MERGE_HAS_SUB_ENTRIES: -// case ACCOUNT_MERGE_SEQNUM_TOO_FAR: -// case ACCOUNT_MERGE_DEST_FULL: -// case ACCOUNT_MERGE_IS_SPONSOR: + +// BumpSequenceResult is an XDR Union defines as: +// +// union BumpSequenceResult switch (BumpSequenceResultCode code) +// { +// case BUMP_SEQUENCE_SUCCESS: +// void; +// case BUMP_SEQUENCE_BAD_SEQ: // void; // }; // -// union with discriminant AccountMergeResultCode +// union with discriminant BumpSequenceResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -24176,111 +33930,72 @@ impl WriteXdr for AccountMergeResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum AccountMergeResult { - Success(i64), - Malformed, - NoAccount, - ImmutableSet, - HasSubEntries, - SeqnumTooFar, - DestFull, - IsSponsor, +pub enum BumpSequenceResult { + Success, + BadSeq, } -impl AccountMergeResult { - pub const VARIANTS: [AccountMergeResultCode; 8] = [ - AccountMergeResultCode::Success, - AccountMergeResultCode::Malformed, - AccountMergeResultCode::NoAccount, - AccountMergeResultCode::ImmutableSet, - AccountMergeResultCode::HasSubEntries, - AccountMergeResultCode::SeqnumTooFar, - AccountMergeResultCode::DestFull, - AccountMergeResultCode::IsSponsor, - ]; - pub const VARIANTS_STR: [&'static str; 8] = [ - "Success", - "Malformed", - "NoAccount", - "ImmutableSet", - "HasSubEntries", - "SeqnumTooFar", - "DestFull", - "IsSponsor", +impl BumpSequenceResult { + pub const VARIANTS: [BumpSequenceResultCode; 2] = [ + BumpSequenceResultCode::Success, + BumpSequenceResultCode::BadSeq, ]; + pub const VARIANTS_STR: [&'static str; 2] = ["Success", "BadSeq"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success(_) => "Success", - Self::Malformed => "Malformed", - Self::NoAccount => "NoAccount", - Self::ImmutableSet => "ImmutableSet", - Self::HasSubEntries => "HasSubEntries", - Self::SeqnumTooFar => "SeqnumTooFar", - Self::DestFull => "DestFull", - Self::IsSponsor => "IsSponsor", + Self::Success => "Success", + Self::BadSeq => "BadSeq", } } #[must_use] - pub const fn discriminant(&self) -> AccountMergeResultCode { + pub const fn discriminant(&self) -> BumpSequenceResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success(_) => AccountMergeResultCode::Success, - Self::Malformed => AccountMergeResultCode::Malformed, - Self::NoAccount => AccountMergeResultCode::NoAccount, - Self::ImmutableSet => AccountMergeResultCode::ImmutableSet, - Self::HasSubEntries => AccountMergeResultCode::HasSubEntries, - Self::SeqnumTooFar => AccountMergeResultCode::SeqnumTooFar, - Self::DestFull => AccountMergeResultCode::DestFull, - Self::IsSponsor => AccountMergeResultCode::IsSponsor, + Self::Success => BumpSequenceResultCode::Success, + Self::BadSeq => BumpSequenceResultCode::BadSeq, } } #[must_use] - pub const fn variants() -> [AccountMergeResultCode; 8] { + pub const fn variants() -> [BumpSequenceResultCode; 2] { Self::VARIANTS } } -impl Name for AccountMergeResult { +impl Name for BumpSequenceResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for AccountMergeResult { +impl Discriminant for BumpSequenceResult { #[must_use] - fn discriminant(&self) -> AccountMergeResultCode { + fn discriminant(&self) -> BumpSequenceResultCode { Self::discriminant(self) } } -impl Variants for AccountMergeResult { - fn variants() -> slice::Iter<'static, AccountMergeResultCode> { +impl Variants for BumpSequenceResult { + fn variants() -> slice::Iter<'static, BumpSequenceResultCode> { Self::VARIANTS.iter() } } -impl Union for AccountMergeResult {} +impl Union for BumpSequenceResult {} -impl ReadXdr for AccountMergeResult { +impl ReadXdr for BumpSequenceResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: AccountMergeResultCode = ::read_xdr(r)?; + let dv: BumpSequenceResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - AccountMergeResultCode::Success => Self::Success(i64::read_xdr(r)?), - AccountMergeResultCode::Malformed => Self::Malformed, - AccountMergeResultCode::NoAccount => Self::NoAccount, - AccountMergeResultCode::ImmutableSet => Self::ImmutableSet, - AccountMergeResultCode::HasSubEntries => Self::HasSubEntries, - AccountMergeResultCode::SeqnumTooFar => Self::SeqnumTooFar, - AccountMergeResultCode::DestFull => Self::DestFull, - AccountMergeResultCode::IsSponsor => Self::IsSponsor, + BumpSequenceResultCode::Success => Self::Success, + BumpSequenceResultCode::BadSeq => Self::BadSeq, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -24289,35 +34004,31 @@ impl ReadXdr for AccountMergeResult { } } -impl WriteXdr for AccountMergeResult { +impl WriteXdr for BumpSequenceResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Success(v) => v.write_xdr(w)?, - Self::Malformed => ().write_xdr(w)?, - Self::NoAccount => ().write_xdr(w)?, - Self::ImmutableSet => ().write_xdr(w)?, - Self::HasSubEntries => ().write_xdr(w)?, - Self::SeqnumTooFar => ().write_xdr(w)?, - Self::DestFull => ().write_xdr(w)?, - Self::IsSponsor => ().write_xdr(w)?, + Self::Success => ().write_xdr(w)?, + Self::BadSeq => ().write_xdr(w)?, }; Ok(()) }) } } -// InflationResultCode is an XDR Enum defines as: +// CreateClaimableBalanceResultCode is an XDR Enum defines as: // -// enum InflationResultCode +// enum CreateClaimableBalanceResultCode // { -// // codes considered as "success" for the operation -// INFLATION_SUCCESS = 0, -// // codes considered as "failure" for the operation -// INFLATION_NOT_TIME = -1 +// CREATE_CLAIMABLE_BALANCE_SUCCESS = 0, +// CREATE_CLAIMABLE_BALANCE_MALFORMED = -1, +// CREATE_CLAIMABLE_BALANCE_LOW_RESERVE = -2, +// CREATE_CLAIMABLE_BALANCE_NO_TRUST = -3, +// CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -4, +// CREATE_CLAIMABLE_BALANCE_UNDERFUNDED = -5 // }; // // enum @@ -24329,58 +34040,83 @@ impl WriteXdr for AccountMergeResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum InflationResultCode { +pub enum CreateClaimableBalanceResultCode { Success = 0, - NotTime = -1, + Malformed = -1, + LowReserve = -2, + NoTrust = -3, + NotAuthorized = -4, + Underfunded = -5, } -impl InflationResultCode { - pub const VARIANTS: [InflationResultCode; 2] = - [InflationResultCode::Success, InflationResultCode::NotTime]; - pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotTime"]; +impl CreateClaimableBalanceResultCode { + pub const VARIANTS: [CreateClaimableBalanceResultCode; 6] = [ + CreateClaimableBalanceResultCode::Success, + CreateClaimableBalanceResultCode::Malformed, + CreateClaimableBalanceResultCode::LowReserve, + CreateClaimableBalanceResultCode::NoTrust, + CreateClaimableBalanceResultCode::NotAuthorized, + CreateClaimableBalanceResultCode::Underfunded, + ]; + pub const VARIANTS_STR: [&'static str; 6] = [ + "Success", + "Malformed", + "LowReserve", + "NoTrust", + "NotAuthorized", + "Underfunded", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::NotTime => "NotTime", + Self::Malformed => "Malformed", + Self::LowReserve => "LowReserve", + Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", + Self::Underfunded => "Underfunded", } } #[must_use] - pub const fn variants() -> [InflationResultCode; 2] { + pub const fn variants() -> [CreateClaimableBalanceResultCode; 6] { Self::VARIANTS } } -impl Name for InflationResultCode { +impl Name for CreateClaimableBalanceResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for InflationResultCode { - fn variants() -> slice::Iter<'static, InflationResultCode> { +impl Variants for CreateClaimableBalanceResultCode { + fn variants() -> slice::Iter<'static, CreateClaimableBalanceResultCode> { Self::VARIANTS.iter() } } -impl Enum for InflationResultCode {} +impl Enum for CreateClaimableBalanceResultCode {} -impl fmt::Display for InflationResultCode { +impl fmt::Display for CreateClaimableBalanceResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for InflationResultCode { +impl TryFrom for CreateClaimableBalanceResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => InflationResultCode::Success, - -1 => InflationResultCode::NotTime, + 0 => CreateClaimableBalanceResultCode::Success, + -1 => CreateClaimableBalanceResultCode::Malformed, + -2 => CreateClaimableBalanceResultCode::LowReserve, + -3 => CreateClaimableBalanceResultCode::NoTrust, + -4 => CreateClaimableBalanceResultCode::NotAuthorized, + -5 => CreateClaimableBalanceResultCode::Underfunded, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -24388,14 +34124,14 @@ impl TryFrom for InflationResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: InflationResultCode) -> Self { + fn from(e: CreateClaimableBalanceResultCode) -> Self { e as Self } } -impl ReadXdr for InflationResultCode { +impl ReadXdr for CreateClaimableBalanceResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -24406,7 +34142,7 @@ impl ReadXdr for InflationResultCode { } } -impl WriteXdr for InflationResultCode { +impl WriteXdr for CreateClaimableBalanceResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -24416,60 +34152,22 @@ impl WriteXdr for InflationResultCode { } } -// InflationPayout is an XDR Struct defines as: -// -// struct InflationPayout // or use PaymentResultAtom to limit types? -// { -// AccountID destination; -// int64 amount; -// }; -// -#[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 InflationPayout { - pub destination: AccountId, - pub amount: i64, -} - -impl ReadXdr for InflationPayout { - #[cfg(feature = "std")] - fn read_xdr(r: &mut DepthLimitedRead) -> Result { - r.with_limited_depth(|r| { - Ok(Self { - destination: AccountId::read_xdr(r)?, - amount: i64::read_xdr(r)?, - }) - }) - } -} - -impl WriteXdr for InflationPayout { - #[cfg(feature = "std")] - fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { - w.with_limited_depth(|w| { - self.destination.write_xdr(w)?; - self.amount.write_xdr(w)?; - Ok(()) - }) - } -} - -// InflationResult is an XDR Union defines as: +// CreateClaimableBalanceResult is an XDR Union defines as: // -// union InflationResult switch (InflationResultCode code) +// union CreateClaimableBalanceResult switch ( +// CreateClaimableBalanceResultCode code) // { -// case INFLATION_SUCCESS: -// InflationPayout payouts<>; -// case INFLATION_NOT_TIME: +// case CREATE_CLAIMABLE_BALANCE_SUCCESS: +// ClaimableBalanceID balanceID; +// case CREATE_CLAIMABLE_BALANCE_MALFORMED: +// case CREATE_CLAIMABLE_BALANCE_LOW_RESERVE: +// case CREATE_CLAIMABLE_BALANCE_NO_TRUST: +// case CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED: +// case CREATE_CLAIMABLE_BALANCE_UNDERFUNDED: // void; // }; // -// union with discriminant InflationResultCode +// union with discriminant CreateClaimableBalanceResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -24478,72 +34176,102 @@ impl WriteXdr for InflationPayout { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum InflationResult { - Success(VecM), - NotTime, +pub enum CreateClaimableBalanceResult { + Success(ClaimableBalanceId), + Malformed, + LowReserve, + NoTrust, + NotAuthorized, + Underfunded, } -impl InflationResult { - pub const VARIANTS: [InflationResultCode; 2] = - [InflationResultCode::Success, InflationResultCode::NotTime]; - pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotTime"]; +impl CreateClaimableBalanceResult { + pub const VARIANTS: [CreateClaimableBalanceResultCode; 6] = [ + CreateClaimableBalanceResultCode::Success, + CreateClaimableBalanceResultCode::Malformed, + CreateClaimableBalanceResultCode::LowReserve, + CreateClaimableBalanceResultCode::NoTrust, + CreateClaimableBalanceResultCode::NotAuthorized, + CreateClaimableBalanceResultCode::Underfunded, + ]; + pub const VARIANTS_STR: [&'static str; 6] = [ + "Success", + "Malformed", + "LowReserve", + "NoTrust", + "NotAuthorized", + "Underfunded", + ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success(_) => "Success", - Self::NotTime => "NotTime", + Self::Malformed => "Malformed", + Self::LowReserve => "LowReserve", + Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", + Self::Underfunded => "Underfunded", } } #[must_use] - pub const fn discriminant(&self) -> InflationResultCode { + pub const fn discriminant(&self) -> CreateClaimableBalanceResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success(_) => InflationResultCode::Success, - Self::NotTime => InflationResultCode::NotTime, + Self::Success(_) => CreateClaimableBalanceResultCode::Success, + Self::Malformed => CreateClaimableBalanceResultCode::Malformed, + Self::LowReserve => CreateClaimableBalanceResultCode::LowReserve, + Self::NoTrust => CreateClaimableBalanceResultCode::NoTrust, + Self::NotAuthorized => CreateClaimableBalanceResultCode::NotAuthorized, + Self::Underfunded => CreateClaimableBalanceResultCode::Underfunded, } } #[must_use] - pub const fn variants() -> [InflationResultCode; 2] { + pub const fn variants() -> [CreateClaimableBalanceResultCode; 6] { Self::VARIANTS } } -impl Name for InflationResult { +impl Name for CreateClaimableBalanceResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for InflationResult { +impl Discriminant for CreateClaimableBalanceResult { #[must_use] - fn discriminant(&self) -> InflationResultCode { + fn discriminant(&self) -> CreateClaimableBalanceResultCode { Self::discriminant(self) } } -impl Variants for InflationResult { - fn variants() -> slice::Iter<'static, InflationResultCode> { +impl Variants for CreateClaimableBalanceResult { + fn variants() -> slice::Iter<'static, CreateClaimableBalanceResultCode> { Self::VARIANTS.iter() } } -impl Union for InflationResult {} +impl Union for CreateClaimableBalanceResult {} -impl ReadXdr for InflationResult { +impl ReadXdr for CreateClaimableBalanceResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: InflationResultCode = ::read_xdr(r)?; + let dv: CreateClaimableBalanceResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - InflationResultCode::Success => { - Self::Success(VecM::::read_xdr(r)?) + CreateClaimableBalanceResultCode::Success => { + Self::Success(ClaimableBalanceId::read_xdr(r)?) } - InflationResultCode::NotTime => Self::NotTime, + CreateClaimableBalanceResultCode::Malformed => Self::Malformed, + CreateClaimableBalanceResultCode::LowReserve => Self::LowReserve, + CreateClaimableBalanceResultCode::NoTrust => Self::NoTrust, + CreateClaimableBalanceResultCode::NotAuthorized => Self::NotAuthorized, + CreateClaimableBalanceResultCode::Underfunded => Self::Underfunded, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -24552,7 +34280,7 @@ impl ReadXdr for InflationResult { } } -impl WriteXdr for InflationResult { +impl WriteXdr for CreateClaimableBalanceResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -24560,26 +34288,27 @@ impl WriteXdr for InflationResult { #[allow(clippy::match_same_arms)] match self { Self::Success(v) => v.write_xdr(w)?, - Self::NotTime => ().write_xdr(w)?, + Self::Malformed => ().write_xdr(w)?, + Self::LowReserve => ().write_xdr(w)?, + Self::NoTrust => ().write_xdr(w)?, + Self::NotAuthorized => ().write_xdr(w)?, + Self::Underfunded => ().write_xdr(w)?, }; Ok(()) }) } } -// ManageDataResultCode is an XDR Enum defines as: +// ClaimClaimableBalanceResultCode is an XDR Enum defines as: // -// enum ManageDataResultCode +// enum ClaimClaimableBalanceResultCode // { -// // codes considered as "success" for the operation -// MANAGE_DATA_SUCCESS = 0, -// // codes considered as "failure" for the operation -// MANAGE_DATA_NOT_SUPPORTED_YET = -// -1, // The network hasn't moved to this protocol change yet -// MANAGE_DATA_NAME_NOT_FOUND = -// -2, // Trying to remove a Data Entry that isn't there -// MANAGE_DATA_LOW_RESERVE = -3, // not enough funds to create a new Data Entry -// MANAGE_DATA_INVALID_NAME = -4 // Name not a valid string +// CLAIM_CLAIMABLE_BALANCE_SUCCESS = 0, +// CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST = -1, +// CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM = -2, +// CLAIM_CLAIMABLE_BALANCE_LINE_FULL = -3, +// CLAIM_CLAIMABLE_BALANCE_NO_TRUST = -4, +// CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -5 // }; // // enum @@ -24591,78 +34320,83 @@ impl WriteXdr for InflationResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ManageDataResultCode { +pub enum ClaimClaimableBalanceResultCode { Success = 0, - NotSupportedYet = -1, - NameNotFound = -2, - LowReserve = -3, - InvalidName = -4, + DoesNotExist = -1, + CannotClaim = -2, + LineFull = -3, + NoTrust = -4, + NotAuthorized = -5, } -impl ManageDataResultCode { - pub const VARIANTS: [ManageDataResultCode; 5] = [ - ManageDataResultCode::Success, - ManageDataResultCode::NotSupportedYet, - ManageDataResultCode::NameNotFound, - ManageDataResultCode::LowReserve, - ManageDataResultCode::InvalidName, +impl ClaimClaimableBalanceResultCode { + pub const VARIANTS: [ClaimClaimableBalanceResultCode; 6] = [ + ClaimClaimableBalanceResultCode::Success, + ClaimClaimableBalanceResultCode::DoesNotExist, + ClaimClaimableBalanceResultCode::CannotClaim, + ClaimClaimableBalanceResultCode::LineFull, + ClaimClaimableBalanceResultCode::NoTrust, + ClaimClaimableBalanceResultCode::NotAuthorized, ]; - pub const VARIANTS_STR: [&'static str; 5] = [ + pub const VARIANTS_STR: [&'static str; 6] = [ "Success", - "NotSupportedYet", - "NameNotFound", - "LowReserve", - "InvalidName", + "DoesNotExist", + "CannotClaim", + "LineFull", + "NoTrust", + "NotAuthorized", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::NotSupportedYet => "NotSupportedYet", - Self::NameNotFound => "NameNotFound", - Self::LowReserve => "LowReserve", - Self::InvalidName => "InvalidName", + Self::DoesNotExist => "DoesNotExist", + Self::CannotClaim => "CannotClaim", + Self::LineFull => "LineFull", + Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", } } #[must_use] - pub const fn variants() -> [ManageDataResultCode; 5] { + pub const fn variants() -> [ClaimClaimableBalanceResultCode; 6] { Self::VARIANTS } } -impl Name for ManageDataResultCode { +impl Name for ClaimClaimableBalanceResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ManageDataResultCode { - fn variants() -> slice::Iter<'static, ManageDataResultCode> { +impl Variants for ClaimClaimableBalanceResultCode { + fn variants() -> slice::Iter<'static, ClaimClaimableBalanceResultCode> { Self::VARIANTS.iter() } } -impl Enum for ManageDataResultCode {} +impl Enum for ClaimClaimableBalanceResultCode {} -impl fmt::Display for ManageDataResultCode { +impl fmt::Display for ClaimClaimableBalanceResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for ManageDataResultCode { +impl TryFrom for ClaimClaimableBalanceResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => ManageDataResultCode::Success, - -1 => ManageDataResultCode::NotSupportedYet, - -2 => ManageDataResultCode::NameNotFound, - -3 => ManageDataResultCode::LowReserve, - -4 => ManageDataResultCode::InvalidName, + 0 => ClaimClaimableBalanceResultCode::Success, + -1 => ClaimClaimableBalanceResultCode::DoesNotExist, + -2 => ClaimClaimableBalanceResultCode::CannotClaim, + -3 => ClaimClaimableBalanceResultCode::LineFull, + -4 => ClaimClaimableBalanceResultCode::NoTrust, + -5 => ClaimClaimableBalanceResultCode::NotAuthorized, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -24670,14 +34404,14 @@ impl TryFrom for ManageDataResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: ManageDataResultCode) -> Self { + fn from(e: ClaimClaimableBalanceResultCode) -> Self { e as Self } } -impl ReadXdr for ManageDataResultCode { +impl ReadXdr for ClaimClaimableBalanceResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -24688,7 +34422,7 @@ impl ReadXdr for ManageDataResultCode { } } -impl WriteXdr for ManageDataResultCode { +impl WriteXdr for ClaimClaimableBalanceResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -24698,20 +34432,21 @@ impl WriteXdr for ManageDataResultCode { } } -// ManageDataResult is an XDR Union defines as: +// ClaimClaimableBalanceResult is an XDR Union defines as: // -// union ManageDataResult switch (ManageDataResultCode code) +// union ClaimClaimableBalanceResult switch (ClaimClaimableBalanceResultCode code) // { -// case MANAGE_DATA_SUCCESS: +// case CLAIM_CLAIMABLE_BALANCE_SUCCESS: // void; -// case MANAGE_DATA_NOT_SUPPORTED_YET: -// case MANAGE_DATA_NAME_NOT_FOUND: -// case MANAGE_DATA_LOW_RESERVE: -// case MANAGE_DATA_INVALID_NAME: +// case CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST: +// case CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM: +// case CLAIM_CLAIMABLE_BALANCE_LINE_FULL: +// case CLAIM_CLAIMABLE_BALANCE_NO_TRUST: +// case CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED: // void; // }; // -// union with discriminant ManageDataResultCode +// union with discriminant ClaimClaimableBalanceResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -24720,93 +34455,100 @@ impl WriteXdr for ManageDataResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ManageDataResult { +pub enum ClaimClaimableBalanceResult { Success, - NotSupportedYet, - NameNotFound, - LowReserve, - InvalidName, + DoesNotExist, + CannotClaim, + LineFull, + NoTrust, + NotAuthorized, } -impl ManageDataResult { - pub const VARIANTS: [ManageDataResultCode; 5] = [ - ManageDataResultCode::Success, - ManageDataResultCode::NotSupportedYet, - ManageDataResultCode::NameNotFound, - ManageDataResultCode::LowReserve, - ManageDataResultCode::InvalidName, +impl ClaimClaimableBalanceResult { + pub const VARIANTS: [ClaimClaimableBalanceResultCode; 6] = [ + ClaimClaimableBalanceResultCode::Success, + ClaimClaimableBalanceResultCode::DoesNotExist, + ClaimClaimableBalanceResultCode::CannotClaim, + ClaimClaimableBalanceResultCode::LineFull, + ClaimClaimableBalanceResultCode::NoTrust, + ClaimClaimableBalanceResultCode::NotAuthorized, ]; - pub const VARIANTS_STR: [&'static str; 5] = [ + pub const VARIANTS_STR: [&'static str; 6] = [ "Success", - "NotSupportedYet", - "NameNotFound", - "LowReserve", - "InvalidName", + "DoesNotExist", + "CannotClaim", + "LineFull", + "NoTrust", + "NotAuthorized", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::NotSupportedYet => "NotSupportedYet", - Self::NameNotFound => "NameNotFound", - Self::LowReserve => "LowReserve", - Self::InvalidName => "InvalidName", + Self::DoesNotExist => "DoesNotExist", + Self::CannotClaim => "CannotClaim", + Self::LineFull => "LineFull", + Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", } } #[must_use] - pub const fn discriminant(&self) -> ManageDataResultCode { + pub const fn discriminant(&self) -> ClaimClaimableBalanceResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => ManageDataResultCode::Success, - Self::NotSupportedYet => ManageDataResultCode::NotSupportedYet, - Self::NameNotFound => ManageDataResultCode::NameNotFound, - Self::LowReserve => ManageDataResultCode::LowReserve, - Self::InvalidName => ManageDataResultCode::InvalidName, + Self::Success => ClaimClaimableBalanceResultCode::Success, + Self::DoesNotExist => ClaimClaimableBalanceResultCode::DoesNotExist, + Self::CannotClaim => ClaimClaimableBalanceResultCode::CannotClaim, + Self::LineFull => ClaimClaimableBalanceResultCode::LineFull, + Self::NoTrust => ClaimClaimableBalanceResultCode::NoTrust, + Self::NotAuthorized => ClaimClaimableBalanceResultCode::NotAuthorized, } } #[must_use] - pub const fn variants() -> [ManageDataResultCode; 5] { + pub const fn variants() -> [ClaimClaimableBalanceResultCode; 6] { Self::VARIANTS } } -impl Name for ManageDataResult { +impl Name for ClaimClaimableBalanceResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ManageDataResult { +impl Discriminant for ClaimClaimableBalanceResult { #[must_use] - fn discriminant(&self) -> ManageDataResultCode { + fn discriminant(&self) -> ClaimClaimableBalanceResultCode { Self::discriminant(self) } } -impl Variants for ManageDataResult { - fn variants() -> slice::Iter<'static, ManageDataResultCode> { +impl Variants for ClaimClaimableBalanceResult { + fn variants() -> slice::Iter<'static, ClaimClaimableBalanceResultCode> { Self::VARIANTS.iter() } } -impl Union for ManageDataResult {} +impl Union for ClaimClaimableBalanceResult {} -impl ReadXdr for ManageDataResult { +impl ReadXdr for ClaimClaimableBalanceResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ManageDataResultCode = ::read_xdr(r)?; + let dv: ClaimClaimableBalanceResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ManageDataResultCode::Success => Self::Success, - ManageDataResultCode::NotSupportedYet => Self::NotSupportedYet, - ManageDataResultCode::NameNotFound => Self::NameNotFound, - ManageDataResultCode::LowReserve => Self::LowReserve, - ManageDataResultCode::InvalidName => Self::InvalidName, + ClaimClaimableBalanceResultCode::Success => Self::Success, + ClaimClaimableBalanceResultCode::DoesNotExist => Self::DoesNotExist, + ClaimClaimableBalanceResultCode::CannotClaim => Self::CannotClaim, + ClaimClaimableBalanceResultCode::LineFull => Self::LineFull, + ClaimClaimableBalanceResultCode::NoTrust => Self::NoTrust, + ClaimClaimableBalanceResultCode::NotAuthorized => Self::NotAuthorized, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -24815,7 +34557,7 @@ impl ReadXdr for ManageDataResult { } } -impl WriteXdr for ManageDataResult { +impl WriteXdr for ClaimClaimableBalanceResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -24823,24 +34565,28 @@ impl WriteXdr for ManageDataResult { #[allow(clippy::match_same_arms)] match self { Self::Success => ().write_xdr(w)?, - Self::NotSupportedYet => ().write_xdr(w)?, - Self::NameNotFound => ().write_xdr(w)?, - Self::LowReserve => ().write_xdr(w)?, - Self::InvalidName => ().write_xdr(w)?, + Self::DoesNotExist => ().write_xdr(w)?, + Self::CannotClaim => ().write_xdr(w)?, + Self::LineFull => ().write_xdr(w)?, + Self::NoTrust => ().write_xdr(w)?, + Self::NotAuthorized => ().write_xdr(w)?, }; Ok(()) }) } } -// BumpSequenceResultCode is an XDR Enum defines as: +// BeginSponsoringFutureReservesResultCode is an XDR Enum defines as: // -// enum BumpSequenceResultCode +// enum BeginSponsoringFutureReservesResultCode // { // // codes considered as "success" for the operation -// BUMP_SEQUENCE_SUCCESS = 0, +// BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS = 0, +// // // codes considered as "failure" for the operation -// BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds +// BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED = -1, +// BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED = -2, +// BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE = -3 // }; // // enum @@ -24852,60 +34598,69 @@ impl WriteXdr for ManageDataResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum BumpSequenceResultCode { +pub enum BeginSponsoringFutureReservesResultCode { Success = 0, - BadSeq = -1, + Malformed = -1, + AlreadySponsored = -2, + Recursive = -3, } -impl BumpSequenceResultCode { - pub const VARIANTS: [BumpSequenceResultCode; 2] = [ - BumpSequenceResultCode::Success, - BumpSequenceResultCode::BadSeq, +impl BeginSponsoringFutureReservesResultCode { + pub const VARIANTS: [BeginSponsoringFutureReservesResultCode; 4] = [ + BeginSponsoringFutureReservesResultCode::Success, + BeginSponsoringFutureReservesResultCode::Malformed, + BeginSponsoringFutureReservesResultCode::AlreadySponsored, + BeginSponsoringFutureReservesResultCode::Recursive, ]; - pub const VARIANTS_STR: [&'static str; 2] = ["Success", "BadSeq"]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Success", "Malformed", "AlreadySponsored", "Recursive"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::BadSeq => "BadSeq", + Self::Malformed => "Malformed", + Self::AlreadySponsored => "AlreadySponsored", + Self::Recursive => "Recursive", } } #[must_use] - pub const fn variants() -> [BumpSequenceResultCode; 2] { + pub const fn variants() -> [BeginSponsoringFutureReservesResultCode; 4] { Self::VARIANTS } } -impl Name for BumpSequenceResultCode { +impl Name for BeginSponsoringFutureReservesResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for BumpSequenceResultCode { - fn variants() -> slice::Iter<'static, BumpSequenceResultCode> { +impl Variants for BeginSponsoringFutureReservesResultCode { + fn variants() -> slice::Iter<'static, BeginSponsoringFutureReservesResultCode> { Self::VARIANTS.iter() } } -impl Enum for BumpSequenceResultCode {} +impl Enum for BeginSponsoringFutureReservesResultCode {} -impl fmt::Display for BumpSequenceResultCode { +impl fmt::Display for BeginSponsoringFutureReservesResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for BumpSequenceResultCode { +impl TryFrom for BeginSponsoringFutureReservesResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => BumpSequenceResultCode::Success, - -1 => BumpSequenceResultCode::BadSeq, + 0 => BeginSponsoringFutureReservesResultCode::Success, + -1 => BeginSponsoringFutureReservesResultCode::Malformed, + -2 => BeginSponsoringFutureReservesResultCode::AlreadySponsored, + -3 => BeginSponsoringFutureReservesResultCode::Recursive, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -24913,14 +34668,14 @@ impl TryFrom for BumpSequenceResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: BumpSequenceResultCode) -> Self { + fn from(e: BeginSponsoringFutureReservesResultCode) -> Self { e as Self } } -impl ReadXdr for BumpSequenceResultCode { +impl ReadXdr for BeginSponsoringFutureReservesResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -24931,7 +34686,7 @@ impl ReadXdr for BumpSequenceResultCode { } } -impl WriteXdr for BumpSequenceResultCode { +impl WriteXdr for BeginSponsoringFutureReservesResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -24941,17 +34696,20 @@ impl WriteXdr for BumpSequenceResultCode { } } -// BumpSequenceResult is an XDR Union defines as: +// BeginSponsoringFutureReservesResult is an XDR Union defines as: // -// union BumpSequenceResult switch (BumpSequenceResultCode code) +// union BeginSponsoringFutureReservesResult switch ( +// BeginSponsoringFutureReservesResultCode code) // { -// case BUMP_SEQUENCE_SUCCESS: +// case BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS: // void; -// case BUMP_SEQUENCE_BAD_SEQ: +// case BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED: +// case BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED: +// case BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE: // void; // }; // -// union with discriminant BumpSequenceResultCode +// union with discriminant BeginSponsoringFutureReservesResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -24960,72 +34718,84 @@ impl WriteXdr for BumpSequenceResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum BumpSequenceResult { +pub enum BeginSponsoringFutureReservesResult { Success, - BadSeq, + Malformed, + AlreadySponsored, + Recursive, } -impl BumpSequenceResult { - pub const VARIANTS: [BumpSequenceResultCode; 2] = [ - BumpSequenceResultCode::Success, - BumpSequenceResultCode::BadSeq, +impl BeginSponsoringFutureReservesResult { + pub const VARIANTS: [BeginSponsoringFutureReservesResultCode; 4] = [ + BeginSponsoringFutureReservesResultCode::Success, + BeginSponsoringFutureReservesResultCode::Malformed, + BeginSponsoringFutureReservesResultCode::AlreadySponsored, + BeginSponsoringFutureReservesResultCode::Recursive, ]; - pub const VARIANTS_STR: [&'static str; 2] = ["Success", "BadSeq"]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Success", "Malformed", "AlreadySponsored", "Recursive"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::BadSeq => "BadSeq", + Self::Malformed => "Malformed", + Self::AlreadySponsored => "AlreadySponsored", + Self::Recursive => "Recursive", } } #[must_use] - pub const fn discriminant(&self) -> BumpSequenceResultCode { + pub const fn discriminant(&self) -> BeginSponsoringFutureReservesResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => BumpSequenceResultCode::Success, - Self::BadSeq => BumpSequenceResultCode::BadSeq, + Self::Success => BeginSponsoringFutureReservesResultCode::Success, + Self::Malformed => BeginSponsoringFutureReservesResultCode::Malformed, + Self::AlreadySponsored => BeginSponsoringFutureReservesResultCode::AlreadySponsored, + Self::Recursive => BeginSponsoringFutureReservesResultCode::Recursive, } } #[must_use] - pub const fn variants() -> [BumpSequenceResultCode; 2] { + pub const fn variants() -> [BeginSponsoringFutureReservesResultCode; 4] { Self::VARIANTS } } -impl Name for BumpSequenceResult { +impl Name for BeginSponsoringFutureReservesResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for BumpSequenceResult { +impl Discriminant for BeginSponsoringFutureReservesResult { #[must_use] - fn discriminant(&self) -> BumpSequenceResultCode { + fn discriminant(&self) -> BeginSponsoringFutureReservesResultCode { Self::discriminant(self) } } -impl Variants for BumpSequenceResult { - fn variants() -> slice::Iter<'static, BumpSequenceResultCode> { +impl Variants for BeginSponsoringFutureReservesResult { + fn variants() -> slice::Iter<'static, BeginSponsoringFutureReservesResultCode> { Self::VARIANTS.iter() } } -impl Union for BumpSequenceResult {} +impl Union for BeginSponsoringFutureReservesResult {} -impl ReadXdr for BumpSequenceResult { +impl ReadXdr for BeginSponsoringFutureReservesResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: BumpSequenceResultCode = ::read_xdr(r)?; + let dv: BeginSponsoringFutureReservesResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - BumpSequenceResultCode::Success => Self::Success, - BumpSequenceResultCode::BadSeq => Self::BadSeq, + BeginSponsoringFutureReservesResultCode::Success => Self::Success, + BeginSponsoringFutureReservesResultCode::Malformed => Self::Malformed, + BeginSponsoringFutureReservesResultCode::AlreadySponsored => Self::AlreadySponsored, + BeginSponsoringFutureReservesResultCode::Recursive => Self::Recursive, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25034,7 +34804,7 @@ impl ReadXdr for BumpSequenceResult { } } -impl WriteXdr for BumpSequenceResult { +impl WriteXdr for BeginSponsoringFutureReservesResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -25042,23 +34812,24 @@ impl WriteXdr for BumpSequenceResult { #[allow(clippy::match_same_arms)] match self { Self::Success => ().write_xdr(w)?, - Self::BadSeq => ().write_xdr(w)?, + Self::Malformed => ().write_xdr(w)?, + Self::AlreadySponsored => ().write_xdr(w)?, + Self::Recursive => ().write_xdr(w)?, }; Ok(()) }) } } -// CreateClaimableBalanceResultCode is an XDR Enum defines as: +// EndSponsoringFutureReservesResultCode is an XDR Enum defines as: // -// enum CreateClaimableBalanceResultCode +// enum EndSponsoringFutureReservesResultCode // { -// CREATE_CLAIMABLE_BALANCE_SUCCESS = 0, -// CREATE_CLAIMABLE_BALANCE_MALFORMED = -1, -// CREATE_CLAIMABLE_BALANCE_LOW_RESERVE = -2, -// CREATE_CLAIMABLE_BALANCE_NO_TRUST = -3, -// CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -4, -// CREATE_CLAIMABLE_BALANCE_UNDERFUNDED = -5 +// // codes considered as "success" for the operation +// END_SPONSORING_FUTURE_RESERVES_SUCCESS = 0, +// +// // codes considered as "failure" for the operation +// END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED = -1 // }; // // enum @@ -25070,83 +34841,60 @@ impl WriteXdr for BumpSequenceResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum CreateClaimableBalanceResultCode { +pub enum EndSponsoringFutureReservesResultCode { Success = 0, - Malformed = -1, - LowReserve = -2, - NoTrust = -3, - NotAuthorized = -4, - Underfunded = -5, + NotSponsored = -1, } -impl CreateClaimableBalanceResultCode { - pub const VARIANTS: [CreateClaimableBalanceResultCode; 6] = [ - CreateClaimableBalanceResultCode::Success, - CreateClaimableBalanceResultCode::Malformed, - CreateClaimableBalanceResultCode::LowReserve, - CreateClaimableBalanceResultCode::NoTrust, - CreateClaimableBalanceResultCode::NotAuthorized, - CreateClaimableBalanceResultCode::Underfunded, - ]; - pub const VARIANTS_STR: [&'static str; 6] = [ - "Success", - "Malformed", - "LowReserve", - "NoTrust", - "NotAuthorized", - "Underfunded", +impl EndSponsoringFutureReservesResultCode { + pub const VARIANTS: [EndSponsoringFutureReservesResultCode; 2] = [ + EndSponsoringFutureReservesResultCode::Success, + EndSponsoringFutureReservesResultCode::NotSponsored, ]; + pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotSponsored"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::Malformed => "Malformed", - Self::LowReserve => "LowReserve", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", - Self::Underfunded => "Underfunded", + Self::NotSponsored => "NotSponsored", } } #[must_use] - pub const fn variants() -> [CreateClaimableBalanceResultCode; 6] { + pub const fn variants() -> [EndSponsoringFutureReservesResultCode; 2] { Self::VARIANTS } } -impl Name for CreateClaimableBalanceResultCode { +impl Name for EndSponsoringFutureReservesResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for CreateClaimableBalanceResultCode { - fn variants() -> slice::Iter<'static, CreateClaimableBalanceResultCode> { +impl Variants for EndSponsoringFutureReservesResultCode { + fn variants() -> slice::Iter<'static, EndSponsoringFutureReservesResultCode> { Self::VARIANTS.iter() } } -impl Enum for CreateClaimableBalanceResultCode {} +impl Enum for EndSponsoringFutureReservesResultCode {} -impl fmt::Display for CreateClaimableBalanceResultCode { +impl fmt::Display for EndSponsoringFutureReservesResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for CreateClaimableBalanceResultCode { +impl TryFrom for EndSponsoringFutureReservesResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => CreateClaimableBalanceResultCode::Success, - -1 => CreateClaimableBalanceResultCode::Malformed, - -2 => CreateClaimableBalanceResultCode::LowReserve, - -3 => CreateClaimableBalanceResultCode::NoTrust, - -4 => CreateClaimableBalanceResultCode::NotAuthorized, - -5 => CreateClaimableBalanceResultCode::Underfunded, + 0 => EndSponsoringFutureReservesResultCode::Success, + -1 => EndSponsoringFutureReservesResultCode::NotSponsored, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25154,14 +34902,14 @@ impl TryFrom for CreateClaimableBalanceResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: CreateClaimableBalanceResultCode) -> Self { + fn from(e: EndSponsoringFutureReservesResultCode) -> Self { e as Self } } -impl ReadXdr for CreateClaimableBalanceResultCode { +impl ReadXdr for EndSponsoringFutureReservesResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -25172,7 +34920,7 @@ impl ReadXdr for CreateClaimableBalanceResultCode { } } -impl WriteXdr for CreateClaimableBalanceResultCode { +impl WriteXdr for EndSponsoringFutureReservesResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -25182,22 +34930,18 @@ impl WriteXdr for CreateClaimableBalanceResultCode { } } -// CreateClaimableBalanceResult is an XDR Union defines as: +// EndSponsoringFutureReservesResult is an XDR Union defines as: // -// union CreateClaimableBalanceResult switch ( -// CreateClaimableBalanceResultCode code) +// union EndSponsoringFutureReservesResult switch ( +// EndSponsoringFutureReservesResultCode code) // { -// case CREATE_CLAIMABLE_BALANCE_SUCCESS: -// ClaimableBalanceID balanceID; -// case CREATE_CLAIMABLE_BALANCE_MALFORMED: -// case CREATE_CLAIMABLE_BALANCE_LOW_RESERVE: -// case CREATE_CLAIMABLE_BALANCE_NO_TRUST: -// case CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED: -// case CREATE_CLAIMABLE_BALANCE_UNDERFUNDED: +// case END_SPONSORING_FUTURE_RESERVES_SUCCESS: +// void; +// case END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED: // void; // }; // -// union with discriminant CreateClaimableBalanceResultCode +// union with discriminant EndSponsoringFutureReservesResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -25206,102 +34950,73 @@ impl WriteXdr for CreateClaimableBalanceResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum CreateClaimableBalanceResult { - Success(ClaimableBalanceId), - Malformed, - LowReserve, - NoTrust, - NotAuthorized, - Underfunded, +pub enum EndSponsoringFutureReservesResult { + Success, + NotSponsored, } -impl CreateClaimableBalanceResult { - pub const VARIANTS: [CreateClaimableBalanceResultCode; 6] = [ - CreateClaimableBalanceResultCode::Success, - CreateClaimableBalanceResultCode::Malformed, - CreateClaimableBalanceResultCode::LowReserve, - CreateClaimableBalanceResultCode::NoTrust, - CreateClaimableBalanceResultCode::NotAuthorized, - CreateClaimableBalanceResultCode::Underfunded, - ]; - pub const VARIANTS_STR: [&'static str; 6] = [ - "Success", - "Malformed", - "LowReserve", - "NoTrust", - "NotAuthorized", - "Underfunded", +impl EndSponsoringFutureReservesResult { + pub const VARIANTS: [EndSponsoringFutureReservesResultCode; 2] = [ + EndSponsoringFutureReservesResultCode::Success, + EndSponsoringFutureReservesResultCode::NotSponsored, ]; + pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotSponsored"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success(_) => "Success", - Self::Malformed => "Malformed", - Self::LowReserve => "LowReserve", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", - Self::Underfunded => "Underfunded", + Self::Success => "Success", + Self::NotSponsored => "NotSponsored", } } #[must_use] - pub const fn discriminant(&self) -> CreateClaimableBalanceResultCode { + pub const fn discriminant(&self) -> EndSponsoringFutureReservesResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success(_) => CreateClaimableBalanceResultCode::Success, - Self::Malformed => CreateClaimableBalanceResultCode::Malformed, - Self::LowReserve => CreateClaimableBalanceResultCode::LowReserve, - Self::NoTrust => CreateClaimableBalanceResultCode::NoTrust, - Self::NotAuthorized => CreateClaimableBalanceResultCode::NotAuthorized, - Self::Underfunded => CreateClaimableBalanceResultCode::Underfunded, + Self::Success => EndSponsoringFutureReservesResultCode::Success, + Self::NotSponsored => EndSponsoringFutureReservesResultCode::NotSponsored, } } #[must_use] - pub const fn variants() -> [CreateClaimableBalanceResultCode; 6] { + pub const fn variants() -> [EndSponsoringFutureReservesResultCode; 2] { Self::VARIANTS } } -impl Name for CreateClaimableBalanceResult { +impl Name for EndSponsoringFutureReservesResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for CreateClaimableBalanceResult { +impl Discriminant for EndSponsoringFutureReservesResult { #[must_use] - fn discriminant(&self) -> CreateClaimableBalanceResultCode { + fn discriminant(&self) -> EndSponsoringFutureReservesResultCode { Self::discriminant(self) } } -impl Variants for CreateClaimableBalanceResult { - fn variants() -> slice::Iter<'static, CreateClaimableBalanceResultCode> { +impl Variants for EndSponsoringFutureReservesResult { + fn variants() -> slice::Iter<'static, EndSponsoringFutureReservesResultCode> { Self::VARIANTS.iter() } } -impl Union for CreateClaimableBalanceResult {} +impl Union for EndSponsoringFutureReservesResult {} -impl ReadXdr for CreateClaimableBalanceResult { +impl ReadXdr for EndSponsoringFutureReservesResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: CreateClaimableBalanceResultCode = - ::read_xdr(r)?; + let dv: EndSponsoringFutureReservesResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - CreateClaimableBalanceResultCode::Success => { - Self::Success(ClaimableBalanceId::read_xdr(r)?) - } - CreateClaimableBalanceResultCode::Malformed => Self::Malformed, - CreateClaimableBalanceResultCode::LowReserve => Self::LowReserve, - CreateClaimableBalanceResultCode::NoTrust => Self::NoTrust, - CreateClaimableBalanceResultCode::NotAuthorized => Self::NotAuthorized, - CreateClaimableBalanceResultCode::Underfunded => Self::Underfunded, + EndSponsoringFutureReservesResultCode::Success => Self::Success, + EndSponsoringFutureReservesResultCode::NotSponsored => Self::NotSponsored, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25310,35 +35025,34 @@ impl ReadXdr for CreateClaimableBalanceResult { } } -impl WriteXdr for CreateClaimableBalanceResult { +impl WriteXdr for EndSponsoringFutureReservesResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Success(v) => v.write_xdr(w)?, - Self::Malformed => ().write_xdr(w)?, - Self::LowReserve => ().write_xdr(w)?, - Self::NoTrust => ().write_xdr(w)?, - Self::NotAuthorized => ().write_xdr(w)?, - Self::Underfunded => ().write_xdr(w)?, + Self::Success => ().write_xdr(w)?, + Self::NotSponsored => ().write_xdr(w)?, }; Ok(()) }) } } -// ClaimClaimableBalanceResultCode is an XDR Enum defines as: +// RevokeSponsorshipResultCode is an XDR Enum defines as: // -// enum ClaimClaimableBalanceResultCode +// enum RevokeSponsorshipResultCode // { -// CLAIM_CLAIMABLE_BALANCE_SUCCESS = 0, -// CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST = -1, -// CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM = -2, -// CLAIM_CLAIMABLE_BALANCE_LINE_FULL = -3, -// CLAIM_CLAIMABLE_BALANCE_NO_TRUST = -4, -// CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -5 +// // codes considered as "success" for the operation +// REVOKE_SPONSORSHIP_SUCCESS = 0, +// +// // codes considered as "failure" for the operation +// REVOKE_SPONSORSHIP_DOES_NOT_EXIST = -1, +// REVOKE_SPONSORSHIP_NOT_SPONSOR = -2, +// REVOKE_SPONSORSHIP_LOW_RESERVE = -3, +// REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE = -4, +// REVOKE_SPONSORSHIP_MALFORMED = -5 // }; // // enum @@ -25350,31 +35064,31 @@ impl WriteXdr for CreateClaimableBalanceResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ClaimClaimableBalanceResultCode { +pub enum RevokeSponsorshipResultCode { Success = 0, DoesNotExist = -1, - CannotClaim = -2, - LineFull = -3, - NoTrust = -4, - NotAuthorized = -5, + NotSponsor = -2, + LowReserve = -3, + OnlyTransferable = -4, + Malformed = -5, } -impl ClaimClaimableBalanceResultCode { - pub const VARIANTS: [ClaimClaimableBalanceResultCode; 6] = [ - ClaimClaimableBalanceResultCode::Success, - ClaimClaimableBalanceResultCode::DoesNotExist, - ClaimClaimableBalanceResultCode::CannotClaim, - ClaimClaimableBalanceResultCode::LineFull, - ClaimClaimableBalanceResultCode::NoTrust, - ClaimClaimableBalanceResultCode::NotAuthorized, +impl RevokeSponsorshipResultCode { + pub const VARIANTS: [RevokeSponsorshipResultCode; 6] = [ + RevokeSponsorshipResultCode::Success, + RevokeSponsorshipResultCode::DoesNotExist, + RevokeSponsorshipResultCode::NotSponsor, + RevokeSponsorshipResultCode::LowReserve, + RevokeSponsorshipResultCode::OnlyTransferable, + RevokeSponsorshipResultCode::Malformed, ]; pub const VARIANTS_STR: [&'static str; 6] = [ "Success", "DoesNotExist", - "CannotClaim", - "LineFull", - "NoTrust", - "NotAuthorized", + "NotSponsor", + "LowReserve", + "OnlyTransferable", + "Malformed", ]; #[must_use] @@ -25382,51 +35096,51 @@ impl ClaimClaimableBalanceResultCode { match self { Self::Success => "Success", Self::DoesNotExist => "DoesNotExist", - Self::CannotClaim => "CannotClaim", - Self::LineFull => "LineFull", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", + Self::NotSponsor => "NotSponsor", + Self::LowReserve => "LowReserve", + Self::OnlyTransferable => "OnlyTransferable", + Self::Malformed => "Malformed", } } #[must_use] - pub const fn variants() -> [ClaimClaimableBalanceResultCode; 6] { + pub const fn variants() -> [RevokeSponsorshipResultCode; 6] { Self::VARIANTS } } -impl Name for ClaimClaimableBalanceResultCode { +impl Name for RevokeSponsorshipResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ClaimClaimableBalanceResultCode { - fn variants() -> slice::Iter<'static, ClaimClaimableBalanceResultCode> { +impl Variants for RevokeSponsorshipResultCode { + fn variants() -> slice::Iter<'static, RevokeSponsorshipResultCode> { Self::VARIANTS.iter() } } -impl Enum for ClaimClaimableBalanceResultCode {} +impl Enum for RevokeSponsorshipResultCode {} -impl fmt::Display for ClaimClaimableBalanceResultCode { +impl fmt::Display for RevokeSponsorshipResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for ClaimClaimableBalanceResultCode { +impl TryFrom for RevokeSponsorshipResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => ClaimClaimableBalanceResultCode::Success, - -1 => ClaimClaimableBalanceResultCode::DoesNotExist, - -2 => ClaimClaimableBalanceResultCode::CannotClaim, - -3 => ClaimClaimableBalanceResultCode::LineFull, - -4 => ClaimClaimableBalanceResultCode::NoTrust, - -5 => ClaimClaimableBalanceResultCode::NotAuthorized, + 0 => RevokeSponsorshipResultCode::Success, + -1 => RevokeSponsorshipResultCode::DoesNotExist, + -2 => RevokeSponsorshipResultCode::NotSponsor, + -3 => RevokeSponsorshipResultCode::LowReserve, + -4 => RevokeSponsorshipResultCode::OnlyTransferable, + -5 => RevokeSponsorshipResultCode::Malformed, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25434,14 +35148,14 @@ impl TryFrom for ClaimClaimableBalanceResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: ClaimClaimableBalanceResultCode) -> Self { + fn from(e: RevokeSponsorshipResultCode) -> Self { e as Self } } -impl ReadXdr for ClaimClaimableBalanceResultCode { +impl ReadXdr for RevokeSponsorshipResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -25452,7 +35166,7 @@ impl ReadXdr for ClaimClaimableBalanceResultCode { } } -impl WriteXdr for ClaimClaimableBalanceResultCode { +impl WriteXdr for RevokeSponsorshipResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -25462,21 +35176,21 @@ impl WriteXdr for ClaimClaimableBalanceResultCode { } } -// ClaimClaimableBalanceResult is an XDR Union defines as: +// RevokeSponsorshipResult is an XDR Union defines as: // -// union ClaimClaimableBalanceResult switch (ClaimClaimableBalanceResultCode code) +// union RevokeSponsorshipResult switch (RevokeSponsorshipResultCode code) // { -// case CLAIM_CLAIMABLE_BALANCE_SUCCESS: +// case REVOKE_SPONSORSHIP_SUCCESS: // void; -// case CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST: -// case CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM: -// case CLAIM_CLAIMABLE_BALANCE_LINE_FULL: -// case CLAIM_CLAIMABLE_BALANCE_NO_TRUST: -// case CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED: +// case REVOKE_SPONSORSHIP_DOES_NOT_EXIST: +// case REVOKE_SPONSORSHIP_NOT_SPONSOR: +// case REVOKE_SPONSORSHIP_LOW_RESERVE: +// case REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE: +// case REVOKE_SPONSORSHIP_MALFORMED: // void; // }; // -// union with discriminant ClaimClaimableBalanceResultCode +// union with discriminant RevokeSponsorshipResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -25485,100 +35199,100 @@ impl WriteXdr for ClaimClaimableBalanceResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ClaimClaimableBalanceResult { +pub enum RevokeSponsorshipResult { Success, DoesNotExist, - CannotClaim, - LineFull, - NoTrust, - NotAuthorized, + NotSponsor, + LowReserve, + OnlyTransferable, + Malformed, } -impl ClaimClaimableBalanceResult { - pub const VARIANTS: [ClaimClaimableBalanceResultCode; 6] = [ - ClaimClaimableBalanceResultCode::Success, - ClaimClaimableBalanceResultCode::DoesNotExist, - ClaimClaimableBalanceResultCode::CannotClaim, - ClaimClaimableBalanceResultCode::LineFull, - ClaimClaimableBalanceResultCode::NoTrust, - ClaimClaimableBalanceResultCode::NotAuthorized, +impl RevokeSponsorshipResult { + pub const VARIANTS: [RevokeSponsorshipResultCode; 6] = [ + RevokeSponsorshipResultCode::Success, + RevokeSponsorshipResultCode::DoesNotExist, + RevokeSponsorshipResultCode::NotSponsor, + RevokeSponsorshipResultCode::LowReserve, + RevokeSponsorshipResultCode::OnlyTransferable, + RevokeSponsorshipResultCode::Malformed, ]; pub const VARIANTS_STR: [&'static str; 6] = [ "Success", "DoesNotExist", - "CannotClaim", - "LineFull", - "NoTrust", - "NotAuthorized", + "NotSponsor", + "LowReserve", + "OnlyTransferable", + "Malformed", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success => "Success", - Self::DoesNotExist => "DoesNotExist", - Self::CannotClaim => "CannotClaim", - Self::LineFull => "LineFull", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", + Self::Success => "Success", + Self::DoesNotExist => "DoesNotExist", + Self::NotSponsor => "NotSponsor", + Self::LowReserve => "LowReserve", + Self::OnlyTransferable => "OnlyTransferable", + Self::Malformed => "Malformed", } } #[must_use] - pub const fn discriminant(&self) -> ClaimClaimableBalanceResultCode { + pub const fn discriminant(&self) -> RevokeSponsorshipResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => ClaimClaimableBalanceResultCode::Success, - Self::DoesNotExist => ClaimClaimableBalanceResultCode::DoesNotExist, - Self::CannotClaim => ClaimClaimableBalanceResultCode::CannotClaim, - Self::LineFull => ClaimClaimableBalanceResultCode::LineFull, - Self::NoTrust => ClaimClaimableBalanceResultCode::NoTrust, - Self::NotAuthorized => ClaimClaimableBalanceResultCode::NotAuthorized, + Self::Success => RevokeSponsorshipResultCode::Success, + Self::DoesNotExist => RevokeSponsorshipResultCode::DoesNotExist, + Self::NotSponsor => RevokeSponsorshipResultCode::NotSponsor, + Self::LowReserve => RevokeSponsorshipResultCode::LowReserve, + Self::OnlyTransferable => RevokeSponsorshipResultCode::OnlyTransferable, + Self::Malformed => RevokeSponsorshipResultCode::Malformed, } } #[must_use] - pub const fn variants() -> [ClaimClaimableBalanceResultCode; 6] { + pub const fn variants() -> [RevokeSponsorshipResultCode; 6] { Self::VARIANTS } } -impl Name for ClaimClaimableBalanceResult { +impl Name for RevokeSponsorshipResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ClaimClaimableBalanceResult { +impl Discriminant for RevokeSponsorshipResult { #[must_use] - fn discriminant(&self) -> ClaimClaimableBalanceResultCode { + fn discriminant(&self) -> RevokeSponsorshipResultCode { Self::discriminant(self) } } -impl Variants for ClaimClaimableBalanceResult { - fn variants() -> slice::Iter<'static, ClaimClaimableBalanceResultCode> { +impl Variants for RevokeSponsorshipResult { + fn variants() -> slice::Iter<'static, RevokeSponsorshipResultCode> { Self::VARIANTS.iter() } } -impl Union for ClaimClaimableBalanceResult {} +impl Union for RevokeSponsorshipResult {} -impl ReadXdr for ClaimClaimableBalanceResult { +impl ReadXdr for RevokeSponsorshipResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ClaimClaimableBalanceResultCode = - ::read_xdr(r)?; + let dv: RevokeSponsorshipResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ClaimClaimableBalanceResultCode::Success => Self::Success, - ClaimClaimableBalanceResultCode::DoesNotExist => Self::DoesNotExist, - ClaimClaimableBalanceResultCode::CannotClaim => Self::CannotClaim, - ClaimClaimableBalanceResultCode::LineFull => Self::LineFull, - ClaimClaimableBalanceResultCode::NoTrust => Self::NoTrust, - ClaimClaimableBalanceResultCode::NotAuthorized => Self::NotAuthorized, + RevokeSponsorshipResultCode::Success => Self::Success, + RevokeSponsorshipResultCode::DoesNotExist => Self::DoesNotExist, + RevokeSponsorshipResultCode::NotSponsor => Self::NotSponsor, + RevokeSponsorshipResultCode::LowReserve => Self::LowReserve, + RevokeSponsorshipResultCode::OnlyTransferable => Self::OnlyTransferable, + RevokeSponsorshipResultCode::Malformed => Self::Malformed, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25587,7 +35301,7 @@ impl ReadXdr for ClaimClaimableBalanceResult { } } -impl WriteXdr for ClaimClaimableBalanceResult { +impl WriteXdr for RevokeSponsorshipResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -25596,27 +35310,28 @@ impl WriteXdr for ClaimClaimableBalanceResult { match self { Self::Success => ().write_xdr(w)?, Self::DoesNotExist => ().write_xdr(w)?, - Self::CannotClaim => ().write_xdr(w)?, - Self::LineFull => ().write_xdr(w)?, - Self::NoTrust => ().write_xdr(w)?, - Self::NotAuthorized => ().write_xdr(w)?, + Self::NotSponsor => ().write_xdr(w)?, + Self::LowReserve => ().write_xdr(w)?, + Self::OnlyTransferable => ().write_xdr(w)?, + Self::Malformed => ().write_xdr(w)?, }; Ok(()) }) } } -// BeginSponsoringFutureReservesResultCode is an XDR Enum defines as: +// ClawbackResultCode is an XDR Enum defines as: // -// enum BeginSponsoringFutureReservesResultCode +// enum ClawbackResultCode // { // // codes considered as "success" for the operation -// BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS = 0, +// CLAWBACK_SUCCESS = 0, // // // codes considered as "failure" for the operation -// BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED = -1, -// BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED = -2, -// BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE = -3 +// CLAWBACK_MALFORMED = -1, +// CLAWBACK_NOT_CLAWBACK_ENABLED = -2, +// CLAWBACK_NO_TRUST = -3, +// CLAWBACK_UNDERFUNDED = -4 // }; // // enum @@ -25628,69 +35343,78 @@ impl WriteXdr for ClaimClaimableBalanceResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum BeginSponsoringFutureReservesResultCode { +pub enum ClawbackResultCode { Success = 0, Malformed = -1, - AlreadySponsored = -2, - Recursive = -3, + NotClawbackEnabled = -2, + NoTrust = -3, + Underfunded = -4, } -impl BeginSponsoringFutureReservesResultCode { - pub const VARIANTS: [BeginSponsoringFutureReservesResultCode; 4] = [ - BeginSponsoringFutureReservesResultCode::Success, - BeginSponsoringFutureReservesResultCode::Malformed, - BeginSponsoringFutureReservesResultCode::AlreadySponsored, - BeginSponsoringFutureReservesResultCode::Recursive, +impl ClawbackResultCode { + pub const VARIANTS: [ClawbackResultCode; 5] = [ + ClawbackResultCode::Success, + ClawbackResultCode::Malformed, + ClawbackResultCode::NotClawbackEnabled, + ClawbackResultCode::NoTrust, + ClawbackResultCode::Underfunded, + ]; + pub const VARIANTS_STR: [&'static str; 5] = [ + "Success", + "Malformed", + "NotClawbackEnabled", + "NoTrust", + "Underfunded", ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Success", "Malformed", "AlreadySponsored", "Recursive"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::AlreadySponsored => "AlreadySponsored", - Self::Recursive => "Recursive", + Self::NotClawbackEnabled => "NotClawbackEnabled", + Self::NoTrust => "NoTrust", + Self::Underfunded => "Underfunded", } } #[must_use] - pub const fn variants() -> [BeginSponsoringFutureReservesResultCode; 4] { + pub const fn variants() -> [ClawbackResultCode; 5] { Self::VARIANTS } } -impl Name for BeginSponsoringFutureReservesResultCode { +impl Name for ClawbackResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for BeginSponsoringFutureReservesResultCode { - fn variants() -> slice::Iter<'static, BeginSponsoringFutureReservesResultCode> { +impl Variants for ClawbackResultCode { + fn variants() -> slice::Iter<'static, ClawbackResultCode> { Self::VARIANTS.iter() } } -impl Enum for BeginSponsoringFutureReservesResultCode {} +impl Enum for ClawbackResultCode {} -impl fmt::Display for BeginSponsoringFutureReservesResultCode { +impl fmt::Display for ClawbackResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for BeginSponsoringFutureReservesResultCode { +impl TryFrom for ClawbackResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => BeginSponsoringFutureReservesResultCode::Success, - -1 => BeginSponsoringFutureReservesResultCode::Malformed, - -2 => BeginSponsoringFutureReservesResultCode::AlreadySponsored, - -3 => BeginSponsoringFutureReservesResultCode::Recursive, + 0 => ClawbackResultCode::Success, + -1 => ClawbackResultCode::Malformed, + -2 => ClawbackResultCode::NotClawbackEnabled, + -3 => ClawbackResultCode::NoTrust, + -4 => ClawbackResultCode::Underfunded, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25698,14 +35422,14 @@ impl TryFrom for BeginSponsoringFutureReservesResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: BeginSponsoringFutureReservesResultCode) -> Self { + fn from(e: ClawbackResultCode) -> Self { e as Self } } -impl ReadXdr for BeginSponsoringFutureReservesResultCode { +impl ReadXdr for ClawbackResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -25716,7 +35440,7 @@ impl ReadXdr for BeginSponsoringFutureReservesResultCode { } } -impl WriteXdr for BeginSponsoringFutureReservesResultCode { +impl WriteXdr for ClawbackResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -25726,20 +35450,20 @@ impl WriteXdr for BeginSponsoringFutureReservesResultCode { } } -// BeginSponsoringFutureReservesResult is an XDR Union defines as: +// ClawbackResult is an XDR Union defines as: // -// union BeginSponsoringFutureReservesResult switch ( -// BeginSponsoringFutureReservesResultCode code) +// union ClawbackResult switch (ClawbackResultCode code) // { -// case BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS: +// case CLAWBACK_SUCCESS: // void; -// case BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED: -// case BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED: -// case BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE: +// case CLAWBACK_MALFORMED: +// case CLAWBACK_NOT_CLAWBACK_ENABLED: +// case CLAWBACK_NO_TRUST: +// case CLAWBACK_UNDERFUNDED: // void; // }; // -// union with discriminant BeginSponsoringFutureReservesResultCode +// union with discriminant ClawbackResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -25748,84 +35472,93 @@ impl WriteXdr for BeginSponsoringFutureReservesResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum BeginSponsoringFutureReservesResult { +pub enum ClawbackResult { Success, Malformed, - AlreadySponsored, - Recursive, + NotClawbackEnabled, + NoTrust, + Underfunded, } -impl BeginSponsoringFutureReservesResult { - pub const VARIANTS: [BeginSponsoringFutureReservesResultCode; 4] = [ - BeginSponsoringFutureReservesResultCode::Success, - BeginSponsoringFutureReservesResultCode::Malformed, - BeginSponsoringFutureReservesResultCode::AlreadySponsored, - BeginSponsoringFutureReservesResultCode::Recursive, +impl ClawbackResult { + pub const VARIANTS: [ClawbackResultCode; 5] = [ + ClawbackResultCode::Success, + ClawbackResultCode::Malformed, + ClawbackResultCode::NotClawbackEnabled, + ClawbackResultCode::NoTrust, + ClawbackResultCode::Underfunded, + ]; + pub const VARIANTS_STR: [&'static str; 5] = [ + "Success", + "Malformed", + "NotClawbackEnabled", + "NoTrust", + "Underfunded", ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Success", "Malformed", "AlreadySponsored", "Recursive"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::AlreadySponsored => "AlreadySponsored", - Self::Recursive => "Recursive", + Self::NotClawbackEnabled => "NotClawbackEnabled", + Self::NoTrust => "NoTrust", + Self::Underfunded => "Underfunded", } } #[must_use] - pub const fn discriminant(&self) -> BeginSponsoringFutureReservesResultCode { + pub const fn discriminant(&self) -> ClawbackResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => BeginSponsoringFutureReservesResultCode::Success, - Self::Malformed => BeginSponsoringFutureReservesResultCode::Malformed, - Self::AlreadySponsored => BeginSponsoringFutureReservesResultCode::AlreadySponsored, - Self::Recursive => BeginSponsoringFutureReservesResultCode::Recursive, + Self::Success => ClawbackResultCode::Success, + Self::Malformed => ClawbackResultCode::Malformed, + Self::NotClawbackEnabled => ClawbackResultCode::NotClawbackEnabled, + Self::NoTrust => ClawbackResultCode::NoTrust, + Self::Underfunded => ClawbackResultCode::Underfunded, } } #[must_use] - pub const fn variants() -> [BeginSponsoringFutureReservesResultCode; 4] { + pub const fn variants() -> [ClawbackResultCode; 5] { Self::VARIANTS } } -impl Name for BeginSponsoringFutureReservesResult { +impl Name for ClawbackResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for BeginSponsoringFutureReservesResult { +impl Discriminant for ClawbackResult { #[must_use] - fn discriminant(&self) -> BeginSponsoringFutureReservesResultCode { + fn discriminant(&self) -> ClawbackResultCode { Self::discriminant(self) } } -impl Variants for BeginSponsoringFutureReservesResult { - fn variants() -> slice::Iter<'static, BeginSponsoringFutureReservesResultCode> { +impl Variants for ClawbackResult { + fn variants() -> slice::Iter<'static, ClawbackResultCode> { Self::VARIANTS.iter() } } -impl Union for BeginSponsoringFutureReservesResult {} +impl Union for ClawbackResult {} -impl ReadXdr for BeginSponsoringFutureReservesResult { +impl ReadXdr for ClawbackResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: BeginSponsoringFutureReservesResultCode = - ::read_xdr(r)?; + let dv: ClawbackResultCode = ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - BeginSponsoringFutureReservesResultCode::Success => Self::Success, - BeginSponsoringFutureReservesResultCode::Malformed => Self::Malformed, - BeginSponsoringFutureReservesResultCode::AlreadySponsored => Self::AlreadySponsored, - BeginSponsoringFutureReservesResultCode::Recursive => Self::Recursive, + ClawbackResultCode::Success => Self::Success, + ClawbackResultCode::Malformed => Self::Malformed, + ClawbackResultCode::NotClawbackEnabled => Self::NotClawbackEnabled, + ClawbackResultCode::NoTrust => Self::NoTrust, + ClawbackResultCode::Underfunded => Self::Underfunded, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25834,7 +35567,7 @@ impl ReadXdr for BeginSponsoringFutureReservesResult { } } -impl WriteXdr for BeginSponsoringFutureReservesResult { +impl WriteXdr for ClawbackResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -25843,23 +35576,26 @@ impl WriteXdr for BeginSponsoringFutureReservesResult { match self { Self::Success => ().write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::AlreadySponsored => ().write_xdr(w)?, - Self::Recursive => ().write_xdr(w)?, + Self::NotClawbackEnabled => ().write_xdr(w)?, + Self::NoTrust => ().write_xdr(w)?, + Self::Underfunded => ().write_xdr(w)?, }; Ok(()) }) } } -// EndSponsoringFutureReservesResultCode is an XDR Enum defines as: +// ClawbackClaimableBalanceResultCode is an XDR Enum defines as: // -// enum EndSponsoringFutureReservesResultCode +// enum ClawbackClaimableBalanceResultCode // { // // codes considered as "success" for the operation -// END_SPONSORING_FUTURE_RESERVES_SUCCESS = 0, +// CLAWBACK_CLAIMABLE_BALANCE_SUCCESS = 0, // // // codes considered as "failure" for the operation -// END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED = -1 +// CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST = -1, +// CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER = -2, +// CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED = -3 // }; // // enum @@ -25871,60 +35607,69 @@ impl WriteXdr for BeginSponsoringFutureReservesResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum EndSponsoringFutureReservesResultCode { +pub enum ClawbackClaimableBalanceResultCode { Success = 0, - NotSponsored = -1, + DoesNotExist = -1, + NotIssuer = -2, + NotClawbackEnabled = -3, } -impl EndSponsoringFutureReservesResultCode { - pub const VARIANTS: [EndSponsoringFutureReservesResultCode; 2] = [ - EndSponsoringFutureReservesResultCode::Success, - EndSponsoringFutureReservesResultCode::NotSponsored, +impl ClawbackClaimableBalanceResultCode { + pub const VARIANTS: [ClawbackClaimableBalanceResultCode; 4] = [ + ClawbackClaimableBalanceResultCode::Success, + ClawbackClaimableBalanceResultCode::DoesNotExist, + ClawbackClaimableBalanceResultCode::NotIssuer, + ClawbackClaimableBalanceResultCode::NotClawbackEnabled, ]; - pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotSponsored"]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Success", "DoesNotExist", "NotIssuer", "NotClawbackEnabled"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::NotSponsored => "NotSponsored", + Self::DoesNotExist => "DoesNotExist", + Self::NotIssuer => "NotIssuer", + Self::NotClawbackEnabled => "NotClawbackEnabled", } } #[must_use] - pub const fn variants() -> [EndSponsoringFutureReservesResultCode; 2] { + pub const fn variants() -> [ClawbackClaimableBalanceResultCode; 4] { Self::VARIANTS } } -impl Name for EndSponsoringFutureReservesResultCode { +impl Name for ClawbackClaimableBalanceResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for EndSponsoringFutureReservesResultCode { - fn variants() -> slice::Iter<'static, EndSponsoringFutureReservesResultCode> { +impl Variants for ClawbackClaimableBalanceResultCode { + fn variants() -> slice::Iter<'static, ClawbackClaimableBalanceResultCode> { Self::VARIANTS.iter() } } -impl Enum for EndSponsoringFutureReservesResultCode {} +impl Enum for ClawbackClaimableBalanceResultCode {} -impl fmt::Display for EndSponsoringFutureReservesResultCode { +impl fmt::Display for ClawbackClaimableBalanceResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for EndSponsoringFutureReservesResultCode { +impl TryFrom for ClawbackClaimableBalanceResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => EndSponsoringFutureReservesResultCode::Success, - -1 => EndSponsoringFutureReservesResultCode::NotSponsored, + 0 => ClawbackClaimableBalanceResultCode::Success, + -1 => ClawbackClaimableBalanceResultCode::DoesNotExist, + -2 => ClawbackClaimableBalanceResultCode::NotIssuer, + -3 => ClawbackClaimableBalanceResultCode::NotClawbackEnabled, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -25932,14 +35677,14 @@ impl TryFrom for EndSponsoringFutureReservesResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: EndSponsoringFutureReservesResultCode) -> Self { + fn from(e: ClawbackClaimableBalanceResultCode) -> Self { e as Self } } -impl ReadXdr for EndSponsoringFutureReservesResultCode { +impl ReadXdr for ClawbackClaimableBalanceResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -25950,7 +35695,7 @@ impl ReadXdr for EndSponsoringFutureReservesResultCode { } } -impl WriteXdr for EndSponsoringFutureReservesResultCode { +impl WriteXdr for ClawbackClaimableBalanceResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -25960,18 +35705,20 @@ impl WriteXdr for EndSponsoringFutureReservesResultCode { } } -// EndSponsoringFutureReservesResult is an XDR Union defines as: +// ClawbackClaimableBalanceResult is an XDR Union defines as: // -// union EndSponsoringFutureReservesResult switch ( -// EndSponsoringFutureReservesResultCode code) +// union ClawbackClaimableBalanceResult switch ( +// ClawbackClaimableBalanceResultCode code) // { -// case END_SPONSORING_FUTURE_RESERVES_SUCCESS: +// case CLAWBACK_CLAIMABLE_BALANCE_SUCCESS: // void; -// case END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED: +// case CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST: +// case CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER: +// case CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED: // void; // }; // -// union with discriminant EndSponsoringFutureReservesResultCode +// union with discriminant ClawbackClaimableBalanceResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -25980,73 +35727,84 @@ impl WriteXdr for EndSponsoringFutureReservesResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum EndSponsoringFutureReservesResult { +pub enum ClawbackClaimableBalanceResult { Success, - NotSponsored, + DoesNotExist, + NotIssuer, + NotClawbackEnabled, } -impl EndSponsoringFutureReservesResult { - pub const VARIANTS: [EndSponsoringFutureReservesResultCode; 2] = [ - EndSponsoringFutureReservesResultCode::Success, - EndSponsoringFutureReservesResultCode::NotSponsored, +impl ClawbackClaimableBalanceResult { + pub const VARIANTS: [ClawbackClaimableBalanceResultCode; 4] = [ + ClawbackClaimableBalanceResultCode::Success, + ClawbackClaimableBalanceResultCode::DoesNotExist, + ClawbackClaimableBalanceResultCode::NotIssuer, + ClawbackClaimableBalanceResultCode::NotClawbackEnabled, ]; - pub const VARIANTS_STR: [&'static str; 2] = ["Success", "NotSponsored"]; + pub const VARIANTS_STR: [&'static str; 4] = + ["Success", "DoesNotExist", "NotIssuer", "NotClawbackEnabled"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::NotSponsored => "NotSponsored", + Self::DoesNotExist => "DoesNotExist", + Self::NotIssuer => "NotIssuer", + Self::NotClawbackEnabled => "NotClawbackEnabled", } } #[must_use] - pub const fn discriminant(&self) -> EndSponsoringFutureReservesResultCode { + pub const fn discriminant(&self) -> ClawbackClaimableBalanceResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => EndSponsoringFutureReservesResultCode::Success, - Self::NotSponsored => EndSponsoringFutureReservesResultCode::NotSponsored, + Self::Success => ClawbackClaimableBalanceResultCode::Success, + Self::DoesNotExist => ClawbackClaimableBalanceResultCode::DoesNotExist, + Self::NotIssuer => ClawbackClaimableBalanceResultCode::NotIssuer, + Self::NotClawbackEnabled => ClawbackClaimableBalanceResultCode::NotClawbackEnabled, } } #[must_use] - pub const fn variants() -> [EndSponsoringFutureReservesResultCode; 2] { + pub const fn variants() -> [ClawbackClaimableBalanceResultCode; 4] { Self::VARIANTS } } -impl Name for EndSponsoringFutureReservesResult { +impl Name for ClawbackClaimableBalanceResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for EndSponsoringFutureReservesResult { +impl Discriminant for ClawbackClaimableBalanceResult { #[must_use] - fn discriminant(&self) -> EndSponsoringFutureReservesResultCode { + fn discriminant(&self) -> ClawbackClaimableBalanceResultCode { Self::discriminant(self) } } -impl Variants for EndSponsoringFutureReservesResult { - fn variants() -> slice::Iter<'static, EndSponsoringFutureReservesResultCode> { +impl Variants for ClawbackClaimableBalanceResult { + fn variants() -> slice::Iter<'static, ClawbackClaimableBalanceResultCode> { Self::VARIANTS.iter() } } -impl Union for EndSponsoringFutureReservesResult {} +impl Union for ClawbackClaimableBalanceResult {} -impl ReadXdr for EndSponsoringFutureReservesResult { +impl ReadXdr for ClawbackClaimableBalanceResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: EndSponsoringFutureReservesResultCode = - ::read_xdr(r)?; + let dv: ClawbackClaimableBalanceResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - EndSponsoringFutureReservesResultCode::Success => Self::Success, - EndSponsoringFutureReservesResultCode::NotSponsored => Self::NotSponsored, + ClawbackClaimableBalanceResultCode::Success => Self::Success, + ClawbackClaimableBalanceResultCode::DoesNotExist => Self::DoesNotExist, + ClawbackClaimableBalanceResultCode::NotIssuer => Self::NotIssuer, + ClawbackClaimableBalanceResultCode::NotClawbackEnabled => Self::NotClawbackEnabled, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26055,7 +35813,7 @@ impl ReadXdr for EndSponsoringFutureReservesResult { } } -impl WriteXdr for EndSponsoringFutureReservesResult { +impl WriteXdr for ClawbackClaimableBalanceResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26063,26 +35821,29 @@ impl WriteXdr for EndSponsoringFutureReservesResult { #[allow(clippy::match_same_arms)] match self { Self::Success => ().write_xdr(w)?, - Self::NotSponsored => ().write_xdr(w)?, + Self::DoesNotExist => ().write_xdr(w)?, + Self::NotIssuer => ().write_xdr(w)?, + Self::NotClawbackEnabled => ().write_xdr(w)?, }; Ok(()) }) } } -// RevokeSponsorshipResultCode is an XDR Enum defines as: +// SetTrustLineFlagsResultCode is an XDR Enum defines as: // -// enum RevokeSponsorshipResultCode +// enum SetTrustLineFlagsResultCode // { // // codes considered as "success" for the operation -// REVOKE_SPONSORSHIP_SUCCESS = 0, +// SET_TRUST_LINE_FLAGS_SUCCESS = 0, // // // codes considered as "failure" for the operation -// REVOKE_SPONSORSHIP_DOES_NOT_EXIST = -1, -// REVOKE_SPONSORSHIP_NOT_SPONSOR = -2, -// REVOKE_SPONSORSHIP_LOW_RESERVE = -3, -// REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE = -4, -// REVOKE_SPONSORSHIP_MALFORMED = -5 +// SET_TRUST_LINE_FLAGS_MALFORMED = -1, +// SET_TRUST_LINE_FLAGS_NO_TRUST_LINE = -2, +// SET_TRUST_LINE_FLAGS_CANT_REVOKE = -3, +// SET_TRUST_LINE_FLAGS_INVALID_STATE = -4, +// SET_TRUST_LINE_FLAGS_LOW_RESERVE = -5 // claimable balances can't be created +// // on revoke due to low reserves // }; // // enum @@ -26094,83 +35855,83 @@ impl WriteXdr for EndSponsoringFutureReservesResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum RevokeSponsorshipResultCode { +pub enum SetTrustLineFlagsResultCode { Success = 0, - DoesNotExist = -1, - NotSponsor = -2, - LowReserve = -3, - OnlyTransferable = -4, - Malformed = -5, + Malformed = -1, + NoTrustLine = -2, + CantRevoke = -3, + InvalidState = -4, + LowReserve = -5, } -impl RevokeSponsorshipResultCode { - pub const VARIANTS: [RevokeSponsorshipResultCode; 6] = [ - RevokeSponsorshipResultCode::Success, - RevokeSponsorshipResultCode::DoesNotExist, - RevokeSponsorshipResultCode::NotSponsor, - RevokeSponsorshipResultCode::LowReserve, - RevokeSponsorshipResultCode::OnlyTransferable, - RevokeSponsorshipResultCode::Malformed, +impl SetTrustLineFlagsResultCode { + pub const VARIANTS: [SetTrustLineFlagsResultCode; 6] = [ + SetTrustLineFlagsResultCode::Success, + SetTrustLineFlagsResultCode::Malformed, + SetTrustLineFlagsResultCode::NoTrustLine, + SetTrustLineFlagsResultCode::CantRevoke, + SetTrustLineFlagsResultCode::InvalidState, + SetTrustLineFlagsResultCode::LowReserve, ]; pub const VARIANTS_STR: [&'static str; 6] = [ "Success", - "DoesNotExist", - "NotSponsor", - "LowReserve", - "OnlyTransferable", "Malformed", + "NoTrustLine", + "CantRevoke", + "InvalidState", + "LowReserve", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::DoesNotExist => "DoesNotExist", - Self::NotSponsor => "NotSponsor", - Self::LowReserve => "LowReserve", - Self::OnlyTransferable => "OnlyTransferable", Self::Malformed => "Malformed", + Self::NoTrustLine => "NoTrustLine", + Self::CantRevoke => "CantRevoke", + Self::InvalidState => "InvalidState", + Self::LowReserve => "LowReserve", } } #[must_use] - pub const fn variants() -> [RevokeSponsorshipResultCode; 6] { + pub const fn variants() -> [SetTrustLineFlagsResultCode; 6] { Self::VARIANTS } } -impl Name for RevokeSponsorshipResultCode { +impl Name for SetTrustLineFlagsResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for RevokeSponsorshipResultCode { - fn variants() -> slice::Iter<'static, RevokeSponsorshipResultCode> { +impl Variants for SetTrustLineFlagsResultCode { + fn variants() -> slice::Iter<'static, SetTrustLineFlagsResultCode> { Self::VARIANTS.iter() } } -impl Enum for RevokeSponsorshipResultCode {} +impl Enum for SetTrustLineFlagsResultCode {} -impl fmt::Display for RevokeSponsorshipResultCode { +impl fmt::Display for SetTrustLineFlagsResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for RevokeSponsorshipResultCode { +impl TryFrom for SetTrustLineFlagsResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => RevokeSponsorshipResultCode::Success, - -1 => RevokeSponsorshipResultCode::DoesNotExist, - -2 => RevokeSponsorshipResultCode::NotSponsor, - -3 => RevokeSponsorshipResultCode::LowReserve, - -4 => RevokeSponsorshipResultCode::OnlyTransferable, - -5 => RevokeSponsorshipResultCode::Malformed, + 0 => SetTrustLineFlagsResultCode::Success, + -1 => SetTrustLineFlagsResultCode::Malformed, + -2 => SetTrustLineFlagsResultCode::NoTrustLine, + -3 => SetTrustLineFlagsResultCode::CantRevoke, + -4 => SetTrustLineFlagsResultCode::InvalidState, + -5 => SetTrustLineFlagsResultCode::LowReserve, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26178,14 +35939,14 @@ impl TryFrom for RevokeSponsorshipResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: RevokeSponsorshipResultCode) -> Self { + fn from(e: SetTrustLineFlagsResultCode) -> Self { e as Self } } -impl ReadXdr for RevokeSponsorshipResultCode { +impl ReadXdr for SetTrustLineFlagsResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -26196,7 +35957,7 @@ impl ReadXdr for RevokeSponsorshipResultCode { } } -impl WriteXdr for RevokeSponsorshipResultCode { +impl WriteXdr for SetTrustLineFlagsResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26206,21 +35967,21 @@ impl WriteXdr for RevokeSponsorshipResultCode { } } -// RevokeSponsorshipResult is an XDR Union defines as: +// SetTrustLineFlagsResult is an XDR Union defines as: // -// union RevokeSponsorshipResult switch (RevokeSponsorshipResultCode code) +// union SetTrustLineFlagsResult switch (SetTrustLineFlagsResultCode code) // { -// case REVOKE_SPONSORSHIP_SUCCESS: +// case SET_TRUST_LINE_FLAGS_SUCCESS: // void; -// case REVOKE_SPONSORSHIP_DOES_NOT_EXIST: -// case REVOKE_SPONSORSHIP_NOT_SPONSOR: -// case REVOKE_SPONSORSHIP_LOW_RESERVE: -// case REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE: -// case REVOKE_SPONSORSHIP_MALFORMED: +// case SET_TRUST_LINE_FLAGS_MALFORMED: +// case SET_TRUST_LINE_FLAGS_NO_TRUST_LINE: +// case SET_TRUST_LINE_FLAGS_CANT_REVOKE: +// case SET_TRUST_LINE_FLAGS_INVALID_STATE: +// case SET_TRUST_LINE_FLAGS_LOW_RESERVE: // void; // }; // -// union with discriminant RevokeSponsorshipResultCode +// union with discriminant SetTrustLineFlagsResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -26229,100 +35990,100 @@ impl WriteXdr for RevokeSponsorshipResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum RevokeSponsorshipResult { +pub enum SetTrustLineFlagsResult { Success, - DoesNotExist, - NotSponsor, - LowReserve, - OnlyTransferable, Malformed, + NoTrustLine, + CantRevoke, + InvalidState, + LowReserve, } -impl RevokeSponsorshipResult { - pub const VARIANTS: [RevokeSponsorshipResultCode; 6] = [ - RevokeSponsorshipResultCode::Success, - RevokeSponsorshipResultCode::DoesNotExist, - RevokeSponsorshipResultCode::NotSponsor, - RevokeSponsorshipResultCode::LowReserve, - RevokeSponsorshipResultCode::OnlyTransferable, - RevokeSponsorshipResultCode::Malformed, +impl SetTrustLineFlagsResult { + pub const VARIANTS: [SetTrustLineFlagsResultCode; 6] = [ + SetTrustLineFlagsResultCode::Success, + SetTrustLineFlagsResultCode::Malformed, + SetTrustLineFlagsResultCode::NoTrustLine, + SetTrustLineFlagsResultCode::CantRevoke, + SetTrustLineFlagsResultCode::InvalidState, + SetTrustLineFlagsResultCode::LowReserve, ]; pub const VARIANTS_STR: [&'static str; 6] = [ "Success", - "DoesNotExist", - "NotSponsor", - "LowReserve", - "OnlyTransferable", "Malformed", + "NoTrustLine", + "CantRevoke", + "InvalidState", + "LowReserve", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::DoesNotExist => "DoesNotExist", - Self::NotSponsor => "NotSponsor", - Self::LowReserve => "LowReserve", - Self::OnlyTransferable => "OnlyTransferable", Self::Malformed => "Malformed", + Self::NoTrustLine => "NoTrustLine", + Self::CantRevoke => "CantRevoke", + Self::InvalidState => "InvalidState", + Self::LowReserve => "LowReserve", } } #[must_use] - pub const fn discriminant(&self) -> RevokeSponsorshipResultCode { + pub const fn discriminant(&self) -> SetTrustLineFlagsResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => RevokeSponsorshipResultCode::Success, - Self::DoesNotExist => RevokeSponsorshipResultCode::DoesNotExist, - Self::NotSponsor => RevokeSponsorshipResultCode::NotSponsor, - Self::LowReserve => RevokeSponsorshipResultCode::LowReserve, - Self::OnlyTransferable => RevokeSponsorshipResultCode::OnlyTransferable, - Self::Malformed => RevokeSponsorshipResultCode::Malformed, + Self::Success => SetTrustLineFlagsResultCode::Success, + Self::Malformed => SetTrustLineFlagsResultCode::Malformed, + Self::NoTrustLine => SetTrustLineFlagsResultCode::NoTrustLine, + Self::CantRevoke => SetTrustLineFlagsResultCode::CantRevoke, + Self::InvalidState => SetTrustLineFlagsResultCode::InvalidState, + Self::LowReserve => SetTrustLineFlagsResultCode::LowReserve, } } #[must_use] - pub const fn variants() -> [RevokeSponsorshipResultCode; 6] { + pub const fn variants() -> [SetTrustLineFlagsResultCode; 6] { Self::VARIANTS } } -impl Name for RevokeSponsorshipResult { +impl Name for SetTrustLineFlagsResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for RevokeSponsorshipResult { +impl Discriminant for SetTrustLineFlagsResult { #[must_use] - fn discriminant(&self) -> RevokeSponsorshipResultCode { + fn discriminant(&self) -> SetTrustLineFlagsResultCode { Self::discriminant(self) } } -impl Variants for RevokeSponsorshipResult { - fn variants() -> slice::Iter<'static, RevokeSponsorshipResultCode> { +impl Variants for SetTrustLineFlagsResult { + fn variants() -> slice::Iter<'static, SetTrustLineFlagsResultCode> { Self::VARIANTS.iter() } } -impl Union for RevokeSponsorshipResult {} +impl Union for SetTrustLineFlagsResult {} -impl ReadXdr for RevokeSponsorshipResult { +impl ReadXdr for SetTrustLineFlagsResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: RevokeSponsorshipResultCode = - ::read_xdr(r)?; + let dv: SetTrustLineFlagsResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - RevokeSponsorshipResultCode::Success => Self::Success, - RevokeSponsorshipResultCode::DoesNotExist => Self::DoesNotExist, - RevokeSponsorshipResultCode::NotSponsor => Self::NotSponsor, - RevokeSponsorshipResultCode::LowReserve => Self::LowReserve, - RevokeSponsorshipResultCode::OnlyTransferable => Self::OnlyTransferable, - RevokeSponsorshipResultCode::Malformed => Self::Malformed, + SetTrustLineFlagsResultCode::Success => Self::Success, + SetTrustLineFlagsResultCode::Malformed => Self::Malformed, + SetTrustLineFlagsResultCode::NoTrustLine => Self::NoTrustLine, + SetTrustLineFlagsResultCode::CantRevoke => Self::CantRevoke, + SetTrustLineFlagsResultCode::InvalidState => Self::InvalidState, + SetTrustLineFlagsResultCode::LowReserve => Self::LowReserve, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26331,7 +36092,7 @@ impl ReadXdr for RevokeSponsorshipResult { } } -impl WriteXdr for RevokeSponsorshipResult { +impl WriteXdr for SetTrustLineFlagsResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26339,29 +36100,36 @@ impl WriteXdr for RevokeSponsorshipResult { #[allow(clippy::match_same_arms)] match self { Self::Success => ().write_xdr(w)?, - Self::DoesNotExist => ().write_xdr(w)?, - Self::NotSponsor => ().write_xdr(w)?, - Self::LowReserve => ().write_xdr(w)?, - Self::OnlyTransferable => ().write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, + Self::NoTrustLine => ().write_xdr(w)?, + Self::CantRevoke => ().write_xdr(w)?, + Self::InvalidState => ().write_xdr(w)?, + Self::LowReserve => ().write_xdr(w)?, }; Ok(()) }) } } -// ClawbackResultCode is an XDR Enum defines as: +// LiquidityPoolDepositResultCode is an XDR Enum defines as: // -// enum ClawbackResultCode +// enum LiquidityPoolDepositResultCode // { // // codes considered as "success" for the operation -// CLAWBACK_SUCCESS = 0, +// LIQUIDITY_POOL_DEPOSIT_SUCCESS = 0, // // // codes considered as "failure" for the operation -// CLAWBACK_MALFORMED = -1, -// CLAWBACK_NOT_CLAWBACK_ENABLED = -2, -// CLAWBACK_NO_TRUST = -3, -// CLAWBACK_UNDERFUNDED = -4 +// LIQUIDITY_POOL_DEPOSIT_MALFORMED = -1, // bad input +// LIQUIDITY_POOL_DEPOSIT_NO_TRUST = -2, // no trust line for one of the +// // assets +// LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED = -3, // not authorized for one of the +// // assets +// LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED = -4, // not enough balance for one of +// // the assets +// LIQUIDITY_POOL_DEPOSIT_LINE_FULL = -5, // pool share trust line doesn't +// // have sufficient limit +// LIQUIDITY_POOL_DEPOSIT_BAD_PRICE = -6, // deposit price outside bounds +// LIQUIDITY_POOL_DEPOSIT_POOL_FULL = -7 // pool reserves are full // }; // // enum @@ -26373,28 +36141,37 @@ impl WriteXdr for RevokeSponsorshipResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ClawbackResultCode { +pub enum LiquidityPoolDepositResultCode { Success = 0, Malformed = -1, - NotClawbackEnabled = -2, - NoTrust = -3, + NoTrust = -2, + NotAuthorized = -3, Underfunded = -4, + LineFull = -5, + BadPrice = -6, + PoolFull = -7, } -impl ClawbackResultCode { - pub const VARIANTS: [ClawbackResultCode; 5] = [ - ClawbackResultCode::Success, - ClawbackResultCode::Malformed, - ClawbackResultCode::NotClawbackEnabled, - ClawbackResultCode::NoTrust, - ClawbackResultCode::Underfunded, +impl LiquidityPoolDepositResultCode { + pub const VARIANTS: [LiquidityPoolDepositResultCode; 8] = [ + LiquidityPoolDepositResultCode::Success, + LiquidityPoolDepositResultCode::Malformed, + LiquidityPoolDepositResultCode::NoTrust, + LiquidityPoolDepositResultCode::NotAuthorized, + LiquidityPoolDepositResultCode::Underfunded, + LiquidityPoolDepositResultCode::LineFull, + LiquidityPoolDepositResultCode::BadPrice, + LiquidityPoolDepositResultCode::PoolFull, ]; - pub const VARIANTS_STR: [&'static str; 5] = [ + pub const VARIANTS_STR: [&'static str; 8] = [ "Success", "Malformed", - "NotClawbackEnabled", "NoTrust", + "NotAuthorized", "Underfunded", + "LineFull", + "BadPrice", + "PoolFull", ]; #[must_use] @@ -26402,49 +36179,55 @@ impl ClawbackResultCode { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::NotClawbackEnabled => "NotClawbackEnabled", Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", Self::Underfunded => "Underfunded", + Self::LineFull => "LineFull", + Self::BadPrice => "BadPrice", + Self::PoolFull => "PoolFull", } } #[must_use] - pub const fn variants() -> [ClawbackResultCode; 5] { + pub const fn variants() -> [LiquidityPoolDepositResultCode; 8] { Self::VARIANTS } } -impl Name for ClawbackResultCode { +impl Name for LiquidityPoolDepositResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ClawbackResultCode { - fn variants() -> slice::Iter<'static, ClawbackResultCode> { +impl Variants for LiquidityPoolDepositResultCode { + fn variants() -> slice::Iter<'static, LiquidityPoolDepositResultCode> { Self::VARIANTS.iter() } } -impl Enum for ClawbackResultCode {} +impl Enum for LiquidityPoolDepositResultCode {} -impl fmt::Display for ClawbackResultCode { +impl fmt::Display for LiquidityPoolDepositResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for ClawbackResultCode { +impl TryFrom for LiquidityPoolDepositResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => ClawbackResultCode::Success, - -1 => ClawbackResultCode::Malformed, - -2 => ClawbackResultCode::NotClawbackEnabled, - -3 => ClawbackResultCode::NoTrust, - -4 => ClawbackResultCode::Underfunded, + 0 => LiquidityPoolDepositResultCode::Success, + -1 => LiquidityPoolDepositResultCode::Malformed, + -2 => LiquidityPoolDepositResultCode::NoTrust, + -3 => LiquidityPoolDepositResultCode::NotAuthorized, + -4 => LiquidityPoolDepositResultCode::Underfunded, + -5 => LiquidityPoolDepositResultCode::LineFull, + -6 => LiquidityPoolDepositResultCode::BadPrice, + -7 => LiquidityPoolDepositResultCode::PoolFull, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26452,14 +36235,14 @@ impl TryFrom for ClawbackResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: ClawbackResultCode) -> Self { + fn from(e: LiquidityPoolDepositResultCode) -> Self { e as Self } } -impl ReadXdr for ClawbackResultCode { +impl ReadXdr for LiquidityPoolDepositResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -26470,7 +36253,7 @@ impl ReadXdr for ClawbackResultCode { } } -impl WriteXdr for ClawbackResultCode { +impl WriteXdr for LiquidityPoolDepositResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26480,20 +36263,23 @@ impl WriteXdr for ClawbackResultCode { } } -// ClawbackResult is an XDR Union defines as: +// LiquidityPoolDepositResult is an XDR Union defines as: // -// union ClawbackResult switch (ClawbackResultCode code) +// union LiquidityPoolDepositResult switch (LiquidityPoolDepositResultCode code) // { -// case CLAWBACK_SUCCESS: +// case LIQUIDITY_POOL_DEPOSIT_SUCCESS: // void; -// case CLAWBACK_MALFORMED: -// case CLAWBACK_NOT_CLAWBACK_ENABLED: -// case CLAWBACK_NO_TRUST: -// case CLAWBACK_UNDERFUNDED: +// case LIQUIDITY_POOL_DEPOSIT_MALFORMED: +// case LIQUIDITY_POOL_DEPOSIT_NO_TRUST: +// case LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED: +// case LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED: +// case LIQUIDITY_POOL_DEPOSIT_LINE_FULL: +// case LIQUIDITY_POOL_DEPOSIT_BAD_PRICE: +// case LIQUIDITY_POOL_DEPOSIT_POOL_FULL: // void; // }; // -// union with discriminant ClawbackResultCode +// union with discriminant LiquidityPoolDepositResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -26502,28 +36288,37 @@ impl WriteXdr for ClawbackResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ClawbackResult { +pub enum LiquidityPoolDepositResult { Success, Malformed, - NotClawbackEnabled, NoTrust, + NotAuthorized, Underfunded, + LineFull, + BadPrice, + PoolFull, } -impl ClawbackResult { - pub const VARIANTS: [ClawbackResultCode; 5] = [ - ClawbackResultCode::Success, - ClawbackResultCode::Malformed, - ClawbackResultCode::NotClawbackEnabled, - ClawbackResultCode::NoTrust, - ClawbackResultCode::Underfunded, +impl LiquidityPoolDepositResult { + pub const VARIANTS: [LiquidityPoolDepositResultCode; 8] = [ + LiquidityPoolDepositResultCode::Success, + LiquidityPoolDepositResultCode::Malformed, + LiquidityPoolDepositResultCode::NoTrust, + LiquidityPoolDepositResultCode::NotAuthorized, + LiquidityPoolDepositResultCode::Underfunded, + LiquidityPoolDepositResultCode::LineFull, + LiquidityPoolDepositResultCode::BadPrice, + LiquidityPoolDepositResultCode::PoolFull, ]; - pub const VARIANTS_STR: [&'static str; 5] = [ + pub const VARIANTS_STR: [&'static str; 8] = [ "Success", "Malformed", - "NotClawbackEnabled", "NoTrust", + "NotAuthorized", "Underfunded", + "LineFull", + "BadPrice", + "PoolFull", ]; #[must_use] @@ -26531,64 +36326,74 @@ impl ClawbackResult { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::NotClawbackEnabled => "NotClawbackEnabled", Self::NoTrust => "NoTrust", + Self::NotAuthorized => "NotAuthorized", Self::Underfunded => "Underfunded", + Self::LineFull => "LineFull", + Self::BadPrice => "BadPrice", + Self::PoolFull => "PoolFull", } } #[must_use] - pub const fn discriminant(&self) -> ClawbackResultCode { + pub const fn discriminant(&self) -> LiquidityPoolDepositResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => ClawbackResultCode::Success, - Self::Malformed => ClawbackResultCode::Malformed, - Self::NotClawbackEnabled => ClawbackResultCode::NotClawbackEnabled, - Self::NoTrust => ClawbackResultCode::NoTrust, - Self::Underfunded => ClawbackResultCode::Underfunded, + Self::Success => LiquidityPoolDepositResultCode::Success, + Self::Malformed => LiquidityPoolDepositResultCode::Malformed, + Self::NoTrust => LiquidityPoolDepositResultCode::NoTrust, + Self::NotAuthorized => LiquidityPoolDepositResultCode::NotAuthorized, + Self::Underfunded => LiquidityPoolDepositResultCode::Underfunded, + Self::LineFull => LiquidityPoolDepositResultCode::LineFull, + Self::BadPrice => LiquidityPoolDepositResultCode::BadPrice, + Self::PoolFull => LiquidityPoolDepositResultCode::PoolFull, } } #[must_use] - pub const fn variants() -> [ClawbackResultCode; 5] { + pub const fn variants() -> [LiquidityPoolDepositResultCode; 8] { Self::VARIANTS } } -impl Name for ClawbackResult { +impl Name for LiquidityPoolDepositResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ClawbackResult { +impl Discriminant for LiquidityPoolDepositResult { #[must_use] - fn discriminant(&self) -> ClawbackResultCode { + fn discriminant(&self) -> LiquidityPoolDepositResultCode { Self::discriminant(self) } } -impl Variants for ClawbackResult { - fn variants() -> slice::Iter<'static, ClawbackResultCode> { +impl Variants for LiquidityPoolDepositResult { + fn variants() -> slice::Iter<'static, LiquidityPoolDepositResultCode> { Self::VARIANTS.iter() } } -impl Union for ClawbackResult {} +impl Union for LiquidityPoolDepositResult {} -impl ReadXdr for ClawbackResult { +impl ReadXdr for LiquidityPoolDepositResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ClawbackResultCode = ::read_xdr(r)?; + let dv: LiquidityPoolDepositResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ClawbackResultCode::Success => Self::Success, - ClawbackResultCode::Malformed => Self::Malformed, - ClawbackResultCode::NotClawbackEnabled => Self::NotClawbackEnabled, - ClawbackResultCode::NoTrust => Self::NoTrust, - ClawbackResultCode::Underfunded => Self::Underfunded, + LiquidityPoolDepositResultCode::Success => Self::Success, + LiquidityPoolDepositResultCode::Malformed => Self::Malformed, + LiquidityPoolDepositResultCode::NoTrust => Self::NoTrust, + LiquidityPoolDepositResultCode::NotAuthorized => Self::NotAuthorized, + LiquidityPoolDepositResultCode::Underfunded => Self::Underfunded, + LiquidityPoolDepositResultCode::LineFull => Self::LineFull, + LiquidityPoolDepositResultCode::BadPrice => Self::BadPrice, + LiquidityPoolDepositResultCode::PoolFull => Self::PoolFull, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26597,7 +36402,7 @@ impl ReadXdr for ClawbackResult { } } -impl WriteXdr for ClawbackResult { +impl WriteXdr for LiquidityPoolDepositResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26606,26 +36411,34 @@ impl WriteXdr for ClawbackResult { match self { Self::Success => ().write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::NotClawbackEnabled => ().write_xdr(w)?, Self::NoTrust => ().write_xdr(w)?, + Self::NotAuthorized => ().write_xdr(w)?, Self::Underfunded => ().write_xdr(w)?, + Self::LineFull => ().write_xdr(w)?, + Self::BadPrice => ().write_xdr(w)?, + Self::PoolFull => ().write_xdr(w)?, }; Ok(()) }) } } -// ClawbackClaimableBalanceResultCode is an XDR Enum defines as: +// LiquidityPoolWithdrawResultCode is an XDR Enum defines as: // -// enum ClawbackClaimableBalanceResultCode +// enum LiquidityPoolWithdrawResultCode // { // // codes considered as "success" for the operation -// CLAWBACK_CLAIMABLE_BALANCE_SUCCESS = 0, +// LIQUIDITY_POOL_WITHDRAW_SUCCESS = 0, // // // codes considered as "failure" for the operation -// CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST = -1, -// CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER = -2, -// CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED = -3 +// LIQUIDITY_POOL_WITHDRAW_MALFORMED = -1, // bad input +// LIQUIDITY_POOL_WITHDRAW_NO_TRUST = -2, // no trust line for one of the +// // assets +// LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED = -3, // not enough balance of the +// // pool share +// LIQUIDITY_POOL_WITHDRAW_LINE_FULL = -4, // would go above limit for one +// // of the assets +// LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM = -5 // didn't withdraw enough // }; // // enum @@ -26637,69 +36450,83 @@ impl WriteXdr for ClawbackResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum ClawbackClaimableBalanceResultCode { +pub enum LiquidityPoolWithdrawResultCode { Success = 0, - DoesNotExist = -1, - NotIssuer = -2, - NotClawbackEnabled = -3, + Malformed = -1, + NoTrust = -2, + Underfunded = -3, + LineFull = -4, + UnderMinimum = -5, } -impl ClawbackClaimableBalanceResultCode { - pub const VARIANTS: [ClawbackClaimableBalanceResultCode; 4] = [ - ClawbackClaimableBalanceResultCode::Success, - ClawbackClaimableBalanceResultCode::DoesNotExist, - ClawbackClaimableBalanceResultCode::NotIssuer, - ClawbackClaimableBalanceResultCode::NotClawbackEnabled, +impl LiquidityPoolWithdrawResultCode { + pub const VARIANTS: [LiquidityPoolWithdrawResultCode; 6] = [ + LiquidityPoolWithdrawResultCode::Success, + LiquidityPoolWithdrawResultCode::Malformed, + LiquidityPoolWithdrawResultCode::NoTrust, + LiquidityPoolWithdrawResultCode::Underfunded, + LiquidityPoolWithdrawResultCode::LineFull, + LiquidityPoolWithdrawResultCode::UnderMinimum, + ]; + pub const VARIANTS_STR: [&'static str; 6] = [ + "Success", + "Malformed", + "NoTrust", + "Underfunded", + "LineFull", + "UnderMinimum", ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Success", "DoesNotExist", "NotIssuer", "NotClawbackEnabled"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::DoesNotExist => "DoesNotExist", - Self::NotIssuer => "NotIssuer", - Self::NotClawbackEnabled => "NotClawbackEnabled", + Self::Malformed => "Malformed", + Self::NoTrust => "NoTrust", + Self::Underfunded => "Underfunded", + Self::LineFull => "LineFull", + Self::UnderMinimum => "UnderMinimum", } } #[must_use] - pub const fn variants() -> [ClawbackClaimableBalanceResultCode; 4] { + pub const fn variants() -> [LiquidityPoolWithdrawResultCode; 6] { Self::VARIANTS } } -impl Name for ClawbackClaimableBalanceResultCode { +impl Name for LiquidityPoolWithdrawResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for ClawbackClaimableBalanceResultCode { - fn variants() -> slice::Iter<'static, ClawbackClaimableBalanceResultCode> { +impl Variants for LiquidityPoolWithdrawResultCode { + fn variants() -> slice::Iter<'static, LiquidityPoolWithdrawResultCode> { Self::VARIANTS.iter() } } -impl Enum for ClawbackClaimableBalanceResultCode {} +impl Enum for LiquidityPoolWithdrawResultCode {} -impl fmt::Display for ClawbackClaimableBalanceResultCode { +impl fmt::Display for LiquidityPoolWithdrawResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for ClawbackClaimableBalanceResultCode { +impl TryFrom for LiquidityPoolWithdrawResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => ClawbackClaimableBalanceResultCode::Success, - -1 => ClawbackClaimableBalanceResultCode::DoesNotExist, - -2 => ClawbackClaimableBalanceResultCode::NotIssuer, - -3 => ClawbackClaimableBalanceResultCode::NotClawbackEnabled, + 0 => LiquidityPoolWithdrawResultCode::Success, + -1 => LiquidityPoolWithdrawResultCode::Malformed, + -2 => LiquidityPoolWithdrawResultCode::NoTrust, + -3 => LiquidityPoolWithdrawResultCode::Underfunded, + -4 => LiquidityPoolWithdrawResultCode::LineFull, + -5 => LiquidityPoolWithdrawResultCode::UnderMinimum, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26707,14 +36534,14 @@ impl TryFrom for ClawbackClaimableBalanceResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: ClawbackClaimableBalanceResultCode) -> Self { + fn from(e: LiquidityPoolWithdrawResultCode) -> Self { e as Self } } -impl ReadXdr for ClawbackClaimableBalanceResultCode { +impl ReadXdr for LiquidityPoolWithdrawResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -26725,7 +36552,7 @@ impl ReadXdr for ClawbackClaimableBalanceResultCode { } } -impl WriteXdr for ClawbackClaimableBalanceResultCode { +impl WriteXdr for LiquidityPoolWithdrawResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26735,20 +36562,21 @@ impl WriteXdr for ClawbackClaimableBalanceResultCode { } } -// ClawbackClaimableBalanceResult is an XDR Union defines as: +// LiquidityPoolWithdrawResult is an XDR Union defines as: // -// union ClawbackClaimableBalanceResult switch ( -// ClawbackClaimableBalanceResultCode code) +// union LiquidityPoolWithdrawResult switch (LiquidityPoolWithdrawResultCode code) // { -// case CLAWBACK_CLAIMABLE_BALANCE_SUCCESS: +// case LIQUIDITY_POOL_WITHDRAW_SUCCESS: // void; -// case CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST: -// case CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER: -// case CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED: +// case LIQUIDITY_POOL_WITHDRAW_MALFORMED: +// case LIQUIDITY_POOL_WITHDRAW_NO_TRUST: +// case LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED: +// case LIQUIDITY_POOL_WITHDRAW_LINE_FULL: +// case LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM: // void; // }; // -// union with discriminant ClawbackClaimableBalanceResultCode +// union with discriminant LiquidityPoolWithdrawResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -26757,84 +36585,100 @@ impl WriteXdr for ClawbackClaimableBalanceResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum ClawbackClaimableBalanceResult { +pub enum LiquidityPoolWithdrawResult { Success, - DoesNotExist, - NotIssuer, - NotClawbackEnabled, + Malformed, + NoTrust, + Underfunded, + LineFull, + UnderMinimum, } -impl ClawbackClaimableBalanceResult { - pub const VARIANTS: [ClawbackClaimableBalanceResultCode; 4] = [ - ClawbackClaimableBalanceResultCode::Success, - ClawbackClaimableBalanceResultCode::DoesNotExist, - ClawbackClaimableBalanceResultCode::NotIssuer, - ClawbackClaimableBalanceResultCode::NotClawbackEnabled, +impl LiquidityPoolWithdrawResult { + pub const VARIANTS: [LiquidityPoolWithdrawResultCode; 6] = [ + LiquidityPoolWithdrawResultCode::Success, + LiquidityPoolWithdrawResultCode::Malformed, + LiquidityPoolWithdrawResultCode::NoTrust, + LiquidityPoolWithdrawResultCode::Underfunded, + LiquidityPoolWithdrawResultCode::LineFull, + LiquidityPoolWithdrawResultCode::UnderMinimum, + ]; + pub const VARIANTS_STR: [&'static str; 6] = [ + "Success", + "Malformed", + "NoTrust", + "Underfunded", + "LineFull", + "UnderMinimum", ]; - pub const VARIANTS_STR: [&'static str; 4] = - ["Success", "DoesNotExist", "NotIssuer", "NotClawbackEnabled"]; #[must_use] pub const fn name(&self) -> &'static str { match self { Self::Success => "Success", - Self::DoesNotExist => "DoesNotExist", - Self::NotIssuer => "NotIssuer", - Self::NotClawbackEnabled => "NotClawbackEnabled", + Self::Malformed => "Malformed", + Self::NoTrust => "NoTrust", + Self::Underfunded => "Underfunded", + Self::LineFull => "LineFull", + Self::UnderMinimum => "UnderMinimum", } } #[must_use] - pub const fn discriminant(&self) -> ClawbackClaimableBalanceResultCode { + pub const fn discriminant(&self) -> LiquidityPoolWithdrawResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => ClawbackClaimableBalanceResultCode::Success, - Self::DoesNotExist => ClawbackClaimableBalanceResultCode::DoesNotExist, - Self::NotIssuer => ClawbackClaimableBalanceResultCode::NotIssuer, - Self::NotClawbackEnabled => ClawbackClaimableBalanceResultCode::NotClawbackEnabled, + Self::Success => LiquidityPoolWithdrawResultCode::Success, + Self::Malformed => LiquidityPoolWithdrawResultCode::Malformed, + Self::NoTrust => LiquidityPoolWithdrawResultCode::NoTrust, + Self::Underfunded => LiquidityPoolWithdrawResultCode::Underfunded, + Self::LineFull => LiquidityPoolWithdrawResultCode::LineFull, + Self::UnderMinimum => LiquidityPoolWithdrawResultCode::UnderMinimum, } } #[must_use] - pub const fn variants() -> [ClawbackClaimableBalanceResultCode; 4] { + pub const fn variants() -> [LiquidityPoolWithdrawResultCode; 6] { Self::VARIANTS } } -impl Name for ClawbackClaimableBalanceResult { +impl Name for LiquidityPoolWithdrawResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for ClawbackClaimableBalanceResult { +impl Discriminant for LiquidityPoolWithdrawResult { #[must_use] - fn discriminant(&self) -> ClawbackClaimableBalanceResultCode { + fn discriminant(&self) -> LiquidityPoolWithdrawResultCode { Self::discriminant(self) } } -impl Variants for ClawbackClaimableBalanceResult { - fn variants() -> slice::Iter<'static, ClawbackClaimableBalanceResultCode> { +impl Variants for LiquidityPoolWithdrawResult { + fn variants() -> slice::Iter<'static, LiquidityPoolWithdrawResultCode> { Self::VARIANTS.iter() } } -impl Union for ClawbackClaimableBalanceResult {} +impl Union for LiquidityPoolWithdrawResult {} -impl ReadXdr for ClawbackClaimableBalanceResult { +impl ReadXdr for LiquidityPoolWithdrawResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: ClawbackClaimableBalanceResultCode = - ::read_xdr(r)?; + let dv: LiquidityPoolWithdrawResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - ClawbackClaimableBalanceResultCode::Success => Self::Success, - ClawbackClaimableBalanceResultCode::DoesNotExist => Self::DoesNotExist, - ClawbackClaimableBalanceResultCode::NotIssuer => Self::NotIssuer, - ClawbackClaimableBalanceResultCode::NotClawbackEnabled => Self::NotClawbackEnabled, + LiquidityPoolWithdrawResultCode::Success => Self::Success, + LiquidityPoolWithdrawResultCode::Malformed => Self::Malformed, + LiquidityPoolWithdrawResultCode::NoTrust => Self::NoTrust, + LiquidityPoolWithdrawResultCode::Underfunded => Self::Underfunded, + LiquidityPoolWithdrawResultCode::LineFull => Self::LineFull, + LiquidityPoolWithdrawResultCode::UnderMinimum => Self::UnderMinimum, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26843,7 +36687,7 @@ impl ReadXdr for ClawbackClaimableBalanceResult { } } -impl WriteXdr for ClawbackClaimableBalanceResult { +impl WriteXdr for LiquidityPoolWithdrawResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26851,29 +36695,30 @@ impl WriteXdr for ClawbackClaimableBalanceResult { #[allow(clippy::match_same_arms)] match self { Self::Success => ().write_xdr(w)?, - Self::DoesNotExist => ().write_xdr(w)?, - Self::NotIssuer => ().write_xdr(w)?, - Self::NotClawbackEnabled => ().write_xdr(w)?, + Self::Malformed => ().write_xdr(w)?, + Self::NoTrust => ().write_xdr(w)?, + Self::Underfunded => ().write_xdr(w)?, + Self::LineFull => ().write_xdr(w)?, + Self::UnderMinimum => ().write_xdr(w)?, }; Ok(()) }) } } -// SetTrustLineFlagsResultCode is an XDR Enum defines as: +// InvokeHostFunctionResultCode is an XDR Enum defines as: // -// enum SetTrustLineFlagsResultCode +// enum InvokeHostFunctionResultCode // { // // codes considered as "success" for the operation -// SET_TRUST_LINE_FLAGS_SUCCESS = 0, +// INVOKE_HOST_FUNCTION_SUCCESS = 0, // // // codes considered as "failure" for the operation -// SET_TRUST_LINE_FLAGS_MALFORMED = -1, -// SET_TRUST_LINE_FLAGS_NO_TRUST_LINE = -2, -// SET_TRUST_LINE_FLAGS_CANT_REVOKE = -3, -// SET_TRUST_LINE_FLAGS_INVALID_STATE = -4, -// SET_TRUST_LINE_FLAGS_LOW_RESERVE = -5 // claimable balances can't be created -// // on revoke due to low reserves +// INVOKE_HOST_FUNCTION_MALFORMED = -1, +// INVOKE_HOST_FUNCTION_TRAPPED = -2, +// INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED = -3, +// INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = -4, +// INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = -5 // }; // // enum @@ -26885,31 +36730,31 @@ impl WriteXdr for ClawbackClaimableBalanceResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum SetTrustLineFlagsResultCode { +pub enum InvokeHostFunctionResultCode { Success = 0, Malformed = -1, - NoTrustLine = -2, - CantRevoke = -3, - InvalidState = -4, - LowReserve = -5, -} - -impl SetTrustLineFlagsResultCode { - pub const VARIANTS: [SetTrustLineFlagsResultCode; 6] = [ - SetTrustLineFlagsResultCode::Success, - SetTrustLineFlagsResultCode::Malformed, - SetTrustLineFlagsResultCode::NoTrustLine, - SetTrustLineFlagsResultCode::CantRevoke, - SetTrustLineFlagsResultCode::InvalidState, - SetTrustLineFlagsResultCode::LowReserve, + Trapped = -2, + ResourceLimitExceeded = -3, + EntryExpired = -4, + InsufficientRefundableFee = -5, +} + +impl InvokeHostFunctionResultCode { + pub const VARIANTS: [InvokeHostFunctionResultCode; 6] = [ + InvokeHostFunctionResultCode::Success, + InvokeHostFunctionResultCode::Malformed, + InvokeHostFunctionResultCode::Trapped, + InvokeHostFunctionResultCode::ResourceLimitExceeded, + InvokeHostFunctionResultCode::EntryExpired, + InvokeHostFunctionResultCode::InsufficientRefundableFee, ]; pub const VARIANTS_STR: [&'static str; 6] = [ "Success", "Malformed", - "NoTrustLine", - "CantRevoke", - "InvalidState", - "LowReserve", + "Trapped", + "ResourceLimitExceeded", + "EntryExpired", + "InsufficientRefundableFee", ]; #[must_use] @@ -26917,51 +36762,51 @@ impl SetTrustLineFlagsResultCode { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::NoTrustLine => "NoTrustLine", - Self::CantRevoke => "CantRevoke", - Self::InvalidState => "InvalidState", - Self::LowReserve => "LowReserve", + Self::Trapped => "Trapped", + Self::ResourceLimitExceeded => "ResourceLimitExceeded", + Self::EntryExpired => "EntryExpired", + Self::InsufficientRefundableFee => "InsufficientRefundableFee", } } #[must_use] - pub const fn variants() -> [SetTrustLineFlagsResultCode; 6] { + pub const fn variants() -> [InvokeHostFunctionResultCode; 6] { Self::VARIANTS } } -impl Name for SetTrustLineFlagsResultCode { +impl Name for InvokeHostFunctionResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for SetTrustLineFlagsResultCode { - fn variants() -> slice::Iter<'static, SetTrustLineFlagsResultCode> { +impl Variants for InvokeHostFunctionResultCode { + fn variants() -> slice::Iter<'static, InvokeHostFunctionResultCode> { Self::VARIANTS.iter() } } -impl Enum for SetTrustLineFlagsResultCode {} +impl Enum for InvokeHostFunctionResultCode {} -impl fmt::Display for SetTrustLineFlagsResultCode { +impl fmt::Display for InvokeHostFunctionResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for SetTrustLineFlagsResultCode { +impl TryFrom for InvokeHostFunctionResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => SetTrustLineFlagsResultCode::Success, - -1 => SetTrustLineFlagsResultCode::Malformed, - -2 => SetTrustLineFlagsResultCode::NoTrustLine, - -3 => SetTrustLineFlagsResultCode::CantRevoke, - -4 => SetTrustLineFlagsResultCode::InvalidState, - -5 => SetTrustLineFlagsResultCode::LowReserve, + 0 => InvokeHostFunctionResultCode::Success, + -1 => InvokeHostFunctionResultCode::Malformed, + -2 => InvokeHostFunctionResultCode::Trapped, + -3 => InvokeHostFunctionResultCode::ResourceLimitExceeded, + -4 => InvokeHostFunctionResultCode::EntryExpired, + -5 => InvokeHostFunctionResultCode::InsufficientRefundableFee, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -26969,14 +36814,14 @@ impl TryFrom for SetTrustLineFlagsResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: SetTrustLineFlagsResultCode) -> Self { + fn from(e: InvokeHostFunctionResultCode) -> Self { e as Self } } -impl ReadXdr for SetTrustLineFlagsResultCode { +impl ReadXdr for InvokeHostFunctionResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -26987,7 +36832,7 @@ impl ReadXdr for SetTrustLineFlagsResultCode { } } -impl WriteXdr for SetTrustLineFlagsResultCode { +impl WriteXdr for InvokeHostFunctionResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -26997,21 +36842,21 @@ impl WriteXdr for SetTrustLineFlagsResultCode { } } -// SetTrustLineFlagsResult is an XDR Union defines as: +// InvokeHostFunctionResult is an XDR Union defines as: // -// union SetTrustLineFlagsResult switch (SetTrustLineFlagsResultCode code) +// union InvokeHostFunctionResult switch (InvokeHostFunctionResultCode code) // { -// case SET_TRUST_LINE_FLAGS_SUCCESS: -// void; -// case SET_TRUST_LINE_FLAGS_MALFORMED: -// case SET_TRUST_LINE_FLAGS_NO_TRUST_LINE: -// case SET_TRUST_LINE_FLAGS_CANT_REVOKE: -// case SET_TRUST_LINE_FLAGS_INVALID_STATE: -// case SET_TRUST_LINE_FLAGS_LOW_RESERVE: +// case INVOKE_HOST_FUNCTION_SUCCESS: +// Hash success; // sha256(InvokeHostFunctionSuccessPreImage) +// case INVOKE_HOST_FUNCTION_MALFORMED: +// case INVOKE_HOST_FUNCTION_TRAPPED: +// case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: +// case INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: +// case INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: // void; // }; // -// union with discriminant SetTrustLineFlagsResultCode +// union with discriminant InvokeHostFunctionResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -27020,100 +36865,104 @@ impl WriteXdr for SetTrustLineFlagsResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum SetTrustLineFlagsResult { - Success, +pub enum InvokeHostFunctionResult { + Success(Hash), Malformed, - NoTrustLine, - CantRevoke, - InvalidState, - LowReserve, -} - -impl SetTrustLineFlagsResult { - pub const VARIANTS: [SetTrustLineFlagsResultCode; 6] = [ - SetTrustLineFlagsResultCode::Success, - SetTrustLineFlagsResultCode::Malformed, - SetTrustLineFlagsResultCode::NoTrustLine, - SetTrustLineFlagsResultCode::CantRevoke, - SetTrustLineFlagsResultCode::InvalidState, - SetTrustLineFlagsResultCode::LowReserve, + Trapped, + ResourceLimitExceeded, + EntryExpired, + InsufficientRefundableFee, +} + +impl InvokeHostFunctionResult { + pub const VARIANTS: [InvokeHostFunctionResultCode; 6] = [ + InvokeHostFunctionResultCode::Success, + InvokeHostFunctionResultCode::Malformed, + InvokeHostFunctionResultCode::Trapped, + InvokeHostFunctionResultCode::ResourceLimitExceeded, + InvokeHostFunctionResultCode::EntryExpired, + InvokeHostFunctionResultCode::InsufficientRefundableFee, ]; pub const VARIANTS_STR: [&'static str; 6] = [ "Success", "Malformed", - "NoTrustLine", - "CantRevoke", - "InvalidState", - "LowReserve", + "Trapped", + "ResourceLimitExceeded", + "EntryExpired", + "InsufficientRefundableFee", ]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::Success => "Success", + Self::Success(_) => "Success", Self::Malformed => "Malformed", - Self::NoTrustLine => "NoTrustLine", - Self::CantRevoke => "CantRevoke", - Self::InvalidState => "InvalidState", - Self::LowReserve => "LowReserve", + Self::Trapped => "Trapped", + Self::ResourceLimitExceeded => "ResourceLimitExceeded", + Self::EntryExpired => "EntryExpired", + Self::InsufficientRefundableFee => "InsufficientRefundableFee", } } #[must_use] - pub const fn discriminant(&self) -> SetTrustLineFlagsResultCode { + pub const fn discriminant(&self) -> InvokeHostFunctionResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => SetTrustLineFlagsResultCode::Success, - Self::Malformed => SetTrustLineFlagsResultCode::Malformed, - Self::NoTrustLine => SetTrustLineFlagsResultCode::NoTrustLine, - Self::CantRevoke => SetTrustLineFlagsResultCode::CantRevoke, - Self::InvalidState => SetTrustLineFlagsResultCode::InvalidState, - Self::LowReserve => SetTrustLineFlagsResultCode::LowReserve, + Self::Success(_) => InvokeHostFunctionResultCode::Success, + Self::Malformed => InvokeHostFunctionResultCode::Malformed, + Self::Trapped => InvokeHostFunctionResultCode::Trapped, + Self::ResourceLimitExceeded => InvokeHostFunctionResultCode::ResourceLimitExceeded, + Self::EntryExpired => InvokeHostFunctionResultCode::EntryExpired, + Self::InsufficientRefundableFee => { + InvokeHostFunctionResultCode::InsufficientRefundableFee + } } } #[must_use] - pub const fn variants() -> [SetTrustLineFlagsResultCode; 6] { + pub const fn variants() -> [InvokeHostFunctionResultCode; 6] { Self::VARIANTS } } -impl Name for SetTrustLineFlagsResult { +impl Name for InvokeHostFunctionResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for SetTrustLineFlagsResult { +impl Discriminant for InvokeHostFunctionResult { #[must_use] - fn discriminant(&self) -> SetTrustLineFlagsResultCode { + fn discriminant(&self) -> InvokeHostFunctionResultCode { Self::discriminant(self) } } -impl Variants for SetTrustLineFlagsResult { - fn variants() -> slice::Iter<'static, SetTrustLineFlagsResultCode> { +impl Variants for InvokeHostFunctionResult { + fn variants() -> slice::Iter<'static, InvokeHostFunctionResultCode> { Self::VARIANTS.iter() } } -impl Union for SetTrustLineFlagsResult {} +impl Union for InvokeHostFunctionResult {} -impl ReadXdr for SetTrustLineFlagsResult { +impl ReadXdr for InvokeHostFunctionResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: SetTrustLineFlagsResultCode = - ::read_xdr(r)?; + let dv: InvokeHostFunctionResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - SetTrustLineFlagsResultCode::Success => Self::Success, - SetTrustLineFlagsResultCode::Malformed => Self::Malformed, - SetTrustLineFlagsResultCode::NoTrustLine => Self::NoTrustLine, - SetTrustLineFlagsResultCode::CantRevoke => Self::CantRevoke, - SetTrustLineFlagsResultCode::InvalidState => Self::InvalidState, - SetTrustLineFlagsResultCode::LowReserve => Self::LowReserve, + InvokeHostFunctionResultCode::Success => Self::Success(Hash::read_xdr(r)?), + InvokeHostFunctionResultCode::Malformed => Self::Malformed, + InvokeHostFunctionResultCode::Trapped => Self::Trapped, + InvokeHostFunctionResultCode::ResourceLimitExceeded => Self::ResourceLimitExceeded, + InvokeHostFunctionResultCode::EntryExpired => Self::EntryExpired, + InvokeHostFunctionResultCode::InsufficientRefundableFee => { + Self::InsufficientRefundableFee + } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -27122,44 +36971,36 @@ impl ReadXdr for SetTrustLineFlagsResult { } } -impl WriteXdr for SetTrustLineFlagsResult { +impl WriteXdr for InvokeHostFunctionResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { self.discriminant().write_xdr(w)?; #[allow(clippy::match_same_arms)] match self { - Self::Success => ().write_xdr(w)?, + Self::Success(v) => v.write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::NoTrustLine => ().write_xdr(w)?, - Self::CantRevoke => ().write_xdr(w)?, - Self::InvalidState => ().write_xdr(w)?, - Self::LowReserve => ().write_xdr(w)?, + Self::Trapped => ().write_xdr(w)?, + Self::ResourceLimitExceeded => ().write_xdr(w)?, + Self::EntryExpired => ().write_xdr(w)?, + Self::InsufficientRefundableFee => ().write_xdr(w)?, }; Ok(()) }) } } -// LiquidityPoolDepositResultCode is an XDR Enum defines as: +// BumpFootprintExpirationResultCode is an XDR Enum defines as: // -// enum LiquidityPoolDepositResultCode +// enum BumpFootprintExpirationResultCode // { // // codes considered as "success" for the operation -// LIQUIDITY_POOL_DEPOSIT_SUCCESS = 0, +// BUMP_FOOTPRINT_EXPIRATION_SUCCESS = 0, // // // codes considered as "failure" for the operation -// LIQUIDITY_POOL_DEPOSIT_MALFORMED = -1, // bad input -// LIQUIDITY_POOL_DEPOSIT_NO_TRUST = -2, // no trust line for one of the -// // assets -// LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED = -3, // not authorized for one of the -// // assets -// LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED = -4, // not enough balance for one of -// // the assets -// LIQUIDITY_POOL_DEPOSIT_LINE_FULL = -5, // pool share trust line doesn't -// // have sufficient limit -// LIQUIDITY_POOL_DEPOSIT_BAD_PRICE = -6, // deposit price outside bounds -// LIQUIDITY_POOL_DEPOSIT_POOL_FULL = -7 // pool reserves are full +// BUMP_FOOTPRINT_EXPIRATION_MALFORMED = -1, +// BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = -2, +// BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = -3 // }; // // enum @@ -27171,37 +37012,25 @@ impl WriteXdr for SetTrustLineFlagsResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum LiquidityPoolDepositResultCode { +pub enum BumpFootprintExpirationResultCode { Success = 0, Malformed = -1, - NoTrust = -2, - NotAuthorized = -3, - Underfunded = -4, - LineFull = -5, - BadPrice = -6, - PoolFull = -7, + ResourceLimitExceeded = -2, + InsufficientRefundableFee = -3, } -impl LiquidityPoolDepositResultCode { - pub const VARIANTS: [LiquidityPoolDepositResultCode; 8] = [ - LiquidityPoolDepositResultCode::Success, - LiquidityPoolDepositResultCode::Malformed, - LiquidityPoolDepositResultCode::NoTrust, - LiquidityPoolDepositResultCode::NotAuthorized, - LiquidityPoolDepositResultCode::Underfunded, - LiquidityPoolDepositResultCode::LineFull, - LiquidityPoolDepositResultCode::BadPrice, - LiquidityPoolDepositResultCode::PoolFull, +impl BumpFootprintExpirationResultCode { + pub const VARIANTS: [BumpFootprintExpirationResultCode; 4] = [ + BumpFootprintExpirationResultCode::Success, + BumpFootprintExpirationResultCode::Malformed, + BumpFootprintExpirationResultCode::ResourceLimitExceeded, + BumpFootprintExpirationResultCode::InsufficientRefundableFee, ]; - pub const VARIANTS_STR: [&'static str; 8] = [ + pub const VARIANTS_STR: [&'static str; 4] = [ "Success", "Malformed", - "NoTrust", - "NotAuthorized", - "Underfunded", - "LineFull", - "BadPrice", - "PoolFull", + "ResourceLimitExceeded", + "InsufficientRefundableFee", ]; #[must_use] @@ -27209,55 +37038,47 @@ impl LiquidityPoolDepositResultCode { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", - Self::Underfunded => "Underfunded", - Self::LineFull => "LineFull", - Self::BadPrice => "BadPrice", - Self::PoolFull => "PoolFull", + Self::ResourceLimitExceeded => "ResourceLimitExceeded", + Self::InsufficientRefundableFee => "InsufficientRefundableFee", } } #[must_use] - pub const fn variants() -> [LiquidityPoolDepositResultCode; 8] { + pub const fn variants() -> [BumpFootprintExpirationResultCode; 4] { Self::VARIANTS } } -impl Name for LiquidityPoolDepositResultCode { +impl Name for BumpFootprintExpirationResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for LiquidityPoolDepositResultCode { - fn variants() -> slice::Iter<'static, LiquidityPoolDepositResultCode> { +impl Variants for BumpFootprintExpirationResultCode { + fn variants() -> slice::Iter<'static, BumpFootprintExpirationResultCode> { Self::VARIANTS.iter() } } -impl Enum for LiquidityPoolDepositResultCode {} +impl Enum for BumpFootprintExpirationResultCode {} -impl fmt::Display for LiquidityPoolDepositResultCode { +impl fmt::Display for BumpFootprintExpirationResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for LiquidityPoolDepositResultCode { +impl TryFrom for BumpFootprintExpirationResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => LiquidityPoolDepositResultCode::Success, - -1 => LiquidityPoolDepositResultCode::Malformed, - -2 => LiquidityPoolDepositResultCode::NoTrust, - -3 => LiquidityPoolDepositResultCode::NotAuthorized, - -4 => LiquidityPoolDepositResultCode::Underfunded, - -5 => LiquidityPoolDepositResultCode::LineFull, - -6 => LiquidityPoolDepositResultCode::BadPrice, - -7 => LiquidityPoolDepositResultCode::PoolFull, + 0 => BumpFootprintExpirationResultCode::Success, + -1 => BumpFootprintExpirationResultCode::Malformed, + -2 => BumpFootprintExpirationResultCode::ResourceLimitExceeded, + -3 => BumpFootprintExpirationResultCode::InsufficientRefundableFee, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -27265,14 +37086,14 @@ impl TryFrom for LiquidityPoolDepositResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: LiquidityPoolDepositResultCode) -> Self { + fn from(e: BumpFootprintExpirationResultCode) -> Self { e as Self } } -impl ReadXdr for LiquidityPoolDepositResultCode { +impl ReadXdr for BumpFootprintExpirationResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -27283,7 +37104,7 @@ impl ReadXdr for LiquidityPoolDepositResultCode { } } -impl WriteXdr for LiquidityPoolDepositResultCode { +impl WriteXdr for BumpFootprintExpirationResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -27293,23 +37114,19 @@ impl WriteXdr for LiquidityPoolDepositResultCode { } } -// LiquidityPoolDepositResult is an XDR Union defines as: +// BumpFootprintExpirationResult is an XDR Union defines as: // -// union LiquidityPoolDepositResult switch (LiquidityPoolDepositResultCode code) +// union BumpFootprintExpirationResult switch (BumpFootprintExpirationResultCode code) // { -// case LIQUIDITY_POOL_DEPOSIT_SUCCESS: +// case BUMP_FOOTPRINT_EXPIRATION_SUCCESS: // void; -// case LIQUIDITY_POOL_DEPOSIT_MALFORMED: -// case LIQUIDITY_POOL_DEPOSIT_NO_TRUST: -// case LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED: -// case LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED: -// case LIQUIDITY_POOL_DEPOSIT_LINE_FULL: -// case LIQUIDITY_POOL_DEPOSIT_BAD_PRICE: -// case LIQUIDITY_POOL_DEPOSIT_POOL_FULL: +// case BUMP_FOOTPRINT_EXPIRATION_MALFORMED: +// case BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: +// case BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: // void; // }; // -// union with discriminant LiquidityPoolDepositResultCode +// union with discriminant BumpFootprintExpirationResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -27318,37 +37135,25 @@ impl WriteXdr for LiquidityPoolDepositResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LiquidityPoolDepositResult { +pub enum BumpFootprintExpirationResult { Success, Malformed, - NoTrust, - NotAuthorized, - Underfunded, - LineFull, - BadPrice, - PoolFull, + ResourceLimitExceeded, + InsufficientRefundableFee, } -impl LiquidityPoolDepositResult { - pub const VARIANTS: [LiquidityPoolDepositResultCode; 8] = [ - LiquidityPoolDepositResultCode::Success, - LiquidityPoolDepositResultCode::Malformed, - LiquidityPoolDepositResultCode::NoTrust, - LiquidityPoolDepositResultCode::NotAuthorized, - LiquidityPoolDepositResultCode::Underfunded, - LiquidityPoolDepositResultCode::LineFull, - LiquidityPoolDepositResultCode::BadPrice, - LiquidityPoolDepositResultCode::PoolFull, +impl BumpFootprintExpirationResult { + pub const VARIANTS: [BumpFootprintExpirationResultCode; 4] = [ + BumpFootprintExpirationResultCode::Success, + BumpFootprintExpirationResultCode::Malformed, + BumpFootprintExpirationResultCode::ResourceLimitExceeded, + BumpFootprintExpirationResultCode::InsufficientRefundableFee, ]; - pub const VARIANTS_STR: [&'static str; 8] = [ + pub const VARIANTS_STR: [&'static str; 4] = [ "Success", "Malformed", - "NoTrust", - "NotAuthorized", - "Underfunded", - "LineFull", - "BadPrice", - "PoolFull", + "ResourceLimitExceeded", + "InsufficientRefundableFee", ]; #[must_use] @@ -27356,74 +37161,68 @@ impl LiquidityPoolDepositResult { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::NoTrust => "NoTrust", - Self::NotAuthorized => "NotAuthorized", - Self::Underfunded => "Underfunded", - Self::LineFull => "LineFull", - Self::BadPrice => "BadPrice", - Self::PoolFull => "PoolFull", + Self::ResourceLimitExceeded => "ResourceLimitExceeded", + Self::InsufficientRefundableFee => "InsufficientRefundableFee", } } #[must_use] - pub const fn discriminant(&self) -> LiquidityPoolDepositResultCode { + pub const fn discriminant(&self) -> BumpFootprintExpirationResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => LiquidityPoolDepositResultCode::Success, - Self::Malformed => LiquidityPoolDepositResultCode::Malformed, - Self::NoTrust => LiquidityPoolDepositResultCode::NoTrust, - Self::NotAuthorized => LiquidityPoolDepositResultCode::NotAuthorized, - Self::Underfunded => LiquidityPoolDepositResultCode::Underfunded, - Self::LineFull => LiquidityPoolDepositResultCode::LineFull, - Self::BadPrice => LiquidityPoolDepositResultCode::BadPrice, - Self::PoolFull => LiquidityPoolDepositResultCode::PoolFull, + Self::Success => BumpFootprintExpirationResultCode::Success, + Self::Malformed => BumpFootprintExpirationResultCode::Malformed, + Self::ResourceLimitExceeded => BumpFootprintExpirationResultCode::ResourceLimitExceeded, + Self::InsufficientRefundableFee => { + BumpFootprintExpirationResultCode::InsufficientRefundableFee + } } } #[must_use] - pub const fn variants() -> [LiquidityPoolDepositResultCode; 8] { + pub const fn variants() -> [BumpFootprintExpirationResultCode; 4] { Self::VARIANTS } } -impl Name for LiquidityPoolDepositResult { +impl Name for BumpFootprintExpirationResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LiquidityPoolDepositResult { +impl Discriminant for BumpFootprintExpirationResult { #[must_use] - fn discriminant(&self) -> LiquidityPoolDepositResultCode { + fn discriminant(&self) -> BumpFootprintExpirationResultCode { Self::discriminant(self) } } -impl Variants for LiquidityPoolDepositResult { - fn variants() -> slice::Iter<'static, LiquidityPoolDepositResultCode> { +impl Variants for BumpFootprintExpirationResult { + fn variants() -> slice::Iter<'static, BumpFootprintExpirationResultCode> { Self::VARIANTS.iter() } } -impl Union for LiquidityPoolDepositResult {} +impl Union for BumpFootprintExpirationResult {} -impl ReadXdr for LiquidityPoolDepositResult { +impl ReadXdr for BumpFootprintExpirationResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LiquidityPoolDepositResultCode = - ::read_xdr(r)?; + let dv: BumpFootprintExpirationResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - LiquidityPoolDepositResultCode::Success => Self::Success, - LiquidityPoolDepositResultCode::Malformed => Self::Malformed, - LiquidityPoolDepositResultCode::NoTrust => Self::NoTrust, - LiquidityPoolDepositResultCode::NotAuthorized => Self::NotAuthorized, - LiquidityPoolDepositResultCode::Underfunded => Self::Underfunded, - LiquidityPoolDepositResultCode::LineFull => Self::LineFull, - LiquidityPoolDepositResultCode::BadPrice => Self::BadPrice, - LiquidityPoolDepositResultCode::PoolFull => Self::PoolFull, + BumpFootprintExpirationResultCode::Success => Self::Success, + BumpFootprintExpirationResultCode::Malformed => Self::Malformed, + BumpFootprintExpirationResultCode::ResourceLimitExceeded => { + Self::ResourceLimitExceeded + } + BumpFootprintExpirationResultCode::InsufficientRefundableFee => { + Self::InsufficientRefundableFee + } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -27432,7 +37231,7 @@ impl ReadXdr for LiquidityPoolDepositResult { } } -impl WriteXdr for LiquidityPoolDepositResult { +impl WriteXdr for BumpFootprintExpirationResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -27441,34 +37240,25 @@ impl WriteXdr for LiquidityPoolDepositResult { match self { Self::Success => ().write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::NoTrust => ().write_xdr(w)?, - Self::NotAuthorized => ().write_xdr(w)?, - Self::Underfunded => ().write_xdr(w)?, - Self::LineFull => ().write_xdr(w)?, - Self::BadPrice => ().write_xdr(w)?, - Self::PoolFull => ().write_xdr(w)?, + Self::ResourceLimitExceeded => ().write_xdr(w)?, + Self::InsufficientRefundableFee => ().write_xdr(w)?, }; Ok(()) }) } } -// LiquidityPoolWithdrawResultCode is an XDR Enum defines as: +// RestoreFootprintResultCode is an XDR Enum defines as: // -// enum LiquidityPoolWithdrawResultCode +// enum RestoreFootprintResultCode // { // // codes considered as "success" for the operation -// LIQUIDITY_POOL_WITHDRAW_SUCCESS = 0, +// RESTORE_FOOTPRINT_SUCCESS = 0, // // // codes considered as "failure" for the operation -// LIQUIDITY_POOL_WITHDRAW_MALFORMED = -1, // bad input -// LIQUIDITY_POOL_WITHDRAW_NO_TRUST = -2, // no trust line for one of the -// // assets -// LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED = -3, // not enough balance of the -// // pool share -// LIQUIDITY_POOL_WITHDRAW_LINE_FULL = -4, // would go above limit for one -// // of the assets -// LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM = -5 // didn't withdraw enough +// RESTORE_FOOTPRINT_MALFORMED = -1, +// RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED = -2, +// RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE = -3 // }; // // enum @@ -27480,31 +37270,25 @@ impl WriteXdr for LiquidityPoolDepositResult { serde(rename_all = "snake_case") )] #[repr(i32)] -pub enum LiquidityPoolWithdrawResultCode { +pub enum RestoreFootprintResultCode { Success = 0, Malformed = -1, - NoTrust = -2, - Underfunded = -3, - LineFull = -4, - UnderMinimum = -5, + ResourceLimitExceeded = -2, + InsufficientRefundableFee = -3, } -impl LiquidityPoolWithdrawResultCode { - pub const VARIANTS: [LiquidityPoolWithdrawResultCode; 6] = [ - LiquidityPoolWithdrawResultCode::Success, - LiquidityPoolWithdrawResultCode::Malformed, - LiquidityPoolWithdrawResultCode::NoTrust, - LiquidityPoolWithdrawResultCode::Underfunded, - LiquidityPoolWithdrawResultCode::LineFull, - LiquidityPoolWithdrawResultCode::UnderMinimum, +impl RestoreFootprintResultCode { + pub const VARIANTS: [RestoreFootprintResultCode; 4] = [ + RestoreFootprintResultCode::Success, + RestoreFootprintResultCode::Malformed, + RestoreFootprintResultCode::ResourceLimitExceeded, + RestoreFootprintResultCode::InsufficientRefundableFee, ]; - pub const VARIANTS_STR: [&'static str; 6] = [ + pub const VARIANTS_STR: [&'static str; 4] = [ "Success", "Malformed", - "NoTrust", - "Underfunded", - "LineFull", - "UnderMinimum", + "ResourceLimitExceeded", + "InsufficientRefundableFee", ]; #[must_use] @@ -27512,51 +37296,47 @@ impl LiquidityPoolWithdrawResultCode { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::NoTrust => "NoTrust", - Self::Underfunded => "Underfunded", - Self::LineFull => "LineFull", - Self::UnderMinimum => "UnderMinimum", + Self::ResourceLimitExceeded => "ResourceLimitExceeded", + Self::InsufficientRefundableFee => "InsufficientRefundableFee", } } #[must_use] - pub const fn variants() -> [LiquidityPoolWithdrawResultCode; 6] { + pub const fn variants() -> [RestoreFootprintResultCode; 4] { Self::VARIANTS } } -impl Name for LiquidityPoolWithdrawResultCode { +impl Name for RestoreFootprintResultCode { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Variants for LiquidityPoolWithdrawResultCode { - fn variants() -> slice::Iter<'static, LiquidityPoolWithdrawResultCode> { +impl Variants for RestoreFootprintResultCode { + fn variants() -> slice::Iter<'static, RestoreFootprintResultCode> { Self::VARIANTS.iter() } } -impl Enum for LiquidityPoolWithdrawResultCode {} +impl Enum for RestoreFootprintResultCode {} -impl fmt::Display for LiquidityPoolWithdrawResultCode { +impl fmt::Display for RestoreFootprintResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.name()) } } -impl TryFrom for LiquidityPoolWithdrawResultCode { +impl TryFrom for RestoreFootprintResultCode { type Error = Error; fn try_from(i: i32) -> Result { let e = match i { - 0 => LiquidityPoolWithdrawResultCode::Success, - -1 => LiquidityPoolWithdrawResultCode::Malformed, - -2 => LiquidityPoolWithdrawResultCode::NoTrust, - -3 => LiquidityPoolWithdrawResultCode::Underfunded, - -4 => LiquidityPoolWithdrawResultCode::LineFull, - -5 => LiquidityPoolWithdrawResultCode::UnderMinimum, + 0 => RestoreFootprintResultCode::Success, + -1 => RestoreFootprintResultCode::Malformed, + -2 => RestoreFootprintResultCode::ResourceLimitExceeded, + -3 => RestoreFootprintResultCode::InsufficientRefundableFee, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -27564,14 +37344,14 @@ impl TryFrom for LiquidityPoolWithdrawResultCode { } } -impl From for i32 { +impl From for i32 { #[must_use] - fn from(e: LiquidityPoolWithdrawResultCode) -> Self { + fn from(e: RestoreFootprintResultCode) -> Self { e as Self } } -impl ReadXdr for LiquidityPoolWithdrawResultCode { +impl ReadXdr for RestoreFootprintResultCode { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { @@ -27582,7 +37362,7 @@ impl ReadXdr for LiquidityPoolWithdrawResultCode { } } -impl WriteXdr for LiquidityPoolWithdrawResultCode { +impl WriteXdr for RestoreFootprintResultCode { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -27592,21 +37372,19 @@ impl WriteXdr for LiquidityPoolWithdrawResultCode { } } -// LiquidityPoolWithdrawResult is an XDR Union defines as: +// RestoreFootprintResult is an XDR Union defines as: // -// union LiquidityPoolWithdrawResult switch (LiquidityPoolWithdrawResultCode code) +// union RestoreFootprintResult switch (RestoreFootprintResultCode code) // { -// case LIQUIDITY_POOL_WITHDRAW_SUCCESS: +// case RESTORE_FOOTPRINT_SUCCESS: // void; -// case LIQUIDITY_POOL_WITHDRAW_MALFORMED: -// case LIQUIDITY_POOL_WITHDRAW_NO_TRUST: -// case LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED: -// case LIQUIDITY_POOL_WITHDRAW_LINE_FULL: -// case LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM: +// case RESTORE_FOOTPRINT_MALFORMED: +// case RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED: +// case RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE: // void; // }; // -// union with discriminant LiquidityPoolWithdrawResultCode +// union with discriminant RestoreFootprintResultCode #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] #[cfg_attr( @@ -27615,31 +37393,25 @@ impl WriteXdr for LiquidityPoolWithdrawResultCode { serde(rename_all = "snake_case") )] #[allow(clippy::large_enum_variant)] -pub enum LiquidityPoolWithdrawResult { +pub enum RestoreFootprintResult { Success, Malformed, - NoTrust, - Underfunded, - LineFull, - UnderMinimum, + ResourceLimitExceeded, + InsufficientRefundableFee, } -impl LiquidityPoolWithdrawResult { - pub const VARIANTS: [LiquidityPoolWithdrawResultCode; 6] = [ - LiquidityPoolWithdrawResultCode::Success, - LiquidityPoolWithdrawResultCode::Malformed, - LiquidityPoolWithdrawResultCode::NoTrust, - LiquidityPoolWithdrawResultCode::Underfunded, - LiquidityPoolWithdrawResultCode::LineFull, - LiquidityPoolWithdrawResultCode::UnderMinimum, +impl RestoreFootprintResult { + pub const VARIANTS: [RestoreFootprintResultCode; 4] = [ + RestoreFootprintResultCode::Success, + RestoreFootprintResultCode::Malformed, + RestoreFootprintResultCode::ResourceLimitExceeded, + RestoreFootprintResultCode::InsufficientRefundableFee, ]; - pub const VARIANTS_STR: [&'static str; 6] = [ + pub const VARIANTS_STR: [&'static str; 4] = [ "Success", "Malformed", - "NoTrust", - "Underfunded", - "LineFull", - "UnderMinimum", + "ResourceLimitExceeded", + "InsufficientRefundableFee", ]; #[must_use] @@ -27647,68 +37419,66 @@ impl LiquidityPoolWithdrawResult { match self { Self::Success => "Success", Self::Malformed => "Malformed", - Self::NoTrust => "NoTrust", - Self::Underfunded => "Underfunded", - Self::LineFull => "LineFull", - Self::UnderMinimum => "UnderMinimum", + Self::ResourceLimitExceeded => "ResourceLimitExceeded", + Self::InsufficientRefundableFee => "InsufficientRefundableFee", } } #[must_use] - pub const fn discriminant(&self) -> LiquidityPoolWithdrawResultCode { + pub const fn discriminant(&self) -> RestoreFootprintResultCode { #[allow(clippy::match_same_arms)] match self { - Self::Success => LiquidityPoolWithdrawResultCode::Success, - Self::Malformed => LiquidityPoolWithdrawResultCode::Malformed, - Self::NoTrust => LiquidityPoolWithdrawResultCode::NoTrust, - Self::Underfunded => LiquidityPoolWithdrawResultCode::Underfunded, - Self::LineFull => LiquidityPoolWithdrawResultCode::LineFull, - Self::UnderMinimum => LiquidityPoolWithdrawResultCode::UnderMinimum, + Self::Success => RestoreFootprintResultCode::Success, + Self::Malformed => RestoreFootprintResultCode::Malformed, + Self::ResourceLimitExceeded => RestoreFootprintResultCode::ResourceLimitExceeded, + Self::InsufficientRefundableFee => { + RestoreFootprintResultCode::InsufficientRefundableFee + } } } #[must_use] - pub const fn variants() -> [LiquidityPoolWithdrawResultCode; 6] { + pub const fn variants() -> [RestoreFootprintResultCode; 4] { Self::VARIANTS } } -impl Name for LiquidityPoolWithdrawResult { +impl Name for RestoreFootprintResult { #[must_use] fn name(&self) -> &'static str { Self::name(self) } } -impl Discriminant for LiquidityPoolWithdrawResult { +impl Discriminant for RestoreFootprintResult { #[must_use] - fn discriminant(&self) -> LiquidityPoolWithdrawResultCode { + fn discriminant(&self) -> RestoreFootprintResultCode { Self::discriminant(self) } } -impl Variants for LiquidityPoolWithdrawResult { - fn variants() -> slice::Iter<'static, LiquidityPoolWithdrawResultCode> { +impl Variants for RestoreFootprintResult { + fn variants() -> slice::Iter<'static, RestoreFootprintResultCode> { Self::VARIANTS.iter() } } -impl Union for LiquidityPoolWithdrawResult {} +impl Union for RestoreFootprintResult {} -impl ReadXdr for LiquidityPoolWithdrawResult { +impl ReadXdr for RestoreFootprintResult { #[cfg(feature = "std")] fn read_xdr(r: &mut DepthLimitedRead) -> Result { r.with_limited_depth(|r| { - let dv: LiquidityPoolWithdrawResultCode = - ::read_xdr(r)?; + let dv: RestoreFootprintResultCode = + ::read_xdr(r)?; #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)] let v = match dv { - LiquidityPoolWithdrawResultCode::Success => Self::Success, - LiquidityPoolWithdrawResultCode::Malformed => Self::Malformed, - LiquidityPoolWithdrawResultCode::NoTrust => Self::NoTrust, - LiquidityPoolWithdrawResultCode::Underfunded => Self::Underfunded, - LiquidityPoolWithdrawResultCode::LineFull => Self::LineFull, - LiquidityPoolWithdrawResultCode::UnderMinimum => Self::UnderMinimum, + RestoreFootprintResultCode::Success => Self::Success, + RestoreFootprintResultCode::Malformed => Self::Malformed, + RestoreFootprintResultCode::ResourceLimitExceeded => Self::ResourceLimitExceeded, + RestoreFootprintResultCode::InsufficientRefundableFee => { + Self::InsufficientRefundableFee + } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -27717,7 +37487,7 @@ impl ReadXdr for LiquidityPoolWithdrawResult { } } -impl WriteXdr for LiquidityPoolWithdrawResult { +impl WriteXdr for RestoreFootprintResult { #[cfg(feature = "std")] fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { w.with_limited_depth(|w| { @@ -27726,10 +37496,8 @@ impl WriteXdr for LiquidityPoolWithdrawResult { match self { Self::Success => ().write_xdr(w)?, Self::Malformed => ().write_xdr(w)?, - Self::NoTrust => ().write_xdr(w)?, - Self::Underfunded => ().write_xdr(w)?, - Self::LineFull => ().write_xdr(w)?, - Self::UnderMinimum => ().write_xdr(w)?, + Self::ResourceLimitExceeded => ().write_xdr(w)?, + Self::InsufficientRefundableFee => ().write_xdr(w)?, }; Ok(()) }) @@ -27928,6 +37696,12 @@ impl WriteXdr for OperationResultCode { // LiquidityPoolDepositResult liquidityPoolDepositResult; // case LIQUIDITY_POOL_WITHDRAW: // LiquidityPoolWithdrawResult liquidityPoolWithdrawResult; +// case INVOKE_HOST_FUNCTION: +// InvokeHostFunctionResult invokeHostFunctionResult; +// case BUMP_FOOTPRINT_EXPIRATION: +// BumpFootprintExpirationResult bumpFootprintExpirationResult; +// case RESTORE_FOOTPRINT: +// RestoreFootprintResult restoreFootprintResult; // } // // union with discriminant OperationType @@ -27964,10 +37738,13 @@ pub enum OperationResultTr { SetTrustLineFlags(SetTrustLineFlagsResult), LiquidityPoolDeposit(LiquidityPoolDepositResult), LiquidityPoolWithdraw(LiquidityPoolWithdrawResult), + InvokeHostFunction(InvokeHostFunctionResult), + BumpFootprintExpiration(BumpFootprintExpirationResult), + RestoreFootprint(RestoreFootprintResult), } impl OperationResultTr { - pub const VARIANTS: [OperationType; 24] = [ + pub const VARIANTS: [OperationType; 27] = [ OperationType::CreateAccount, OperationType::Payment, OperationType::PathPaymentStrictReceive, @@ -27992,8 +37769,11 @@ impl OperationResultTr { OperationType::SetTrustLineFlags, OperationType::LiquidityPoolDeposit, OperationType::LiquidityPoolWithdraw, + OperationType::InvokeHostFunction, + OperationType::BumpFootprintExpiration, + OperationType::RestoreFootprint, ]; - pub const VARIANTS_STR: [&'static str; 24] = [ + pub const VARIANTS_STR: [&'static str; 27] = [ "CreateAccount", "Payment", "PathPaymentStrictReceive", @@ -28018,6 +37798,9 @@ impl OperationResultTr { "SetTrustLineFlags", "LiquidityPoolDeposit", "LiquidityPoolWithdraw", + "InvokeHostFunction", + "BumpFootprintExpiration", + "RestoreFootprint", ]; #[must_use] @@ -28047,6 +37830,9 @@ impl OperationResultTr { Self::SetTrustLineFlags(_) => "SetTrustLineFlags", Self::LiquidityPoolDeposit(_) => "LiquidityPoolDeposit", Self::LiquidityPoolWithdraw(_) => "LiquidityPoolWithdraw", + Self::InvokeHostFunction(_) => "InvokeHostFunction", + Self::BumpFootprintExpiration(_) => "BumpFootprintExpiration", + Self::RestoreFootprint(_) => "RestoreFootprint", } } @@ -28078,11 +37864,14 @@ impl OperationResultTr { Self::SetTrustLineFlags(_) => OperationType::SetTrustLineFlags, Self::LiquidityPoolDeposit(_) => OperationType::LiquidityPoolDeposit, Self::LiquidityPoolWithdraw(_) => OperationType::LiquidityPoolWithdraw, + Self::InvokeHostFunction(_) => OperationType::InvokeHostFunction, + Self::BumpFootprintExpiration(_) => OperationType::BumpFootprintExpiration, + Self::RestoreFootprint(_) => OperationType::RestoreFootprint, } } #[must_use] - pub const fn variants() -> [OperationType; 24] { + pub const fn variants() -> [OperationType; 27] { Self::VARIANTS } } @@ -28172,6 +37961,15 @@ impl ReadXdr for OperationResultTr { OperationType::LiquidityPoolWithdraw => { Self::LiquidityPoolWithdraw(LiquidityPoolWithdrawResult::read_xdr(r)?) } + OperationType::InvokeHostFunction => { + Self::InvokeHostFunction(InvokeHostFunctionResult::read_xdr(r)?) + } + OperationType::BumpFootprintExpiration => { + Self::BumpFootprintExpiration(BumpFootprintExpirationResult::read_xdr(r)?) + } + OperationType::RestoreFootprint => { + Self::RestoreFootprint(RestoreFootprintResult::read_xdr(r)?) + } #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -28211,6 +38009,9 @@ impl WriteXdr for OperationResultTr { Self::SetTrustLineFlags(v) => v.write_xdr(w)?, Self::LiquidityPoolDeposit(v) => v.write_xdr(w)?, Self::LiquidityPoolWithdraw(v) => v.write_xdr(w)?, + Self::InvokeHostFunction(v) => v.write_xdr(w)?, + Self::BumpFootprintExpiration(v) => v.write_xdr(w)?, + Self::RestoreFootprint(v) => v.write_xdr(w)?, }; Ok(()) }) @@ -28272,6 +38073,12 @@ impl WriteXdr for OperationResultTr { // LiquidityPoolDepositResult liquidityPoolDepositResult; // case LIQUIDITY_POOL_WITHDRAW: // LiquidityPoolWithdrawResult liquidityPoolWithdrawResult; +// case INVOKE_HOST_FUNCTION: +// InvokeHostFunctionResult invokeHostFunctionResult; +// case BUMP_FOOTPRINT_EXPIRATION: +// BumpFootprintExpirationResult bumpFootprintExpirationResult; +// case RESTORE_FOOTPRINT: +// RestoreFootprintResult restoreFootprintResult; // } // tr; // case opBAD_AUTH: @@ -28440,12 +38247,12 @@ impl WriteXdr for OperationResult { // txBAD_AUTH_EXTRA = -10, // unused signatures attached to transaction // txINTERNAL_ERROR = -11, // an unknown error occurred // -// txNOT_SUPPORTED = -12, // transaction type not supported -// txFEE_BUMP_INNER_FAILED = -13, // fee bump inner transaction failed -// txBAD_SPONSORSHIP = -14, // sponsorship not confirmed -// txBAD_MIN_SEQ_AGE_OR_GAP = -// -15, // minSeqAge or minSeqLedgerGap conditions not met -// txMALFORMED = -16 // precondition is invalid +// txNOT_SUPPORTED = -12, // transaction type not supported +// txFEE_BUMP_INNER_FAILED = -13, // fee bump inner transaction failed +// txBAD_SPONSORSHIP = -14, // sponsorship not confirmed +// txBAD_MIN_SEQ_AGE_OR_GAP = -15, // minSeqAge or minSeqLedgerGap conditions not met +// txMALFORMED = -16, // precondition is invalid +// txSOROBAN_INVALID = -17 // soroban-specific preconditions were not met // }; // // enum @@ -28476,10 +38283,11 @@ pub enum TransactionResultCode { TxBadSponsorship = -14, TxBadMinSeqAgeOrGap = -15, TxMalformed = -16, + TxSorobanInvalid = -17, } impl TransactionResultCode { - pub const VARIANTS: [TransactionResultCode; 18] = [ + pub const VARIANTS: [TransactionResultCode; 19] = [ TransactionResultCode::TxFeeBumpInnerSuccess, TransactionResultCode::TxSuccess, TransactionResultCode::TxFailed, @@ -28498,8 +38306,9 @@ impl TransactionResultCode { TransactionResultCode::TxBadSponsorship, TransactionResultCode::TxBadMinSeqAgeOrGap, TransactionResultCode::TxMalformed, + TransactionResultCode::TxSorobanInvalid, ]; - pub const VARIANTS_STR: [&'static str; 18] = [ + pub const VARIANTS_STR: [&'static str; 19] = [ "TxFeeBumpInnerSuccess", "TxSuccess", "TxFailed", @@ -28518,6 +38327,7 @@ impl TransactionResultCode { "TxBadSponsorship", "TxBadMinSeqAgeOrGap", "TxMalformed", + "TxSorobanInvalid", ]; #[must_use] @@ -28541,11 +38351,12 @@ impl TransactionResultCode { Self::TxBadSponsorship => "TxBadSponsorship", Self::TxBadMinSeqAgeOrGap => "TxBadMinSeqAgeOrGap", Self::TxMalformed => "TxMalformed", + Self::TxSorobanInvalid => "TxSorobanInvalid", } } #[must_use] - pub const fn variants() -> [TransactionResultCode; 18] { + pub const fn variants() -> [TransactionResultCode; 19] { Self::VARIANTS } } @@ -28594,6 +38405,7 @@ impl TryFrom for TransactionResultCode { -14 => TransactionResultCode::TxBadSponsorship, -15 => TransactionResultCode::TxBadMinSeqAgeOrGap, -16 => TransactionResultCode::TxMalformed, + -17 => TransactionResultCode::TxSorobanInvalid, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -28652,6 +38464,7 @@ impl WriteXdr for TransactionResultCode { // case txBAD_SPONSORSHIP: // case txBAD_MIN_SEQ_AGE_OR_GAP: // case txMALFORMED: +// case txSOROBAN_INVALID: // void; // } // @@ -28681,10 +38494,11 @@ pub enum InnerTransactionResultResult { TxBadSponsorship, TxBadMinSeqAgeOrGap, TxMalformed, + TxSorobanInvalid, } impl InnerTransactionResultResult { - pub const VARIANTS: [TransactionResultCode; 16] = [ + pub const VARIANTS: [TransactionResultCode; 17] = [ TransactionResultCode::TxSuccess, TransactionResultCode::TxFailed, TransactionResultCode::TxTooEarly, @@ -28701,8 +38515,9 @@ impl InnerTransactionResultResult { TransactionResultCode::TxBadSponsorship, TransactionResultCode::TxBadMinSeqAgeOrGap, TransactionResultCode::TxMalformed, + TransactionResultCode::TxSorobanInvalid, ]; - pub const VARIANTS_STR: [&'static str; 16] = [ + pub const VARIANTS_STR: [&'static str; 17] = [ "TxSuccess", "TxFailed", "TxTooEarly", @@ -28719,6 +38534,7 @@ impl InnerTransactionResultResult { "TxBadSponsorship", "TxBadMinSeqAgeOrGap", "TxMalformed", + "TxSorobanInvalid", ]; #[must_use] @@ -28740,6 +38556,7 @@ impl InnerTransactionResultResult { Self::TxBadSponsorship => "TxBadSponsorship", Self::TxBadMinSeqAgeOrGap => "TxBadMinSeqAgeOrGap", Self::TxMalformed => "TxMalformed", + Self::TxSorobanInvalid => "TxSorobanInvalid", } } @@ -28763,11 +38580,12 @@ impl InnerTransactionResultResult { Self::TxBadSponsorship => TransactionResultCode::TxBadSponsorship, Self::TxBadMinSeqAgeOrGap => TransactionResultCode::TxBadMinSeqAgeOrGap, Self::TxMalformed => TransactionResultCode::TxMalformed, + Self::TxSorobanInvalid => TransactionResultCode::TxSorobanInvalid, } } #[must_use] - pub const fn variants() -> [TransactionResultCode; 16] { + pub const fn variants() -> [TransactionResultCode; 17] { Self::VARIANTS } } @@ -28821,6 +38639,7 @@ impl ReadXdr for InnerTransactionResultResult { TransactionResultCode::TxBadSponsorship => Self::TxBadSponsorship, TransactionResultCode::TxBadMinSeqAgeOrGap => Self::TxBadMinSeqAgeOrGap, TransactionResultCode::TxMalformed => Self::TxMalformed, + TransactionResultCode::TxSorobanInvalid => Self::TxSorobanInvalid, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -28852,6 +38671,7 @@ impl WriteXdr for InnerTransactionResultResult { Self::TxBadSponsorship => ().write_xdr(w)?, Self::TxBadMinSeqAgeOrGap => ().write_xdr(w)?, Self::TxMalformed => ().write_xdr(w)?, + Self::TxSorobanInvalid => ().write_xdr(w)?, }; Ok(()) }) @@ -28984,6 +38804,7 @@ impl WriteXdr for InnerTransactionResultExt { // case txBAD_SPONSORSHIP: // case txBAD_MIN_SEQ_AGE_OR_GAP: // case txMALFORMED: +// case txSOROBAN_INVALID: // void; // } // result; @@ -29103,6 +38924,7 @@ impl WriteXdr for InnerTransactionResultPair { // case txBAD_SPONSORSHIP: // case txBAD_MIN_SEQ_AGE_OR_GAP: // case txMALFORMED: +// case txSOROBAN_INVALID: // void; // } // @@ -29134,10 +38956,11 @@ pub enum TransactionResultResult { TxBadSponsorship, TxBadMinSeqAgeOrGap, TxMalformed, + TxSorobanInvalid, } impl TransactionResultResult { - pub const VARIANTS: [TransactionResultCode; 18] = [ + pub const VARIANTS: [TransactionResultCode; 19] = [ TransactionResultCode::TxFeeBumpInnerSuccess, TransactionResultCode::TxFeeBumpInnerFailed, TransactionResultCode::TxSuccess, @@ -29156,8 +38979,9 @@ impl TransactionResultResult { TransactionResultCode::TxBadSponsorship, TransactionResultCode::TxBadMinSeqAgeOrGap, TransactionResultCode::TxMalformed, + TransactionResultCode::TxSorobanInvalid, ]; - pub const VARIANTS_STR: [&'static str; 18] = [ + pub const VARIANTS_STR: [&'static str; 19] = [ "TxFeeBumpInnerSuccess", "TxFeeBumpInnerFailed", "TxSuccess", @@ -29176,6 +39000,7 @@ impl TransactionResultResult { "TxBadSponsorship", "TxBadMinSeqAgeOrGap", "TxMalformed", + "TxSorobanInvalid", ]; #[must_use] @@ -29199,6 +39024,7 @@ impl TransactionResultResult { Self::TxBadSponsorship => "TxBadSponsorship", Self::TxBadMinSeqAgeOrGap => "TxBadMinSeqAgeOrGap", Self::TxMalformed => "TxMalformed", + Self::TxSorobanInvalid => "TxSorobanInvalid", } } @@ -29224,11 +39050,12 @@ impl TransactionResultResult { Self::TxBadSponsorship => TransactionResultCode::TxBadSponsorship, Self::TxBadMinSeqAgeOrGap => TransactionResultCode::TxBadMinSeqAgeOrGap, Self::TxMalformed => TransactionResultCode::TxMalformed, + Self::TxSorobanInvalid => TransactionResultCode::TxSorobanInvalid, } } #[must_use] - pub const fn variants() -> [TransactionResultCode; 18] { + pub const fn variants() -> [TransactionResultCode; 19] { Self::VARIANTS } } @@ -29288,6 +39115,7 @@ impl ReadXdr for TransactionResultResult { TransactionResultCode::TxBadSponsorship => Self::TxBadSponsorship, TransactionResultCode::TxBadMinSeqAgeOrGap => Self::TxBadMinSeqAgeOrGap, TransactionResultCode::TxMalformed => Self::TxMalformed, + TransactionResultCode::TxSorobanInvalid => Self::TxSorobanInvalid, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; @@ -29321,6 +39149,7 @@ impl WriteXdr for TransactionResultResult { Self::TxBadSponsorship => ().write_xdr(w)?, Self::TxBadMinSeqAgeOrGap => ().write_xdr(w)?, Self::TxMalformed => ().write_xdr(w)?, + Self::TxSorobanInvalid => ().write_xdr(w)?, }; Ok(()) }) @@ -29454,6 +39283,7 @@ impl WriteXdr for TransactionResultExt { // case txBAD_SPONSORSHIP: // case txBAD_MIN_SEQ_AGE_OR_GAP: // case txMALFORMED: +// case txSOROBAN_INVALID: // void; // } // result; @@ -29763,6 +39593,112 @@ pub type Uint64 = u64; // pub type Int64 = i64; +// TimePoint is an XDR Typedef defines as: +// +// typedef uint64 TimePoint; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct TimePoint(pub u64); + +impl From for u64 { + #[must_use] + fn from(x: TimePoint) -> Self { + x.0 + } +} + +impl From for TimePoint { + #[must_use] + fn from(x: u64) -> Self { + TimePoint(x) + } +} + +impl AsRef for TimePoint { + #[must_use] + fn as_ref(&self) -> &u64 { + &self.0 + } +} + +impl ReadXdr for TimePoint { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = u64::read_xdr(r)?; + let v = TimePoint(i); + Ok(v) + }) + } +} + +impl WriteXdr for TimePoint { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + +// Duration is an XDR Typedef defines as: +// +// typedef uint64 Duration; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct Duration(pub u64); + +impl From for u64 { + #[must_use] + fn from(x: Duration) -> Self { + x.0 + } +} + +impl From for Duration { + #[must_use] + fn from(x: u64) -> Self { + Duration(x) + } +} + +impl AsRef for Duration { + #[must_use] + fn as_ref(&self) -> &u64 { + &self.0 + } +} + +impl ReadXdr for Duration { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = u64::read_xdr(r)?; + let v = Duration(i); + Ok(v) + }) + } +} + +impl WriteXdr for Duration { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + // ExtensionPoint is an XDR Union defines as: // // union ExtensionPoint switch (int v) @@ -30758,6 +40694,59 @@ impl WriteXdr for NodeId { } } +// AccountId is an XDR Typedef defines as: +// +// typedef PublicKey AccountID; +// +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug)] +#[cfg_attr( + all(feature = "serde", feature = "alloc"), + derive(serde::Serialize, serde::Deserialize), + serde(rename_all = "snake_case") +)] +pub struct AccountId(pub PublicKey); + +impl From for PublicKey { + #[must_use] + fn from(x: AccountId) -> Self { + x.0 + } +} + +impl From for AccountId { + #[must_use] + fn from(x: PublicKey) -> Self { + AccountId(x) + } +} + +impl AsRef for AccountId { + #[must_use] + fn as_ref(&self) -> &PublicKey { + &self.0 + } +} + +impl ReadXdr for AccountId { + #[cfg(feature = "std")] + fn read_xdr(r: &mut DepthLimitedRead) -> Result { + r.with_limited_depth(|r| { + let i = PublicKey::read_xdr(r)?; + let v = AccountId(i); + Ok(v) + }) + } +} + +impl WriteXdr for AccountId { + #[cfg(feature = "std")] + fn write_xdr(&self, w: &mut DepthLimitedWrite) -> Result<()> { + w.with_limited_depth(|w| self.0.write_xdr(w)) + } +} + // Curve25519Secret is an XDR Struct defines as: // // struct Curve25519Secret @@ -30932,17 +40921,77 @@ pub enum TypeVariant { ScpStatementExternalize, ScpEnvelope, ScpQuorumSet, + ConfigSettingContractExecutionLanesV0, + ConfigSettingContractComputeV0, + ConfigSettingContractLedgerCostV0, + ConfigSettingContractHistoricalDataV0, + ConfigSettingContractEventsV0, + ConfigSettingContractBandwidthV0, + ContractCostType, + ContractCostParamEntry, + StateExpirationSettings, + EvictionIterator, + ContractCostParams, + ConfigSettingId, + ConfigSettingEntry, + ScEnvMetaKind, + ScEnvMetaEntry, + ScMetaV0, + ScMetaKind, + ScMetaEntry, + ScSpecType, + ScSpecTypeOption, + ScSpecTypeResult, + ScSpecTypeVec, + ScSpecTypeMap, + ScSpecTypeTuple, + ScSpecTypeBytesN, + ScSpecTypeUdt, + ScSpecTypeDef, + ScSpecUdtStructFieldV0, + ScSpecUdtStructV0, + ScSpecUdtUnionCaseVoidV0, + ScSpecUdtUnionCaseTupleV0, + ScSpecUdtUnionCaseV0Kind, + ScSpecUdtUnionCaseV0, + ScSpecUdtUnionV0, + ScSpecUdtEnumCaseV0, + ScSpecUdtEnumV0, + ScSpecUdtErrorEnumCaseV0, + ScSpecUdtErrorEnumV0, + ScSpecFunctionInputV0, + ScSpecFunctionV0, + ScSpecEntryKind, + ScSpecEntry, + ScValType, + ScErrorType, + ScErrorCode, + ScError, + UInt128Parts, + Int128Parts, + UInt256Parts, + Int256Parts, + ContractExecutableType, + ContractExecutable, + ScAddressType, + ScAddress, + ScVec, + ScMap, + ScBytes, + ScString, + ScSymbol, + ScNonceKey, + ScContractInstance, + ScVal, + ScMapEntry, StoredTransactionSet, PersistedScpStateV0, PersistedScpStateV1, PersistedScpState, - AccountId, Thresholds, String32, String64, SequenceNumber, - TimePoint, - Duration, DataValue, PoolId, AssetCode4, @@ -30996,6 +41045,10 @@ pub enum TypeVariant { LiquidityPoolEntry, LiquidityPoolEntryBody, LiquidityPoolEntryConstantProduct, + ContractDataDurability, + ContractDataEntry, + ContractCodeEntry, + ExpirationEntry, LedgerEntryExtensionV1, LedgerEntryExtensionV1Ext, LedgerEntry, @@ -31008,6 +41061,10 @@ pub enum TypeVariant { LedgerKeyData, LedgerKeyClaimableBalance, LedgerKeyLiquidityPool, + LedgerKeyContractData, + LedgerKeyContractCode, + LedgerKeyConfigSetting, + LedgerKeyExpiration, EnvelopeType, UpgradeType, StellarValueType, @@ -31020,7 +41077,9 @@ pub enum TypeVariant { LedgerHeader, LedgerHeaderExt, LedgerUpgradeType, + ConfigUpgradeSetKey, LedgerUpgrade, + ConfigUpgradeSet, BucketEntryType, BucketMetadata, BucketMetadataExt, @@ -31049,15 +41108,25 @@ pub enum TypeVariant { OperationMeta, TransactionMetaV1, TransactionMetaV2, + ContractEventType, + ContractEvent, + ContractEventBody, + ContractEventV0, + DiagnosticEvent, + SorobanTransactionMeta, + TransactionMetaV3, + InvokeHostFunctionSuccessPreImage, TransactionMeta, TransactionResultMeta, UpgradeEntryMeta, LedgerCloseMetaV0, LedgerCloseMetaV1, + LedgerCloseMetaV2, LedgerCloseMeta, ErrorCode, SError, SendMore, + SendMoreExtended, AuthCert, Hello, Auth, @@ -31067,6 +41136,7 @@ pub enum TypeVariant { MessageType, DontHave, SurveyMessageCommandType, + SurveyMessageResponseType, SurveyRequestMessage, SignedSurveyRequestMessage, EncryptedBody, @@ -31074,7 +41144,8 @@ pub enum TypeVariant { SignedSurveyResponseMessage, PeerStats, PeerStatList, - TopologyResponseBody, + TopologyResponseBodyV0, + TopologyResponseBodyV1, SurveyResponseBody, TxAdvertVector, FloodAdvert, @@ -31112,11 +41183,30 @@ pub enum TypeVariant { SetTrustLineFlagsOp, LiquidityPoolDepositOp, LiquidityPoolWithdrawOp, + HostFunctionType, + ContractIdPreimageType, + ContractIdPreimage, + ContractIdPreimageFromAddress, + CreateContractArgs, + InvokeContractArgs, + HostFunction, + SorobanAuthorizedFunctionType, + SorobanAuthorizedFunction, + SorobanAuthorizedInvocation, + SorobanAddressCredentials, + SorobanCredentialsType, + SorobanCredentials, + SorobanAuthorizationEntry, + InvokeHostFunctionOp, + BumpFootprintExpirationOp, + RestoreFootprintOp, Operation, OperationBody, HashIdPreimage, HashIdPreimageOperationId, HashIdPreimageRevokeId, + HashIdPreimageContractId, + HashIdPreimageSorobanAuthorization, MemoType, Memo, TimeBounds, @@ -31124,6 +41214,9 @@ pub enum TypeVariant { PreconditionsV2, PreconditionType, Preconditions, + LedgerFootprint, + SorobanResources, + SorobanTransactionData, TransactionV0, TransactionV0Ext, TransactionV0Envelope, @@ -31195,6 +41288,12 @@ pub enum TypeVariant { LiquidityPoolDepositResult, LiquidityPoolWithdrawResultCode, LiquidityPoolWithdrawResult, + InvokeHostFunctionResultCode, + InvokeHostFunctionResult, + BumpFootprintExpirationResultCode, + BumpFootprintExpirationResult, + RestoreFootprintResultCode, + RestoreFootprintResult, OperationResultCode, OperationResult, OperationResultTr, @@ -31212,6 +41311,8 @@ pub enum TypeVariant { Int32, Uint64, Int64, + TimePoint, + Duration, ExtensionPoint, CryptoKeyType, PublicKeyType, @@ -31222,6 +41323,7 @@ pub enum TypeVariant { Signature, SignatureHint, NodeId, + AccountId, Curve25519Secret, Curve25519Public, HmacSha256Key, @@ -31229,7 +41331,7 @@ pub enum TypeVariant { } impl TypeVariant { - pub const VARIANTS: [TypeVariant; 305] = [ + pub const VARIANTS: [TypeVariant; 418] = [ TypeVariant::Value, TypeVariant::ScpBallot, TypeVariant::ScpStatementType, @@ -31241,17 +41343,77 @@ impl TypeVariant { TypeVariant::ScpStatementExternalize, TypeVariant::ScpEnvelope, TypeVariant::ScpQuorumSet, + TypeVariant::ConfigSettingContractExecutionLanesV0, + TypeVariant::ConfigSettingContractComputeV0, + TypeVariant::ConfigSettingContractLedgerCostV0, + TypeVariant::ConfigSettingContractHistoricalDataV0, + TypeVariant::ConfigSettingContractEventsV0, + TypeVariant::ConfigSettingContractBandwidthV0, + TypeVariant::ContractCostType, + TypeVariant::ContractCostParamEntry, + TypeVariant::StateExpirationSettings, + TypeVariant::EvictionIterator, + TypeVariant::ContractCostParams, + TypeVariant::ConfigSettingId, + TypeVariant::ConfigSettingEntry, + TypeVariant::ScEnvMetaKind, + TypeVariant::ScEnvMetaEntry, + TypeVariant::ScMetaV0, + TypeVariant::ScMetaKind, + TypeVariant::ScMetaEntry, + TypeVariant::ScSpecType, + TypeVariant::ScSpecTypeOption, + TypeVariant::ScSpecTypeResult, + TypeVariant::ScSpecTypeVec, + TypeVariant::ScSpecTypeMap, + TypeVariant::ScSpecTypeTuple, + TypeVariant::ScSpecTypeBytesN, + TypeVariant::ScSpecTypeUdt, + TypeVariant::ScSpecTypeDef, + TypeVariant::ScSpecUdtStructFieldV0, + TypeVariant::ScSpecUdtStructV0, + TypeVariant::ScSpecUdtUnionCaseVoidV0, + TypeVariant::ScSpecUdtUnionCaseTupleV0, + TypeVariant::ScSpecUdtUnionCaseV0Kind, + TypeVariant::ScSpecUdtUnionCaseV0, + TypeVariant::ScSpecUdtUnionV0, + TypeVariant::ScSpecUdtEnumCaseV0, + TypeVariant::ScSpecUdtEnumV0, + TypeVariant::ScSpecUdtErrorEnumCaseV0, + TypeVariant::ScSpecUdtErrorEnumV0, + TypeVariant::ScSpecFunctionInputV0, + TypeVariant::ScSpecFunctionV0, + TypeVariant::ScSpecEntryKind, + TypeVariant::ScSpecEntry, + TypeVariant::ScValType, + TypeVariant::ScErrorType, + TypeVariant::ScErrorCode, + TypeVariant::ScError, + TypeVariant::UInt128Parts, + TypeVariant::Int128Parts, + TypeVariant::UInt256Parts, + TypeVariant::Int256Parts, + TypeVariant::ContractExecutableType, + TypeVariant::ContractExecutable, + TypeVariant::ScAddressType, + TypeVariant::ScAddress, + TypeVariant::ScVec, + TypeVariant::ScMap, + TypeVariant::ScBytes, + TypeVariant::ScString, + TypeVariant::ScSymbol, + TypeVariant::ScNonceKey, + TypeVariant::ScContractInstance, + TypeVariant::ScVal, + TypeVariant::ScMapEntry, TypeVariant::StoredTransactionSet, TypeVariant::PersistedScpStateV0, TypeVariant::PersistedScpStateV1, TypeVariant::PersistedScpState, - TypeVariant::AccountId, TypeVariant::Thresholds, TypeVariant::String32, TypeVariant::String64, TypeVariant::SequenceNumber, - TypeVariant::TimePoint, - TypeVariant::Duration, TypeVariant::DataValue, TypeVariant::PoolId, TypeVariant::AssetCode4, @@ -31305,6 +41467,10 @@ impl TypeVariant { TypeVariant::LiquidityPoolEntry, TypeVariant::LiquidityPoolEntryBody, TypeVariant::LiquidityPoolEntryConstantProduct, + TypeVariant::ContractDataDurability, + TypeVariant::ContractDataEntry, + TypeVariant::ContractCodeEntry, + TypeVariant::ExpirationEntry, TypeVariant::LedgerEntryExtensionV1, TypeVariant::LedgerEntryExtensionV1Ext, TypeVariant::LedgerEntry, @@ -31317,6 +41483,10 @@ impl TypeVariant { TypeVariant::LedgerKeyData, TypeVariant::LedgerKeyClaimableBalance, TypeVariant::LedgerKeyLiquidityPool, + TypeVariant::LedgerKeyContractData, + TypeVariant::LedgerKeyContractCode, + TypeVariant::LedgerKeyConfigSetting, + TypeVariant::LedgerKeyExpiration, TypeVariant::EnvelopeType, TypeVariant::UpgradeType, TypeVariant::StellarValueType, @@ -31329,7 +41499,9 @@ impl TypeVariant { TypeVariant::LedgerHeader, TypeVariant::LedgerHeaderExt, TypeVariant::LedgerUpgradeType, + TypeVariant::ConfigUpgradeSetKey, TypeVariant::LedgerUpgrade, + TypeVariant::ConfigUpgradeSet, TypeVariant::BucketEntryType, TypeVariant::BucketMetadata, TypeVariant::BucketMetadataExt, @@ -31358,15 +41530,25 @@ impl TypeVariant { TypeVariant::OperationMeta, TypeVariant::TransactionMetaV1, TypeVariant::TransactionMetaV2, + TypeVariant::ContractEventType, + TypeVariant::ContractEvent, + TypeVariant::ContractEventBody, + TypeVariant::ContractEventV0, + TypeVariant::DiagnosticEvent, + TypeVariant::SorobanTransactionMeta, + TypeVariant::TransactionMetaV3, + TypeVariant::InvokeHostFunctionSuccessPreImage, TypeVariant::TransactionMeta, TypeVariant::TransactionResultMeta, TypeVariant::UpgradeEntryMeta, TypeVariant::LedgerCloseMetaV0, TypeVariant::LedgerCloseMetaV1, + TypeVariant::LedgerCloseMetaV2, TypeVariant::LedgerCloseMeta, TypeVariant::ErrorCode, TypeVariant::SError, TypeVariant::SendMore, + TypeVariant::SendMoreExtended, TypeVariant::AuthCert, TypeVariant::Hello, TypeVariant::Auth, @@ -31376,6 +41558,7 @@ impl TypeVariant { TypeVariant::MessageType, TypeVariant::DontHave, TypeVariant::SurveyMessageCommandType, + TypeVariant::SurveyMessageResponseType, TypeVariant::SurveyRequestMessage, TypeVariant::SignedSurveyRequestMessage, TypeVariant::EncryptedBody, @@ -31383,7 +41566,8 @@ impl TypeVariant { TypeVariant::SignedSurveyResponseMessage, TypeVariant::PeerStats, TypeVariant::PeerStatList, - TypeVariant::TopologyResponseBody, + TypeVariant::TopologyResponseBodyV0, + TypeVariant::TopologyResponseBodyV1, TypeVariant::SurveyResponseBody, TypeVariant::TxAdvertVector, TypeVariant::FloodAdvert, @@ -31421,11 +41605,30 @@ impl TypeVariant { TypeVariant::SetTrustLineFlagsOp, TypeVariant::LiquidityPoolDepositOp, TypeVariant::LiquidityPoolWithdrawOp, + TypeVariant::HostFunctionType, + TypeVariant::ContractIdPreimageType, + TypeVariant::ContractIdPreimage, + TypeVariant::ContractIdPreimageFromAddress, + TypeVariant::CreateContractArgs, + TypeVariant::InvokeContractArgs, + TypeVariant::HostFunction, + TypeVariant::SorobanAuthorizedFunctionType, + TypeVariant::SorobanAuthorizedFunction, + TypeVariant::SorobanAuthorizedInvocation, + TypeVariant::SorobanAddressCredentials, + TypeVariant::SorobanCredentialsType, + TypeVariant::SorobanCredentials, + TypeVariant::SorobanAuthorizationEntry, + TypeVariant::InvokeHostFunctionOp, + TypeVariant::BumpFootprintExpirationOp, + TypeVariant::RestoreFootprintOp, TypeVariant::Operation, TypeVariant::OperationBody, TypeVariant::HashIdPreimage, TypeVariant::HashIdPreimageOperationId, TypeVariant::HashIdPreimageRevokeId, + TypeVariant::HashIdPreimageContractId, + TypeVariant::HashIdPreimageSorobanAuthorization, TypeVariant::MemoType, TypeVariant::Memo, TypeVariant::TimeBounds, @@ -31433,6 +41636,9 @@ impl TypeVariant { TypeVariant::PreconditionsV2, TypeVariant::PreconditionType, TypeVariant::Preconditions, + TypeVariant::LedgerFootprint, + TypeVariant::SorobanResources, + TypeVariant::SorobanTransactionData, TypeVariant::TransactionV0, TypeVariant::TransactionV0Ext, TypeVariant::TransactionV0Envelope, @@ -31504,6 +41710,12 @@ impl TypeVariant { TypeVariant::LiquidityPoolDepositResult, TypeVariant::LiquidityPoolWithdrawResultCode, TypeVariant::LiquidityPoolWithdrawResult, + TypeVariant::InvokeHostFunctionResultCode, + TypeVariant::InvokeHostFunctionResult, + TypeVariant::BumpFootprintExpirationResultCode, + TypeVariant::BumpFootprintExpirationResult, + TypeVariant::RestoreFootprintResultCode, + TypeVariant::RestoreFootprintResult, TypeVariant::OperationResultCode, TypeVariant::OperationResult, TypeVariant::OperationResultTr, @@ -31521,6 +41733,8 @@ impl TypeVariant { TypeVariant::Int32, TypeVariant::Uint64, TypeVariant::Int64, + TypeVariant::TimePoint, + TypeVariant::Duration, TypeVariant::ExtensionPoint, TypeVariant::CryptoKeyType, TypeVariant::PublicKeyType, @@ -31531,12 +41745,13 @@ impl TypeVariant { TypeVariant::Signature, TypeVariant::SignatureHint, TypeVariant::NodeId, + TypeVariant::AccountId, TypeVariant::Curve25519Secret, TypeVariant::Curve25519Public, TypeVariant::HmacSha256Key, TypeVariant::HmacSha256Mac, ]; - pub const VARIANTS_STR: [&'static str; 305] = [ + pub const VARIANTS_STR: [&'static str; 418] = [ "Value", "ScpBallot", "ScpStatementType", @@ -31548,17 +41763,77 @@ impl TypeVariant { "ScpStatementExternalize", "ScpEnvelope", "ScpQuorumSet", + "ConfigSettingContractExecutionLanesV0", + "ConfigSettingContractComputeV0", + "ConfigSettingContractLedgerCostV0", + "ConfigSettingContractHistoricalDataV0", + "ConfigSettingContractEventsV0", + "ConfigSettingContractBandwidthV0", + "ContractCostType", + "ContractCostParamEntry", + "StateExpirationSettings", + "EvictionIterator", + "ContractCostParams", + "ConfigSettingId", + "ConfigSettingEntry", + "ScEnvMetaKind", + "ScEnvMetaEntry", + "ScMetaV0", + "ScMetaKind", + "ScMetaEntry", + "ScSpecType", + "ScSpecTypeOption", + "ScSpecTypeResult", + "ScSpecTypeVec", + "ScSpecTypeMap", + "ScSpecTypeTuple", + "ScSpecTypeBytesN", + "ScSpecTypeUdt", + "ScSpecTypeDef", + "ScSpecUdtStructFieldV0", + "ScSpecUdtStructV0", + "ScSpecUdtUnionCaseVoidV0", + "ScSpecUdtUnionCaseTupleV0", + "ScSpecUdtUnionCaseV0Kind", + "ScSpecUdtUnionCaseV0", + "ScSpecUdtUnionV0", + "ScSpecUdtEnumCaseV0", + "ScSpecUdtEnumV0", + "ScSpecUdtErrorEnumCaseV0", + "ScSpecUdtErrorEnumV0", + "ScSpecFunctionInputV0", + "ScSpecFunctionV0", + "ScSpecEntryKind", + "ScSpecEntry", + "ScValType", + "ScErrorType", + "ScErrorCode", + "ScError", + "UInt128Parts", + "Int128Parts", + "UInt256Parts", + "Int256Parts", + "ContractExecutableType", + "ContractExecutable", + "ScAddressType", + "ScAddress", + "ScVec", + "ScMap", + "ScBytes", + "ScString", + "ScSymbol", + "ScNonceKey", + "ScContractInstance", + "ScVal", + "ScMapEntry", "StoredTransactionSet", "PersistedScpStateV0", "PersistedScpStateV1", "PersistedScpState", - "AccountId", "Thresholds", "String32", "String64", "SequenceNumber", - "TimePoint", - "Duration", "DataValue", "PoolId", "AssetCode4", @@ -31612,6 +41887,10 @@ impl TypeVariant { "LiquidityPoolEntry", "LiquidityPoolEntryBody", "LiquidityPoolEntryConstantProduct", + "ContractDataDurability", + "ContractDataEntry", + "ContractCodeEntry", + "ExpirationEntry", "LedgerEntryExtensionV1", "LedgerEntryExtensionV1Ext", "LedgerEntry", @@ -31624,6 +41903,10 @@ impl TypeVariant { "LedgerKeyData", "LedgerKeyClaimableBalance", "LedgerKeyLiquidityPool", + "LedgerKeyContractData", + "LedgerKeyContractCode", + "LedgerKeyConfigSetting", + "LedgerKeyExpiration", "EnvelopeType", "UpgradeType", "StellarValueType", @@ -31636,7 +41919,9 @@ impl TypeVariant { "LedgerHeader", "LedgerHeaderExt", "LedgerUpgradeType", + "ConfigUpgradeSetKey", "LedgerUpgrade", + "ConfigUpgradeSet", "BucketEntryType", "BucketMetadata", "BucketMetadataExt", @@ -31665,15 +41950,25 @@ impl TypeVariant { "OperationMeta", "TransactionMetaV1", "TransactionMetaV2", + "ContractEventType", + "ContractEvent", + "ContractEventBody", + "ContractEventV0", + "DiagnosticEvent", + "SorobanTransactionMeta", + "TransactionMetaV3", + "InvokeHostFunctionSuccessPreImage", "TransactionMeta", "TransactionResultMeta", "UpgradeEntryMeta", "LedgerCloseMetaV0", "LedgerCloseMetaV1", + "LedgerCloseMetaV2", "LedgerCloseMeta", "ErrorCode", "SError", "SendMore", + "SendMoreExtended", "AuthCert", "Hello", "Auth", @@ -31683,6 +41978,7 @@ impl TypeVariant { "MessageType", "DontHave", "SurveyMessageCommandType", + "SurveyMessageResponseType", "SurveyRequestMessage", "SignedSurveyRequestMessage", "EncryptedBody", @@ -31690,7 +41986,8 @@ impl TypeVariant { "SignedSurveyResponseMessage", "PeerStats", "PeerStatList", - "TopologyResponseBody", + "TopologyResponseBodyV0", + "TopologyResponseBodyV1", "SurveyResponseBody", "TxAdvertVector", "FloodAdvert", @@ -31728,11 +42025,30 @@ impl TypeVariant { "SetTrustLineFlagsOp", "LiquidityPoolDepositOp", "LiquidityPoolWithdrawOp", + "HostFunctionType", + "ContractIdPreimageType", + "ContractIdPreimage", + "ContractIdPreimageFromAddress", + "CreateContractArgs", + "InvokeContractArgs", + "HostFunction", + "SorobanAuthorizedFunctionType", + "SorobanAuthorizedFunction", + "SorobanAuthorizedInvocation", + "SorobanAddressCredentials", + "SorobanCredentialsType", + "SorobanCredentials", + "SorobanAuthorizationEntry", + "InvokeHostFunctionOp", + "BumpFootprintExpirationOp", + "RestoreFootprintOp", "Operation", "OperationBody", "HashIdPreimage", "HashIdPreimageOperationId", "HashIdPreimageRevokeId", + "HashIdPreimageContractId", + "HashIdPreimageSorobanAuthorization", "MemoType", "Memo", "TimeBounds", @@ -31740,6 +42056,9 @@ impl TypeVariant { "PreconditionsV2", "PreconditionType", "Preconditions", + "LedgerFootprint", + "SorobanResources", + "SorobanTransactionData", "TransactionV0", "TransactionV0Ext", "TransactionV0Envelope", @@ -31811,6 +42130,12 @@ impl TypeVariant { "LiquidityPoolDepositResult", "LiquidityPoolWithdrawResultCode", "LiquidityPoolWithdrawResult", + "InvokeHostFunctionResultCode", + "InvokeHostFunctionResult", + "BumpFootprintExpirationResultCode", + "BumpFootprintExpirationResult", + "RestoreFootprintResultCode", + "RestoreFootprintResult", "OperationResultCode", "OperationResult", "OperationResultTr", @@ -31828,6 +42153,8 @@ impl TypeVariant { "Int32", "Uint64", "Int64", + "TimePoint", + "Duration", "ExtensionPoint", "CryptoKeyType", "PublicKeyType", @@ -31838,6 +42165,7 @@ impl TypeVariant { "Signature", "SignatureHint", "NodeId", + "AccountId", "Curve25519Secret", "Curve25519Public", "HmacSha256Key", @@ -31859,17 +42187,77 @@ impl TypeVariant { Self::ScpStatementExternalize => "ScpStatementExternalize", Self::ScpEnvelope => "ScpEnvelope", Self::ScpQuorumSet => "ScpQuorumSet", + Self::ConfigSettingContractExecutionLanesV0 => "ConfigSettingContractExecutionLanesV0", + Self::ConfigSettingContractComputeV0 => "ConfigSettingContractComputeV0", + Self::ConfigSettingContractLedgerCostV0 => "ConfigSettingContractLedgerCostV0", + Self::ConfigSettingContractHistoricalDataV0 => "ConfigSettingContractHistoricalDataV0", + Self::ConfigSettingContractEventsV0 => "ConfigSettingContractEventsV0", + Self::ConfigSettingContractBandwidthV0 => "ConfigSettingContractBandwidthV0", + Self::ContractCostType => "ContractCostType", + Self::ContractCostParamEntry => "ContractCostParamEntry", + Self::StateExpirationSettings => "StateExpirationSettings", + Self::EvictionIterator => "EvictionIterator", + Self::ContractCostParams => "ContractCostParams", + Self::ConfigSettingId => "ConfigSettingId", + Self::ConfigSettingEntry => "ConfigSettingEntry", + Self::ScEnvMetaKind => "ScEnvMetaKind", + Self::ScEnvMetaEntry => "ScEnvMetaEntry", + Self::ScMetaV0 => "ScMetaV0", + Self::ScMetaKind => "ScMetaKind", + Self::ScMetaEntry => "ScMetaEntry", + Self::ScSpecType => "ScSpecType", + Self::ScSpecTypeOption => "ScSpecTypeOption", + Self::ScSpecTypeResult => "ScSpecTypeResult", + Self::ScSpecTypeVec => "ScSpecTypeVec", + Self::ScSpecTypeMap => "ScSpecTypeMap", + Self::ScSpecTypeTuple => "ScSpecTypeTuple", + Self::ScSpecTypeBytesN => "ScSpecTypeBytesN", + Self::ScSpecTypeUdt => "ScSpecTypeUdt", + Self::ScSpecTypeDef => "ScSpecTypeDef", + Self::ScSpecUdtStructFieldV0 => "ScSpecUdtStructFieldV0", + Self::ScSpecUdtStructV0 => "ScSpecUdtStructV0", + Self::ScSpecUdtUnionCaseVoidV0 => "ScSpecUdtUnionCaseVoidV0", + Self::ScSpecUdtUnionCaseTupleV0 => "ScSpecUdtUnionCaseTupleV0", + Self::ScSpecUdtUnionCaseV0Kind => "ScSpecUdtUnionCaseV0Kind", + Self::ScSpecUdtUnionCaseV0 => "ScSpecUdtUnionCaseV0", + Self::ScSpecUdtUnionV0 => "ScSpecUdtUnionV0", + Self::ScSpecUdtEnumCaseV0 => "ScSpecUdtEnumCaseV0", + Self::ScSpecUdtEnumV0 => "ScSpecUdtEnumV0", + Self::ScSpecUdtErrorEnumCaseV0 => "ScSpecUdtErrorEnumCaseV0", + Self::ScSpecUdtErrorEnumV0 => "ScSpecUdtErrorEnumV0", + Self::ScSpecFunctionInputV0 => "ScSpecFunctionInputV0", + Self::ScSpecFunctionV0 => "ScSpecFunctionV0", + Self::ScSpecEntryKind => "ScSpecEntryKind", + Self::ScSpecEntry => "ScSpecEntry", + Self::ScValType => "ScValType", + Self::ScErrorType => "ScErrorType", + Self::ScErrorCode => "ScErrorCode", + Self::ScError => "ScError", + Self::UInt128Parts => "UInt128Parts", + Self::Int128Parts => "Int128Parts", + Self::UInt256Parts => "UInt256Parts", + Self::Int256Parts => "Int256Parts", + Self::ContractExecutableType => "ContractExecutableType", + Self::ContractExecutable => "ContractExecutable", + Self::ScAddressType => "ScAddressType", + Self::ScAddress => "ScAddress", + Self::ScVec => "ScVec", + Self::ScMap => "ScMap", + Self::ScBytes => "ScBytes", + Self::ScString => "ScString", + Self::ScSymbol => "ScSymbol", + Self::ScNonceKey => "ScNonceKey", + Self::ScContractInstance => "ScContractInstance", + Self::ScVal => "ScVal", + Self::ScMapEntry => "ScMapEntry", Self::StoredTransactionSet => "StoredTransactionSet", Self::PersistedScpStateV0 => "PersistedScpStateV0", Self::PersistedScpStateV1 => "PersistedScpStateV1", Self::PersistedScpState => "PersistedScpState", - Self::AccountId => "AccountId", Self::Thresholds => "Thresholds", Self::String32 => "String32", Self::String64 => "String64", Self::SequenceNumber => "SequenceNumber", - Self::TimePoint => "TimePoint", - Self::Duration => "Duration", Self::DataValue => "DataValue", Self::PoolId => "PoolId", Self::AssetCode4 => "AssetCode4", @@ -31925,6 +42313,10 @@ impl TypeVariant { Self::LiquidityPoolEntry => "LiquidityPoolEntry", Self::LiquidityPoolEntryBody => "LiquidityPoolEntryBody", Self::LiquidityPoolEntryConstantProduct => "LiquidityPoolEntryConstantProduct", + Self::ContractDataDurability => "ContractDataDurability", + Self::ContractDataEntry => "ContractDataEntry", + Self::ContractCodeEntry => "ContractCodeEntry", + Self::ExpirationEntry => "ExpirationEntry", Self::LedgerEntryExtensionV1 => "LedgerEntryExtensionV1", Self::LedgerEntryExtensionV1Ext => "LedgerEntryExtensionV1Ext", Self::LedgerEntry => "LedgerEntry", @@ -31937,6 +42329,10 @@ impl TypeVariant { Self::LedgerKeyData => "LedgerKeyData", Self::LedgerKeyClaimableBalance => "LedgerKeyClaimableBalance", Self::LedgerKeyLiquidityPool => "LedgerKeyLiquidityPool", + Self::LedgerKeyContractData => "LedgerKeyContractData", + Self::LedgerKeyContractCode => "LedgerKeyContractCode", + Self::LedgerKeyConfigSetting => "LedgerKeyConfigSetting", + Self::LedgerKeyExpiration => "LedgerKeyExpiration", Self::EnvelopeType => "EnvelopeType", Self::UpgradeType => "UpgradeType", Self::StellarValueType => "StellarValueType", @@ -31949,7 +42345,9 @@ impl TypeVariant { Self::LedgerHeader => "LedgerHeader", Self::LedgerHeaderExt => "LedgerHeaderExt", Self::LedgerUpgradeType => "LedgerUpgradeType", + Self::ConfigUpgradeSetKey => "ConfigUpgradeSetKey", Self::LedgerUpgrade => "LedgerUpgrade", + Self::ConfigUpgradeSet => "ConfigUpgradeSet", Self::BucketEntryType => "BucketEntryType", Self::BucketMetadata => "BucketMetadata", Self::BucketMetadataExt => "BucketMetadataExt", @@ -31978,15 +42376,25 @@ impl TypeVariant { Self::OperationMeta => "OperationMeta", Self::TransactionMetaV1 => "TransactionMetaV1", Self::TransactionMetaV2 => "TransactionMetaV2", + Self::ContractEventType => "ContractEventType", + Self::ContractEvent => "ContractEvent", + Self::ContractEventBody => "ContractEventBody", + Self::ContractEventV0 => "ContractEventV0", + Self::DiagnosticEvent => "DiagnosticEvent", + Self::SorobanTransactionMeta => "SorobanTransactionMeta", + Self::TransactionMetaV3 => "TransactionMetaV3", + Self::InvokeHostFunctionSuccessPreImage => "InvokeHostFunctionSuccessPreImage", Self::TransactionMeta => "TransactionMeta", Self::TransactionResultMeta => "TransactionResultMeta", Self::UpgradeEntryMeta => "UpgradeEntryMeta", Self::LedgerCloseMetaV0 => "LedgerCloseMetaV0", Self::LedgerCloseMetaV1 => "LedgerCloseMetaV1", + Self::LedgerCloseMetaV2 => "LedgerCloseMetaV2", Self::LedgerCloseMeta => "LedgerCloseMeta", Self::ErrorCode => "ErrorCode", Self::SError => "SError", Self::SendMore => "SendMore", + Self::SendMoreExtended => "SendMoreExtended", Self::AuthCert => "AuthCert", Self::Hello => "Hello", Self::Auth => "Auth", @@ -31996,6 +42404,7 @@ impl TypeVariant { Self::MessageType => "MessageType", Self::DontHave => "DontHave", Self::SurveyMessageCommandType => "SurveyMessageCommandType", + Self::SurveyMessageResponseType => "SurveyMessageResponseType", Self::SurveyRequestMessage => "SurveyRequestMessage", Self::SignedSurveyRequestMessage => "SignedSurveyRequestMessage", Self::EncryptedBody => "EncryptedBody", @@ -32003,7 +42412,8 @@ impl TypeVariant { Self::SignedSurveyResponseMessage => "SignedSurveyResponseMessage", Self::PeerStats => "PeerStats", Self::PeerStatList => "PeerStatList", - Self::TopologyResponseBody => "TopologyResponseBody", + Self::TopologyResponseBodyV0 => "TopologyResponseBodyV0", + Self::TopologyResponseBodyV1 => "TopologyResponseBodyV1", Self::SurveyResponseBody => "SurveyResponseBody", Self::TxAdvertVector => "TxAdvertVector", Self::FloodAdvert => "FloodAdvert", @@ -32041,11 +42451,30 @@ impl TypeVariant { Self::SetTrustLineFlagsOp => "SetTrustLineFlagsOp", Self::LiquidityPoolDepositOp => "LiquidityPoolDepositOp", Self::LiquidityPoolWithdrawOp => "LiquidityPoolWithdrawOp", + Self::HostFunctionType => "HostFunctionType", + Self::ContractIdPreimageType => "ContractIdPreimageType", + Self::ContractIdPreimage => "ContractIdPreimage", + Self::ContractIdPreimageFromAddress => "ContractIdPreimageFromAddress", + Self::CreateContractArgs => "CreateContractArgs", + Self::InvokeContractArgs => "InvokeContractArgs", + Self::HostFunction => "HostFunction", + Self::SorobanAuthorizedFunctionType => "SorobanAuthorizedFunctionType", + Self::SorobanAuthorizedFunction => "SorobanAuthorizedFunction", + Self::SorobanAuthorizedInvocation => "SorobanAuthorizedInvocation", + Self::SorobanAddressCredentials => "SorobanAddressCredentials", + Self::SorobanCredentialsType => "SorobanCredentialsType", + Self::SorobanCredentials => "SorobanCredentials", + Self::SorobanAuthorizationEntry => "SorobanAuthorizationEntry", + Self::InvokeHostFunctionOp => "InvokeHostFunctionOp", + Self::BumpFootprintExpirationOp => "BumpFootprintExpirationOp", + Self::RestoreFootprintOp => "RestoreFootprintOp", Self::Operation => "Operation", Self::OperationBody => "OperationBody", Self::HashIdPreimage => "HashIdPreimage", Self::HashIdPreimageOperationId => "HashIdPreimageOperationId", Self::HashIdPreimageRevokeId => "HashIdPreimageRevokeId", + Self::HashIdPreimageContractId => "HashIdPreimageContractId", + Self::HashIdPreimageSorobanAuthorization => "HashIdPreimageSorobanAuthorization", Self::MemoType => "MemoType", Self::Memo => "Memo", Self::TimeBounds => "TimeBounds", @@ -32053,6 +42482,9 @@ impl TypeVariant { Self::PreconditionsV2 => "PreconditionsV2", Self::PreconditionType => "PreconditionType", Self::Preconditions => "Preconditions", + Self::LedgerFootprint => "LedgerFootprint", + Self::SorobanResources => "SorobanResources", + Self::SorobanTransactionData => "SorobanTransactionData", Self::TransactionV0 => "TransactionV0", Self::TransactionV0Ext => "TransactionV0Ext", Self::TransactionV0Envelope => "TransactionV0Envelope", @@ -32128,6 +42560,12 @@ impl TypeVariant { Self::LiquidityPoolDepositResult => "LiquidityPoolDepositResult", Self::LiquidityPoolWithdrawResultCode => "LiquidityPoolWithdrawResultCode", Self::LiquidityPoolWithdrawResult => "LiquidityPoolWithdrawResult", + Self::InvokeHostFunctionResultCode => "InvokeHostFunctionResultCode", + Self::InvokeHostFunctionResult => "InvokeHostFunctionResult", + Self::BumpFootprintExpirationResultCode => "BumpFootprintExpirationResultCode", + Self::BumpFootprintExpirationResult => "BumpFootprintExpirationResult", + Self::RestoreFootprintResultCode => "RestoreFootprintResultCode", + Self::RestoreFootprintResult => "RestoreFootprintResult", Self::OperationResultCode => "OperationResultCode", Self::OperationResult => "OperationResult", Self::OperationResultTr => "OperationResultTr", @@ -32145,6 +42583,8 @@ impl TypeVariant { Self::Int32 => "Int32", Self::Uint64 => "Uint64", Self::Int64 => "Int64", + Self::TimePoint => "TimePoint", + Self::Duration => "Duration", Self::ExtensionPoint => "ExtensionPoint", Self::CryptoKeyType => "CryptoKeyType", Self::PublicKeyType => "PublicKeyType", @@ -32155,6 +42595,7 @@ impl TypeVariant { Self::Signature => "Signature", Self::SignatureHint => "SignatureHint", Self::NodeId => "NodeId", + Self::AccountId => "AccountId", Self::Curve25519Secret => "Curve25519Secret", Self::Curve25519Public => "Curve25519Public", Self::HmacSha256Key => "HmacSha256Key", @@ -32164,7 +42605,7 @@ impl TypeVariant { #[must_use] #[allow(clippy::too_many_lines)] - pub const fn variants() -> [TypeVariant; 305] { + pub const fn variants() -> [TypeVariant; 418] { Self::VARIANTS } } @@ -32198,17 +42639,81 @@ impl core::str::FromStr for TypeVariant { "ScpStatementExternalize" => Ok(Self::ScpStatementExternalize), "ScpEnvelope" => Ok(Self::ScpEnvelope), "ScpQuorumSet" => Ok(Self::ScpQuorumSet), + "ConfigSettingContractExecutionLanesV0" => { + Ok(Self::ConfigSettingContractExecutionLanesV0) + } + "ConfigSettingContractComputeV0" => Ok(Self::ConfigSettingContractComputeV0), + "ConfigSettingContractLedgerCostV0" => Ok(Self::ConfigSettingContractLedgerCostV0), + "ConfigSettingContractHistoricalDataV0" => { + Ok(Self::ConfigSettingContractHistoricalDataV0) + } + "ConfigSettingContractEventsV0" => Ok(Self::ConfigSettingContractEventsV0), + "ConfigSettingContractBandwidthV0" => Ok(Self::ConfigSettingContractBandwidthV0), + "ContractCostType" => Ok(Self::ContractCostType), + "ContractCostParamEntry" => Ok(Self::ContractCostParamEntry), + "StateExpirationSettings" => Ok(Self::StateExpirationSettings), + "EvictionIterator" => Ok(Self::EvictionIterator), + "ContractCostParams" => Ok(Self::ContractCostParams), + "ConfigSettingId" => Ok(Self::ConfigSettingId), + "ConfigSettingEntry" => Ok(Self::ConfigSettingEntry), + "ScEnvMetaKind" => Ok(Self::ScEnvMetaKind), + "ScEnvMetaEntry" => Ok(Self::ScEnvMetaEntry), + "ScMetaV0" => Ok(Self::ScMetaV0), + "ScMetaKind" => Ok(Self::ScMetaKind), + "ScMetaEntry" => Ok(Self::ScMetaEntry), + "ScSpecType" => Ok(Self::ScSpecType), + "ScSpecTypeOption" => Ok(Self::ScSpecTypeOption), + "ScSpecTypeResult" => Ok(Self::ScSpecTypeResult), + "ScSpecTypeVec" => Ok(Self::ScSpecTypeVec), + "ScSpecTypeMap" => Ok(Self::ScSpecTypeMap), + "ScSpecTypeTuple" => Ok(Self::ScSpecTypeTuple), + "ScSpecTypeBytesN" => Ok(Self::ScSpecTypeBytesN), + "ScSpecTypeUdt" => Ok(Self::ScSpecTypeUdt), + "ScSpecTypeDef" => Ok(Self::ScSpecTypeDef), + "ScSpecUdtStructFieldV0" => Ok(Self::ScSpecUdtStructFieldV0), + "ScSpecUdtStructV0" => Ok(Self::ScSpecUdtStructV0), + "ScSpecUdtUnionCaseVoidV0" => Ok(Self::ScSpecUdtUnionCaseVoidV0), + "ScSpecUdtUnionCaseTupleV0" => Ok(Self::ScSpecUdtUnionCaseTupleV0), + "ScSpecUdtUnionCaseV0Kind" => Ok(Self::ScSpecUdtUnionCaseV0Kind), + "ScSpecUdtUnionCaseV0" => Ok(Self::ScSpecUdtUnionCaseV0), + "ScSpecUdtUnionV0" => Ok(Self::ScSpecUdtUnionV0), + "ScSpecUdtEnumCaseV0" => Ok(Self::ScSpecUdtEnumCaseV0), + "ScSpecUdtEnumV0" => Ok(Self::ScSpecUdtEnumV0), + "ScSpecUdtErrorEnumCaseV0" => Ok(Self::ScSpecUdtErrorEnumCaseV0), + "ScSpecUdtErrorEnumV0" => Ok(Self::ScSpecUdtErrorEnumV0), + "ScSpecFunctionInputV0" => Ok(Self::ScSpecFunctionInputV0), + "ScSpecFunctionV0" => Ok(Self::ScSpecFunctionV0), + "ScSpecEntryKind" => Ok(Self::ScSpecEntryKind), + "ScSpecEntry" => Ok(Self::ScSpecEntry), + "ScValType" => Ok(Self::ScValType), + "ScErrorType" => Ok(Self::ScErrorType), + "ScErrorCode" => Ok(Self::ScErrorCode), + "ScError" => Ok(Self::ScError), + "UInt128Parts" => Ok(Self::UInt128Parts), + "Int128Parts" => Ok(Self::Int128Parts), + "UInt256Parts" => Ok(Self::UInt256Parts), + "Int256Parts" => Ok(Self::Int256Parts), + "ContractExecutableType" => Ok(Self::ContractExecutableType), + "ContractExecutable" => Ok(Self::ContractExecutable), + "ScAddressType" => Ok(Self::ScAddressType), + "ScAddress" => Ok(Self::ScAddress), + "ScVec" => Ok(Self::ScVec), + "ScMap" => Ok(Self::ScMap), + "ScBytes" => Ok(Self::ScBytes), + "ScString" => Ok(Self::ScString), + "ScSymbol" => Ok(Self::ScSymbol), + "ScNonceKey" => Ok(Self::ScNonceKey), + "ScContractInstance" => Ok(Self::ScContractInstance), + "ScVal" => Ok(Self::ScVal), + "ScMapEntry" => Ok(Self::ScMapEntry), "StoredTransactionSet" => Ok(Self::StoredTransactionSet), "PersistedScpStateV0" => Ok(Self::PersistedScpStateV0), "PersistedScpStateV1" => Ok(Self::PersistedScpStateV1), "PersistedScpState" => Ok(Self::PersistedScpState), - "AccountId" => Ok(Self::AccountId), "Thresholds" => Ok(Self::Thresholds), "String32" => Ok(Self::String32), "String64" => Ok(Self::String64), "SequenceNumber" => Ok(Self::SequenceNumber), - "TimePoint" => Ok(Self::TimePoint), - "Duration" => Ok(Self::Duration), "DataValue" => Ok(Self::DataValue), "PoolId" => Ok(Self::PoolId), "AssetCode4" => Ok(Self::AssetCode4), @@ -32264,6 +42769,10 @@ impl core::str::FromStr for TypeVariant { "LiquidityPoolEntry" => Ok(Self::LiquidityPoolEntry), "LiquidityPoolEntryBody" => Ok(Self::LiquidityPoolEntryBody), "LiquidityPoolEntryConstantProduct" => Ok(Self::LiquidityPoolEntryConstantProduct), + "ContractDataDurability" => Ok(Self::ContractDataDurability), + "ContractDataEntry" => Ok(Self::ContractDataEntry), + "ContractCodeEntry" => Ok(Self::ContractCodeEntry), + "ExpirationEntry" => Ok(Self::ExpirationEntry), "LedgerEntryExtensionV1" => Ok(Self::LedgerEntryExtensionV1), "LedgerEntryExtensionV1Ext" => Ok(Self::LedgerEntryExtensionV1Ext), "LedgerEntry" => Ok(Self::LedgerEntry), @@ -32276,6 +42785,10 @@ impl core::str::FromStr for TypeVariant { "LedgerKeyData" => Ok(Self::LedgerKeyData), "LedgerKeyClaimableBalance" => Ok(Self::LedgerKeyClaimableBalance), "LedgerKeyLiquidityPool" => Ok(Self::LedgerKeyLiquidityPool), + "LedgerKeyContractData" => Ok(Self::LedgerKeyContractData), + "LedgerKeyContractCode" => Ok(Self::LedgerKeyContractCode), + "LedgerKeyConfigSetting" => Ok(Self::LedgerKeyConfigSetting), + "LedgerKeyExpiration" => Ok(Self::LedgerKeyExpiration), "EnvelopeType" => Ok(Self::EnvelopeType), "UpgradeType" => Ok(Self::UpgradeType), "StellarValueType" => Ok(Self::StellarValueType), @@ -32288,7 +42801,9 @@ impl core::str::FromStr for TypeVariant { "LedgerHeader" => Ok(Self::LedgerHeader), "LedgerHeaderExt" => Ok(Self::LedgerHeaderExt), "LedgerUpgradeType" => Ok(Self::LedgerUpgradeType), + "ConfigUpgradeSetKey" => Ok(Self::ConfigUpgradeSetKey), "LedgerUpgrade" => Ok(Self::LedgerUpgrade), + "ConfigUpgradeSet" => Ok(Self::ConfigUpgradeSet), "BucketEntryType" => Ok(Self::BucketEntryType), "BucketMetadata" => Ok(Self::BucketMetadata), "BucketMetadataExt" => Ok(Self::BucketMetadataExt), @@ -32317,15 +42832,25 @@ impl core::str::FromStr for TypeVariant { "OperationMeta" => Ok(Self::OperationMeta), "TransactionMetaV1" => Ok(Self::TransactionMetaV1), "TransactionMetaV2" => Ok(Self::TransactionMetaV2), + "ContractEventType" => Ok(Self::ContractEventType), + "ContractEvent" => Ok(Self::ContractEvent), + "ContractEventBody" => Ok(Self::ContractEventBody), + "ContractEventV0" => Ok(Self::ContractEventV0), + "DiagnosticEvent" => Ok(Self::DiagnosticEvent), + "SorobanTransactionMeta" => Ok(Self::SorobanTransactionMeta), + "TransactionMetaV3" => Ok(Self::TransactionMetaV3), + "InvokeHostFunctionSuccessPreImage" => Ok(Self::InvokeHostFunctionSuccessPreImage), "TransactionMeta" => Ok(Self::TransactionMeta), "TransactionResultMeta" => Ok(Self::TransactionResultMeta), "UpgradeEntryMeta" => Ok(Self::UpgradeEntryMeta), "LedgerCloseMetaV0" => Ok(Self::LedgerCloseMetaV0), "LedgerCloseMetaV1" => Ok(Self::LedgerCloseMetaV1), + "LedgerCloseMetaV2" => Ok(Self::LedgerCloseMetaV2), "LedgerCloseMeta" => Ok(Self::LedgerCloseMeta), "ErrorCode" => Ok(Self::ErrorCode), "SError" => Ok(Self::SError), "SendMore" => Ok(Self::SendMore), + "SendMoreExtended" => Ok(Self::SendMoreExtended), "AuthCert" => Ok(Self::AuthCert), "Hello" => Ok(Self::Hello), "Auth" => Ok(Self::Auth), @@ -32335,6 +42860,7 @@ impl core::str::FromStr for TypeVariant { "MessageType" => Ok(Self::MessageType), "DontHave" => Ok(Self::DontHave), "SurveyMessageCommandType" => Ok(Self::SurveyMessageCommandType), + "SurveyMessageResponseType" => Ok(Self::SurveyMessageResponseType), "SurveyRequestMessage" => Ok(Self::SurveyRequestMessage), "SignedSurveyRequestMessage" => Ok(Self::SignedSurveyRequestMessage), "EncryptedBody" => Ok(Self::EncryptedBody), @@ -32342,7 +42868,8 @@ impl core::str::FromStr for TypeVariant { "SignedSurveyResponseMessage" => Ok(Self::SignedSurveyResponseMessage), "PeerStats" => Ok(Self::PeerStats), "PeerStatList" => Ok(Self::PeerStatList), - "TopologyResponseBody" => Ok(Self::TopologyResponseBody), + "TopologyResponseBodyV0" => Ok(Self::TopologyResponseBodyV0), + "TopologyResponseBodyV1" => Ok(Self::TopologyResponseBodyV1), "SurveyResponseBody" => Ok(Self::SurveyResponseBody), "TxAdvertVector" => Ok(Self::TxAdvertVector), "FloodAdvert" => Ok(Self::FloodAdvert), @@ -32380,11 +42907,30 @@ impl core::str::FromStr for TypeVariant { "SetTrustLineFlagsOp" => Ok(Self::SetTrustLineFlagsOp), "LiquidityPoolDepositOp" => Ok(Self::LiquidityPoolDepositOp), "LiquidityPoolWithdrawOp" => Ok(Self::LiquidityPoolWithdrawOp), + "HostFunctionType" => Ok(Self::HostFunctionType), + "ContractIdPreimageType" => Ok(Self::ContractIdPreimageType), + "ContractIdPreimage" => Ok(Self::ContractIdPreimage), + "ContractIdPreimageFromAddress" => Ok(Self::ContractIdPreimageFromAddress), + "CreateContractArgs" => Ok(Self::CreateContractArgs), + "InvokeContractArgs" => Ok(Self::InvokeContractArgs), + "HostFunction" => Ok(Self::HostFunction), + "SorobanAuthorizedFunctionType" => Ok(Self::SorobanAuthorizedFunctionType), + "SorobanAuthorizedFunction" => Ok(Self::SorobanAuthorizedFunction), + "SorobanAuthorizedInvocation" => Ok(Self::SorobanAuthorizedInvocation), + "SorobanAddressCredentials" => Ok(Self::SorobanAddressCredentials), + "SorobanCredentialsType" => Ok(Self::SorobanCredentialsType), + "SorobanCredentials" => Ok(Self::SorobanCredentials), + "SorobanAuthorizationEntry" => Ok(Self::SorobanAuthorizationEntry), + "InvokeHostFunctionOp" => Ok(Self::InvokeHostFunctionOp), + "BumpFootprintExpirationOp" => Ok(Self::BumpFootprintExpirationOp), + "RestoreFootprintOp" => Ok(Self::RestoreFootprintOp), "Operation" => Ok(Self::Operation), "OperationBody" => Ok(Self::OperationBody), "HashIdPreimage" => Ok(Self::HashIdPreimage), "HashIdPreimageOperationId" => Ok(Self::HashIdPreimageOperationId), "HashIdPreimageRevokeId" => Ok(Self::HashIdPreimageRevokeId), + "HashIdPreimageContractId" => Ok(Self::HashIdPreimageContractId), + "HashIdPreimageSorobanAuthorization" => Ok(Self::HashIdPreimageSorobanAuthorization), "MemoType" => Ok(Self::MemoType), "Memo" => Ok(Self::Memo), "TimeBounds" => Ok(Self::TimeBounds), @@ -32392,6 +42938,9 @@ impl core::str::FromStr for TypeVariant { "PreconditionsV2" => Ok(Self::PreconditionsV2), "PreconditionType" => Ok(Self::PreconditionType), "Preconditions" => Ok(Self::Preconditions), + "LedgerFootprint" => Ok(Self::LedgerFootprint), + "SorobanResources" => Ok(Self::SorobanResources), + "SorobanTransactionData" => Ok(Self::SorobanTransactionData), "TransactionV0" => Ok(Self::TransactionV0), "TransactionV0Ext" => Ok(Self::TransactionV0Ext), "TransactionV0Envelope" => Ok(Self::TransactionV0Envelope), @@ -32471,6 +43020,12 @@ impl core::str::FromStr for TypeVariant { "LiquidityPoolDepositResult" => Ok(Self::LiquidityPoolDepositResult), "LiquidityPoolWithdrawResultCode" => Ok(Self::LiquidityPoolWithdrawResultCode), "LiquidityPoolWithdrawResult" => Ok(Self::LiquidityPoolWithdrawResult), + "InvokeHostFunctionResultCode" => Ok(Self::InvokeHostFunctionResultCode), + "InvokeHostFunctionResult" => Ok(Self::InvokeHostFunctionResult), + "BumpFootprintExpirationResultCode" => Ok(Self::BumpFootprintExpirationResultCode), + "BumpFootprintExpirationResult" => Ok(Self::BumpFootprintExpirationResult), + "RestoreFootprintResultCode" => Ok(Self::RestoreFootprintResultCode), + "RestoreFootprintResult" => Ok(Self::RestoreFootprintResult), "OperationResultCode" => Ok(Self::OperationResultCode), "OperationResult" => Ok(Self::OperationResult), "OperationResultTr" => Ok(Self::OperationResultTr), @@ -32488,6 +43043,8 @@ impl core::str::FromStr for TypeVariant { "Int32" => Ok(Self::Int32), "Uint64" => Ok(Self::Uint64), "Int64" => Ok(Self::Int64), + "TimePoint" => Ok(Self::TimePoint), + "Duration" => Ok(Self::Duration), "ExtensionPoint" => Ok(Self::ExtensionPoint), "CryptoKeyType" => Ok(Self::CryptoKeyType), "PublicKeyType" => Ok(Self::PublicKeyType), @@ -32498,6 +43055,7 @@ impl core::str::FromStr for TypeVariant { "Signature" => Ok(Self::Signature), "SignatureHint" => Ok(Self::SignatureHint), "NodeId" => Ok(Self::NodeId), + "AccountId" => Ok(Self::AccountId), "Curve25519Secret" => Ok(Self::Curve25519Secret), "Curve25519Public" => Ok(Self::Curve25519Public), "HmacSha256Key" => Ok(Self::HmacSha256Key), @@ -32526,17 +43084,77 @@ pub enum Type { ScpStatementExternalize(Box), ScpEnvelope(Box), ScpQuorumSet(Box), + ConfigSettingContractExecutionLanesV0(Box), + ConfigSettingContractComputeV0(Box), + ConfigSettingContractLedgerCostV0(Box), + ConfigSettingContractHistoricalDataV0(Box), + ConfigSettingContractEventsV0(Box), + ConfigSettingContractBandwidthV0(Box), + ContractCostType(Box), + ContractCostParamEntry(Box), + StateExpirationSettings(Box), + EvictionIterator(Box), + ContractCostParams(Box), + ConfigSettingId(Box), + ConfigSettingEntry(Box), + ScEnvMetaKind(Box), + ScEnvMetaEntry(Box), + ScMetaV0(Box), + ScMetaKind(Box), + ScMetaEntry(Box), + ScSpecType(Box), + ScSpecTypeOption(Box), + ScSpecTypeResult(Box), + ScSpecTypeVec(Box), + ScSpecTypeMap(Box), + ScSpecTypeTuple(Box), + ScSpecTypeBytesN(Box), + ScSpecTypeUdt(Box), + ScSpecTypeDef(Box), + ScSpecUdtStructFieldV0(Box), + ScSpecUdtStructV0(Box), + ScSpecUdtUnionCaseVoidV0(Box), + ScSpecUdtUnionCaseTupleV0(Box), + ScSpecUdtUnionCaseV0Kind(Box), + ScSpecUdtUnionCaseV0(Box), + ScSpecUdtUnionV0(Box), + ScSpecUdtEnumCaseV0(Box), + ScSpecUdtEnumV0(Box), + ScSpecUdtErrorEnumCaseV0(Box), + ScSpecUdtErrorEnumV0(Box), + ScSpecFunctionInputV0(Box), + ScSpecFunctionV0(Box), + ScSpecEntryKind(Box), + ScSpecEntry(Box), + ScValType(Box), + ScErrorType(Box), + ScErrorCode(Box), + ScError(Box), + UInt128Parts(Box), + Int128Parts(Box), + UInt256Parts(Box), + Int256Parts(Box), + ContractExecutableType(Box), + ContractExecutable(Box), + ScAddressType(Box), + ScAddress(Box), + ScVec(Box), + ScMap(Box), + ScBytes(Box), + ScString(Box), + ScSymbol(Box), + ScNonceKey(Box), + ScContractInstance(Box), + ScVal(Box), + ScMapEntry(Box), StoredTransactionSet(Box), PersistedScpStateV0(Box), PersistedScpStateV1(Box), PersistedScpState(Box), - AccountId(Box), Thresholds(Box), String32(Box), String64(Box), SequenceNumber(Box), - TimePoint(Box), - Duration(Box), DataValue(Box), PoolId(Box), AssetCode4(Box), @@ -32590,6 +43208,10 @@ pub enum Type { LiquidityPoolEntry(Box), LiquidityPoolEntryBody(Box), LiquidityPoolEntryConstantProduct(Box), + ContractDataDurability(Box), + ContractDataEntry(Box), + ContractCodeEntry(Box), + ExpirationEntry(Box), LedgerEntryExtensionV1(Box), LedgerEntryExtensionV1Ext(Box), LedgerEntry(Box), @@ -32602,6 +43224,10 @@ pub enum Type { LedgerKeyData(Box), LedgerKeyClaimableBalance(Box), LedgerKeyLiquidityPool(Box), + LedgerKeyContractData(Box), + LedgerKeyContractCode(Box), + LedgerKeyConfigSetting(Box), + LedgerKeyExpiration(Box), EnvelopeType(Box), UpgradeType(Box), StellarValueType(Box), @@ -32614,7 +43240,9 @@ pub enum Type { LedgerHeader(Box), LedgerHeaderExt(Box), LedgerUpgradeType(Box), + ConfigUpgradeSetKey(Box), LedgerUpgrade(Box), + ConfigUpgradeSet(Box), BucketEntryType(Box), BucketMetadata(Box), BucketMetadataExt(Box), @@ -32643,15 +43271,25 @@ pub enum Type { OperationMeta(Box), TransactionMetaV1(Box), TransactionMetaV2(Box), + ContractEventType(Box), + ContractEvent(Box), + ContractEventBody(Box), + ContractEventV0(Box), + DiagnosticEvent(Box), + SorobanTransactionMeta(Box), + TransactionMetaV3(Box), + InvokeHostFunctionSuccessPreImage(Box), TransactionMeta(Box), TransactionResultMeta(Box), UpgradeEntryMeta(Box), LedgerCloseMetaV0(Box), LedgerCloseMetaV1(Box), + LedgerCloseMetaV2(Box), LedgerCloseMeta(Box), ErrorCode(Box), SError(Box), SendMore(Box), + SendMoreExtended(Box), AuthCert(Box), Hello(Box), Auth(Box), @@ -32661,6 +43299,7 @@ pub enum Type { MessageType(Box), DontHave(Box), SurveyMessageCommandType(Box), + SurveyMessageResponseType(Box), SurveyRequestMessage(Box), SignedSurveyRequestMessage(Box), EncryptedBody(Box), @@ -32668,7 +43307,8 @@ pub enum Type { SignedSurveyResponseMessage(Box), PeerStats(Box), PeerStatList(Box), - TopologyResponseBody(Box), + TopologyResponseBodyV0(Box), + TopologyResponseBodyV1(Box), SurveyResponseBody(Box), TxAdvertVector(Box), FloodAdvert(Box), @@ -32706,11 +43346,30 @@ pub enum Type { SetTrustLineFlagsOp(Box), LiquidityPoolDepositOp(Box), LiquidityPoolWithdrawOp(Box), + HostFunctionType(Box), + ContractIdPreimageType(Box), + ContractIdPreimage(Box), + ContractIdPreimageFromAddress(Box), + CreateContractArgs(Box), + InvokeContractArgs(Box), + HostFunction(Box), + SorobanAuthorizedFunctionType(Box), + SorobanAuthorizedFunction(Box), + SorobanAuthorizedInvocation(Box), + SorobanAddressCredentials(Box), + SorobanCredentialsType(Box), + SorobanCredentials(Box), + SorobanAuthorizationEntry(Box), + InvokeHostFunctionOp(Box), + BumpFootprintExpirationOp(Box), + RestoreFootprintOp(Box), Operation(Box), OperationBody(Box), HashIdPreimage(Box), HashIdPreimageOperationId(Box), HashIdPreimageRevokeId(Box), + HashIdPreimageContractId(Box), + HashIdPreimageSorobanAuthorization(Box), MemoType(Box), Memo(Box), TimeBounds(Box), @@ -32718,6 +43377,9 @@ pub enum Type { PreconditionsV2(Box), PreconditionType(Box), Preconditions(Box), + LedgerFootprint(Box), + SorobanResources(Box), + SorobanTransactionData(Box), TransactionV0(Box), TransactionV0Ext(Box), TransactionV0Envelope(Box), @@ -32789,6 +43451,12 @@ pub enum Type { LiquidityPoolDepositResult(Box), LiquidityPoolWithdrawResultCode(Box), LiquidityPoolWithdrawResult(Box), + InvokeHostFunctionResultCode(Box), + InvokeHostFunctionResult(Box), + BumpFootprintExpirationResultCode(Box), + BumpFootprintExpirationResult(Box), + RestoreFootprintResultCode(Box), + RestoreFootprintResult(Box), OperationResultCode(Box), OperationResult(Box), OperationResultTr(Box), @@ -32806,6 +43474,8 @@ pub enum Type { Int32(Box), Uint64(Box), Int64(Box), + TimePoint(Box), + Duration(Box), ExtensionPoint(Box), CryptoKeyType(Box), PublicKeyType(Box), @@ -32816,6 +43486,7 @@ pub enum Type { Signature(Box), SignatureHint(Box), NodeId(Box), + AccountId(Box), Curve25519Secret(Box), Curve25519Public(Box), HmacSha256Key(Box), @@ -32823,7 +43494,7 @@ pub enum Type { } impl Type { - pub const VARIANTS: [TypeVariant; 305] = [ + pub const VARIANTS: [TypeVariant; 418] = [ TypeVariant::Value, TypeVariant::ScpBallot, TypeVariant::ScpStatementType, @@ -32835,17 +43506,77 @@ impl Type { TypeVariant::ScpStatementExternalize, TypeVariant::ScpEnvelope, TypeVariant::ScpQuorumSet, + TypeVariant::ConfigSettingContractExecutionLanesV0, + TypeVariant::ConfigSettingContractComputeV0, + TypeVariant::ConfigSettingContractLedgerCostV0, + TypeVariant::ConfigSettingContractHistoricalDataV0, + TypeVariant::ConfigSettingContractEventsV0, + TypeVariant::ConfigSettingContractBandwidthV0, + TypeVariant::ContractCostType, + TypeVariant::ContractCostParamEntry, + TypeVariant::StateExpirationSettings, + TypeVariant::EvictionIterator, + TypeVariant::ContractCostParams, + TypeVariant::ConfigSettingId, + TypeVariant::ConfigSettingEntry, + TypeVariant::ScEnvMetaKind, + TypeVariant::ScEnvMetaEntry, + TypeVariant::ScMetaV0, + TypeVariant::ScMetaKind, + TypeVariant::ScMetaEntry, + TypeVariant::ScSpecType, + TypeVariant::ScSpecTypeOption, + TypeVariant::ScSpecTypeResult, + TypeVariant::ScSpecTypeVec, + TypeVariant::ScSpecTypeMap, + TypeVariant::ScSpecTypeTuple, + TypeVariant::ScSpecTypeBytesN, + TypeVariant::ScSpecTypeUdt, + TypeVariant::ScSpecTypeDef, + TypeVariant::ScSpecUdtStructFieldV0, + TypeVariant::ScSpecUdtStructV0, + TypeVariant::ScSpecUdtUnionCaseVoidV0, + TypeVariant::ScSpecUdtUnionCaseTupleV0, + TypeVariant::ScSpecUdtUnionCaseV0Kind, + TypeVariant::ScSpecUdtUnionCaseV0, + TypeVariant::ScSpecUdtUnionV0, + TypeVariant::ScSpecUdtEnumCaseV0, + TypeVariant::ScSpecUdtEnumV0, + TypeVariant::ScSpecUdtErrorEnumCaseV0, + TypeVariant::ScSpecUdtErrorEnumV0, + TypeVariant::ScSpecFunctionInputV0, + TypeVariant::ScSpecFunctionV0, + TypeVariant::ScSpecEntryKind, + TypeVariant::ScSpecEntry, + TypeVariant::ScValType, + TypeVariant::ScErrorType, + TypeVariant::ScErrorCode, + TypeVariant::ScError, + TypeVariant::UInt128Parts, + TypeVariant::Int128Parts, + TypeVariant::UInt256Parts, + TypeVariant::Int256Parts, + TypeVariant::ContractExecutableType, + TypeVariant::ContractExecutable, + TypeVariant::ScAddressType, + TypeVariant::ScAddress, + TypeVariant::ScVec, + TypeVariant::ScMap, + TypeVariant::ScBytes, + TypeVariant::ScString, + TypeVariant::ScSymbol, + TypeVariant::ScNonceKey, + TypeVariant::ScContractInstance, + TypeVariant::ScVal, + TypeVariant::ScMapEntry, TypeVariant::StoredTransactionSet, TypeVariant::PersistedScpStateV0, TypeVariant::PersistedScpStateV1, TypeVariant::PersistedScpState, - TypeVariant::AccountId, TypeVariant::Thresholds, TypeVariant::String32, TypeVariant::String64, TypeVariant::SequenceNumber, - TypeVariant::TimePoint, - TypeVariant::Duration, TypeVariant::DataValue, TypeVariant::PoolId, TypeVariant::AssetCode4, @@ -32899,6 +43630,10 @@ impl Type { TypeVariant::LiquidityPoolEntry, TypeVariant::LiquidityPoolEntryBody, TypeVariant::LiquidityPoolEntryConstantProduct, + TypeVariant::ContractDataDurability, + TypeVariant::ContractDataEntry, + TypeVariant::ContractCodeEntry, + TypeVariant::ExpirationEntry, TypeVariant::LedgerEntryExtensionV1, TypeVariant::LedgerEntryExtensionV1Ext, TypeVariant::LedgerEntry, @@ -32911,6 +43646,10 @@ impl Type { TypeVariant::LedgerKeyData, TypeVariant::LedgerKeyClaimableBalance, TypeVariant::LedgerKeyLiquidityPool, + TypeVariant::LedgerKeyContractData, + TypeVariant::LedgerKeyContractCode, + TypeVariant::LedgerKeyConfigSetting, + TypeVariant::LedgerKeyExpiration, TypeVariant::EnvelopeType, TypeVariant::UpgradeType, TypeVariant::StellarValueType, @@ -32923,7 +43662,9 @@ impl Type { TypeVariant::LedgerHeader, TypeVariant::LedgerHeaderExt, TypeVariant::LedgerUpgradeType, + TypeVariant::ConfigUpgradeSetKey, TypeVariant::LedgerUpgrade, + TypeVariant::ConfigUpgradeSet, TypeVariant::BucketEntryType, TypeVariant::BucketMetadata, TypeVariant::BucketMetadataExt, @@ -32952,15 +43693,25 @@ impl Type { TypeVariant::OperationMeta, TypeVariant::TransactionMetaV1, TypeVariant::TransactionMetaV2, + TypeVariant::ContractEventType, + TypeVariant::ContractEvent, + TypeVariant::ContractEventBody, + TypeVariant::ContractEventV0, + TypeVariant::DiagnosticEvent, + TypeVariant::SorobanTransactionMeta, + TypeVariant::TransactionMetaV3, + TypeVariant::InvokeHostFunctionSuccessPreImage, TypeVariant::TransactionMeta, TypeVariant::TransactionResultMeta, TypeVariant::UpgradeEntryMeta, TypeVariant::LedgerCloseMetaV0, TypeVariant::LedgerCloseMetaV1, + TypeVariant::LedgerCloseMetaV2, TypeVariant::LedgerCloseMeta, TypeVariant::ErrorCode, TypeVariant::SError, TypeVariant::SendMore, + TypeVariant::SendMoreExtended, TypeVariant::AuthCert, TypeVariant::Hello, TypeVariant::Auth, @@ -32970,6 +43721,7 @@ impl Type { TypeVariant::MessageType, TypeVariant::DontHave, TypeVariant::SurveyMessageCommandType, + TypeVariant::SurveyMessageResponseType, TypeVariant::SurveyRequestMessage, TypeVariant::SignedSurveyRequestMessage, TypeVariant::EncryptedBody, @@ -32977,7 +43729,8 @@ impl Type { TypeVariant::SignedSurveyResponseMessage, TypeVariant::PeerStats, TypeVariant::PeerStatList, - TypeVariant::TopologyResponseBody, + TypeVariant::TopologyResponseBodyV0, + TypeVariant::TopologyResponseBodyV1, TypeVariant::SurveyResponseBody, TypeVariant::TxAdvertVector, TypeVariant::FloodAdvert, @@ -33015,11 +43768,30 @@ impl Type { TypeVariant::SetTrustLineFlagsOp, TypeVariant::LiquidityPoolDepositOp, TypeVariant::LiquidityPoolWithdrawOp, + TypeVariant::HostFunctionType, + TypeVariant::ContractIdPreimageType, + TypeVariant::ContractIdPreimage, + TypeVariant::ContractIdPreimageFromAddress, + TypeVariant::CreateContractArgs, + TypeVariant::InvokeContractArgs, + TypeVariant::HostFunction, + TypeVariant::SorobanAuthorizedFunctionType, + TypeVariant::SorobanAuthorizedFunction, + TypeVariant::SorobanAuthorizedInvocation, + TypeVariant::SorobanAddressCredentials, + TypeVariant::SorobanCredentialsType, + TypeVariant::SorobanCredentials, + TypeVariant::SorobanAuthorizationEntry, + TypeVariant::InvokeHostFunctionOp, + TypeVariant::BumpFootprintExpirationOp, + TypeVariant::RestoreFootprintOp, TypeVariant::Operation, TypeVariant::OperationBody, TypeVariant::HashIdPreimage, TypeVariant::HashIdPreimageOperationId, TypeVariant::HashIdPreimageRevokeId, + TypeVariant::HashIdPreimageContractId, + TypeVariant::HashIdPreimageSorobanAuthorization, TypeVariant::MemoType, TypeVariant::Memo, TypeVariant::TimeBounds, @@ -33027,6 +43799,9 @@ impl Type { TypeVariant::PreconditionsV2, TypeVariant::PreconditionType, TypeVariant::Preconditions, + TypeVariant::LedgerFootprint, + TypeVariant::SorobanResources, + TypeVariant::SorobanTransactionData, TypeVariant::TransactionV0, TypeVariant::TransactionV0Ext, TypeVariant::TransactionV0Envelope, @@ -33098,6 +43873,12 @@ impl Type { TypeVariant::LiquidityPoolDepositResult, TypeVariant::LiquidityPoolWithdrawResultCode, TypeVariant::LiquidityPoolWithdrawResult, + TypeVariant::InvokeHostFunctionResultCode, + TypeVariant::InvokeHostFunctionResult, + TypeVariant::BumpFootprintExpirationResultCode, + TypeVariant::BumpFootprintExpirationResult, + TypeVariant::RestoreFootprintResultCode, + TypeVariant::RestoreFootprintResult, TypeVariant::OperationResultCode, TypeVariant::OperationResult, TypeVariant::OperationResultTr, @@ -33115,6 +43896,8 @@ impl Type { TypeVariant::Int32, TypeVariant::Uint64, TypeVariant::Int64, + TypeVariant::TimePoint, + TypeVariant::Duration, TypeVariant::ExtensionPoint, TypeVariant::CryptoKeyType, TypeVariant::PublicKeyType, @@ -33125,12 +43908,13 @@ impl Type { TypeVariant::Signature, TypeVariant::SignatureHint, TypeVariant::NodeId, + TypeVariant::AccountId, TypeVariant::Curve25519Secret, TypeVariant::Curve25519Public, TypeVariant::HmacSha256Key, TypeVariant::HmacSha256Mac, ]; - pub const VARIANTS_STR: [&'static str; 305] = [ + pub const VARIANTS_STR: [&'static str; 418] = [ "Value", "ScpBallot", "ScpStatementType", @@ -33142,17 +43926,77 @@ impl Type { "ScpStatementExternalize", "ScpEnvelope", "ScpQuorumSet", + "ConfigSettingContractExecutionLanesV0", + "ConfigSettingContractComputeV0", + "ConfigSettingContractLedgerCostV0", + "ConfigSettingContractHistoricalDataV0", + "ConfigSettingContractEventsV0", + "ConfigSettingContractBandwidthV0", + "ContractCostType", + "ContractCostParamEntry", + "StateExpirationSettings", + "EvictionIterator", + "ContractCostParams", + "ConfigSettingId", + "ConfigSettingEntry", + "ScEnvMetaKind", + "ScEnvMetaEntry", + "ScMetaV0", + "ScMetaKind", + "ScMetaEntry", + "ScSpecType", + "ScSpecTypeOption", + "ScSpecTypeResult", + "ScSpecTypeVec", + "ScSpecTypeMap", + "ScSpecTypeTuple", + "ScSpecTypeBytesN", + "ScSpecTypeUdt", + "ScSpecTypeDef", + "ScSpecUdtStructFieldV0", + "ScSpecUdtStructV0", + "ScSpecUdtUnionCaseVoidV0", + "ScSpecUdtUnionCaseTupleV0", + "ScSpecUdtUnionCaseV0Kind", + "ScSpecUdtUnionCaseV0", + "ScSpecUdtUnionV0", + "ScSpecUdtEnumCaseV0", + "ScSpecUdtEnumV0", + "ScSpecUdtErrorEnumCaseV0", + "ScSpecUdtErrorEnumV0", + "ScSpecFunctionInputV0", + "ScSpecFunctionV0", + "ScSpecEntryKind", + "ScSpecEntry", + "ScValType", + "ScErrorType", + "ScErrorCode", + "ScError", + "UInt128Parts", + "Int128Parts", + "UInt256Parts", + "Int256Parts", + "ContractExecutableType", + "ContractExecutable", + "ScAddressType", + "ScAddress", + "ScVec", + "ScMap", + "ScBytes", + "ScString", + "ScSymbol", + "ScNonceKey", + "ScContractInstance", + "ScVal", + "ScMapEntry", "StoredTransactionSet", "PersistedScpStateV0", "PersistedScpStateV1", "PersistedScpState", - "AccountId", "Thresholds", "String32", "String64", "SequenceNumber", - "TimePoint", - "Duration", "DataValue", "PoolId", "AssetCode4", @@ -33206,6 +44050,10 @@ impl Type { "LiquidityPoolEntry", "LiquidityPoolEntryBody", "LiquidityPoolEntryConstantProduct", + "ContractDataDurability", + "ContractDataEntry", + "ContractCodeEntry", + "ExpirationEntry", "LedgerEntryExtensionV1", "LedgerEntryExtensionV1Ext", "LedgerEntry", @@ -33218,6 +44066,10 @@ impl Type { "LedgerKeyData", "LedgerKeyClaimableBalance", "LedgerKeyLiquidityPool", + "LedgerKeyContractData", + "LedgerKeyContractCode", + "LedgerKeyConfigSetting", + "LedgerKeyExpiration", "EnvelopeType", "UpgradeType", "StellarValueType", @@ -33230,7 +44082,9 @@ impl Type { "LedgerHeader", "LedgerHeaderExt", "LedgerUpgradeType", + "ConfigUpgradeSetKey", "LedgerUpgrade", + "ConfigUpgradeSet", "BucketEntryType", "BucketMetadata", "BucketMetadataExt", @@ -33259,15 +44113,25 @@ impl Type { "OperationMeta", "TransactionMetaV1", "TransactionMetaV2", + "ContractEventType", + "ContractEvent", + "ContractEventBody", + "ContractEventV0", + "DiagnosticEvent", + "SorobanTransactionMeta", + "TransactionMetaV3", + "InvokeHostFunctionSuccessPreImage", "TransactionMeta", "TransactionResultMeta", "UpgradeEntryMeta", "LedgerCloseMetaV0", "LedgerCloseMetaV1", + "LedgerCloseMetaV2", "LedgerCloseMeta", "ErrorCode", "SError", "SendMore", + "SendMoreExtended", "AuthCert", "Hello", "Auth", @@ -33277,6 +44141,7 @@ impl Type { "MessageType", "DontHave", "SurveyMessageCommandType", + "SurveyMessageResponseType", "SurveyRequestMessage", "SignedSurveyRequestMessage", "EncryptedBody", @@ -33284,7 +44149,8 @@ impl Type { "SignedSurveyResponseMessage", "PeerStats", "PeerStatList", - "TopologyResponseBody", + "TopologyResponseBodyV0", + "TopologyResponseBodyV1", "SurveyResponseBody", "TxAdvertVector", "FloodAdvert", @@ -33322,11 +44188,30 @@ impl Type { "SetTrustLineFlagsOp", "LiquidityPoolDepositOp", "LiquidityPoolWithdrawOp", + "HostFunctionType", + "ContractIdPreimageType", + "ContractIdPreimage", + "ContractIdPreimageFromAddress", + "CreateContractArgs", + "InvokeContractArgs", + "HostFunction", + "SorobanAuthorizedFunctionType", + "SorobanAuthorizedFunction", + "SorobanAuthorizedInvocation", + "SorobanAddressCredentials", + "SorobanCredentialsType", + "SorobanCredentials", + "SorobanAuthorizationEntry", + "InvokeHostFunctionOp", + "BumpFootprintExpirationOp", + "RestoreFootprintOp", "Operation", "OperationBody", "HashIdPreimage", "HashIdPreimageOperationId", "HashIdPreimageRevokeId", + "HashIdPreimageContractId", + "HashIdPreimageSorobanAuthorization", "MemoType", "Memo", "TimeBounds", @@ -33334,6 +44219,9 @@ impl Type { "PreconditionsV2", "PreconditionType", "Preconditions", + "LedgerFootprint", + "SorobanResources", + "SorobanTransactionData", "TransactionV0", "TransactionV0Ext", "TransactionV0Envelope", @@ -33405,6 +44293,12 @@ impl Type { "LiquidityPoolDepositResult", "LiquidityPoolWithdrawResultCode", "LiquidityPoolWithdrawResult", + "InvokeHostFunctionResultCode", + "InvokeHostFunctionResult", + "BumpFootprintExpirationResultCode", + "BumpFootprintExpirationResult", + "RestoreFootprintResultCode", + "RestoreFootprintResult", "OperationResultCode", "OperationResult", "OperationResultTr", @@ -33422,6 +44316,8 @@ impl Type { "Int32", "Uint64", "Int64", + "TimePoint", + "Duration", "ExtensionPoint", "CryptoKeyType", "PublicKeyType", @@ -33432,6 +44328,7 @@ impl Type { "Signature", "SignatureHint", "NodeId", + "AccountId", "Curve25519Secret", "Curve25519Public", "HmacSha256Key", @@ -33485,6 +44382,263 @@ impl Type { TypeVariant::ScpQuorumSet => r.with_limited_depth(|r| { Ok(Self::ScpQuorumSet(Box::new(ScpQuorumSet::read_xdr(r)?))) }), + TypeVariant::ConfigSettingContractExecutionLanesV0 => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingContractExecutionLanesV0(Box::new( + ConfigSettingContractExecutionLanesV0::read_xdr(r)?, + ))) + }), + TypeVariant::ConfigSettingContractComputeV0 => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingContractComputeV0(Box::new( + ConfigSettingContractComputeV0::read_xdr(r)?, + ))) + }), + TypeVariant::ConfigSettingContractLedgerCostV0 => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingContractLedgerCostV0(Box::new( + ConfigSettingContractLedgerCostV0::read_xdr(r)?, + ))) + }), + TypeVariant::ConfigSettingContractHistoricalDataV0 => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingContractHistoricalDataV0(Box::new( + ConfigSettingContractHistoricalDataV0::read_xdr(r)?, + ))) + }), + TypeVariant::ConfigSettingContractEventsV0 => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingContractEventsV0(Box::new( + ConfigSettingContractEventsV0::read_xdr(r)?, + ))) + }), + TypeVariant::ConfigSettingContractBandwidthV0 => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingContractBandwidthV0(Box::new( + ConfigSettingContractBandwidthV0::read_xdr(r)?, + ))) + }), + TypeVariant::ContractCostType => r.with_limited_depth(|r| { + Ok(Self::ContractCostType(Box::new( + ContractCostType::read_xdr(r)?, + ))) + }), + TypeVariant::ContractCostParamEntry => r.with_limited_depth(|r| { + Ok(Self::ContractCostParamEntry(Box::new( + ContractCostParamEntry::read_xdr(r)?, + ))) + }), + TypeVariant::StateExpirationSettings => r.with_limited_depth(|r| { + Ok(Self::StateExpirationSettings(Box::new( + StateExpirationSettings::read_xdr(r)?, + ))) + }), + TypeVariant::EvictionIterator => r.with_limited_depth(|r| { + Ok(Self::EvictionIterator(Box::new( + EvictionIterator::read_xdr(r)?, + ))) + }), + TypeVariant::ContractCostParams => r.with_limited_depth(|r| { + Ok(Self::ContractCostParams(Box::new( + ContractCostParams::read_xdr(r)?, + ))) + }), + TypeVariant::ConfigSettingId => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingId(Box::new(ConfigSettingId::read_xdr( + r, + )?))) + }), + TypeVariant::ConfigSettingEntry => r.with_limited_depth(|r| { + Ok(Self::ConfigSettingEntry(Box::new( + ConfigSettingEntry::read_xdr(r)?, + ))) + }), + TypeVariant::ScEnvMetaKind => r.with_limited_depth(|r| { + Ok(Self::ScEnvMetaKind(Box::new(ScEnvMetaKind::read_xdr(r)?))) + }), + TypeVariant::ScEnvMetaEntry => r.with_limited_depth(|r| { + Ok(Self::ScEnvMetaEntry(Box::new(ScEnvMetaEntry::read_xdr(r)?))) + }), + TypeVariant::ScMetaV0 => { + r.with_limited_depth(|r| Ok(Self::ScMetaV0(Box::new(ScMetaV0::read_xdr(r)?)))) + } + TypeVariant::ScMetaKind => { + r.with_limited_depth(|r| Ok(Self::ScMetaKind(Box::new(ScMetaKind::read_xdr(r)?)))) + } + TypeVariant::ScMetaEntry => { + r.with_limited_depth(|r| Ok(Self::ScMetaEntry(Box::new(ScMetaEntry::read_xdr(r)?)))) + } + TypeVariant::ScSpecType => { + r.with_limited_depth(|r| Ok(Self::ScSpecType(Box::new(ScSpecType::read_xdr(r)?)))) + } + TypeVariant::ScSpecTypeOption => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeOption(Box::new( + ScSpecTypeOption::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecTypeResult => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeResult(Box::new( + ScSpecTypeResult::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecTypeVec => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeVec(Box::new(ScSpecTypeVec::read_xdr(r)?))) + }), + TypeVariant::ScSpecTypeMap => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeMap(Box::new(ScSpecTypeMap::read_xdr(r)?))) + }), + TypeVariant::ScSpecTypeTuple => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeTuple(Box::new(ScSpecTypeTuple::read_xdr( + r, + )?))) + }), + TypeVariant::ScSpecTypeBytesN => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeBytesN(Box::new( + ScSpecTypeBytesN::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecTypeUdt => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeUdt(Box::new(ScSpecTypeUdt::read_xdr(r)?))) + }), + TypeVariant::ScSpecTypeDef => r.with_limited_depth(|r| { + Ok(Self::ScSpecTypeDef(Box::new(ScSpecTypeDef::read_xdr(r)?))) + }), + TypeVariant::ScSpecUdtStructFieldV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtStructFieldV0(Box::new( + ScSpecUdtStructFieldV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtStructV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtStructV0(Box::new( + ScSpecUdtStructV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtUnionCaseVoidV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtUnionCaseVoidV0(Box::new( + ScSpecUdtUnionCaseVoidV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtUnionCaseTupleV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtUnionCaseTupleV0(Box::new( + ScSpecUdtUnionCaseTupleV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtUnionCaseV0Kind => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtUnionCaseV0Kind(Box::new( + ScSpecUdtUnionCaseV0Kind::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtUnionCaseV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtUnionCaseV0(Box::new( + ScSpecUdtUnionCaseV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtUnionV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtUnionV0(Box::new( + ScSpecUdtUnionV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtEnumCaseV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtEnumCaseV0(Box::new( + ScSpecUdtEnumCaseV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtEnumV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtEnumV0(Box::new(ScSpecUdtEnumV0::read_xdr( + r, + )?))) + }), + TypeVariant::ScSpecUdtErrorEnumCaseV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtErrorEnumCaseV0(Box::new( + ScSpecUdtErrorEnumCaseV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecUdtErrorEnumV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecUdtErrorEnumV0(Box::new( + ScSpecUdtErrorEnumV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecFunctionInputV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecFunctionInputV0(Box::new( + ScSpecFunctionInputV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecFunctionV0 => r.with_limited_depth(|r| { + Ok(Self::ScSpecFunctionV0(Box::new( + ScSpecFunctionV0::read_xdr(r)?, + ))) + }), + TypeVariant::ScSpecEntryKind => r.with_limited_depth(|r| { + Ok(Self::ScSpecEntryKind(Box::new(ScSpecEntryKind::read_xdr( + r, + )?))) + }), + TypeVariant::ScSpecEntry => { + r.with_limited_depth(|r| Ok(Self::ScSpecEntry(Box::new(ScSpecEntry::read_xdr(r)?)))) + } + TypeVariant::ScValType => { + r.with_limited_depth(|r| Ok(Self::ScValType(Box::new(ScValType::read_xdr(r)?)))) + } + TypeVariant::ScErrorType => { + r.with_limited_depth(|r| Ok(Self::ScErrorType(Box::new(ScErrorType::read_xdr(r)?)))) + } + TypeVariant::ScErrorCode => { + r.with_limited_depth(|r| Ok(Self::ScErrorCode(Box::new(ScErrorCode::read_xdr(r)?)))) + } + TypeVariant::ScError => { + r.with_limited_depth(|r| Ok(Self::ScError(Box::new(ScError::read_xdr(r)?)))) + } + TypeVariant::UInt128Parts => r.with_limited_depth(|r| { + Ok(Self::UInt128Parts(Box::new(UInt128Parts::read_xdr(r)?))) + }), + TypeVariant::Int128Parts => { + r.with_limited_depth(|r| Ok(Self::Int128Parts(Box::new(Int128Parts::read_xdr(r)?)))) + } + TypeVariant::UInt256Parts => r.with_limited_depth(|r| { + Ok(Self::UInt256Parts(Box::new(UInt256Parts::read_xdr(r)?))) + }), + TypeVariant::Int256Parts => { + r.with_limited_depth(|r| Ok(Self::Int256Parts(Box::new(Int256Parts::read_xdr(r)?)))) + } + TypeVariant::ContractExecutableType => r.with_limited_depth(|r| { + Ok(Self::ContractExecutableType(Box::new( + ContractExecutableType::read_xdr(r)?, + ))) + }), + TypeVariant::ContractExecutable => r.with_limited_depth(|r| { + Ok(Self::ContractExecutable(Box::new( + ContractExecutable::read_xdr(r)?, + ))) + }), + TypeVariant::ScAddressType => r.with_limited_depth(|r| { + Ok(Self::ScAddressType(Box::new(ScAddressType::read_xdr(r)?))) + }), + TypeVariant::ScAddress => { + r.with_limited_depth(|r| Ok(Self::ScAddress(Box::new(ScAddress::read_xdr(r)?)))) + } + TypeVariant::ScVec => { + r.with_limited_depth(|r| Ok(Self::ScVec(Box::new(ScVec::read_xdr(r)?)))) + } + TypeVariant::ScMap => { + r.with_limited_depth(|r| Ok(Self::ScMap(Box::new(ScMap::read_xdr(r)?)))) + } + TypeVariant::ScBytes => { + r.with_limited_depth(|r| Ok(Self::ScBytes(Box::new(ScBytes::read_xdr(r)?)))) + } + TypeVariant::ScString => { + r.with_limited_depth(|r| Ok(Self::ScString(Box::new(ScString::read_xdr(r)?)))) + } + TypeVariant::ScSymbol => { + r.with_limited_depth(|r| Ok(Self::ScSymbol(Box::new(ScSymbol::read_xdr(r)?)))) + } + TypeVariant::ScNonceKey => { + r.with_limited_depth(|r| Ok(Self::ScNonceKey(Box::new(ScNonceKey::read_xdr(r)?)))) + } + TypeVariant::ScContractInstance => r.with_limited_depth(|r| { + Ok(Self::ScContractInstance(Box::new( + ScContractInstance::read_xdr(r)?, + ))) + }), + TypeVariant::ScVal => { + r.with_limited_depth(|r| Ok(Self::ScVal(Box::new(ScVal::read_xdr(r)?)))) + } + TypeVariant::ScMapEntry => { + r.with_limited_depth(|r| Ok(Self::ScMapEntry(Box::new(ScMapEntry::read_xdr(r)?)))) + } TypeVariant::StoredTransactionSet => r.with_limited_depth(|r| { Ok(Self::StoredTransactionSet(Box::new( StoredTransactionSet::read_xdr(r)?, @@ -33505,9 +44659,6 @@ impl Type { PersistedScpState::read_xdr(r)?, ))) }), - TypeVariant::AccountId => { - r.with_limited_depth(|r| Ok(Self::AccountId(Box::new(AccountId::read_xdr(r)?)))) - } TypeVariant::Thresholds => { r.with_limited_depth(|r| Ok(Self::Thresholds(Box::new(Thresholds::read_xdr(r)?)))) } @@ -33520,12 +44671,6 @@ impl Type { TypeVariant::SequenceNumber => r.with_limited_depth(|r| { Ok(Self::SequenceNumber(Box::new(SequenceNumber::read_xdr(r)?))) }), - TypeVariant::TimePoint => { - r.with_limited_depth(|r| Ok(Self::TimePoint(Box::new(TimePoint::read_xdr(r)?)))) - } - TypeVariant::Duration => { - r.with_limited_depth(|r| Ok(Self::Duration(Box::new(Duration::read_xdr(r)?)))) - } TypeVariant::DataValue => { r.with_limited_depth(|r| Ok(Self::DataValue(Box::new(DataValue::read_xdr(r)?)))) } @@ -33741,6 +44886,26 @@ impl Type { LiquidityPoolEntryConstantProduct::read_xdr(r)?, ))) }), + TypeVariant::ContractDataDurability => r.with_limited_depth(|r| { + Ok(Self::ContractDataDurability(Box::new( + ContractDataDurability::read_xdr(r)?, + ))) + }), + TypeVariant::ContractDataEntry => r.with_limited_depth(|r| { + Ok(Self::ContractDataEntry(Box::new( + ContractDataEntry::read_xdr(r)?, + ))) + }), + TypeVariant::ContractCodeEntry => r.with_limited_depth(|r| { + Ok(Self::ContractCodeEntry(Box::new( + ContractCodeEntry::read_xdr(r)?, + ))) + }), + TypeVariant::ExpirationEntry => r.with_limited_depth(|r| { + Ok(Self::ExpirationEntry(Box::new(ExpirationEntry::read_xdr( + r, + )?))) + }), TypeVariant::LedgerEntryExtensionV1 => r.with_limited_depth(|r| { Ok(Self::LedgerEntryExtensionV1(Box::new( LedgerEntryExtensionV1::read_xdr(r)?, @@ -33791,6 +44956,26 @@ impl Type { LedgerKeyLiquidityPool::read_xdr(r)?, ))) }), + TypeVariant::LedgerKeyContractData => r.with_limited_depth(|r| { + Ok(Self::LedgerKeyContractData(Box::new( + LedgerKeyContractData::read_xdr(r)?, + ))) + }), + TypeVariant::LedgerKeyContractCode => r.with_limited_depth(|r| { + Ok(Self::LedgerKeyContractCode(Box::new( + LedgerKeyContractCode::read_xdr(r)?, + ))) + }), + TypeVariant::LedgerKeyConfigSetting => r.with_limited_depth(|r| { + Ok(Self::LedgerKeyConfigSetting(Box::new( + LedgerKeyConfigSetting::read_xdr(r)?, + ))) + }), + TypeVariant::LedgerKeyExpiration => r.with_limited_depth(|r| { + Ok(Self::LedgerKeyExpiration(Box::new( + LedgerKeyExpiration::read_xdr(r)?, + ))) + }), TypeVariant::EnvelopeType => r.with_limited_depth(|r| { Ok(Self::EnvelopeType(Box::new(EnvelopeType::read_xdr(r)?))) }), @@ -33843,9 +45028,19 @@ impl Type { LedgerUpgradeType::read_xdr(r)?, ))) }), + TypeVariant::ConfigUpgradeSetKey => r.with_limited_depth(|r| { + Ok(Self::ConfigUpgradeSetKey(Box::new( + ConfigUpgradeSetKey::read_xdr(r)?, + ))) + }), TypeVariant::LedgerUpgrade => r.with_limited_depth(|r| { Ok(Self::LedgerUpgrade(Box::new(LedgerUpgrade::read_xdr(r)?))) }), + TypeVariant::ConfigUpgradeSet => r.with_limited_depth(|r| { + Ok(Self::ConfigUpgradeSet(Box::new( + ConfigUpgradeSet::read_xdr(r)?, + ))) + }), TypeVariant::BucketEntryType => r.with_limited_depth(|r| { Ok(Self::BucketEntryType(Box::new(BucketEntryType::read_xdr( r, @@ -33976,6 +45171,44 @@ impl Type { TransactionMetaV2::read_xdr(r)?, ))) }), + TypeVariant::ContractEventType => r.with_limited_depth(|r| { + Ok(Self::ContractEventType(Box::new( + ContractEventType::read_xdr(r)?, + ))) + }), + TypeVariant::ContractEvent => r.with_limited_depth(|r| { + Ok(Self::ContractEvent(Box::new(ContractEvent::read_xdr(r)?))) + }), + TypeVariant::ContractEventBody => r.with_limited_depth(|r| { + Ok(Self::ContractEventBody(Box::new( + ContractEventBody::read_xdr(r)?, + ))) + }), + TypeVariant::ContractEventV0 => r.with_limited_depth(|r| { + Ok(Self::ContractEventV0(Box::new(ContractEventV0::read_xdr( + r, + )?))) + }), + TypeVariant::DiagnosticEvent => r.with_limited_depth(|r| { + Ok(Self::DiagnosticEvent(Box::new(DiagnosticEvent::read_xdr( + r, + )?))) + }), + TypeVariant::SorobanTransactionMeta => r.with_limited_depth(|r| { + Ok(Self::SorobanTransactionMeta(Box::new( + SorobanTransactionMeta::read_xdr(r)?, + ))) + }), + TypeVariant::TransactionMetaV3 => r.with_limited_depth(|r| { + Ok(Self::TransactionMetaV3(Box::new( + TransactionMetaV3::read_xdr(r)?, + ))) + }), + TypeVariant::InvokeHostFunctionSuccessPreImage => r.with_limited_depth(|r| { + Ok(Self::InvokeHostFunctionSuccessPreImage(Box::new( + InvokeHostFunctionSuccessPreImage::read_xdr(r)?, + ))) + }), TypeVariant::TransactionMeta => r.with_limited_depth(|r| { Ok(Self::TransactionMeta(Box::new(TransactionMeta::read_xdr( r, @@ -34001,6 +45234,11 @@ impl Type { LedgerCloseMetaV1::read_xdr(r)?, ))) }), + TypeVariant::LedgerCloseMetaV2 => r.with_limited_depth(|r| { + Ok(Self::LedgerCloseMetaV2(Box::new( + LedgerCloseMetaV2::read_xdr(r)?, + ))) + }), TypeVariant::LedgerCloseMeta => r.with_limited_depth(|r| { Ok(Self::LedgerCloseMeta(Box::new(LedgerCloseMeta::read_xdr( r, @@ -34015,6 +45253,11 @@ impl Type { TypeVariant::SendMore => { r.with_limited_depth(|r| Ok(Self::SendMore(Box::new(SendMore::read_xdr(r)?)))) } + TypeVariant::SendMoreExtended => r.with_limited_depth(|r| { + Ok(Self::SendMoreExtended(Box::new( + SendMoreExtended::read_xdr(r)?, + ))) + }), TypeVariant::AuthCert => { r.with_limited_depth(|r| Ok(Self::AuthCert(Box::new(AuthCert::read_xdr(r)?)))) } @@ -34044,6 +45287,11 @@ impl Type { SurveyMessageCommandType::read_xdr(r)?, ))) }), + TypeVariant::SurveyMessageResponseType => r.with_limited_depth(|r| { + Ok(Self::SurveyMessageResponseType(Box::new( + SurveyMessageResponseType::read_xdr(r)?, + ))) + }), TypeVariant::SurveyRequestMessage => r.with_limited_depth(|r| { Ok(Self::SurveyRequestMessage(Box::new( SurveyRequestMessage::read_xdr(r)?, @@ -34073,9 +45321,14 @@ impl Type { TypeVariant::PeerStatList => r.with_limited_depth(|r| { Ok(Self::PeerStatList(Box::new(PeerStatList::read_xdr(r)?))) }), - TypeVariant::TopologyResponseBody => r.with_limited_depth(|r| { - Ok(Self::TopologyResponseBody(Box::new( - TopologyResponseBody::read_xdr(r)?, + TypeVariant::TopologyResponseBodyV0 => r.with_limited_depth(|r| { + Ok(Self::TopologyResponseBodyV0(Box::new( + TopologyResponseBodyV0::read_xdr(r)?, + ))) + }), + TypeVariant::TopologyResponseBodyV1 => r.with_limited_depth(|r| { + Ok(Self::TopologyResponseBodyV1(Box::new( + TopologyResponseBodyV1::read_xdr(r)?, ))) }), TypeVariant::SurveyResponseBody => r.with_limited_depth(|r| { @@ -34235,6 +45488,89 @@ impl Type { LiquidityPoolWithdrawOp::read_xdr(r)?, ))) }), + TypeVariant::HostFunctionType => r.with_limited_depth(|r| { + Ok(Self::HostFunctionType(Box::new( + HostFunctionType::read_xdr(r)?, + ))) + }), + TypeVariant::ContractIdPreimageType => r.with_limited_depth(|r| { + Ok(Self::ContractIdPreimageType(Box::new( + ContractIdPreimageType::read_xdr(r)?, + ))) + }), + TypeVariant::ContractIdPreimage => r.with_limited_depth(|r| { + Ok(Self::ContractIdPreimage(Box::new( + ContractIdPreimage::read_xdr(r)?, + ))) + }), + TypeVariant::ContractIdPreimageFromAddress => r.with_limited_depth(|r| { + Ok(Self::ContractIdPreimageFromAddress(Box::new( + ContractIdPreimageFromAddress::read_xdr(r)?, + ))) + }), + TypeVariant::CreateContractArgs => r.with_limited_depth(|r| { + Ok(Self::CreateContractArgs(Box::new( + CreateContractArgs::read_xdr(r)?, + ))) + }), + TypeVariant::InvokeContractArgs => r.with_limited_depth(|r| { + Ok(Self::InvokeContractArgs(Box::new( + InvokeContractArgs::read_xdr(r)?, + ))) + }), + TypeVariant::HostFunction => r.with_limited_depth(|r| { + Ok(Self::HostFunction(Box::new(HostFunction::read_xdr(r)?))) + }), + TypeVariant::SorobanAuthorizedFunctionType => r.with_limited_depth(|r| { + Ok(Self::SorobanAuthorizedFunctionType(Box::new( + SorobanAuthorizedFunctionType::read_xdr(r)?, + ))) + }), + TypeVariant::SorobanAuthorizedFunction => r.with_limited_depth(|r| { + Ok(Self::SorobanAuthorizedFunction(Box::new( + SorobanAuthorizedFunction::read_xdr(r)?, + ))) + }), + TypeVariant::SorobanAuthorizedInvocation => r.with_limited_depth(|r| { + Ok(Self::SorobanAuthorizedInvocation(Box::new( + SorobanAuthorizedInvocation::read_xdr(r)?, + ))) + }), + TypeVariant::SorobanAddressCredentials => r.with_limited_depth(|r| { + Ok(Self::SorobanAddressCredentials(Box::new( + SorobanAddressCredentials::read_xdr(r)?, + ))) + }), + TypeVariant::SorobanCredentialsType => r.with_limited_depth(|r| { + Ok(Self::SorobanCredentialsType(Box::new( + SorobanCredentialsType::read_xdr(r)?, + ))) + }), + TypeVariant::SorobanCredentials => r.with_limited_depth(|r| { + Ok(Self::SorobanCredentials(Box::new( + SorobanCredentials::read_xdr(r)?, + ))) + }), + TypeVariant::SorobanAuthorizationEntry => r.with_limited_depth(|r| { + Ok(Self::SorobanAuthorizationEntry(Box::new( + SorobanAuthorizationEntry::read_xdr(r)?, + ))) + }), + TypeVariant::InvokeHostFunctionOp => r.with_limited_depth(|r| { + Ok(Self::InvokeHostFunctionOp(Box::new( + InvokeHostFunctionOp::read_xdr(r)?, + ))) + }), + TypeVariant::BumpFootprintExpirationOp => r.with_limited_depth(|r| { + Ok(Self::BumpFootprintExpirationOp(Box::new( + BumpFootprintExpirationOp::read_xdr(r)?, + ))) + }), + TypeVariant::RestoreFootprintOp => r.with_limited_depth(|r| { + Ok(Self::RestoreFootprintOp(Box::new( + RestoreFootprintOp::read_xdr(r)?, + ))) + }), TypeVariant::Operation => { r.with_limited_depth(|r| Ok(Self::Operation(Box::new(Operation::read_xdr(r)?)))) } @@ -34254,6 +45590,16 @@ impl Type { HashIdPreimageRevokeId::read_xdr(r)?, ))) }), + TypeVariant::HashIdPreimageContractId => r.with_limited_depth(|r| { + Ok(Self::HashIdPreimageContractId(Box::new( + HashIdPreimageContractId::read_xdr(r)?, + ))) + }), + TypeVariant::HashIdPreimageSorobanAuthorization => r.with_limited_depth(|r| { + Ok(Self::HashIdPreimageSorobanAuthorization(Box::new( + HashIdPreimageSorobanAuthorization::read_xdr(r)?, + ))) + }), TypeVariant::MemoType => { r.with_limited_depth(|r| Ok(Self::MemoType(Box::new(MemoType::read_xdr(r)?)))) } @@ -34279,6 +45625,21 @@ impl Type { TypeVariant::Preconditions => r.with_limited_depth(|r| { Ok(Self::Preconditions(Box::new(Preconditions::read_xdr(r)?))) }), + TypeVariant::LedgerFootprint => r.with_limited_depth(|r| { + Ok(Self::LedgerFootprint(Box::new(LedgerFootprint::read_xdr( + r, + )?))) + }), + TypeVariant::SorobanResources => r.with_limited_depth(|r| { + Ok(Self::SorobanResources(Box::new( + SorobanResources::read_xdr(r)?, + ))) + }), + TypeVariant::SorobanTransactionData => r.with_limited_depth(|r| { + Ok(Self::SorobanTransactionData(Box::new( + SorobanTransactionData::read_xdr(r)?, + ))) + }), TypeVariant::TransactionV0 => r.with_limited_depth(|r| { Ok(Self::TransactionV0(Box::new(TransactionV0::read_xdr(r)?))) }), @@ -34620,6 +45981,36 @@ impl Type { LiquidityPoolWithdrawResult::read_xdr(r)?, ))) }), + TypeVariant::InvokeHostFunctionResultCode => r.with_limited_depth(|r| { + Ok(Self::InvokeHostFunctionResultCode(Box::new( + InvokeHostFunctionResultCode::read_xdr(r)?, + ))) + }), + TypeVariant::InvokeHostFunctionResult => r.with_limited_depth(|r| { + Ok(Self::InvokeHostFunctionResult(Box::new( + InvokeHostFunctionResult::read_xdr(r)?, + ))) + }), + TypeVariant::BumpFootprintExpirationResultCode => r.with_limited_depth(|r| { + Ok(Self::BumpFootprintExpirationResultCode(Box::new( + BumpFootprintExpirationResultCode::read_xdr(r)?, + ))) + }), + TypeVariant::BumpFootprintExpirationResult => r.with_limited_depth(|r| { + Ok(Self::BumpFootprintExpirationResult(Box::new( + BumpFootprintExpirationResult::read_xdr(r)?, + ))) + }), + TypeVariant::RestoreFootprintResultCode => r.with_limited_depth(|r| { + Ok(Self::RestoreFootprintResultCode(Box::new( + RestoreFootprintResultCode::read_xdr(r)?, + ))) + }), + TypeVariant::RestoreFootprintResult => r.with_limited_depth(|r| { + Ok(Self::RestoreFootprintResult(Box::new( + RestoreFootprintResult::read_xdr(r)?, + ))) + }), TypeVariant::OperationResultCode => r.with_limited_depth(|r| { Ok(Self::OperationResultCode(Box::new( OperationResultCode::read_xdr(r)?, @@ -34693,6 +46084,12 @@ impl Type { TypeVariant::Int64 => { r.with_limited_depth(|r| Ok(Self::Int64(Box::new(Int64::read_xdr(r)?)))) } + TypeVariant::TimePoint => { + r.with_limited_depth(|r| Ok(Self::TimePoint(Box::new(TimePoint::read_xdr(r)?)))) + } + TypeVariant::Duration => { + r.with_limited_depth(|r| Ok(Self::Duration(Box::new(Duration::read_xdr(r)?)))) + } TypeVariant::ExtensionPoint => r.with_limited_depth(|r| { Ok(Self::ExtensionPoint(Box::new(ExtensionPoint::read_xdr(r)?))) }), @@ -34725,6 +46122,9 @@ impl Type { TypeVariant::NodeId => { r.with_limited_depth(|r| Ok(Self::NodeId(Box::new(NodeId::read_xdr(r)?)))) } + TypeVariant::AccountId => { + r.with_limited_depth(|r| Ok(Self::AccountId(Box::new(AccountId::read_xdr(r)?)))) + } TypeVariant::Curve25519Secret => r.with_limited_depth(|r| { Ok(Self::Curve25519Secret(Box::new( Curve25519Secret::read_xdr(r)?, @@ -34830,6 +46230,276 @@ impl Type { ReadXdrIter::<_, ScpQuorumSet>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::ScpQuorumSet(Box::new(t)))), ), + TypeVariant::ConfigSettingContractExecutionLanesV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractExecutionLanesV0>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractExecutionLanesV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractComputeV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractComputeV0>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractComputeV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractLedgerCostV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractLedgerCostV0>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractLedgerCostV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractHistoricalDataV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractHistoricalDataV0>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractHistoricalDataV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractEventsV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractEventsV0>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractEventsV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractBandwidthV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractBandwidthV0>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractBandwidthV0(Box::new(t)))), + ), + TypeVariant::ContractCostType => Box::new( + ReadXdrIter::<_, ContractCostType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostType(Box::new(t)))), + ), + TypeVariant::ContractCostParamEntry => Box::new( + ReadXdrIter::<_, ContractCostParamEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostParamEntry(Box::new(t)))), + ), + TypeVariant::StateExpirationSettings => Box::new( + ReadXdrIter::<_, StateExpirationSettings>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::StateExpirationSettings(Box::new(t)))), + ), + TypeVariant::EvictionIterator => Box::new( + ReadXdrIter::<_, EvictionIterator>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::EvictionIterator(Box::new(t)))), + ), + TypeVariant::ContractCostParams => Box::new( + ReadXdrIter::<_, ContractCostParams>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostParams(Box::new(t)))), + ), + TypeVariant::ConfigSettingId => Box::new( + ReadXdrIter::<_, ConfigSettingId>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingId(Box::new(t)))), + ), + TypeVariant::ConfigSettingEntry => Box::new( + ReadXdrIter::<_, ConfigSettingEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingEntry(Box::new(t)))), + ), + TypeVariant::ScEnvMetaKind => Box::new( + ReadXdrIter::<_, ScEnvMetaKind>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScEnvMetaKind(Box::new(t)))), + ), + TypeVariant::ScEnvMetaEntry => Box::new( + ReadXdrIter::<_, ScEnvMetaEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScEnvMetaEntry(Box::new(t)))), + ), + TypeVariant::ScMetaV0 => Box::new( + ReadXdrIter::<_, ScMetaV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaV0(Box::new(t)))), + ), + TypeVariant::ScMetaKind => Box::new( + ReadXdrIter::<_, ScMetaKind>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaKind(Box::new(t)))), + ), + TypeVariant::ScMetaEntry => Box::new( + ReadXdrIter::<_, ScMetaEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaEntry(Box::new(t)))), + ), + TypeVariant::ScSpecType => Box::new( + ReadXdrIter::<_, ScSpecType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecType(Box::new(t)))), + ), + TypeVariant::ScSpecTypeOption => Box::new( + ReadXdrIter::<_, ScSpecTypeOption>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeOption(Box::new(t)))), + ), + TypeVariant::ScSpecTypeResult => Box::new( + ReadXdrIter::<_, ScSpecTypeResult>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeResult(Box::new(t)))), + ), + TypeVariant::ScSpecTypeVec => Box::new( + ReadXdrIter::<_, ScSpecTypeVec>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeVec(Box::new(t)))), + ), + TypeVariant::ScSpecTypeMap => Box::new( + ReadXdrIter::<_, ScSpecTypeMap>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeMap(Box::new(t)))), + ), + TypeVariant::ScSpecTypeTuple => Box::new( + ReadXdrIter::<_, ScSpecTypeTuple>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeTuple(Box::new(t)))), + ), + TypeVariant::ScSpecTypeBytesN => Box::new( + ReadXdrIter::<_, ScSpecTypeBytesN>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t)))), + ), + TypeVariant::ScSpecTypeUdt => Box::new( + ReadXdrIter::<_, ScSpecTypeUdt>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t)))), + ), + TypeVariant::ScSpecTypeDef => Box::new( + ReadXdrIter::<_, ScSpecTypeDef>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeDef(Box::new(t)))), + ), + TypeVariant::ScSpecUdtStructFieldV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtStructFieldV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtStructFieldV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtStructV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtStructV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtStructV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseVoidV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseVoidV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseVoidV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseTupleV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseTupleV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseTupleV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseV0Kind => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseV0Kind>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseV0Kind(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtEnumCaseV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtEnumCaseV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtEnumCaseV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtEnumV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtEnumV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtEnumV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtErrorEnumCaseV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtErrorEnumCaseV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtErrorEnumCaseV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtErrorEnumV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtErrorEnumV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtErrorEnumV0(Box::new(t)))), + ), + TypeVariant::ScSpecFunctionInputV0 => Box::new( + ReadXdrIter::<_, ScSpecFunctionInputV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecFunctionInputV0(Box::new(t)))), + ), + TypeVariant::ScSpecFunctionV0 => Box::new( + ReadXdrIter::<_, ScSpecFunctionV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecFunctionV0(Box::new(t)))), + ), + TypeVariant::ScSpecEntryKind => Box::new( + ReadXdrIter::<_, ScSpecEntryKind>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecEntryKind(Box::new(t)))), + ), + TypeVariant::ScSpecEntry => Box::new( + ReadXdrIter::<_, ScSpecEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecEntry(Box::new(t)))), + ), + TypeVariant::ScValType => Box::new( + ReadXdrIter::<_, ScValType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScValType(Box::new(t)))), + ), + TypeVariant::ScErrorType => Box::new( + ReadXdrIter::<_, ScErrorType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScErrorType(Box::new(t)))), + ), + TypeVariant::ScErrorCode => Box::new( + ReadXdrIter::<_, ScErrorCode>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScErrorCode(Box::new(t)))), + ), + TypeVariant::ScError => Box::new( + ReadXdrIter::<_, ScError>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScError(Box::new(t)))), + ), + TypeVariant::UInt128Parts => Box::new( + ReadXdrIter::<_, UInt128Parts>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::UInt128Parts(Box::new(t)))), + ), + TypeVariant::Int128Parts => Box::new( + ReadXdrIter::<_, Int128Parts>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::Int128Parts(Box::new(t)))), + ), + TypeVariant::UInt256Parts => Box::new( + ReadXdrIter::<_, UInt256Parts>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::UInt256Parts(Box::new(t)))), + ), + TypeVariant::Int256Parts => Box::new( + ReadXdrIter::<_, Int256Parts>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::Int256Parts(Box::new(t)))), + ), + TypeVariant::ContractExecutableType => Box::new( + ReadXdrIter::<_, ContractExecutableType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractExecutableType(Box::new(t)))), + ), + TypeVariant::ContractExecutable => Box::new( + ReadXdrIter::<_, ContractExecutable>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractExecutable(Box::new(t)))), + ), + TypeVariant::ScAddressType => Box::new( + ReadXdrIter::<_, ScAddressType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScAddressType(Box::new(t)))), + ), + TypeVariant::ScAddress => Box::new( + ReadXdrIter::<_, ScAddress>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScAddress(Box::new(t)))), + ), + TypeVariant::ScVec => Box::new( + ReadXdrIter::<_, ScVec>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScVec(Box::new(t)))), + ), + TypeVariant::ScMap => Box::new( + ReadXdrIter::<_, ScMap>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMap(Box::new(t)))), + ), + TypeVariant::ScBytes => Box::new( + ReadXdrIter::<_, ScBytes>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScBytes(Box::new(t)))), + ), + TypeVariant::ScString => Box::new( + ReadXdrIter::<_, ScString>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScString(Box::new(t)))), + ), + TypeVariant::ScSymbol => Box::new( + ReadXdrIter::<_, ScSymbol>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSymbol(Box::new(t)))), + ), + TypeVariant::ScNonceKey => Box::new( + ReadXdrIter::<_, ScNonceKey>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScNonceKey(Box::new(t)))), + ), + TypeVariant::ScContractInstance => Box::new( + ReadXdrIter::<_, ScContractInstance>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScContractInstance(Box::new(t)))), + ), + TypeVariant::ScVal => Box::new( + ReadXdrIter::<_, ScVal>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScVal(Box::new(t)))), + ), + TypeVariant::ScMapEntry => Box::new( + ReadXdrIter::<_, ScMapEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMapEntry(Box::new(t)))), + ), TypeVariant::StoredTransactionSet => Box::new( ReadXdrIter::<_, StoredTransactionSet>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::StoredTransactionSet(Box::new(t)))), @@ -34846,10 +46516,6 @@ impl Type { ReadXdrIter::<_, PersistedScpState>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::PersistedScpState(Box::new(t)))), ), - TypeVariant::AccountId => Box::new( - ReadXdrIter::<_, AccountId>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::AccountId(Box::new(t)))), - ), TypeVariant::Thresholds => Box::new( ReadXdrIter::<_, Thresholds>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Thresholds(Box::new(t)))), @@ -34866,14 +46532,6 @@ impl Type { ReadXdrIter::<_, SequenceNumber>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::SequenceNumber(Box::new(t)))), ), - TypeVariant::TimePoint => Box::new( - ReadXdrIter::<_, TimePoint>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::TimePoint(Box::new(t)))), - ), - TypeVariant::Duration => Box::new( - ReadXdrIter::<_, Duration>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::Duration(Box::new(t)))), - ), TypeVariant::DataValue => Box::new( ReadXdrIter::<_, DataValue>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::DataValue(Box::new(t)))), @@ -35101,6 +46759,22 @@ impl Type { ) .map(|r| r.map(|t| Self::LiquidityPoolEntryConstantProduct(Box::new(t)))), ), + TypeVariant::ContractDataDurability => Box::new( + ReadXdrIter::<_, ContractDataDurability>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractDataDurability(Box::new(t)))), + ), + TypeVariant::ContractDataEntry => Box::new( + ReadXdrIter::<_, ContractDataEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractDataEntry(Box::new(t)))), + ), + TypeVariant::ContractCodeEntry => Box::new( + ReadXdrIter::<_, ContractCodeEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCodeEntry(Box::new(t)))), + ), + TypeVariant::ExpirationEntry => Box::new( + ReadXdrIter::<_, ExpirationEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ExpirationEntry(Box::new(t)))), + ), TypeVariant::LedgerEntryExtensionV1 => Box::new( ReadXdrIter::<_, LedgerEntryExtensionV1>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerEntryExtensionV1(Box::new(t)))), @@ -35149,6 +46823,22 @@ impl Type { ReadXdrIter::<_, LedgerKeyLiquidityPool>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerKeyLiquidityPool(Box::new(t)))), ), + TypeVariant::LedgerKeyContractData => Box::new( + ReadXdrIter::<_, LedgerKeyContractData>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyContractData(Box::new(t)))), + ), + TypeVariant::LedgerKeyContractCode => Box::new( + ReadXdrIter::<_, LedgerKeyContractCode>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyContractCode(Box::new(t)))), + ), + TypeVariant::LedgerKeyConfigSetting => Box::new( + ReadXdrIter::<_, LedgerKeyConfigSetting>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyConfigSetting(Box::new(t)))), + ), + TypeVariant::LedgerKeyExpiration => Box::new( + ReadXdrIter::<_, LedgerKeyExpiration>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyExpiration(Box::new(t)))), + ), TypeVariant::EnvelopeType => Box::new( ReadXdrIter::<_, EnvelopeType>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::EnvelopeType(Box::new(t)))), @@ -35197,10 +46887,18 @@ impl Type { ReadXdrIter::<_, LedgerUpgradeType>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerUpgradeType(Box::new(t)))), ), + TypeVariant::ConfigUpgradeSetKey => Box::new( + ReadXdrIter::<_, ConfigUpgradeSetKey>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigUpgradeSetKey(Box::new(t)))), + ), TypeVariant::LedgerUpgrade => Box::new( ReadXdrIter::<_, LedgerUpgrade>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerUpgrade(Box::new(t)))), ), + TypeVariant::ConfigUpgradeSet => Box::new( + ReadXdrIter::<_, ConfigUpgradeSet>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigUpgradeSet(Box::new(t)))), + ), TypeVariant::BucketEntryType => Box::new( ReadXdrIter::<_, BucketEntryType>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::BucketEntryType(Box::new(t)))), @@ -35322,6 +47020,41 @@ impl Type { ReadXdrIter::<_, TransactionMetaV2>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionMetaV2(Box::new(t)))), ), + TypeVariant::ContractEventType => Box::new( + ReadXdrIter::<_, ContractEventType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventType(Box::new(t)))), + ), + TypeVariant::ContractEvent => Box::new( + ReadXdrIter::<_, ContractEvent>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEvent(Box::new(t)))), + ), + TypeVariant::ContractEventBody => Box::new( + ReadXdrIter::<_, ContractEventBody>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventBody(Box::new(t)))), + ), + TypeVariant::ContractEventV0 => Box::new( + ReadXdrIter::<_, ContractEventV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventV0(Box::new(t)))), + ), + TypeVariant::DiagnosticEvent => Box::new( + ReadXdrIter::<_, DiagnosticEvent>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::DiagnosticEvent(Box::new(t)))), + ), + TypeVariant::SorobanTransactionMeta => Box::new( + ReadXdrIter::<_, SorobanTransactionMeta>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanTransactionMeta(Box::new(t)))), + ), + TypeVariant::TransactionMetaV3 => Box::new( + ReadXdrIter::<_, TransactionMetaV3>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::TransactionMetaV3(Box::new(t)))), + ), + TypeVariant::InvokeHostFunctionSuccessPreImage => Box::new( + ReadXdrIter::<_, InvokeHostFunctionSuccessPreImage>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::InvokeHostFunctionSuccessPreImage(Box::new(t)))), + ), TypeVariant::TransactionMeta => Box::new( ReadXdrIter::<_, TransactionMeta>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionMeta(Box::new(t)))), @@ -35342,6 +47075,10 @@ impl Type { ReadXdrIter::<_, LedgerCloseMetaV1>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerCloseMetaV1(Box::new(t)))), ), + TypeVariant::LedgerCloseMetaV2 => Box::new( + ReadXdrIter::<_, LedgerCloseMetaV2>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerCloseMetaV2(Box::new(t)))), + ), TypeVariant::LedgerCloseMeta => Box::new( ReadXdrIter::<_, LedgerCloseMeta>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerCloseMeta(Box::new(t)))), @@ -35358,6 +47095,10 @@ impl Type { ReadXdrIter::<_, SendMore>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::SendMore(Box::new(t)))), ), + TypeVariant::SendMoreExtended => Box::new( + ReadXdrIter::<_, SendMoreExtended>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SendMoreExtended(Box::new(t)))), + ), TypeVariant::AuthCert => Box::new( ReadXdrIter::<_, AuthCert>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::AuthCert(Box::new(t)))), @@ -35394,6 +47135,10 @@ impl Type { ReadXdrIter::<_, SurveyMessageCommandType>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::SurveyMessageCommandType(Box::new(t)))), ), + TypeVariant::SurveyMessageResponseType => Box::new( + ReadXdrIter::<_, SurveyMessageResponseType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SurveyMessageResponseType(Box::new(t)))), + ), TypeVariant::SurveyRequestMessage => Box::new( ReadXdrIter::<_, SurveyRequestMessage>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::SurveyRequestMessage(Box::new(t)))), @@ -35422,9 +47167,13 @@ impl Type { ReadXdrIter::<_, PeerStatList>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::PeerStatList(Box::new(t)))), ), - TypeVariant::TopologyResponseBody => Box::new( - ReadXdrIter::<_, TopologyResponseBody>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::TopologyResponseBody(Box::new(t)))), + TypeVariant::TopologyResponseBodyV0 => Box::new( + ReadXdrIter::<_, TopologyResponseBodyV0>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::TopologyResponseBodyV0(Box::new(t)))), + ), + TypeVariant::TopologyResponseBodyV1 => Box::new( + ReadXdrIter::<_, TopologyResponseBodyV1>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::TopologyResponseBodyV1(Box::new(t)))), ), TypeVariant::SurveyResponseBody => Box::new( ReadXdrIter::<_, SurveyResponseBody>::new(&mut r.inner, r.depth_remaining) @@ -35577,6 +47326,80 @@ impl Type { ReadXdrIter::<_, LiquidityPoolWithdrawOp>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LiquidityPoolWithdrawOp(Box::new(t)))), ), + TypeVariant::HostFunctionType => Box::new( + ReadXdrIter::<_, HostFunctionType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::HostFunctionType(Box::new(t)))), + ), + TypeVariant::ContractIdPreimageType => Box::new( + ReadXdrIter::<_, ContractIdPreimageType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractIdPreimageType(Box::new(t)))), + ), + TypeVariant::ContractIdPreimage => Box::new( + ReadXdrIter::<_, ContractIdPreimage>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractIdPreimage(Box::new(t)))), + ), + TypeVariant::ContractIdPreimageFromAddress => Box::new( + ReadXdrIter::<_, ContractIdPreimageFromAddress>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ContractIdPreimageFromAddress(Box::new(t)))), + ), + TypeVariant::CreateContractArgs => Box::new( + ReadXdrIter::<_, CreateContractArgs>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::CreateContractArgs(Box::new(t)))), + ), + TypeVariant::InvokeContractArgs => Box::new( + ReadXdrIter::<_, InvokeContractArgs>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeContractArgs(Box::new(t)))), + ), + TypeVariant::HostFunction => Box::new( + ReadXdrIter::<_, HostFunction>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::HostFunction(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizedFunctionType => Box::new( + ReadXdrIter::<_, SorobanAuthorizedFunctionType>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanAuthorizedFunctionType(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizedFunction => Box::new( + ReadXdrIter::<_, SorobanAuthorizedFunction>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAuthorizedFunction(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizedInvocation => Box::new( + ReadXdrIter::<_, SorobanAuthorizedInvocation>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAuthorizedInvocation(Box::new(t)))), + ), + TypeVariant::SorobanAddressCredentials => Box::new( + ReadXdrIter::<_, SorobanAddressCredentials>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAddressCredentials(Box::new(t)))), + ), + TypeVariant::SorobanCredentialsType => Box::new( + ReadXdrIter::<_, SorobanCredentialsType>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanCredentialsType(Box::new(t)))), + ), + TypeVariant::SorobanCredentials => Box::new( + ReadXdrIter::<_, SorobanCredentials>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanCredentials(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizationEntry => Box::new( + ReadXdrIter::<_, SorobanAuthorizationEntry>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAuthorizationEntry(Box::new(t)))), + ), + TypeVariant::InvokeHostFunctionOp => Box::new( + ReadXdrIter::<_, InvokeHostFunctionOp>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeHostFunctionOp(Box::new(t)))), + ), + TypeVariant::BumpFootprintExpirationOp => Box::new( + ReadXdrIter::<_, BumpFootprintExpirationOp>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::BumpFootprintExpirationOp(Box::new(t)))), + ), + TypeVariant::RestoreFootprintOp => Box::new( + ReadXdrIter::<_, RestoreFootprintOp>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::RestoreFootprintOp(Box::new(t)))), + ), TypeVariant::Operation => Box::new( ReadXdrIter::<_, Operation>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Operation(Box::new(t)))), @@ -35597,6 +47420,17 @@ impl Type { ReadXdrIter::<_, HashIdPreimageRevokeId>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::HashIdPreimageRevokeId(Box::new(t)))), ), + TypeVariant::HashIdPreimageContractId => Box::new( + ReadXdrIter::<_, HashIdPreimageContractId>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::HashIdPreimageContractId(Box::new(t)))), + ), + TypeVariant::HashIdPreimageSorobanAuthorization => Box::new( + ReadXdrIter::<_, HashIdPreimageSorobanAuthorization>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::HashIdPreimageSorobanAuthorization(Box::new(t)))), + ), TypeVariant::MemoType => Box::new( ReadXdrIter::<_, MemoType>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::MemoType(Box::new(t)))), @@ -35625,6 +47459,18 @@ impl Type { ReadXdrIter::<_, Preconditions>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Preconditions(Box::new(t)))), ), + TypeVariant::LedgerFootprint => Box::new( + ReadXdrIter::<_, LedgerFootprint>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerFootprint(Box::new(t)))), + ), + TypeVariant::SorobanResources => Box::new( + ReadXdrIter::<_, SorobanResources>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanResources(Box::new(t)))), + ), + TypeVariant::SorobanTransactionData => Box::new( + ReadXdrIter::<_, SorobanTransactionData>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanTransactionData(Box::new(t)))), + ), TypeVariant::TransactionV0 => Box::new( ReadXdrIter::<_, TransactionV0>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionV0(Box::new(t)))), @@ -35965,6 +47811,39 @@ impl Type { ReadXdrIter::<_, LiquidityPoolWithdrawResult>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LiquidityPoolWithdrawResult(Box::new(t)))), ), + TypeVariant::InvokeHostFunctionResultCode => Box::new( + ReadXdrIter::<_, InvokeHostFunctionResultCode>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::InvokeHostFunctionResultCode(Box::new(t)))), + ), + TypeVariant::InvokeHostFunctionResult => Box::new( + ReadXdrIter::<_, InvokeHostFunctionResult>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeHostFunctionResult(Box::new(t)))), + ), + TypeVariant::BumpFootprintExpirationResultCode => Box::new( + ReadXdrIter::<_, BumpFootprintExpirationResultCode>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::BumpFootprintExpirationResultCode(Box::new(t)))), + ), + TypeVariant::BumpFootprintExpirationResult => Box::new( + ReadXdrIter::<_, BumpFootprintExpirationResult>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::BumpFootprintExpirationResult(Box::new(t)))), + ), + TypeVariant::RestoreFootprintResultCode => Box::new( + ReadXdrIter::<_, RestoreFootprintResultCode>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::RestoreFootprintResultCode(Box::new(t)))), + ), + TypeVariant::RestoreFootprintResult => Box::new( + ReadXdrIter::<_, RestoreFootprintResult>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::RestoreFootprintResult(Box::new(t)))), + ), TypeVariant::OperationResultCode => Box::new( ReadXdrIter::<_, OperationResultCode>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::OperationResultCode(Box::new(t)))), @@ -36036,6 +47915,14 @@ impl Type { ReadXdrIter::<_, Int64>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Int64(Box::new(t)))), ), + TypeVariant::TimePoint => Box::new( + ReadXdrIter::<_, TimePoint>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::TimePoint(Box::new(t)))), + ), + TypeVariant::Duration => Box::new( + ReadXdrIter::<_, Duration>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::Duration(Box::new(t)))), + ), TypeVariant::ExtensionPoint => Box::new( ReadXdrIter::<_, ExtensionPoint>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::ExtensionPoint(Box::new(t)))), @@ -36079,6 +47966,10 @@ impl Type { ReadXdrIter::<_, NodeId>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::NodeId(Box::new(t)))), ), + TypeVariant::AccountId => Box::new( + ReadXdrIter::<_, AccountId>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::AccountId(Box::new(t)))), + ), TypeVariant::Curve25519Secret => Box::new( ReadXdrIter::<_, Curve25519Secret>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Curve25519Secret(Box::new(t)))), @@ -36152,6 +48043,303 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::ScpQuorumSet(Box::new(t.0)))), ), + TypeVariant::ConfigSettingContractExecutionLanesV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractExecutionLanesV0(Box::new(t.0)))), + ), + TypeVariant::ConfigSettingContractComputeV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractComputeV0(Box::new(t.0)))), + ), + TypeVariant::ConfigSettingContractLedgerCostV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractLedgerCostV0(Box::new(t.0)))), + ), + TypeVariant::ConfigSettingContractHistoricalDataV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractHistoricalDataV0(Box::new(t.0)))), + ), + TypeVariant::ConfigSettingContractEventsV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractEventsV0(Box::new(t.0)))), + ), + TypeVariant::ConfigSettingContractBandwidthV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractBandwidthV0(Box::new(t.0)))), + ), + TypeVariant::ContractCostType => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostType(Box::new(t.0)))), + ), + TypeVariant::ContractCostParamEntry => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ContractCostParamEntry(Box::new(t.0)))), + ), + TypeVariant::StateExpirationSettings => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::StateExpirationSettings(Box::new(t.0)))), + ), + TypeVariant::EvictionIterator => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::EvictionIterator(Box::new(t.0)))), + ), + TypeVariant::ContractCostParams => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostParams(Box::new(t.0)))), + ), + TypeVariant::ConfigSettingId => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingId(Box::new(t.0)))), + ), + TypeVariant::ConfigSettingEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingEntry(Box::new(t.0)))), + ), + TypeVariant::ScEnvMetaKind => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScEnvMetaKind(Box::new(t.0)))), + ), + TypeVariant::ScEnvMetaEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScEnvMetaEntry(Box::new(t.0)))), + ), + TypeVariant::ScMetaV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaV0(Box::new(t.0)))), + ), + TypeVariant::ScMetaKind => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaKind(Box::new(t.0)))), + ), + TypeVariant::ScMetaEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaEntry(Box::new(t.0)))), + ), + TypeVariant::ScSpecType => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecType(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeOption => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeOption(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeResult => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeResult(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeVec => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeVec(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeMap => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeMap(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeTuple => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeTuple(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeBytesN => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeUdt => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t.0)))), + ), + TypeVariant::ScSpecTypeDef => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeDef(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtStructFieldV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ScSpecUdtStructFieldV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtStructV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtStructV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtUnionCaseVoidV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseVoidV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtUnionCaseTupleV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseTupleV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtUnionCaseV0Kind => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseV0Kind(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtUnionCaseV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtUnionV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtEnumCaseV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtEnumCaseV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtEnumV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtEnumV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtErrorEnumCaseV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ScSpecUdtErrorEnumCaseV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecUdtErrorEnumV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtErrorEnumV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecFunctionInputV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ScSpecFunctionInputV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecFunctionV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecFunctionV0(Box::new(t.0)))), + ), + TypeVariant::ScSpecEntryKind => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecEntryKind(Box::new(t.0)))), + ), + TypeVariant::ScSpecEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecEntry(Box::new(t.0)))), + ), + TypeVariant::ScValType => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScValType(Box::new(t.0)))), + ), + TypeVariant::ScErrorType => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScErrorType(Box::new(t.0)))), + ), + TypeVariant::ScErrorCode => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScErrorCode(Box::new(t.0)))), + ), + TypeVariant::ScError => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScError(Box::new(t.0)))), + ), + TypeVariant::UInt128Parts => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::UInt128Parts(Box::new(t.0)))), + ), + TypeVariant::Int128Parts => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::Int128Parts(Box::new(t.0)))), + ), + TypeVariant::UInt256Parts => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::UInt256Parts(Box::new(t.0)))), + ), + TypeVariant::Int256Parts => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::Int256Parts(Box::new(t.0)))), + ), + TypeVariant::ContractExecutableType => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ContractExecutableType(Box::new(t.0)))), + ), + TypeVariant::ContractExecutable => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractExecutable(Box::new(t.0)))), + ), + TypeVariant::ScAddressType => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScAddressType(Box::new(t.0)))), + ), + TypeVariant::ScAddress => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScAddress(Box::new(t.0)))), + ), + TypeVariant::ScVec => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScVec(Box::new(t.0)))), + ), + TypeVariant::ScMap => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMap(Box::new(t.0)))), + ), + TypeVariant::ScBytes => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScBytes(Box::new(t.0)))), + ), + TypeVariant::ScString => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScString(Box::new(t.0)))), + ), + TypeVariant::ScSymbol => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSymbol(Box::new(t.0)))), + ), + TypeVariant::ScNonceKey => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScNonceKey(Box::new(t.0)))), + ), + TypeVariant::ScContractInstance => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScContractInstance(Box::new(t.0)))), + ), + TypeVariant::ScVal => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScVal(Box::new(t.0)))), + ), + TypeVariant::ScMapEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMapEntry(Box::new(t.0)))), + ), TypeVariant::StoredTransactionSet => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::StoredTransactionSet(Box::new(t.0)))), @@ -36168,10 +48356,6 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::PersistedScpState(Box::new(t.0)))), ), - TypeVariant::AccountId => Box::new( - ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::AccountId(Box::new(t.0)))), - ), TypeVariant::Thresholds => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Thresholds(Box::new(t.0)))), @@ -36188,14 +48372,6 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::SequenceNumber(Box::new(t.0)))), ), - TypeVariant::TimePoint => Box::new( - ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::TimePoint(Box::new(t.0)))), - ), - TypeVariant::Duration => Box::new( - ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::Duration(Box::new(t.0)))), - ), TypeVariant::DataValue => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::DataValue(Box::new(t.0)))), @@ -36459,6 +48635,25 @@ impl Type { ) .map(|r| r.map(|t| Self::LiquidityPoolEntryConstantProduct(Box::new(t.0)))), ), + TypeVariant::ContractDataDurability => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ContractDataDurability(Box::new(t.0)))), + ), + TypeVariant::ContractDataEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractDataEntry(Box::new(t.0)))), + ), + TypeVariant::ContractCodeEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCodeEntry(Box::new(t.0)))), + ), + TypeVariant::ExpirationEntry => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ExpirationEntry(Box::new(t.0)))), + ), TypeVariant::LedgerEntryExtensionV1 => Box::new( ReadXdrIter::<_, Frame>::new( &mut r.inner, @@ -36519,6 +48714,31 @@ impl Type { ) .map(|r| r.map(|t| Self::LedgerKeyLiquidityPool(Box::new(t.0)))), ), + TypeVariant::LedgerKeyContractData => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::LedgerKeyContractData(Box::new(t.0)))), + ), + TypeVariant::LedgerKeyContractCode => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::LedgerKeyContractCode(Box::new(t.0)))), + ), + TypeVariant::LedgerKeyConfigSetting => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::LedgerKeyConfigSetting(Box::new(t.0)))), + ), + TypeVariant::LedgerKeyExpiration => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyExpiration(Box::new(t.0)))), + ), TypeVariant::EnvelopeType => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::EnvelopeType(Box::new(t.0)))), @@ -36576,10 +48796,18 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerUpgradeType(Box::new(t.0)))), ), + TypeVariant::ConfigUpgradeSetKey => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigUpgradeSetKey(Box::new(t.0)))), + ), TypeVariant::LedgerUpgrade => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerUpgrade(Box::new(t.0)))), ), + TypeVariant::ConfigUpgradeSet => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigUpgradeSet(Box::new(t.0)))), + ), TypeVariant::BucketEntryType => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::BucketEntryType(Box::new(t.0)))), @@ -36722,6 +48950,44 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionMetaV2(Box::new(t.0)))), ), + TypeVariant::ContractEventType => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventType(Box::new(t.0)))), + ), + TypeVariant::ContractEvent => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEvent(Box::new(t.0)))), + ), + TypeVariant::ContractEventBody => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventBody(Box::new(t.0)))), + ), + TypeVariant::ContractEventV0 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventV0(Box::new(t.0)))), + ), + TypeVariant::DiagnosticEvent => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::DiagnosticEvent(Box::new(t.0)))), + ), + TypeVariant::SorobanTransactionMeta => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanTransactionMeta(Box::new(t.0)))), + ), + TypeVariant::TransactionMetaV3 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::TransactionMetaV3(Box::new(t.0)))), + ), + TypeVariant::InvokeHostFunctionSuccessPreImage => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::InvokeHostFunctionSuccessPreImage(Box::new(t.0)))), + ), TypeVariant::TransactionMeta => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionMeta(Box::new(t.0)))), @@ -36745,6 +49011,10 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerCloseMetaV1(Box::new(t.0)))), ), + TypeVariant::LedgerCloseMetaV2 => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerCloseMetaV2(Box::new(t.0)))), + ), TypeVariant::LedgerCloseMeta => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerCloseMeta(Box::new(t.0)))), @@ -36761,6 +49031,10 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::SendMore(Box::new(t.0)))), ), + TypeVariant::SendMoreExtended => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SendMoreExtended(Box::new(t.0)))), + ), TypeVariant::AuthCert => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::AuthCert(Box::new(t.0)))), @@ -36800,6 +49074,13 @@ impl Type { ) .map(|r| r.map(|t| Self::SurveyMessageCommandType(Box::new(t.0)))), ), + TypeVariant::SurveyMessageResponseType => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SurveyMessageResponseType(Box::new(t.0)))), + ), TypeVariant::SurveyRequestMessage => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::SurveyRequestMessage(Box::new(t.0)))), @@ -36837,9 +49118,19 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::PeerStatList(Box::new(t.0)))), ), - TypeVariant::TopologyResponseBody => Box::new( - ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) - .map(|r| r.map(|t| Self::TopologyResponseBody(Box::new(t.0)))), + TypeVariant::TopologyResponseBodyV0 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::TopologyResponseBodyV0(Box::new(t.0)))), + ), + TypeVariant::TopologyResponseBodyV1 => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::TopologyResponseBodyV1(Box::new(t.0)))), ), TypeVariant::SurveyResponseBody => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) @@ -37028,6 +49319,101 @@ impl Type { ) .map(|r| r.map(|t| Self::LiquidityPoolWithdrawOp(Box::new(t.0)))), ), + TypeVariant::HostFunctionType => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::HostFunctionType(Box::new(t.0)))), + ), + TypeVariant::ContractIdPreimageType => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ContractIdPreimageType(Box::new(t.0)))), + ), + TypeVariant::ContractIdPreimage => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractIdPreimage(Box::new(t.0)))), + ), + TypeVariant::ContractIdPreimageFromAddress => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ContractIdPreimageFromAddress(Box::new(t.0)))), + ), + TypeVariant::CreateContractArgs => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::CreateContractArgs(Box::new(t.0)))), + ), + TypeVariant::InvokeContractArgs => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeContractArgs(Box::new(t.0)))), + ), + TypeVariant::HostFunction => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::HostFunction(Box::new(t.0)))), + ), + TypeVariant::SorobanAuthorizedFunctionType => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanAuthorizedFunctionType(Box::new(t.0)))), + ), + TypeVariant::SorobanAuthorizedFunction => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanAuthorizedFunction(Box::new(t.0)))), + ), + TypeVariant::SorobanAuthorizedInvocation => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanAuthorizedInvocation(Box::new(t.0)))), + ), + TypeVariant::SorobanAddressCredentials => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanAddressCredentials(Box::new(t.0)))), + ), + TypeVariant::SorobanCredentialsType => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanCredentialsType(Box::new(t.0)))), + ), + TypeVariant::SorobanCredentials => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanCredentials(Box::new(t.0)))), + ), + TypeVariant::SorobanAuthorizationEntry => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanAuthorizationEntry(Box::new(t.0)))), + ), + TypeVariant::InvokeHostFunctionOp => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeHostFunctionOp(Box::new(t.0)))), + ), + TypeVariant::BumpFootprintExpirationOp => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::BumpFootprintExpirationOp(Box::new(t.0)))), + ), + TypeVariant::RestoreFootprintOp => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::RestoreFootprintOp(Box::new(t.0)))), + ), TypeVariant::Operation => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Operation(Box::new(t.0)))), @@ -37054,6 +49440,20 @@ impl Type { ) .map(|r| r.map(|t| Self::HashIdPreimageRevokeId(Box::new(t.0)))), ), + TypeVariant::HashIdPreimageContractId => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::HashIdPreimageContractId(Box::new(t.0)))), + ), + TypeVariant::HashIdPreimageSorobanAuthorization => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::HashIdPreimageSorobanAuthorization(Box::new(t.0)))), + ), TypeVariant::MemoType => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::MemoType(Box::new(t.0)))), @@ -37082,6 +49482,21 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Preconditions(Box::new(t.0)))), ), + TypeVariant::LedgerFootprint => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerFootprint(Box::new(t.0)))), + ), + TypeVariant::SorobanResources => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanResources(Box::new(t.0)))), + ), + TypeVariant::SorobanTransactionData => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::SorobanTransactionData(Box::new(t.0)))), + ), TypeVariant::TransactionV0 => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionV0(Box::new(t.0)))), @@ -37488,6 +49903,48 @@ impl Type { ) .map(|r| r.map(|t| Self::LiquidityPoolWithdrawResult(Box::new(t.0)))), ), + TypeVariant::InvokeHostFunctionResultCode => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::InvokeHostFunctionResultCode(Box::new(t.0)))), + ), + TypeVariant::InvokeHostFunctionResult => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::InvokeHostFunctionResult(Box::new(t.0)))), + ), + TypeVariant::BumpFootprintExpirationResultCode => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::BumpFootprintExpirationResultCode(Box::new(t.0)))), + ), + TypeVariant::BumpFootprintExpirationResult => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::BumpFootprintExpirationResult(Box::new(t.0)))), + ), + TypeVariant::RestoreFootprintResultCode => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::RestoreFootprintResultCode(Box::new(t.0)))), + ), + TypeVariant::RestoreFootprintResult => Box::new( + ReadXdrIter::<_, Frame>::new( + &mut r.inner, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::RestoreFootprintResult(Box::new(t.0)))), + ), TypeVariant::OperationResultCode => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::OperationResultCode(Box::new(t.0)))), @@ -37574,6 +50031,14 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Int64(Box::new(t.0)))), ), + TypeVariant::TimePoint => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::TimePoint(Box::new(t.0)))), + ), + TypeVariant::Duration => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::Duration(Box::new(t.0)))), + ), TypeVariant::ExtensionPoint => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::ExtensionPoint(Box::new(t.0)))), @@ -37617,6 +50082,10 @@ impl Type { ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::NodeId(Box::new(t.0)))), ), + TypeVariant::AccountId => Box::new( + ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) + .map(|r| r.map(|t| Self::AccountId(Box::new(t.0)))), + ), TypeVariant::Curve25519Secret => Box::new( ReadXdrIter::<_, Frame>::new(&mut r.inner, r.depth_remaining) .map(|r| r.map(|t| Self::Curve25519Secret(Box::new(t.0)))), @@ -37688,6 +50157,264 @@ impl Type { ReadXdrIter::<_, ScpQuorumSet>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::ScpQuorumSet(Box::new(t)))), ), + TypeVariant::ConfigSettingContractExecutionLanesV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractExecutionLanesV0>::new( + dec, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractExecutionLanesV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractComputeV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractComputeV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingContractComputeV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractLedgerCostV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractLedgerCostV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingContractLedgerCostV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractHistoricalDataV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractHistoricalDataV0>::new( + dec, + r.depth_remaining, + ) + .map(|r| r.map(|t| Self::ConfigSettingContractHistoricalDataV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractEventsV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractEventsV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingContractEventsV0(Box::new(t)))), + ), + TypeVariant::ConfigSettingContractBandwidthV0 => Box::new( + ReadXdrIter::<_, ConfigSettingContractBandwidthV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingContractBandwidthV0(Box::new(t)))), + ), + TypeVariant::ContractCostType => Box::new( + ReadXdrIter::<_, ContractCostType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostType(Box::new(t)))), + ), + TypeVariant::ContractCostParamEntry => Box::new( + ReadXdrIter::<_, ContractCostParamEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostParamEntry(Box::new(t)))), + ), + TypeVariant::StateExpirationSettings => Box::new( + ReadXdrIter::<_, StateExpirationSettings>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::StateExpirationSettings(Box::new(t)))), + ), + TypeVariant::EvictionIterator => Box::new( + ReadXdrIter::<_, EvictionIterator>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::EvictionIterator(Box::new(t)))), + ), + TypeVariant::ContractCostParams => Box::new( + ReadXdrIter::<_, ContractCostParams>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCostParams(Box::new(t)))), + ), + TypeVariant::ConfigSettingId => Box::new( + ReadXdrIter::<_, ConfigSettingId>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingId(Box::new(t)))), + ), + TypeVariant::ConfigSettingEntry => Box::new( + ReadXdrIter::<_, ConfigSettingEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigSettingEntry(Box::new(t)))), + ), + TypeVariant::ScEnvMetaKind => Box::new( + ReadXdrIter::<_, ScEnvMetaKind>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScEnvMetaKind(Box::new(t)))), + ), + TypeVariant::ScEnvMetaEntry => Box::new( + ReadXdrIter::<_, ScEnvMetaEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScEnvMetaEntry(Box::new(t)))), + ), + TypeVariant::ScMetaV0 => Box::new( + ReadXdrIter::<_, ScMetaV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaV0(Box::new(t)))), + ), + TypeVariant::ScMetaKind => Box::new( + ReadXdrIter::<_, ScMetaKind>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaKind(Box::new(t)))), + ), + TypeVariant::ScMetaEntry => Box::new( + ReadXdrIter::<_, ScMetaEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMetaEntry(Box::new(t)))), + ), + TypeVariant::ScSpecType => Box::new( + ReadXdrIter::<_, ScSpecType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecType(Box::new(t)))), + ), + TypeVariant::ScSpecTypeOption => Box::new( + ReadXdrIter::<_, ScSpecTypeOption>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeOption(Box::new(t)))), + ), + TypeVariant::ScSpecTypeResult => Box::new( + ReadXdrIter::<_, ScSpecTypeResult>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeResult(Box::new(t)))), + ), + TypeVariant::ScSpecTypeVec => Box::new( + ReadXdrIter::<_, ScSpecTypeVec>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeVec(Box::new(t)))), + ), + TypeVariant::ScSpecTypeMap => Box::new( + ReadXdrIter::<_, ScSpecTypeMap>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeMap(Box::new(t)))), + ), + TypeVariant::ScSpecTypeTuple => Box::new( + ReadXdrIter::<_, ScSpecTypeTuple>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeTuple(Box::new(t)))), + ), + TypeVariant::ScSpecTypeBytesN => Box::new( + ReadXdrIter::<_, ScSpecTypeBytesN>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeBytesN(Box::new(t)))), + ), + TypeVariant::ScSpecTypeUdt => Box::new( + ReadXdrIter::<_, ScSpecTypeUdt>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeUdt(Box::new(t)))), + ), + TypeVariant::ScSpecTypeDef => Box::new( + ReadXdrIter::<_, ScSpecTypeDef>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecTypeDef(Box::new(t)))), + ), + TypeVariant::ScSpecUdtStructFieldV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtStructFieldV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtStructFieldV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtStructV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtStructV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtStructV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseVoidV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseVoidV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseVoidV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseTupleV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseTupleV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseTupleV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseV0Kind => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseV0Kind>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseV0Kind(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionCaseV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionCaseV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionCaseV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtUnionV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtUnionV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtUnionV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtEnumCaseV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtEnumCaseV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtEnumCaseV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtEnumV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtEnumV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtEnumV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtErrorEnumCaseV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtErrorEnumCaseV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtErrorEnumCaseV0(Box::new(t)))), + ), + TypeVariant::ScSpecUdtErrorEnumV0 => Box::new( + ReadXdrIter::<_, ScSpecUdtErrorEnumV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecUdtErrorEnumV0(Box::new(t)))), + ), + TypeVariant::ScSpecFunctionInputV0 => Box::new( + ReadXdrIter::<_, ScSpecFunctionInputV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecFunctionInputV0(Box::new(t)))), + ), + TypeVariant::ScSpecFunctionV0 => Box::new( + ReadXdrIter::<_, ScSpecFunctionV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecFunctionV0(Box::new(t)))), + ), + TypeVariant::ScSpecEntryKind => Box::new( + ReadXdrIter::<_, ScSpecEntryKind>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecEntryKind(Box::new(t)))), + ), + TypeVariant::ScSpecEntry => Box::new( + ReadXdrIter::<_, ScSpecEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSpecEntry(Box::new(t)))), + ), + TypeVariant::ScValType => Box::new( + ReadXdrIter::<_, ScValType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScValType(Box::new(t)))), + ), + TypeVariant::ScErrorType => Box::new( + ReadXdrIter::<_, ScErrorType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScErrorType(Box::new(t)))), + ), + TypeVariant::ScErrorCode => Box::new( + ReadXdrIter::<_, ScErrorCode>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScErrorCode(Box::new(t)))), + ), + TypeVariant::ScError => Box::new( + ReadXdrIter::<_, ScError>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScError(Box::new(t)))), + ), + TypeVariant::UInt128Parts => Box::new( + ReadXdrIter::<_, UInt128Parts>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::UInt128Parts(Box::new(t)))), + ), + TypeVariant::Int128Parts => Box::new( + ReadXdrIter::<_, Int128Parts>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::Int128Parts(Box::new(t)))), + ), + TypeVariant::UInt256Parts => Box::new( + ReadXdrIter::<_, UInt256Parts>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::UInt256Parts(Box::new(t)))), + ), + TypeVariant::Int256Parts => Box::new( + ReadXdrIter::<_, Int256Parts>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::Int256Parts(Box::new(t)))), + ), + TypeVariant::ContractExecutableType => Box::new( + ReadXdrIter::<_, ContractExecutableType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractExecutableType(Box::new(t)))), + ), + TypeVariant::ContractExecutable => Box::new( + ReadXdrIter::<_, ContractExecutable>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractExecutable(Box::new(t)))), + ), + TypeVariant::ScAddressType => Box::new( + ReadXdrIter::<_, ScAddressType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScAddressType(Box::new(t)))), + ), + TypeVariant::ScAddress => Box::new( + ReadXdrIter::<_, ScAddress>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScAddress(Box::new(t)))), + ), + TypeVariant::ScVec => Box::new( + ReadXdrIter::<_, ScVec>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScVec(Box::new(t)))), + ), + TypeVariant::ScMap => Box::new( + ReadXdrIter::<_, ScMap>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMap(Box::new(t)))), + ), + TypeVariant::ScBytes => Box::new( + ReadXdrIter::<_, ScBytes>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScBytes(Box::new(t)))), + ), + TypeVariant::ScString => Box::new( + ReadXdrIter::<_, ScString>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScString(Box::new(t)))), + ), + TypeVariant::ScSymbol => Box::new( + ReadXdrIter::<_, ScSymbol>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScSymbol(Box::new(t)))), + ), + TypeVariant::ScNonceKey => Box::new( + ReadXdrIter::<_, ScNonceKey>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScNonceKey(Box::new(t)))), + ), + TypeVariant::ScContractInstance => Box::new( + ReadXdrIter::<_, ScContractInstance>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScContractInstance(Box::new(t)))), + ), + TypeVariant::ScVal => Box::new( + ReadXdrIter::<_, ScVal>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScVal(Box::new(t)))), + ), + TypeVariant::ScMapEntry => Box::new( + ReadXdrIter::<_, ScMapEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ScMapEntry(Box::new(t)))), + ), TypeVariant::StoredTransactionSet => Box::new( ReadXdrIter::<_, StoredTransactionSet>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::StoredTransactionSet(Box::new(t)))), @@ -37704,10 +50431,6 @@ impl Type { ReadXdrIter::<_, PersistedScpState>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::PersistedScpState(Box::new(t)))), ), - TypeVariant::AccountId => Box::new( - ReadXdrIter::<_, AccountId>::new(dec, r.depth_remaining) - .map(|r| r.map(|t| Self::AccountId(Box::new(t)))), - ), TypeVariant::Thresholds => Box::new( ReadXdrIter::<_, Thresholds>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::Thresholds(Box::new(t)))), @@ -37724,14 +50447,6 @@ impl Type { ReadXdrIter::<_, SequenceNumber>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::SequenceNumber(Box::new(t)))), ), - TypeVariant::TimePoint => Box::new( - ReadXdrIter::<_, TimePoint>::new(dec, r.depth_remaining) - .map(|r| r.map(|t| Self::TimePoint(Box::new(t)))), - ), - TypeVariant::Duration => Box::new( - ReadXdrIter::<_, Duration>::new(dec, r.depth_remaining) - .map(|r| r.map(|t| Self::Duration(Box::new(t)))), - ), TypeVariant::DataValue => Box::new( ReadXdrIter::<_, DataValue>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::DataValue(Box::new(t)))), @@ -37947,6 +50662,22 @@ impl Type { ReadXdrIter::<_, LiquidityPoolEntryConstantProduct>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LiquidityPoolEntryConstantProduct(Box::new(t)))), ), + TypeVariant::ContractDataDurability => Box::new( + ReadXdrIter::<_, ContractDataDurability>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractDataDurability(Box::new(t)))), + ), + TypeVariant::ContractDataEntry => Box::new( + ReadXdrIter::<_, ContractDataEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractDataEntry(Box::new(t)))), + ), + TypeVariant::ContractCodeEntry => Box::new( + ReadXdrIter::<_, ContractCodeEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractCodeEntry(Box::new(t)))), + ), + TypeVariant::ExpirationEntry => Box::new( + ReadXdrIter::<_, ExpirationEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ExpirationEntry(Box::new(t)))), + ), TypeVariant::LedgerEntryExtensionV1 => Box::new( ReadXdrIter::<_, LedgerEntryExtensionV1>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerEntryExtensionV1(Box::new(t)))), @@ -37995,6 +50726,22 @@ impl Type { ReadXdrIter::<_, LedgerKeyLiquidityPool>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerKeyLiquidityPool(Box::new(t)))), ), + TypeVariant::LedgerKeyContractData => Box::new( + ReadXdrIter::<_, LedgerKeyContractData>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyContractData(Box::new(t)))), + ), + TypeVariant::LedgerKeyContractCode => Box::new( + ReadXdrIter::<_, LedgerKeyContractCode>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyContractCode(Box::new(t)))), + ), + TypeVariant::LedgerKeyConfigSetting => Box::new( + ReadXdrIter::<_, LedgerKeyConfigSetting>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyConfigSetting(Box::new(t)))), + ), + TypeVariant::LedgerKeyExpiration => Box::new( + ReadXdrIter::<_, LedgerKeyExpiration>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerKeyExpiration(Box::new(t)))), + ), TypeVariant::EnvelopeType => Box::new( ReadXdrIter::<_, EnvelopeType>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::EnvelopeType(Box::new(t)))), @@ -38043,10 +50790,18 @@ impl Type { ReadXdrIter::<_, LedgerUpgradeType>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerUpgradeType(Box::new(t)))), ), + TypeVariant::ConfigUpgradeSetKey => Box::new( + ReadXdrIter::<_, ConfigUpgradeSetKey>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigUpgradeSetKey(Box::new(t)))), + ), TypeVariant::LedgerUpgrade => Box::new( ReadXdrIter::<_, LedgerUpgrade>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerUpgrade(Box::new(t)))), ), + TypeVariant::ConfigUpgradeSet => Box::new( + ReadXdrIter::<_, ConfigUpgradeSet>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ConfigUpgradeSet(Box::new(t)))), + ), TypeVariant::BucketEntryType => Box::new( ReadXdrIter::<_, BucketEntryType>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::BucketEntryType(Box::new(t)))), @@ -38159,6 +50914,38 @@ impl Type { ReadXdrIter::<_, TransactionMetaV2>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionMetaV2(Box::new(t)))), ), + TypeVariant::ContractEventType => Box::new( + ReadXdrIter::<_, ContractEventType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventType(Box::new(t)))), + ), + TypeVariant::ContractEvent => Box::new( + ReadXdrIter::<_, ContractEvent>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEvent(Box::new(t)))), + ), + TypeVariant::ContractEventBody => Box::new( + ReadXdrIter::<_, ContractEventBody>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventBody(Box::new(t)))), + ), + TypeVariant::ContractEventV0 => Box::new( + ReadXdrIter::<_, ContractEventV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractEventV0(Box::new(t)))), + ), + TypeVariant::DiagnosticEvent => Box::new( + ReadXdrIter::<_, DiagnosticEvent>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::DiagnosticEvent(Box::new(t)))), + ), + TypeVariant::SorobanTransactionMeta => Box::new( + ReadXdrIter::<_, SorobanTransactionMeta>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanTransactionMeta(Box::new(t)))), + ), + TypeVariant::TransactionMetaV3 => Box::new( + ReadXdrIter::<_, TransactionMetaV3>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::TransactionMetaV3(Box::new(t)))), + ), + TypeVariant::InvokeHostFunctionSuccessPreImage => Box::new( + ReadXdrIter::<_, InvokeHostFunctionSuccessPreImage>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeHostFunctionSuccessPreImage(Box::new(t)))), + ), TypeVariant::TransactionMeta => Box::new( ReadXdrIter::<_, TransactionMeta>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionMeta(Box::new(t)))), @@ -38179,6 +50966,10 @@ impl Type { ReadXdrIter::<_, LedgerCloseMetaV1>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerCloseMetaV1(Box::new(t)))), ), + TypeVariant::LedgerCloseMetaV2 => Box::new( + ReadXdrIter::<_, LedgerCloseMetaV2>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerCloseMetaV2(Box::new(t)))), + ), TypeVariant::LedgerCloseMeta => Box::new( ReadXdrIter::<_, LedgerCloseMeta>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LedgerCloseMeta(Box::new(t)))), @@ -38195,6 +50986,10 @@ impl Type { ReadXdrIter::<_, SendMore>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::SendMore(Box::new(t)))), ), + TypeVariant::SendMoreExtended => Box::new( + ReadXdrIter::<_, SendMoreExtended>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SendMoreExtended(Box::new(t)))), + ), TypeVariant::AuthCert => Box::new( ReadXdrIter::<_, AuthCert>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::AuthCert(Box::new(t)))), @@ -38231,6 +51026,10 @@ impl Type { ReadXdrIter::<_, SurveyMessageCommandType>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::SurveyMessageCommandType(Box::new(t)))), ), + TypeVariant::SurveyMessageResponseType => Box::new( + ReadXdrIter::<_, SurveyMessageResponseType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SurveyMessageResponseType(Box::new(t)))), + ), TypeVariant::SurveyRequestMessage => Box::new( ReadXdrIter::<_, SurveyRequestMessage>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::SurveyRequestMessage(Box::new(t)))), @@ -38259,9 +51058,13 @@ impl Type { ReadXdrIter::<_, PeerStatList>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::PeerStatList(Box::new(t)))), ), - TypeVariant::TopologyResponseBody => Box::new( - ReadXdrIter::<_, TopologyResponseBody>::new(dec, r.depth_remaining) - .map(|r| r.map(|t| Self::TopologyResponseBody(Box::new(t)))), + TypeVariant::TopologyResponseBodyV0 => Box::new( + ReadXdrIter::<_, TopologyResponseBodyV0>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::TopologyResponseBodyV0(Box::new(t)))), + ), + TypeVariant::TopologyResponseBodyV1 => Box::new( + ReadXdrIter::<_, TopologyResponseBodyV1>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::TopologyResponseBodyV1(Box::new(t)))), ), TypeVariant::SurveyResponseBody => Box::new( ReadXdrIter::<_, SurveyResponseBody>::new(dec, r.depth_remaining) @@ -38411,6 +51214,74 @@ impl Type { ReadXdrIter::<_, LiquidityPoolWithdrawOp>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LiquidityPoolWithdrawOp(Box::new(t)))), ), + TypeVariant::HostFunctionType => Box::new( + ReadXdrIter::<_, HostFunctionType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::HostFunctionType(Box::new(t)))), + ), + TypeVariant::ContractIdPreimageType => Box::new( + ReadXdrIter::<_, ContractIdPreimageType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractIdPreimageType(Box::new(t)))), + ), + TypeVariant::ContractIdPreimage => Box::new( + ReadXdrIter::<_, ContractIdPreimage>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractIdPreimage(Box::new(t)))), + ), + TypeVariant::ContractIdPreimageFromAddress => Box::new( + ReadXdrIter::<_, ContractIdPreimageFromAddress>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::ContractIdPreimageFromAddress(Box::new(t)))), + ), + TypeVariant::CreateContractArgs => Box::new( + ReadXdrIter::<_, CreateContractArgs>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::CreateContractArgs(Box::new(t)))), + ), + TypeVariant::InvokeContractArgs => Box::new( + ReadXdrIter::<_, InvokeContractArgs>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeContractArgs(Box::new(t)))), + ), + TypeVariant::HostFunction => Box::new( + ReadXdrIter::<_, HostFunction>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::HostFunction(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizedFunctionType => Box::new( + ReadXdrIter::<_, SorobanAuthorizedFunctionType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAuthorizedFunctionType(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizedFunction => Box::new( + ReadXdrIter::<_, SorobanAuthorizedFunction>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAuthorizedFunction(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizedInvocation => Box::new( + ReadXdrIter::<_, SorobanAuthorizedInvocation>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAuthorizedInvocation(Box::new(t)))), + ), + TypeVariant::SorobanAddressCredentials => Box::new( + ReadXdrIter::<_, SorobanAddressCredentials>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAddressCredentials(Box::new(t)))), + ), + TypeVariant::SorobanCredentialsType => Box::new( + ReadXdrIter::<_, SorobanCredentialsType>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanCredentialsType(Box::new(t)))), + ), + TypeVariant::SorobanCredentials => Box::new( + ReadXdrIter::<_, SorobanCredentials>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanCredentials(Box::new(t)))), + ), + TypeVariant::SorobanAuthorizationEntry => Box::new( + ReadXdrIter::<_, SorobanAuthorizationEntry>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanAuthorizationEntry(Box::new(t)))), + ), + TypeVariant::InvokeHostFunctionOp => Box::new( + ReadXdrIter::<_, InvokeHostFunctionOp>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeHostFunctionOp(Box::new(t)))), + ), + TypeVariant::BumpFootprintExpirationOp => Box::new( + ReadXdrIter::<_, BumpFootprintExpirationOp>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::BumpFootprintExpirationOp(Box::new(t)))), + ), + TypeVariant::RestoreFootprintOp => Box::new( + ReadXdrIter::<_, RestoreFootprintOp>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::RestoreFootprintOp(Box::new(t)))), + ), TypeVariant::Operation => Box::new( ReadXdrIter::<_, Operation>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::Operation(Box::new(t)))), @@ -38431,6 +51302,14 @@ impl Type { ReadXdrIter::<_, HashIdPreimageRevokeId>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::HashIdPreimageRevokeId(Box::new(t)))), ), + TypeVariant::HashIdPreimageContractId => Box::new( + ReadXdrIter::<_, HashIdPreimageContractId>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::HashIdPreimageContractId(Box::new(t)))), + ), + TypeVariant::HashIdPreimageSorobanAuthorization => Box::new( + ReadXdrIter::<_, HashIdPreimageSorobanAuthorization>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::HashIdPreimageSorobanAuthorization(Box::new(t)))), + ), TypeVariant::MemoType => Box::new( ReadXdrIter::<_, MemoType>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::MemoType(Box::new(t)))), @@ -38459,6 +51338,18 @@ impl Type { ReadXdrIter::<_, Preconditions>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::Preconditions(Box::new(t)))), ), + TypeVariant::LedgerFootprint => Box::new( + ReadXdrIter::<_, LedgerFootprint>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::LedgerFootprint(Box::new(t)))), + ), + TypeVariant::SorobanResources => Box::new( + ReadXdrIter::<_, SorobanResources>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanResources(Box::new(t)))), + ), + TypeVariant::SorobanTransactionData => Box::new( + ReadXdrIter::<_, SorobanTransactionData>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::SorobanTransactionData(Box::new(t)))), + ), TypeVariant::TransactionV0 => Box::new( ReadXdrIter::<_, TransactionV0>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::TransactionV0(Box::new(t)))), @@ -38757,6 +51648,30 @@ impl Type { ReadXdrIter::<_, LiquidityPoolWithdrawResult>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::LiquidityPoolWithdrawResult(Box::new(t)))), ), + TypeVariant::InvokeHostFunctionResultCode => Box::new( + ReadXdrIter::<_, InvokeHostFunctionResultCode>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeHostFunctionResultCode(Box::new(t)))), + ), + TypeVariant::InvokeHostFunctionResult => Box::new( + ReadXdrIter::<_, InvokeHostFunctionResult>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::InvokeHostFunctionResult(Box::new(t)))), + ), + TypeVariant::BumpFootprintExpirationResultCode => Box::new( + ReadXdrIter::<_, BumpFootprintExpirationResultCode>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::BumpFootprintExpirationResultCode(Box::new(t)))), + ), + TypeVariant::BumpFootprintExpirationResult => Box::new( + ReadXdrIter::<_, BumpFootprintExpirationResult>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::BumpFootprintExpirationResult(Box::new(t)))), + ), + TypeVariant::RestoreFootprintResultCode => Box::new( + ReadXdrIter::<_, RestoreFootprintResultCode>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::RestoreFootprintResultCode(Box::new(t)))), + ), + TypeVariant::RestoreFootprintResult => Box::new( + ReadXdrIter::<_, RestoreFootprintResult>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::RestoreFootprintResult(Box::new(t)))), + ), TypeVariant::OperationResultCode => Box::new( ReadXdrIter::<_, OperationResultCode>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::OperationResultCode(Box::new(t)))), @@ -38825,6 +51740,14 @@ impl Type { ReadXdrIter::<_, Int64>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::Int64(Box::new(t)))), ), + TypeVariant::TimePoint => Box::new( + ReadXdrIter::<_, TimePoint>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::TimePoint(Box::new(t)))), + ), + TypeVariant::Duration => Box::new( + ReadXdrIter::<_, Duration>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::Duration(Box::new(t)))), + ), TypeVariant::ExtensionPoint => Box::new( ReadXdrIter::<_, ExtensionPoint>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::ExtensionPoint(Box::new(t)))), @@ -38865,6 +51788,10 @@ impl Type { ReadXdrIter::<_, NodeId>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::NodeId(Box::new(t)))), ), + TypeVariant::AccountId => Box::new( + ReadXdrIter::<_, AccountId>::new(dec, r.depth_remaining) + .map(|r| r.map(|t| Self::AccountId(Box::new(t)))), + ), TypeVariant::Curve25519Secret => Box::new( ReadXdrIter::<_, Curve25519Secret>::new(dec, r.depth_remaining) .map(|r| r.map(|t| Self::Curve25519Secret(Box::new(t)))), @@ -38920,17 +51847,77 @@ impl Type { Self::ScpStatementExternalize(ref v) => v.as_ref(), Self::ScpEnvelope(ref v) => v.as_ref(), Self::ScpQuorumSet(ref v) => v.as_ref(), + Self::ConfigSettingContractExecutionLanesV0(ref v) => v.as_ref(), + Self::ConfigSettingContractComputeV0(ref v) => v.as_ref(), + Self::ConfigSettingContractLedgerCostV0(ref v) => v.as_ref(), + Self::ConfigSettingContractHistoricalDataV0(ref v) => v.as_ref(), + Self::ConfigSettingContractEventsV0(ref v) => v.as_ref(), + Self::ConfigSettingContractBandwidthV0(ref v) => v.as_ref(), + Self::ContractCostType(ref v) => v.as_ref(), + Self::ContractCostParamEntry(ref v) => v.as_ref(), + Self::StateExpirationSettings(ref v) => v.as_ref(), + Self::EvictionIterator(ref v) => v.as_ref(), + Self::ContractCostParams(ref v) => v.as_ref(), + Self::ConfigSettingId(ref v) => v.as_ref(), + Self::ConfigSettingEntry(ref v) => v.as_ref(), + Self::ScEnvMetaKind(ref v) => v.as_ref(), + Self::ScEnvMetaEntry(ref v) => v.as_ref(), + Self::ScMetaV0(ref v) => v.as_ref(), + Self::ScMetaKind(ref v) => v.as_ref(), + Self::ScMetaEntry(ref v) => v.as_ref(), + Self::ScSpecType(ref v) => v.as_ref(), + Self::ScSpecTypeOption(ref v) => v.as_ref(), + Self::ScSpecTypeResult(ref v) => v.as_ref(), + Self::ScSpecTypeVec(ref v) => v.as_ref(), + Self::ScSpecTypeMap(ref v) => v.as_ref(), + Self::ScSpecTypeTuple(ref v) => v.as_ref(), + Self::ScSpecTypeBytesN(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(), + Self::ScSpecUdtStructV0(ref v) => v.as_ref(), + Self::ScSpecUdtUnionCaseVoidV0(ref v) => v.as_ref(), + Self::ScSpecUdtUnionCaseTupleV0(ref v) => v.as_ref(), + Self::ScSpecUdtUnionCaseV0Kind(ref v) => v.as_ref(), + Self::ScSpecUdtUnionCaseV0(ref v) => v.as_ref(), + Self::ScSpecUdtUnionV0(ref v) => v.as_ref(), + Self::ScSpecUdtEnumCaseV0(ref v) => v.as_ref(), + Self::ScSpecUdtEnumV0(ref v) => v.as_ref(), + Self::ScSpecUdtErrorEnumCaseV0(ref v) => v.as_ref(), + Self::ScSpecUdtErrorEnumV0(ref v) => v.as_ref(), + Self::ScSpecFunctionInputV0(ref v) => v.as_ref(), + Self::ScSpecFunctionV0(ref v) => v.as_ref(), + Self::ScSpecEntryKind(ref v) => v.as_ref(), + Self::ScSpecEntry(ref v) => v.as_ref(), + Self::ScValType(ref v) => v.as_ref(), + Self::ScErrorType(ref v) => v.as_ref(), + Self::ScErrorCode(ref v) => v.as_ref(), + Self::ScError(ref v) => v.as_ref(), + Self::UInt128Parts(ref v) => v.as_ref(), + Self::Int128Parts(ref v) => v.as_ref(), + Self::UInt256Parts(ref v) => v.as_ref(), + Self::Int256Parts(ref v) => v.as_ref(), + Self::ContractExecutableType(ref v) => v.as_ref(), + Self::ContractExecutable(ref v) => v.as_ref(), + Self::ScAddressType(ref v) => v.as_ref(), + Self::ScAddress(ref v) => v.as_ref(), + Self::ScVec(ref v) => v.as_ref(), + Self::ScMap(ref v) => v.as_ref(), + Self::ScBytes(ref v) => v.as_ref(), + Self::ScString(ref v) => v.as_ref(), + Self::ScSymbol(ref v) => v.as_ref(), + Self::ScNonceKey(ref v) => v.as_ref(), + Self::ScContractInstance(ref v) => v.as_ref(), + Self::ScVal(ref v) => v.as_ref(), + Self::ScMapEntry(ref v) => v.as_ref(), Self::StoredTransactionSet(ref v) => v.as_ref(), Self::PersistedScpStateV0(ref v) => v.as_ref(), Self::PersistedScpStateV1(ref v) => v.as_ref(), Self::PersistedScpState(ref v) => v.as_ref(), - Self::AccountId(ref v) => v.as_ref(), Self::Thresholds(ref v) => v.as_ref(), Self::String32(ref v) => v.as_ref(), Self::String64(ref v) => v.as_ref(), Self::SequenceNumber(ref v) => v.as_ref(), - Self::TimePoint(ref v) => v.as_ref(), - Self::Duration(ref v) => v.as_ref(), Self::DataValue(ref v) => v.as_ref(), Self::PoolId(ref v) => v.as_ref(), Self::AssetCode4(ref v) => v.as_ref(), @@ -38984,6 +51971,10 @@ impl Type { Self::LiquidityPoolEntry(ref v) => v.as_ref(), Self::LiquidityPoolEntryBody(ref v) => v.as_ref(), Self::LiquidityPoolEntryConstantProduct(ref v) => v.as_ref(), + Self::ContractDataDurability(ref v) => v.as_ref(), + Self::ContractDataEntry(ref v) => v.as_ref(), + Self::ContractCodeEntry(ref v) => v.as_ref(), + Self::ExpirationEntry(ref v) => v.as_ref(), Self::LedgerEntryExtensionV1(ref v) => v.as_ref(), Self::LedgerEntryExtensionV1Ext(ref v) => v.as_ref(), Self::LedgerEntry(ref v) => v.as_ref(), @@ -38996,6 +51987,10 @@ impl Type { Self::LedgerKeyData(ref v) => v.as_ref(), Self::LedgerKeyClaimableBalance(ref v) => v.as_ref(), Self::LedgerKeyLiquidityPool(ref v) => v.as_ref(), + Self::LedgerKeyContractData(ref v) => v.as_ref(), + Self::LedgerKeyContractCode(ref v) => v.as_ref(), + Self::LedgerKeyConfigSetting(ref v) => v.as_ref(), + Self::LedgerKeyExpiration(ref v) => v.as_ref(), Self::EnvelopeType(ref v) => v.as_ref(), Self::UpgradeType(ref v) => v.as_ref(), Self::StellarValueType(ref v) => v.as_ref(), @@ -39008,7 +52003,9 @@ impl Type { Self::LedgerHeader(ref v) => v.as_ref(), Self::LedgerHeaderExt(ref v) => v.as_ref(), Self::LedgerUpgradeType(ref v) => v.as_ref(), + Self::ConfigUpgradeSetKey(ref v) => v.as_ref(), Self::LedgerUpgrade(ref v) => v.as_ref(), + Self::ConfigUpgradeSet(ref v) => v.as_ref(), Self::BucketEntryType(ref v) => v.as_ref(), Self::BucketMetadata(ref v) => v.as_ref(), Self::BucketMetadataExt(ref v) => v.as_ref(), @@ -39037,15 +52034,25 @@ impl Type { Self::OperationMeta(ref v) => v.as_ref(), Self::TransactionMetaV1(ref v) => v.as_ref(), Self::TransactionMetaV2(ref v) => v.as_ref(), + Self::ContractEventType(ref v) => v.as_ref(), + Self::ContractEvent(ref v) => v.as_ref(), + Self::ContractEventBody(ref v) => v.as_ref(), + Self::ContractEventV0(ref v) => v.as_ref(), + Self::DiagnosticEvent(ref v) => v.as_ref(), + Self::SorobanTransactionMeta(ref v) => v.as_ref(), + Self::TransactionMetaV3(ref v) => v.as_ref(), + Self::InvokeHostFunctionSuccessPreImage(ref v) => v.as_ref(), Self::TransactionMeta(ref v) => v.as_ref(), Self::TransactionResultMeta(ref v) => v.as_ref(), Self::UpgradeEntryMeta(ref v) => v.as_ref(), Self::LedgerCloseMetaV0(ref v) => v.as_ref(), Self::LedgerCloseMetaV1(ref v) => v.as_ref(), + Self::LedgerCloseMetaV2(ref v) => v.as_ref(), Self::LedgerCloseMeta(ref v) => v.as_ref(), Self::ErrorCode(ref v) => v.as_ref(), Self::SError(ref v) => v.as_ref(), Self::SendMore(ref v) => v.as_ref(), + Self::SendMoreExtended(ref v) => v.as_ref(), Self::AuthCert(ref v) => v.as_ref(), Self::Hello(ref v) => v.as_ref(), Self::Auth(ref v) => v.as_ref(), @@ -39055,6 +52062,7 @@ impl Type { Self::MessageType(ref v) => v.as_ref(), Self::DontHave(ref v) => v.as_ref(), Self::SurveyMessageCommandType(ref v) => v.as_ref(), + Self::SurveyMessageResponseType(ref v) => v.as_ref(), Self::SurveyRequestMessage(ref v) => v.as_ref(), Self::SignedSurveyRequestMessage(ref v) => v.as_ref(), Self::EncryptedBody(ref v) => v.as_ref(), @@ -39062,7 +52070,8 @@ impl Type { Self::SignedSurveyResponseMessage(ref v) => v.as_ref(), Self::PeerStats(ref v) => v.as_ref(), Self::PeerStatList(ref v) => v.as_ref(), - Self::TopologyResponseBody(ref v) => v.as_ref(), + Self::TopologyResponseBodyV0(ref v) => v.as_ref(), + Self::TopologyResponseBodyV1(ref v) => v.as_ref(), Self::SurveyResponseBody(ref v) => v.as_ref(), Self::TxAdvertVector(ref v) => v.as_ref(), Self::FloodAdvert(ref v) => v.as_ref(), @@ -39100,11 +52109,30 @@ impl Type { Self::SetTrustLineFlagsOp(ref v) => v.as_ref(), Self::LiquidityPoolDepositOp(ref v) => v.as_ref(), Self::LiquidityPoolWithdrawOp(ref v) => v.as_ref(), + Self::HostFunctionType(ref v) => v.as_ref(), + Self::ContractIdPreimageType(ref v) => v.as_ref(), + Self::ContractIdPreimage(ref v) => v.as_ref(), + Self::ContractIdPreimageFromAddress(ref v) => v.as_ref(), + Self::CreateContractArgs(ref v) => v.as_ref(), + Self::InvokeContractArgs(ref v) => v.as_ref(), + Self::HostFunction(ref v) => v.as_ref(), + Self::SorobanAuthorizedFunctionType(ref v) => v.as_ref(), + Self::SorobanAuthorizedFunction(ref v) => v.as_ref(), + Self::SorobanAuthorizedInvocation(ref v) => v.as_ref(), + Self::SorobanAddressCredentials(ref v) => v.as_ref(), + Self::SorobanCredentialsType(ref v) => v.as_ref(), + Self::SorobanCredentials(ref v) => v.as_ref(), + Self::SorobanAuthorizationEntry(ref v) => v.as_ref(), + Self::InvokeHostFunctionOp(ref v) => v.as_ref(), + Self::BumpFootprintExpirationOp(ref v) => v.as_ref(), + Self::RestoreFootprintOp(ref v) => v.as_ref(), Self::Operation(ref v) => v.as_ref(), Self::OperationBody(ref v) => v.as_ref(), Self::HashIdPreimage(ref v) => v.as_ref(), Self::HashIdPreimageOperationId(ref v) => v.as_ref(), Self::HashIdPreimageRevokeId(ref v) => v.as_ref(), + Self::HashIdPreimageContractId(ref v) => v.as_ref(), + Self::HashIdPreimageSorobanAuthorization(ref v) => v.as_ref(), Self::MemoType(ref v) => v.as_ref(), Self::Memo(ref v) => v.as_ref(), Self::TimeBounds(ref v) => v.as_ref(), @@ -39112,6 +52140,9 @@ impl Type { Self::PreconditionsV2(ref v) => v.as_ref(), Self::PreconditionType(ref v) => v.as_ref(), Self::Preconditions(ref v) => v.as_ref(), + Self::LedgerFootprint(ref v) => v.as_ref(), + Self::SorobanResources(ref v) => v.as_ref(), + Self::SorobanTransactionData(ref v) => v.as_ref(), Self::TransactionV0(ref v) => v.as_ref(), Self::TransactionV0Ext(ref v) => v.as_ref(), Self::TransactionV0Envelope(ref v) => v.as_ref(), @@ -39183,6 +52214,12 @@ impl Type { Self::LiquidityPoolDepositResult(ref v) => v.as_ref(), Self::LiquidityPoolWithdrawResultCode(ref v) => v.as_ref(), Self::LiquidityPoolWithdrawResult(ref v) => v.as_ref(), + Self::InvokeHostFunctionResultCode(ref v) => v.as_ref(), + Self::InvokeHostFunctionResult(ref v) => v.as_ref(), + Self::BumpFootprintExpirationResultCode(ref v) => v.as_ref(), + Self::BumpFootprintExpirationResult(ref v) => v.as_ref(), + Self::RestoreFootprintResultCode(ref v) => v.as_ref(), + Self::RestoreFootprintResult(ref v) => v.as_ref(), Self::OperationResultCode(ref v) => v.as_ref(), Self::OperationResult(ref v) => v.as_ref(), Self::OperationResultTr(ref v) => v.as_ref(), @@ -39200,6 +52237,8 @@ impl Type { Self::Int32(ref v) => v.as_ref(), Self::Uint64(ref v) => v.as_ref(), Self::Int64(ref v) => v.as_ref(), + Self::TimePoint(ref v) => v.as_ref(), + Self::Duration(ref v) => v.as_ref(), Self::ExtensionPoint(ref v) => v.as_ref(), Self::CryptoKeyType(ref v) => v.as_ref(), Self::PublicKeyType(ref v) => v.as_ref(), @@ -39210,6 +52249,7 @@ impl Type { Self::Signature(ref v) => v.as_ref(), Self::SignatureHint(ref v) => v.as_ref(), Self::NodeId(ref v) => v.as_ref(), + Self::AccountId(ref v) => v.as_ref(), Self::Curve25519Secret(ref v) => v.as_ref(), Self::Curve25519Public(ref v) => v.as_ref(), Self::HmacSha256Key(ref v) => v.as_ref(), @@ -39232,17 +52272,81 @@ impl Type { Self::ScpStatementExternalize(_) => "ScpStatementExternalize", Self::ScpEnvelope(_) => "ScpEnvelope", Self::ScpQuorumSet(_) => "ScpQuorumSet", + Self::ConfigSettingContractExecutionLanesV0(_) => { + "ConfigSettingContractExecutionLanesV0" + } + Self::ConfigSettingContractComputeV0(_) => "ConfigSettingContractComputeV0", + Self::ConfigSettingContractLedgerCostV0(_) => "ConfigSettingContractLedgerCostV0", + Self::ConfigSettingContractHistoricalDataV0(_) => { + "ConfigSettingContractHistoricalDataV0" + } + Self::ConfigSettingContractEventsV0(_) => "ConfigSettingContractEventsV0", + Self::ConfigSettingContractBandwidthV0(_) => "ConfigSettingContractBandwidthV0", + Self::ContractCostType(_) => "ContractCostType", + Self::ContractCostParamEntry(_) => "ContractCostParamEntry", + Self::StateExpirationSettings(_) => "StateExpirationSettings", + Self::EvictionIterator(_) => "EvictionIterator", + Self::ContractCostParams(_) => "ContractCostParams", + Self::ConfigSettingId(_) => "ConfigSettingId", + Self::ConfigSettingEntry(_) => "ConfigSettingEntry", + Self::ScEnvMetaKind(_) => "ScEnvMetaKind", + Self::ScEnvMetaEntry(_) => "ScEnvMetaEntry", + Self::ScMetaV0(_) => "ScMetaV0", + Self::ScMetaKind(_) => "ScMetaKind", + Self::ScMetaEntry(_) => "ScMetaEntry", + Self::ScSpecType(_) => "ScSpecType", + Self::ScSpecTypeOption(_) => "ScSpecTypeOption", + Self::ScSpecTypeResult(_) => "ScSpecTypeResult", + Self::ScSpecTypeVec(_) => "ScSpecTypeVec", + Self::ScSpecTypeMap(_) => "ScSpecTypeMap", + Self::ScSpecTypeTuple(_) => "ScSpecTypeTuple", + Self::ScSpecTypeBytesN(_) => "ScSpecTypeBytesN", + Self::ScSpecTypeUdt(_) => "ScSpecTypeUdt", + Self::ScSpecTypeDef(_) => "ScSpecTypeDef", + Self::ScSpecUdtStructFieldV0(_) => "ScSpecUdtStructFieldV0", + Self::ScSpecUdtStructV0(_) => "ScSpecUdtStructV0", + Self::ScSpecUdtUnionCaseVoidV0(_) => "ScSpecUdtUnionCaseVoidV0", + Self::ScSpecUdtUnionCaseTupleV0(_) => "ScSpecUdtUnionCaseTupleV0", + Self::ScSpecUdtUnionCaseV0Kind(_) => "ScSpecUdtUnionCaseV0Kind", + Self::ScSpecUdtUnionCaseV0(_) => "ScSpecUdtUnionCaseV0", + Self::ScSpecUdtUnionV0(_) => "ScSpecUdtUnionV0", + Self::ScSpecUdtEnumCaseV0(_) => "ScSpecUdtEnumCaseV0", + Self::ScSpecUdtEnumV0(_) => "ScSpecUdtEnumV0", + Self::ScSpecUdtErrorEnumCaseV0(_) => "ScSpecUdtErrorEnumCaseV0", + Self::ScSpecUdtErrorEnumV0(_) => "ScSpecUdtErrorEnumV0", + Self::ScSpecFunctionInputV0(_) => "ScSpecFunctionInputV0", + Self::ScSpecFunctionV0(_) => "ScSpecFunctionV0", + Self::ScSpecEntryKind(_) => "ScSpecEntryKind", + Self::ScSpecEntry(_) => "ScSpecEntry", + Self::ScValType(_) => "ScValType", + Self::ScErrorType(_) => "ScErrorType", + Self::ScErrorCode(_) => "ScErrorCode", + Self::ScError(_) => "ScError", + Self::UInt128Parts(_) => "UInt128Parts", + Self::Int128Parts(_) => "Int128Parts", + Self::UInt256Parts(_) => "UInt256Parts", + Self::Int256Parts(_) => "Int256Parts", + Self::ContractExecutableType(_) => "ContractExecutableType", + Self::ContractExecutable(_) => "ContractExecutable", + Self::ScAddressType(_) => "ScAddressType", + Self::ScAddress(_) => "ScAddress", + Self::ScVec(_) => "ScVec", + Self::ScMap(_) => "ScMap", + Self::ScBytes(_) => "ScBytes", + Self::ScString(_) => "ScString", + Self::ScSymbol(_) => "ScSymbol", + Self::ScNonceKey(_) => "ScNonceKey", + Self::ScContractInstance(_) => "ScContractInstance", + Self::ScVal(_) => "ScVal", + Self::ScMapEntry(_) => "ScMapEntry", Self::StoredTransactionSet(_) => "StoredTransactionSet", Self::PersistedScpStateV0(_) => "PersistedScpStateV0", Self::PersistedScpStateV1(_) => "PersistedScpStateV1", Self::PersistedScpState(_) => "PersistedScpState", - Self::AccountId(_) => "AccountId", Self::Thresholds(_) => "Thresholds", Self::String32(_) => "String32", Self::String64(_) => "String64", Self::SequenceNumber(_) => "SequenceNumber", - Self::TimePoint(_) => "TimePoint", - Self::Duration(_) => "Duration", Self::DataValue(_) => "DataValue", Self::PoolId(_) => "PoolId", Self::AssetCode4(_) => "AssetCode4", @@ -39298,6 +52402,10 @@ impl Type { Self::LiquidityPoolEntry(_) => "LiquidityPoolEntry", Self::LiquidityPoolEntryBody(_) => "LiquidityPoolEntryBody", Self::LiquidityPoolEntryConstantProduct(_) => "LiquidityPoolEntryConstantProduct", + Self::ContractDataDurability(_) => "ContractDataDurability", + Self::ContractDataEntry(_) => "ContractDataEntry", + Self::ContractCodeEntry(_) => "ContractCodeEntry", + Self::ExpirationEntry(_) => "ExpirationEntry", Self::LedgerEntryExtensionV1(_) => "LedgerEntryExtensionV1", Self::LedgerEntryExtensionV1Ext(_) => "LedgerEntryExtensionV1Ext", Self::LedgerEntry(_) => "LedgerEntry", @@ -39310,6 +52418,10 @@ impl Type { Self::LedgerKeyData(_) => "LedgerKeyData", Self::LedgerKeyClaimableBalance(_) => "LedgerKeyClaimableBalance", Self::LedgerKeyLiquidityPool(_) => "LedgerKeyLiquidityPool", + Self::LedgerKeyContractData(_) => "LedgerKeyContractData", + Self::LedgerKeyContractCode(_) => "LedgerKeyContractCode", + Self::LedgerKeyConfigSetting(_) => "LedgerKeyConfigSetting", + Self::LedgerKeyExpiration(_) => "LedgerKeyExpiration", Self::EnvelopeType(_) => "EnvelopeType", Self::UpgradeType(_) => "UpgradeType", Self::StellarValueType(_) => "StellarValueType", @@ -39322,7 +52434,9 @@ impl Type { Self::LedgerHeader(_) => "LedgerHeader", Self::LedgerHeaderExt(_) => "LedgerHeaderExt", Self::LedgerUpgradeType(_) => "LedgerUpgradeType", + Self::ConfigUpgradeSetKey(_) => "ConfigUpgradeSetKey", Self::LedgerUpgrade(_) => "LedgerUpgrade", + Self::ConfigUpgradeSet(_) => "ConfigUpgradeSet", Self::BucketEntryType(_) => "BucketEntryType", Self::BucketMetadata(_) => "BucketMetadata", Self::BucketMetadataExt(_) => "BucketMetadataExt", @@ -39351,15 +52465,25 @@ impl Type { Self::OperationMeta(_) => "OperationMeta", Self::TransactionMetaV1(_) => "TransactionMetaV1", Self::TransactionMetaV2(_) => "TransactionMetaV2", + Self::ContractEventType(_) => "ContractEventType", + Self::ContractEvent(_) => "ContractEvent", + Self::ContractEventBody(_) => "ContractEventBody", + Self::ContractEventV0(_) => "ContractEventV0", + Self::DiagnosticEvent(_) => "DiagnosticEvent", + Self::SorobanTransactionMeta(_) => "SorobanTransactionMeta", + Self::TransactionMetaV3(_) => "TransactionMetaV3", + Self::InvokeHostFunctionSuccessPreImage(_) => "InvokeHostFunctionSuccessPreImage", Self::TransactionMeta(_) => "TransactionMeta", Self::TransactionResultMeta(_) => "TransactionResultMeta", Self::UpgradeEntryMeta(_) => "UpgradeEntryMeta", Self::LedgerCloseMetaV0(_) => "LedgerCloseMetaV0", Self::LedgerCloseMetaV1(_) => "LedgerCloseMetaV1", + Self::LedgerCloseMetaV2(_) => "LedgerCloseMetaV2", Self::LedgerCloseMeta(_) => "LedgerCloseMeta", Self::ErrorCode(_) => "ErrorCode", Self::SError(_) => "SError", Self::SendMore(_) => "SendMore", + Self::SendMoreExtended(_) => "SendMoreExtended", Self::AuthCert(_) => "AuthCert", Self::Hello(_) => "Hello", Self::Auth(_) => "Auth", @@ -39369,6 +52493,7 @@ impl Type { Self::MessageType(_) => "MessageType", Self::DontHave(_) => "DontHave", Self::SurveyMessageCommandType(_) => "SurveyMessageCommandType", + Self::SurveyMessageResponseType(_) => "SurveyMessageResponseType", Self::SurveyRequestMessage(_) => "SurveyRequestMessage", Self::SignedSurveyRequestMessage(_) => "SignedSurveyRequestMessage", Self::EncryptedBody(_) => "EncryptedBody", @@ -39376,7 +52501,8 @@ impl Type { Self::SignedSurveyResponseMessage(_) => "SignedSurveyResponseMessage", Self::PeerStats(_) => "PeerStats", Self::PeerStatList(_) => "PeerStatList", - Self::TopologyResponseBody(_) => "TopologyResponseBody", + Self::TopologyResponseBodyV0(_) => "TopologyResponseBodyV0", + Self::TopologyResponseBodyV1(_) => "TopologyResponseBodyV1", Self::SurveyResponseBody(_) => "SurveyResponseBody", Self::TxAdvertVector(_) => "TxAdvertVector", Self::FloodAdvert(_) => "FloodAdvert", @@ -39414,11 +52540,30 @@ impl Type { Self::SetTrustLineFlagsOp(_) => "SetTrustLineFlagsOp", Self::LiquidityPoolDepositOp(_) => "LiquidityPoolDepositOp", Self::LiquidityPoolWithdrawOp(_) => "LiquidityPoolWithdrawOp", + Self::HostFunctionType(_) => "HostFunctionType", + Self::ContractIdPreimageType(_) => "ContractIdPreimageType", + Self::ContractIdPreimage(_) => "ContractIdPreimage", + Self::ContractIdPreimageFromAddress(_) => "ContractIdPreimageFromAddress", + Self::CreateContractArgs(_) => "CreateContractArgs", + Self::InvokeContractArgs(_) => "InvokeContractArgs", + Self::HostFunction(_) => "HostFunction", + Self::SorobanAuthorizedFunctionType(_) => "SorobanAuthorizedFunctionType", + Self::SorobanAuthorizedFunction(_) => "SorobanAuthorizedFunction", + Self::SorobanAuthorizedInvocation(_) => "SorobanAuthorizedInvocation", + Self::SorobanAddressCredentials(_) => "SorobanAddressCredentials", + Self::SorobanCredentialsType(_) => "SorobanCredentialsType", + Self::SorobanCredentials(_) => "SorobanCredentials", + Self::SorobanAuthorizationEntry(_) => "SorobanAuthorizationEntry", + Self::InvokeHostFunctionOp(_) => "InvokeHostFunctionOp", + Self::BumpFootprintExpirationOp(_) => "BumpFootprintExpirationOp", + Self::RestoreFootprintOp(_) => "RestoreFootprintOp", Self::Operation(_) => "Operation", Self::OperationBody(_) => "OperationBody", Self::HashIdPreimage(_) => "HashIdPreimage", Self::HashIdPreimageOperationId(_) => "HashIdPreimageOperationId", Self::HashIdPreimageRevokeId(_) => "HashIdPreimageRevokeId", + Self::HashIdPreimageContractId(_) => "HashIdPreimageContractId", + Self::HashIdPreimageSorobanAuthorization(_) => "HashIdPreimageSorobanAuthorization", Self::MemoType(_) => "MemoType", Self::Memo(_) => "Memo", Self::TimeBounds(_) => "TimeBounds", @@ -39426,6 +52571,9 @@ impl Type { Self::PreconditionsV2(_) => "PreconditionsV2", Self::PreconditionType(_) => "PreconditionType", Self::Preconditions(_) => "Preconditions", + Self::LedgerFootprint(_) => "LedgerFootprint", + Self::SorobanResources(_) => "SorobanResources", + Self::SorobanTransactionData(_) => "SorobanTransactionData", Self::TransactionV0(_) => "TransactionV0", Self::TransactionV0Ext(_) => "TransactionV0Ext", Self::TransactionV0Envelope(_) => "TransactionV0Envelope", @@ -39505,6 +52653,12 @@ impl Type { Self::LiquidityPoolDepositResult(_) => "LiquidityPoolDepositResult", Self::LiquidityPoolWithdrawResultCode(_) => "LiquidityPoolWithdrawResultCode", Self::LiquidityPoolWithdrawResult(_) => "LiquidityPoolWithdrawResult", + Self::InvokeHostFunctionResultCode(_) => "InvokeHostFunctionResultCode", + Self::InvokeHostFunctionResult(_) => "InvokeHostFunctionResult", + Self::BumpFootprintExpirationResultCode(_) => "BumpFootprintExpirationResultCode", + Self::BumpFootprintExpirationResult(_) => "BumpFootprintExpirationResult", + Self::RestoreFootprintResultCode(_) => "RestoreFootprintResultCode", + Self::RestoreFootprintResult(_) => "RestoreFootprintResult", Self::OperationResultCode(_) => "OperationResultCode", Self::OperationResult(_) => "OperationResult", Self::OperationResultTr(_) => "OperationResultTr", @@ -39522,6 +52676,8 @@ impl Type { Self::Int32(_) => "Int32", Self::Uint64(_) => "Uint64", Self::Int64(_) => "Int64", + Self::TimePoint(_) => "TimePoint", + Self::Duration(_) => "Duration", Self::ExtensionPoint(_) => "ExtensionPoint", Self::CryptoKeyType(_) => "CryptoKeyType", Self::PublicKeyType(_) => "PublicKeyType", @@ -39532,6 +52688,7 @@ impl Type { Self::Signature(_) => "Signature", Self::SignatureHint(_) => "SignatureHint", Self::NodeId(_) => "NodeId", + Self::AccountId(_) => "AccountId", Self::Curve25519Secret(_) => "Curve25519Secret", Self::Curve25519Public(_) => "Curve25519Public", Self::HmacSha256Key(_) => "HmacSha256Key", @@ -39541,7 +52698,7 @@ impl Type { #[must_use] #[allow(clippy::too_many_lines)] - pub const fn variants() -> [TypeVariant; 305] { + pub const fn variants() -> [TypeVariant; 418] { Self::VARIANTS } @@ -39560,17 +52717,85 @@ impl Type { Self::ScpStatementExternalize(_) => TypeVariant::ScpStatementExternalize, Self::ScpEnvelope(_) => TypeVariant::ScpEnvelope, Self::ScpQuorumSet(_) => TypeVariant::ScpQuorumSet, + Self::ConfigSettingContractExecutionLanesV0(_) => { + TypeVariant::ConfigSettingContractExecutionLanesV0 + } + Self::ConfigSettingContractComputeV0(_) => TypeVariant::ConfigSettingContractComputeV0, + Self::ConfigSettingContractLedgerCostV0(_) => { + TypeVariant::ConfigSettingContractLedgerCostV0 + } + Self::ConfigSettingContractHistoricalDataV0(_) => { + TypeVariant::ConfigSettingContractHistoricalDataV0 + } + Self::ConfigSettingContractEventsV0(_) => TypeVariant::ConfigSettingContractEventsV0, + Self::ConfigSettingContractBandwidthV0(_) => { + TypeVariant::ConfigSettingContractBandwidthV0 + } + Self::ContractCostType(_) => TypeVariant::ContractCostType, + Self::ContractCostParamEntry(_) => TypeVariant::ContractCostParamEntry, + Self::StateExpirationSettings(_) => TypeVariant::StateExpirationSettings, + Self::EvictionIterator(_) => TypeVariant::EvictionIterator, + Self::ContractCostParams(_) => TypeVariant::ContractCostParams, + Self::ConfigSettingId(_) => TypeVariant::ConfigSettingId, + Self::ConfigSettingEntry(_) => TypeVariant::ConfigSettingEntry, + Self::ScEnvMetaKind(_) => TypeVariant::ScEnvMetaKind, + Self::ScEnvMetaEntry(_) => TypeVariant::ScEnvMetaEntry, + Self::ScMetaV0(_) => TypeVariant::ScMetaV0, + Self::ScMetaKind(_) => TypeVariant::ScMetaKind, + Self::ScMetaEntry(_) => TypeVariant::ScMetaEntry, + Self::ScSpecType(_) => TypeVariant::ScSpecType, + Self::ScSpecTypeOption(_) => TypeVariant::ScSpecTypeOption, + Self::ScSpecTypeResult(_) => TypeVariant::ScSpecTypeResult, + Self::ScSpecTypeVec(_) => TypeVariant::ScSpecTypeVec, + Self::ScSpecTypeMap(_) => TypeVariant::ScSpecTypeMap, + Self::ScSpecTypeTuple(_) => TypeVariant::ScSpecTypeTuple, + Self::ScSpecTypeBytesN(_) => TypeVariant::ScSpecTypeBytesN, + Self::ScSpecTypeUdt(_) => TypeVariant::ScSpecTypeUdt, + Self::ScSpecTypeDef(_) => TypeVariant::ScSpecTypeDef, + Self::ScSpecUdtStructFieldV0(_) => TypeVariant::ScSpecUdtStructFieldV0, + Self::ScSpecUdtStructV0(_) => TypeVariant::ScSpecUdtStructV0, + Self::ScSpecUdtUnionCaseVoidV0(_) => TypeVariant::ScSpecUdtUnionCaseVoidV0, + Self::ScSpecUdtUnionCaseTupleV0(_) => TypeVariant::ScSpecUdtUnionCaseTupleV0, + Self::ScSpecUdtUnionCaseV0Kind(_) => TypeVariant::ScSpecUdtUnionCaseV0Kind, + Self::ScSpecUdtUnionCaseV0(_) => TypeVariant::ScSpecUdtUnionCaseV0, + Self::ScSpecUdtUnionV0(_) => TypeVariant::ScSpecUdtUnionV0, + Self::ScSpecUdtEnumCaseV0(_) => TypeVariant::ScSpecUdtEnumCaseV0, + Self::ScSpecUdtEnumV0(_) => TypeVariant::ScSpecUdtEnumV0, + Self::ScSpecUdtErrorEnumCaseV0(_) => TypeVariant::ScSpecUdtErrorEnumCaseV0, + Self::ScSpecUdtErrorEnumV0(_) => TypeVariant::ScSpecUdtErrorEnumV0, + Self::ScSpecFunctionInputV0(_) => TypeVariant::ScSpecFunctionInputV0, + Self::ScSpecFunctionV0(_) => TypeVariant::ScSpecFunctionV0, + Self::ScSpecEntryKind(_) => TypeVariant::ScSpecEntryKind, + Self::ScSpecEntry(_) => TypeVariant::ScSpecEntry, + Self::ScValType(_) => TypeVariant::ScValType, + Self::ScErrorType(_) => TypeVariant::ScErrorType, + Self::ScErrorCode(_) => TypeVariant::ScErrorCode, + Self::ScError(_) => TypeVariant::ScError, + Self::UInt128Parts(_) => TypeVariant::UInt128Parts, + Self::Int128Parts(_) => TypeVariant::Int128Parts, + Self::UInt256Parts(_) => TypeVariant::UInt256Parts, + Self::Int256Parts(_) => TypeVariant::Int256Parts, + Self::ContractExecutableType(_) => TypeVariant::ContractExecutableType, + Self::ContractExecutable(_) => TypeVariant::ContractExecutable, + Self::ScAddressType(_) => TypeVariant::ScAddressType, + Self::ScAddress(_) => TypeVariant::ScAddress, + Self::ScVec(_) => TypeVariant::ScVec, + Self::ScMap(_) => TypeVariant::ScMap, + Self::ScBytes(_) => TypeVariant::ScBytes, + Self::ScString(_) => TypeVariant::ScString, + Self::ScSymbol(_) => TypeVariant::ScSymbol, + Self::ScNonceKey(_) => TypeVariant::ScNonceKey, + Self::ScContractInstance(_) => TypeVariant::ScContractInstance, + Self::ScVal(_) => TypeVariant::ScVal, + Self::ScMapEntry(_) => TypeVariant::ScMapEntry, Self::StoredTransactionSet(_) => TypeVariant::StoredTransactionSet, Self::PersistedScpStateV0(_) => TypeVariant::PersistedScpStateV0, Self::PersistedScpStateV1(_) => TypeVariant::PersistedScpStateV1, Self::PersistedScpState(_) => TypeVariant::PersistedScpState, - Self::AccountId(_) => TypeVariant::AccountId, Self::Thresholds(_) => TypeVariant::Thresholds, Self::String32(_) => TypeVariant::String32, Self::String64(_) => TypeVariant::String64, Self::SequenceNumber(_) => TypeVariant::SequenceNumber, - Self::TimePoint(_) => TypeVariant::TimePoint, - Self::Duration(_) => TypeVariant::Duration, Self::DataValue(_) => TypeVariant::DataValue, Self::PoolId(_) => TypeVariant::PoolId, Self::AssetCode4(_) => TypeVariant::AssetCode4, @@ -39632,6 +52857,10 @@ impl Type { Self::LiquidityPoolEntryConstantProduct(_) => { TypeVariant::LiquidityPoolEntryConstantProduct } + Self::ContractDataDurability(_) => TypeVariant::ContractDataDurability, + Self::ContractDataEntry(_) => TypeVariant::ContractDataEntry, + Self::ContractCodeEntry(_) => TypeVariant::ContractCodeEntry, + Self::ExpirationEntry(_) => TypeVariant::ExpirationEntry, Self::LedgerEntryExtensionV1(_) => TypeVariant::LedgerEntryExtensionV1, Self::LedgerEntryExtensionV1Ext(_) => TypeVariant::LedgerEntryExtensionV1Ext, Self::LedgerEntry(_) => TypeVariant::LedgerEntry, @@ -39644,6 +52873,10 @@ impl Type { Self::LedgerKeyData(_) => TypeVariant::LedgerKeyData, Self::LedgerKeyClaimableBalance(_) => TypeVariant::LedgerKeyClaimableBalance, Self::LedgerKeyLiquidityPool(_) => TypeVariant::LedgerKeyLiquidityPool, + Self::LedgerKeyContractData(_) => TypeVariant::LedgerKeyContractData, + Self::LedgerKeyContractCode(_) => TypeVariant::LedgerKeyContractCode, + Self::LedgerKeyConfigSetting(_) => TypeVariant::LedgerKeyConfigSetting, + Self::LedgerKeyExpiration(_) => TypeVariant::LedgerKeyExpiration, Self::EnvelopeType(_) => TypeVariant::EnvelopeType, Self::UpgradeType(_) => TypeVariant::UpgradeType, Self::StellarValueType(_) => TypeVariant::StellarValueType, @@ -39656,7 +52889,9 @@ impl Type { Self::LedgerHeader(_) => TypeVariant::LedgerHeader, Self::LedgerHeaderExt(_) => TypeVariant::LedgerHeaderExt, Self::LedgerUpgradeType(_) => TypeVariant::LedgerUpgradeType, + Self::ConfigUpgradeSetKey(_) => TypeVariant::ConfigUpgradeSetKey, Self::LedgerUpgrade(_) => TypeVariant::LedgerUpgrade, + Self::ConfigUpgradeSet(_) => TypeVariant::ConfigUpgradeSet, Self::BucketEntryType(_) => TypeVariant::BucketEntryType, Self::BucketMetadata(_) => TypeVariant::BucketMetadata, Self::BucketMetadataExt(_) => TypeVariant::BucketMetadataExt, @@ -39689,15 +52924,27 @@ impl Type { Self::OperationMeta(_) => TypeVariant::OperationMeta, Self::TransactionMetaV1(_) => TypeVariant::TransactionMetaV1, Self::TransactionMetaV2(_) => TypeVariant::TransactionMetaV2, + Self::ContractEventType(_) => TypeVariant::ContractEventType, + Self::ContractEvent(_) => TypeVariant::ContractEvent, + Self::ContractEventBody(_) => TypeVariant::ContractEventBody, + Self::ContractEventV0(_) => TypeVariant::ContractEventV0, + Self::DiagnosticEvent(_) => TypeVariant::DiagnosticEvent, + Self::SorobanTransactionMeta(_) => TypeVariant::SorobanTransactionMeta, + Self::TransactionMetaV3(_) => TypeVariant::TransactionMetaV3, + Self::InvokeHostFunctionSuccessPreImage(_) => { + TypeVariant::InvokeHostFunctionSuccessPreImage + } Self::TransactionMeta(_) => TypeVariant::TransactionMeta, Self::TransactionResultMeta(_) => TypeVariant::TransactionResultMeta, Self::UpgradeEntryMeta(_) => TypeVariant::UpgradeEntryMeta, Self::LedgerCloseMetaV0(_) => TypeVariant::LedgerCloseMetaV0, Self::LedgerCloseMetaV1(_) => TypeVariant::LedgerCloseMetaV1, + Self::LedgerCloseMetaV2(_) => TypeVariant::LedgerCloseMetaV2, Self::LedgerCloseMeta(_) => TypeVariant::LedgerCloseMeta, Self::ErrorCode(_) => TypeVariant::ErrorCode, Self::SError(_) => TypeVariant::SError, Self::SendMore(_) => TypeVariant::SendMore, + Self::SendMoreExtended(_) => TypeVariant::SendMoreExtended, Self::AuthCert(_) => TypeVariant::AuthCert, Self::Hello(_) => TypeVariant::Hello, Self::Auth(_) => TypeVariant::Auth, @@ -39707,6 +52954,7 @@ impl Type { Self::MessageType(_) => TypeVariant::MessageType, Self::DontHave(_) => TypeVariant::DontHave, Self::SurveyMessageCommandType(_) => TypeVariant::SurveyMessageCommandType, + Self::SurveyMessageResponseType(_) => TypeVariant::SurveyMessageResponseType, Self::SurveyRequestMessage(_) => TypeVariant::SurveyRequestMessage, Self::SignedSurveyRequestMessage(_) => TypeVariant::SignedSurveyRequestMessage, Self::EncryptedBody(_) => TypeVariant::EncryptedBody, @@ -39714,7 +52962,8 @@ impl Type { Self::SignedSurveyResponseMessage(_) => TypeVariant::SignedSurveyResponseMessage, Self::PeerStats(_) => TypeVariant::PeerStats, Self::PeerStatList(_) => TypeVariant::PeerStatList, - Self::TopologyResponseBody(_) => TypeVariant::TopologyResponseBody, + Self::TopologyResponseBodyV0(_) => TypeVariant::TopologyResponseBodyV0, + Self::TopologyResponseBodyV1(_) => TypeVariant::TopologyResponseBodyV1, Self::SurveyResponseBody(_) => TypeVariant::SurveyResponseBody, Self::TxAdvertVector(_) => TypeVariant::TxAdvertVector, Self::FloodAdvert(_) => TypeVariant::FloodAdvert, @@ -39754,11 +53003,32 @@ impl Type { Self::SetTrustLineFlagsOp(_) => TypeVariant::SetTrustLineFlagsOp, Self::LiquidityPoolDepositOp(_) => TypeVariant::LiquidityPoolDepositOp, Self::LiquidityPoolWithdrawOp(_) => TypeVariant::LiquidityPoolWithdrawOp, + Self::HostFunctionType(_) => TypeVariant::HostFunctionType, + Self::ContractIdPreimageType(_) => TypeVariant::ContractIdPreimageType, + Self::ContractIdPreimage(_) => TypeVariant::ContractIdPreimage, + Self::ContractIdPreimageFromAddress(_) => TypeVariant::ContractIdPreimageFromAddress, + Self::CreateContractArgs(_) => TypeVariant::CreateContractArgs, + Self::InvokeContractArgs(_) => TypeVariant::InvokeContractArgs, + Self::HostFunction(_) => TypeVariant::HostFunction, + Self::SorobanAuthorizedFunctionType(_) => TypeVariant::SorobanAuthorizedFunctionType, + Self::SorobanAuthorizedFunction(_) => TypeVariant::SorobanAuthorizedFunction, + Self::SorobanAuthorizedInvocation(_) => TypeVariant::SorobanAuthorizedInvocation, + Self::SorobanAddressCredentials(_) => TypeVariant::SorobanAddressCredentials, + Self::SorobanCredentialsType(_) => TypeVariant::SorobanCredentialsType, + Self::SorobanCredentials(_) => TypeVariant::SorobanCredentials, + Self::SorobanAuthorizationEntry(_) => TypeVariant::SorobanAuthorizationEntry, + Self::InvokeHostFunctionOp(_) => TypeVariant::InvokeHostFunctionOp, + Self::BumpFootprintExpirationOp(_) => TypeVariant::BumpFootprintExpirationOp, + Self::RestoreFootprintOp(_) => TypeVariant::RestoreFootprintOp, Self::Operation(_) => TypeVariant::Operation, Self::OperationBody(_) => TypeVariant::OperationBody, Self::HashIdPreimage(_) => TypeVariant::HashIdPreimage, Self::HashIdPreimageOperationId(_) => TypeVariant::HashIdPreimageOperationId, Self::HashIdPreimageRevokeId(_) => TypeVariant::HashIdPreimageRevokeId, + Self::HashIdPreimageContractId(_) => TypeVariant::HashIdPreimageContractId, + Self::HashIdPreimageSorobanAuthorization(_) => { + TypeVariant::HashIdPreimageSorobanAuthorization + } Self::MemoType(_) => TypeVariant::MemoType, Self::Memo(_) => TypeVariant::Memo, Self::TimeBounds(_) => TypeVariant::TimeBounds, @@ -39766,6 +53036,9 @@ impl Type { Self::PreconditionsV2(_) => TypeVariant::PreconditionsV2, Self::PreconditionType(_) => TypeVariant::PreconditionType, Self::Preconditions(_) => TypeVariant::Preconditions, + Self::LedgerFootprint(_) => TypeVariant::LedgerFootprint, + Self::SorobanResources(_) => TypeVariant::SorobanResources, + Self::SorobanTransactionData(_) => TypeVariant::SorobanTransactionData, Self::TransactionV0(_) => TypeVariant::TransactionV0, Self::TransactionV0Ext(_) => TypeVariant::TransactionV0Ext, Self::TransactionV0Envelope(_) => TypeVariant::TransactionV0Envelope, @@ -39863,6 +53136,14 @@ impl Type { TypeVariant::LiquidityPoolWithdrawResultCode } Self::LiquidityPoolWithdrawResult(_) => TypeVariant::LiquidityPoolWithdrawResult, + Self::InvokeHostFunctionResultCode(_) => TypeVariant::InvokeHostFunctionResultCode, + Self::InvokeHostFunctionResult(_) => TypeVariant::InvokeHostFunctionResult, + Self::BumpFootprintExpirationResultCode(_) => { + TypeVariant::BumpFootprintExpirationResultCode + } + Self::BumpFootprintExpirationResult(_) => TypeVariant::BumpFootprintExpirationResult, + Self::RestoreFootprintResultCode(_) => TypeVariant::RestoreFootprintResultCode, + Self::RestoreFootprintResult(_) => TypeVariant::RestoreFootprintResult, Self::OperationResultCode(_) => TypeVariant::OperationResultCode, Self::OperationResult(_) => TypeVariant::OperationResult, Self::OperationResultTr(_) => TypeVariant::OperationResultTr, @@ -39880,6 +53161,8 @@ impl Type { Self::Int32(_) => TypeVariant::Int32, Self::Uint64(_) => TypeVariant::Uint64, Self::Int64(_) => TypeVariant::Int64, + Self::TimePoint(_) => TypeVariant::TimePoint, + Self::Duration(_) => TypeVariant::Duration, Self::ExtensionPoint(_) => TypeVariant::ExtensionPoint, Self::CryptoKeyType(_) => TypeVariant::CryptoKeyType, Self::PublicKeyType(_) => TypeVariant::PublicKeyType, @@ -39890,6 +53173,7 @@ impl Type { Self::Signature(_) => TypeVariant::Signature, Self::SignatureHint(_) => TypeVariant::SignatureHint, Self::NodeId(_) => TypeVariant::NodeId, + Self::AccountId(_) => TypeVariant::AccountId, Self::Curve25519Secret(_) => TypeVariant::Curve25519Secret, Self::Curve25519Public(_) => TypeVariant::Curve25519Public, Self::HmacSha256Key(_) => TypeVariant::HmacSha256Key, diff --git a/src/next/generated.rs b/src/next/generated.rs index 046d2151..5171df3f 100644 --- a/src/next/generated.rs +++ b/src/next/generated.rs @@ -50,7 +50,7 @@ pub const XDR_FILES_SHA256: [(&str, &str); 12] = [ ), ( "xdr/next/Stellar-ledger.x", - "59077cbb5a1517fdaaaf7b1f0f750cf02f84984ed024441dc37b7f974866fa58", + "f9dcc0d632cc7d8f921e5d991c77a18838c68f4234e90f2abf90d297716968e3", ), ( "xdr/next/Stellar-overlay.x", @@ -16466,9 +16466,9 @@ impl WriteXdr for StellarValue { // MaskLedgerHeaderFlags is an XDR Const defines as: // -// const MASK_LEDGER_HEADER_FLAGS = 0x7F; +// const MASK_LEDGER_HEADER_FLAGS = 0x7; // -pub const MASK_LEDGER_HEADER_FLAGS: u64 = 0x7F; +pub const MASK_LEDGER_HEADER_FLAGS: u64 = 0x7; // LedgerHeaderFlags is an XDR Enum defines as: // @@ -16476,11 +16476,7 @@ pub const MASK_LEDGER_HEADER_FLAGS: u64 = 0x7F; // { // DISABLE_LIQUIDITY_POOL_TRADING_FLAG = 0x1, // DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG = 0x2, -// DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 0x4, -// DISABLE_CONTRACT_CREATE = 0x8, -// DISABLE_CONTRACT_UPDATE = 0x10, -// DISABLE_CONTRACT_REMOVE = 0x20, -// DISABLE_CONTRACT_INVOKE = 0x40 +// DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 0x4 // }; // // enum @@ -16493,50 +16489,30 @@ pub const MASK_LEDGER_HEADER_FLAGS: u64 = 0x7F; )] #[repr(i32)] pub enum LedgerHeaderFlags { - LiquidityPoolTradingFlag = 1, - LiquidityPoolDepositFlag = 2, - LiquidityPoolWithdrawalFlag = 4, - ContractCreate = 8, - ContractUpdate = 16, - ContractRemove = 32, - ContractInvoke = 64, + TradingFlag = 1, + DepositFlag = 2, + WithdrawalFlag = 4, } impl LedgerHeaderFlags { - pub const VARIANTS: [LedgerHeaderFlags; 7] = [ - LedgerHeaderFlags::LiquidityPoolTradingFlag, - LedgerHeaderFlags::LiquidityPoolDepositFlag, - LedgerHeaderFlags::LiquidityPoolWithdrawalFlag, - LedgerHeaderFlags::ContractCreate, - LedgerHeaderFlags::ContractUpdate, - LedgerHeaderFlags::ContractRemove, - LedgerHeaderFlags::ContractInvoke, - ]; - pub const VARIANTS_STR: [&'static str; 7] = [ - "LiquidityPoolTradingFlag", - "LiquidityPoolDepositFlag", - "LiquidityPoolWithdrawalFlag", - "ContractCreate", - "ContractUpdate", - "ContractRemove", - "ContractInvoke", + pub const VARIANTS: [LedgerHeaderFlags; 3] = [ + LedgerHeaderFlags::TradingFlag, + LedgerHeaderFlags::DepositFlag, + LedgerHeaderFlags::WithdrawalFlag, ]; + pub const VARIANTS_STR: [&'static str; 3] = ["TradingFlag", "DepositFlag", "WithdrawalFlag"]; #[must_use] pub const fn name(&self) -> &'static str { match self { - Self::LiquidityPoolTradingFlag => "LiquidityPoolTradingFlag", - Self::LiquidityPoolDepositFlag => "LiquidityPoolDepositFlag", - Self::LiquidityPoolWithdrawalFlag => "LiquidityPoolWithdrawalFlag", - Self::ContractCreate => "ContractCreate", - Self::ContractUpdate => "ContractUpdate", - Self::ContractRemove => "ContractRemove", - Self::ContractInvoke => "ContractInvoke", + Self::TradingFlag => "TradingFlag", + Self::DepositFlag => "DepositFlag", + Self::WithdrawalFlag => "WithdrawalFlag", } } #[must_use] - pub const fn variants() -> [LedgerHeaderFlags; 7] { + pub const fn variants() -> [LedgerHeaderFlags; 3] { Self::VARIANTS } } @@ -16567,13 +16543,9 @@ impl TryFrom for LedgerHeaderFlags { fn try_from(i: i32) -> Result { let e = match i { - 1 => LedgerHeaderFlags::LiquidityPoolTradingFlag, - 2 => LedgerHeaderFlags::LiquidityPoolDepositFlag, - 4 => LedgerHeaderFlags::LiquidityPoolWithdrawalFlag, - 8 => LedgerHeaderFlags::ContractCreate, - 16 => LedgerHeaderFlags::ContractUpdate, - 32 => LedgerHeaderFlags::ContractRemove, - 64 => LedgerHeaderFlags::ContractInvoke, + 1 => LedgerHeaderFlags::TradingFlag, + 2 => LedgerHeaderFlags::DepositFlag, + 4 => LedgerHeaderFlags::WithdrawalFlag, #[allow(unreachable_patterns)] _ => return Err(Error::Invalid), }; diff --git a/xdr/curr b/xdr/curr index 07e9e82b..9ac02641 160000 --- a/xdr/curr +++ b/xdr/curr @@ -1 +1 @@ -Subproject commit 07e9e82b8d60244596214b4d327506d791d35ad3 +Subproject commit 9ac02641139e6717924fdad716f6e958d0168491 diff --git a/xdr/curr-version b/xdr/curr-version index 837a1a41..c5e549e9 100644 --- a/xdr/curr-version +++ b/xdr/curr-version @@ -1 +1 @@ -07e9e82b8d60244596214b4d327506d791d35ad3 \ No newline at end of file +9ac02641139e6717924fdad716f6e958d0168491 \ No newline at end of file diff --git a/xdr/next b/xdr/next index 65afa63b..1c70d732 160000 --- a/xdr/next +++ b/xdr/next @@ -1 +1 @@ -Subproject commit 65afa63b7f52c898143ebbe9541ef91fcf290ade +Subproject commit 1c70d732c0a7514c3b42dbce0f4c86e87fb04f2f diff --git a/xdr/next-version b/xdr/next-version index f128ab87..3d6ec63e 100644 --- a/xdr/next-version +++ b/xdr/next-version @@ -1 +1 @@ -65afa63b7f52c898143ebbe9541ef91fcf290ade \ No newline at end of file +1c70d732c0a7514c3b42dbce0f4c86e87fb04f2f \ No newline at end of file From 93968e1afc3e3af6c4ac9e651f03122d0a839788 Mon Sep 17 00:00:00 2001 From: Siddharth Suresh Date: Fri, 8 Sep 2023 14:04:15 -0700 Subject: [PATCH 2/2] Add missing soroban files --- src/curr/mod.rs | 11 + src/curr/scmap.rs | 75 ++++ src/curr/scval_conversions.rs | 808 ++++++++++++++++++++++++++++++++++ src/curr/scval_validations.rs | 169 +++++++ 4 files changed, 1063 insertions(+) create mode 100644 src/curr/scmap.rs create mode 100644 src/curr/scval_conversions.rs create mode 100644 src/curr/scval_validations.rs diff --git a/src/curr/mod.rs b/src/curr/mod.rs index 14ed6711..a36c0299 100644 --- a/src/curr/mod.rs +++ b/src/curr/mod.rs @@ -1,2 +1,13 @@ mod generated; pub use generated::*; + +mod scval_conversions; +pub use scval_conversions::*; + +mod scval_validations; +pub use scval_validations::*; + +#[cfg(feature = "alloc")] +mod scmap; +#[cfg(feature = "alloc")] +pub use scmap::*; diff --git a/src/curr/scmap.rs b/src/curr/scmap.rs new file mode 100644 index 00000000..6e44e654 --- /dev/null +++ b/src/curr/scmap.rs @@ -0,0 +1,75 @@ +#![allow(clippy::missing_errors_doc)] + +use super::{Error, ScMap, ScMapEntry, ScVal, Validate}; +extern crate alloc; +use alloc::vec::Vec; + +impl ScMap { + pub fn sorted_from_entries(entries: I) -> Result + where + E: TryInto, + I: Iterator, + { + let mut v = entries + .map(TryInto::try_into) + .collect::, _>>() + .map_err(|_| Error::Invalid)?; + // TODO: Add tests that prove order consistency of ScVal with RawVal. https://github.com/stellar/rs-stellar-xdr/issues/117 + v.sort_by(|a, b| a.key.cmp(&b.key)); + let m = ScMap(v.try_into()?); + // `validate` will further check that there are no duplicates. + m.validate()?; + Ok(m) + } + + pub fn sorted_from_pairs(pairs: I) -> Result + where + K: TryInto, + V: TryInto, + I: Iterator, + { + Self::sorted_from_entries(pairs) + } + + pub fn sorted_from(src: I) -> Result + where + E: TryInto, + I: IntoIterator, + { + Self::sorted_from_entries(src.into_iter()) + } +} + +#[cfg(test)] +mod test { + use super::*; + use alloc::{collections::BTreeMap, vec}; + + #[test] + fn scmap_from_map() -> Result<(), ()> { + let mut m: BTreeMap = BTreeMap::new(); + m.insert(1, 2); + m.insert(5, 6); + m.insert(3, 4); + let scm = ScMap::sorted_from(m)?; + assert_eq!(scm.0.first().unwrap().key, 1u32.into()); + assert_eq!(scm.0.last().unwrap().key, 5u32.into()); + Ok(()) + } + + #[test] + fn scmap_from_pairs() -> Result<(), ()> { + let pairs: Vec<(u32, u32)> = vec![(3, 4), (5, 6), (1, 2)]; + let scm = ScMap::sorted_from(pairs)?; + assert_eq!(scm.0.first().unwrap().key, 1u32.into()); + assert_eq!(scm.0.last().unwrap().key, 5u32.into()); + Ok(()) + } + + #[test] + fn scmap_from_pairs_containing_duplicate_keys() { + let pairs: Vec<(u32, u32)> = vec![(3, 4), (3, 5), (5, 6), (1, 2)]; + let scm = ScMap::sorted_from(pairs); + assert!(scm.is_err()); + } +} diff --git a/src/curr/scval_conversions.rs b/src/curr/scval_conversions.rs new file mode 100644 index 00000000..e15102d7 --- /dev/null +++ b/src/curr/scval_conversions.rs @@ -0,0 +1,808 @@ +use super::{ + Int128Parts, ScBytes, ScError, ScMap, ScMapEntry, ScSymbol, ScVal, ScVec, UInt128Parts, +}; + +#[cfg(all(not(feature = "std"), feature = "alloc"))] +extern crate alloc; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::{string::String, vec, vec::Vec}; + +// TODO: Use the Error type for conversions in this file. + +impl From for ScVal { + fn from(v: ScError) -> Self { + ScVal::Error(v) + } +} + +impl TryFrom for ScError { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Error(s) = v { + Ok(s) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: i32) -> ScVal { + ScVal::I32(v) + } +} + +impl From<&i32> for ScVal { + fn from(v: &i32) -> ScVal { + ScVal::I32(*v) + } +} + +impl TryFrom for i32 { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::I32(i) = v { + Ok(i) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: u32) -> ScVal { + ScVal::U32(v) + } +} + +impl From<&u32> for ScVal { + fn from(v: &u32) -> ScVal { + ScVal::U32(*v) + } +} + +impl TryFrom for u32 { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::U32(i) = v { + Ok(i) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: i64) -> ScVal { + ScVal::I64(v) + } +} + +impl From<&i64> for ScVal { + fn from(v: &i64) -> ScVal { + <_ as Into>::into(*v) + } +} + +impl TryFrom for i64 { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::I64(i) = v { + Ok(i) + } else { + Err(()) + } + } +} + +impl From<()> for ScVal { + fn from(_: ()) -> Self { + ScVal::Void + } +} + +impl From<&()> for ScVal { + fn from(_: &()) -> Self { + ScVal::Void + } +} + +impl TryFrom for () { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Void = v { + Ok(()) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: bool) -> Self { + ScVal::Bool(v) + } +} + +impl From<&bool> for ScVal { + fn from(v: &bool) -> Self { + <_ as Into>::into(*v) + } +} + +impl TryFrom for bool { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Bool(b) = v { + Ok(b) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: u64) -> Self { + ScVal::U64(v) + } +} + +impl From<&u64> for ScVal { + fn from(v: &u64) -> Self { + ScVal::U64(*v) + } +} + +impl TryFrom for u64 { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::U64(i) = v { + Ok(i) + } else { + Err(()) + } + } +} + +pub mod int128_helpers { + #[must_use] + #[inline(always)] + #[allow(clippy::inline_always, clippy::cast_possible_truncation)] + pub fn u128_hi(u: u128) -> u64 { + (u >> 64) as u64 + } + + #[must_use] + #[inline(always)] + #[allow(clippy::inline_always, clippy::cast_possible_truncation)] + pub fn u128_lo(u: u128) -> u64 { + u as u64 + } + + #[must_use] + #[inline(always)] + #[allow(clippy::inline_always)] + pub fn u128_from_pieces(hi: u64, lo: u64) -> u128 { + (u128::from(hi) << 64) | u128::from(lo) + } + + #[must_use] + #[inline(always)] + #[allow(clippy::inline_always, clippy::cast_possible_truncation)] + pub fn i128_hi(i: i128) -> i64 { + (i >> 64) as i64 + } + + #[must_use] + #[inline(always)] + #[allow( + clippy::inline_always, + clippy::cast_possible_truncation, + clippy::cast_sign_loss + )] + pub fn i128_lo(i: i128) -> u64 { + i as u64 + } + + #[must_use] + #[inline(always)] + #[allow( + clippy::inline_always, + clippy::cast_sign_loss, + clippy::cast_possible_wrap + )] + pub fn i128_from_pieces(hi: i64, lo: u64) -> i128 { + (u128::from(hi as u64) << 64 | u128::from(lo)) as i128 + } +} + +#[allow(clippy::wildcard_imports)] +use int128_helpers::*; + +impl From for ScVal { + fn from(v: u128) -> Self { + ScVal::U128(UInt128Parts { + hi: u128_hi(v), + lo: u128_lo(v), + }) + } +} + +impl From<&u128> for ScVal { + fn from(v: &u128) -> Self { + >::from(*v) + } +} + +impl From<&UInt128Parts> for u128 { + fn from(v: &UInt128Parts) -> Self { + u128_from_pieces(v.hi, v.lo) + } +} + +impl TryFrom for u128 { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::U128(i) = v { + Ok((&i).into()) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: i128) -> Self { + ScVal::I128(Int128Parts { + hi: i128_hi(v), + lo: i128_lo(v), + }) + } +} + +impl From<&i128> for ScVal { + fn from(v: &i128) -> Self { + >::from(*v) + } +} + +impl From<&Int128Parts> for i128 { + fn from(v: &Int128Parts) -> Self { + i128_from_pieces(v.hi, v.lo) + } +} + +impl TryFrom for i128 { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::I128(i) = v { + Ok((&i).into()) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: ScSymbol) -> Self { + ScVal::Symbol(v) + } +} + +impl TryFrom for ScSymbol { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Symbol(s) = v { + Ok(s) + } else { + Err(()) + } + } +} + +#[cfg(feature = "alloc")] +impl TryFrom for ScVal { + type Error = (); + fn try_from(v: String) -> Result { + Ok(ScVal::Symbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&String> for ScVal { + type Error = (); + fn try_from(v: &String) -> Result { + Ok(ScVal::Symbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom for ScSymbol { + type Error = (); + fn try_from(v: String) -> Result { + Ok(ScSymbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&String> for ScSymbol { + type Error = (); + fn try_from(v: &String) -> Result { + Ok(ScSymbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&str> for ScVal { + type Error = (); + fn try_from(v: &str) -> Result { + Ok(ScVal::Symbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(not(feature = "alloc"))] +impl TryFrom<&'static str> for ScVal { + type Error = (); + fn try_from(v: &'static str) -> Result { + Ok(ScVal::Symbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&str> for ScSymbol { + type Error = (); + fn try_from(v: &str) -> Result { + Ok(ScSymbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(not(feature = "alloc"))] +impl TryFrom<&'static str> for ScSymbol { + type Error = (); + fn try_from(v: &'static str) -> Result { + Ok(ScSymbol(v.try_into().map_err(|_| ())?)) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom for String { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Symbol(s) = v { + // TODO: It might be worth distinguishing the error case where this + // is an invalid symbol with invalid characters. + Ok(s.0.into_string().map_err(|_| ())?) + } else { + Err(()) + } + } +} + +#[cfg(feature = "alloc")] +impl TryFrom> for ScVal { + type Error = (); + fn try_from(v: Vec) -> Result { + Ok(ScVal::Bytes(ScBytes(v.try_into().map_err(|_| ())?))) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&Vec> for ScVal { + type Error = (); + fn try_from(v: &Vec) -> Result { + Ok(ScVal::Bytes(ScBytes(v.try_into().map_err(|_| ())?))) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&[u8]> for ScVal { + type Error = (); + fn try_from(v: &[u8]) -> Result { + Ok(ScVal::Bytes(ScBytes(v.try_into().map_err(|_| ())?))) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<[u8; N]> for ScVal { + type Error = (); + fn try_from(v: [u8; N]) -> Result { + Ok(ScVal::Bytes(ScBytes(v.try_into().map_err(|_| ())?))) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&[u8; N]> for ScVal { + type Error = (); + fn try_from(v: &[u8; N]) -> Result { + Ok(ScVal::Bytes(ScBytes(v.try_into().map_err(|_| ())?))) + } +} + +#[cfg(not(feature = "alloc"))] +impl TryFrom<&'static [u8]> for ScVal { + type Error = (); + fn try_from(v: &'static [u8]) -> Result { + Ok(ScVal::Bytes(ScBytes(v.try_into().map_err(|_| ())?))) + } +} + +#[cfg(feature = "alloc")] +impl TryFrom for Vec { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Bytes(ScBytes(b)) = v { + Ok(b.into()) + } else { + Err(()) + } + } +} + +#[cfg(feature = "alloc")] +impl TryFrom<&ScVal> for Vec { + type Error = (); + fn try_from(v: &ScVal) -> Result { + if let ScVal::Bytes(ScBytes(b)) = v { + Ok(b.into()) + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: ScVec) -> Self { + ScVal::Vec(Some(v)) + } +} + +#[cfg(feature = "alloc")] +impl> TryFrom> for ScVal { + type Error = (); + fn try_from(v: Vec) -> Result { + Ok(ScVal::Vec(Some( + v.into_iter() + .map(|t| <_ as TryInto>::try_into(t)) + .collect::, _>>() // TODO: Impl conversion from Iterator to VecM in xdrgen generated code. + .map_err(|_| ())? + .try_into() + .map_err(|_| ())?, + ))) + } +} + +#[cfg(feature = "alloc")] +impl + Clone> TryFrom<&Vec> for ScVal { + type Error = (); + fn try_from(v: &Vec) -> Result { + Ok(ScVal::Vec(Some( + v.iter() + .map(|t| <_ as TryInto>::try_into(t.clone())) + .collect::, _>>() // TODO: Impl conversion from Iterator to VecM in xdrgen generated code. + .map_err(|_| ())? + .try_into() + .map_err(|_| ())?, + ))) + } +} + +#[cfg(feature = "alloc")] +impl + Clone> TryFrom<&[T]> for ScVal { + type Error = (); + fn try_from(v: &[T]) -> Result { + Ok(ScVal::Vec(Some( + v.iter() + .map(|t| <_ as TryInto>::try_into(t.clone())) + .collect::, _>>() // TODO: Impl conversion from Iterator to VecM in xdrgen generated code. + .map_err(|_| ())? + .try_into() + .map_err(|_| ())?, + ))) + } +} + +#[cfg(feature = "alloc")] +impl + Clone> TryFrom for Vec { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Vec(Some(v)) = v { + v.iter() + .map(|t| T::try_from(t.clone()).map_err(|_| ())) + .collect::, _>>() + } else { + Err(()) + } + } +} + +impl From for ScVal { + fn from(v: ScMap) -> Self { + ScVal::Map(Some(v)) + } +} + +impl TryFrom for ScMap { + type Error = (); + fn try_from(v: ScVal) -> Result { + if let ScVal::Map(Some(m)) = v { + Ok(m) + } else { + Err(()) + } + } +} + +impl TryFrom<(K, V)> for ScMapEntry +where + K: TryInto, + V: TryInto, +{ + type Error = (); + + fn try_from(v: (K, V)) -> Result { + Ok(ScMapEntry { + key: v.0.try_into().map_err(|_| ())?, + val: v.1.try_into().map_err(|_| ())?, + }) + } +} + +// TODO: Add conversions from std::collections::HashMap, im_rcOrdMap, and other +// popular map types to ScMap. + +impl> From> for ScVal { + fn from(v: Option) -> Self { + match v { + Some(v) => v.into(), + None => ().into(), + } + } +} + +macro_rules! impl_for_tuple { + ( $count:literal $($typ:ident $idx:tt)+ ) => { + #[cfg(feature = "alloc")] + impl<$($typ),*> TryFrom<($($typ,)*)> for ScVec + where + $($typ: TryInto),* + { + type Error = (); + fn try_from(v: ($($typ,)*)) -> Result { + let vec: Vec = vec![$(v.$idx.try_into().map_err(|_| ())?),+]; + Ok(ScVec(vec.try_into()?)) + } + } + + #[cfg(feature = "alloc")] + impl<$($typ),*> TryFrom<($($typ,)*)> for ScVal + where + $($typ: TryInto),* + { + type Error = (); + fn try_from(v: ($($typ,)*)) -> Result { + Ok(ScVal::Vec(Some(<_ as TryInto>::try_into(v)?))) + } + } + + impl<$($typ),*> TryFrom for ($($typ,)*) + where + // TODO: Consider removing the Clone constraint by changing the + // try_from to use a reference. + $($typ: TryFrom + Clone),* + { + type Error = (); + + fn try_from(vec: ScVec) -> Result { + if vec.len() != $count { + return Err(()); + } + Ok(( + $({ + let idx: usize = $idx; + let val = vec[idx].clone(); + $typ::try_from(val).map_err(|_| ())? + },)* + )) + } + } + + impl<$($typ),*> TryFrom for ($($typ,)*) + where + $($typ: TryFrom + Clone),* + { + type Error = (); + + fn try_from(obj: ScVal) -> Result { + if let ScVal::Vec(Some(vec)) = obj { + <_ as TryFrom>::try_from(vec) + } else { + Err(()) + } + } + } + }; +} + +impl_for_tuple! { 1 T0 0 } +impl_for_tuple! { 2 T0 0 T1 1 } +impl_for_tuple! { 3 T0 0 T1 1 T2 2 } +impl_for_tuple! { 4 T0 0 T1 1 T2 2 T3 3 } +impl_for_tuple! { 5 T0 0 T1 1 T2 2 T3 3 T4 4 } +impl_for_tuple! { 6 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 } +impl_for_tuple! { 7 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 } +impl_for_tuple! { 8 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 } +impl_for_tuple! { 9 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 } +impl_for_tuple! { 10 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 } +impl_for_tuple! { 11 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 T10 10 } +impl_for_tuple! { 12 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 T10 10 T11 11 } +impl_for_tuple! { 13 T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 T10 10 T11 11 T12 12 } + +#[cfg(test)] +mod test { + use super::{int128_helpers, Int128Parts, ScVal, UInt128Parts}; + + #[test] + fn i32_pos() { + let v = 5; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::I32(5)); + let roundtrip: i32 = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[test] + fn i32_neg() { + let v = -5; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::I32(-5)); + let roundtrip: i32 = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[test] + fn u32() { + use super::ScVal; + + let v = 5u32; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::U32(5)); + let roundtrip: u32 = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[test] + fn i64_pos() { + let v = 5i64; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::I64(5)); + let roundtrip: i64 = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[test] + fn i64_neg() { + let v = -5i64; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::I64(-5)); + let roundtrip: i64 = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[test] + fn u64() { + let v = 5u64; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::U64(5)); + let roundtrip: u64 = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[test] + fn u128() { + let hi = 0x1234_5678_9abc_def0u64; + let lo = 0xfedc_ba98_7654_3210u64; + let u = int128_helpers::u128_from_pieces(hi, lo); + assert_eq!(u, 0x1234_5678_9abc_def0_fedc_ba98_7654_3210); + assert_eq!(int128_helpers::u128_hi(u), hi); + assert_eq!(int128_helpers::u128_lo(u), lo); + + let val: ScVal = u.try_into().unwrap(); + assert_eq!(val, ScVal::U128(UInt128Parts { hi, lo })); + let roundtrip: u128 = val.try_into().unwrap(); + assert_eq!(u, roundtrip); + } + + #[test] + #[allow(clippy::cast_sign_loss, clippy::cast_possible_wrap)] + fn i128() { + let part1 = 0x00ab_cdef_9876_5432u64; // some positive int64 + let part2 = 0xfedc_ba98_7654_3210u64; // some negative int64 + let roundtrip = |hi: i64, lo: u64, ref_i128: i128| { + let i = int128_helpers::i128_from_pieces(hi, lo); + assert_eq!(i, ref_i128); + assert_eq!(int128_helpers::i128_hi(i), hi); + assert_eq!(int128_helpers::i128_lo(i), lo); + + let val: ScVal = i.try_into().unwrap(); + assert_eq!(val, ScVal::I128(Int128Parts { hi, lo })); + let roundtrip: i128 = val.try_into().unwrap(); + assert_eq!(i, roundtrip); + }; + roundtrip( + part1 as i64, + part1, + 0x00ab_cdef_9876_5432_00ab_cdef_9876_5432, + ); + roundtrip( + part2 as i64, + part2, + 0xfedc_ba98_7654_3210_fedc_ba98_7654_3210u128 as i128, + ); + roundtrip( + part1 as i64, + part2, + 0x00ab_cdef_9876_5432_fedc_ba98_7654_3210, + ); + roundtrip( + part2 as i64, + part1, + 0xfedc_ba98_7654_3210_00ab_cdef_9876_5432u128 as i128, + ); + } + + #[cfg(feature = "alloc")] + #[test] + fn binary() { + extern crate alloc; + use alloc::vec; + + let v = [1, 2, 3, 4, 5]; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::Bytes(vec![1, 2, 3, 4, 5].try_into().unwrap())); + + let v = &[1, 2, 3, 4, 5]; + let val: ScVal = v.try_into().unwrap(); + assert_eq!(val, ScVal::Bytes(vec![1, 2, 3, 4, 5].try_into().unwrap())); + } + + #[cfg(feature = "alloc")] + #[test] + fn vec() { + extern crate alloc; + use alloc::vec; + use alloc::vec::Vec; + + let v = vec![1, 2, 3, 4, 5]; + let val: ScVal = v.clone().try_into().unwrap(); + let roundtrip: Vec = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + + let v = vec![vec![true], vec![false]]; + let val: ScVal = v.clone().try_into().unwrap(); + let roundtrip: Vec> = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[cfg(feature = "alloc")] + #[test] + fn tuple() { + extern crate alloc; + use alloc::vec; + use alloc::vec::Vec; + let v = (1i32, 2i64, vec![true, false]); + let val: ScVal = v.clone().try_into().unwrap(); + let roundtrip: (i32, i64, Vec) = val.try_into().unwrap(); + assert_eq!(v, roundtrip); + } + + #[test] + fn option() { + let v: Option = Some(1); + let val: ScVal = v.into(); + assert_eq!(val, ScVal::I64(1)); + + let v: Option = None; + let val: ScVal = v.into(); + assert_eq!(val, ScVal::Void); + } +} diff --git a/src/curr/scval_validations.rs b/src/curr/scval_validations.rs new file mode 100644 index 00000000..c7305591 --- /dev/null +++ b/src/curr/scval_validations.rs @@ -0,0 +1,169 @@ +#![allow(clippy::missing_errors_doc)] + +use super::{Error, ScMap, ScVal}; + +pub trait Validate { + type Error; + fn validate(&self) -> Result<(), Self::Error>; +} + +impl Validate for ScVal { + type Error = Error; + + fn validate(&self) -> Result<(), ::Error> { + match self { + ScVal::U32(_) + | ScVal::I32(_) + | ScVal::Error(_) + | ScVal::Bool(_) + | ScVal::Void + | ScVal::U64(_) + | ScVal::I64(_) + | ScVal::Timepoint(_) + | ScVal::Duration(_) + | ScVal::U128(_) + | ScVal::I128(_) + | ScVal::U256(_) + | ScVal::I256(_) + | ScVal::Bytes(_) + | ScVal::String(_) + | ScVal::Vec(Some(_)) + | ScVal::Address(_) + | ScVal::LedgerKeyContractInstance + | ScVal::LedgerKeyNonce(_) + | ScVal::ContractInstance(_) => Ok(()), + + ScVal::Symbol(s) => { + // Symbol is defined as valid per https://github.com/stellar/rs-stellar-contract-env/blob/94c1717516c8fad4ad65caa148183b9fcbc408db/stellar-contract-env-common/src/symbol.rs#L107-L111. + if s.iter() + .all(|c| matches!(*c as char, '_' | '0'..='9' | 'A'..='Z' | 'a'..='z')) + { + Ok(()) + } else { + Err(Error::Invalid) + } + } + ScVal::Vec(None) | ScVal::Map(None) => Err(Error::Invalid), + ScVal::Map(Some(m)) => m.validate(), + } + } +} + +impl Validate for ScMap { + type Error = Error; + + fn validate(&self) -> Result<(), Self::Error> { + // Check the map is sorted by key, and there are no keys that are + // duplicates. + if self.windows(2).all(|w| w[0].key < w[1].key) { + Ok(()) + } else { + Err(Error::Invalid) + } + } +} + +#[cfg(test)] +mod test { + use crate::curr::ScSymbol; + + use super::{Error, ScVal, Validate}; + + #[test] + fn symbol() { + assert_eq!( + ScVal::Symbol(ScSymbol("".try_into().unwrap())).validate(), + Ok(()) + ); + assert_eq!( + ScVal::Symbol(ScSymbol("a0A_".try_into().unwrap())).validate(), + Ok(()) + ); + assert_eq!( + ScVal::Symbol(ScSymbol("]".try_into().unwrap())).validate(), + Err(Error::Invalid) + ); + } + + #[test] + #[cfg(feature = "alloc")] + fn map() { + use super::super::{ScMap, ScMapEntry}; + extern crate alloc; + use alloc::vec; + // Maps should be sorted by key and have no duplicates. The sort order + // is just the "normal" sort order on ScVal emitted by derive(PartialOrd). + assert_eq!( + ScVal::Map(Some(ScMap( + vec![ + ScMapEntry { + key: ScVal::I64(0), + val: ScVal::U32(1), + }, + ScMapEntry { + key: ScVal::I64(1), + val: ScVal::I64(1), + } + ] + .try_into() + .unwrap() + ))) + .validate(), + Ok(()) + ); + assert_eq!( + ScVal::Map(Some(ScMap( + vec![ + ScMapEntry { + key: ScVal::I64(0), + val: ScVal::I64(1), + }, + ScMapEntry { + key: ScVal::I64(1), + val: ScVal::I64(1), + } + ] + .try_into() + .unwrap() + ))) + .validate(), + Ok(()) + ); + assert_eq!( + ScVal::Map(Some(ScMap( + vec![ + ScMapEntry { + key: ScVal::I64(2), + val: ScVal::I64(1), + }, + ScMapEntry { + key: ScVal::I64(1), + val: ScVal::I64(1), + } + ] + .try_into() + .unwrap() + ))) + .validate(), + Err(Error::Invalid) + ); + assert_eq!( + ScVal::Map(Some(ScMap( + vec![ + ScMapEntry { + key: ScVal::I64(2), + val: ScVal::I64(1), + }, + ScMapEntry { + key: ScVal::U32(1), + val: ScVal::I64(1), + }, + ] + .try_into() + .unwrap() + ))) + .validate(), + Err(Error::Invalid) + ); + } +}