starknet_core/types/
codegen.rs

1// AUTO-GENERATED CODE. DO NOT EDIT
2// To change the code generated, modify the codegen tool instead:
3//     https://github.com/xJonathanLEI/starknet-jsonrpc-codegen
4
5// Code generated with version:
6//     https://github.com/xJonathanLEI/starknet-jsonrpc-codegen#66aa909a760ed0800232a2ca13ece97b9ea32d24
7
8// These types are ignored from code generation. Implement them manually:
9// - `RECEIPT_BLOCK`
10
11// Code generation requested but not implemented for these types:
12// - `BLOCK_ID`
13// - `BROADCASTED_DECLARE_TXN`
14// - `BROADCASTED_DEPLOY_ACCOUNT_TXN`
15// - `BROADCASTED_INVOKE_TXN`
16// - `BROADCASTED_TXN`
17// - `CONTRACT_ABI_ENTRY`
18// - `CONTRACT_CLASS`
19// - `DECLARE_TXN`
20// - `DEPLOY_ACCOUNT_TXN`
21// - `EXECUTE_INVOCATION`
22// - `INVOKE_TXN`
23// - `TRANSACTION_TRACE`
24// - `TXN`
25// - `TXN_RECEIPT`
26
27#![allow(missing_docs)]
28#![allow(clippy::doc_markdown)]
29#![allow(clippy::missing_const_for_fn)]
30
31use alloc::{format, string::*, vec::*};
32
33use serde::{Deserialize, Deserializer, Serialize, Serializer};
34use serde_with::serde_as;
35
36use crate::serde::byte_array::base64;
37
38use super::{serde_impls::NumAsHex, *};
39
40#[cfg(target_has_atomic = "ptr")]
41pub type OwnedPtr<T> = alloc::sync::Arc<T>;
42#[cfg(not(target_has_atomic = "ptr"))]
43pub type OwnedPtr<T> = alloc::boxed::Box<T>;
44
45const QUERY_VERSION_OFFSET: Felt = Felt::from_raw([
46    576460752142434320,
47    18446744073709551584,
48    17407,
49    18446744073700081665,
50]);
51
52/// Block status.
53///
54/// The status of the block.
55#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
56pub enum BlockStatus {
57    #[serde(rename = "PENDING")]
58    Pending,
59    #[serde(rename = "ACCEPTED_ON_L2")]
60    AcceptedOnL2,
61    #[serde(rename = "ACCEPTED_ON_L1")]
62    AcceptedOnL1,
63    #[serde(rename = "REJECTED")]
64    Rejected,
65}
66
67/// Block tag.
68///
69/// A tag specifying a dynamic reference to a block.
70#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
71pub enum BlockTag {
72    #[serde(rename = "latest")]
73    Latest,
74    #[serde(rename = "pending")]
75    Pending,
76}
77
78/// Block with transactions and receipts.
79///
80/// The block object.
81#[serde_as]
82#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
83#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
84pub struct BlockWithReceipts {
85    /// Status
86    pub status: BlockStatus,
87    /// Block hash
88    #[serde_as(as = "UfeHex")]
89    pub block_hash: Felt,
90    /// The hash of this block's parent
91    #[serde_as(as = "UfeHex")]
92    pub parent_hash: Felt,
93    /// The block number (its height)
94    pub block_number: u64,
95    /// The new global state root
96    #[serde_as(as = "UfeHex")]
97    pub new_root: Felt,
98    /// The time in which the block was created, encoded in Unix time
99    pub timestamp: u64,
100    /// The Starknet identity of the sequencer submitting this block
101    #[serde_as(as = "UfeHex")]
102    pub sequencer_address: Felt,
103    /// The price of L1 gas in the block
104    pub l1_gas_price: ResourcePrice,
105    /// The price of L1 data gas in the block
106    pub l1_data_gas_price: ResourcePrice,
107    /// Specifies whether the data of this block is published via blob data or calldata
108    pub l1_da_mode: L1DataAvailabilityMode,
109    /// Semver of the current Starknet protocol
110    pub starknet_version: String,
111    /// The transactions in this block
112    pub transactions: Vec<TransactionWithReceipt>,
113}
114
115/// Block with transaction hashes.
116///
117/// The block object.
118#[serde_as]
119#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
120#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
121pub struct BlockWithTxHashes {
122    /// Status
123    pub status: BlockStatus,
124    /// Block hash
125    #[serde_as(as = "UfeHex")]
126    pub block_hash: Felt,
127    /// The hash of this block's parent
128    #[serde_as(as = "UfeHex")]
129    pub parent_hash: Felt,
130    /// The block number (its height)
131    pub block_number: u64,
132    /// The new global state root
133    #[serde_as(as = "UfeHex")]
134    pub new_root: Felt,
135    /// The time in which the block was created, encoded in Unix time
136    pub timestamp: u64,
137    /// The Starknet identity of the sequencer submitting this block
138    #[serde_as(as = "UfeHex")]
139    pub sequencer_address: Felt,
140    /// The price of L1 gas in the block
141    pub l1_gas_price: ResourcePrice,
142    /// The price of L1 data gas in the block
143    pub l1_data_gas_price: ResourcePrice,
144    /// Specifies whether the data of this block is published via blob data or calldata
145    pub l1_da_mode: L1DataAvailabilityMode,
146    /// Semver of the current Starknet protocol
147    pub starknet_version: String,
148    /// The hashes of the transactions included in this block
149    #[serde_as(as = "Vec<UfeHex>")]
150    pub transactions: Vec<Felt>,
151}
152
153/// Block with transactions.
154///
155/// The block object.
156#[serde_as]
157#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
158#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
159pub struct BlockWithTxs {
160    /// Status
161    pub status: BlockStatus,
162    /// Block hash
163    #[serde_as(as = "UfeHex")]
164    pub block_hash: Felt,
165    /// The hash of this block's parent
166    #[serde_as(as = "UfeHex")]
167    pub parent_hash: Felt,
168    /// The block number (its height)
169    pub block_number: u64,
170    /// The new global state root
171    #[serde_as(as = "UfeHex")]
172    pub new_root: Felt,
173    /// The time in which the block was created, encoded in Unix time
174    pub timestamp: u64,
175    /// The Starknet identity of the sequencer submitting this block
176    #[serde_as(as = "UfeHex")]
177    pub sequencer_address: Felt,
178    /// The price of L1 gas in the block
179    pub l1_gas_price: ResourcePrice,
180    /// The price of L1 data gas in the block
181    pub l1_data_gas_price: ResourcePrice,
182    /// Specifies whether the data of this block is published via blob data or calldata
183    pub l1_da_mode: L1DataAvailabilityMode,
184    /// Semver of the current Starknet protocol
185    pub starknet_version: String,
186    /// The transactions in this block
187    pub transactions: Vec<Transaction>,
188}
189
190/// Broadcasted declare contract transaction v1.
191#[derive(Debug, Clone, PartialEq, Eq)]
192pub struct BroadcastedDeclareTransactionV1 {
193    /// The address of the account contract sending the declaration transaction
194    pub sender_address: Felt,
195    /// The maximal fee that can be charged for including the transaction
196    pub max_fee: Felt,
197    /// Signature
198    pub signature: Vec<Felt>,
199    /// Nonce
200    pub nonce: Felt,
201    /// The class to be declared
202    pub contract_class: OwnedPtr<CompressedLegacyContractClass>,
203    /// If set to `true`, uses a query-only transaction version that's invalid for execution
204    pub is_query: bool,
205}
206
207/// Broadcasted declare transaction v2.
208///
209/// Broadcasted declare contract transaction v2.
210#[derive(Debug, Clone, PartialEq, Eq)]
211pub struct BroadcastedDeclareTransactionV2 {
212    /// The address of the account contract sending the declaration transaction
213    pub sender_address: Felt,
214    /// The hash of the cairo assembly resulting from the sierra compilation
215    pub compiled_class_hash: Felt,
216    /// The maximal fee that can be charged for including the transaction
217    pub max_fee: Felt,
218    /// Signature
219    pub signature: Vec<Felt>,
220    /// Nonce
221    pub nonce: Felt,
222    /// The class to be declared
223    pub contract_class: OwnedPtr<FlattenedSierraClass>,
224    /// If set to `true`, uses a query-only transaction version that's invalid for execution
225    pub is_query: bool,
226}
227
228/// Broadcasted declare transaction v3.
229///
230/// Broadcasted declare contract transaction v3.
231#[derive(Debug, Clone, PartialEq, Eq)]
232pub struct BroadcastedDeclareTransactionV3 {
233    /// The address of the account contract sending the declaration transaction
234    pub sender_address: Felt,
235    /// The hash of the cairo assembly resulting from the sierra compilation
236    pub compiled_class_hash: Felt,
237    /// Signature
238    pub signature: Vec<Felt>,
239    /// Nonce
240    pub nonce: Felt,
241    /// The class to be declared
242    pub contract_class: OwnedPtr<FlattenedSierraClass>,
243    /// Resource bounds for the transaction execution
244    pub resource_bounds: ResourceBoundsMapping,
245    /// The tip for the transaction
246    pub tip: u64,
247    /// Data needed to allow the paymaster to pay for the transaction in native tokens
248    pub paymaster_data: Vec<Felt>,
249    /// Data needed to deploy the account contract from which this tx will be initiated
250    pub account_deployment_data: Vec<Felt>,
251    /// The storage domain of the account's nonce (an account has a nonce per da mode)
252    pub nonce_data_availability_mode: DataAvailabilityMode,
253    /// The storage domain of the account's balance from which fee will be charged
254    pub fee_data_availability_mode: DataAvailabilityMode,
255    /// If set to `true`, uses a query-only transaction version that's invalid for execution
256    pub is_query: bool,
257}
258
259/// Deploy account transaction.
260///
261/// Deploys an account contract, charges fee from the pre-funded account addresses.
262#[derive(Debug, Clone, PartialEq, Eq)]
263pub struct BroadcastedDeployAccountTransactionV1 {
264    /// The maximal fee that can be charged for including the transaction
265    pub max_fee: Felt,
266    /// Signature
267    pub signature: Vec<Felt>,
268    /// Nonce
269    pub nonce: Felt,
270    /// The salt for the address of the deployed contract
271    pub contract_address_salt: Felt,
272    /// The parameters passed to the constructor
273    pub constructor_calldata: Vec<Felt>,
274    /// The hash of the deployed contract's class
275    pub class_hash: Felt,
276    /// If set to `true`, uses a query-only transaction version that's invalid for execution
277    pub is_query: bool,
278}
279
280/// Deploy account transaction.
281///
282/// Deploys an account contract, charges fee from the pre-funded account addresses.
283#[derive(Debug, Clone, PartialEq, Eq)]
284pub struct BroadcastedDeployAccountTransactionV3 {
285    /// Signature
286    pub signature: Vec<Felt>,
287    /// Nonce
288    pub nonce: Felt,
289    /// The salt for the address of the deployed contract
290    pub contract_address_salt: Felt,
291    /// The parameters passed to the constructor
292    pub constructor_calldata: Vec<Felt>,
293    /// The hash of the deployed contract's class
294    pub class_hash: Felt,
295    /// Resource bounds for the transaction execution
296    pub resource_bounds: ResourceBoundsMapping,
297    /// The tip for the transaction
298    pub tip: u64,
299    /// Data needed to allow the paymaster to pay for the transaction in native tokens
300    pub paymaster_data: Vec<Felt>,
301    /// The storage domain of the account's nonce (an account has a nonce per da mode)
302    pub nonce_data_availability_mode: DataAvailabilityMode,
303    /// The storage domain of the account's balance from which fee will be charged
304    pub fee_data_availability_mode: DataAvailabilityMode,
305    /// If set to `true`, uses a query-only transaction version that's invalid for execution
306    pub is_query: bool,
307}
308
309/// Invoke transaction v1.
310///
311/// Initiates a transaction from a given account.
312#[derive(Debug, Clone, PartialEq, Eq)]
313pub struct BroadcastedInvokeTransactionV1 {
314    /// Sender address
315    pub sender_address: Felt,
316    /// The data expected by the account's `execute` function (in most usecases, this includes the
317    /// called contract address and a function selector)
318    pub calldata: Vec<Felt>,
319    /// The maximal fee that can be charged for including the transaction
320    pub max_fee: Felt,
321    /// Signature
322    pub signature: Vec<Felt>,
323    /// Nonce
324    pub nonce: Felt,
325    /// If set to `true`, uses a query-only transaction version that's invalid for execution
326    pub is_query: bool,
327}
328
329/// Invoke transaction v3.
330///
331/// Initiates a transaction from a given account.
332#[derive(Debug, Clone, PartialEq, Eq)]
333pub struct BroadcastedInvokeTransactionV3 {
334    /// Sender address
335    pub sender_address: Felt,
336    /// The data expected by the account's `execute` function (in most usecases, this includes the
337    /// called contract address and a function selector)
338    pub calldata: Vec<Felt>,
339    /// Signature
340    pub signature: Vec<Felt>,
341    /// Nonce
342    pub nonce: Felt,
343    /// Resource bounds for the transaction execution
344    pub resource_bounds: ResourceBoundsMapping,
345    /// The tip for the transaction
346    pub tip: u64,
347    /// Data needed to allow the paymaster to pay for the transaction in native tokens
348    pub paymaster_data: Vec<Felt>,
349    /// Data needed to deploy the account contract from which this tx will be initiated
350    pub account_deployment_data: Vec<Felt>,
351    /// The storage domain of the account's nonce (an account has a nonce per da mode)
352    pub nonce_data_availability_mode: DataAvailabilityMode,
353    /// The storage domain of the account's balance from which fee will be charged
354    pub fee_data_availability_mode: DataAvailabilityMode,
355    /// If set to `true`, uses a query-only transaction version that's invalid for execution
356    pub is_query: bool,
357}
358
359#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
360pub enum CallType {
361    #[serde(rename = "LIBRARY_CALL")]
362    LibraryCall,
363    #[serde(rename = "CALL")]
364    Call,
365    #[serde(rename = "DELEGATE")]
366    Delegate,
367}
368
369/// Deprecated contract class.
370///
371/// The definition of a Starknet contract class.
372#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
373#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
374pub struct CompressedLegacyContractClass {
375    /// A base64 representation of the compressed program code
376    #[serde(with = "base64")]
377    pub program: Vec<u8>,
378    /// Deprecated entry points by type
379    pub entry_points_by_type: LegacyEntryPointsByType,
380    /// Contract abi
381    #[serde(skip_serializing_if = "Option::is_none")]
382    pub abi: Option<Vec<LegacyContractAbiEntry>>,
383}
384
385/// Computation resources.
386///
387/// The resources consumed by the vm.
388#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
389#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
390pub struct ComputationResources {
391    /// The number of cairo steps used
392    pub steps: u64,
393    /// The number of unused memory cells (each cell is roughly equivalent to a step)
394    #[serde(skip_serializing_if = "Option::is_none")]
395    pub memory_holes: Option<u64>,
396    /// The number of range_check builtin instances
397    #[serde(skip_serializing_if = "Option::is_none")]
398    pub range_check_builtin_applications: Option<u64>,
399    /// The number of pedersen builtin instances
400    #[serde(skip_serializing_if = "Option::is_none")]
401    pub pedersen_builtin_applications: Option<u64>,
402    /// The number of poseidon builtin instances
403    #[serde(skip_serializing_if = "Option::is_none")]
404    pub poseidon_builtin_applications: Option<u64>,
405    /// The number of ec_op builtin instances
406    #[serde(skip_serializing_if = "Option::is_none")]
407    pub ec_op_builtin_applications: Option<u64>,
408    /// The number of ecdsa builtin instances
409    #[serde(skip_serializing_if = "Option::is_none")]
410    pub ecdsa_builtin_applications: Option<u64>,
411    /// The number of bitwise builtin instances
412    #[serde(skip_serializing_if = "Option::is_none")]
413    pub bitwise_builtin_applications: Option<u64>,
414    /// The number of keccak builtin instances
415    #[serde(skip_serializing_if = "Option::is_none")]
416    pub keccak_builtin_applications: Option<u64>,
417    /// The number of accesses to the segment arena
418    #[serde(skip_serializing_if = "Option::is_none")]
419    pub segment_arena_builtin: Option<u64>,
420}
421
422/// More data about the execution failure.
423#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
424#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
425pub struct ContractErrorData {
426    /// A string encoding the execution trace up to the point of failure
427    pub revert_error: String,
428}
429
430/// Contract storage diff item.
431#[serde_as]
432#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
433#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
434pub struct ContractStorageDiffItem {
435    /// The contract address for which the storage changed
436    #[serde_as(as = "UfeHex")]
437    pub address: Felt,
438    /// The changes in the storage of the contract
439    pub storage_entries: Vec<StorageEntry>,
440}
441
442/// Da mode.
443///
444/// Specifies a storage domain in Starknet. Each domain has different gurantess regarding
445/// availability.
446#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
447pub enum DataAvailabilityMode {
448    #[serde(rename = "L1")]
449    L1,
450    #[serde(rename = "L2")]
451    L2,
452}
453
454#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
455#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
456pub struct DataAvailabilityResources {
457    /// The gas consumed by this transaction's data, 0 if it uses data gas for da
458    pub l1_gas: u64,
459    /// The data gas consumed by this transaction's data, 0 if it uses gas for da
460    pub l1_data_gas: u64,
461}
462
463/// Dataresources.
464///
465/// The data-availability resources of this transaction.
466#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
467#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
468pub struct DataResources {
469    pub data_availability: DataAvailabilityResources,
470}
471
472/// Declare transaction receipt.
473#[derive(Debug, Clone, PartialEq, Eq)]
474pub struct DeclareTransactionReceipt {
475    /// The hash identifying the transaction
476    pub transaction_hash: Felt,
477    /// The fee that was charged by the sequencer
478    pub actual_fee: FeePayment,
479    /// Finality status of the tx
480    pub finality_status: TransactionFinalityStatus,
481    /// Messages sent
482    pub messages_sent: Vec<MsgToL1>,
483    /// The events emitted as part of this transaction
484    pub events: Vec<Event>,
485    /// The resources consumed by the transaction
486    pub execution_resources: ExecutionResources,
487    pub execution_result: ExecutionResult,
488}
489
490/// The execution trace of a declare transaction.
491#[derive(Debug, Clone, PartialEq, Eq)]
492pub struct DeclareTransactionTrace {
493    pub validate_invocation: Option<FunctionInvocation>,
494    pub fee_transfer_invocation: Option<FunctionInvocation>,
495    /// The state diffs induced by the transaction
496    pub state_diff: Option<StateDiff>,
497    /// The resources consumed by the transaction, includes both computation and data
498    pub execution_resources: ExecutionResources,
499}
500
501/// Declare contract transaction v0.
502///
503/// Declare contract transaction v0.
504#[derive(Debug, Clone, PartialEq, Eq)]
505pub struct DeclareTransactionV0 {
506    /// Transaction hash
507    pub transaction_hash: Felt,
508    /// The address of the account contract sending the declaration transaction
509    pub sender_address: Felt,
510    /// The maximal fee that can be charged for including the transaction
511    pub max_fee: Felt,
512    /// Signature
513    pub signature: Vec<Felt>,
514    /// The hash of the declared class
515    pub class_hash: Felt,
516}
517
518/// Declare contract transaction v1.
519///
520/// Declare contract transaction v1.
521#[derive(Debug, Clone, PartialEq, Eq)]
522pub struct DeclareTransactionV1 {
523    /// Transaction hash
524    pub transaction_hash: Felt,
525    /// The address of the account contract sending the declaration transaction
526    pub sender_address: Felt,
527    /// The maximal fee that can be charged for including the transaction
528    pub max_fee: Felt,
529    /// Signature
530    pub signature: Vec<Felt>,
531    /// Nonce
532    pub nonce: Felt,
533    /// The hash of the declared class
534    pub class_hash: Felt,
535}
536
537/// Declare transaction v2.
538///
539/// Declare contract transaction v2.
540#[derive(Debug, Clone, PartialEq, Eq)]
541pub struct DeclareTransactionV2 {
542    /// Transaction hash
543    pub transaction_hash: Felt,
544    /// The address of the account contract sending the declaration transaction
545    pub sender_address: Felt,
546    /// The hash of the cairo assembly resulting from the sierra compilation
547    pub compiled_class_hash: Felt,
548    /// The maximal fee that can be charged for including the transaction
549    pub max_fee: Felt,
550    /// Signature
551    pub signature: Vec<Felt>,
552    /// Nonce
553    pub nonce: Felt,
554    /// The hash of the declared class
555    pub class_hash: Felt,
556}
557
558/// Declare transaction v3.
559///
560/// Declare contract transaction v3.
561#[derive(Debug, Clone, PartialEq, Eq)]
562pub struct DeclareTransactionV3 {
563    /// Transaction hash
564    pub transaction_hash: Felt,
565    /// The address of the account contract sending the declaration transaction
566    pub sender_address: Felt,
567    /// The hash of the cairo assembly resulting from the sierra compilation
568    pub compiled_class_hash: Felt,
569    /// Signature
570    pub signature: Vec<Felt>,
571    /// Nonce
572    pub nonce: Felt,
573    /// The hash of the declared class
574    pub class_hash: Felt,
575    /// Resource bounds for the transaction execution
576    pub resource_bounds: ResourceBoundsMapping,
577    /// The tip for the transaction
578    pub tip: u64,
579    /// Data needed to allow the paymaster to pay for the transaction in native tokens
580    pub paymaster_data: Vec<Felt>,
581    /// Data needed to deploy the account contract from which this tx will be initiated
582    pub account_deployment_data: Vec<Felt>,
583    /// The storage domain of the account's nonce (an account has a nonce per da mode)
584    pub nonce_data_availability_mode: DataAvailabilityMode,
585    /// The storage domain of the account's balance from which fee will be charged
586    pub fee_data_availability_mode: DataAvailabilityMode,
587}
588
589/// New classes.
590///
591/// The declared class hash and compiled class hash.
592#[serde_as]
593#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
594#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
595pub struct DeclaredClassItem {
596    /// The hash of the declared class
597    #[serde_as(as = "UfeHex")]
598    pub class_hash: Felt,
599    /// The cairo assembly hash corresponding to the declared class
600    #[serde_as(as = "UfeHex")]
601    pub compiled_class_hash: Felt,
602}
603
604/// Deploy account transaction receipt.
605#[derive(Debug, Clone, PartialEq, Eq)]
606pub struct DeployAccountTransactionReceipt {
607    /// The hash identifying the transaction
608    pub transaction_hash: Felt,
609    /// The fee that was charged by the sequencer
610    pub actual_fee: FeePayment,
611    /// Finality status of the tx
612    pub finality_status: TransactionFinalityStatus,
613    /// Messages sent
614    pub messages_sent: Vec<MsgToL1>,
615    /// The events emitted as part of this transaction
616    pub events: Vec<Event>,
617    /// The resources consumed by the transaction
618    pub execution_resources: ExecutionResources,
619    pub execution_result: ExecutionResult,
620    /// The address of the deployed contract
621    pub contract_address: Felt,
622}
623
624/// The execution trace of a deploy account transaction.
625#[derive(Debug, Clone, PartialEq, Eq)]
626pub struct DeployAccountTransactionTrace {
627    pub validate_invocation: Option<FunctionInvocation>,
628    /// The trace of the __execute__ call or constructor call, depending on the transaction type
629    /// (none for declare transactions)
630    pub constructor_invocation: FunctionInvocation,
631    pub fee_transfer_invocation: Option<FunctionInvocation>,
632    /// The state diffs induced by the transaction
633    pub state_diff: Option<StateDiff>,
634    /// The resources consumed by the transaction, includes both computation and data
635    pub execution_resources: ExecutionResources,
636}
637
638/// Deploy account transaction.
639///
640/// Deploys an account contract, charges fee from the pre-funded account addresses.
641#[derive(Debug, Clone, PartialEq, Eq)]
642pub struct DeployAccountTransactionV1 {
643    /// Transaction hash
644    pub transaction_hash: Felt,
645    /// The maximal fee that can be charged for including the transaction
646    pub max_fee: Felt,
647    /// Signature
648    pub signature: Vec<Felt>,
649    /// Nonce
650    pub nonce: Felt,
651    /// The salt for the address of the deployed contract
652    pub contract_address_salt: Felt,
653    /// The parameters passed to the constructor
654    pub constructor_calldata: Vec<Felt>,
655    /// The hash of the deployed contract's class
656    pub class_hash: Felt,
657}
658
659/// Deploy account transaction.
660///
661/// Deploys an account contract, charges fee from the pre-funded account addresses.
662#[derive(Debug, Clone, PartialEq, Eq)]
663pub struct DeployAccountTransactionV3 {
664    /// Transaction hash
665    pub transaction_hash: Felt,
666    /// Signature
667    pub signature: Vec<Felt>,
668    /// Nonce
669    pub nonce: Felt,
670    /// The salt for the address of the deployed contract
671    pub contract_address_salt: Felt,
672    /// The parameters passed to the constructor
673    pub constructor_calldata: Vec<Felt>,
674    /// The hash of the deployed contract's class
675    pub class_hash: Felt,
676    /// Resource bounds for the transaction execution
677    pub resource_bounds: ResourceBoundsMapping,
678    /// The tip for the transaction
679    pub tip: u64,
680    /// Data needed to allow the paymaster to pay for the transaction in native tokens
681    pub paymaster_data: Vec<Felt>,
682    /// The storage domain of the account's nonce (an account has a nonce per da mode)
683    pub nonce_data_availability_mode: DataAvailabilityMode,
684    /// The storage domain of the account's balance from which fee will be charged
685    pub fee_data_availability_mode: DataAvailabilityMode,
686}
687
688/// Deploy contract transaction.
689///
690/// The structure of a deploy transaction. Note that this transaction type is deprecated and will no
691/// longer be supported in future versions.
692#[derive(Debug, Clone, PartialEq, Eq)]
693pub struct DeployTransaction {
694    /// Transaction hash
695    pub transaction_hash: Felt,
696    /// Version of the transaction scheme
697    pub version: Felt,
698    /// The salt for the address of the deployed contract
699    pub contract_address_salt: Felt,
700    /// The parameters passed to the constructor
701    pub constructor_calldata: Vec<Felt>,
702    /// The hash of the deployed contract's class
703    pub class_hash: Felt,
704}
705
706/// Deploy transaction receipt.
707#[derive(Debug, Clone, PartialEq, Eq)]
708pub struct DeployTransactionReceipt {
709    /// The hash identifying the transaction
710    pub transaction_hash: Felt,
711    /// The fee that was charged by the sequencer
712    pub actual_fee: FeePayment,
713    /// Finality status of the tx
714    pub finality_status: TransactionFinalityStatus,
715    /// Messages sent
716    pub messages_sent: Vec<MsgToL1>,
717    /// The events emitted as part of this transaction
718    pub events: Vec<Event>,
719    /// The resources consumed by the transaction
720    pub execution_resources: ExecutionResources,
721    pub execution_result: ExecutionResult,
722    /// The address of the deployed contract
723    pub contract_address: Felt,
724}
725
726/// Deployed contract item.
727#[serde_as]
728#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
729#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
730pub struct DeployedContractItem {
731    /// The address of the contract
732    #[serde_as(as = "UfeHex")]
733    pub address: Felt,
734    /// The hash of the contract code
735    #[serde_as(as = "UfeHex")]
736    pub class_hash: Felt,
737}
738
739/// Emitted event.
740///
741/// Event information decorated with metadata on where it was emitted / an event emitted as a result
742/// of transaction execution.
743#[serde_as]
744#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
745#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
746pub struct EmittedEvent {
747    /// From address
748    #[serde_as(as = "UfeHex")]
749    pub from_address: Felt,
750    /// Keys
751    #[serde_as(as = "Vec<UfeHex>")]
752    pub keys: Vec<Felt>,
753    /// Data
754    #[serde_as(as = "Vec<UfeHex>")]
755    pub data: Vec<Felt>,
756    /// The hash of the block in which the event was emitted
757    #[serde(skip_serializing_if = "Option::is_none")]
758    #[serde_as(as = "Option<UfeHex>")]
759    pub block_hash: Option<Felt>,
760    /// The number of the block in which the event was emitted
761    #[serde(skip_serializing_if = "Option::is_none")]
762    pub block_number: Option<u64>,
763    /// The transaction that emitted the event
764    #[serde_as(as = "UfeHex")]
765    pub transaction_hash: Felt,
766}
767
768#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
769pub enum EntryPointType {
770    #[serde(rename = "EXTERNAL")]
771    External,
772    #[serde(rename = "L1_HANDLER")]
773    L1Handler,
774    #[serde(rename = "CONSTRUCTOR")]
775    Constructor,
776}
777
778/// Entry points by type.
779#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
780#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
781pub struct EntryPointsByType {
782    /// Constructor
783    #[serde(rename = "CONSTRUCTOR")]
784    pub constructor: Vec<SierraEntryPoint>,
785    /// External
786    #[serde(rename = "EXTERNAL")]
787    pub external: Vec<SierraEntryPoint>,
788    /// L1 handler
789    #[serde(rename = "L1_HANDLER")]
790    pub l1_handler: Vec<SierraEntryPoint>,
791}
792
793/// Event.
794///
795/// A Starknet event.
796#[serde_as]
797#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
798#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
799pub struct Event {
800    /// From address
801    #[serde_as(as = "UfeHex")]
802    pub from_address: Felt,
803    /// Keys
804    #[serde_as(as = "Vec<UfeHex>")]
805    pub keys: Vec<Felt>,
806    /// Data
807    #[serde_as(as = "Vec<UfeHex>")]
808    pub data: Vec<Felt>,
809}
810
811/// Event filter.
812///
813/// An event filter/query.
814#[serde_as]
815#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
816#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
817pub struct EventFilter {
818    /// From block
819    #[serde(skip_serializing_if = "Option::is_none")]
820    pub from_block: Option<BlockId>,
821    /// To block
822    #[serde(skip_serializing_if = "Option::is_none")]
823    pub to_block: Option<BlockId>,
824    /// From contract
825    #[serde(skip_serializing_if = "Option::is_none")]
826    #[serde_as(as = "Option<UfeHex>")]
827    pub address: Option<Felt>,
828    /// The values used to filter the events
829    #[serde(skip_serializing_if = "Option::is_none")]
830    #[serde_as(as = "Option<Vec<Vec<UfeHex>>>")]
831    pub keys: Option<Vec<Vec<Felt>>>,
832}
833
834/// Events request.
835#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
836#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
837pub struct EventFilterWithPage {
838    #[serde(flatten)]
839    pub event_filter: EventFilter,
840    #[serde(flatten)]
841    pub result_page_request: ResultPageRequest,
842}
843
844/// Events chunk.
845#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
846#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
847pub struct EventsChunk {
848    /// Matching events
849    pub events: Vec<EmittedEvent>,
850    /// Use this token in a subsequent query to obtain the next page. Should not appear if there are
851    /// no more pages.
852    #[serde(skip_serializing_if = "Option::is_none")]
853    pub continuation_token: Option<String>,
854}
855
856/// Execution resources.
857///
858/// The resources consumed by the transaction, includes both computation and data.
859#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
860#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
861pub struct ExecutionResources {
862    #[serde(flatten)]
863    pub computation_resources: ComputationResources,
864    #[serde(flatten)]
865    pub data_resources: DataResources,
866}
867
868/// Fee estimation.
869#[serde_as]
870#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
871#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
872pub struct FeeEstimate {
873    /// The Ethereum gas consumption of the transaction
874    #[serde_as(as = "UfeHex")]
875    pub gas_consumed: Felt,
876    /// The gas price (in wei or fri, depending on the tx version) that was used in the cost
877    /// estimation
878    #[serde_as(as = "UfeHex")]
879    pub gas_price: Felt,
880    /// The Ethereum data gas consumption of the transaction
881    #[serde_as(as = "UfeHex")]
882    pub data_gas_consumed: Felt,
883    /// The data gas price (in wei or fri, depending on the tx version) that was used in the cost
884    /// estimation
885    #[serde_as(as = "UfeHex")]
886    pub data_gas_price: Felt,
887    /// The estimated fee for the transaction (in wei or fri, depending on the tx version), equals
888    /// to gas_consumed*gas_price + data_gas_consumed*data_gas_price
889    #[serde_as(as = "UfeHex")]
890    pub overall_fee: Felt,
891    /// Units in which the fee is given
892    pub unit: PriceUnit,
893}
894
895/// Fee payment.
896///
897/// Fee payment info as it appears in receipts.
898#[serde_as]
899#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
900#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
901pub struct FeePayment {
902    /// Amount paid
903    #[serde_as(as = "UfeHex")]
904    pub amount: Felt,
905    /// Units in which the fee is given
906    pub unit: PriceUnit,
907}
908
909/// The definition of a sierra Starknet contract class.
910#[serde_as]
911#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
912#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
913pub struct FlattenedSierraClass {
914    /// The list of sierra instructions of which the program consists
915    #[serde_as(as = "Vec<UfeHex>")]
916    pub sierra_program: Vec<Felt>,
917    /// The version of the contract class object. Currently, the Starknet os supports version 0.1.0
918    pub contract_class_version: String,
919    /// Entry points by type
920    pub entry_points_by_type: EntryPointsByType,
921    /// The class abi, as supplied by the user declaring the class
922    pub abi: String,
923}
924
925/// Function call.
926///
927/// Function call information.
928#[serde_as]
929#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
930#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
931pub struct FunctionCall {
932    /// Contract address
933    #[serde_as(as = "UfeHex")]
934    pub contract_address: Felt,
935    /// Entry point selector
936    #[serde_as(as = "UfeHex")]
937    pub entry_point_selector: Felt,
938    /// The parameters passed to the function
939    #[serde_as(as = "Vec<UfeHex>")]
940    pub calldata: Vec<Felt>,
941}
942
943#[serde_as]
944#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
945#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
946pub struct FunctionInvocation {
947    /// Contract address
948    #[serde_as(as = "UfeHex")]
949    pub contract_address: Felt,
950    /// Entry point selector
951    #[serde_as(as = "UfeHex")]
952    pub entry_point_selector: Felt,
953    /// The parameters passed to the function
954    #[serde_as(as = "Vec<UfeHex>")]
955    pub calldata: Vec<Felt>,
956    /// The address of the invoking contract. 0 for the root invocation
957    #[serde_as(as = "UfeHex")]
958    pub caller_address: Felt,
959    /// The hash of the class being called
960    #[serde_as(as = "UfeHex")]
961    pub class_hash: Felt,
962    pub entry_point_type: EntryPointType,
963    pub call_type: CallType,
964    /// The value returned from the function invocation
965    #[serde_as(as = "Vec<UfeHex>")]
966    pub result: Vec<Felt>,
967    /// The calls made by this invocation
968    pub calls: Vec<FunctionInvocation>,
969    /// The events emitted in this invocation
970    pub events: Vec<OrderedEvent>,
971    /// The messages sent by this invocation to L1
972    pub messages: Vec<OrderedMessage>,
973    /// Resources consumed by the internal call. This is named execution_resources for legacy
974    /// reasons
975    pub execution_resources: ComputationResources,
976}
977
978/// Function state mutability type.
979#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
980pub enum FunctionStateMutability {
981    #[serde(rename = "view")]
982    View,
983}
984
985/// Invoke transaction receipt.
986#[derive(Debug, Clone, PartialEq, Eq)]
987pub struct InvokeTransactionReceipt {
988    /// The hash identifying the transaction
989    pub transaction_hash: Felt,
990    /// The fee that was charged by the sequencer
991    pub actual_fee: FeePayment,
992    /// Finality status of the tx
993    pub finality_status: TransactionFinalityStatus,
994    /// Messages sent
995    pub messages_sent: Vec<MsgToL1>,
996    /// The events emitted as part of this transaction
997    pub events: Vec<Event>,
998    /// The resources consumed by the transaction
999    pub execution_resources: ExecutionResources,
1000    pub execution_result: ExecutionResult,
1001}
1002
1003/// The execution trace of an invoke transaction.
1004#[derive(Debug, Clone, PartialEq, Eq)]
1005pub struct InvokeTransactionTrace {
1006    pub validate_invocation: Option<FunctionInvocation>,
1007    pub execute_invocation: ExecuteInvocation,
1008    pub fee_transfer_invocation: Option<FunctionInvocation>,
1009    /// The state diffs induced by the transaction
1010    pub state_diff: Option<StateDiff>,
1011    /// The resources consumed by the transaction, includes both computation and data
1012    pub execution_resources: ExecutionResources,
1013}
1014
1015/// Invoke transaction v0.
1016///
1017/// Invokes a specific function in the desired contract (not necessarily an account).
1018#[derive(Debug, Clone, PartialEq, Eq)]
1019pub struct InvokeTransactionV0 {
1020    /// Transaction hash
1021    pub transaction_hash: Felt,
1022    /// The maximal fee that can be charged for including the transaction
1023    pub max_fee: Felt,
1024    /// Signature
1025    pub signature: Vec<Felt>,
1026    /// Contract address
1027    pub contract_address: Felt,
1028    /// Entry point selector
1029    pub entry_point_selector: Felt,
1030    /// The parameters passed to the function
1031    pub calldata: Vec<Felt>,
1032}
1033
1034/// Invoke transaction v1.
1035///
1036/// Initiates a transaction from a given account.
1037#[derive(Debug, Clone, PartialEq, Eq)]
1038pub struct InvokeTransactionV1 {
1039    /// Transaction hash
1040    pub transaction_hash: Felt,
1041    /// Sender address
1042    pub sender_address: Felt,
1043    /// The data expected by the account's `execute` function (in most usecases, this includes the
1044    /// called contract address and a function selector)
1045    pub calldata: Vec<Felt>,
1046    /// The maximal fee that can be charged for including the transaction
1047    pub max_fee: Felt,
1048    /// Signature
1049    pub signature: Vec<Felt>,
1050    /// Nonce
1051    pub nonce: Felt,
1052}
1053
1054/// Invoke transaction v3.
1055///
1056/// Initiates a transaction from a given account.
1057#[derive(Debug, Clone, PartialEq, Eq)]
1058pub struct InvokeTransactionV3 {
1059    /// Transaction hash
1060    pub transaction_hash: Felt,
1061    /// Sender address
1062    pub sender_address: Felt,
1063    /// The data expected by the account's `execute` function (in most usecases, this includes the
1064    /// called contract address and a function selector)
1065    pub calldata: Vec<Felt>,
1066    /// Signature
1067    pub signature: Vec<Felt>,
1068    /// Nonce
1069    pub nonce: Felt,
1070    /// Resource bounds for the transaction execution
1071    pub resource_bounds: ResourceBoundsMapping,
1072    /// The tip for the transaction
1073    pub tip: u64,
1074    /// Data needed to allow the paymaster to pay for the transaction in native tokens
1075    pub paymaster_data: Vec<Felt>,
1076    /// Data needed to deploy the account contract from which this tx will be initiated
1077    pub account_deployment_data: Vec<Felt>,
1078    /// The storage domain of the account's nonce (an account has a nonce per da mode)
1079    pub nonce_data_availability_mode: DataAvailabilityMode,
1080    /// The storage domain of the account's balance from which fee will be charged
1081    pub fee_data_availability_mode: DataAvailabilityMode,
1082}
1083
1084/// L1 da mode.
1085#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1086pub enum L1DataAvailabilityMode {
1087    #[serde(rename = "BLOB")]
1088    Blob,
1089    #[serde(rename = "CALLDATA")]
1090    Calldata,
1091}
1092
1093/// L1 handler transaction.
1094#[derive(Debug, Clone, PartialEq, Eq)]
1095pub struct L1HandlerTransaction {
1096    /// Transaction hash
1097    pub transaction_hash: Felt,
1098    /// Version of the transaction scheme
1099    pub version: Felt,
1100    /// The L1->L2 message nonce field of the sn core L1 contract at the time the transaction was
1101    /// sent
1102    pub nonce: u64,
1103    /// Contract address
1104    pub contract_address: Felt,
1105    /// Entry point selector
1106    pub entry_point_selector: Felt,
1107    /// The parameters passed to the function
1108    pub calldata: Vec<Felt>,
1109}
1110
1111/// L1 handler transaction receipt.
1112///
1113/// Receipt for L1 handler transaction.
1114#[derive(Debug, Clone, PartialEq, Eq)]
1115pub struct L1HandlerTransactionReceipt {
1116    /// The message hash as it appears on the L1 core contract
1117    pub message_hash: Hash256,
1118    /// The hash identifying the transaction
1119    pub transaction_hash: Felt,
1120    /// The fee that was charged by the sequencer
1121    pub actual_fee: FeePayment,
1122    /// Finality status of the tx
1123    pub finality_status: TransactionFinalityStatus,
1124    /// Messages sent
1125    pub messages_sent: Vec<MsgToL1>,
1126    /// The events emitted as part of this transaction
1127    pub events: Vec<Event>,
1128    /// The resources consumed by the transaction
1129    pub execution_resources: ExecutionResources,
1130    pub execution_result: ExecutionResult,
1131}
1132
1133/// The execution trace of an L1 handler transaction.
1134#[derive(Debug, Clone, PartialEq, Eq)]
1135pub struct L1HandlerTransactionTrace {
1136    /// The trace of the __execute__ call or constructor call, depending on the transaction type
1137    /// (none for declare transactions)
1138    pub function_invocation: FunctionInvocation,
1139    /// The state diffs induced by the transaction
1140    pub state_diff: Option<StateDiff>,
1141    /// The resources consumed by the transaction, includes both computation and data
1142    pub execution_resources: ExecutionResources,
1143}
1144
1145/// Deprecated cairo entry point.
1146#[serde_as]
1147#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1148#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1149pub struct LegacyContractEntryPoint {
1150    /// The offset of the entry point in the program
1151    #[serde_as(as = "NumAsHex")]
1152    pub offset: u64,
1153    /// A unique identifier of the entry point (function) in the program
1154    #[serde_as(as = "UfeHex")]
1155    pub selector: Felt,
1156}
1157
1158/// Deprecated entry points by type.
1159#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1160#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1161pub struct LegacyEntryPointsByType {
1162    /// Deprecated constructor
1163    #[serde(rename = "CONSTRUCTOR")]
1164    pub constructor: Vec<LegacyContractEntryPoint>,
1165    /// Deprecated external
1166    #[serde(rename = "EXTERNAL")]
1167    pub external: Vec<LegacyContractEntryPoint>,
1168    /// Deprecated L1 handler
1169    #[serde(rename = "L1_HANDLER")]
1170    pub l1_handler: Vec<LegacyContractEntryPoint>,
1171}
1172
1173/// Event abi entry.
1174#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1175#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1176pub struct LegacyEventAbiEntry {
1177    /// Event abi type
1178    pub r#type: LegacyEventAbiType,
1179    /// The event name
1180    pub name: String,
1181    /// Typed parameter
1182    pub keys: Vec<LegacyTypedParameter>,
1183    /// Typed parameter
1184    pub data: Vec<LegacyTypedParameter>,
1185}
1186
1187/// Event abi type.
1188#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1189pub enum LegacyEventAbiType {
1190    #[serde(rename = "event")]
1191    Event,
1192}
1193
1194/// Function abi entry.
1195#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1196#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1197pub struct LegacyFunctionAbiEntry {
1198    /// Function abi type
1199    pub r#type: LegacyFunctionAbiType,
1200    /// The function name
1201    pub name: String,
1202    /// Typed parameter
1203    pub inputs: Vec<LegacyTypedParameter>,
1204    /// Typed parameter
1205    pub outputs: Vec<LegacyTypedParameter>,
1206    /// Function state mutability
1207    #[serde(skip_serializing_if = "Option::is_none")]
1208    #[serde(rename = "stateMutability")]
1209    pub state_mutability: Option<FunctionStateMutability>,
1210}
1211
1212/// Function abi type.
1213#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1214pub enum LegacyFunctionAbiType {
1215    #[serde(rename = "function")]
1216    Function,
1217    #[serde(rename = "l1_handler")]
1218    L1Handler,
1219    #[serde(rename = "constructor")]
1220    Constructor,
1221}
1222
1223/// Struct abi entry.
1224#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1225#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1226pub struct LegacyStructAbiEntry {
1227    /// Struct abi type
1228    pub r#type: LegacyStructAbiType,
1229    /// The struct name
1230    pub name: String,
1231    /// Size
1232    pub size: u64,
1233    /// Members
1234    pub members: Vec<LegacyStructMember>,
1235}
1236
1237/// Struct abi type.
1238#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1239pub enum LegacyStructAbiType {
1240    #[serde(rename = "struct")]
1241    Struct,
1242}
1243
1244/// Struct member.
1245#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1246#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1247pub struct LegacyStructMember {
1248    /// The parameter's name
1249    pub name: String,
1250    /// The parameter's type
1251    pub r#type: String,
1252    /// Offset of this property within the struct
1253    pub offset: u64,
1254}
1255
1256/// Typed parameter.
1257#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1258#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1259pub struct LegacyTypedParameter {
1260    /// The parameter's name
1261    pub name: String,
1262    /// The parameter's type
1263    pub r#type: String,
1264}
1265
1266/// Message from L1.
1267#[serde_as]
1268#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1269#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1270pub struct MsgFromL1 {
1271    /// The address of the L1 contract sending the message
1272    pub from_address: EthAddress,
1273    /// The target L2 address the message is sent to
1274    #[serde_as(as = "UfeHex")]
1275    pub to_address: Felt,
1276    /// The selector of the l1_handler in invoke in the target contract
1277    #[serde_as(as = "UfeHex")]
1278    pub entry_point_selector: Felt,
1279    /// The payload of the message
1280    #[serde_as(as = "Vec<UfeHex>")]
1281    pub payload: Vec<Felt>,
1282}
1283
1284/// Message to L1.
1285#[serde_as]
1286#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1287#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1288pub struct MsgToL1 {
1289    /// The address of the L2 contract sending the message
1290    #[serde_as(as = "UfeHex")]
1291    pub from_address: Felt,
1292    /// The target L1 address the message is sent to
1293    #[serde_as(as = "UfeHex")]
1294    pub to_address: Felt,
1295    /// The payload of the message
1296    #[serde_as(as = "Vec<UfeHex>")]
1297    pub payload: Vec<Felt>,
1298}
1299
1300/// Extra information on why trace is not available. Either it wasn't executed yet (received), or
1301/// the transaction failed (rejected).
1302#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1303#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1304pub struct NoTraceAvailableErrorData {
1305    pub status: SequencerTransactionStatus,
1306}
1307
1308/// Nonce update.
1309///
1310/// The updated nonce per contract address.
1311#[serde_as]
1312#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1313#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1314pub struct NonceUpdate {
1315    /// The address of the contract
1316    #[serde_as(as = "UfeHex")]
1317    pub contract_address: Felt,
1318    /// The nonce for the given address at the end of the block
1319    #[serde_as(as = "UfeHex")]
1320    pub nonce: Felt,
1321}
1322
1323/// Orderedevent.
1324///
1325/// An event alongside its order within the transaction.
1326#[serde_as]
1327#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1328#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1329pub struct OrderedEvent {
1330    /// The order of the event within the transaction
1331    pub order: u64,
1332    /// Keys
1333    #[serde_as(as = "Vec<UfeHex>")]
1334    pub keys: Vec<Felt>,
1335    /// Data
1336    #[serde_as(as = "Vec<UfeHex>")]
1337    pub data: Vec<Felt>,
1338}
1339
1340/// Orderedmessage.
1341///
1342/// A message alongside its order within the transaction.
1343#[serde_as]
1344#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1345#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1346pub struct OrderedMessage {
1347    /// The order of the message within the transaction
1348    pub order: u64,
1349    /// The address of the L2 contract sending the message
1350    #[serde_as(as = "UfeHex")]
1351    pub from_address: Felt,
1352    /// The target L1 address the message is sent to
1353    #[serde_as(as = "UfeHex")]
1354    pub to_address: Felt,
1355    /// The payload of the message
1356    #[serde_as(as = "Vec<UfeHex>")]
1357    pub payload: Vec<Felt>,
1358}
1359
1360/// Pending block with transactions and receipts.
1361///
1362/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated
1363/// upon decentralization.
1364#[serde_as]
1365#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1366#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1367pub struct PendingBlockWithReceipts {
1368    /// The transactions in this block
1369    pub transactions: Vec<TransactionWithReceipt>,
1370    /// The hash of this block's parent
1371    #[serde_as(as = "UfeHex")]
1372    pub parent_hash: Felt,
1373    /// The time in which the block was created, encoded in Unix time
1374    pub timestamp: u64,
1375    /// The Starknet identity of the sequencer submitting this block
1376    #[serde_as(as = "UfeHex")]
1377    pub sequencer_address: Felt,
1378    /// The price of L1 gas in the block
1379    pub l1_gas_price: ResourcePrice,
1380    /// The price of L1 data gas in the block
1381    pub l1_data_gas_price: ResourcePrice,
1382    /// Specifies whether the data of this block is published via blob data or calldata
1383    pub l1_da_mode: L1DataAvailabilityMode,
1384    /// Semver of the current Starknet protocol
1385    pub starknet_version: String,
1386}
1387
1388/// Pending block with transaction hashes.
1389///
1390/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated
1391/// upon decentralization.
1392#[serde_as]
1393#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1394#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1395pub struct PendingBlockWithTxHashes {
1396    /// The hashes of the transactions included in this block
1397    #[serde_as(as = "Vec<UfeHex>")]
1398    pub transactions: Vec<Felt>,
1399    /// The hash of this block's parent
1400    #[serde_as(as = "UfeHex")]
1401    pub parent_hash: Felt,
1402    /// The time in which the block was created, encoded in Unix time
1403    pub timestamp: u64,
1404    /// The Starknet identity of the sequencer submitting this block
1405    #[serde_as(as = "UfeHex")]
1406    pub sequencer_address: Felt,
1407    /// The price of L1 gas in the block
1408    pub l1_gas_price: ResourcePrice,
1409    /// The price of L1 data gas in the block
1410    pub l1_data_gas_price: ResourcePrice,
1411    /// Specifies whether the data of this block is published via blob data or calldata
1412    pub l1_da_mode: L1DataAvailabilityMode,
1413    /// Semver of the current Starknet protocol
1414    pub starknet_version: String,
1415}
1416
1417/// Pending block with transactions.
1418///
1419/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated
1420/// upon decentralization.
1421#[serde_as]
1422#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1423#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1424pub struct PendingBlockWithTxs {
1425    /// The transactions in this block
1426    pub transactions: Vec<Transaction>,
1427    /// The hash of this block's parent
1428    #[serde_as(as = "UfeHex")]
1429    pub parent_hash: Felt,
1430    /// The time in which the block was created, encoded in Unix time
1431    pub timestamp: u64,
1432    /// The Starknet identity of the sequencer submitting this block
1433    #[serde_as(as = "UfeHex")]
1434    pub sequencer_address: Felt,
1435    /// The price of L1 gas in the block
1436    pub l1_gas_price: ResourcePrice,
1437    /// The price of L1 data gas in the block
1438    pub l1_data_gas_price: ResourcePrice,
1439    /// Specifies whether the data of this block is published via blob data or calldata
1440    pub l1_da_mode: L1DataAvailabilityMode,
1441    /// Semver of the current Starknet protocol
1442    pub starknet_version: String,
1443}
1444
1445/// Pending state update.
1446///
1447/// Pending state update.
1448#[serde_as]
1449#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1450#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1451pub struct PendingStateUpdate {
1452    /// The previous global state root
1453    #[serde_as(as = "UfeHex")]
1454    pub old_root: Felt,
1455    /// State diff
1456    pub state_diff: StateDiff,
1457}
1458
1459/// Price unit.
1460#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1461pub enum PriceUnit {
1462    #[serde(rename = "WEI")]
1463    Wei,
1464    #[serde(rename = "FRI")]
1465    Fri,
1466}
1467
1468/// Replaced class.
1469///
1470/// The list of contracts whose class was replaced.
1471#[serde_as]
1472#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1473#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1474pub struct ReplacedClassItem {
1475    /// The address of the contract whose class was replaced
1476    #[serde_as(as = "UfeHex")]
1477    pub contract_address: Felt,
1478    /// The new class hash
1479    #[serde_as(as = "UfeHex")]
1480    pub class_hash: Felt,
1481}
1482
1483#[serde_as]
1484#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1485#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1486pub struct ResourceBounds {
1487    /// The max amount of the resource that can be used in the tx
1488    #[serde_as(as = "NumAsHex")]
1489    pub max_amount: u64,
1490    /// The max price per unit of this resource for this tx
1491    #[serde_as(as = "NumAsHex")]
1492    pub max_price_per_unit: u128,
1493}
1494
1495#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1496#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1497pub struct ResourceBoundsMapping {
1498    /// The max amount and max price per unit of L1 gas used in this tx
1499    pub l1_gas: ResourceBounds,
1500    /// The max amount and max price per unit of L2 gas used in this tx
1501    pub l2_gas: ResourceBounds,
1502}
1503
1504#[serde_as]
1505#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1506#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1507pub struct ResourcePrice {
1508    /// The price of one unit of the given resource, denominated in fri (10^-18 strk)
1509    #[serde_as(as = "UfeHex")]
1510    pub price_in_fri: Felt,
1511    /// The price of one unit of the given resource, denominated in wei
1512    #[serde_as(as = "UfeHex")]
1513    pub price_in_wei: Felt,
1514}
1515
1516/// Result page request.
1517#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1518#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1519pub struct ResultPageRequest {
1520    /// The token returned from the previous query. If no token is provided the first page is
1521    /// returned.
1522    #[serde(skip_serializing_if = "Option::is_none")]
1523    pub continuation_token: Option<String>,
1524    /// Chunk size
1525    pub chunk_size: u64,
1526}
1527
1528#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1529#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1530pub struct RevertedInvocation {
1531    /// The revert reason for the failed execution
1532    pub revert_reason: String,
1533}
1534
1535/// Transaction status.
1536///
1537/// The finality status of the transaction, including the case the txn is still in the mempool or
1538/// failed validation during the block construction phase.
1539#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1540pub enum SequencerTransactionStatus {
1541    #[serde(rename = "RECEIVED")]
1542    Received,
1543    #[serde(rename = "REJECTED")]
1544    Rejected,
1545    #[serde(rename = "ACCEPTED_ON_L2")]
1546    AcceptedOnL2,
1547    #[serde(rename = "ACCEPTED_ON_L1")]
1548    AcceptedOnL1,
1549}
1550
1551/// Sierra entry point.
1552#[serde_as]
1553#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1554#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1555pub struct SierraEntryPoint {
1556    /// A unique identifier of the entry point (function) in the program
1557    #[serde_as(as = "UfeHex")]
1558    pub selector: Felt,
1559    /// The index of the function in the program
1560    pub function_idx: u64,
1561}
1562
1563#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1564#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1565pub struct SimulatedTransaction {
1566    /// The transaction's trace
1567    pub transaction_trace: TransactionTrace,
1568    /// The transaction's resources and fee
1569    pub fee_estimation: FeeEstimate,
1570}
1571
1572/// Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is
1573/// replicated locally (enough funds are expected to be in the account, and fee will be deducted
1574/// from the balance before the simulation of the next transaction). To skip the fee charge, use the
1575/// skip_fee_charge flag.
1576#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1577pub enum SimulationFlag {
1578    #[serde(rename = "SKIP_VALIDATE")]
1579    SkipValidate,
1580    #[serde(rename = "SKIP_FEE_CHARGE")]
1581    SkipFeeCharge,
1582}
1583
1584/// Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is
1585/// replicated locally.
1586#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1587pub enum SimulationFlagForEstimateFee {
1588    #[serde(rename = "SKIP_VALIDATE")]
1589    SkipValidate,
1590}
1591
1592/// JSON-RPC error codes
1593#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1594pub enum StarknetError {
1595    /// Failed to write transaction
1596    FailedToReceiveTransaction,
1597    /// Contract not found
1598    ContractNotFound,
1599    /// Block not found
1600    BlockNotFound,
1601    /// Invalid transaction index in a block
1602    InvalidTransactionIndex,
1603    /// Class hash not found
1604    ClassHashNotFound,
1605    /// Transaction hash not found
1606    TransactionHashNotFound,
1607    /// Requested page size is too big
1608    PageSizeTooBig,
1609    /// There are no blocks
1610    NoBlocks,
1611    /// The supplied continuation token is invalid or unknown
1612    InvalidContinuationToken,
1613    /// Too many keys provided in a filter
1614    TooManyKeysInFilter,
1615    /// Contract error
1616    ContractError(ContractErrorData),
1617    /// Transaction execution error
1618    TransactionExecutionError(TransactionExecutionErrorData),
1619    /// Class already declared
1620    ClassAlreadyDeclared,
1621    /// Invalid transaction nonce
1622    InvalidTransactionNonce,
1623    /// Max fee is smaller than the minimal transaction cost (validation plus fee transfer)
1624    InsufficientMaxFee,
1625    /// Account balance is smaller than the transaction's max_fee
1626    InsufficientAccountBalance,
1627    /// Account validation failed
1628    ValidationFailure(String),
1629    /// Compilation failed
1630    CompilationFailed,
1631    /// Contract class size it too large
1632    ContractClassSizeIsTooLarge,
1633    /// Sender address in not an account contract
1634    NonAccount,
1635    /// A transaction with the same hash already exists in the mempool
1636    DuplicateTx,
1637    /// the compiled class hash did not match the one supplied in the transaction
1638    CompiledClassHashMismatch,
1639    /// the transaction version is not supported
1640    UnsupportedTxVersion,
1641    /// the contract class version is not supported
1642    UnsupportedContractClassVersion,
1643    /// An unexpected error occurred
1644    UnexpectedError(String),
1645    /// No trace available for transaction
1646    NoTraceAvailable(NoTraceAvailableErrorData),
1647}
1648
1649#[cfg(feature = "std")]
1650impl std::error::Error for StarknetError {}
1651
1652impl core::fmt::Display for StarknetError {
1653    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1654        match self {
1655            Self::FailedToReceiveTransaction => write!(f, "FailedToReceiveTransaction"),
1656            Self::ContractNotFound => write!(f, "ContractNotFound"),
1657            Self::BlockNotFound => write!(f, "BlockNotFound"),
1658            Self::InvalidTransactionIndex => write!(f, "InvalidTransactionIndex"),
1659            Self::ClassHashNotFound => write!(f, "ClassHashNotFound"),
1660            Self::TransactionHashNotFound => write!(f, "TransactionHashNotFound"),
1661            Self::PageSizeTooBig => write!(f, "PageSizeTooBig"),
1662            Self::NoBlocks => write!(f, "NoBlocks"),
1663            Self::InvalidContinuationToken => write!(f, "InvalidContinuationToken"),
1664            Self::TooManyKeysInFilter => write!(f, "TooManyKeysInFilter"),
1665            Self::ContractError(_) => write!(f, "ContractError"),
1666            Self::TransactionExecutionError(_) => write!(f, "TransactionExecutionError"),
1667            Self::ClassAlreadyDeclared => write!(f, "ClassAlreadyDeclared"),
1668            Self::InvalidTransactionNonce => write!(f, "InvalidTransactionNonce"),
1669            Self::InsufficientMaxFee => write!(f, "InsufficientMaxFee"),
1670            Self::InsufficientAccountBalance => write!(f, "InsufficientAccountBalance"),
1671            Self::ValidationFailure(_) => write!(f, "ValidationFailure"),
1672            Self::CompilationFailed => write!(f, "CompilationFailed"),
1673            Self::ContractClassSizeIsTooLarge => write!(f, "ContractClassSizeIsTooLarge"),
1674            Self::NonAccount => write!(f, "NonAccount"),
1675            Self::DuplicateTx => write!(f, "DuplicateTx"),
1676            Self::CompiledClassHashMismatch => write!(f, "CompiledClassHashMismatch"),
1677            Self::UnsupportedTxVersion => write!(f, "UnsupportedTxVersion"),
1678            Self::UnsupportedContractClassVersion => write!(f, "UnsupportedContractClassVersion"),
1679            Self::UnexpectedError(_) => write!(f, "UnexpectedError"),
1680            Self::NoTraceAvailable(_) => write!(f, "NoTraceAvailable"),
1681        }
1682    }
1683}
1684
1685impl StarknetError {
1686    pub fn message(&self) -> &'static str {
1687        match self {
1688            Self::FailedToReceiveTransaction => "Failed to write transaction",
1689            Self::ContractNotFound => "Contract not found",
1690            Self::BlockNotFound => "Block not found",
1691            Self::InvalidTransactionIndex => "Invalid transaction index in a block",
1692            Self::ClassHashNotFound => "Class hash not found",
1693            Self::TransactionHashNotFound => "Transaction hash not found",
1694            Self::PageSizeTooBig => "Requested page size is too big",
1695            Self::NoBlocks => "There are no blocks",
1696            Self::InvalidContinuationToken => "The supplied continuation token is invalid or unknown",
1697            Self::TooManyKeysInFilter => "Too many keys provided in a filter",
1698            Self::ContractError(_) => "Contract error",
1699            Self::TransactionExecutionError(_) => "Transaction execution error",
1700            Self::ClassAlreadyDeclared => "Class already declared",
1701            Self::InvalidTransactionNonce => "Invalid transaction nonce",
1702            Self::InsufficientMaxFee => "Max fee is smaller than the minimal transaction cost (validation plus fee transfer)",
1703            Self::InsufficientAccountBalance => "Account balance is smaller than the transaction's max_fee",
1704            Self::ValidationFailure(_) => "Account validation failed",
1705            Self::CompilationFailed => "Compilation failed",
1706            Self::ContractClassSizeIsTooLarge => "Contract class size it too large",
1707            Self::NonAccount => "Sender address in not an account contract",
1708            Self::DuplicateTx => "A transaction with the same hash already exists in the mempool",
1709            Self::CompiledClassHashMismatch => "the compiled class hash did not match the one supplied in the transaction",
1710            Self::UnsupportedTxVersion => "the transaction version is not supported",
1711            Self::UnsupportedContractClassVersion => "the contract class version is not supported",
1712            Self::UnexpectedError(_) => "An unexpected error occurred",
1713            Self::NoTraceAvailable(_) => "No trace available for transaction",
1714        }
1715    }
1716}
1717
1718/// The change in state applied in this block, given as a mapping of addresses to the new values
1719/// and/or new contracts.
1720#[serde_as]
1721#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1722#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1723pub struct StateDiff {
1724    /// Storage diffs
1725    pub storage_diffs: Vec<ContractStorageDiffItem>,
1726    /// Deprecated declared classes
1727    #[serde_as(as = "Vec<UfeHex>")]
1728    pub deprecated_declared_classes: Vec<Felt>,
1729    /// Declared classes
1730    pub declared_classes: Vec<DeclaredClassItem>,
1731    /// Deployed contracts
1732    pub deployed_contracts: Vec<DeployedContractItem>,
1733    /// Replaced classes
1734    pub replaced_classes: Vec<ReplacedClassItem>,
1735    /// Nonces
1736    pub nonces: Vec<NonceUpdate>,
1737}
1738
1739/// State update.
1740#[serde_as]
1741#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1742#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1743pub struct StateUpdate {
1744    /// Block hash
1745    #[serde_as(as = "UfeHex")]
1746    pub block_hash: Felt,
1747    /// The previous global state root
1748    #[serde_as(as = "UfeHex")]
1749    pub old_root: Felt,
1750    /// The new global state root
1751    #[serde_as(as = "UfeHex")]
1752    pub new_root: Felt,
1753    /// State diff
1754    pub state_diff: StateDiff,
1755}
1756
1757/// Storage diff item.
1758#[serde_as]
1759#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1760#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1761pub struct StorageEntry {
1762    /// The key of the changed value
1763    #[serde_as(as = "UfeHex")]
1764    pub key: Felt,
1765    /// The new value applied to the given address
1766    #[serde_as(as = "UfeHex")]
1767    pub value: Felt,
1768}
1769
1770/// Sync status.
1771///
1772/// An object describing the node synchronization status.
1773#[serde_as]
1774#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1775#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1776pub struct SyncStatus {
1777    /// The hash of the block from which the sync started
1778    #[serde_as(as = "UfeHex")]
1779    pub starting_block_hash: Felt,
1780    /// The number (height) of the block from which the sync started
1781    pub starting_block_num: u64,
1782    /// The hash of the current block being synchronized
1783    #[serde_as(as = "UfeHex")]
1784    pub current_block_hash: Felt,
1785    /// The number (height) of the current block being synchronized
1786    pub current_block_num: u64,
1787    /// The hash of the estimated highest block to be synchronized
1788    #[serde_as(as = "UfeHex")]
1789    pub highest_block_hash: Felt,
1790    /// The number (height) of the estimated highest block to be synchronized
1791    pub highest_block_num: u64,
1792}
1793
1794/// More data about the execution failure.
1795#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1796#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1797pub struct TransactionExecutionErrorData {
1798    /// The index of the first transaction failing in a sequence of given transactions
1799    pub transaction_index: u64,
1800    /// A string encoding the execution trace up to the point of failure
1801    pub execution_error: String,
1802}
1803
1804/// Execution status.
1805///
1806/// The execution status of the transaction.
1807#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1808pub enum TransactionExecutionStatus {
1809    #[serde(rename = "SUCCEEDED")]
1810    Succeeded,
1811    #[serde(rename = "REVERTED")]
1812    Reverted,
1813}
1814
1815/// Finality status.
1816///
1817/// The finality status of the transaction.
1818#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1819pub enum TransactionFinalityStatus {
1820    #[serde(rename = "ACCEPTED_ON_L2")]
1821    AcceptedOnL2,
1822    #[serde(rename = "ACCEPTED_ON_L1")]
1823    AcceptedOnL1,
1824}
1825
1826/// Transaction receipt with block info.
1827#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1828pub struct TransactionReceiptWithBlockInfo {
1829    #[serde(flatten)]
1830    pub receipt: TransactionReceipt,
1831    #[serde(flatten)]
1832    pub block: ReceiptBlock,
1833}
1834
1835/// A single pair of transaction hash and corresponding trace.
1836#[serde_as]
1837#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1838#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1839pub struct TransactionTraceWithHash {
1840    #[serde_as(as = "UfeHex")]
1841    pub transaction_hash: Felt,
1842    pub trace_root: TransactionTrace,
1843}
1844
1845/// Transaction and receipt.
1846#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1847#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1848pub struct TransactionWithReceipt {
1849    /// Transaction
1850    pub transaction: Transaction,
1851    /// Receipt
1852    pub receipt: TransactionReceipt,
1853}
1854
1855/// Request for method starknet_addDeclareTransaction
1856#[derive(Debug, Clone, PartialEq, Eq)]
1857pub struct AddDeclareTransactionRequest {
1858    /// Declare transaction required to declare a new class on Starknet
1859    pub declare_transaction: BroadcastedDeclareTransaction,
1860}
1861
1862/// Reference version of [AddDeclareTransactionRequest].
1863#[derive(Debug, Clone, PartialEq, Eq)]
1864pub struct AddDeclareTransactionRequestRef<'a> {
1865    pub declare_transaction: &'a BroadcastedDeclareTransaction,
1866}
1867
1868/// Request for method starknet_addDeployAccountTransaction
1869#[derive(Debug, Clone, PartialEq, Eq)]
1870pub struct AddDeployAccountTransactionRequest {
1871    /// The deploy account transaction
1872    pub deploy_account_transaction: BroadcastedDeployAccountTransaction,
1873}
1874
1875/// Reference version of [AddDeployAccountTransactionRequest].
1876#[derive(Debug, Clone, PartialEq, Eq)]
1877pub struct AddDeployAccountTransactionRequestRef<'a> {
1878    pub deploy_account_transaction: &'a BroadcastedDeployAccountTransaction,
1879}
1880
1881/// Request for method starknet_addInvokeTransaction
1882#[derive(Debug, Clone, PartialEq, Eq)]
1883pub struct AddInvokeTransactionRequest {
1884    /// The information needed to invoke the function (or account, for version 1 transactions)
1885    pub invoke_transaction: BroadcastedInvokeTransaction,
1886}
1887
1888/// Reference version of [AddInvokeTransactionRequest].
1889#[derive(Debug, Clone, PartialEq, Eq)]
1890pub struct AddInvokeTransactionRequestRef<'a> {
1891    pub invoke_transaction: &'a BroadcastedInvokeTransaction,
1892}
1893
1894/// Request for method starknet_blockHashAndNumber
1895#[derive(Debug, Clone, PartialEq, Eq)]
1896pub struct BlockHashAndNumberRequest;
1897
1898/// Request for method starknet_blockNumber
1899#[derive(Debug, Clone, PartialEq, Eq)]
1900pub struct BlockNumberRequest;
1901
1902/// Request for method starknet_call
1903#[derive(Debug, Clone, PartialEq, Eq)]
1904pub struct CallRequest {
1905    pub request: FunctionCall,
1906    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
1907    /// for the block referencing the state or call the transaction on.
1908    pub block_id: BlockId,
1909}
1910
1911/// Reference version of [CallRequest].
1912#[derive(Debug, Clone, PartialEq, Eq)]
1913pub struct CallRequestRef<'a> {
1914    pub request: &'a FunctionCall,
1915    pub block_id: &'a BlockId,
1916}
1917
1918/// Request for method starknet_chainId
1919#[derive(Debug, Clone, PartialEq, Eq)]
1920pub struct ChainIdRequest;
1921
1922/// Request for method starknet_estimateFee
1923#[derive(Debug, Clone, PartialEq, Eq)]
1924pub struct EstimateFeeRequest {
1925    pub request: Vec<BroadcastedTransaction>,
1926    /// describes what parts of the transaction should be executed
1927    pub simulation_flags: Vec<SimulationFlagForEstimateFee>,
1928    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
1929    /// for the block referencing the state or call the transaction on.
1930    pub block_id: BlockId,
1931}
1932
1933/// Reference version of [EstimateFeeRequest].
1934#[derive(Debug, Clone, PartialEq, Eq)]
1935pub struct EstimateFeeRequestRef<'a> {
1936    pub request: &'a [BroadcastedTransaction],
1937    pub simulation_flags: &'a [SimulationFlagForEstimateFee],
1938    pub block_id: &'a BlockId,
1939}
1940
1941/// Request for method starknet_estimateMessageFee
1942#[derive(Debug, Clone, PartialEq, Eq)]
1943pub struct EstimateMessageFeeRequest {
1944    /// the message's parameters
1945    pub message: MsgFromL1,
1946    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
1947    /// for the block referencing the state or call the transaction on.
1948    pub block_id: BlockId,
1949}
1950
1951/// Reference version of [EstimateMessageFeeRequest].
1952#[derive(Debug, Clone, PartialEq, Eq)]
1953pub struct EstimateMessageFeeRequestRef<'a> {
1954    pub message: &'a MsgFromL1,
1955    pub block_id: &'a BlockId,
1956}
1957
1958/// Request for method starknet_getBlockTransactionCount
1959#[derive(Debug, Clone, PartialEq, Eq)]
1960pub struct GetBlockTransactionCountRequest {
1961    /// The hash of the requested block, or number (height) of the requested block, or a block tag
1962    pub block_id: BlockId,
1963}
1964
1965/// Reference version of [GetBlockTransactionCountRequest].
1966#[derive(Debug, Clone, PartialEq, Eq)]
1967pub struct GetBlockTransactionCountRequestRef<'a> {
1968    pub block_id: &'a BlockId,
1969}
1970
1971/// Request for method starknet_getBlockWithReceipts
1972#[derive(Debug, Clone, PartialEq, Eq)]
1973pub struct GetBlockWithReceiptsRequest {
1974    /// The hash of the requested block, or number (height) of the requested block, or a block tag
1975    pub block_id: BlockId,
1976}
1977
1978/// Reference version of [GetBlockWithReceiptsRequest].
1979#[derive(Debug, Clone, PartialEq, Eq)]
1980pub struct GetBlockWithReceiptsRequestRef<'a> {
1981    pub block_id: &'a BlockId,
1982}
1983
1984/// Request for method starknet_getBlockWithTxHashes
1985#[derive(Debug, Clone, PartialEq, Eq)]
1986pub struct GetBlockWithTxHashesRequest {
1987    /// The hash of the requested block, or number (height) of the requested block, or a block tag
1988    pub block_id: BlockId,
1989}
1990
1991/// Reference version of [GetBlockWithTxHashesRequest].
1992#[derive(Debug, Clone, PartialEq, Eq)]
1993pub struct GetBlockWithTxHashesRequestRef<'a> {
1994    pub block_id: &'a BlockId,
1995}
1996
1997/// Request for method starknet_getBlockWithTxs
1998#[derive(Debug, Clone, PartialEq, Eq)]
1999pub struct GetBlockWithTxsRequest {
2000    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2001    pub block_id: BlockId,
2002}
2003
2004/// Reference version of [GetBlockWithTxsRequest].
2005#[derive(Debug, Clone, PartialEq, Eq)]
2006pub struct GetBlockWithTxsRequestRef<'a> {
2007    pub block_id: &'a BlockId,
2008}
2009
2010/// Request for method starknet_getClassAt
2011#[derive(Debug, Clone, PartialEq, Eq)]
2012pub struct GetClassAtRequest {
2013    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2014    pub block_id: BlockId,
2015    /// The address of the contract whose class definition will be returned
2016    pub contract_address: Felt,
2017}
2018
2019/// Reference version of [GetClassAtRequest].
2020#[derive(Debug, Clone, PartialEq, Eq)]
2021pub struct GetClassAtRequestRef<'a> {
2022    pub block_id: &'a BlockId,
2023    pub contract_address: &'a Felt,
2024}
2025
2026/// Request for method starknet_getClassHashAt
2027#[derive(Debug, Clone, PartialEq, Eq)]
2028pub struct GetClassHashAtRequest {
2029    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2030    pub block_id: BlockId,
2031    /// The address of the contract whose class hash will be returned
2032    pub contract_address: Felt,
2033}
2034
2035/// Reference version of [GetClassHashAtRequest].
2036#[derive(Debug, Clone, PartialEq, Eq)]
2037pub struct GetClassHashAtRequestRef<'a> {
2038    pub block_id: &'a BlockId,
2039    pub contract_address: &'a Felt,
2040}
2041
2042/// Request for method starknet_getClass
2043#[derive(Debug, Clone, PartialEq, Eq)]
2044pub struct GetClassRequest {
2045    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2046    pub block_id: BlockId,
2047    /// The hash of the requested contract class
2048    pub class_hash: Felt,
2049}
2050
2051/// Reference version of [GetClassRequest].
2052#[derive(Debug, Clone, PartialEq, Eq)]
2053pub struct GetClassRequestRef<'a> {
2054    pub block_id: &'a BlockId,
2055    pub class_hash: &'a Felt,
2056}
2057
2058/// Request for method starknet_getEvents
2059#[derive(Debug, Clone, PartialEq, Eq)]
2060pub struct GetEventsRequest {
2061    pub filter: EventFilterWithPage,
2062}
2063
2064/// Reference version of [GetEventsRequest].
2065#[derive(Debug, Clone, PartialEq, Eq)]
2066pub struct GetEventsRequestRef<'a> {
2067    pub filter: &'a EventFilterWithPage,
2068}
2069
2070/// Request for method starknet_getNonce
2071#[derive(Debug, Clone, PartialEq, Eq)]
2072pub struct GetNonceRequest {
2073    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2074    pub block_id: BlockId,
2075    /// The address of the contract whose nonce we're seeking
2076    pub contract_address: Felt,
2077}
2078
2079/// Reference version of [GetNonceRequest].
2080#[derive(Debug, Clone, PartialEq, Eq)]
2081pub struct GetNonceRequestRef<'a> {
2082    pub block_id: &'a BlockId,
2083    pub contract_address: &'a Felt,
2084}
2085
2086/// Request for method starknet_getStateUpdate
2087#[derive(Debug, Clone, PartialEq, Eq)]
2088pub struct GetStateUpdateRequest {
2089    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2090    pub block_id: BlockId,
2091}
2092
2093/// Reference version of [GetStateUpdateRequest].
2094#[derive(Debug, Clone, PartialEq, Eq)]
2095pub struct GetStateUpdateRequestRef<'a> {
2096    pub block_id: &'a BlockId,
2097}
2098
2099/// Request for method starknet_getStorageAt
2100#[derive(Debug, Clone, PartialEq, Eq)]
2101pub struct GetStorageAtRequest {
2102    /// The address of the contract to read from
2103    pub contract_address: Felt,
2104    /// The key to the storage value for the given contract
2105    pub key: Felt,
2106    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2107    pub block_id: BlockId,
2108}
2109
2110/// Reference version of [GetStorageAtRequest].
2111#[derive(Debug, Clone, PartialEq, Eq)]
2112pub struct GetStorageAtRequestRef<'a> {
2113    pub contract_address: &'a Felt,
2114    pub key: &'a Felt,
2115    pub block_id: &'a BlockId,
2116}
2117
2118/// Request for method starknet_getTransactionByBlockIdAndIndex
2119#[derive(Debug, Clone, PartialEq, Eq)]
2120pub struct GetTransactionByBlockIdAndIndexRequest {
2121    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2122    pub block_id: BlockId,
2123    pub index: u64,
2124}
2125
2126/// Reference version of [GetTransactionByBlockIdAndIndexRequest].
2127#[derive(Debug, Clone, PartialEq, Eq)]
2128pub struct GetTransactionByBlockIdAndIndexRequestRef<'a> {
2129    pub block_id: &'a BlockId,
2130    pub index: &'a u64,
2131}
2132
2133/// Request for method starknet_getTransactionByHash
2134#[derive(Debug, Clone, PartialEq, Eq)]
2135pub struct GetTransactionByHashRequest {
2136    pub transaction_hash: Felt,
2137}
2138
2139/// Reference version of [GetTransactionByHashRequest].
2140#[derive(Debug, Clone, PartialEq, Eq)]
2141pub struct GetTransactionByHashRequestRef<'a> {
2142    pub transaction_hash: &'a Felt,
2143}
2144
2145/// Request for method starknet_getTransactionReceipt
2146#[derive(Debug, Clone, PartialEq, Eq)]
2147pub struct GetTransactionReceiptRequest {
2148    pub transaction_hash: Felt,
2149}
2150
2151/// Reference version of [GetTransactionReceiptRequest].
2152#[derive(Debug, Clone, PartialEq, Eq)]
2153pub struct GetTransactionReceiptRequestRef<'a> {
2154    pub transaction_hash: &'a Felt,
2155}
2156
2157/// Request for method starknet_getTransactionStatus
2158#[derive(Debug, Clone, PartialEq, Eq)]
2159pub struct GetTransactionStatusRequest {
2160    pub transaction_hash: Felt,
2161}
2162
2163/// Reference version of [GetTransactionStatusRequest].
2164#[derive(Debug, Clone, PartialEq, Eq)]
2165pub struct GetTransactionStatusRequestRef<'a> {
2166    pub transaction_hash: &'a Felt,
2167}
2168
2169/// Request for method starknet_simulateTransactions
2170#[derive(Debug, Clone, PartialEq, Eq)]
2171pub struct SimulateTransactionsRequest {
2172    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
2173    /// for the block referencing the state or call the transaction on.
2174    pub block_id: BlockId,
2175    /// The transactions to simulate
2176    pub transactions: Vec<BroadcastedTransaction>,
2177    /// describes what parts of the transaction should be executed
2178    pub simulation_flags: Vec<SimulationFlag>,
2179}
2180
2181/// Reference version of [SimulateTransactionsRequest].
2182#[derive(Debug, Clone, PartialEq, Eq)]
2183pub struct SimulateTransactionsRequestRef<'a> {
2184    pub block_id: &'a BlockId,
2185    pub transactions: &'a [BroadcastedTransaction],
2186    pub simulation_flags: &'a [SimulationFlag],
2187}
2188
2189/// Request for method starknet_specVersion
2190#[derive(Debug, Clone, PartialEq, Eq)]
2191pub struct SpecVersionRequest;
2192
2193/// Request for method starknet_syncing
2194#[derive(Debug, Clone, PartialEq, Eq)]
2195pub struct SyncingRequest;
2196
2197/// Request for method starknet_traceBlockTransactions
2198#[derive(Debug, Clone, PartialEq, Eq)]
2199pub struct TraceBlockTransactionsRequest {
2200    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2201    pub block_id: BlockId,
2202}
2203
2204/// Reference version of [TraceBlockTransactionsRequest].
2205#[derive(Debug, Clone, PartialEq, Eq)]
2206pub struct TraceBlockTransactionsRequestRef<'a> {
2207    pub block_id: &'a BlockId,
2208}
2209
2210/// Request for method starknet_traceTransaction
2211#[derive(Debug, Clone, PartialEq, Eq)]
2212pub struct TraceTransactionRequest {
2213    pub transaction_hash: Felt,
2214}
2215
2216/// Reference version of [TraceTransactionRequest].
2217#[derive(Debug, Clone, PartialEq, Eq)]
2218pub struct TraceTransactionRequestRef<'a> {
2219    pub transaction_hash: &'a Felt,
2220}
2221
2222impl Serialize for BroadcastedDeclareTransactionV1 {
2223    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2224        #[serde_as]
2225        #[derive(Serialize)]
2226        struct Tagged<'a> {
2227            pub r#type: &'a str,
2228            #[serde_as(as = "UfeHex")]
2229            pub sender_address: &'a Felt,
2230            #[serde_as(as = "UfeHex")]
2231            pub max_fee: &'a Felt,
2232            #[serde_as(as = "UfeHex")]
2233            pub version: &'a Felt,
2234            #[serde_as(as = "[UfeHex]")]
2235            pub signature: &'a [Felt],
2236            #[serde_as(as = "UfeHex")]
2237            pub nonce: &'a Felt,
2238            pub contract_class: &'a CompressedLegacyContractClass,
2239        }
2240
2241        let r#type = "DECLARE";
2242
2243        let version = &(if self.is_query {
2244            Felt::ONE + QUERY_VERSION_OFFSET
2245        } else {
2246            Felt::ONE
2247        });
2248
2249        let tagged = Tagged {
2250            r#type,
2251            sender_address: &self.sender_address,
2252            max_fee: &self.max_fee,
2253            version,
2254            signature: &self.signature,
2255            nonce: &self.nonce,
2256            contract_class: &self.contract_class,
2257        };
2258
2259        Tagged::serialize(&tagged, serializer)
2260    }
2261}
2262
2263impl<'de> Deserialize<'de> for BroadcastedDeclareTransactionV1 {
2264    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2265        #[serde_as]
2266        #[derive(Deserialize)]
2267        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2268        struct Tagged {
2269            pub r#type: Option<String>,
2270            #[serde_as(as = "UfeHex")]
2271            pub sender_address: Felt,
2272            #[serde_as(as = "UfeHex")]
2273            pub max_fee: Felt,
2274            #[serde_as(as = "UfeHex")]
2275            pub version: Felt,
2276            #[serde_as(as = "Vec<UfeHex>")]
2277            pub signature: Vec<Felt>,
2278            #[serde_as(as = "UfeHex")]
2279            pub nonce: Felt,
2280            pub contract_class: CompressedLegacyContractClass,
2281        }
2282
2283        let tagged = Tagged::deserialize(deserializer)?;
2284
2285        if let Some(tag_field) = &tagged.r#type {
2286            if tag_field != "DECLARE" {
2287                return Err(serde::de::Error::custom("invalid `type` value"));
2288            }
2289        }
2290
2291        let is_query = if tagged.version == Felt::ONE {
2292            false
2293        } else if tagged.version == Felt::ONE + QUERY_VERSION_OFFSET {
2294            true
2295        } else {
2296            return Err(serde::de::Error::custom("invalid `version` value"));
2297        };
2298
2299        Ok(Self {
2300            sender_address: tagged.sender_address,
2301            max_fee: tagged.max_fee,
2302            signature: tagged.signature,
2303            nonce: tagged.nonce,
2304            contract_class: OwnedPtr::new(tagged.contract_class),
2305            is_query,
2306        })
2307    }
2308}
2309
2310impl Serialize for BroadcastedDeclareTransactionV2 {
2311    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2312        #[serde_as]
2313        #[derive(Serialize)]
2314        struct Tagged<'a> {
2315            pub r#type: &'a str,
2316            #[serde_as(as = "UfeHex")]
2317            pub sender_address: &'a Felt,
2318            #[serde_as(as = "UfeHex")]
2319            pub compiled_class_hash: &'a Felt,
2320            #[serde_as(as = "UfeHex")]
2321            pub max_fee: &'a Felt,
2322            #[serde_as(as = "UfeHex")]
2323            pub version: &'a Felt,
2324            #[serde_as(as = "[UfeHex]")]
2325            pub signature: &'a [Felt],
2326            #[serde_as(as = "UfeHex")]
2327            pub nonce: &'a Felt,
2328            pub contract_class: &'a FlattenedSierraClass,
2329        }
2330
2331        let r#type = "DECLARE";
2332
2333        let version = &(if self.is_query {
2334            Felt::TWO + QUERY_VERSION_OFFSET
2335        } else {
2336            Felt::TWO
2337        });
2338
2339        let tagged = Tagged {
2340            r#type,
2341            sender_address: &self.sender_address,
2342            compiled_class_hash: &self.compiled_class_hash,
2343            max_fee: &self.max_fee,
2344            version,
2345            signature: &self.signature,
2346            nonce: &self.nonce,
2347            contract_class: &self.contract_class,
2348        };
2349
2350        Tagged::serialize(&tagged, serializer)
2351    }
2352}
2353
2354impl<'de> Deserialize<'de> for BroadcastedDeclareTransactionV2 {
2355    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2356        #[serde_as]
2357        #[derive(Deserialize)]
2358        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2359        struct Tagged {
2360            pub r#type: Option<String>,
2361            #[serde_as(as = "UfeHex")]
2362            pub sender_address: Felt,
2363            #[serde_as(as = "UfeHex")]
2364            pub compiled_class_hash: Felt,
2365            #[serde_as(as = "UfeHex")]
2366            pub max_fee: Felt,
2367            #[serde_as(as = "UfeHex")]
2368            pub version: Felt,
2369            #[serde_as(as = "Vec<UfeHex>")]
2370            pub signature: Vec<Felt>,
2371            #[serde_as(as = "UfeHex")]
2372            pub nonce: Felt,
2373            pub contract_class: FlattenedSierraClass,
2374        }
2375
2376        let tagged = Tagged::deserialize(deserializer)?;
2377
2378        if let Some(tag_field) = &tagged.r#type {
2379            if tag_field != "DECLARE" {
2380                return Err(serde::de::Error::custom("invalid `type` value"));
2381            }
2382        }
2383
2384        let is_query = if tagged.version == Felt::TWO {
2385            false
2386        } else if tagged.version == Felt::TWO + QUERY_VERSION_OFFSET {
2387            true
2388        } else {
2389            return Err(serde::de::Error::custom("invalid `version` value"));
2390        };
2391
2392        Ok(Self {
2393            sender_address: tagged.sender_address,
2394            compiled_class_hash: tagged.compiled_class_hash,
2395            max_fee: tagged.max_fee,
2396            signature: tagged.signature,
2397            nonce: tagged.nonce,
2398            contract_class: OwnedPtr::new(tagged.contract_class),
2399            is_query,
2400        })
2401    }
2402}
2403
2404impl Serialize for BroadcastedDeclareTransactionV3 {
2405    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2406        #[serde_as]
2407        #[derive(Serialize)]
2408        struct Tagged<'a> {
2409            pub r#type: &'a str,
2410            #[serde_as(as = "UfeHex")]
2411            pub sender_address: &'a Felt,
2412            #[serde_as(as = "UfeHex")]
2413            pub compiled_class_hash: &'a Felt,
2414            #[serde_as(as = "UfeHex")]
2415            pub version: &'a Felt,
2416            #[serde_as(as = "[UfeHex]")]
2417            pub signature: &'a [Felt],
2418            #[serde_as(as = "UfeHex")]
2419            pub nonce: &'a Felt,
2420            pub contract_class: &'a FlattenedSierraClass,
2421            pub resource_bounds: &'a ResourceBoundsMapping,
2422            #[serde_as(as = "NumAsHex")]
2423            pub tip: &'a u64,
2424            #[serde_as(as = "[UfeHex]")]
2425            pub paymaster_data: &'a [Felt],
2426            #[serde_as(as = "[UfeHex]")]
2427            pub account_deployment_data: &'a [Felt],
2428            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
2429            pub fee_data_availability_mode: &'a DataAvailabilityMode,
2430        }
2431
2432        let r#type = "DECLARE";
2433
2434        let version = &(if self.is_query {
2435            Felt::THREE + QUERY_VERSION_OFFSET
2436        } else {
2437            Felt::THREE
2438        });
2439
2440        let tagged = Tagged {
2441            r#type,
2442            sender_address: &self.sender_address,
2443            compiled_class_hash: &self.compiled_class_hash,
2444            version,
2445            signature: &self.signature,
2446            nonce: &self.nonce,
2447            contract_class: &self.contract_class,
2448            resource_bounds: &self.resource_bounds,
2449            tip: &self.tip,
2450            paymaster_data: &self.paymaster_data,
2451            account_deployment_data: &self.account_deployment_data,
2452            nonce_data_availability_mode: &self.nonce_data_availability_mode,
2453            fee_data_availability_mode: &self.fee_data_availability_mode,
2454        };
2455
2456        Tagged::serialize(&tagged, serializer)
2457    }
2458}
2459
2460impl<'de> Deserialize<'de> for BroadcastedDeclareTransactionV3 {
2461    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2462        #[serde_as]
2463        #[derive(Deserialize)]
2464        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2465        struct Tagged {
2466            pub r#type: Option<String>,
2467            #[serde_as(as = "UfeHex")]
2468            pub sender_address: Felt,
2469            #[serde_as(as = "UfeHex")]
2470            pub compiled_class_hash: Felt,
2471            #[serde_as(as = "UfeHex")]
2472            pub version: Felt,
2473            #[serde_as(as = "Vec<UfeHex>")]
2474            pub signature: Vec<Felt>,
2475            #[serde_as(as = "UfeHex")]
2476            pub nonce: Felt,
2477            pub contract_class: FlattenedSierraClass,
2478            pub resource_bounds: ResourceBoundsMapping,
2479            #[serde_as(as = "NumAsHex")]
2480            pub tip: u64,
2481            #[serde_as(as = "Vec<UfeHex>")]
2482            pub paymaster_data: Vec<Felt>,
2483            #[serde_as(as = "Vec<UfeHex>")]
2484            pub account_deployment_data: Vec<Felt>,
2485            pub nonce_data_availability_mode: DataAvailabilityMode,
2486            pub fee_data_availability_mode: DataAvailabilityMode,
2487        }
2488
2489        let tagged = Tagged::deserialize(deserializer)?;
2490
2491        if let Some(tag_field) = &tagged.r#type {
2492            if tag_field != "DECLARE" {
2493                return Err(serde::de::Error::custom("invalid `type` value"));
2494            }
2495        }
2496
2497        let is_query = if tagged.version == Felt::THREE {
2498            false
2499        } else if tagged.version == Felt::THREE + QUERY_VERSION_OFFSET {
2500            true
2501        } else {
2502            return Err(serde::de::Error::custom("invalid `version` value"));
2503        };
2504
2505        Ok(Self {
2506            sender_address: tagged.sender_address,
2507            compiled_class_hash: tagged.compiled_class_hash,
2508            signature: tagged.signature,
2509            nonce: tagged.nonce,
2510            contract_class: OwnedPtr::new(tagged.contract_class),
2511            resource_bounds: tagged.resource_bounds,
2512            tip: tagged.tip,
2513            paymaster_data: tagged.paymaster_data,
2514            account_deployment_data: tagged.account_deployment_data,
2515            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
2516            fee_data_availability_mode: tagged.fee_data_availability_mode,
2517            is_query,
2518        })
2519    }
2520}
2521
2522impl Serialize for BroadcastedDeployAccountTransactionV1 {
2523    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2524        #[serde_as]
2525        #[derive(Serialize)]
2526        struct Tagged<'a> {
2527            pub r#type: &'a str,
2528            #[serde_as(as = "UfeHex")]
2529            pub max_fee: &'a Felt,
2530            #[serde_as(as = "UfeHex")]
2531            pub version: &'a Felt,
2532            #[serde_as(as = "[UfeHex]")]
2533            pub signature: &'a [Felt],
2534            #[serde_as(as = "UfeHex")]
2535            pub nonce: &'a Felt,
2536            #[serde_as(as = "UfeHex")]
2537            pub contract_address_salt: &'a Felt,
2538            #[serde_as(as = "[UfeHex]")]
2539            pub constructor_calldata: &'a [Felt],
2540            #[serde_as(as = "UfeHex")]
2541            pub class_hash: &'a Felt,
2542        }
2543
2544        let r#type = "DEPLOY_ACCOUNT";
2545
2546        let version = &(if self.is_query {
2547            Felt::ONE + QUERY_VERSION_OFFSET
2548        } else {
2549            Felt::ONE
2550        });
2551
2552        let tagged = Tagged {
2553            r#type,
2554            max_fee: &self.max_fee,
2555            version,
2556            signature: &self.signature,
2557            nonce: &self.nonce,
2558            contract_address_salt: &self.contract_address_salt,
2559            constructor_calldata: &self.constructor_calldata,
2560            class_hash: &self.class_hash,
2561        };
2562
2563        Tagged::serialize(&tagged, serializer)
2564    }
2565}
2566
2567impl<'de> Deserialize<'de> for BroadcastedDeployAccountTransactionV1 {
2568    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2569        #[serde_as]
2570        #[derive(Deserialize)]
2571        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2572        struct Tagged {
2573            pub r#type: Option<String>,
2574            #[serde_as(as = "UfeHex")]
2575            pub max_fee: Felt,
2576            #[serde_as(as = "UfeHex")]
2577            pub version: Felt,
2578            #[serde_as(as = "Vec<UfeHex>")]
2579            pub signature: Vec<Felt>,
2580            #[serde_as(as = "UfeHex")]
2581            pub nonce: Felt,
2582            #[serde_as(as = "UfeHex")]
2583            pub contract_address_salt: Felt,
2584            #[serde_as(as = "Vec<UfeHex>")]
2585            pub constructor_calldata: Vec<Felt>,
2586            #[serde_as(as = "UfeHex")]
2587            pub class_hash: Felt,
2588        }
2589
2590        let tagged = Tagged::deserialize(deserializer)?;
2591
2592        if let Some(tag_field) = &tagged.r#type {
2593            if tag_field != "DEPLOY_ACCOUNT" {
2594                return Err(serde::de::Error::custom("invalid `type` value"));
2595            }
2596        }
2597
2598        let is_query = if tagged.version == Felt::ONE {
2599            false
2600        } else if tagged.version == Felt::ONE + QUERY_VERSION_OFFSET {
2601            true
2602        } else {
2603            return Err(serde::de::Error::custom("invalid `version` value"));
2604        };
2605
2606        Ok(Self {
2607            max_fee: tagged.max_fee,
2608            signature: tagged.signature,
2609            nonce: tagged.nonce,
2610            contract_address_salt: tagged.contract_address_salt,
2611            constructor_calldata: tagged.constructor_calldata,
2612            class_hash: tagged.class_hash,
2613            is_query,
2614        })
2615    }
2616}
2617
2618impl Serialize for BroadcastedDeployAccountTransactionV3 {
2619    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2620        #[serde_as]
2621        #[derive(Serialize)]
2622        struct Tagged<'a> {
2623            pub r#type: &'a str,
2624            #[serde_as(as = "UfeHex")]
2625            pub version: &'a Felt,
2626            #[serde_as(as = "[UfeHex]")]
2627            pub signature: &'a [Felt],
2628            #[serde_as(as = "UfeHex")]
2629            pub nonce: &'a Felt,
2630            #[serde_as(as = "UfeHex")]
2631            pub contract_address_salt: &'a Felt,
2632            #[serde_as(as = "[UfeHex]")]
2633            pub constructor_calldata: &'a [Felt],
2634            #[serde_as(as = "UfeHex")]
2635            pub class_hash: &'a Felt,
2636            pub resource_bounds: &'a ResourceBoundsMapping,
2637            #[serde_as(as = "NumAsHex")]
2638            pub tip: &'a u64,
2639            #[serde_as(as = "[UfeHex]")]
2640            pub paymaster_data: &'a [Felt],
2641            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
2642            pub fee_data_availability_mode: &'a DataAvailabilityMode,
2643        }
2644
2645        let r#type = "DEPLOY_ACCOUNT";
2646
2647        let version = &(if self.is_query {
2648            Felt::THREE + QUERY_VERSION_OFFSET
2649        } else {
2650            Felt::THREE
2651        });
2652
2653        let tagged = Tagged {
2654            r#type,
2655            version,
2656            signature: &self.signature,
2657            nonce: &self.nonce,
2658            contract_address_salt: &self.contract_address_salt,
2659            constructor_calldata: &self.constructor_calldata,
2660            class_hash: &self.class_hash,
2661            resource_bounds: &self.resource_bounds,
2662            tip: &self.tip,
2663            paymaster_data: &self.paymaster_data,
2664            nonce_data_availability_mode: &self.nonce_data_availability_mode,
2665            fee_data_availability_mode: &self.fee_data_availability_mode,
2666        };
2667
2668        Tagged::serialize(&tagged, serializer)
2669    }
2670}
2671
2672impl<'de> Deserialize<'de> for BroadcastedDeployAccountTransactionV3 {
2673    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2674        #[serde_as]
2675        #[derive(Deserialize)]
2676        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2677        struct Tagged {
2678            pub r#type: Option<String>,
2679            #[serde_as(as = "UfeHex")]
2680            pub version: Felt,
2681            #[serde_as(as = "Vec<UfeHex>")]
2682            pub signature: Vec<Felt>,
2683            #[serde_as(as = "UfeHex")]
2684            pub nonce: Felt,
2685            #[serde_as(as = "UfeHex")]
2686            pub contract_address_salt: Felt,
2687            #[serde_as(as = "Vec<UfeHex>")]
2688            pub constructor_calldata: Vec<Felt>,
2689            #[serde_as(as = "UfeHex")]
2690            pub class_hash: Felt,
2691            pub resource_bounds: ResourceBoundsMapping,
2692            #[serde_as(as = "NumAsHex")]
2693            pub tip: u64,
2694            #[serde_as(as = "Vec<UfeHex>")]
2695            pub paymaster_data: Vec<Felt>,
2696            pub nonce_data_availability_mode: DataAvailabilityMode,
2697            pub fee_data_availability_mode: DataAvailabilityMode,
2698        }
2699
2700        let tagged = Tagged::deserialize(deserializer)?;
2701
2702        if let Some(tag_field) = &tagged.r#type {
2703            if tag_field != "DEPLOY_ACCOUNT" {
2704                return Err(serde::de::Error::custom("invalid `type` value"));
2705            }
2706        }
2707
2708        let is_query = if tagged.version == Felt::THREE {
2709            false
2710        } else if tagged.version == Felt::THREE + QUERY_VERSION_OFFSET {
2711            true
2712        } else {
2713            return Err(serde::de::Error::custom("invalid `version` value"));
2714        };
2715
2716        Ok(Self {
2717            signature: tagged.signature,
2718            nonce: tagged.nonce,
2719            contract_address_salt: tagged.contract_address_salt,
2720            constructor_calldata: tagged.constructor_calldata,
2721            class_hash: tagged.class_hash,
2722            resource_bounds: tagged.resource_bounds,
2723            tip: tagged.tip,
2724            paymaster_data: tagged.paymaster_data,
2725            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
2726            fee_data_availability_mode: tagged.fee_data_availability_mode,
2727            is_query,
2728        })
2729    }
2730}
2731
2732impl Serialize for BroadcastedInvokeTransactionV1 {
2733    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2734        #[serde_as]
2735        #[derive(Serialize)]
2736        struct Tagged<'a> {
2737            pub r#type: &'a str,
2738            #[serde_as(as = "UfeHex")]
2739            pub sender_address: &'a Felt,
2740            #[serde_as(as = "[UfeHex]")]
2741            pub calldata: &'a [Felt],
2742            #[serde_as(as = "UfeHex")]
2743            pub max_fee: &'a Felt,
2744            #[serde_as(as = "UfeHex")]
2745            pub version: &'a Felt,
2746            #[serde_as(as = "[UfeHex]")]
2747            pub signature: &'a [Felt],
2748            #[serde_as(as = "UfeHex")]
2749            pub nonce: &'a Felt,
2750        }
2751
2752        let r#type = "INVOKE";
2753
2754        let version = &(if self.is_query {
2755            Felt::ONE + QUERY_VERSION_OFFSET
2756        } else {
2757            Felt::ONE
2758        });
2759
2760        let tagged = Tagged {
2761            r#type,
2762            sender_address: &self.sender_address,
2763            calldata: &self.calldata,
2764            max_fee: &self.max_fee,
2765            version,
2766            signature: &self.signature,
2767            nonce: &self.nonce,
2768        };
2769
2770        Tagged::serialize(&tagged, serializer)
2771    }
2772}
2773
2774impl<'de> Deserialize<'de> for BroadcastedInvokeTransactionV1 {
2775    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2776        #[serde_as]
2777        #[derive(Deserialize)]
2778        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2779        struct Tagged {
2780            pub r#type: Option<String>,
2781            #[serde_as(as = "UfeHex")]
2782            pub sender_address: Felt,
2783            #[serde_as(as = "Vec<UfeHex>")]
2784            pub calldata: Vec<Felt>,
2785            #[serde_as(as = "UfeHex")]
2786            pub max_fee: Felt,
2787            #[serde_as(as = "UfeHex")]
2788            pub version: Felt,
2789            #[serde_as(as = "Vec<UfeHex>")]
2790            pub signature: Vec<Felt>,
2791            #[serde_as(as = "UfeHex")]
2792            pub nonce: Felt,
2793        }
2794
2795        let tagged = Tagged::deserialize(deserializer)?;
2796
2797        if let Some(tag_field) = &tagged.r#type {
2798            if tag_field != "INVOKE" {
2799                return Err(serde::de::Error::custom("invalid `type` value"));
2800            }
2801        }
2802
2803        let is_query = if tagged.version == Felt::ONE {
2804            false
2805        } else if tagged.version == Felt::ONE + QUERY_VERSION_OFFSET {
2806            true
2807        } else {
2808            return Err(serde::de::Error::custom("invalid `version` value"));
2809        };
2810
2811        Ok(Self {
2812            sender_address: tagged.sender_address,
2813            calldata: tagged.calldata,
2814            max_fee: tagged.max_fee,
2815            signature: tagged.signature,
2816            nonce: tagged.nonce,
2817            is_query,
2818        })
2819    }
2820}
2821
2822impl Serialize for BroadcastedInvokeTransactionV3 {
2823    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2824        #[serde_as]
2825        #[derive(Serialize)]
2826        struct Tagged<'a> {
2827            pub r#type: &'a str,
2828            #[serde_as(as = "UfeHex")]
2829            pub sender_address: &'a Felt,
2830            #[serde_as(as = "[UfeHex]")]
2831            pub calldata: &'a [Felt],
2832            #[serde_as(as = "UfeHex")]
2833            pub version: &'a Felt,
2834            #[serde_as(as = "[UfeHex]")]
2835            pub signature: &'a [Felt],
2836            #[serde_as(as = "UfeHex")]
2837            pub nonce: &'a Felt,
2838            pub resource_bounds: &'a ResourceBoundsMapping,
2839            #[serde_as(as = "NumAsHex")]
2840            pub tip: &'a u64,
2841            #[serde_as(as = "[UfeHex]")]
2842            pub paymaster_data: &'a [Felt],
2843            #[serde_as(as = "[UfeHex]")]
2844            pub account_deployment_data: &'a [Felt],
2845            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
2846            pub fee_data_availability_mode: &'a DataAvailabilityMode,
2847        }
2848
2849        let r#type = "INVOKE";
2850
2851        let version = &(if self.is_query {
2852            Felt::THREE + QUERY_VERSION_OFFSET
2853        } else {
2854            Felt::THREE
2855        });
2856
2857        let tagged = Tagged {
2858            r#type,
2859            sender_address: &self.sender_address,
2860            calldata: &self.calldata,
2861            version,
2862            signature: &self.signature,
2863            nonce: &self.nonce,
2864            resource_bounds: &self.resource_bounds,
2865            tip: &self.tip,
2866            paymaster_data: &self.paymaster_data,
2867            account_deployment_data: &self.account_deployment_data,
2868            nonce_data_availability_mode: &self.nonce_data_availability_mode,
2869            fee_data_availability_mode: &self.fee_data_availability_mode,
2870        };
2871
2872        Tagged::serialize(&tagged, serializer)
2873    }
2874}
2875
2876impl<'de> Deserialize<'de> for BroadcastedInvokeTransactionV3 {
2877    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2878        #[serde_as]
2879        #[derive(Deserialize)]
2880        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2881        struct Tagged {
2882            pub r#type: Option<String>,
2883            #[serde_as(as = "UfeHex")]
2884            pub sender_address: Felt,
2885            #[serde_as(as = "Vec<UfeHex>")]
2886            pub calldata: Vec<Felt>,
2887            #[serde_as(as = "UfeHex")]
2888            pub version: Felt,
2889            #[serde_as(as = "Vec<UfeHex>")]
2890            pub signature: Vec<Felt>,
2891            #[serde_as(as = "UfeHex")]
2892            pub nonce: Felt,
2893            pub resource_bounds: ResourceBoundsMapping,
2894            #[serde_as(as = "NumAsHex")]
2895            pub tip: u64,
2896            #[serde_as(as = "Vec<UfeHex>")]
2897            pub paymaster_data: Vec<Felt>,
2898            #[serde_as(as = "Vec<UfeHex>")]
2899            pub account_deployment_data: Vec<Felt>,
2900            pub nonce_data_availability_mode: DataAvailabilityMode,
2901            pub fee_data_availability_mode: DataAvailabilityMode,
2902        }
2903
2904        let tagged = Tagged::deserialize(deserializer)?;
2905
2906        if let Some(tag_field) = &tagged.r#type {
2907            if tag_field != "INVOKE" {
2908                return Err(serde::de::Error::custom("invalid `type` value"));
2909            }
2910        }
2911
2912        let is_query = if tagged.version == Felt::THREE {
2913            false
2914        } else if tagged.version == Felt::THREE + QUERY_VERSION_OFFSET {
2915            true
2916        } else {
2917            return Err(serde::de::Error::custom("invalid `version` value"));
2918        };
2919
2920        Ok(Self {
2921            sender_address: tagged.sender_address,
2922            calldata: tagged.calldata,
2923            signature: tagged.signature,
2924            nonce: tagged.nonce,
2925            resource_bounds: tagged.resource_bounds,
2926            tip: tagged.tip,
2927            paymaster_data: tagged.paymaster_data,
2928            account_deployment_data: tagged.account_deployment_data,
2929            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
2930            fee_data_availability_mode: tagged.fee_data_availability_mode,
2931            is_query,
2932        })
2933    }
2934}
2935
2936impl Serialize for DeclareTransactionReceipt {
2937    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2938        #[serde_as]
2939        #[derive(Serialize)]
2940        struct Tagged<'a> {
2941            pub r#type: &'a str,
2942            #[serde_as(as = "UfeHex")]
2943            pub transaction_hash: &'a Felt,
2944            pub actual_fee: &'a FeePayment,
2945            pub finality_status: &'a TransactionFinalityStatus,
2946            pub messages_sent: &'a [MsgToL1],
2947            pub events: &'a [Event],
2948            pub execution_resources: &'a ExecutionResources,
2949            #[serde(flatten)]
2950            pub execution_result: &'a ExecutionResult,
2951        }
2952
2953        let r#type = "DECLARE";
2954
2955        let tagged = Tagged {
2956            r#type,
2957            transaction_hash: &self.transaction_hash,
2958            actual_fee: &self.actual_fee,
2959            finality_status: &self.finality_status,
2960            messages_sent: &self.messages_sent,
2961            events: &self.events,
2962            execution_resources: &self.execution_resources,
2963            execution_result: &self.execution_result,
2964        };
2965
2966        Tagged::serialize(&tagged, serializer)
2967    }
2968}
2969
2970impl<'de> Deserialize<'de> for DeclareTransactionReceipt {
2971    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2972        #[serde_as]
2973        #[derive(Deserialize)]
2974        struct Tagged {
2975            pub r#type: Option<String>,
2976            #[serde_as(as = "UfeHex")]
2977            pub transaction_hash: Felt,
2978            pub actual_fee: FeePayment,
2979            pub finality_status: TransactionFinalityStatus,
2980            pub messages_sent: Vec<MsgToL1>,
2981            pub events: Vec<Event>,
2982            pub execution_resources: ExecutionResources,
2983            #[serde(flatten)]
2984            pub execution_result: ExecutionResult,
2985        }
2986
2987        let tagged = Tagged::deserialize(deserializer)?;
2988
2989        if let Some(tag_field) = &tagged.r#type {
2990            if tag_field != "DECLARE" {
2991                return Err(serde::de::Error::custom("invalid `type` value"));
2992            }
2993        }
2994
2995        Ok(Self {
2996            transaction_hash: tagged.transaction_hash,
2997            actual_fee: tagged.actual_fee,
2998            finality_status: tagged.finality_status,
2999            messages_sent: tagged.messages_sent,
3000            events: tagged.events,
3001            execution_resources: tagged.execution_resources,
3002            execution_result: tagged.execution_result,
3003        })
3004    }
3005}
3006
3007impl Serialize for DeclareTransactionTrace {
3008    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3009        #[derive(Serialize)]
3010        struct Tagged<'a> {
3011            #[serde(skip_serializing_if = "Option::is_none")]
3012            pub validate_invocation: &'a Option<FunctionInvocation>,
3013            #[serde(skip_serializing_if = "Option::is_none")]
3014            pub fee_transfer_invocation: &'a Option<FunctionInvocation>,
3015            #[serde(skip_serializing_if = "Option::is_none")]
3016            pub state_diff: &'a Option<StateDiff>,
3017            pub execution_resources: &'a ExecutionResources,
3018            pub r#type: &'a str,
3019        }
3020
3021        let r#type = "DECLARE";
3022
3023        let tagged = Tagged {
3024            validate_invocation: &self.validate_invocation,
3025            fee_transfer_invocation: &self.fee_transfer_invocation,
3026            state_diff: &self.state_diff,
3027            execution_resources: &self.execution_resources,
3028            r#type,
3029        };
3030
3031        Tagged::serialize(&tagged, serializer)
3032    }
3033}
3034
3035impl<'de> Deserialize<'de> for DeclareTransactionTrace {
3036    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3037        #[derive(Deserialize)]
3038        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3039        struct Tagged {
3040            #[serde(skip_serializing_if = "Option::is_none")]
3041            pub validate_invocation: Option<FunctionInvocation>,
3042            #[serde(skip_serializing_if = "Option::is_none")]
3043            pub fee_transfer_invocation: Option<FunctionInvocation>,
3044            #[serde(skip_serializing_if = "Option::is_none")]
3045            pub state_diff: Option<StateDiff>,
3046            pub execution_resources: ExecutionResources,
3047            pub r#type: Option<String>,
3048        }
3049
3050        let tagged = Tagged::deserialize(deserializer)?;
3051
3052        if let Some(tag_field) = &tagged.r#type {
3053            if tag_field != "DECLARE" {
3054                return Err(serde::de::Error::custom("invalid `type` value"));
3055            }
3056        }
3057
3058        Ok(Self {
3059            validate_invocation: tagged.validate_invocation,
3060            fee_transfer_invocation: tagged.fee_transfer_invocation,
3061            state_diff: tagged.state_diff,
3062            execution_resources: tagged.execution_resources,
3063        })
3064    }
3065}
3066
3067impl Serialize for DeclareTransactionV0 {
3068    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3069        #[serde_as]
3070        #[derive(Serialize)]
3071        struct Tagged<'a> {
3072            #[serde_as(as = "UfeHex")]
3073            pub transaction_hash: &'a Felt,
3074            pub r#type: &'a str,
3075            #[serde_as(as = "UfeHex")]
3076            pub sender_address: &'a Felt,
3077            #[serde_as(as = "UfeHex")]
3078            pub max_fee: &'a Felt,
3079            #[serde_as(as = "NumAsHex")]
3080            pub version: &'a u64,
3081            #[serde_as(as = "[UfeHex]")]
3082            pub signature: &'a [Felt],
3083            #[serde_as(as = "UfeHex")]
3084            pub class_hash: &'a Felt,
3085        }
3086
3087        let r#type = "DECLARE";
3088
3089        let version = &0;
3090
3091        let tagged = Tagged {
3092            transaction_hash: &self.transaction_hash,
3093            r#type,
3094            sender_address: &self.sender_address,
3095            max_fee: &self.max_fee,
3096            version,
3097            signature: &self.signature,
3098            class_hash: &self.class_hash,
3099        };
3100
3101        Tagged::serialize(&tagged, serializer)
3102    }
3103}
3104
3105impl<'de> Deserialize<'de> for DeclareTransactionV0 {
3106    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3107        #[serde_as]
3108        #[derive(Deserialize)]
3109        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3110        struct Tagged {
3111            #[serde_as(as = "UfeHex")]
3112            pub transaction_hash: Felt,
3113            pub r#type: Option<String>,
3114            #[serde_as(as = "UfeHex")]
3115            pub sender_address: Felt,
3116            #[serde_as(as = "UfeHex")]
3117            pub max_fee: Felt,
3118            #[serde_as(as = "Option<NumAsHex>")]
3119            pub version: Option<u64>,
3120            #[serde_as(as = "Vec<UfeHex>")]
3121            pub signature: Vec<Felt>,
3122            #[serde_as(as = "UfeHex")]
3123            pub class_hash: Felt,
3124        }
3125
3126        let tagged = Tagged::deserialize(deserializer)?;
3127
3128        if let Some(tag_field) = &tagged.r#type {
3129            if tag_field != "DECLARE" {
3130                return Err(serde::de::Error::custom("invalid `type` value"));
3131            }
3132        }
3133
3134        if let Some(tag_field) = &tagged.version {
3135            if tag_field != &0 {
3136                return Err(serde::de::Error::custom("invalid `version` value"));
3137            }
3138        }
3139
3140        Ok(Self {
3141            transaction_hash: tagged.transaction_hash,
3142            sender_address: tagged.sender_address,
3143            max_fee: tagged.max_fee,
3144            signature: tagged.signature,
3145            class_hash: tagged.class_hash,
3146        })
3147    }
3148}
3149
3150impl Serialize for DeclareTransactionV1 {
3151    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3152        #[serde_as]
3153        #[derive(Serialize)]
3154        struct Tagged<'a> {
3155            #[serde_as(as = "UfeHex")]
3156            pub transaction_hash: &'a Felt,
3157            pub r#type: &'a str,
3158            #[serde_as(as = "UfeHex")]
3159            pub sender_address: &'a Felt,
3160            #[serde_as(as = "UfeHex")]
3161            pub max_fee: &'a Felt,
3162            #[serde_as(as = "NumAsHex")]
3163            pub version: &'a u64,
3164            #[serde_as(as = "[UfeHex]")]
3165            pub signature: &'a [Felt],
3166            #[serde_as(as = "UfeHex")]
3167            pub nonce: &'a Felt,
3168            #[serde_as(as = "UfeHex")]
3169            pub class_hash: &'a Felt,
3170        }
3171
3172        let r#type = "DECLARE";
3173
3174        let version = &1;
3175
3176        let tagged = Tagged {
3177            transaction_hash: &self.transaction_hash,
3178            r#type,
3179            sender_address: &self.sender_address,
3180            max_fee: &self.max_fee,
3181            version,
3182            signature: &self.signature,
3183            nonce: &self.nonce,
3184            class_hash: &self.class_hash,
3185        };
3186
3187        Tagged::serialize(&tagged, serializer)
3188    }
3189}
3190
3191impl<'de> Deserialize<'de> for DeclareTransactionV1 {
3192    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3193        #[serde_as]
3194        #[derive(Deserialize)]
3195        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3196        struct Tagged {
3197            #[serde_as(as = "UfeHex")]
3198            pub transaction_hash: Felt,
3199            pub r#type: Option<String>,
3200            #[serde_as(as = "UfeHex")]
3201            pub sender_address: Felt,
3202            #[serde_as(as = "UfeHex")]
3203            pub max_fee: Felt,
3204            #[serde_as(as = "Option<NumAsHex>")]
3205            pub version: Option<u64>,
3206            #[serde_as(as = "Vec<UfeHex>")]
3207            pub signature: Vec<Felt>,
3208            #[serde_as(as = "UfeHex")]
3209            pub nonce: Felt,
3210            #[serde_as(as = "UfeHex")]
3211            pub class_hash: Felt,
3212        }
3213
3214        let tagged = Tagged::deserialize(deserializer)?;
3215
3216        if let Some(tag_field) = &tagged.r#type {
3217            if tag_field != "DECLARE" {
3218                return Err(serde::de::Error::custom("invalid `type` value"));
3219            }
3220        }
3221
3222        if let Some(tag_field) = &tagged.version {
3223            if tag_field != &1 {
3224                return Err(serde::de::Error::custom("invalid `version` value"));
3225            }
3226        }
3227
3228        Ok(Self {
3229            transaction_hash: tagged.transaction_hash,
3230            sender_address: tagged.sender_address,
3231            max_fee: tagged.max_fee,
3232            signature: tagged.signature,
3233            nonce: tagged.nonce,
3234            class_hash: tagged.class_hash,
3235        })
3236    }
3237}
3238
3239impl Serialize for DeclareTransactionV2 {
3240    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3241        #[serde_as]
3242        #[derive(Serialize)]
3243        struct Tagged<'a> {
3244            #[serde_as(as = "UfeHex")]
3245            pub transaction_hash: &'a Felt,
3246            pub r#type: &'a str,
3247            #[serde_as(as = "UfeHex")]
3248            pub sender_address: &'a Felt,
3249            #[serde_as(as = "UfeHex")]
3250            pub compiled_class_hash: &'a Felt,
3251            #[serde_as(as = "UfeHex")]
3252            pub max_fee: &'a Felt,
3253            #[serde_as(as = "NumAsHex")]
3254            pub version: &'a u64,
3255            #[serde_as(as = "[UfeHex]")]
3256            pub signature: &'a [Felt],
3257            #[serde_as(as = "UfeHex")]
3258            pub nonce: &'a Felt,
3259            #[serde_as(as = "UfeHex")]
3260            pub class_hash: &'a Felt,
3261        }
3262
3263        let r#type = "DECLARE";
3264
3265        let version = &2;
3266
3267        let tagged = Tagged {
3268            transaction_hash: &self.transaction_hash,
3269            r#type,
3270            sender_address: &self.sender_address,
3271            compiled_class_hash: &self.compiled_class_hash,
3272            max_fee: &self.max_fee,
3273            version,
3274            signature: &self.signature,
3275            nonce: &self.nonce,
3276            class_hash: &self.class_hash,
3277        };
3278
3279        Tagged::serialize(&tagged, serializer)
3280    }
3281}
3282
3283impl<'de> Deserialize<'de> for DeclareTransactionV2 {
3284    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3285        #[serde_as]
3286        #[derive(Deserialize)]
3287        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3288        struct Tagged {
3289            #[serde_as(as = "UfeHex")]
3290            pub transaction_hash: Felt,
3291            pub r#type: Option<String>,
3292            #[serde_as(as = "UfeHex")]
3293            pub sender_address: Felt,
3294            #[serde_as(as = "UfeHex")]
3295            pub compiled_class_hash: Felt,
3296            #[serde_as(as = "UfeHex")]
3297            pub max_fee: Felt,
3298            #[serde_as(as = "Option<NumAsHex>")]
3299            pub version: Option<u64>,
3300            #[serde_as(as = "Vec<UfeHex>")]
3301            pub signature: Vec<Felt>,
3302            #[serde_as(as = "UfeHex")]
3303            pub nonce: Felt,
3304            #[serde_as(as = "UfeHex")]
3305            pub class_hash: Felt,
3306        }
3307
3308        let tagged = Tagged::deserialize(deserializer)?;
3309
3310        if let Some(tag_field) = &tagged.r#type {
3311            if tag_field != "DECLARE" {
3312                return Err(serde::de::Error::custom("invalid `type` value"));
3313            }
3314        }
3315
3316        if let Some(tag_field) = &tagged.version {
3317            if tag_field != &2 {
3318                return Err(serde::de::Error::custom("invalid `version` value"));
3319            }
3320        }
3321
3322        Ok(Self {
3323            transaction_hash: tagged.transaction_hash,
3324            sender_address: tagged.sender_address,
3325            compiled_class_hash: tagged.compiled_class_hash,
3326            max_fee: tagged.max_fee,
3327            signature: tagged.signature,
3328            nonce: tagged.nonce,
3329            class_hash: tagged.class_hash,
3330        })
3331    }
3332}
3333
3334impl Serialize for DeclareTransactionV3 {
3335    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3336        #[serde_as]
3337        #[derive(Serialize)]
3338        struct Tagged<'a> {
3339            #[serde_as(as = "UfeHex")]
3340            pub transaction_hash: &'a Felt,
3341            pub r#type: &'a str,
3342            #[serde_as(as = "UfeHex")]
3343            pub sender_address: &'a Felt,
3344            #[serde_as(as = "UfeHex")]
3345            pub compiled_class_hash: &'a Felt,
3346            #[serde_as(as = "NumAsHex")]
3347            pub version: &'a u64,
3348            #[serde_as(as = "[UfeHex]")]
3349            pub signature: &'a [Felt],
3350            #[serde_as(as = "UfeHex")]
3351            pub nonce: &'a Felt,
3352            #[serde_as(as = "UfeHex")]
3353            pub class_hash: &'a Felt,
3354            pub resource_bounds: &'a ResourceBoundsMapping,
3355            #[serde_as(as = "NumAsHex")]
3356            pub tip: &'a u64,
3357            #[serde_as(as = "[UfeHex]")]
3358            pub paymaster_data: &'a [Felt],
3359            #[serde_as(as = "[UfeHex]")]
3360            pub account_deployment_data: &'a [Felt],
3361            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
3362            pub fee_data_availability_mode: &'a DataAvailabilityMode,
3363        }
3364
3365        let r#type = "DECLARE";
3366
3367        let version = &3;
3368
3369        let tagged = Tagged {
3370            transaction_hash: &self.transaction_hash,
3371            r#type,
3372            sender_address: &self.sender_address,
3373            compiled_class_hash: &self.compiled_class_hash,
3374            version,
3375            signature: &self.signature,
3376            nonce: &self.nonce,
3377            class_hash: &self.class_hash,
3378            resource_bounds: &self.resource_bounds,
3379            tip: &self.tip,
3380            paymaster_data: &self.paymaster_data,
3381            account_deployment_data: &self.account_deployment_data,
3382            nonce_data_availability_mode: &self.nonce_data_availability_mode,
3383            fee_data_availability_mode: &self.fee_data_availability_mode,
3384        };
3385
3386        Tagged::serialize(&tagged, serializer)
3387    }
3388}
3389
3390impl<'de> Deserialize<'de> for DeclareTransactionV3 {
3391    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3392        #[serde_as]
3393        #[derive(Deserialize)]
3394        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3395        struct Tagged {
3396            #[serde_as(as = "UfeHex")]
3397            pub transaction_hash: Felt,
3398            pub r#type: Option<String>,
3399            #[serde_as(as = "UfeHex")]
3400            pub sender_address: Felt,
3401            #[serde_as(as = "UfeHex")]
3402            pub compiled_class_hash: Felt,
3403            #[serde_as(as = "Option<NumAsHex>")]
3404            pub version: Option<u64>,
3405            #[serde_as(as = "Vec<UfeHex>")]
3406            pub signature: Vec<Felt>,
3407            #[serde_as(as = "UfeHex")]
3408            pub nonce: Felt,
3409            #[serde_as(as = "UfeHex")]
3410            pub class_hash: Felt,
3411            pub resource_bounds: ResourceBoundsMapping,
3412            #[serde_as(as = "NumAsHex")]
3413            pub tip: u64,
3414            #[serde_as(as = "Vec<UfeHex>")]
3415            pub paymaster_data: Vec<Felt>,
3416            #[serde_as(as = "Vec<UfeHex>")]
3417            pub account_deployment_data: Vec<Felt>,
3418            pub nonce_data_availability_mode: DataAvailabilityMode,
3419            pub fee_data_availability_mode: DataAvailabilityMode,
3420        }
3421
3422        let tagged = Tagged::deserialize(deserializer)?;
3423
3424        if let Some(tag_field) = &tagged.r#type {
3425            if tag_field != "DECLARE" {
3426                return Err(serde::de::Error::custom("invalid `type` value"));
3427            }
3428        }
3429
3430        if let Some(tag_field) = &tagged.version {
3431            if tag_field != &3 {
3432                return Err(serde::de::Error::custom("invalid `version` value"));
3433            }
3434        }
3435
3436        Ok(Self {
3437            transaction_hash: tagged.transaction_hash,
3438            sender_address: tagged.sender_address,
3439            compiled_class_hash: tagged.compiled_class_hash,
3440            signature: tagged.signature,
3441            nonce: tagged.nonce,
3442            class_hash: tagged.class_hash,
3443            resource_bounds: tagged.resource_bounds,
3444            tip: tagged.tip,
3445            paymaster_data: tagged.paymaster_data,
3446            account_deployment_data: tagged.account_deployment_data,
3447            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
3448            fee_data_availability_mode: tagged.fee_data_availability_mode,
3449        })
3450    }
3451}
3452
3453impl Serialize for DeployAccountTransactionReceipt {
3454    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3455        #[serde_as]
3456        #[derive(Serialize)]
3457        struct Tagged<'a> {
3458            #[serde_as(as = "UfeHex")]
3459            pub transaction_hash: &'a Felt,
3460            pub actual_fee: &'a FeePayment,
3461            pub finality_status: &'a TransactionFinalityStatus,
3462            pub messages_sent: &'a [MsgToL1],
3463            pub events: &'a [Event],
3464            pub execution_resources: &'a ExecutionResources,
3465            #[serde(flatten)]
3466            pub execution_result: &'a ExecutionResult,
3467            pub r#type: &'a str,
3468            #[serde_as(as = "UfeHex")]
3469            pub contract_address: &'a Felt,
3470        }
3471
3472        let r#type = "DEPLOY_ACCOUNT";
3473
3474        let tagged = Tagged {
3475            transaction_hash: &self.transaction_hash,
3476            actual_fee: &self.actual_fee,
3477            finality_status: &self.finality_status,
3478            messages_sent: &self.messages_sent,
3479            events: &self.events,
3480            execution_resources: &self.execution_resources,
3481            execution_result: &self.execution_result,
3482            r#type,
3483            contract_address: &self.contract_address,
3484        };
3485
3486        Tagged::serialize(&tagged, serializer)
3487    }
3488}
3489
3490impl<'de> Deserialize<'de> for DeployAccountTransactionReceipt {
3491    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3492        #[serde_as]
3493        #[derive(Deserialize)]
3494        struct Tagged {
3495            #[serde_as(as = "UfeHex")]
3496            pub transaction_hash: Felt,
3497            pub actual_fee: FeePayment,
3498            pub finality_status: TransactionFinalityStatus,
3499            pub messages_sent: Vec<MsgToL1>,
3500            pub events: Vec<Event>,
3501            pub execution_resources: ExecutionResources,
3502            #[serde(flatten)]
3503            pub execution_result: ExecutionResult,
3504            pub r#type: Option<String>,
3505            #[serde_as(as = "UfeHex")]
3506            pub contract_address: Felt,
3507        }
3508
3509        let tagged = Tagged::deserialize(deserializer)?;
3510
3511        if let Some(tag_field) = &tagged.r#type {
3512            if tag_field != "DEPLOY_ACCOUNT" {
3513                return Err(serde::de::Error::custom("invalid `type` value"));
3514            }
3515        }
3516
3517        Ok(Self {
3518            transaction_hash: tagged.transaction_hash,
3519            actual_fee: tagged.actual_fee,
3520            finality_status: tagged.finality_status,
3521            messages_sent: tagged.messages_sent,
3522            events: tagged.events,
3523            execution_resources: tagged.execution_resources,
3524            execution_result: tagged.execution_result,
3525            contract_address: tagged.contract_address,
3526        })
3527    }
3528}
3529
3530impl Serialize for DeployAccountTransactionTrace {
3531    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3532        #[derive(Serialize)]
3533        struct Tagged<'a> {
3534            #[serde(skip_serializing_if = "Option::is_none")]
3535            pub validate_invocation: &'a Option<FunctionInvocation>,
3536            pub constructor_invocation: &'a FunctionInvocation,
3537            #[serde(skip_serializing_if = "Option::is_none")]
3538            pub fee_transfer_invocation: &'a Option<FunctionInvocation>,
3539            #[serde(skip_serializing_if = "Option::is_none")]
3540            pub state_diff: &'a Option<StateDiff>,
3541            pub execution_resources: &'a ExecutionResources,
3542            pub r#type: &'a str,
3543        }
3544
3545        let r#type = "DEPLOY_ACCOUNT";
3546
3547        let tagged = Tagged {
3548            validate_invocation: &self.validate_invocation,
3549            constructor_invocation: &self.constructor_invocation,
3550            fee_transfer_invocation: &self.fee_transfer_invocation,
3551            state_diff: &self.state_diff,
3552            execution_resources: &self.execution_resources,
3553            r#type,
3554        };
3555
3556        Tagged::serialize(&tagged, serializer)
3557    }
3558}
3559
3560impl<'de> Deserialize<'de> for DeployAccountTransactionTrace {
3561    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3562        #[derive(Deserialize)]
3563        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3564        struct Tagged {
3565            #[serde(skip_serializing_if = "Option::is_none")]
3566            pub validate_invocation: Option<FunctionInvocation>,
3567            pub constructor_invocation: FunctionInvocation,
3568            #[serde(skip_serializing_if = "Option::is_none")]
3569            pub fee_transfer_invocation: Option<FunctionInvocation>,
3570            #[serde(skip_serializing_if = "Option::is_none")]
3571            pub state_diff: Option<StateDiff>,
3572            pub execution_resources: ExecutionResources,
3573            pub r#type: Option<String>,
3574        }
3575
3576        let tagged = Tagged::deserialize(deserializer)?;
3577
3578        if let Some(tag_field) = &tagged.r#type {
3579            if tag_field != "DEPLOY_ACCOUNT" {
3580                return Err(serde::de::Error::custom("invalid `type` value"));
3581            }
3582        }
3583
3584        Ok(Self {
3585            validate_invocation: tagged.validate_invocation,
3586            constructor_invocation: tagged.constructor_invocation,
3587            fee_transfer_invocation: tagged.fee_transfer_invocation,
3588            state_diff: tagged.state_diff,
3589            execution_resources: tagged.execution_resources,
3590        })
3591    }
3592}
3593
3594impl Serialize for DeployAccountTransactionV1 {
3595    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3596        #[serde_as]
3597        #[derive(Serialize)]
3598        struct Tagged<'a> {
3599            #[serde_as(as = "UfeHex")]
3600            pub transaction_hash: &'a Felt,
3601            pub r#type: &'a str,
3602            #[serde_as(as = "UfeHex")]
3603            pub max_fee: &'a Felt,
3604            #[serde_as(as = "NumAsHex")]
3605            pub version: &'a u64,
3606            #[serde_as(as = "[UfeHex]")]
3607            pub signature: &'a [Felt],
3608            #[serde_as(as = "UfeHex")]
3609            pub nonce: &'a Felt,
3610            #[serde_as(as = "UfeHex")]
3611            pub contract_address_salt: &'a Felt,
3612            #[serde_as(as = "[UfeHex]")]
3613            pub constructor_calldata: &'a [Felt],
3614            #[serde_as(as = "UfeHex")]
3615            pub class_hash: &'a Felt,
3616        }
3617
3618        let r#type = "DEPLOY_ACCOUNT";
3619
3620        let version = &1;
3621
3622        let tagged = Tagged {
3623            transaction_hash: &self.transaction_hash,
3624            r#type,
3625            max_fee: &self.max_fee,
3626            version,
3627            signature: &self.signature,
3628            nonce: &self.nonce,
3629            contract_address_salt: &self.contract_address_salt,
3630            constructor_calldata: &self.constructor_calldata,
3631            class_hash: &self.class_hash,
3632        };
3633
3634        Tagged::serialize(&tagged, serializer)
3635    }
3636}
3637
3638impl<'de> Deserialize<'de> for DeployAccountTransactionV1 {
3639    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3640        #[serde_as]
3641        #[derive(Deserialize)]
3642        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3643        struct Tagged {
3644            #[serde_as(as = "UfeHex")]
3645            pub transaction_hash: Felt,
3646            pub r#type: Option<String>,
3647            #[serde_as(as = "UfeHex")]
3648            pub max_fee: Felt,
3649            #[serde_as(as = "Option<NumAsHex>")]
3650            pub version: Option<u64>,
3651            #[serde_as(as = "Vec<UfeHex>")]
3652            pub signature: Vec<Felt>,
3653            #[serde_as(as = "UfeHex")]
3654            pub nonce: Felt,
3655            #[serde_as(as = "UfeHex")]
3656            pub contract_address_salt: Felt,
3657            #[serde_as(as = "Vec<UfeHex>")]
3658            pub constructor_calldata: Vec<Felt>,
3659            #[serde_as(as = "UfeHex")]
3660            pub class_hash: Felt,
3661        }
3662
3663        let tagged = Tagged::deserialize(deserializer)?;
3664
3665        if let Some(tag_field) = &tagged.r#type {
3666            if tag_field != "DEPLOY_ACCOUNT" {
3667                return Err(serde::de::Error::custom("invalid `type` value"));
3668            }
3669        }
3670
3671        if let Some(tag_field) = &tagged.version {
3672            if tag_field != &1 {
3673                return Err(serde::de::Error::custom("invalid `version` value"));
3674            }
3675        }
3676
3677        Ok(Self {
3678            transaction_hash: tagged.transaction_hash,
3679            max_fee: tagged.max_fee,
3680            signature: tagged.signature,
3681            nonce: tagged.nonce,
3682            contract_address_salt: tagged.contract_address_salt,
3683            constructor_calldata: tagged.constructor_calldata,
3684            class_hash: tagged.class_hash,
3685        })
3686    }
3687}
3688
3689impl Serialize for DeployAccountTransactionV3 {
3690    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3691        #[serde_as]
3692        #[derive(Serialize)]
3693        struct Tagged<'a> {
3694            #[serde_as(as = "UfeHex")]
3695            pub transaction_hash: &'a Felt,
3696            pub r#type: &'a str,
3697            #[serde_as(as = "NumAsHex")]
3698            pub version: &'a u64,
3699            #[serde_as(as = "[UfeHex]")]
3700            pub signature: &'a [Felt],
3701            #[serde_as(as = "UfeHex")]
3702            pub nonce: &'a Felt,
3703            #[serde_as(as = "UfeHex")]
3704            pub contract_address_salt: &'a Felt,
3705            #[serde_as(as = "[UfeHex]")]
3706            pub constructor_calldata: &'a [Felt],
3707            #[serde_as(as = "UfeHex")]
3708            pub class_hash: &'a Felt,
3709            pub resource_bounds: &'a ResourceBoundsMapping,
3710            #[serde_as(as = "NumAsHex")]
3711            pub tip: &'a u64,
3712            #[serde_as(as = "[UfeHex]")]
3713            pub paymaster_data: &'a [Felt],
3714            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
3715            pub fee_data_availability_mode: &'a DataAvailabilityMode,
3716        }
3717
3718        let r#type = "DEPLOY_ACCOUNT";
3719
3720        let version = &3;
3721
3722        let tagged = Tagged {
3723            transaction_hash: &self.transaction_hash,
3724            r#type,
3725            version,
3726            signature: &self.signature,
3727            nonce: &self.nonce,
3728            contract_address_salt: &self.contract_address_salt,
3729            constructor_calldata: &self.constructor_calldata,
3730            class_hash: &self.class_hash,
3731            resource_bounds: &self.resource_bounds,
3732            tip: &self.tip,
3733            paymaster_data: &self.paymaster_data,
3734            nonce_data_availability_mode: &self.nonce_data_availability_mode,
3735            fee_data_availability_mode: &self.fee_data_availability_mode,
3736        };
3737
3738        Tagged::serialize(&tagged, serializer)
3739    }
3740}
3741
3742impl<'de> Deserialize<'de> for DeployAccountTransactionV3 {
3743    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3744        #[serde_as]
3745        #[derive(Deserialize)]
3746        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3747        struct Tagged {
3748            #[serde_as(as = "UfeHex")]
3749            pub transaction_hash: Felt,
3750            pub r#type: Option<String>,
3751            #[serde_as(as = "Option<NumAsHex>")]
3752            pub version: Option<u64>,
3753            #[serde_as(as = "Vec<UfeHex>")]
3754            pub signature: Vec<Felt>,
3755            #[serde_as(as = "UfeHex")]
3756            pub nonce: Felt,
3757            #[serde_as(as = "UfeHex")]
3758            pub contract_address_salt: Felt,
3759            #[serde_as(as = "Vec<UfeHex>")]
3760            pub constructor_calldata: Vec<Felt>,
3761            #[serde_as(as = "UfeHex")]
3762            pub class_hash: Felt,
3763            pub resource_bounds: ResourceBoundsMapping,
3764            #[serde_as(as = "NumAsHex")]
3765            pub tip: u64,
3766            #[serde_as(as = "Vec<UfeHex>")]
3767            pub paymaster_data: Vec<Felt>,
3768            pub nonce_data_availability_mode: DataAvailabilityMode,
3769            pub fee_data_availability_mode: DataAvailabilityMode,
3770        }
3771
3772        let tagged = Tagged::deserialize(deserializer)?;
3773
3774        if let Some(tag_field) = &tagged.r#type {
3775            if tag_field != "DEPLOY_ACCOUNT" {
3776                return Err(serde::de::Error::custom("invalid `type` value"));
3777            }
3778        }
3779
3780        if let Some(tag_field) = &tagged.version {
3781            if tag_field != &3 {
3782                return Err(serde::de::Error::custom("invalid `version` value"));
3783            }
3784        }
3785
3786        Ok(Self {
3787            transaction_hash: tagged.transaction_hash,
3788            signature: tagged.signature,
3789            nonce: tagged.nonce,
3790            contract_address_salt: tagged.contract_address_salt,
3791            constructor_calldata: tagged.constructor_calldata,
3792            class_hash: tagged.class_hash,
3793            resource_bounds: tagged.resource_bounds,
3794            tip: tagged.tip,
3795            paymaster_data: tagged.paymaster_data,
3796            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
3797            fee_data_availability_mode: tagged.fee_data_availability_mode,
3798        })
3799    }
3800}
3801
3802impl Serialize for DeployTransaction {
3803    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3804        #[serde_as]
3805        #[derive(Serialize)]
3806        struct Tagged<'a> {
3807            #[serde_as(as = "UfeHex")]
3808            pub transaction_hash: &'a Felt,
3809            #[serde_as(as = "UfeHex")]
3810            pub version: &'a Felt,
3811            pub r#type: &'a str,
3812            #[serde_as(as = "UfeHex")]
3813            pub contract_address_salt: &'a Felt,
3814            #[serde_as(as = "[UfeHex]")]
3815            pub constructor_calldata: &'a [Felt],
3816            #[serde_as(as = "UfeHex")]
3817            pub class_hash: &'a Felt,
3818        }
3819
3820        let r#type = "DEPLOY";
3821
3822        let tagged = Tagged {
3823            transaction_hash: &self.transaction_hash,
3824            version: &self.version,
3825            r#type,
3826            contract_address_salt: &self.contract_address_salt,
3827            constructor_calldata: &self.constructor_calldata,
3828            class_hash: &self.class_hash,
3829        };
3830
3831        Tagged::serialize(&tagged, serializer)
3832    }
3833}
3834
3835impl<'de> Deserialize<'de> for DeployTransaction {
3836    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3837        #[serde_as]
3838        #[derive(Deserialize)]
3839        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3840        struct Tagged {
3841            #[serde_as(as = "UfeHex")]
3842            pub transaction_hash: Felt,
3843            #[serde_as(as = "UfeHex")]
3844            pub version: Felt,
3845            pub r#type: Option<String>,
3846            #[serde_as(as = "UfeHex")]
3847            pub contract_address_salt: Felt,
3848            #[serde_as(as = "Vec<UfeHex>")]
3849            pub constructor_calldata: Vec<Felt>,
3850            #[serde_as(as = "UfeHex")]
3851            pub class_hash: Felt,
3852        }
3853
3854        let tagged = Tagged::deserialize(deserializer)?;
3855
3856        if let Some(tag_field) = &tagged.r#type {
3857            if tag_field != "DEPLOY" {
3858                return Err(serde::de::Error::custom("invalid `type` value"));
3859            }
3860        }
3861
3862        Ok(Self {
3863            transaction_hash: tagged.transaction_hash,
3864            version: tagged.version,
3865            contract_address_salt: tagged.contract_address_salt,
3866            constructor_calldata: tagged.constructor_calldata,
3867            class_hash: tagged.class_hash,
3868        })
3869    }
3870}
3871
3872impl Serialize for DeployTransactionReceipt {
3873    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3874        #[serde_as]
3875        #[derive(Serialize)]
3876        struct Tagged<'a> {
3877            #[serde_as(as = "UfeHex")]
3878            pub transaction_hash: &'a Felt,
3879            pub actual_fee: &'a FeePayment,
3880            pub finality_status: &'a TransactionFinalityStatus,
3881            pub messages_sent: &'a [MsgToL1],
3882            pub events: &'a [Event],
3883            pub execution_resources: &'a ExecutionResources,
3884            #[serde(flatten)]
3885            pub execution_result: &'a ExecutionResult,
3886            pub r#type: &'a str,
3887            #[serde_as(as = "UfeHex")]
3888            pub contract_address: &'a Felt,
3889        }
3890
3891        let r#type = "DEPLOY";
3892
3893        let tagged = Tagged {
3894            transaction_hash: &self.transaction_hash,
3895            actual_fee: &self.actual_fee,
3896            finality_status: &self.finality_status,
3897            messages_sent: &self.messages_sent,
3898            events: &self.events,
3899            execution_resources: &self.execution_resources,
3900            execution_result: &self.execution_result,
3901            r#type,
3902            contract_address: &self.contract_address,
3903        };
3904
3905        Tagged::serialize(&tagged, serializer)
3906    }
3907}
3908
3909impl<'de> Deserialize<'de> for DeployTransactionReceipt {
3910    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3911        #[serde_as]
3912        #[derive(Deserialize)]
3913        struct Tagged {
3914            #[serde_as(as = "UfeHex")]
3915            pub transaction_hash: Felt,
3916            pub actual_fee: FeePayment,
3917            pub finality_status: TransactionFinalityStatus,
3918            pub messages_sent: Vec<MsgToL1>,
3919            pub events: Vec<Event>,
3920            pub execution_resources: ExecutionResources,
3921            #[serde(flatten)]
3922            pub execution_result: ExecutionResult,
3923            pub r#type: Option<String>,
3924            #[serde_as(as = "UfeHex")]
3925            pub contract_address: Felt,
3926        }
3927
3928        let tagged = Tagged::deserialize(deserializer)?;
3929
3930        if let Some(tag_field) = &tagged.r#type {
3931            if tag_field != "DEPLOY" {
3932                return Err(serde::de::Error::custom("invalid `type` value"));
3933            }
3934        }
3935
3936        Ok(Self {
3937            transaction_hash: tagged.transaction_hash,
3938            actual_fee: tagged.actual_fee,
3939            finality_status: tagged.finality_status,
3940            messages_sent: tagged.messages_sent,
3941            events: tagged.events,
3942            execution_resources: tagged.execution_resources,
3943            execution_result: tagged.execution_result,
3944            contract_address: tagged.contract_address,
3945        })
3946    }
3947}
3948
3949impl Serialize for InvokeTransactionReceipt {
3950    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3951        #[serde_as]
3952        #[derive(Serialize)]
3953        struct Tagged<'a> {
3954            pub r#type: &'a str,
3955            #[serde_as(as = "UfeHex")]
3956            pub transaction_hash: &'a Felt,
3957            pub actual_fee: &'a FeePayment,
3958            pub finality_status: &'a TransactionFinalityStatus,
3959            pub messages_sent: &'a [MsgToL1],
3960            pub events: &'a [Event],
3961            pub execution_resources: &'a ExecutionResources,
3962            #[serde(flatten)]
3963            pub execution_result: &'a ExecutionResult,
3964        }
3965
3966        let r#type = "INVOKE";
3967
3968        let tagged = Tagged {
3969            r#type,
3970            transaction_hash: &self.transaction_hash,
3971            actual_fee: &self.actual_fee,
3972            finality_status: &self.finality_status,
3973            messages_sent: &self.messages_sent,
3974            events: &self.events,
3975            execution_resources: &self.execution_resources,
3976            execution_result: &self.execution_result,
3977        };
3978
3979        Tagged::serialize(&tagged, serializer)
3980    }
3981}
3982
3983impl<'de> Deserialize<'de> for InvokeTransactionReceipt {
3984    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3985        #[serde_as]
3986        #[derive(Deserialize)]
3987        struct Tagged {
3988            pub r#type: Option<String>,
3989            #[serde_as(as = "UfeHex")]
3990            pub transaction_hash: Felt,
3991            pub actual_fee: FeePayment,
3992            pub finality_status: TransactionFinalityStatus,
3993            pub messages_sent: Vec<MsgToL1>,
3994            pub events: Vec<Event>,
3995            pub execution_resources: ExecutionResources,
3996            #[serde(flatten)]
3997            pub execution_result: ExecutionResult,
3998        }
3999
4000        let tagged = Tagged::deserialize(deserializer)?;
4001
4002        if let Some(tag_field) = &tagged.r#type {
4003            if tag_field != "INVOKE" {
4004                return Err(serde::de::Error::custom("invalid `type` value"));
4005            }
4006        }
4007
4008        Ok(Self {
4009            transaction_hash: tagged.transaction_hash,
4010            actual_fee: tagged.actual_fee,
4011            finality_status: tagged.finality_status,
4012            messages_sent: tagged.messages_sent,
4013            events: tagged.events,
4014            execution_resources: tagged.execution_resources,
4015            execution_result: tagged.execution_result,
4016        })
4017    }
4018}
4019
4020impl Serialize for InvokeTransactionTrace {
4021    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4022        #[derive(Serialize)]
4023        struct Tagged<'a> {
4024            #[serde(skip_serializing_if = "Option::is_none")]
4025            pub validate_invocation: &'a Option<FunctionInvocation>,
4026            pub execute_invocation: &'a ExecuteInvocation,
4027            #[serde(skip_serializing_if = "Option::is_none")]
4028            pub fee_transfer_invocation: &'a Option<FunctionInvocation>,
4029            #[serde(skip_serializing_if = "Option::is_none")]
4030            pub state_diff: &'a Option<StateDiff>,
4031            pub execution_resources: &'a ExecutionResources,
4032            pub r#type: &'a str,
4033        }
4034
4035        let r#type = "INVOKE";
4036
4037        let tagged = Tagged {
4038            validate_invocation: &self.validate_invocation,
4039            execute_invocation: &self.execute_invocation,
4040            fee_transfer_invocation: &self.fee_transfer_invocation,
4041            state_diff: &self.state_diff,
4042            execution_resources: &self.execution_resources,
4043            r#type,
4044        };
4045
4046        Tagged::serialize(&tagged, serializer)
4047    }
4048}
4049
4050impl<'de> Deserialize<'de> for InvokeTransactionTrace {
4051    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4052        #[derive(Deserialize)]
4053        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4054        struct Tagged {
4055            #[serde(skip_serializing_if = "Option::is_none")]
4056            pub validate_invocation: Option<FunctionInvocation>,
4057            pub execute_invocation: ExecuteInvocation,
4058            #[serde(skip_serializing_if = "Option::is_none")]
4059            pub fee_transfer_invocation: Option<FunctionInvocation>,
4060            #[serde(skip_serializing_if = "Option::is_none")]
4061            pub state_diff: Option<StateDiff>,
4062            pub execution_resources: ExecutionResources,
4063            pub r#type: Option<String>,
4064        }
4065
4066        let tagged = Tagged::deserialize(deserializer)?;
4067
4068        if let Some(tag_field) = &tagged.r#type {
4069            if tag_field != "INVOKE" {
4070                return Err(serde::de::Error::custom("invalid `type` value"));
4071            }
4072        }
4073
4074        Ok(Self {
4075            validate_invocation: tagged.validate_invocation,
4076            execute_invocation: tagged.execute_invocation,
4077            fee_transfer_invocation: tagged.fee_transfer_invocation,
4078            state_diff: tagged.state_diff,
4079            execution_resources: tagged.execution_resources,
4080        })
4081    }
4082}
4083
4084impl Serialize for InvokeTransactionV0 {
4085    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4086        #[serde_as]
4087        #[derive(Serialize)]
4088        struct Tagged<'a> {
4089            #[serde_as(as = "UfeHex")]
4090            pub transaction_hash: &'a Felt,
4091            pub r#type: &'a str,
4092            #[serde_as(as = "UfeHex")]
4093            pub max_fee: &'a Felt,
4094            #[serde_as(as = "NumAsHex")]
4095            pub version: &'a u64,
4096            #[serde_as(as = "[UfeHex]")]
4097            pub signature: &'a [Felt],
4098            #[serde_as(as = "UfeHex")]
4099            pub contract_address: &'a Felt,
4100            #[serde_as(as = "UfeHex")]
4101            pub entry_point_selector: &'a Felt,
4102            #[serde_as(as = "[UfeHex]")]
4103            pub calldata: &'a [Felt],
4104        }
4105
4106        let r#type = "INVOKE";
4107
4108        let version = &0;
4109
4110        let tagged = Tagged {
4111            transaction_hash: &self.transaction_hash,
4112            r#type,
4113            max_fee: &self.max_fee,
4114            version,
4115            signature: &self.signature,
4116            contract_address: &self.contract_address,
4117            entry_point_selector: &self.entry_point_selector,
4118            calldata: &self.calldata,
4119        };
4120
4121        Tagged::serialize(&tagged, serializer)
4122    }
4123}
4124
4125impl<'de> Deserialize<'de> for InvokeTransactionV0 {
4126    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4127        #[serde_as]
4128        #[derive(Deserialize)]
4129        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4130        struct Tagged {
4131            #[serde_as(as = "UfeHex")]
4132            pub transaction_hash: Felt,
4133            pub r#type: Option<String>,
4134            #[serde_as(as = "UfeHex")]
4135            pub max_fee: Felt,
4136            #[serde_as(as = "Option<NumAsHex>")]
4137            pub version: Option<u64>,
4138            #[serde_as(as = "Vec<UfeHex>")]
4139            pub signature: Vec<Felt>,
4140            #[serde_as(as = "UfeHex")]
4141            pub contract_address: Felt,
4142            #[serde_as(as = "UfeHex")]
4143            pub entry_point_selector: Felt,
4144            #[serde_as(as = "Vec<UfeHex>")]
4145            pub calldata: Vec<Felt>,
4146        }
4147
4148        let tagged = Tagged::deserialize(deserializer)?;
4149
4150        if let Some(tag_field) = &tagged.r#type {
4151            if tag_field != "INVOKE" {
4152                return Err(serde::de::Error::custom("invalid `type` value"));
4153            }
4154        }
4155
4156        if let Some(tag_field) = &tagged.version {
4157            if tag_field != &0 {
4158                return Err(serde::de::Error::custom("invalid `version` value"));
4159            }
4160        }
4161
4162        Ok(Self {
4163            transaction_hash: tagged.transaction_hash,
4164            max_fee: tagged.max_fee,
4165            signature: tagged.signature,
4166            contract_address: tagged.contract_address,
4167            entry_point_selector: tagged.entry_point_selector,
4168            calldata: tagged.calldata,
4169        })
4170    }
4171}
4172
4173impl Serialize for InvokeTransactionV1 {
4174    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4175        #[serde_as]
4176        #[derive(Serialize)]
4177        struct Tagged<'a> {
4178            #[serde_as(as = "UfeHex")]
4179            pub transaction_hash: &'a Felt,
4180            pub r#type: &'a str,
4181            #[serde_as(as = "UfeHex")]
4182            pub sender_address: &'a Felt,
4183            #[serde_as(as = "[UfeHex]")]
4184            pub calldata: &'a [Felt],
4185            #[serde_as(as = "UfeHex")]
4186            pub max_fee: &'a Felt,
4187            #[serde_as(as = "NumAsHex")]
4188            pub version: &'a u64,
4189            #[serde_as(as = "[UfeHex]")]
4190            pub signature: &'a [Felt],
4191            #[serde_as(as = "UfeHex")]
4192            pub nonce: &'a Felt,
4193        }
4194
4195        let r#type = "INVOKE";
4196
4197        let version = &1;
4198
4199        let tagged = Tagged {
4200            transaction_hash: &self.transaction_hash,
4201            r#type,
4202            sender_address: &self.sender_address,
4203            calldata: &self.calldata,
4204            max_fee: &self.max_fee,
4205            version,
4206            signature: &self.signature,
4207            nonce: &self.nonce,
4208        };
4209
4210        Tagged::serialize(&tagged, serializer)
4211    }
4212}
4213
4214impl<'de> Deserialize<'de> for InvokeTransactionV1 {
4215    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4216        #[serde_as]
4217        #[derive(Deserialize)]
4218        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4219        struct Tagged {
4220            #[serde_as(as = "UfeHex")]
4221            pub transaction_hash: Felt,
4222            pub r#type: Option<String>,
4223            #[serde_as(as = "UfeHex")]
4224            pub sender_address: Felt,
4225            #[serde_as(as = "Vec<UfeHex>")]
4226            pub calldata: Vec<Felt>,
4227            #[serde_as(as = "UfeHex")]
4228            pub max_fee: Felt,
4229            #[serde_as(as = "Option<NumAsHex>")]
4230            pub version: Option<u64>,
4231            #[serde_as(as = "Vec<UfeHex>")]
4232            pub signature: Vec<Felt>,
4233            #[serde_as(as = "UfeHex")]
4234            pub nonce: Felt,
4235        }
4236
4237        let tagged = Tagged::deserialize(deserializer)?;
4238
4239        if let Some(tag_field) = &tagged.r#type {
4240            if tag_field != "INVOKE" {
4241                return Err(serde::de::Error::custom("invalid `type` value"));
4242            }
4243        }
4244
4245        if let Some(tag_field) = &tagged.version {
4246            if tag_field != &1 {
4247                return Err(serde::de::Error::custom("invalid `version` value"));
4248            }
4249        }
4250
4251        Ok(Self {
4252            transaction_hash: tagged.transaction_hash,
4253            sender_address: tagged.sender_address,
4254            calldata: tagged.calldata,
4255            max_fee: tagged.max_fee,
4256            signature: tagged.signature,
4257            nonce: tagged.nonce,
4258        })
4259    }
4260}
4261
4262impl Serialize for InvokeTransactionV3 {
4263    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4264        #[serde_as]
4265        #[derive(Serialize)]
4266        struct Tagged<'a> {
4267            #[serde_as(as = "UfeHex")]
4268            pub transaction_hash: &'a Felt,
4269            pub r#type: &'a str,
4270            #[serde_as(as = "UfeHex")]
4271            pub sender_address: &'a Felt,
4272            #[serde_as(as = "[UfeHex]")]
4273            pub calldata: &'a [Felt],
4274            #[serde_as(as = "NumAsHex")]
4275            pub version: &'a u64,
4276            #[serde_as(as = "[UfeHex]")]
4277            pub signature: &'a [Felt],
4278            #[serde_as(as = "UfeHex")]
4279            pub nonce: &'a Felt,
4280            pub resource_bounds: &'a ResourceBoundsMapping,
4281            #[serde_as(as = "NumAsHex")]
4282            pub tip: &'a u64,
4283            #[serde_as(as = "[UfeHex]")]
4284            pub paymaster_data: &'a [Felt],
4285            #[serde_as(as = "[UfeHex]")]
4286            pub account_deployment_data: &'a [Felt],
4287            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
4288            pub fee_data_availability_mode: &'a DataAvailabilityMode,
4289        }
4290
4291        let r#type = "INVOKE";
4292
4293        let version = &3;
4294
4295        let tagged = Tagged {
4296            transaction_hash: &self.transaction_hash,
4297            r#type,
4298            sender_address: &self.sender_address,
4299            calldata: &self.calldata,
4300            version,
4301            signature: &self.signature,
4302            nonce: &self.nonce,
4303            resource_bounds: &self.resource_bounds,
4304            tip: &self.tip,
4305            paymaster_data: &self.paymaster_data,
4306            account_deployment_data: &self.account_deployment_data,
4307            nonce_data_availability_mode: &self.nonce_data_availability_mode,
4308            fee_data_availability_mode: &self.fee_data_availability_mode,
4309        };
4310
4311        Tagged::serialize(&tagged, serializer)
4312    }
4313}
4314
4315impl<'de> Deserialize<'de> for InvokeTransactionV3 {
4316    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4317        #[serde_as]
4318        #[derive(Deserialize)]
4319        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4320        struct Tagged {
4321            #[serde_as(as = "UfeHex")]
4322            pub transaction_hash: Felt,
4323            pub r#type: Option<String>,
4324            #[serde_as(as = "UfeHex")]
4325            pub sender_address: Felt,
4326            #[serde_as(as = "Vec<UfeHex>")]
4327            pub calldata: Vec<Felt>,
4328            #[serde_as(as = "Option<NumAsHex>")]
4329            pub version: Option<u64>,
4330            #[serde_as(as = "Vec<UfeHex>")]
4331            pub signature: Vec<Felt>,
4332            #[serde_as(as = "UfeHex")]
4333            pub nonce: Felt,
4334            pub resource_bounds: ResourceBoundsMapping,
4335            #[serde_as(as = "NumAsHex")]
4336            pub tip: u64,
4337            #[serde_as(as = "Vec<UfeHex>")]
4338            pub paymaster_data: Vec<Felt>,
4339            #[serde_as(as = "Vec<UfeHex>")]
4340            pub account_deployment_data: Vec<Felt>,
4341            pub nonce_data_availability_mode: DataAvailabilityMode,
4342            pub fee_data_availability_mode: DataAvailabilityMode,
4343        }
4344
4345        let tagged = Tagged::deserialize(deserializer)?;
4346
4347        if let Some(tag_field) = &tagged.r#type {
4348            if tag_field != "INVOKE" {
4349                return Err(serde::de::Error::custom("invalid `type` value"));
4350            }
4351        }
4352
4353        if let Some(tag_field) = &tagged.version {
4354            if tag_field != &3 {
4355                return Err(serde::de::Error::custom("invalid `version` value"));
4356            }
4357        }
4358
4359        Ok(Self {
4360            transaction_hash: tagged.transaction_hash,
4361            sender_address: tagged.sender_address,
4362            calldata: tagged.calldata,
4363            signature: tagged.signature,
4364            nonce: tagged.nonce,
4365            resource_bounds: tagged.resource_bounds,
4366            tip: tagged.tip,
4367            paymaster_data: tagged.paymaster_data,
4368            account_deployment_data: tagged.account_deployment_data,
4369            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
4370            fee_data_availability_mode: tagged.fee_data_availability_mode,
4371        })
4372    }
4373}
4374
4375impl Serialize for L1HandlerTransaction {
4376    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4377        #[serde_as]
4378        #[derive(Serialize)]
4379        struct Tagged<'a> {
4380            #[serde_as(as = "UfeHex")]
4381            pub transaction_hash: &'a Felt,
4382            #[serde_as(as = "UfeHex")]
4383            pub version: &'a Felt,
4384            pub r#type: &'a str,
4385            #[serde_as(as = "NumAsHex")]
4386            pub nonce: &'a u64,
4387            #[serde_as(as = "UfeHex")]
4388            pub contract_address: &'a Felt,
4389            #[serde_as(as = "UfeHex")]
4390            pub entry_point_selector: &'a Felt,
4391            #[serde_as(as = "[UfeHex]")]
4392            pub calldata: &'a [Felt],
4393        }
4394
4395        let r#type = "L1_HANDLER";
4396
4397        let tagged = Tagged {
4398            transaction_hash: &self.transaction_hash,
4399            version: &self.version,
4400            r#type,
4401            nonce: &self.nonce,
4402            contract_address: &self.contract_address,
4403            entry_point_selector: &self.entry_point_selector,
4404            calldata: &self.calldata,
4405        };
4406
4407        Tagged::serialize(&tagged, serializer)
4408    }
4409}
4410
4411impl<'de> Deserialize<'de> for L1HandlerTransaction {
4412    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4413        #[serde_as]
4414        #[derive(Deserialize)]
4415        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4416        struct Tagged {
4417            #[serde_as(as = "UfeHex")]
4418            pub transaction_hash: Felt,
4419            #[serde_as(as = "UfeHex")]
4420            pub version: Felt,
4421            pub r#type: Option<String>,
4422            #[serde_as(as = "NumAsHex")]
4423            pub nonce: u64,
4424            #[serde_as(as = "UfeHex")]
4425            pub contract_address: Felt,
4426            #[serde_as(as = "UfeHex")]
4427            pub entry_point_selector: Felt,
4428            #[serde_as(as = "Vec<UfeHex>")]
4429            pub calldata: Vec<Felt>,
4430        }
4431
4432        let tagged = Tagged::deserialize(deserializer)?;
4433
4434        if let Some(tag_field) = &tagged.r#type {
4435            if tag_field != "L1_HANDLER" {
4436                return Err(serde::de::Error::custom("invalid `type` value"));
4437            }
4438        }
4439
4440        Ok(Self {
4441            transaction_hash: tagged.transaction_hash,
4442            version: tagged.version,
4443            nonce: tagged.nonce,
4444            contract_address: tagged.contract_address,
4445            entry_point_selector: tagged.entry_point_selector,
4446            calldata: tagged.calldata,
4447        })
4448    }
4449}
4450
4451impl Serialize for L1HandlerTransactionReceipt {
4452    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4453        #[serde_as]
4454        #[derive(Serialize)]
4455        struct Tagged<'a> {
4456            pub r#type: &'a str,
4457            pub message_hash: &'a Hash256,
4458            #[serde_as(as = "UfeHex")]
4459            pub transaction_hash: &'a Felt,
4460            pub actual_fee: &'a FeePayment,
4461            pub finality_status: &'a TransactionFinalityStatus,
4462            pub messages_sent: &'a [MsgToL1],
4463            pub events: &'a [Event],
4464            pub execution_resources: &'a ExecutionResources,
4465            #[serde(flatten)]
4466            pub execution_result: &'a ExecutionResult,
4467        }
4468
4469        let r#type = "L1_HANDLER";
4470
4471        let tagged = Tagged {
4472            r#type,
4473            message_hash: &self.message_hash,
4474            transaction_hash: &self.transaction_hash,
4475            actual_fee: &self.actual_fee,
4476            finality_status: &self.finality_status,
4477            messages_sent: &self.messages_sent,
4478            events: &self.events,
4479            execution_resources: &self.execution_resources,
4480            execution_result: &self.execution_result,
4481        };
4482
4483        Tagged::serialize(&tagged, serializer)
4484    }
4485}
4486
4487impl<'de> Deserialize<'de> for L1HandlerTransactionReceipt {
4488    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4489        #[serde_as]
4490        #[derive(Deserialize)]
4491        struct Tagged {
4492            pub r#type: Option<String>,
4493            pub message_hash: Hash256,
4494            #[serde_as(as = "UfeHex")]
4495            pub transaction_hash: Felt,
4496            pub actual_fee: FeePayment,
4497            pub finality_status: TransactionFinalityStatus,
4498            pub messages_sent: Vec<MsgToL1>,
4499            pub events: Vec<Event>,
4500            pub execution_resources: ExecutionResources,
4501            #[serde(flatten)]
4502            pub execution_result: ExecutionResult,
4503        }
4504
4505        let tagged = Tagged::deserialize(deserializer)?;
4506
4507        if let Some(tag_field) = &tagged.r#type {
4508            if tag_field != "L1_HANDLER" {
4509                return Err(serde::de::Error::custom("invalid `type` value"));
4510            }
4511        }
4512
4513        Ok(Self {
4514            message_hash: tagged.message_hash,
4515            transaction_hash: tagged.transaction_hash,
4516            actual_fee: tagged.actual_fee,
4517            finality_status: tagged.finality_status,
4518            messages_sent: tagged.messages_sent,
4519            events: tagged.events,
4520            execution_resources: tagged.execution_resources,
4521            execution_result: tagged.execution_result,
4522        })
4523    }
4524}
4525
4526impl Serialize for L1HandlerTransactionTrace {
4527    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4528        #[derive(Serialize)]
4529        struct Tagged<'a> {
4530            pub function_invocation: &'a FunctionInvocation,
4531            #[serde(skip_serializing_if = "Option::is_none")]
4532            pub state_diff: &'a Option<StateDiff>,
4533            pub execution_resources: &'a ExecutionResources,
4534            pub r#type: &'a str,
4535        }
4536
4537        let r#type = "L1_HANDLER";
4538
4539        let tagged = Tagged {
4540            function_invocation: &self.function_invocation,
4541            state_diff: &self.state_diff,
4542            execution_resources: &self.execution_resources,
4543            r#type,
4544        };
4545
4546        Tagged::serialize(&tagged, serializer)
4547    }
4548}
4549
4550impl<'de> Deserialize<'de> for L1HandlerTransactionTrace {
4551    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4552        #[derive(Deserialize)]
4553        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4554        struct Tagged {
4555            pub function_invocation: FunctionInvocation,
4556            #[serde(skip_serializing_if = "Option::is_none")]
4557            pub state_diff: Option<StateDiff>,
4558            pub execution_resources: ExecutionResources,
4559            pub r#type: Option<String>,
4560        }
4561
4562        let tagged = Tagged::deserialize(deserializer)?;
4563
4564        if let Some(tag_field) = &tagged.r#type {
4565            if tag_field != "L1_HANDLER" {
4566                return Err(serde::de::Error::custom("invalid `type` value"));
4567            }
4568        }
4569
4570        Ok(Self {
4571            function_invocation: tagged.function_invocation,
4572            state_diff: tagged.state_diff,
4573            execution_resources: tagged.execution_resources,
4574        })
4575    }
4576}
4577
4578impl Serialize for AddDeclareTransactionRequest {
4579    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4580        #[derive(Serialize)]
4581        #[serde(transparent)]
4582        struct Field0<'a> {
4583            pub declare_transaction: &'a BroadcastedDeclareTransaction,
4584        }
4585
4586        use serde::ser::SerializeSeq;
4587
4588        let mut seq = serializer.serialize_seq(None)?;
4589
4590        seq.serialize_element(&Field0 {
4591            declare_transaction: &self.declare_transaction,
4592        })?;
4593
4594        seq.end()
4595    }
4596}
4597
4598impl Serialize for AddDeclareTransactionRequestRef<'_> {
4599    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4600        #[derive(Serialize)]
4601        #[serde(transparent)]
4602        struct Field0<'a> {
4603            pub declare_transaction: &'a BroadcastedDeclareTransaction,
4604        }
4605
4606        use serde::ser::SerializeSeq;
4607
4608        let mut seq = serializer.serialize_seq(None)?;
4609
4610        seq.serialize_element(&Field0 {
4611            declare_transaction: self.declare_transaction,
4612        })?;
4613
4614        seq.end()
4615    }
4616}
4617
4618impl<'de> Deserialize<'de> for AddDeclareTransactionRequest {
4619    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4620        #[serde_as]
4621        #[derive(Deserialize)]
4622        struct AsObject {
4623            pub declare_transaction: BroadcastedDeclareTransaction,
4624        }
4625
4626        #[derive(Deserialize)]
4627        #[serde(transparent)]
4628        struct Field0 {
4629            pub declare_transaction: BroadcastedDeclareTransaction,
4630        }
4631
4632        let temp = serde_json::Value::deserialize(deserializer)?;
4633
4634        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
4635            let field0 = serde_json::from_value::<Field0>(
4636                elements
4637                    .pop()
4638                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
4639            )
4640            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
4641
4642            Ok(Self {
4643                declare_transaction: field0.declare_transaction,
4644            })
4645        } else if let Ok(object) = AsObject::deserialize(&temp) {
4646            Ok(Self {
4647                declare_transaction: object.declare_transaction,
4648            })
4649        } else {
4650            Err(serde::de::Error::custom("invalid sequence length"))
4651        }
4652    }
4653}
4654
4655impl Serialize for AddDeployAccountTransactionRequest {
4656    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4657        #[derive(Serialize)]
4658        #[serde(transparent)]
4659        struct Field0<'a> {
4660            pub deploy_account_transaction: &'a BroadcastedDeployAccountTransaction,
4661        }
4662
4663        use serde::ser::SerializeSeq;
4664
4665        let mut seq = serializer.serialize_seq(None)?;
4666
4667        seq.serialize_element(&Field0 {
4668            deploy_account_transaction: &self.deploy_account_transaction,
4669        })?;
4670
4671        seq.end()
4672    }
4673}
4674
4675impl Serialize for AddDeployAccountTransactionRequestRef<'_> {
4676    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4677        #[derive(Serialize)]
4678        #[serde(transparent)]
4679        struct Field0<'a> {
4680            pub deploy_account_transaction: &'a BroadcastedDeployAccountTransaction,
4681        }
4682
4683        use serde::ser::SerializeSeq;
4684
4685        let mut seq = serializer.serialize_seq(None)?;
4686
4687        seq.serialize_element(&Field0 {
4688            deploy_account_transaction: self.deploy_account_transaction,
4689        })?;
4690
4691        seq.end()
4692    }
4693}
4694
4695impl<'de> Deserialize<'de> for AddDeployAccountTransactionRequest {
4696    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4697        #[serde_as]
4698        #[derive(Deserialize)]
4699        struct AsObject {
4700            pub deploy_account_transaction: BroadcastedDeployAccountTransaction,
4701        }
4702
4703        #[derive(Deserialize)]
4704        #[serde(transparent)]
4705        struct Field0 {
4706            pub deploy_account_transaction: BroadcastedDeployAccountTransaction,
4707        }
4708
4709        let temp = serde_json::Value::deserialize(deserializer)?;
4710
4711        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
4712            let field0 = serde_json::from_value::<Field0>(
4713                elements
4714                    .pop()
4715                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
4716            )
4717            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
4718
4719            Ok(Self {
4720                deploy_account_transaction: field0.deploy_account_transaction,
4721            })
4722        } else if let Ok(object) = AsObject::deserialize(&temp) {
4723            Ok(Self {
4724                deploy_account_transaction: object.deploy_account_transaction,
4725            })
4726        } else {
4727            Err(serde::de::Error::custom("invalid sequence length"))
4728        }
4729    }
4730}
4731
4732impl Serialize for AddInvokeTransactionRequest {
4733    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4734        #[derive(Serialize)]
4735        #[serde(transparent)]
4736        struct Field0<'a> {
4737            pub invoke_transaction: &'a BroadcastedInvokeTransaction,
4738        }
4739
4740        use serde::ser::SerializeSeq;
4741
4742        let mut seq = serializer.serialize_seq(None)?;
4743
4744        seq.serialize_element(&Field0 {
4745            invoke_transaction: &self.invoke_transaction,
4746        })?;
4747
4748        seq.end()
4749    }
4750}
4751
4752impl Serialize for AddInvokeTransactionRequestRef<'_> {
4753    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4754        #[derive(Serialize)]
4755        #[serde(transparent)]
4756        struct Field0<'a> {
4757            pub invoke_transaction: &'a BroadcastedInvokeTransaction,
4758        }
4759
4760        use serde::ser::SerializeSeq;
4761
4762        let mut seq = serializer.serialize_seq(None)?;
4763
4764        seq.serialize_element(&Field0 {
4765            invoke_transaction: self.invoke_transaction,
4766        })?;
4767
4768        seq.end()
4769    }
4770}
4771
4772impl<'de> Deserialize<'de> for AddInvokeTransactionRequest {
4773    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4774        #[serde_as]
4775        #[derive(Deserialize)]
4776        struct AsObject {
4777            pub invoke_transaction: BroadcastedInvokeTransaction,
4778        }
4779
4780        #[derive(Deserialize)]
4781        #[serde(transparent)]
4782        struct Field0 {
4783            pub invoke_transaction: BroadcastedInvokeTransaction,
4784        }
4785
4786        let temp = serde_json::Value::deserialize(deserializer)?;
4787
4788        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
4789            let field0 = serde_json::from_value::<Field0>(
4790                elements
4791                    .pop()
4792                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
4793            )
4794            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
4795
4796            Ok(Self {
4797                invoke_transaction: field0.invoke_transaction,
4798            })
4799        } else if let Ok(object) = AsObject::deserialize(&temp) {
4800            Ok(Self {
4801                invoke_transaction: object.invoke_transaction,
4802            })
4803        } else {
4804            Err(serde::de::Error::custom("invalid sequence length"))
4805        }
4806    }
4807}
4808
4809impl Serialize for BlockHashAndNumberRequest {
4810    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4811        use serde::ser::SerializeSeq;
4812
4813        let seq = serializer.serialize_seq(Some(0))?;
4814        seq.end()
4815    }
4816}
4817
4818impl<'de> Deserialize<'de> for BlockHashAndNumberRequest {
4819    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4820        let elements = Vec::<()>::deserialize(deserializer)?;
4821        if !elements.is_empty() {
4822            return Err(serde::de::Error::custom("invalid sequence length"));
4823        }
4824        Ok(Self)
4825    }
4826}
4827
4828impl Serialize for BlockNumberRequest {
4829    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4830        use serde::ser::SerializeSeq;
4831
4832        let seq = serializer.serialize_seq(Some(0))?;
4833        seq.end()
4834    }
4835}
4836
4837impl<'de> Deserialize<'de> for BlockNumberRequest {
4838    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4839        let elements = Vec::<()>::deserialize(deserializer)?;
4840        if !elements.is_empty() {
4841            return Err(serde::de::Error::custom("invalid sequence length"));
4842        }
4843        Ok(Self)
4844    }
4845}
4846
4847impl Serialize for CallRequest {
4848    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4849        #[derive(Serialize)]
4850        #[serde(transparent)]
4851        struct Field0<'a> {
4852            pub request: &'a FunctionCall,
4853        }
4854
4855        #[derive(Serialize)]
4856        #[serde(transparent)]
4857        struct Field1<'a> {
4858            pub block_id: &'a BlockId,
4859        }
4860
4861        use serde::ser::SerializeSeq;
4862
4863        let mut seq = serializer.serialize_seq(None)?;
4864
4865        seq.serialize_element(&Field0 {
4866            request: &self.request,
4867        })?;
4868        seq.serialize_element(&Field1 {
4869            block_id: &self.block_id,
4870        })?;
4871
4872        seq.end()
4873    }
4874}
4875
4876impl Serialize for CallRequestRef<'_> {
4877    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4878        #[derive(Serialize)]
4879        #[serde(transparent)]
4880        struct Field0<'a> {
4881            pub request: &'a FunctionCall,
4882        }
4883
4884        #[derive(Serialize)]
4885        #[serde(transparent)]
4886        struct Field1<'a> {
4887            pub block_id: &'a BlockId,
4888        }
4889
4890        use serde::ser::SerializeSeq;
4891
4892        let mut seq = serializer.serialize_seq(None)?;
4893
4894        seq.serialize_element(&Field0 {
4895            request: self.request,
4896        })?;
4897        seq.serialize_element(&Field1 {
4898            block_id: self.block_id,
4899        })?;
4900
4901        seq.end()
4902    }
4903}
4904
4905impl<'de> Deserialize<'de> for CallRequest {
4906    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4907        #[serde_as]
4908        #[derive(Deserialize)]
4909        struct AsObject {
4910            pub request: FunctionCall,
4911            pub block_id: BlockId,
4912        }
4913
4914        #[derive(Deserialize)]
4915        #[serde(transparent)]
4916        struct Field0 {
4917            pub request: FunctionCall,
4918        }
4919
4920        #[derive(Deserialize)]
4921        #[serde(transparent)]
4922        struct Field1 {
4923            pub block_id: BlockId,
4924        }
4925
4926        let temp = serde_json::Value::deserialize(deserializer)?;
4927
4928        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
4929            let field1 = serde_json::from_value::<Field1>(
4930                elements
4931                    .pop()
4932                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
4933            )
4934            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
4935            let field0 = serde_json::from_value::<Field0>(
4936                elements
4937                    .pop()
4938                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
4939            )
4940            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
4941
4942            Ok(Self {
4943                request: field0.request,
4944                block_id: field1.block_id,
4945            })
4946        } else if let Ok(object) = AsObject::deserialize(&temp) {
4947            Ok(Self {
4948                request: object.request,
4949                block_id: object.block_id,
4950            })
4951        } else {
4952            Err(serde::de::Error::custom("invalid sequence length"))
4953        }
4954    }
4955}
4956
4957impl Serialize for ChainIdRequest {
4958    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4959        use serde::ser::SerializeSeq;
4960
4961        let seq = serializer.serialize_seq(Some(0))?;
4962        seq.end()
4963    }
4964}
4965
4966impl<'de> Deserialize<'de> for ChainIdRequest {
4967    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4968        let elements = Vec::<()>::deserialize(deserializer)?;
4969        if !elements.is_empty() {
4970            return Err(serde::de::Error::custom("invalid sequence length"));
4971        }
4972        Ok(Self)
4973    }
4974}
4975
4976impl Serialize for EstimateFeeRequest {
4977    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4978        #[derive(Serialize)]
4979        #[serde(transparent)]
4980        struct Field0<'a> {
4981            pub request: &'a [BroadcastedTransaction],
4982        }
4983
4984        #[derive(Serialize)]
4985        #[serde(transparent)]
4986        struct Field1<'a> {
4987            pub simulation_flags: &'a [SimulationFlagForEstimateFee],
4988        }
4989
4990        #[derive(Serialize)]
4991        #[serde(transparent)]
4992        struct Field2<'a> {
4993            pub block_id: &'a BlockId,
4994        }
4995
4996        use serde::ser::SerializeSeq;
4997
4998        let mut seq = serializer.serialize_seq(None)?;
4999
5000        seq.serialize_element(&Field0 {
5001            request: &self.request,
5002        })?;
5003        seq.serialize_element(&Field1 {
5004            simulation_flags: &self.simulation_flags,
5005        })?;
5006        seq.serialize_element(&Field2 {
5007            block_id: &self.block_id,
5008        })?;
5009
5010        seq.end()
5011    }
5012}
5013
5014impl Serialize for EstimateFeeRequestRef<'_> {
5015    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5016        #[derive(Serialize)]
5017        #[serde(transparent)]
5018        struct Field0<'a> {
5019            pub request: &'a [BroadcastedTransaction],
5020        }
5021
5022        #[derive(Serialize)]
5023        #[serde(transparent)]
5024        struct Field1<'a> {
5025            pub simulation_flags: &'a [SimulationFlagForEstimateFee],
5026        }
5027
5028        #[derive(Serialize)]
5029        #[serde(transparent)]
5030        struct Field2<'a> {
5031            pub block_id: &'a BlockId,
5032        }
5033
5034        use serde::ser::SerializeSeq;
5035
5036        let mut seq = serializer.serialize_seq(None)?;
5037
5038        seq.serialize_element(&Field0 {
5039            request: self.request,
5040        })?;
5041        seq.serialize_element(&Field1 {
5042            simulation_flags: self.simulation_flags,
5043        })?;
5044        seq.serialize_element(&Field2 {
5045            block_id: self.block_id,
5046        })?;
5047
5048        seq.end()
5049    }
5050}
5051
5052impl<'de> Deserialize<'de> for EstimateFeeRequest {
5053    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5054        #[serde_as]
5055        #[derive(Deserialize)]
5056        struct AsObject {
5057            pub request: Vec<BroadcastedTransaction>,
5058            pub simulation_flags: Vec<SimulationFlagForEstimateFee>,
5059            pub block_id: BlockId,
5060        }
5061
5062        #[derive(Deserialize)]
5063        #[serde(transparent)]
5064        struct Field0 {
5065            pub request: Vec<BroadcastedTransaction>,
5066        }
5067
5068        #[derive(Deserialize)]
5069        #[serde(transparent)]
5070        struct Field1 {
5071            pub simulation_flags: Vec<SimulationFlagForEstimateFee>,
5072        }
5073
5074        #[derive(Deserialize)]
5075        #[serde(transparent)]
5076        struct Field2 {
5077            pub block_id: BlockId,
5078        }
5079
5080        let temp = serde_json::Value::deserialize(deserializer)?;
5081
5082        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5083            let field2 = serde_json::from_value::<Field2>(
5084                elements
5085                    .pop()
5086                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5087            )
5088            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5089            let field1 = serde_json::from_value::<Field1>(
5090                elements
5091                    .pop()
5092                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5093            )
5094            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5095            let field0 = serde_json::from_value::<Field0>(
5096                elements
5097                    .pop()
5098                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5099            )
5100            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5101
5102            Ok(Self {
5103                request: field0.request,
5104                simulation_flags: field1.simulation_flags,
5105                block_id: field2.block_id,
5106            })
5107        } else if let Ok(object) = AsObject::deserialize(&temp) {
5108            Ok(Self {
5109                request: object.request,
5110                simulation_flags: object.simulation_flags,
5111                block_id: object.block_id,
5112            })
5113        } else {
5114            Err(serde::de::Error::custom("invalid sequence length"))
5115        }
5116    }
5117}
5118
5119impl Serialize for EstimateMessageFeeRequest {
5120    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5121        #[derive(Serialize)]
5122        #[serde(transparent)]
5123        struct Field0<'a> {
5124            pub message: &'a MsgFromL1,
5125        }
5126
5127        #[derive(Serialize)]
5128        #[serde(transparent)]
5129        struct Field1<'a> {
5130            pub block_id: &'a BlockId,
5131        }
5132
5133        use serde::ser::SerializeSeq;
5134
5135        let mut seq = serializer.serialize_seq(None)?;
5136
5137        seq.serialize_element(&Field0 {
5138            message: &self.message,
5139        })?;
5140        seq.serialize_element(&Field1 {
5141            block_id: &self.block_id,
5142        })?;
5143
5144        seq.end()
5145    }
5146}
5147
5148impl Serialize for EstimateMessageFeeRequestRef<'_> {
5149    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5150        #[derive(Serialize)]
5151        #[serde(transparent)]
5152        struct Field0<'a> {
5153            pub message: &'a MsgFromL1,
5154        }
5155
5156        #[derive(Serialize)]
5157        #[serde(transparent)]
5158        struct Field1<'a> {
5159            pub block_id: &'a BlockId,
5160        }
5161
5162        use serde::ser::SerializeSeq;
5163
5164        let mut seq = serializer.serialize_seq(None)?;
5165
5166        seq.serialize_element(&Field0 {
5167            message: self.message,
5168        })?;
5169        seq.serialize_element(&Field1 {
5170            block_id: self.block_id,
5171        })?;
5172
5173        seq.end()
5174    }
5175}
5176
5177impl<'de> Deserialize<'de> for EstimateMessageFeeRequest {
5178    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5179        #[serde_as]
5180        #[derive(Deserialize)]
5181        struct AsObject {
5182            pub message: MsgFromL1,
5183            pub block_id: BlockId,
5184        }
5185
5186        #[derive(Deserialize)]
5187        #[serde(transparent)]
5188        struct Field0 {
5189            pub message: MsgFromL1,
5190        }
5191
5192        #[derive(Deserialize)]
5193        #[serde(transparent)]
5194        struct Field1 {
5195            pub block_id: BlockId,
5196        }
5197
5198        let temp = serde_json::Value::deserialize(deserializer)?;
5199
5200        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5201            let field1 = serde_json::from_value::<Field1>(
5202                elements
5203                    .pop()
5204                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5205            )
5206            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5207            let field0 = serde_json::from_value::<Field0>(
5208                elements
5209                    .pop()
5210                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5211            )
5212            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5213
5214            Ok(Self {
5215                message: field0.message,
5216                block_id: field1.block_id,
5217            })
5218        } else if let Ok(object) = AsObject::deserialize(&temp) {
5219            Ok(Self {
5220                message: object.message,
5221                block_id: object.block_id,
5222            })
5223        } else {
5224            Err(serde::de::Error::custom("invalid sequence length"))
5225        }
5226    }
5227}
5228
5229impl Serialize for GetBlockTransactionCountRequest {
5230    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5231        #[derive(Serialize)]
5232        #[serde(transparent)]
5233        struct Field0<'a> {
5234            pub block_id: &'a BlockId,
5235        }
5236
5237        use serde::ser::SerializeSeq;
5238
5239        let mut seq = serializer.serialize_seq(None)?;
5240
5241        seq.serialize_element(&Field0 {
5242            block_id: &self.block_id,
5243        })?;
5244
5245        seq.end()
5246    }
5247}
5248
5249impl Serialize for GetBlockTransactionCountRequestRef<'_> {
5250    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5251        #[derive(Serialize)]
5252        #[serde(transparent)]
5253        struct Field0<'a> {
5254            pub block_id: &'a BlockId,
5255        }
5256
5257        use serde::ser::SerializeSeq;
5258
5259        let mut seq = serializer.serialize_seq(None)?;
5260
5261        seq.serialize_element(&Field0 {
5262            block_id: self.block_id,
5263        })?;
5264
5265        seq.end()
5266    }
5267}
5268
5269impl<'de> Deserialize<'de> for GetBlockTransactionCountRequest {
5270    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5271        #[serde_as]
5272        #[derive(Deserialize)]
5273        struct AsObject {
5274            pub block_id: BlockId,
5275        }
5276
5277        #[derive(Deserialize)]
5278        #[serde(transparent)]
5279        struct Field0 {
5280            pub block_id: BlockId,
5281        }
5282
5283        let temp = serde_json::Value::deserialize(deserializer)?;
5284
5285        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5286            let field0 = serde_json::from_value::<Field0>(
5287                elements
5288                    .pop()
5289                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5290            )
5291            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5292
5293            Ok(Self {
5294                block_id: field0.block_id,
5295            })
5296        } else if let Ok(object) = AsObject::deserialize(&temp) {
5297            Ok(Self {
5298                block_id: object.block_id,
5299            })
5300        } else {
5301            Err(serde::de::Error::custom("invalid sequence length"))
5302        }
5303    }
5304}
5305
5306impl Serialize for GetBlockWithReceiptsRequest {
5307    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5308        #[derive(Serialize)]
5309        #[serde(transparent)]
5310        struct Field0<'a> {
5311            pub block_id: &'a BlockId,
5312        }
5313
5314        use serde::ser::SerializeSeq;
5315
5316        let mut seq = serializer.serialize_seq(None)?;
5317
5318        seq.serialize_element(&Field0 {
5319            block_id: &self.block_id,
5320        })?;
5321
5322        seq.end()
5323    }
5324}
5325
5326impl Serialize for GetBlockWithReceiptsRequestRef<'_> {
5327    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5328        #[derive(Serialize)]
5329        #[serde(transparent)]
5330        struct Field0<'a> {
5331            pub block_id: &'a BlockId,
5332        }
5333
5334        use serde::ser::SerializeSeq;
5335
5336        let mut seq = serializer.serialize_seq(None)?;
5337
5338        seq.serialize_element(&Field0 {
5339            block_id: self.block_id,
5340        })?;
5341
5342        seq.end()
5343    }
5344}
5345
5346impl<'de> Deserialize<'de> for GetBlockWithReceiptsRequest {
5347    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5348        #[serde_as]
5349        #[derive(Deserialize)]
5350        struct AsObject {
5351            pub block_id: BlockId,
5352        }
5353
5354        #[derive(Deserialize)]
5355        #[serde(transparent)]
5356        struct Field0 {
5357            pub block_id: BlockId,
5358        }
5359
5360        let temp = serde_json::Value::deserialize(deserializer)?;
5361
5362        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5363            let field0 = serde_json::from_value::<Field0>(
5364                elements
5365                    .pop()
5366                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5367            )
5368            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5369
5370            Ok(Self {
5371                block_id: field0.block_id,
5372            })
5373        } else if let Ok(object) = AsObject::deserialize(&temp) {
5374            Ok(Self {
5375                block_id: object.block_id,
5376            })
5377        } else {
5378            Err(serde::de::Error::custom("invalid sequence length"))
5379        }
5380    }
5381}
5382
5383impl Serialize for GetBlockWithTxHashesRequest {
5384    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5385        #[derive(Serialize)]
5386        #[serde(transparent)]
5387        struct Field0<'a> {
5388            pub block_id: &'a BlockId,
5389        }
5390
5391        use serde::ser::SerializeSeq;
5392
5393        let mut seq = serializer.serialize_seq(None)?;
5394
5395        seq.serialize_element(&Field0 {
5396            block_id: &self.block_id,
5397        })?;
5398
5399        seq.end()
5400    }
5401}
5402
5403impl Serialize for GetBlockWithTxHashesRequestRef<'_> {
5404    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5405        #[derive(Serialize)]
5406        #[serde(transparent)]
5407        struct Field0<'a> {
5408            pub block_id: &'a BlockId,
5409        }
5410
5411        use serde::ser::SerializeSeq;
5412
5413        let mut seq = serializer.serialize_seq(None)?;
5414
5415        seq.serialize_element(&Field0 {
5416            block_id: self.block_id,
5417        })?;
5418
5419        seq.end()
5420    }
5421}
5422
5423impl<'de> Deserialize<'de> for GetBlockWithTxHashesRequest {
5424    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5425        #[serde_as]
5426        #[derive(Deserialize)]
5427        struct AsObject {
5428            pub block_id: BlockId,
5429        }
5430
5431        #[derive(Deserialize)]
5432        #[serde(transparent)]
5433        struct Field0 {
5434            pub block_id: BlockId,
5435        }
5436
5437        let temp = serde_json::Value::deserialize(deserializer)?;
5438
5439        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5440            let field0 = serde_json::from_value::<Field0>(
5441                elements
5442                    .pop()
5443                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5444            )
5445            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5446
5447            Ok(Self {
5448                block_id: field0.block_id,
5449            })
5450        } else if let Ok(object) = AsObject::deserialize(&temp) {
5451            Ok(Self {
5452                block_id: object.block_id,
5453            })
5454        } else {
5455            Err(serde::de::Error::custom("invalid sequence length"))
5456        }
5457    }
5458}
5459
5460impl Serialize for GetBlockWithTxsRequest {
5461    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5462        #[derive(Serialize)]
5463        #[serde(transparent)]
5464        struct Field0<'a> {
5465            pub block_id: &'a BlockId,
5466        }
5467
5468        use serde::ser::SerializeSeq;
5469
5470        let mut seq = serializer.serialize_seq(None)?;
5471
5472        seq.serialize_element(&Field0 {
5473            block_id: &self.block_id,
5474        })?;
5475
5476        seq.end()
5477    }
5478}
5479
5480impl Serialize for GetBlockWithTxsRequestRef<'_> {
5481    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5482        #[derive(Serialize)]
5483        #[serde(transparent)]
5484        struct Field0<'a> {
5485            pub block_id: &'a BlockId,
5486        }
5487
5488        use serde::ser::SerializeSeq;
5489
5490        let mut seq = serializer.serialize_seq(None)?;
5491
5492        seq.serialize_element(&Field0 {
5493            block_id: self.block_id,
5494        })?;
5495
5496        seq.end()
5497    }
5498}
5499
5500impl<'de> Deserialize<'de> for GetBlockWithTxsRequest {
5501    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5502        #[serde_as]
5503        #[derive(Deserialize)]
5504        struct AsObject {
5505            pub block_id: BlockId,
5506        }
5507
5508        #[derive(Deserialize)]
5509        #[serde(transparent)]
5510        struct Field0 {
5511            pub block_id: BlockId,
5512        }
5513
5514        let temp = serde_json::Value::deserialize(deserializer)?;
5515
5516        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5517            let field0 = serde_json::from_value::<Field0>(
5518                elements
5519                    .pop()
5520                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5521            )
5522            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5523
5524            Ok(Self {
5525                block_id: field0.block_id,
5526            })
5527        } else if let Ok(object) = AsObject::deserialize(&temp) {
5528            Ok(Self {
5529                block_id: object.block_id,
5530            })
5531        } else {
5532            Err(serde::de::Error::custom("invalid sequence length"))
5533        }
5534    }
5535}
5536
5537impl Serialize for GetClassAtRequest {
5538    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5539        #[derive(Serialize)]
5540        #[serde(transparent)]
5541        struct Field0<'a> {
5542            pub block_id: &'a BlockId,
5543        }
5544
5545        #[serde_as]
5546        #[derive(Serialize)]
5547        #[serde(transparent)]
5548        struct Field1<'a> {
5549            #[serde_as(as = "UfeHex")]
5550            pub contract_address: &'a Felt,
5551        }
5552
5553        use serde::ser::SerializeSeq;
5554
5555        let mut seq = serializer.serialize_seq(None)?;
5556
5557        seq.serialize_element(&Field0 {
5558            block_id: &self.block_id,
5559        })?;
5560        seq.serialize_element(&Field1 {
5561            contract_address: &self.contract_address,
5562        })?;
5563
5564        seq.end()
5565    }
5566}
5567
5568impl Serialize for GetClassAtRequestRef<'_> {
5569    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5570        #[derive(Serialize)]
5571        #[serde(transparent)]
5572        struct Field0<'a> {
5573            pub block_id: &'a BlockId,
5574        }
5575
5576        #[serde_as]
5577        #[derive(Serialize)]
5578        #[serde(transparent)]
5579        struct Field1<'a> {
5580            #[serde_as(as = "UfeHex")]
5581            pub contract_address: &'a Felt,
5582        }
5583
5584        use serde::ser::SerializeSeq;
5585
5586        let mut seq = serializer.serialize_seq(None)?;
5587
5588        seq.serialize_element(&Field0 {
5589            block_id: self.block_id,
5590        })?;
5591        seq.serialize_element(&Field1 {
5592            contract_address: self.contract_address,
5593        })?;
5594
5595        seq.end()
5596    }
5597}
5598
5599impl<'de> Deserialize<'de> for GetClassAtRequest {
5600    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5601        #[serde_as]
5602        #[derive(Deserialize)]
5603        struct AsObject {
5604            pub block_id: BlockId,
5605            #[serde_as(as = "UfeHex")]
5606            pub contract_address: Felt,
5607        }
5608
5609        #[derive(Deserialize)]
5610        #[serde(transparent)]
5611        struct Field0 {
5612            pub block_id: BlockId,
5613        }
5614
5615        #[serde_as]
5616        #[derive(Deserialize)]
5617        #[serde(transparent)]
5618        struct Field1 {
5619            #[serde_as(as = "UfeHex")]
5620            pub contract_address: Felt,
5621        }
5622
5623        let temp = serde_json::Value::deserialize(deserializer)?;
5624
5625        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5626            let field1 = serde_json::from_value::<Field1>(
5627                elements
5628                    .pop()
5629                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5630            )
5631            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5632            let field0 = serde_json::from_value::<Field0>(
5633                elements
5634                    .pop()
5635                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5636            )
5637            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5638
5639            Ok(Self {
5640                block_id: field0.block_id,
5641                contract_address: field1.contract_address,
5642            })
5643        } else if let Ok(object) = AsObject::deserialize(&temp) {
5644            Ok(Self {
5645                block_id: object.block_id,
5646                contract_address: object.contract_address,
5647            })
5648        } else {
5649            Err(serde::de::Error::custom("invalid sequence length"))
5650        }
5651    }
5652}
5653
5654impl Serialize for GetClassHashAtRequest {
5655    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5656        #[derive(Serialize)]
5657        #[serde(transparent)]
5658        struct Field0<'a> {
5659            pub block_id: &'a BlockId,
5660        }
5661
5662        #[serde_as]
5663        #[derive(Serialize)]
5664        #[serde(transparent)]
5665        struct Field1<'a> {
5666            #[serde_as(as = "UfeHex")]
5667            pub contract_address: &'a Felt,
5668        }
5669
5670        use serde::ser::SerializeSeq;
5671
5672        let mut seq = serializer.serialize_seq(None)?;
5673
5674        seq.serialize_element(&Field0 {
5675            block_id: &self.block_id,
5676        })?;
5677        seq.serialize_element(&Field1 {
5678            contract_address: &self.contract_address,
5679        })?;
5680
5681        seq.end()
5682    }
5683}
5684
5685impl Serialize for GetClassHashAtRequestRef<'_> {
5686    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5687        #[derive(Serialize)]
5688        #[serde(transparent)]
5689        struct Field0<'a> {
5690            pub block_id: &'a BlockId,
5691        }
5692
5693        #[serde_as]
5694        #[derive(Serialize)]
5695        #[serde(transparent)]
5696        struct Field1<'a> {
5697            #[serde_as(as = "UfeHex")]
5698            pub contract_address: &'a Felt,
5699        }
5700
5701        use serde::ser::SerializeSeq;
5702
5703        let mut seq = serializer.serialize_seq(None)?;
5704
5705        seq.serialize_element(&Field0 {
5706            block_id: self.block_id,
5707        })?;
5708        seq.serialize_element(&Field1 {
5709            contract_address: self.contract_address,
5710        })?;
5711
5712        seq.end()
5713    }
5714}
5715
5716impl<'de> Deserialize<'de> for GetClassHashAtRequest {
5717    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5718        #[serde_as]
5719        #[derive(Deserialize)]
5720        struct AsObject {
5721            pub block_id: BlockId,
5722            #[serde_as(as = "UfeHex")]
5723            pub contract_address: Felt,
5724        }
5725
5726        #[derive(Deserialize)]
5727        #[serde(transparent)]
5728        struct Field0 {
5729            pub block_id: BlockId,
5730        }
5731
5732        #[serde_as]
5733        #[derive(Deserialize)]
5734        #[serde(transparent)]
5735        struct Field1 {
5736            #[serde_as(as = "UfeHex")]
5737            pub contract_address: Felt,
5738        }
5739
5740        let temp = serde_json::Value::deserialize(deserializer)?;
5741
5742        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5743            let field1 = serde_json::from_value::<Field1>(
5744                elements
5745                    .pop()
5746                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5747            )
5748            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5749            let field0 = serde_json::from_value::<Field0>(
5750                elements
5751                    .pop()
5752                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5753            )
5754            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5755
5756            Ok(Self {
5757                block_id: field0.block_id,
5758                contract_address: field1.contract_address,
5759            })
5760        } else if let Ok(object) = AsObject::deserialize(&temp) {
5761            Ok(Self {
5762                block_id: object.block_id,
5763                contract_address: object.contract_address,
5764            })
5765        } else {
5766            Err(serde::de::Error::custom("invalid sequence length"))
5767        }
5768    }
5769}
5770
5771impl Serialize for GetClassRequest {
5772    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5773        #[derive(Serialize)]
5774        #[serde(transparent)]
5775        struct Field0<'a> {
5776            pub block_id: &'a BlockId,
5777        }
5778
5779        #[serde_as]
5780        #[derive(Serialize)]
5781        #[serde(transparent)]
5782        struct Field1<'a> {
5783            #[serde_as(as = "UfeHex")]
5784            pub class_hash: &'a Felt,
5785        }
5786
5787        use serde::ser::SerializeSeq;
5788
5789        let mut seq = serializer.serialize_seq(None)?;
5790
5791        seq.serialize_element(&Field0 {
5792            block_id: &self.block_id,
5793        })?;
5794        seq.serialize_element(&Field1 {
5795            class_hash: &self.class_hash,
5796        })?;
5797
5798        seq.end()
5799    }
5800}
5801
5802impl Serialize for GetClassRequestRef<'_> {
5803    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5804        #[derive(Serialize)]
5805        #[serde(transparent)]
5806        struct Field0<'a> {
5807            pub block_id: &'a BlockId,
5808        }
5809
5810        #[serde_as]
5811        #[derive(Serialize)]
5812        #[serde(transparent)]
5813        struct Field1<'a> {
5814            #[serde_as(as = "UfeHex")]
5815            pub class_hash: &'a Felt,
5816        }
5817
5818        use serde::ser::SerializeSeq;
5819
5820        let mut seq = serializer.serialize_seq(None)?;
5821
5822        seq.serialize_element(&Field0 {
5823            block_id: self.block_id,
5824        })?;
5825        seq.serialize_element(&Field1 {
5826            class_hash: self.class_hash,
5827        })?;
5828
5829        seq.end()
5830    }
5831}
5832
5833impl<'de> Deserialize<'de> for GetClassRequest {
5834    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5835        #[serde_as]
5836        #[derive(Deserialize)]
5837        struct AsObject {
5838            pub block_id: BlockId,
5839            #[serde_as(as = "UfeHex")]
5840            pub class_hash: Felt,
5841        }
5842
5843        #[derive(Deserialize)]
5844        #[serde(transparent)]
5845        struct Field0 {
5846            pub block_id: BlockId,
5847        }
5848
5849        #[serde_as]
5850        #[derive(Deserialize)]
5851        #[serde(transparent)]
5852        struct Field1 {
5853            #[serde_as(as = "UfeHex")]
5854            pub class_hash: Felt,
5855        }
5856
5857        let temp = serde_json::Value::deserialize(deserializer)?;
5858
5859        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5860            let field1 = serde_json::from_value::<Field1>(
5861                elements
5862                    .pop()
5863                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5864            )
5865            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5866            let field0 = serde_json::from_value::<Field0>(
5867                elements
5868                    .pop()
5869                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5870            )
5871            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5872
5873            Ok(Self {
5874                block_id: field0.block_id,
5875                class_hash: field1.class_hash,
5876            })
5877        } else if let Ok(object) = AsObject::deserialize(&temp) {
5878            Ok(Self {
5879                block_id: object.block_id,
5880                class_hash: object.class_hash,
5881            })
5882        } else {
5883            Err(serde::de::Error::custom("invalid sequence length"))
5884        }
5885    }
5886}
5887
5888impl Serialize for GetEventsRequest {
5889    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5890        #[derive(Serialize)]
5891        #[serde(transparent)]
5892        struct Field0<'a> {
5893            pub filter: &'a EventFilterWithPage,
5894        }
5895
5896        use serde::ser::SerializeSeq;
5897
5898        let mut seq = serializer.serialize_seq(None)?;
5899
5900        seq.serialize_element(&Field0 {
5901            filter: &self.filter,
5902        })?;
5903
5904        seq.end()
5905    }
5906}
5907
5908impl Serialize for GetEventsRequestRef<'_> {
5909    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5910        #[derive(Serialize)]
5911        #[serde(transparent)]
5912        struct Field0<'a> {
5913            pub filter: &'a EventFilterWithPage,
5914        }
5915
5916        use serde::ser::SerializeSeq;
5917
5918        let mut seq = serializer.serialize_seq(None)?;
5919
5920        seq.serialize_element(&Field0 {
5921            filter: self.filter,
5922        })?;
5923
5924        seq.end()
5925    }
5926}
5927
5928impl<'de> Deserialize<'de> for GetEventsRequest {
5929    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5930        #[serde_as]
5931        #[derive(Deserialize)]
5932        struct AsObject {
5933            pub filter: EventFilterWithPage,
5934        }
5935
5936        #[derive(Deserialize)]
5937        #[serde(transparent)]
5938        struct Field0 {
5939            pub filter: EventFilterWithPage,
5940        }
5941
5942        let temp = serde_json::Value::deserialize(deserializer)?;
5943
5944        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
5945            let field0 = serde_json::from_value::<Field0>(
5946                elements
5947                    .pop()
5948                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
5949            )
5950            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
5951
5952            Ok(Self {
5953                filter: field0.filter,
5954            })
5955        } else if let Ok(object) = AsObject::deserialize(&temp) {
5956            Ok(Self {
5957                filter: object.filter,
5958            })
5959        } else {
5960            Err(serde::de::Error::custom("invalid sequence length"))
5961        }
5962    }
5963}
5964
5965impl Serialize for GetNonceRequest {
5966    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5967        #[derive(Serialize)]
5968        #[serde(transparent)]
5969        struct Field0<'a> {
5970            pub block_id: &'a BlockId,
5971        }
5972
5973        #[serde_as]
5974        #[derive(Serialize)]
5975        #[serde(transparent)]
5976        struct Field1<'a> {
5977            #[serde_as(as = "UfeHex")]
5978            pub contract_address: &'a Felt,
5979        }
5980
5981        use serde::ser::SerializeSeq;
5982
5983        let mut seq = serializer.serialize_seq(None)?;
5984
5985        seq.serialize_element(&Field0 {
5986            block_id: &self.block_id,
5987        })?;
5988        seq.serialize_element(&Field1 {
5989            contract_address: &self.contract_address,
5990        })?;
5991
5992        seq.end()
5993    }
5994}
5995
5996impl Serialize for GetNonceRequestRef<'_> {
5997    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5998        #[derive(Serialize)]
5999        #[serde(transparent)]
6000        struct Field0<'a> {
6001            pub block_id: &'a BlockId,
6002        }
6003
6004        #[serde_as]
6005        #[derive(Serialize)]
6006        #[serde(transparent)]
6007        struct Field1<'a> {
6008            #[serde_as(as = "UfeHex")]
6009            pub contract_address: &'a Felt,
6010        }
6011
6012        use serde::ser::SerializeSeq;
6013
6014        let mut seq = serializer.serialize_seq(None)?;
6015
6016        seq.serialize_element(&Field0 {
6017            block_id: self.block_id,
6018        })?;
6019        seq.serialize_element(&Field1 {
6020            contract_address: self.contract_address,
6021        })?;
6022
6023        seq.end()
6024    }
6025}
6026
6027impl<'de> Deserialize<'de> for GetNonceRequest {
6028    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6029        #[serde_as]
6030        #[derive(Deserialize)]
6031        struct AsObject {
6032            pub block_id: BlockId,
6033            #[serde_as(as = "UfeHex")]
6034            pub contract_address: Felt,
6035        }
6036
6037        #[derive(Deserialize)]
6038        #[serde(transparent)]
6039        struct Field0 {
6040            pub block_id: BlockId,
6041        }
6042
6043        #[serde_as]
6044        #[derive(Deserialize)]
6045        #[serde(transparent)]
6046        struct Field1 {
6047            #[serde_as(as = "UfeHex")]
6048            pub contract_address: Felt,
6049        }
6050
6051        let temp = serde_json::Value::deserialize(deserializer)?;
6052
6053        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6054            let field1 = serde_json::from_value::<Field1>(
6055                elements
6056                    .pop()
6057                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6058            )
6059            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6060            let field0 = serde_json::from_value::<Field0>(
6061                elements
6062                    .pop()
6063                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6064            )
6065            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6066
6067            Ok(Self {
6068                block_id: field0.block_id,
6069                contract_address: field1.contract_address,
6070            })
6071        } else if let Ok(object) = AsObject::deserialize(&temp) {
6072            Ok(Self {
6073                block_id: object.block_id,
6074                contract_address: object.contract_address,
6075            })
6076        } else {
6077            Err(serde::de::Error::custom("invalid sequence length"))
6078        }
6079    }
6080}
6081
6082impl Serialize for GetStateUpdateRequest {
6083    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6084        #[derive(Serialize)]
6085        #[serde(transparent)]
6086        struct Field0<'a> {
6087            pub block_id: &'a BlockId,
6088        }
6089
6090        use serde::ser::SerializeSeq;
6091
6092        let mut seq = serializer.serialize_seq(None)?;
6093
6094        seq.serialize_element(&Field0 {
6095            block_id: &self.block_id,
6096        })?;
6097
6098        seq.end()
6099    }
6100}
6101
6102impl Serialize for GetStateUpdateRequestRef<'_> {
6103    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6104        #[derive(Serialize)]
6105        #[serde(transparent)]
6106        struct Field0<'a> {
6107            pub block_id: &'a BlockId,
6108        }
6109
6110        use serde::ser::SerializeSeq;
6111
6112        let mut seq = serializer.serialize_seq(None)?;
6113
6114        seq.serialize_element(&Field0 {
6115            block_id: self.block_id,
6116        })?;
6117
6118        seq.end()
6119    }
6120}
6121
6122impl<'de> Deserialize<'de> for GetStateUpdateRequest {
6123    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6124        #[serde_as]
6125        #[derive(Deserialize)]
6126        struct AsObject {
6127            pub block_id: BlockId,
6128        }
6129
6130        #[derive(Deserialize)]
6131        #[serde(transparent)]
6132        struct Field0 {
6133            pub block_id: BlockId,
6134        }
6135
6136        let temp = serde_json::Value::deserialize(deserializer)?;
6137
6138        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6139            let field0 = serde_json::from_value::<Field0>(
6140                elements
6141                    .pop()
6142                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6143            )
6144            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6145
6146            Ok(Self {
6147                block_id: field0.block_id,
6148            })
6149        } else if let Ok(object) = AsObject::deserialize(&temp) {
6150            Ok(Self {
6151                block_id: object.block_id,
6152            })
6153        } else {
6154            Err(serde::de::Error::custom("invalid sequence length"))
6155        }
6156    }
6157}
6158
6159impl Serialize for GetStorageAtRequest {
6160    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6161        #[serde_as]
6162        #[derive(Serialize)]
6163        #[serde(transparent)]
6164        struct Field0<'a> {
6165            #[serde_as(as = "UfeHex")]
6166            pub contract_address: &'a Felt,
6167        }
6168
6169        #[serde_as]
6170        #[derive(Serialize)]
6171        #[serde(transparent)]
6172        struct Field1<'a> {
6173            #[serde_as(as = "UfeHex")]
6174            pub key: &'a Felt,
6175        }
6176
6177        #[derive(Serialize)]
6178        #[serde(transparent)]
6179        struct Field2<'a> {
6180            pub block_id: &'a BlockId,
6181        }
6182
6183        use serde::ser::SerializeSeq;
6184
6185        let mut seq = serializer.serialize_seq(None)?;
6186
6187        seq.serialize_element(&Field0 {
6188            contract_address: &self.contract_address,
6189        })?;
6190        seq.serialize_element(&Field1 { key: &self.key })?;
6191        seq.serialize_element(&Field2 {
6192            block_id: &self.block_id,
6193        })?;
6194
6195        seq.end()
6196    }
6197}
6198
6199impl Serialize for GetStorageAtRequestRef<'_> {
6200    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6201        #[serde_as]
6202        #[derive(Serialize)]
6203        #[serde(transparent)]
6204        struct Field0<'a> {
6205            #[serde_as(as = "UfeHex")]
6206            pub contract_address: &'a Felt,
6207        }
6208
6209        #[serde_as]
6210        #[derive(Serialize)]
6211        #[serde(transparent)]
6212        struct Field1<'a> {
6213            #[serde_as(as = "UfeHex")]
6214            pub key: &'a Felt,
6215        }
6216
6217        #[derive(Serialize)]
6218        #[serde(transparent)]
6219        struct Field2<'a> {
6220            pub block_id: &'a BlockId,
6221        }
6222
6223        use serde::ser::SerializeSeq;
6224
6225        let mut seq = serializer.serialize_seq(None)?;
6226
6227        seq.serialize_element(&Field0 {
6228            contract_address: self.contract_address,
6229        })?;
6230        seq.serialize_element(&Field1 { key: self.key })?;
6231        seq.serialize_element(&Field2 {
6232            block_id: self.block_id,
6233        })?;
6234
6235        seq.end()
6236    }
6237}
6238
6239impl<'de> Deserialize<'de> for GetStorageAtRequest {
6240    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6241        #[serde_as]
6242        #[derive(Deserialize)]
6243        struct AsObject {
6244            #[serde_as(as = "UfeHex")]
6245            pub contract_address: Felt,
6246            #[serde_as(as = "UfeHex")]
6247            pub key: Felt,
6248            pub block_id: BlockId,
6249        }
6250
6251        #[serde_as]
6252        #[derive(Deserialize)]
6253        #[serde(transparent)]
6254        struct Field0 {
6255            #[serde_as(as = "UfeHex")]
6256            pub contract_address: Felt,
6257        }
6258
6259        #[serde_as]
6260        #[derive(Deserialize)]
6261        #[serde(transparent)]
6262        struct Field1 {
6263            #[serde_as(as = "UfeHex")]
6264            pub key: Felt,
6265        }
6266
6267        #[derive(Deserialize)]
6268        #[serde(transparent)]
6269        struct Field2 {
6270            pub block_id: BlockId,
6271        }
6272
6273        let temp = serde_json::Value::deserialize(deserializer)?;
6274
6275        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6276            let field2 = serde_json::from_value::<Field2>(
6277                elements
6278                    .pop()
6279                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6280            )
6281            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6282            let field1 = serde_json::from_value::<Field1>(
6283                elements
6284                    .pop()
6285                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6286            )
6287            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6288            let field0 = serde_json::from_value::<Field0>(
6289                elements
6290                    .pop()
6291                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6292            )
6293            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6294
6295            Ok(Self {
6296                contract_address: field0.contract_address,
6297                key: field1.key,
6298                block_id: field2.block_id,
6299            })
6300        } else if let Ok(object) = AsObject::deserialize(&temp) {
6301            Ok(Self {
6302                contract_address: object.contract_address,
6303                key: object.key,
6304                block_id: object.block_id,
6305            })
6306        } else {
6307            Err(serde::de::Error::custom("invalid sequence length"))
6308        }
6309    }
6310}
6311
6312impl Serialize for GetTransactionByBlockIdAndIndexRequest {
6313    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6314        #[derive(Serialize)]
6315        #[serde(transparent)]
6316        struct Field0<'a> {
6317            pub block_id: &'a BlockId,
6318        }
6319
6320        #[derive(Serialize)]
6321        #[serde(transparent)]
6322        struct Field1<'a> {
6323            pub index: &'a u64,
6324        }
6325
6326        use serde::ser::SerializeSeq;
6327
6328        let mut seq = serializer.serialize_seq(None)?;
6329
6330        seq.serialize_element(&Field0 {
6331            block_id: &self.block_id,
6332        })?;
6333        seq.serialize_element(&Field1 { index: &self.index })?;
6334
6335        seq.end()
6336    }
6337}
6338
6339impl Serialize for GetTransactionByBlockIdAndIndexRequestRef<'_> {
6340    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6341        #[derive(Serialize)]
6342        #[serde(transparent)]
6343        struct Field0<'a> {
6344            pub block_id: &'a BlockId,
6345        }
6346
6347        #[derive(Serialize)]
6348        #[serde(transparent)]
6349        struct Field1<'a> {
6350            pub index: &'a u64,
6351        }
6352
6353        use serde::ser::SerializeSeq;
6354
6355        let mut seq = serializer.serialize_seq(None)?;
6356
6357        seq.serialize_element(&Field0 {
6358            block_id: self.block_id,
6359        })?;
6360        seq.serialize_element(&Field1 { index: self.index })?;
6361
6362        seq.end()
6363    }
6364}
6365
6366impl<'de> Deserialize<'de> for GetTransactionByBlockIdAndIndexRequest {
6367    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6368        #[serde_as]
6369        #[derive(Deserialize)]
6370        struct AsObject {
6371            pub block_id: BlockId,
6372            pub index: u64,
6373        }
6374
6375        #[derive(Deserialize)]
6376        #[serde(transparent)]
6377        struct Field0 {
6378            pub block_id: BlockId,
6379        }
6380
6381        #[derive(Deserialize)]
6382        #[serde(transparent)]
6383        struct Field1 {
6384            pub index: u64,
6385        }
6386
6387        let temp = serde_json::Value::deserialize(deserializer)?;
6388
6389        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6390            let field1 = serde_json::from_value::<Field1>(
6391                elements
6392                    .pop()
6393                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6394            )
6395            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6396            let field0 = serde_json::from_value::<Field0>(
6397                elements
6398                    .pop()
6399                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6400            )
6401            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6402
6403            Ok(Self {
6404                block_id: field0.block_id,
6405                index: field1.index,
6406            })
6407        } else if let Ok(object) = AsObject::deserialize(&temp) {
6408            Ok(Self {
6409                block_id: object.block_id,
6410                index: object.index,
6411            })
6412        } else {
6413            Err(serde::de::Error::custom("invalid sequence length"))
6414        }
6415    }
6416}
6417
6418impl Serialize for GetTransactionByHashRequest {
6419    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6420        #[serde_as]
6421        #[derive(Serialize)]
6422        #[serde(transparent)]
6423        struct Field0<'a> {
6424            #[serde_as(as = "UfeHex")]
6425            pub transaction_hash: &'a Felt,
6426        }
6427
6428        use serde::ser::SerializeSeq;
6429
6430        let mut seq = serializer.serialize_seq(None)?;
6431
6432        seq.serialize_element(&Field0 {
6433            transaction_hash: &self.transaction_hash,
6434        })?;
6435
6436        seq.end()
6437    }
6438}
6439
6440impl Serialize for GetTransactionByHashRequestRef<'_> {
6441    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6442        #[serde_as]
6443        #[derive(Serialize)]
6444        #[serde(transparent)]
6445        struct Field0<'a> {
6446            #[serde_as(as = "UfeHex")]
6447            pub transaction_hash: &'a Felt,
6448        }
6449
6450        use serde::ser::SerializeSeq;
6451
6452        let mut seq = serializer.serialize_seq(None)?;
6453
6454        seq.serialize_element(&Field0 {
6455            transaction_hash: self.transaction_hash,
6456        })?;
6457
6458        seq.end()
6459    }
6460}
6461
6462impl<'de> Deserialize<'de> for GetTransactionByHashRequest {
6463    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6464        #[serde_as]
6465        #[derive(Deserialize)]
6466        struct AsObject {
6467            #[serde_as(as = "UfeHex")]
6468            pub transaction_hash: Felt,
6469        }
6470
6471        #[serde_as]
6472        #[derive(Deserialize)]
6473        #[serde(transparent)]
6474        struct Field0 {
6475            #[serde_as(as = "UfeHex")]
6476            pub transaction_hash: Felt,
6477        }
6478
6479        let temp = serde_json::Value::deserialize(deserializer)?;
6480
6481        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6482            let field0 = serde_json::from_value::<Field0>(
6483                elements
6484                    .pop()
6485                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6486            )
6487            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6488
6489            Ok(Self {
6490                transaction_hash: field0.transaction_hash,
6491            })
6492        } else if let Ok(object) = AsObject::deserialize(&temp) {
6493            Ok(Self {
6494                transaction_hash: object.transaction_hash,
6495            })
6496        } else {
6497            Err(serde::de::Error::custom("invalid sequence length"))
6498        }
6499    }
6500}
6501
6502impl Serialize for GetTransactionReceiptRequest {
6503    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6504        #[serde_as]
6505        #[derive(Serialize)]
6506        #[serde(transparent)]
6507        struct Field0<'a> {
6508            #[serde_as(as = "UfeHex")]
6509            pub transaction_hash: &'a Felt,
6510        }
6511
6512        use serde::ser::SerializeSeq;
6513
6514        let mut seq = serializer.serialize_seq(None)?;
6515
6516        seq.serialize_element(&Field0 {
6517            transaction_hash: &self.transaction_hash,
6518        })?;
6519
6520        seq.end()
6521    }
6522}
6523
6524impl Serialize for GetTransactionReceiptRequestRef<'_> {
6525    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6526        #[serde_as]
6527        #[derive(Serialize)]
6528        #[serde(transparent)]
6529        struct Field0<'a> {
6530            #[serde_as(as = "UfeHex")]
6531            pub transaction_hash: &'a Felt,
6532        }
6533
6534        use serde::ser::SerializeSeq;
6535
6536        let mut seq = serializer.serialize_seq(None)?;
6537
6538        seq.serialize_element(&Field0 {
6539            transaction_hash: self.transaction_hash,
6540        })?;
6541
6542        seq.end()
6543    }
6544}
6545
6546impl<'de> Deserialize<'de> for GetTransactionReceiptRequest {
6547    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6548        #[serde_as]
6549        #[derive(Deserialize)]
6550        struct AsObject {
6551            #[serde_as(as = "UfeHex")]
6552            pub transaction_hash: Felt,
6553        }
6554
6555        #[serde_as]
6556        #[derive(Deserialize)]
6557        #[serde(transparent)]
6558        struct Field0 {
6559            #[serde_as(as = "UfeHex")]
6560            pub transaction_hash: Felt,
6561        }
6562
6563        let temp = serde_json::Value::deserialize(deserializer)?;
6564
6565        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6566            let field0 = serde_json::from_value::<Field0>(
6567                elements
6568                    .pop()
6569                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6570            )
6571            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6572
6573            Ok(Self {
6574                transaction_hash: field0.transaction_hash,
6575            })
6576        } else if let Ok(object) = AsObject::deserialize(&temp) {
6577            Ok(Self {
6578                transaction_hash: object.transaction_hash,
6579            })
6580        } else {
6581            Err(serde::de::Error::custom("invalid sequence length"))
6582        }
6583    }
6584}
6585
6586impl Serialize for GetTransactionStatusRequest {
6587    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6588        #[serde_as]
6589        #[derive(Serialize)]
6590        #[serde(transparent)]
6591        struct Field0<'a> {
6592            #[serde_as(as = "UfeHex")]
6593            pub transaction_hash: &'a Felt,
6594        }
6595
6596        use serde::ser::SerializeSeq;
6597
6598        let mut seq = serializer.serialize_seq(None)?;
6599
6600        seq.serialize_element(&Field0 {
6601            transaction_hash: &self.transaction_hash,
6602        })?;
6603
6604        seq.end()
6605    }
6606}
6607
6608impl Serialize for GetTransactionStatusRequestRef<'_> {
6609    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6610        #[serde_as]
6611        #[derive(Serialize)]
6612        #[serde(transparent)]
6613        struct Field0<'a> {
6614            #[serde_as(as = "UfeHex")]
6615            pub transaction_hash: &'a Felt,
6616        }
6617
6618        use serde::ser::SerializeSeq;
6619
6620        let mut seq = serializer.serialize_seq(None)?;
6621
6622        seq.serialize_element(&Field0 {
6623            transaction_hash: self.transaction_hash,
6624        })?;
6625
6626        seq.end()
6627    }
6628}
6629
6630impl<'de> Deserialize<'de> for GetTransactionStatusRequest {
6631    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6632        #[serde_as]
6633        #[derive(Deserialize)]
6634        struct AsObject {
6635            #[serde_as(as = "UfeHex")]
6636            pub transaction_hash: Felt,
6637        }
6638
6639        #[serde_as]
6640        #[derive(Deserialize)]
6641        #[serde(transparent)]
6642        struct Field0 {
6643            #[serde_as(as = "UfeHex")]
6644            pub transaction_hash: Felt,
6645        }
6646
6647        let temp = serde_json::Value::deserialize(deserializer)?;
6648
6649        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6650            let field0 = serde_json::from_value::<Field0>(
6651                elements
6652                    .pop()
6653                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6654            )
6655            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6656
6657            Ok(Self {
6658                transaction_hash: field0.transaction_hash,
6659            })
6660        } else if let Ok(object) = AsObject::deserialize(&temp) {
6661            Ok(Self {
6662                transaction_hash: object.transaction_hash,
6663            })
6664        } else {
6665            Err(serde::de::Error::custom("invalid sequence length"))
6666        }
6667    }
6668}
6669
6670impl Serialize for SimulateTransactionsRequest {
6671    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6672        #[derive(Serialize)]
6673        #[serde(transparent)]
6674        struct Field0<'a> {
6675            pub block_id: &'a BlockId,
6676        }
6677
6678        #[derive(Serialize)]
6679        #[serde(transparent)]
6680        struct Field1<'a> {
6681            pub transactions: &'a [BroadcastedTransaction],
6682        }
6683
6684        #[derive(Serialize)]
6685        #[serde(transparent)]
6686        struct Field2<'a> {
6687            pub simulation_flags: &'a [SimulationFlag],
6688        }
6689
6690        use serde::ser::SerializeSeq;
6691
6692        let mut seq = serializer.serialize_seq(None)?;
6693
6694        seq.serialize_element(&Field0 {
6695            block_id: &self.block_id,
6696        })?;
6697        seq.serialize_element(&Field1 {
6698            transactions: &self.transactions,
6699        })?;
6700        seq.serialize_element(&Field2 {
6701            simulation_flags: &self.simulation_flags,
6702        })?;
6703
6704        seq.end()
6705    }
6706}
6707
6708impl Serialize for SimulateTransactionsRequestRef<'_> {
6709    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6710        #[derive(Serialize)]
6711        #[serde(transparent)]
6712        struct Field0<'a> {
6713            pub block_id: &'a BlockId,
6714        }
6715
6716        #[derive(Serialize)]
6717        #[serde(transparent)]
6718        struct Field1<'a> {
6719            pub transactions: &'a [BroadcastedTransaction],
6720        }
6721
6722        #[derive(Serialize)]
6723        #[serde(transparent)]
6724        struct Field2<'a> {
6725            pub simulation_flags: &'a [SimulationFlag],
6726        }
6727
6728        use serde::ser::SerializeSeq;
6729
6730        let mut seq = serializer.serialize_seq(None)?;
6731
6732        seq.serialize_element(&Field0 {
6733            block_id: self.block_id,
6734        })?;
6735        seq.serialize_element(&Field1 {
6736            transactions: self.transactions,
6737        })?;
6738        seq.serialize_element(&Field2 {
6739            simulation_flags: self.simulation_flags,
6740        })?;
6741
6742        seq.end()
6743    }
6744}
6745
6746impl<'de> Deserialize<'de> for SimulateTransactionsRequest {
6747    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6748        #[serde_as]
6749        #[derive(Deserialize)]
6750        struct AsObject {
6751            pub block_id: BlockId,
6752            pub transactions: Vec<BroadcastedTransaction>,
6753            pub simulation_flags: Vec<SimulationFlag>,
6754        }
6755
6756        #[derive(Deserialize)]
6757        #[serde(transparent)]
6758        struct Field0 {
6759            pub block_id: BlockId,
6760        }
6761
6762        #[derive(Deserialize)]
6763        #[serde(transparent)]
6764        struct Field1 {
6765            pub transactions: Vec<BroadcastedTransaction>,
6766        }
6767
6768        #[derive(Deserialize)]
6769        #[serde(transparent)]
6770        struct Field2 {
6771            pub simulation_flags: Vec<SimulationFlag>,
6772        }
6773
6774        let temp = serde_json::Value::deserialize(deserializer)?;
6775
6776        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6777            let field2 = serde_json::from_value::<Field2>(
6778                elements
6779                    .pop()
6780                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6781            )
6782            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6783            let field1 = serde_json::from_value::<Field1>(
6784                elements
6785                    .pop()
6786                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6787            )
6788            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6789            let field0 = serde_json::from_value::<Field0>(
6790                elements
6791                    .pop()
6792                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6793            )
6794            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6795
6796            Ok(Self {
6797                block_id: field0.block_id,
6798                transactions: field1.transactions,
6799                simulation_flags: field2.simulation_flags,
6800            })
6801        } else if let Ok(object) = AsObject::deserialize(&temp) {
6802            Ok(Self {
6803                block_id: object.block_id,
6804                transactions: object.transactions,
6805                simulation_flags: object.simulation_flags,
6806            })
6807        } else {
6808            Err(serde::de::Error::custom("invalid sequence length"))
6809        }
6810    }
6811}
6812
6813impl Serialize for SpecVersionRequest {
6814    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6815        use serde::ser::SerializeSeq;
6816
6817        let seq = serializer.serialize_seq(Some(0))?;
6818        seq.end()
6819    }
6820}
6821
6822impl<'de> Deserialize<'de> for SpecVersionRequest {
6823    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6824        let elements = Vec::<()>::deserialize(deserializer)?;
6825        if !elements.is_empty() {
6826            return Err(serde::de::Error::custom("invalid sequence length"));
6827        }
6828        Ok(Self)
6829    }
6830}
6831
6832impl Serialize for SyncingRequest {
6833    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6834        use serde::ser::SerializeSeq;
6835
6836        let seq = serializer.serialize_seq(Some(0))?;
6837        seq.end()
6838    }
6839}
6840
6841impl<'de> Deserialize<'de> for SyncingRequest {
6842    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6843        let elements = Vec::<()>::deserialize(deserializer)?;
6844        if !elements.is_empty() {
6845            return Err(serde::de::Error::custom("invalid sequence length"));
6846        }
6847        Ok(Self)
6848    }
6849}
6850
6851impl Serialize for TraceBlockTransactionsRequest {
6852    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6853        #[derive(Serialize)]
6854        #[serde(transparent)]
6855        struct Field0<'a> {
6856            pub block_id: &'a BlockId,
6857        }
6858
6859        use serde::ser::SerializeSeq;
6860
6861        let mut seq = serializer.serialize_seq(None)?;
6862
6863        seq.serialize_element(&Field0 {
6864            block_id: &self.block_id,
6865        })?;
6866
6867        seq.end()
6868    }
6869}
6870
6871impl Serialize for TraceBlockTransactionsRequestRef<'_> {
6872    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6873        #[derive(Serialize)]
6874        #[serde(transparent)]
6875        struct Field0<'a> {
6876            pub block_id: &'a BlockId,
6877        }
6878
6879        use serde::ser::SerializeSeq;
6880
6881        let mut seq = serializer.serialize_seq(None)?;
6882
6883        seq.serialize_element(&Field0 {
6884            block_id: self.block_id,
6885        })?;
6886
6887        seq.end()
6888    }
6889}
6890
6891impl<'de> Deserialize<'de> for TraceBlockTransactionsRequest {
6892    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6893        #[serde_as]
6894        #[derive(Deserialize)]
6895        struct AsObject {
6896            pub block_id: BlockId,
6897        }
6898
6899        #[derive(Deserialize)]
6900        #[serde(transparent)]
6901        struct Field0 {
6902            pub block_id: BlockId,
6903        }
6904
6905        let temp = serde_json::Value::deserialize(deserializer)?;
6906
6907        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6908            let field0 = serde_json::from_value::<Field0>(
6909                elements
6910                    .pop()
6911                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6912            )
6913            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6914
6915            Ok(Self {
6916                block_id: field0.block_id,
6917            })
6918        } else if let Ok(object) = AsObject::deserialize(&temp) {
6919            Ok(Self {
6920                block_id: object.block_id,
6921            })
6922        } else {
6923            Err(serde::de::Error::custom("invalid sequence length"))
6924        }
6925    }
6926}
6927
6928impl Serialize for TraceTransactionRequest {
6929    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6930        #[serde_as]
6931        #[derive(Serialize)]
6932        #[serde(transparent)]
6933        struct Field0<'a> {
6934            #[serde_as(as = "UfeHex")]
6935            pub transaction_hash: &'a Felt,
6936        }
6937
6938        use serde::ser::SerializeSeq;
6939
6940        let mut seq = serializer.serialize_seq(None)?;
6941
6942        seq.serialize_element(&Field0 {
6943            transaction_hash: &self.transaction_hash,
6944        })?;
6945
6946        seq.end()
6947    }
6948}
6949
6950impl Serialize for TraceTransactionRequestRef<'_> {
6951    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6952        #[serde_as]
6953        #[derive(Serialize)]
6954        #[serde(transparent)]
6955        struct Field0<'a> {
6956            #[serde_as(as = "UfeHex")]
6957            pub transaction_hash: &'a Felt,
6958        }
6959
6960        use serde::ser::SerializeSeq;
6961
6962        let mut seq = serializer.serialize_seq(None)?;
6963
6964        seq.serialize_element(&Field0 {
6965            transaction_hash: self.transaction_hash,
6966        })?;
6967
6968        seq.end()
6969    }
6970}
6971
6972impl<'de> Deserialize<'de> for TraceTransactionRequest {
6973    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6974        #[serde_as]
6975        #[derive(Deserialize)]
6976        struct AsObject {
6977            #[serde_as(as = "UfeHex")]
6978            pub transaction_hash: Felt,
6979        }
6980
6981        #[serde_as]
6982        #[derive(Deserialize)]
6983        #[serde(transparent)]
6984        struct Field0 {
6985            #[serde_as(as = "UfeHex")]
6986            pub transaction_hash: Felt,
6987        }
6988
6989        let temp = serde_json::Value::deserialize(deserializer)?;
6990
6991        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6992            let field0 = serde_json::from_value::<Field0>(
6993                elements
6994                    .pop()
6995                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6996            )
6997            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {}", err)))?;
6998
6999            Ok(Self {
7000                transaction_hash: field0.transaction_hash,
7001            })
7002        } else if let Ok(object) = AsObject::deserialize(&temp) {
7003            Ok(Self {
7004                transaction_hash: object.transaction_hash,
7005            })
7006        } else {
7007            Err(serde::de::Error::custom("invalid sequence length"))
7008        }
7009    }
7010}