1#![allow(non_camel_case_types)]
9#![allow(non_snake_case)]
10#![allow(non_upper_case_globals)]
11#![allow(unused_imports)]
12#![allow(dead_code)]
13#![allow(unused_variables)]
14#![allow(clippy::unnecessary_cast)]
15
16use crate::*;
17use core::option::Option;
18use core::ops::{Deref, DerefMut};
19
20#[cfg(feature = "std")]
21use std::io::{Read, Write};
22use xdrs::*;
23
24
25#[cfg(feature = "serde")]
26use ::serde::{{Serialize, Deserialize}};
27
28
29
30#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
38#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
39#[derive(schemars::JsonSchema)]
40#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41#[repr(C)]
42pub struct ViewGatewayPayload {
43 pub height: BlockHeight,
44 pub output: InvocationFrameOutput,
45 pub gas_consumed: GasAmount,
46 pub events: VecM<TxEmittedEvent>,
47}
48
49#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
50#[cfg_attr(feature = "serde", serde(transparent))]
51#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
52#[derive(schemars::JsonSchema)]
53#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
54#[derive(Copy)]
55#[repr(transparent)]
56pub struct ViewGatewayOutcome(pub i32);
57
58impl ViewGatewayOutcome {
59 pub const ViewGatewayOk: Self = Self(0);
60
61 pub const ViewGatewayAbandoned: Self = Self(1);
64
65 pub const ViewGatewayInternalError: Self = Self(2);
67
68 pub const ViewGatewayInvalidInput: Self = Self(3);
75}
76impl From<i32> for ViewGatewayOutcome {
77 fn from(v: i32) -> Self {
78 Self(v)
79 }
80}
81#[cfg(feature = "std")]
82impl core::fmt::Display for ViewGatewayOutcome {
83 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
84 match self.0 {
85 x if x == Self::ViewGatewayOk.0 => {
86 write!(f, "ViewGatewayOutcome::ViewGatewayOk")
87 },
88 x if x == Self::ViewGatewayAbandoned.0 => {
89 write!(f, "ViewGatewayOutcome::ViewGatewayAbandoned")
90 },
91 x if x == Self::ViewGatewayInternalError.0 => {
92 write!(f, "ViewGatewayOutcome::ViewGatewayInternalError")
93 },
94 x if x == Self::ViewGatewayInvalidInput.0 => {
95 write!(f, "ViewGatewayOutcome::ViewGatewayInvalidInput")
96 },
97 _ => {
98 write!(f, "ViewGatewayOutcome({})", self.0)
99 }
100 }
101 }
102}
103
104
105#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
106#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
107#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
108#[derive(schemars::JsonSchema)]
109#[repr(i32)]
110#[non_exhaustive]
111pub enum ViewGatewayResult {
112 ViewGatewayOk { payload: ViewGatewayPayload } = ViewGatewayOutcome::ViewGatewayOk.0 as i32,
115 ViewGatewayAbandoned = ViewGatewayOutcome::ViewGatewayAbandoned.0 as i32,
118 ViewGatewayInternalError = ViewGatewayOutcome::ViewGatewayInternalError.0 as i32,
121 ViewGatewayInvalidInput { error_code: SyscallErrorCode } = ViewGatewayOutcome::ViewGatewayInvalidInput.0 as i32,
124 #[xdr(default_variant)] Default { outcome: i32 },
127}
128
129#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
130#[cfg_attr(feature = "serde", serde(transparent))]
131#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
132#[derive(schemars::JsonSchema)]
133#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
134#[derive(Copy)]
135#[repr(transparent)]
136pub struct ViewGatewayIntroOutcome(pub i32);
137
138impl ViewGatewayIntroOutcome {
139 pub const ViewGatewayIntroSuccess: Self = Self(0);
140 pub const ViewGatewayIntroMismatchedProtocol: Self = Self(1);
141}
142impl From<i32> for ViewGatewayIntroOutcome {
143 fn from(v: i32) -> Self {
144 Self(v)
145 }
146}
147#[cfg(feature = "std")]
148impl core::fmt::Display for ViewGatewayIntroOutcome {
149 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
150 match self.0 {
151 x if x == Self::ViewGatewayIntroSuccess.0 => {
152 write!(f, "ViewGatewayIntroOutcome::ViewGatewayIntroSuccess")
153 },
154 x if x == Self::ViewGatewayIntroMismatchedProtocol.0 => {
155 write!(f, "ViewGatewayIntroOutcome::ViewGatewayIntroMismatchedProtocol")
156 },
157 _ => {
158 write!(f, "ViewGatewayIntroOutcome({})", self.0)
159 }
160 }
161 }
162}
163
164
165#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
169#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
170#[derive(schemars::JsonSchema)]
171#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
172#[repr(C)]
173pub struct ViewGatewayBatchQuery {
174 pub calls: VecM<TransactionViewQuery>,
175 pub min_height: Option<BlockHeight>,
178 pub budget_millis: u32,
181 pub max_response_bytes: u32,
184}
185
186#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
187#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
188#[derive(schemars::JsonSchema)]
189#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
190#[repr(C)]
191pub struct ViewGatewayBatchPayload {
192 pub height: BlockHeight,
193 pub results: VecM<TransactionViewResult>,
194}
195
196#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
197#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
198#[derive(schemars::JsonSchema)]
199#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
200#[repr(C)]
201pub struct ViewGatewayHeightUnavailable {
202 pub requested: BlockHeight,
203 pub observed: BlockHeight,
204}
205
206#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
207#[cfg_attr(feature = "serde", serde(transparent))]
208#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
209#[derive(schemars::JsonSchema)]
210#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
211#[derive(Copy)]
212#[repr(transparent)]
213pub struct ViewGatewayBatchOutcome(pub i32);
214
215impl ViewGatewayBatchOutcome {
216 pub const ViewGatewayBatchOk: Self = Self(0);
217 pub const ViewGatewayBatchInvalidRequest: Self = Self(1);
218 pub const ViewGatewayBatchHeightUnavailable: Self = Self(2);
219 pub const ViewGatewayBatchAbandoned: Self = Self(3);
220 pub const ViewGatewayBatchDeadlineExceeded: Self = Self(4);
221 pub const ViewGatewayBatchResponseTooLarge: Self = Self(5);
222 pub const ViewGatewayBatchInternalError: Self = Self(6);
223}
224impl From<i32> for ViewGatewayBatchOutcome {
225 fn from(v: i32) -> Self {
226 Self(v)
227 }
228}
229#[cfg(feature = "std")]
230impl core::fmt::Display for ViewGatewayBatchOutcome {
231 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
232 match self.0 {
233 x if x == Self::ViewGatewayBatchOk.0 => {
234 write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchOk")
235 },
236 x if x == Self::ViewGatewayBatchInvalidRequest.0 => {
237 write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchInvalidRequest")
238 },
239 x if x == Self::ViewGatewayBatchHeightUnavailable.0 => {
240 write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchHeightUnavailable")
241 },
242 x if x == Self::ViewGatewayBatchAbandoned.0 => {
243 write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchAbandoned")
244 },
245 x if x == Self::ViewGatewayBatchDeadlineExceeded.0 => {
246 write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchDeadlineExceeded")
247 },
248 x if x == Self::ViewGatewayBatchResponseTooLarge.0 => {
249 write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchResponseTooLarge")
250 },
251 x if x == Self::ViewGatewayBatchInternalError.0 => {
252 write!(f, "ViewGatewayBatchOutcome::ViewGatewayBatchInternalError")
253 },
254 _ => {
255 write!(f, "ViewGatewayBatchOutcome({})", self.0)
256 }
257 }
258 }
259}
260
261
262#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
266#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
267#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
268#[derive(schemars::JsonSchema)]
269#[repr(i32)]
270#[non_exhaustive]
271pub enum ViewGatewayBatchResult {
272 ViewGatewayBatchOk { payload: ViewGatewayBatchPayload } = ViewGatewayBatchOutcome::ViewGatewayBatchOk.0 as i32,
275 ViewGatewayBatchHeightUnavailable { height_unavailable: ViewGatewayHeightUnavailable } = ViewGatewayBatchOutcome::ViewGatewayBatchHeightUnavailable.0 as i32,
278 #[xdr(default_variant)] Default { outcome: i32 },
281}
282
283
284#[allow(non_camel_case_types)]
288pub trait ViewGateway_ViewGateway1: Send + Sync {
289 fn viewgateway_intro(&self, arg0 : ProtocolCommit) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<ViewGatewayIntroOutcome>, ::thruput_rpc_api::ProgramError>> + Send;
290
291 fn viewgateway_view(&self, arg0 : TransactionViewQuery) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<ViewGatewayResult>, ::thruput_rpc_api::ProgramError>> + Send;
292
293 fn viewgateway_view_batch(&self, arg0 : ViewGatewayBatchQuery) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<ViewGatewayBatchResult>, ::thruput_rpc_api::ProgramError>> + Send;
294}
295
296
297#[allow(non_camel_case_types)]
298pub struct ViewGateway_ViewGateway1_Dispatcher<__Handler> {
299 inner: Box<__Handler>,
300}
301
302impl<__Handler: ViewGateway_ViewGateway1> ViewGateway_ViewGateway1_Dispatcher<__Handler> {
303 pub fn new(inner: Box<__Handler>) -> Self {
304 Self { inner }
305 }
306}
307
308#[async_trait::async_trait]
309impl<__Handler: ViewGateway_ViewGateway1> ::thruput_rpc_api::RpcHandler for ViewGateway_ViewGateway1_Dispatcher<__Handler> {
310 fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
311 ::thruput_rpc_api::ProgVers::new(0x56475759, 1)
312 }
313 async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
314 match proc {
315 0 => {
317 let args: (ProtocolCommit, ) =
318 xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
319 let res = self.inner.viewgateway_intro(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
320 xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
321 }
322 1 => {
324 let args: (TransactionViewQuery, ) =
325 xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
326 let res = self.inner.viewgateway_view(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
327 xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
328 }
329 2 => {
331 let args: (ViewGatewayBatchQuery, ) =
332 xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
333 let res = self.inner.viewgateway_view_batch(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
334 xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
335 }
336 _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
337 }
338 }
339}
340
341#[derive(Clone)]
342pub struct ViewGateway_ViewGateway1_Client {
343 handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
344}
345
346impl ViewGateway_ViewGateway1_Client {
347 pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
348 Self { handle }
349 }
350
351 fn prog_vers() -> ::thruput_rpc_api::ProgVers {
352 ::thruput_rpc_api::ProgVers::new(0x56475759, 1)
353 }
354 pub async fn viewgateway_intro(&self, arg0 : &(impl xdrs::EncodesAs<ProtocolCommit> + ?Sized)) -> Result<ViewGatewayIntroOutcome, ::thruput_rpc_api::RpcError> {
355 let mut call = self.handle.call_buf();
356 call.append_with(|buf| {
357 let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
358 let r = xdrs::write_xdr(&(arg0), &mut w);
359 *buf = w.into();
360 r
361 }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
362 let mut out = ::core::option::Option::None;
363 let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
364 out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
365 Ok(())
366 };
367 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 0, call, &mut decode) }.await?;
372 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
373 }
374 pub async fn viewgateway_view(&self, arg0 : &(impl xdrs::EncodesAs<TransactionViewQuery> + ?Sized)) -> Result<ViewGatewayResult, ::thruput_rpc_api::RpcError> {
375 let mut call = self.handle.call_buf();
376 call.append_with(|buf| {
377 let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
378 let r = xdrs::write_xdr(&(arg0), &mut w);
379 *buf = w.into();
380 r
381 }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
382 let mut out = ::core::option::Option::None;
383 let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
384 out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
385 Ok(())
386 };
387 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }.await?;
392 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
393 }
394 pub async fn viewgateway_view_batch(&self, arg0 : &(impl xdrs::EncodesAs<ViewGatewayBatchQuery> + ?Sized)) -> Result<ViewGatewayBatchResult, ::thruput_rpc_api::RpcError> {
395 let mut call = self.handle.call_buf();
396 call.append_with(|buf| {
397 let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
398 let r = xdrs::write_xdr(&(arg0), &mut w);
399 *buf = w.into();
400 r
401 }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
402 let mut out = ::core::option::Option::None;
403 let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
404 out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
405 Ok(())
406 };
407 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 2, call, &mut decode) }.await?;
412 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
413 }
414}
415
416impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for ViewGateway_ViewGateway1_Client {
417 fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
418 Self::new(handle)
419 }
420}
421
422
423
424impl ViewGatewayResult {
429 #[allow(clippy::match_single_binding)]
430 pub fn outcome(&self) -> ViewGatewayOutcome {
431 match self {
432 ViewGatewayResult::Default{ outcome } => (*outcome).into(),
433
434 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
435 }
436 }
437}
438
439impl ViewGatewayBatchResult {
440 #[allow(clippy::match_single_binding)]
441 pub fn outcome(&self) -> ViewGatewayBatchOutcome {
442 match self {
443 ViewGatewayBatchResult::Default{ outcome } => (*outcome).into(),
444
445 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
446 }
447 }
448}
449
450