#![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}};
#[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 ViewGatewayPayload {
pub height: BlockHeight,
pub output: InvocationFrameOutput,
pub gas_consumed: GasAmount,
pub events: VecM<TxEmittedEvent>,
}
#[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 ViewGatewayOutcome(pub i32);
impl ViewGatewayOutcome {
pub const ViewGatewayOk: Self = Self(0);
pub const ViewGatewayAbandoned: Self = Self(1);
pub const ViewGatewayInternalError: Self = Self(2);
pub const ViewGatewayInvalidInput: Self = Self(3);
}
impl From<i32> for ViewGatewayOutcome {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "std")]
impl core::fmt::Display for ViewGatewayOutcome {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::ViewGatewayOk.0 => {
write!(f, "ViewGatewayOutcome::ViewGatewayOk")
},
x if x == Self::ViewGatewayAbandoned.0 => {
write!(f, "ViewGatewayOutcome::ViewGatewayAbandoned")
},
x if x == Self::ViewGatewayInternalError.0 => {
write!(f, "ViewGatewayOutcome::ViewGatewayInternalError")
},
x if x == Self::ViewGatewayInvalidInput.0 => {
write!(f, "ViewGatewayOutcome::ViewGatewayInvalidInput")
},
_ => {
write!(f, "ViewGatewayOutcome({})", self.0)
}
}
}
}
#[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 ViewGatewayResult {
ViewGatewayOk { payload: ViewGatewayPayload } = ViewGatewayOutcome::ViewGatewayOk.0 as i32,
ViewGatewayAbandoned = ViewGatewayOutcome::ViewGatewayAbandoned.0 as i32,
ViewGatewayInternalError = ViewGatewayOutcome::ViewGatewayInternalError.0 as i32,
ViewGatewayInvalidInput { error_code: SyscallErrorCode } = ViewGatewayOutcome::ViewGatewayInvalidInput.0 as i32,
#[xdr(default_variant)] Default { outcome: i32 },
}
#[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 ViewGatewayIntroOutcome(pub i32);
impl ViewGatewayIntroOutcome {
pub const ViewGatewayIntroSuccess: Self = Self(0);
pub const ViewGatewayIntroMismatchedProtocol: Self = Self(1);
}
impl From<i32> for ViewGatewayIntroOutcome {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "std")]
impl core::fmt::Display for ViewGatewayIntroOutcome {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::ViewGatewayIntroSuccess.0 => {
write!(f, "ViewGatewayIntroOutcome::ViewGatewayIntroSuccess")
},
x if x == Self::ViewGatewayIntroMismatchedProtocol.0 => {
write!(f, "ViewGatewayIntroOutcome::ViewGatewayIntroMismatchedProtocol")
},
_ => {
write!(f, "ViewGatewayIntroOutcome({})", self.0)
}
}
}
}
#[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 ViewGatewayBatchQuery {
pub calls: VecM<TransactionViewQuery>,
pub min_height: Option<BlockHeight>,
pub budget_millis: u32,
pub max_response_bytes: u32,
}
#[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 ViewGatewayBatchPayload {
pub height: BlockHeight,
pub results: VecM<TransactionViewResult>,
}
#[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 ViewGatewayHeightUnavailable {
pub requested: BlockHeight,
pub observed: BlockHeight,
}
#[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 ViewGatewayBatchOutcome(pub i32);
impl ViewGatewayBatchOutcome {
pub const ViewGatewayBatchOk: Self = Self(0);
pub const ViewGatewayBatchInvalidRequest: Self = Self(1);
pub const ViewGatewayBatchHeightUnavailable: Self = Self(2);
pub const ViewGatewayBatchAbandoned: Self = Self(3);
pub const ViewGatewayBatchDeadlineExceeded: Self = Self(4);
pub const ViewGatewayBatchResponseTooLarge: Self = Self(5);
pub const ViewGatewayBatchInternalError: Self = Self(6);
}
impl From<i32> for ViewGatewayBatchOutcome {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "std")]
impl core::fmt::Display for ViewGatewayBatchOutcome {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::ViewGatewayBatchOk.0 => {
write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchOk")
},
x if x == Self::ViewGatewayBatchInvalidRequest.0 => {
write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchInvalidRequest")
},
x if x == Self::ViewGatewayBatchHeightUnavailable.0 => {
write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchHeightUnavailable")
},
x if x == Self::ViewGatewayBatchAbandoned.0 => {
write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchAbandoned")
},
x if x == Self::ViewGatewayBatchDeadlineExceeded.0 => {
write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchDeadlineExceeded")
},
x if x == Self::ViewGatewayBatchResponseTooLarge.0 => {
write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchResponseTooLarge")
},
x if x == Self::ViewGatewayBatchInternalError.0 => {
write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchInternalError")
},
_ => {
write!(f, "ViewGatewayBatchOutcome({})", self.0)
}
}
}
}
#[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 ViewGatewayBatchResult {
ViewGatewayBatchOk { payload: ViewGatewayBatchPayload } = ViewGatewayBatchOutcome::ViewGatewayBatchOk.0 as i32,
ViewGatewayBatchHeightUnavailable { height_unavailable: ViewGatewayHeightUnavailable } = ViewGatewayBatchOutcome::ViewGatewayBatchHeightUnavailable.0 as i32,
#[xdr(default_variant)] Default { outcome: i32 },
}
#[allow(non_camel_case_types)]
pub trait ViewGateway_ViewGateway1: Send + Sync {
fn viewgateway_intro(&self, arg0 : ProtocolCommit) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<ViewGatewayIntroOutcome>, ::thruput_rpc_api::ProgramError>> + Send;
fn viewgateway_view(&self, arg0 : TransactionViewQuery) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<ViewGatewayResult>, ::thruput_rpc_api::ProgramError>> + Send;
fn viewgateway_view_batch(&self, arg0 : ViewGatewayBatchQuery) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<ViewGatewayBatchResult>, ::thruput_rpc_api::ProgramError>> + Send;
}
#[allow(non_camel_case_types)]
pub struct ViewGateway_ViewGateway1_Dispatcher<__Handler> {
inner: Box<__Handler>,
}
impl<__Handler: ViewGateway_ViewGateway1> ViewGateway_ViewGateway1_Dispatcher<__Handler> {
pub fn new(inner: Box<__Handler>) -> Self {
Self { inner }
}
}
#[async_trait::async_trait]
impl<__Handler: ViewGateway_ViewGateway1> ::thruput_rpc_api::RpcHandler for ViewGateway_ViewGateway1_Dispatcher<__Handler> {
fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
::thruput_rpc_api::ProgVers::new(0x56475759, 1)
}
async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
match proc {
0 => {
let args: (ProtocolCommit, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.viewgateway_intro(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
1 => {
let args: (TransactionViewQuery, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.viewgateway_view(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
2 => {
let args: (ViewGatewayBatchQuery, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.viewgateway_view_batch(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
_ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
}
}
}
#[derive(Clone)]
pub struct ViewGateway_ViewGateway1_Client {
handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
}
impl ViewGateway_ViewGateway1_Client {
pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
Self { handle }
}
fn prog_vers() -> ::thruput_rpc_api::ProgVers {
::thruput_rpc_api::ProgVers::new(0x56475759, 1)
}
pub async fn viewgateway_intro(&self, arg0 : &(impl xdrs::EncodesAs<ProtocolCommit> + ?Sized)) -> Result<ViewGatewayIntroOutcome, ::thruput_rpc_api::RpcError> {
let mut call = self.handle.call_buf();
call.append_with(|buf| {
let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
let r = xdrs::write_xdr(&(arg0), &mut w);
*buf = w.into();
r
}).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let mut out = ::core::option::Option::None;
let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
Ok(())
};
unsafe { self.handle.send_call_decoded(Self::prog_vers(), 0, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
pub async fn viewgateway_view(&self, arg0 : &(impl xdrs::EncodesAs<TransactionViewQuery> + ?Sized)) -> Result<ViewGatewayResult, ::thruput_rpc_api::RpcError> {
let mut call = self.handle.call_buf();
call.append_with(|buf| {
let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
let r = xdrs::write_xdr(&(arg0), &mut w);
*buf = w.into();
r
}).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let mut out = ::core::option::Option::None;
let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
Ok(())
};
unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
pub async fn viewgateway_view_batch(&self, arg0 : &(impl xdrs::EncodesAs<ViewGatewayBatchQuery> + ?Sized)) -> Result<ViewGatewayBatchResult, ::thruput_rpc_api::RpcError> {
let mut call = self.handle.call_buf();
call.append_with(|buf| {
let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
let r = xdrs::write_xdr(&(arg0), &mut w);
*buf = w.into();
r
}).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let mut out = ::core::option::Option::None;
let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
Ok(())
};
unsafe { self.handle.send_call_decoded(Self::prog_vers(), 2, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
}
impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for ViewGateway_ViewGateway1_Client {
fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
Self::new(handle)
}
}
impl ViewGatewayResult {
#[allow(clippy::match_single_binding)]
pub fn outcome(&self) -> ViewGatewayOutcome {
match self {
ViewGatewayResult::Default{ outcome } => (*outcome).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}
impl ViewGatewayBatchResult {
#[allow(clippy::match_single_binding)]
pub fn outcome(&self) -> ViewGatewayBatchOutcome {
match self {
ViewGatewayBatchResult::Default{ outcome } => (*outcome).into(),
_ => (unsafe { *(self as *const Self as *const i32) }).into(),
}
}
}