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
30pub type BlockID = u64;
34
35#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
54#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
55#[derive(schemars::JsonSchema)]
56#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
57#[repr(C)]
58pub struct BlockExecutionContext {
59 pub block_height: BlockHeight,
63 pub block_timepoint: TimePoint,
67}
68
69#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
70#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
71#[derive(schemars::JsonSchema)]
72#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
73#[repr(C)]
74pub struct DbTip {
75 pub id: BlockID,
76 pub storage_long_hash: StorageLongHash,
77 pub value: ConsensusValue,
78 pub default_wallet: DeployedContractHash,
85 pub network_config: NetworkConfig,
90}
91
92pub type TransactionID = u64;
95
96#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
102#[cfg_attr(feature = "serde", serde(transparent))]
103#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
104#[derive(schemars::JsonSchema)]
105#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
106#[derive(Copy)]
107#[repr(transparent)]
108pub struct RPCError(pub i32);
109
110impl RPCError {
111 pub const kRPCNone: Self = Self(0);
112
113 pub const kRPCNotFound: Self = Self(1);
116
117 pub const kRPCBadBlockID: Self = Self(3);
119
120 pub const kRPCStorageWriteFailed: Self = Self(4);
122
123 pub const kRPCTransactionFailed: Self = Self(5);
125
126 pub const kRPCUnimplemented: Self = Self(6);
128
129 pub const kRPCUnrecoverable: Self = Self(7);
131}
132impl From<i32> for RPCError {
133 fn from(v: i32) -> Self {
134 Self(v)
135 }
136}
137#[cfg(feature = "std")]
138impl core::fmt::Display for RPCError {
139 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
140 match self.0 {
141 x if x == Self::kRPCNone.0 => {
142 write!(f, "RPCError::kRPCNone")
143 },
144 x if x == Self::kRPCNotFound.0 => {
145 write!(f, "RPCError::kRPCNotFound")
146 },
147 x if x == Self::kRPCBadBlockID.0 => {
148 write!(f, "RPCError::kRPCBadBlockID")
149 },
150 x if x == Self::kRPCStorageWriteFailed.0 => {
151 write!(f, "RPCError::kRPCStorageWriteFailed")
152 },
153 x if x == Self::kRPCTransactionFailed.0 => {
154 write!(f, "RPCError::kRPCTransactionFailed")
155 },
156 x if x == Self::kRPCUnimplemented.0 => {
157 write!(f, "RPCError::kRPCUnimplemented")
158 },
159 x if x == Self::kRPCUnrecoverable.0 => {
160 write!(f, "RPCError::kRPCUnrecoverable")
161 },
162 _ => {
163 write!(f, "RPCError({})", self.0)
164 }
165 }
166 }
167}
168
169
170#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
172#[cfg_attr(feature = "serde", serde(transparent))]
173#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
174#[derive(schemars::JsonSchema)]
175#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
176#[derive(Copy)]
177#[repr(transparent)]
178pub struct BlockExecutionMode(pub i32);
179
180impl BlockExecutionMode {
181 pub const kBlockExecutionModeValidation: Self = Self(0);
182 pub const kBlockExecutionModeProposal: Self = Self(1);
183
184 pub const kBlockExecutionModeViewing: Self = Self(2);
188}
189impl From<i32> for BlockExecutionMode {
190 fn from(v: i32) -> Self {
191 Self(v)
192 }
193}
194#[cfg(feature = "std")]
195impl core::fmt::Display for BlockExecutionMode {
196 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
197 match self.0 {
198 x if x == Self::kBlockExecutionModeValidation.0 => {
199 write!(f, "BlockExecutionMode::kBlockExecutionModeValidation")
200 },
201 x if x == Self::kBlockExecutionModeProposal.0 => {
202 write!(f, "BlockExecutionMode::kBlockExecutionModeProposal")
203 },
204 x if x == Self::kBlockExecutionModeViewing.0 => {
205 write!(f, "BlockExecutionMode::kBlockExecutionModeViewing")
206 },
207 _ => {
208 write!(f, "BlockExecutionMode({})", self.0)
209 }
210 }
211 }
212}
213
214
215pub type StorageCost = int128_xdr;
216
217#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
218#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
219#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
220#[derive(schemars::JsonSchema)]
221#[repr(i32)]
222#[non_exhaustive]
223pub enum ExpectedStorageCost {
224 kRPCNone { storage_cost: StorageCost } = RPCError::kRPCNone.0 as i32,
227 #[xdr(default_variant)] Default { error: i32 },
230}
231
232#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
234#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
235#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
236#[derive(schemars::JsonSchema)]
237#[repr(i32)]
238#[non_exhaustive]
239pub enum ExpectedContract {
240 kRPCNone { contract: Contract } = RPCError::kRPCNone.0 as i32,
243 #[xdr(default_variant)] Default { error: i32 },
246}
247
248#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
249#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
250#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
251#[derive(schemars::JsonSchema)]
252#[repr(i32)]
253#[non_exhaustive]
254pub enum ExpectedDeployment {
255 kRPCNone { deployed_hash: DeployedContractHash } = RPCError::kRPCNone.0 as i32,
258 #[xdr(default_variant)] Default { error: i32 },
261}
262
263#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
264#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
265#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
266#[derive(schemars::JsonSchema)]
267#[repr(i32)]
268#[non_exhaustive]
269pub enum ExpectedProposalData {
270 kRPCNone { proposal_data: NondeterministicProposalData } = RPCError::kRPCNone.0 as i32,
273 #[xdr(default_variant)] Default { error: i32 },
276}
277
278#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
279#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
280#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
281#[derive(schemars::JsonSchema)]
282#[repr(i32)]
283#[non_exhaustive]
284pub enum ExpectedRetrocausalQueueBlock {
285 kRPCNone { queue_block: RetrocausalQueueBlock } = RPCError::kRPCNone.0 as i32,
288 #[xdr(default_variant)] Default { error: i32 },
291}
292
293#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
294#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
295#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
296#[derive(schemars::JsonSchema)]
297#[repr(i32)]
298#[non_exhaustive]
299pub enum ExpectedQueueEntry {
300 kRPCNone { queue_entry: QueueEntry } = RPCError::kRPCNone.0 as i32,
303 #[xdr(default_variant)] Default { error: i32 },
306}
307
308#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
309#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
310#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
311#[derive(schemars::JsonSchema)]
312#[repr(i32)]
313#[non_exhaustive]
314pub enum ExpectedDBTip {
315 kRPCNone { db_tip: DbTip } = RPCError::kRPCNone.0 as i32,
318 #[xdr(default_variant)] Default { error: i32 },
321}
322
323#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
324#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
325#[derive(schemars::JsonSchema)]
326#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
327#[repr(C)]
328pub struct ViewingSnapshot {
329 pub viewing_block_id: BlockID,
330 pub tip: DbTip,
331}
332
333#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
334#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
335#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
336#[derive(schemars::JsonSchema)]
337#[repr(i32)]
338#[non_exhaustive]
339pub enum ExpectedViewingSnapshot {
340 kRPCNone { snapshot: ViewingSnapshot } = RPCError::kRPCNone.0 as i32,
343 #[xdr(default_variant)] Default { error: i32 },
346}
347
348pub type ContractAddressBatch = VecM::<ContractAddress>;
350
351
352impl ExpectedStorageCost {
357 #[allow(clippy::match_single_binding)]
358 pub fn error(&self) -> RPCError {
359 match self {
360 ExpectedStorageCost::Default{ error } => (*error).into(),
361
362 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
363 }
364 }
365}
366
367impl ExpectedContract {
368 #[allow(clippy::match_single_binding)]
369 pub fn error(&self) -> RPCError {
370 match self {
371 ExpectedContract::Default{ error } => (*error).into(),
372
373 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
374 }
375 }
376}
377
378impl ExpectedDeployment {
379 #[allow(clippy::match_single_binding)]
380 pub fn error(&self) -> RPCError {
381 match self {
382 ExpectedDeployment::Default{ error } => (*error).into(),
383
384 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
385 }
386 }
387}
388
389impl ExpectedProposalData {
390 #[allow(clippy::match_single_binding)]
391 pub fn error(&self) -> RPCError {
392 match self {
393 ExpectedProposalData::Default{ error } => (*error).into(),
394
395 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
396 }
397 }
398}
399
400impl ExpectedRetrocausalQueueBlock {
401 #[allow(clippy::match_single_binding)]
402 pub fn error(&self) -> RPCError {
403 match self {
404 ExpectedRetrocausalQueueBlock::Default{ error } => (*error).into(),
405
406 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
407 }
408 }
409}
410
411impl ExpectedQueueEntry {
412 #[allow(clippy::match_single_binding)]
413 pub fn error(&self) -> RPCError {
414 match self {
415 ExpectedQueueEntry::Default{ error } => (*error).into(),
416
417 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
418 }
419 }
420}
421
422impl ExpectedDBTip {
423 #[allow(clippy::match_single_binding)]
424 pub fn error(&self) -> RPCError {
425 match self {
426 ExpectedDBTip::Default{ error } => (*error).into(),
427
428 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
429 }
430 }
431}
432
433impl ExpectedViewingSnapshot {
434 #[allow(clippy::match_single_binding)]
435 pub fn error(&self) -> RPCError {
436 match self {
437 ExpectedViewingSnapshot::Default{ error } => (*error).into(),
438
439 _ => (unsafe { *(self as *const Self as *const i32) }).into(),
440 }
441 }
442}
443
444