#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(clippy::unnecessary_cast)]
use crate::*;
use core::option::Option;
use core::ops::{Deref, DerefMut};
#[cfg(feature = "std")]
use std::io::{Read, Write};
use xdrs::*;
#[cfg(feature = "serde")]
use ::serde::{{Serialize, Deserialize}};
pub type BlockID = u64;
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct BlockExecutionContext {
pub block_height: BlockHeight,
pub block_timepoint: TimePoint,
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct DbTip {
pub id: BlockID,
pub storage_long_hash: StorageLongHash,
pub value: ConsensusValue,
pub default_wallet: DeployedContractHash,
pub network_config: NetworkConfig,
}
pub type TransactionID = u64;
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
pub struct RPCError(pub i32);
impl RPCError {
pub const kRPCNone: Self = Self(0);
pub const kRPCNotFound: Self = Self(1);
pub const kRPCBadBlockID: Self = Self(3);
pub const kRPCStorageWriteFailed: Self = Self(4);
pub const kRPCTransactionFailed: Self = Self(5);
pub const kRPCUnimplemented: Self = Self(6);
pub const kRPCUnrecoverable: Self = Self(7);
}
impl From<i32> for RPCError {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "std")]
impl core::fmt::Display for RPCError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::kRPCNone.0 => {
write!(f, "RPCError::kRPCNone")
},
x if x == Self::kRPCNotFound.0 => {
write!(f, "RPCError::kRPCNotFound")
},
x if x == Self::kRPCBadBlockID.0 => {
write!(f, "RPCError::kRPCBadBlockID")
},
x if x == Self::kRPCStorageWriteFailed.0 => {
write!(f, "RPCError::kRPCStorageWriteFailed")
},
x if x == Self::kRPCTransactionFailed.0 => {
write!(f, "RPCError::kRPCTransactionFailed")
},
x if x == Self::kRPCUnimplemented.0 => {
write!(f, "RPCError::kRPCUnimplemented")
},
x if x == Self::kRPCUnrecoverable.0 => {
write!(f, "RPCError::kRPCUnrecoverable")
},
_ => {
write!(f, "RPCError({})", self.0)
}
}
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
pub struct BlockExecutionMode(pub i32);
impl BlockExecutionMode {
pub const kBlockExecutionModeValidation: Self = Self(0);
pub const kBlockExecutionModeProposal: Self = Self(1);
pub const kBlockExecutionModeViewing: Self = Self(2);
}
impl From<i32> for BlockExecutionMode {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "std")]
impl core::fmt::Display for BlockExecutionMode {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::kBlockExecutionModeValidation.0 => {
write!(f, "BlockExecutionMode::kBlockExecutionModeValidation")
},
x if x == Self::kBlockExecutionModeProposal.0 => {
write!(f, "BlockExecutionMode::kBlockExecutionModeProposal")
},
x if x == Self::kBlockExecutionModeViewing.0 => {
write!(f, "BlockExecutionMode::kBlockExecutionModeViewing")
},
_ => {
write!(f, "BlockExecutionMode({})", self.0)
}
}
}
}
pub type StorageCost = int128_xdr;
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedStorageCost {
kRPCNone { storage_cost: StorageCost } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedContract {
kRPCNone { contract: Contract } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedDeployment {
kRPCNone { deployed_hash: DeployedContractHash } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedProposalData {
kRPCNone { proposal_data: NondeterministicProposalData } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedRetrocausalQueueBlock {
kRPCNone { queue_block: RetrocausalQueueBlock } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedQueueEntry {
kRPCNone { queue_entry: QueueEntry } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedDBTip {
kRPCNone { db_tip: DbTip } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct ViewingSnapshot {
pub viewing_block_id: BlockID,
pub tip: DbTip,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[repr(i32)]
#[non_exhaustive]
pub enum ExpectedViewingSnapshot {
kRPCNone { snapshot: ViewingSnapshot } = RPCError::kRPCNone.0 as i32,
#[xdr(default_variant)] Default { error: i32 },
}
pub type ContractAddressBatch = VecM::<ContractAddress>;
impl ExpectedStorageCost {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedStorageCost::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ExpectedContract {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedContract::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ExpectedDeployment {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedDeployment::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ExpectedProposalData {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedProposalData::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ExpectedRetrocausalQueueBlock {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedRetrocausalQueueBlock::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ExpectedQueueEntry {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedQueueEntry::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ExpectedDBTip {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedDBTip::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ExpectedViewingSnapshot {
#[allow(clippy::match_single_binding)]
pub fn error(&self) -> RPCError {
match self {
ExpectedViewingSnapshot::Default{ error } => (*error).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}