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#29b359aeb373001f024553059cd242f1e91417d1
7
8// These types are ignored from code generation. Implement them manually:
9// - `RECEIPT_BLOCK`
10// - `TXN_STATUS_RESULT`
11// - `SUBSCRIPTION_BLOCK_TAG`
12
13// Code generation requested but not implemented for these types:
14// - `BLOCK_ID`
15// - `BROADCASTED_TXN`
16// - `CONFIRMED_BLOCK_ID`
17// - `CONTRACT_ABI_ENTRY`
18// - `CONTRACT_CLASS`
19// - `CONTRACT_EXECUTION_ERROR`
20// - `DECLARE_TXN`
21// - `DECLARE_TXN_CONTENT`
22// - `DEPLOY_ACCOUNT_TXN`
23// - `DEPLOY_ACCOUNT_TXN_CONTENT`
24// - `EXECUTE_INVOCATION`
25// - `INVOKE_TXN`
26// - `INVOKE_TXN_CONTENT`
27// - `MERKLE_NODE`
28// - `TRANSACTION_TRACE`
29// - `TXN`
30// - `TXN_CONTENT`
31// - `TXN_RECEIPT`
32
33#![allow(missing_docs)]
34#![allow(clippy::doc_markdown)]
35#![allow(clippy::missing_const_for_fn)]
36
37use alloc::{format, string::*, vec::*};
38
39use indexmap::IndexMap;
40use serde::{Deserialize, Deserializer, Serialize, Serializer};
41use serde_with::serde_as;
42
43use crate::serde::byte_array::base64;
44
45use super::{
46    serde_impls::{MerkleNodeMap, NumAsHex, OwnedContractExecutionError},
47    *,
48};
49
50#[cfg(target_has_atomic = "ptr")]
51pub type OwnedPtr<T> = alloc::sync::Arc<T>;
52#[cfg(not(target_has_atomic = "ptr"))]
53pub type OwnedPtr<T> = alloc::boxed::Box<T>;
54
55#[cfg(feature = "std")]
56type RandomState = std::hash::RandomState;
57#[cfg(not(feature = "std"))]
58type RandomState = foldhash::fast::RandomState;
59
60const QUERY_VERSION_OFFSET: Felt = Felt::from_raw([
61    576460752142434320,
62    18446744073709551584,
63    17407,
64    18446744073700081665,
65]);
66
67pub type BroadcastedInvokeTransaction = BroadcastedInvokeTransactionV3;
68pub type BroadcastedDeployAccountTransaction = BroadcastedDeployAccountTransactionV3;
69pub type BroadcastedDeclareTransaction = BroadcastedDeclareTransactionV3;
70
71/// An internal node whose both children are non-zero.
72#[serde_as]
73#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
74#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
75pub struct BinaryNode {
76    /// The hash of the left child
77    #[serde_as(as = "UfeHex")]
78    pub left: Felt,
79    /// The hash of the right child
80    #[serde_as(as = "UfeHex")]
81    pub right: Felt,
82}
83
84/// Block header.
85#[serde_as]
86#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
87#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
88pub struct BlockHeader {
89    /// Block hash
90    #[serde_as(as = "UfeHex")]
91    pub block_hash: Felt,
92    /// The hash of this block's parent
93    #[serde_as(as = "UfeHex")]
94    pub parent_hash: Felt,
95    /// The block number (its height)
96    pub block_number: u64,
97    /// The new global state root
98    #[serde_as(as = "UfeHex")]
99    pub new_root: Felt,
100    /// The time in which the block was created, encoded in Unix time
101    pub timestamp: u64,
102    /// The Starknet identity of the sequencer submitting this block
103    #[serde_as(as = "UfeHex")]
104    pub sequencer_address: Felt,
105    /// The price of L1 gas in the block
106    pub l1_gas_price: ResourcePrice,
107    /// The price of L2 gas in the block
108    pub l2_gas_price: ResourcePrice,
109    /// The price of L1 data gas in the block
110    pub l1_data_gas_price: ResourcePrice,
111    /// Specifies whether the data of this block is published via blob data or calldata
112    pub l1_da_mode: L1DataAvailabilityMode,
113    /// Semver of the current Starknet protocol
114    pub starknet_version: String,
115}
116
117/// Block status.
118///
119/// The status of the block.
120#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
121pub enum BlockStatus {
122    #[serde(rename = "PRE_CONFIRMED")]
123    PreConfirmed,
124    #[serde(rename = "ACCEPTED_ON_L2")]
125    AcceptedOnL2,
126    #[serde(rename = "ACCEPTED_ON_L1")]
127    AcceptedOnL1,
128}
129
130/// Block tag.
131///
132/// A tag specifying a dynamic reference to a block. Tag `l1_accepted` refers to the latest Starknet
133/// block which was included in a state update on L1 and finalized by the consensus on L1. Tag
134/// `latest` refers to the latest Starknet block finalized by the consensus on L2. Tag
135/// `pre_confirmed` refers to the block which is currently being built by the block proposer in
136/// height `latest` + 1.
137#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
138pub enum BlockTag {
139    #[serde(rename = "l1_accepted")]
140    L1Accepted,
141    #[serde(rename = "latest")]
142    Latest,
143    #[serde(rename = "pre_confirmed")]
144    PreConfirmed,
145}
146
147/// Block with transactions and receipts.
148///
149/// The block object.
150#[serde_as]
151#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
152#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
153pub struct BlockWithReceipts {
154    /// Status
155    pub status: BlockStatus,
156    /// Block hash
157    #[serde_as(as = "UfeHex")]
158    pub block_hash: Felt,
159    /// The hash of this block's parent
160    #[serde_as(as = "UfeHex")]
161    pub parent_hash: Felt,
162    /// The block number (its height)
163    pub block_number: u64,
164    /// The new global state root
165    #[serde_as(as = "UfeHex")]
166    pub new_root: Felt,
167    /// The time in which the block was created, encoded in Unix time
168    pub timestamp: u64,
169    /// The Starknet identity of the sequencer submitting this block
170    #[serde_as(as = "UfeHex")]
171    pub sequencer_address: Felt,
172    /// The price of L1 gas in the block
173    pub l1_gas_price: ResourcePrice,
174    /// The price of L2 gas in the block
175    pub l2_gas_price: ResourcePrice,
176    /// The price of L1 data gas in the block
177    pub l1_data_gas_price: ResourcePrice,
178    /// Specifies whether the data of this block is published via blob data or calldata
179    pub l1_da_mode: L1DataAvailabilityMode,
180    /// Semver of the current Starknet protocol
181    pub starknet_version: String,
182    /// The transactions in this block
183    pub transactions: Vec<TransactionWithReceipt>,
184}
185
186/// Block with transaction hashes.
187///
188/// The block object.
189#[serde_as]
190#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
191#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
192pub struct BlockWithTxHashes {
193    /// Status
194    pub status: BlockStatus,
195    /// Block hash
196    #[serde_as(as = "UfeHex")]
197    pub block_hash: Felt,
198    /// The hash of this block's parent
199    #[serde_as(as = "UfeHex")]
200    pub parent_hash: Felt,
201    /// The block number (its height)
202    pub block_number: u64,
203    /// The new global state root
204    #[serde_as(as = "UfeHex")]
205    pub new_root: Felt,
206    /// The time in which the block was created, encoded in Unix time
207    pub timestamp: u64,
208    /// The Starknet identity of the sequencer submitting this block
209    #[serde_as(as = "UfeHex")]
210    pub sequencer_address: Felt,
211    /// The price of L1 gas in the block
212    pub l1_gas_price: ResourcePrice,
213    /// The price of L2 gas in the block
214    pub l2_gas_price: ResourcePrice,
215    /// The price of L1 data gas in the block
216    pub l1_data_gas_price: ResourcePrice,
217    /// Specifies whether the data of this block is published via blob data or calldata
218    pub l1_da_mode: L1DataAvailabilityMode,
219    /// Semver of the current Starknet protocol
220    pub starknet_version: String,
221    /// The hashes of the transactions included in this block
222    #[serde_as(as = "Vec<UfeHex>")]
223    pub transactions: Vec<Felt>,
224}
225
226/// Block with transactions.
227///
228/// The block object.
229#[serde_as]
230#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
231#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
232pub struct BlockWithTxs {
233    /// Status
234    pub status: BlockStatus,
235    /// Block hash
236    #[serde_as(as = "UfeHex")]
237    pub block_hash: Felt,
238    /// The hash of this block's parent
239    #[serde_as(as = "UfeHex")]
240    pub parent_hash: Felt,
241    /// The block number (its height)
242    pub block_number: u64,
243    /// The new global state root
244    #[serde_as(as = "UfeHex")]
245    pub new_root: Felt,
246    /// The time in which the block was created, encoded in Unix time
247    pub timestamp: u64,
248    /// The Starknet identity of the sequencer submitting this block
249    #[serde_as(as = "UfeHex")]
250    pub sequencer_address: Felt,
251    /// The price of L1 gas in the block
252    pub l1_gas_price: ResourcePrice,
253    /// The price of L2 gas in the block
254    pub l2_gas_price: ResourcePrice,
255    /// The price of L1 data gas in the block
256    pub l1_data_gas_price: ResourcePrice,
257    /// Specifies whether the data of this block is published via blob data or calldata
258    pub l1_da_mode: L1DataAvailabilityMode,
259    /// Semver of the current Starknet protocol
260    pub starknet_version: String,
261    /// The transactions in this block
262    pub transactions: Vec<Transaction>,
263}
264
265/// Broadcasted declare transaction v3.
266///
267/// Broadcasted declare contract transaction v3.
268#[derive(Debug, Clone, PartialEq, Eq)]
269pub struct BroadcastedDeclareTransactionV3 {
270    /// The address of the account contract sending the declaration transaction
271    pub sender_address: Felt,
272    /// The hash of the cairo assembly resulting from the sierra compilation
273    pub compiled_class_hash: Felt,
274    /// Signature
275    pub signature: Vec<Felt>,
276    /// Nonce
277    pub nonce: Felt,
278    /// The class to be declared
279    pub contract_class: OwnedPtr<FlattenedSierraClass>,
280    /// Resource bounds for the transaction execution
281    pub resource_bounds: ResourceBoundsMapping,
282    /// The tip for the transaction
283    pub tip: u64,
284    /// Data needed to allow the paymaster to pay for the transaction in native tokens
285    pub paymaster_data: Vec<Felt>,
286    /// Data needed to deploy the account contract from which this tx will be initiated
287    pub account_deployment_data: Vec<Felt>,
288    /// The storage domain of the account's nonce (an account has a nonce per da mode)
289    pub nonce_data_availability_mode: DataAvailabilityMode,
290    /// The storage domain of the account's balance from which fee will be charged
291    pub fee_data_availability_mode: DataAvailabilityMode,
292    /// If set to `true`, uses a query-only transaction version that's invalid for execution
293    pub is_query: bool,
294}
295
296#[derive(Debug, Clone, PartialEq, Eq)]
297pub struct BroadcastedDeployAccountTransactionV3 {
298    /// Signature
299    pub signature: Vec<Felt>,
300    /// Nonce
301    pub nonce: Felt,
302    /// The salt for the address of the deployed contract
303    pub contract_address_salt: Felt,
304    /// The parameters passed to the constructor
305    pub constructor_calldata: Vec<Felt>,
306    /// The hash of the deployed contract's class
307    pub class_hash: Felt,
308    /// Resource bounds for the transaction execution
309    pub resource_bounds: ResourceBoundsMapping,
310    /// The tip for the transaction
311    pub tip: u64,
312    /// Data needed to allow the paymaster to pay for the transaction in native tokens
313    pub paymaster_data: Vec<Felt>,
314    /// The storage domain of the account's nonce (an account has a nonce per da mode)
315    pub nonce_data_availability_mode: DataAvailabilityMode,
316    /// The storage domain of the account's balance from which fee will be charged
317    pub fee_data_availability_mode: DataAvailabilityMode,
318    /// If set to `true`, uses a query-only transaction version that's invalid for execution
319    pub is_query: bool,
320}
321
322#[derive(Debug, Clone, PartialEq, Eq)]
323pub struct BroadcastedInvokeTransactionV3 {
324    /// Sender address
325    pub sender_address: Felt,
326    /// The data expected by the account's `execute` function (in most usecases, this includes the
327    /// called contract address and a function selector)
328    pub calldata: Vec<Felt>,
329    /// Signature
330    pub signature: Vec<Felt>,
331    /// Nonce
332    pub nonce: Felt,
333    /// Resource bounds for the transaction execution
334    pub resource_bounds: ResourceBoundsMapping,
335    /// The tip for the transaction
336    pub tip: u64,
337    /// Data needed to allow the paymaster to pay for the transaction in native tokens
338    pub paymaster_data: Vec<Felt>,
339    /// Data needed to deploy the account contract from which this tx will be initiated
340    pub account_deployment_data: Vec<Felt>,
341    /// The storage domain of the account's nonce (an account has a nonce per da mode)
342    pub nonce_data_availability_mode: DataAvailabilityMode,
343    /// The storage domain of the account's balance from which fee will be charged
344    pub fee_data_availability_mode: DataAvailabilityMode,
345    /// If set to `true`, uses a query-only transaction version that's invalid for execution
346    pub is_query: bool,
347}
348
349#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
350pub enum CallType {
351    #[serde(rename = "LIBRARY_CALL")]
352    LibraryCall,
353    #[serde(rename = "CALL")]
354    Call,
355    #[serde(rename = "DELEGATE")]
356    Delegate,
357}
358
359/// Deprecated contract class.
360///
361/// The definition of a Starknet contract class.
362#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
363#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
364pub struct CompressedLegacyContractClass {
365    /// A base64 representation of the compressed program code
366    #[serde(with = "base64")]
367    pub program: Vec<u8>,
368    /// Deprecated entry points by type
369    pub entry_points_by_type: LegacyEntryPointsByType,
370    /// Contract abi
371    #[serde(skip_serializing_if = "Option::is_none")]
372    pub abi: Option<Vec<LegacyContractAbiEntry>>,
373}
374
375/// More data about the execution failure.
376#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
377#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
378pub struct ContractErrorData {
379    /// The execution trace up to the point of failure
380    pub revert_error: ContractExecutionError,
381}
382
383/// The nonce and class hash for each requested contract address, in the order in which they appear
384/// in the request. These values are needed to construct the associated leaf node.
385#[serde_as]
386#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
387#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
388pub struct ContractLeafData {
389    #[serde_as(as = "UfeHex")]
390    pub nonce: Felt,
391    #[serde_as(as = "UfeHex")]
392    pub class_hash: Felt,
393    #[serde(skip_serializing_if = "Option::is_none")]
394    #[serde_as(as = "Option<UfeHex>")]
395    pub storage_root: Option<Felt>,
396}
397
398/// Contract storage diff item.
399#[serde_as]
400#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
401#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
402pub struct ContractStorageDiffItem {
403    /// The contract address for which the storage changed
404    #[serde_as(as = "UfeHex")]
405    pub address: Felt,
406    /// The changes in the storage of the contract
407    pub storage_entries: Vec<StorageEntry>,
408}
409
410#[serde_as]
411#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
412#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
413pub struct ContractStorageKeys {
414    #[serde_as(as = "UfeHex")]
415    pub contract_address: Felt,
416    #[serde_as(as = "Vec<UfeHex>")]
417    pub storage_keys: Vec<Felt>,
418}
419
420#[serde_as]
421#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
422#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
423pub struct ContractsProof {
424    /// The nodes in the union of the paths from the contracts tree root to the requested leaves
425    #[serde_as(as = "MerkleNodeMap")]
426    pub nodes: IndexMap<Felt, MerkleNode, RandomState>,
427    pub contract_leaves_data: Vec<ContractLeafData>,
428}
429
430/// Da mode.
431///
432/// Specifies a storage domain in Starknet. Each domain has different guarantees regarding
433/// availability.
434#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
435pub enum DataAvailabilityMode {
436    #[serde(rename = "L1")]
437    L1,
438    #[serde(rename = "L2")]
439    L2,
440}
441
442/// Declare transaction receipt.
443#[derive(Debug, Clone, PartialEq, Eq)]
444pub struct DeclareTransactionReceipt {
445    /// The hash identifying the transaction
446    pub transaction_hash: Felt,
447    /// The fee that was charged by the sequencer
448    pub actual_fee: FeePayment,
449    /// Finality status of the tx
450    pub finality_status: TransactionFinalityStatus,
451    /// Messages sent
452    pub messages_sent: Vec<MsgToL1>,
453    /// The events emitted as part of this transaction
454    pub events: Vec<Event>,
455    /// The resources consumed by the transaction
456    pub execution_resources: ExecutionResources,
457    pub execution_result: ExecutionResult,
458}
459
460/// The execution trace of a declare transaction.
461#[derive(Debug, Clone, PartialEq, Eq)]
462pub struct DeclareTransactionTrace {
463    pub validate_invocation: Option<FunctionInvocation>,
464    pub fee_transfer_invocation: Option<FunctionInvocation>,
465    /// The state diffs induced by the transaction
466    pub state_diff: Option<StateDiff>,
467    /// The resources consumed by the transaction, includes both computation and data
468    pub execution_resources: ExecutionResources,
469}
470
471/// Declare contract transaction v0.
472///
473/// Declare contract transaction v0.
474#[derive(Debug, Clone, PartialEq, Eq)]
475pub struct DeclareTransactionV0 {
476    /// Transaction hash
477    pub transaction_hash: Felt,
478    /// The address of the account contract sending the declaration transaction
479    pub sender_address: Felt,
480    /// The maximal fee that can be charged for including the transaction
481    pub max_fee: Felt,
482    /// Signature
483    pub signature: Vec<Felt>,
484    /// The hash of the declared class
485    pub class_hash: Felt,
486}
487
488/// Declare txn v0.
489#[derive(Debug, Clone, PartialEq, Eq)]
490pub struct DeclareTransactionV0Content {
491    /// The address of the account contract sending the declaration transaction
492    pub sender_address: Felt,
493    /// The maximal fee that can be charged for including the transaction
494    pub max_fee: Felt,
495    /// Signature
496    pub signature: Vec<Felt>,
497    /// The hash of the declared class
498    pub class_hash: Felt,
499}
500
501/// Declare contract transaction v1.
502///
503/// Declare contract transaction v1.
504#[derive(Debug, Clone, PartialEq, Eq)]
505pub struct DeclareTransactionV1 {
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    /// Nonce
515    pub nonce: Felt,
516    /// The hash of the declared class
517    pub class_hash: Felt,
518}
519
520/// Declare txn v1.
521#[derive(Debug, Clone, PartialEq, Eq)]
522pub struct DeclareTransactionV1Content {
523    /// The address of the account contract sending the declaration transaction
524    pub sender_address: Felt,
525    /// The maximal fee that can be charged for including the transaction
526    pub max_fee: Felt,
527    /// Signature
528    pub signature: Vec<Felt>,
529    /// Nonce
530    pub nonce: Felt,
531    /// The hash of the declared class
532    pub class_hash: Felt,
533}
534
535/// Declare transaction v2.
536///
537/// Declare contract transaction v2.
538#[derive(Debug, Clone, PartialEq, Eq)]
539pub struct DeclareTransactionV2 {
540    /// Transaction hash
541    pub transaction_hash: Felt,
542    /// The address of the account contract sending the declaration transaction
543    pub sender_address: Felt,
544    /// The hash of the cairo assembly resulting from the sierra compilation
545    pub compiled_class_hash: Felt,
546    /// The maximal fee that can be charged for including the transaction
547    pub max_fee: Felt,
548    /// Signature
549    pub signature: Vec<Felt>,
550    /// Nonce
551    pub nonce: Felt,
552    /// The hash of the declared class
553    pub class_hash: Felt,
554}
555
556/// Declare txn v2.
557#[derive(Debug, Clone, PartialEq, Eq)]
558pub struct DeclareTransactionV2Content {
559    /// The address of the account contract sending the declaration transaction
560    pub sender_address: Felt,
561    /// The hash of the cairo assembly resulting from the sierra compilation
562    pub compiled_class_hash: Felt,
563    /// The maximal fee that can be charged for including the transaction
564    pub max_fee: Felt,
565    /// Signature
566    pub signature: Vec<Felt>,
567    /// Nonce
568    pub nonce: Felt,
569    /// The hash of the declared class
570    pub class_hash: Felt,
571}
572
573/// Declare transaction v3.
574///
575/// Declare contract transaction v3.
576#[derive(Debug, Clone, PartialEq, Eq)]
577pub struct DeclareTransactionV3 {
578    /// Transaction hash
579    pub transaction_hash: Felt,
580    /// The address of the account contract sending the declaration transaction
581    pub sender_address: Felt,
582    /// The hash of the cairo assembly resulting from the sierra compilation
583    pub compiled_class_hash: Felt,
584    /// Signature
585    pub signature: Vec<Felt>,
586    /// Nonce
587    pub nonce: Felt,
588    /// The hash of the declared class
589    pub class_hash: Felt,
590    /// Resource bounds for the transaction execution
591    pub resource_bounds: ResourceBoundsMapping,
592    /// The tip for the transaction
593    pub tip: u64,
594    /// Data needed to allow the paymaster to pay for the transaction in native tokens
595    pub paymaster_data: Vec<Felt>,
596    /// Data needed to deploy the account contract from which this tx will be initiated
597    pub account_deployment_data: Vec<Felt>,
598    /// The storage domain of the account's nonce (an account has a nonce per da mode)
599    pub nonce_data_availability_mode: DataAvailabilityMode,
600    /// The storage domain of the account's balance from which fee will be charged
601    pub fee_data_availability_mode: DataAvailabilityMode,
602}
603
604/// Declare txn v3.
605#[derive(Debug, Clone, PartialEq, Eq)]
606pub struct DeclareTransactionV3Content {
607    /// The address of the account contract sending the declaration transaction
608    pub sender_address: Felt,
609    /// The hash of the cairo assembly resulting from the sierra compilation
610    pub compiled_class_hash: Felt,
611    /// Signature
612    pub signature: Vec<Felt>,
613    /// Nonce
614    pub nonce: Felt,
615    /// The hash of the declared class
616    pub class_hash: Felt,
617    /// Resource bounds for the transaction execution
618    pub resource_bounds: ResourceBoundsMapping,
619    /// The tip for the transaction
620    pub tip: u64,
621    /// Data needed to allow the paymaster to pay for the transaction in native tokens
622    pub paymaster_data: Vec<Felt>,
623    /// Data needed to deploy the account contract from which this tx will be initiated
624    pub account_deployment_data: Vec<Felt>,
625    /// The storage domain of the account's nonce (an account has a nonce per da mode)
626    pub nonce_data_availability_mode: DataAvailabilityMode,
627    /// The storage domain of the account's balance from which fee will be charged
628    pub fee_data_availability_mode: DataAvailabilityMode,
629}
630
631/// New classes.
632///
633/// The declared class hash and compiled class hash.
634#[serde_as]
635#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
636#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
637pub struct DeclaredClassItem {
638    /// The hash of the declared class
639    #[serde_as(as = "UfeHex")]
640    pub class_hash: Felt,
641    /// The cairo assembly hash corresponding to the declared class
642    #[serde_as(as = "UfeHex")]
643    pub compiled_class_hash: Felt,
644}
645
646/// Deploy account transaction receipt.
647#[derive(Debug, Clone, PartialEq, Eq)]
648pub struct DeployAccountTransactionReceipt {
649    /// The hash identifying the transaction
650    pub transaction_hash: Felt,
651    /// The fee that was charged by the sequencer
652    pub actual_fee: FeePayment,
653    /// Finality status of the tx
654    pub finality_status: TransactionFinalityStatus,
655    /// Messages sent
656    pub messages_sent: Vec<MsgToL1>,
657    /// The events emitted as part of this transaction
658    pub events: Vec<Event>,
659    /// The resources consumed by the transaction
660    pub execution_resources: ExecutionResources,
661    pub execution_result: ExecutionResult,
662    /// The address of the deployed contract
663    pub contract_address: Felt,
664}
665
666/// The execution trace of a deploy account transaction.
667#[derive(Debug, Clone, PartialEq, Eq)]
668pub struct DeployAccountTransactionTrace {
669    pub validate_invocation: Option<FunctionInvocation>,
670    /// The trace of the constructor call
671    pub constructor_invocation: FunctionInvocation,
672    pub fee_transfer_invocation: Option<FunctionInvocation>,
673    /// The state diffs induced by the transaction
674    pub state_diff: Option<StateDiff>,
675    /// The resources consumed by the transaction, includes both computation and data
676    pub execution_resources: ExecutionResources,
677}
678
679/// Deploy account transaction.
680///
681/// Deploys an account contract, charges fee from the pre-funded account addresses.
682#[derive(Debug, Clone, PartialEq, Eq)]
683pub struct DeployAccountTransactionV1 {
684    /// Transaction hash
685    pub transaction_hash: Felt,
686    /// The maximal fee that can be charged for including the transaction
687    pub max_fee: Felt,
688    /// Signature
689    pub signature: Vec<Felt>,
690    /// Nonce
691    pub nonce: Felt,
692    /// The salt for the address of the deployed contract
693    pub contract_address_salt: Felt,
694    /// The parameters passed to the constructor
695    pub constructor_calldata: Vec<Felt>,
696    /// The hash of the deployed contract's class
697    pub class_hash: Felt,
698}
699
700/// Deploy account transaction.
701///
702/// Deploys an account contract, charges fee from the pre-funded account addresses.
703#[derive(Debug, Clone, PartialEq, Eq)]
704pub struct DeployAccountTransactionV1Content {
705    /// The maximal fee that can be charged for including the transaction
706    pub max_fee: Felt,
707    /// Signature
708    pub signature: Vec<Felt>,
709    /// Nonce
710    pub nonce: Felt,
711    /// The salt for the address of the deployed contract
712    pub contract_address_salt: Felt,
713    /// The parameters passed to the constructor
714    pub constructor_calldata: Vec<Felt>,
715    /// The hash of the deployed contract's class
716    pub class_hash: Felt,
717}
718
719/// Deploy account transaction.
720///
721/// Deploys an account contract, charges fee from the pre-funded account addresses.
722#[derive(Debug, Clone, PartialEq, Eq)]
723pub struct DeployAccountTransactionV3 {
724    /// Transaction hash
725    pub transaction_hash: Felt,
726    /// Signature
727    pub signature: Vec<Felt>,
728    /// Nonce
729    pub nonce: Felt,
730    /// The salt for the address of the deployed contract
731    pub contract_address_salt: Felt,
732    /// The parameters passed to the constructor
733    pub constructor_calldata: Vec<Felt>,
734    /// The hash of the deployed contract's class
735    pub class_hash: Felt,
736    /// Resource bounds for the transaction execution
737    pub resource_bounds: ResourceBoundsMapping,
738    /// The tip for the transaction
739    pub tip: u64,
740    /// Data needed to allow the paymaster to pay for the transaction in native tokens
741    pub paymaster_data: Vec<Felt>,
742    /// The storage domain of the account's nonce (an account has a nonce per da mode)
743    pub nonce_data_availability_mode: DataAvailabilityMode,
744    /// The storage domain of the account's balance from which fee will be charged
745    pub fee_data_availability_mode: DataAvailabilityMode,
746}
747
748/// Deploy account transaction.
749///
750/// Deploys an account contract, charges fee from the pre-funded account addresses.
751#[derive(Debug, Clone, PartialEq, Eq)]
752pub struct DeployAccountTransactionV3Content {
753    /// Signature
754    pub signature: Vec<Felt>,
755    /// Nonce
756    pub nonce: Felt,
757    /// The salt for the address of the deployed contract
758    pub contract_address_salt: Felt,
759    /// The parameters passed to the constructor
760    pub constructor_calldata: Vec<Felt>,
761    /// The hash of the deployed contract's class
762    pub class_hash: Felt,
763    /// Resource bounds for the transaction execution
764    pub resource_bounds: ResourceBoundsMapping,
765    /// The tip for the transaction
766    pub tip: u64,
767    /// Data needed to allow the paymaster to pay for the transaction in native tokens
768    pub paymaster_data: Vec<Felt>,
769    /// The storage domain of the account's nonce (an account has a nonce per da mode)
770    pub nonce_data_availability_mode: DataAvailabilityMode,
771    /// The storage domain of the account's balance from which fee will be charged
772    pub fee_data_availability_mode: DataAvailabilityMode,
773}
774
775/// Deploy contract transaction.
776///
777/// The structure of a deploy transaction. Note that this transaction type is deprecated and will no
778/// longer be supported in future versions.
779#[derive(Debug, Clone, PartialEq, Eq)]
780pub struct DeployTransaction {
781    /// Transaction hash
782    pub transaction_hash: Felt,
783    /// Version of the transaction scheme
784    pub version: Felt,
785    /// The salt for the address of the deployed contract
786    pub contract_address_salt: Felt,
787    /// The parameters passed to the constructor
788    pub constructor_calldata: Vec<Felt>,
789    /// The hash of the deployed contract's class
790    pub class_hash: Felt,
791}
792
793/// Deploy txn.
794#[derive(Debug, Clone, PartialEq, Eq)]
795pub struct DeployTransactionContent {
796    /// Version of the transaction scheme
797    pub version: Felt,
798    /// The salt for the address of the deployed contract
799    pub contract_address_salt: Felt,
800    /// The parameters passed to the constructor
801    pub constructor_calldata: Vec<Felt>,
802    /// The hash of the deployed contract's class
803    pub class_hash: Felt,
804}
805
806/// Deploy transaction receipt.
807#[derive(Debug, Clone, PartialEq, Eq)]
808pub struct DeployTransactionReceipt {
809    /// The hash identifying the transaction
810    pub transaction_hash: Felt,
811    /// The fee that was charged by the sequencer
812    pub actual_fee: FeePayment,
813    /// Finality status of the tx
814    pub finality_status: TransactionFinalityStatus,
815    /// Messages sent
816    pub messages_sent: Vec<MsgToL1>,
817    /// The events emitted as part of this transaction
818    pub events: Vec<Event>,
819    /// The resources consumed by the transaction
820    pub execution_resources: ExecutionResources,
821    pub execution_result: ExecutionResult,
822    /// The address of the deployed contract
823    pub contract_address: Felt,
824}
825
826/// Deployed contract item.
827#[serde_as]
828#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
829#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
830pub struct DeployedContractItem {
831    /// The address of the contract
832    #[serde_as(as = "UfeHex")]
833    pub address: Felt,
834    /// The hash of the contract code
835    #[serde_as(as = "UfeHex")]
836    pub class_hash: Felt,
837}
838
839/// Represents a path to the highest non-zero descendant node.
840#[serde_as]
841#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
842#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
843pub struct EdgeNode {
844    /// An unsigned integer whose binary representation represents the path from the current node to
845    /// its highest non-zero descendant (bounded by 2^251)
846    #[serde_as(as = "UfeHex")]
847    pub path: Felt,
848    /// The length of the path (bounded by 251)
849    pub length: u64,
850    /// The hash of the unique non-zero maximal-height descendant node
851    #[serde_as(as = "UfeHex")]
852    pub child: Felt,
853}
854
855/// Emitted event.
856///
857/// Event information decorated with metadata on where it was emitted / an event emitted as a result
858/// of transaction execution.
859#[serde_as]
860#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
861#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
862pub struct EmittedEvent {
863    /// From address
864    #[serde_as(as = "UfeHex")]
865    pub from_address: Felt,
866    /// Keys
867    #[serde_as(as = "Vec<UfeHex>")]
868    pub keys: Vec<Felt>,
869    /// Data
870    #[serde_as(as = "Vec<UfeHex>")]
871    pub data: Vec<Felt>,
872    /// The hash of the block in which the event was emitted
873    #[serde(skip_serializing_if = "Option::is_none")]
874    #[serde_as(as = "Option<UfeHex>")]
875    pub block_hash: Option<Felt>,
876    /// The number of the block in which the event was emitted
877    #[serde(skip_serializing_if = "Option::is_none")]
878    pub block_number: Option<u64>,
879    /// The transaction that emitted the event
880    #[serde_as(as = "UfeHex")]
881    pub transaction_hash: Felt,
882}
883
884#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
885#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
886pub struct EmittedEventWithFinality {
887    #[serde(flatten)]
888    pub emitted_event: EmittedEvent,
889    /// Finality status of the transaction
890    pub finality_status: TransactionFinalityStatus,
891}
892
893#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
894pub enum EntryPointType {
895    #[serde(rename = "EXTERNAL")]
896    External,
897    #[serde(rename = "L1_HANDLER")]
898    L1Handler,
899    #[serde(rename = "CONSTRUCTOR")]
900    Constructor,
901}
902
903/// Entry points by type.
904#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
905#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
906pub struct EntryPointsByType {
907    /// Constructor
908    #[serde(rename = "CONSTRUCTOR")]
909    pub constructor: Vec<SierraEntryPoint>,
910    /// External
911    #[serde(rename = "EXTERNAL")]
912    pub external: Vec<SierraEntryPoint>,
913    /// L1 handler
914    #[serde(rename = "L1_HANDLER")]
915    pub l1_handler: Vec<SierraEntryPoint>,
916}
917
918/// Event.
919///
920/// A Starknet event.
921#[serde_as]
922#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
923#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
924pub struct Event {
925    /// From address
926    #[serde_as(as = "UfeHex")]
927    pub from_address: Felt,
928    /// Keys
929    #[serde_as(as = "Vec<UfeHex>")]
930    pub keys: Vec<Felt>,
931    /// Data
932    #[serde_as(as = "Vec<UfeHex>")]
933    pub data: Vec<Felt>,
934}
935
936/// Event filter.
937///
938/// An event filter/query.
939#[serde_as]
940#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
941#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
942pub struct EventFilter {
943    /// From block
944    #[serde(skip_serializing_if = "Option::is_none")]
945    pub from_block: Option<BlockId>,
946    /// To block
947    #[serde(skip_serializing_if = "Option::is_none")]
948    pub to_block: Option<BlockId>,
949    /// From contract
950    #[serde(skip_serializing_if = "Option::is_none")]
951    #[serde_as(as = "Option<UfeHex>")]
952    pub address: Option<Felt>,
953    /// The keys to filter over
954    #[serde(skip_serializing_if = "Option::is_none")]
955    #[serde_as(as = "Option<Vec<Vec<UfeHex>>>")]
956    pub keys: Option<Vec<Vec<Felt>>>,
957}
958
959/// Events request.
960#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
961#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
962pub struct EventFilterWithPage {
963    #[serde(flatten)]
964    pub event_filter: EventFilter,
965    #[serde(flatten)]
966    pub result_page_request: ResultPageRequest,
967}
968
969/// Events chunk.
970#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
971#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
972pub struct EventsChunk {
973    /// Matching events
974    pub events: Vec<EmittedEvent>,
975    /// Use this token in a subsequent query to obtain the next page. Should not appear if there are
976    /// no more pages.
977    #[serde(skip_serializing_if = "Option::is_none")]
978    pub continuation_token: Option<String>,
979}
980
981/// Execution resources.
982///
983/// The resources consumed by the transaction.
984#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
985#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
986pub struct ExecutionResources {
987    /// L1 gas consumed by this transaction, used for L2-->L1 messages and state updates if blobs
988    /// are not used
989    pub l1_gas: u64,
990    /// Data gas consumed by this transaction, 0 if blobs are not used
991    pub l1_data_gas: u64,
992    /// L2 gas consumed by this transaction, used for computation and calldata
993    pub l2_gas: u64,
994}
995
996/// Fee estimation.
997#[derive(Debug, Clone, PartialEq, Eq)]
998pub struct FeeEstimate {
999    /// The Ethereum gas consumption of the transaction, charged for L1->L2 messages and, depending
1000    /// on the block's da_mode, state diffs
1001    pub l1_gas_consumed: u64,
1002    /// The gas price (in wei or fri, depending on the tx version) that was used in the cost
1003    /// estimation
1004    pub l1_gas_price: u128,
1005    /// The L2 gas consumption of the transaction
1006    pub l2_gas_consumed: u64,
1007    /// The L2 gas price (in wei or fri, depending on the tx version) that was used in the cost
1008    /// estimation
1009    pub l2_gas_price: u128,
1010    /// The Ethereum data gas consumption of the transaction
1011    pub l1_data_gas_consumed: u64,
1012    /// The data gas price (in wei or fri, depending on the tx version) that was used in the cost
1013    /// estimation
1014    pub l1_data_gas_price: u128,
1015    /// The estimated fee for the transaction (in wei or fri, depending on the tx version), equals
1016    /// to l1_gas_consumed*l1_gas_price + l1_data_gas_consumed*l1_data_gas_price +
1017    /// l2_gas_consumed*l2_gas_price
1018    pub overall_fee: u128,
1019}
1020
1021/// Fee payment.
1022///
1023/// Fee payment info as it appears in receipts.
1024#[serde_as]
1025#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1026#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1027pub struct FeePayment {
1028    /// Amount paid
1029    #[serde_as(as = "UfeHex")]
1030    pub amount: Felt,
1031    /// Units in which the fee is given
1032    pub unit: PriceUnit,
1033}
1034
1035/// The definition of a sierra Starknet contract class.
1036#[serde_as]
1037#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1038#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1039pub struct FlattenedSierraClass {
1040    /// The list of sierra instructions of which the program consists
1041    #[serde_as(as = "Vec<UfeHex>")]
1042    pub sierra_program: Vec<Felt>,
1043    /// The version of the contract class object. Currently, the Starknet os supports version 0.1.0
1044    pub contract_class_version: String,
1045    /// Entry points by type
1046    pub entry_points_by_type: EntryPointsByType,
1047    /// The class abi, as supplied by the user declaring the class
1048    pub abi: String,
1049}
1050
1051/// Function call.
1052///
1053/// Function call information.
1054#[serde_as]
1055#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1056#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1057pub struct FunctionCall {
1058    /// Contract address
1059    #[serde_as(as = "UfeHex")]
1060    pub contract_address: Felt,
1061    /// Entry point selector
1062    #[serde_as(as = "UfeHex")]
1063    pub entry_point_selector: Felt,
1064    /// The parameters passed to the function
1065    #[serde_as(as = "Vec<UfeHex>")]
1066    pub calldata: Vec<Felt>,
1067}
1068
1069#[serde_as]
1070#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1071#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1072pub struct FunctionInvocation {
1073    /// Contract address
1074    #[serde_as(as = "UfeHex")]
1075    pub contract_address: Felt,
1076    /// Entry point selector
1077    #[serde_as(as = "UfeHex")]
1078    pub entry_point_selector: Felt,
1079    /// The parameters passed to the function
1080    #[serde_as(as = "Vec<UfeHex>")]
1081    pub calldata: Vec<Felt>,
1082    /// The address of the invoking contract. 0 for the root invocation
1083    #[serde_as(as = "UfeHex")]
1084    pub caller_address: Felt,
1085    /// The hash of the class being called
1086    #[serde_as(as = "UfeHex")]
1087    pub class_hash: Felt,
1088    pub entry_point_type: EntryPointType,
1089    pub call_type: CallType,
1090    /// The value returned from the function invocation
1091    #[serde_as(as = "Vec<UfeHex>")]
1092    pub result: Vec<Felt>,
1093    /// The calls made by this invocation
1094    pub calls: Vec<FunctionInvocation>,
1095    /// The events emitted in this invocation
1096    pub events: Vec<OrderedEvent>,
1097    /// The messages sent by this invocation to L1
1098    pub messages: Vec<OrderedMessage>,
1099    /// Resources consumed by the call tree rooted at this given call (including the root)
1100    pub execution_resources: InnerCallExecutionResources,
1101    /// True if this inner call panicked
1102    pub is_reverted: bool,
1103}
1104
1105/// Function state mutability type.
1106#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1107pub enum FunctionStateMutability {
1108    #[serde(rename = "view")]
1109    View,
1110}
1111
1112#[serde_as]
1113#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1114#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1115pub struct GlobalRoots {
1116    #[serde_as(as = "UfeHex")]
1117    pub contracts_tree_root: Felt,
1118    #[serde_as(as = "UfeHex")]
1119    pub classes_tree_root: Felt,
1120    /// The associated block hash (needed in case the caller used a block tag for the block_id
1121    /// parameter)
1122    #[serde_as(as = "UfeHex")]
1123    pub block_hash: Felt,
1124}
1125
1126/// Execution resources.
1127///
1128/// The resources consumed by an inner call (does not account for state diffs since data is squashed
1129/// across the transaction).
1130#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1131#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1132pub struct InnerCallExecutionResources {
1133    /// L1 gas consumed by this transaction, used for L2-->L1 messages and state updates if blobs
1134    /// are not used
1135    pub l1_gas: u64,
1136    /// L2 gas consumed by this transaction, used for computation and calldata
1137    pub l2_gas: u64,
1138}
1139
1140#[serde_as]
1141#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1142#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1143pub struct InnerContractExecutionError {
1144    #[serde_as(as = "UfeHex")]
1145    pub contract_address: Felt,
1146    #[serde_as(as = "UfeHex")]
1147    pub class_hash: Felt,
1148    #[serde_as(as = "UfeHex")]
1149    pub selector: Felt,
1150    #[serde_as(as = "OwnedContractExecutionError")]
1151    pub error: OwnedPtr<ContractExecutionError>,
1152}
1153
1154/// Invoke transaction receipt.
1155#[derive(Debug, Clone, PartialEq, Eq)]
1156pub struct InvokeTransactionReceipt {
1157    /// The hash identifying the transaction
1158    pub transaction_hash: Felt,
1159    /// The fee that was charged by the sequencer
1160    pub actual_fee: FeePayment,
1161    /// Finality status of the tx
1162    pub finality_status: TransactionFinalityStatus,
1163    /// Messages sent
1164    pub messages_sent: Vec<MsgToL1>,
1165    /// The events emitted as part of this transaction
1166    pub events: Vec<Event>,
1167    /// The resources consumed by the transaction
1168    pub execution_resources: ExecutionResources,
1169    pub execution_result: ExecutionResult,
1170}
1171
1172/// The execution trace of an invoke transaction.
1173#[derive(Debug, Clone, PartialEq, Eq)]
1174pub struct InvokeTransactionTrace {
1175    pub validate_invocation: Option<FunctionInvocation>,
1176    pub execute_invocation: ExecuteInvocation,
1177    pub fee_transfer_invocation: Option<FunctionInvocation>,
1178    /// The state diffs induced by the transaction
1179    pub state_diff: Option<StateDiff>,
1180    /// The resources consumed by the transaction, includes both computation and data
1181    pub execution_resources: ExecutionResources,
1182}
1183
1184/// Invoke transaction v0.
1185///
1186/// Invokes a specific function in the desired contract (not necessarily an account).
1187#[derive(Debug, Clone, PartialEq, Eq)]
1188pub struct InvokeTransactionV0 {
1189    /// Transaction hash
1190    pub transaction_hash: Felt,
1191    /// The maximal fee that can be charged for including the transaction
1192    pub max_fee: Felt,
1193    /// Signature
1194    pub signature: Vec<Felt>,
1195    /// Contract address
1196    pub contract_address: Felt,
1197    /// Entry point selector
1198    pub entry_point_selector: Felt,
1199    /// The parameters passed to the function
1200    pub calldata: Vec<Felt>,
1201}
1202
1203/// Invoke transaction v0.
1204///
1205/// Invokes a specific function in the desired contract (not necessarily an account).
1206#[derive(Debug, Clone, PartialEq, Eq)]
1207pub struct InvokeTransactionV0Content {
1208    /// The maximal fee that can be charged for including the transaction
1209    pub max_fee: Felt,
1210    /// Signature
1211    pub signature: Vec<Felt>,
1212    /// Contract address
1213    pub contract_address: Felt,
1214    /// Entry point selector
1215    pub entry_point_selector: Felt,
1216    /// The parameters passed to the function
1217    pub calldata: Vec<Felt>,
1218}
1219
1220/// Invoke transaction v1.
1221///
1222/// Initiates a transaction from a given account.
1223#[derive(Debug, Clone, PartialEq, Eq)]
1224pub struct InvokeTransactionV1 {
1225    /// Transaction hash
1226    pub transaction_hash: Felt,
1227    /// Sender address
1228    pub sender_address: Felt,
1229    /// The data expected by the account's `execute` function (in most usecases, this includes the
1230    /// called contract address and a function selector)
1231    pub calldata: Vec<Felt>,
1232    /// The maximal fee that can be charged for including the transaction
1233    pub max_fee: Felt,
1234    /// Signature
1235    pub signature: Vec<Felt>,
1236    /// Nonce
1237    pub nonce: Felt,
1238}
1239
1240/// Invoke transaction v1.
1241///
1242/// Initiates a transaction from a given account.
1243#[derive(Debug, Clone, PartialEq, Eq)]
1244pub struct InvokeTransactionV1Content {
1245    /// Sender address
1246    pub sender_address: Felt,
1247    /// The data expected by the account's `execute` function (in most usecases, this includes the
1248    /// called contract address and a function selector)
1249    pub calldata: Vec<Felt>,
1250    /// The maximal fee that can be charged for including the transaction
1251    pub max_fee: Felt,
1252    /// Signature
1253    pub signature: Vec<Felt>,
1254    /// Nonce
1255    pub nonce: Felt,
1256}
1257
1258/// Invoke transaction v3.
1259///
1260/// Initiates a transaction from a given account.
1261#[derive(Debug, Clone, PartialEq, Eq)]
1262pub struct InvokeTransactionV3 {
1263    /// Transaction hash
1264    pub transaction_hash: Felt,
1265    /// Sender address
1266    pub sender_address: Felt,
1267    /// The data expected by the account's `execute` function (in most usecases, this includes the
1268    /// called contract address and a function selector)
1269    pub calldata: Vec<Felt>,
1270    /// Signature
1271    pub signature: Vec<Felt>,
1272    /// Nonce
1273    pub nonce: Felt,
1274    /// Resource bounds for the transaction execution
1275    pub resource_bounds: ResourceBoundsMapping,
1276    /// The tip for the transaction
1277    pub tip: u64,
1278    /// Data needed to allow the paymaster to pay for the transaction in native tokens
1279    pub paymaster_data: Vec<Felt>,
1280    /// Data needed to deploy the account contract from which this tx will be initiated
1281    pub account_deployment_data: Vec<Felt>,
1282    /// The storage domain of the account's nonce (an account has a nonce per da mode)
1283    pub nonce_data_availability_mode: DataAvailabilityMode,
1284    /// The storage domain of the account's balance from which fee will be charged
1285    pub fee_data_availability_mode: DataAvailabilityMode,
1286}
1287
1288/// Invoke transaction v3.
1289///
1290/// Initiates a transaction from a given account.
1291#[derive(Debug, Clone, PartialEq, Eq)]
1292pub struct InvokeTransactionV3Content {
1293    /// Sender address
1294    pub sender_address: Felt,
1295    /// The data expected by the account's `execute` function (in most usecases, this includes the
1296    /// called contract address and a function selector)
1297    pub calldata: Vec<Felt>,
1298    /// Signature
1299    pub signature: Vec<Felt>,
1300    /// Nonce
1301    pub nonce: Felt,
1302    /// Resource bounds for the transaction execution
1303    pub resource_bounds: ResourceBoundsMapping,
1304    /// The tip for the transaction
1305    pub tip: u64,
1306    /// Data needed to allow the paymaster to pay for the transaction in native tokens
1307    pub paymaster_data: Vec<Felt>,
1308    /// Data needed to deploy the account contract from which this tx will be initiated
1309    pub account_deployment_data: Vec<Felt>,
1310    /// The storage domain of the account's nonce (an account has a nonce per da mode)
1311    pub nonce_data_availability_mode: DataAvailabilityMode,
1312    /// The storage domain of the account's balance from which fee will be charged
1313    pub fee_data_availability_mode: DataAvailabilityMode,
1314}
1315
1316/// L1 da mode.
1317#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1318pub enum L1DataAvailabilityMode {
1319    #[serde(rename = "BLOB")]
1320    Blob,
1321    #[serde(rename = "CALLDATA")]
1322    Calldata,
1323}
1324
1325/// L1 handler transaction.
1326///
1327/// A call to an l1_handler on an L2 contract induced by a message from L1.
1328#[derive(Debug, Clone, PartialEq, Eq)]
1329pub struct L1HandlerTransaction {
1330    /// Transaction hash
1331    pub transaction_hash: Felt,
1332    /// Version of the transaction scheme
1333    pub version: Felt,
1334    /// The L1->L2 message nonce field of the sn core L1 contract at the time the transaction was
1335    /// sent
1336    pub nonce: u64,
1337    /// Contract address
1338    pub contract_address: Felt,
1339    /// Entry point selector
1340    pub entry_point_selector: Felt,
1341    /// The parameters passed to the function
1342    pub calldata: Vec<Felt>,
1343}
1344
1345/// L1 handler transaction.
1346///
1347/// A call to an l1_handler on an L2 contract induced by a message from L1.
1348#[derive(Debug, Clone, PartialEq, Eq)]
1349pub struct L1HandlerTransactionContent {
1350    /// Version of the transaction scheme
1351    pub version: Felt,
1352    /// The L1->L2 message nonce field of the sn core L1 contract at the time the transaction was
1353    /// sent
1354    pub nonce: u64,
1355    /// Contract address
1356    pub contract_address: Felt,
1357    /// Entry point selector
1358    pub entry_point_selector: Felt,
1359    /// The parameters passed to the function
1360    pub calldata: Vec<Felt>,
1361}
1362
1363/// L1 handler transaction receipt.
1364///
1365/// Receipt for L1 handler transaction.
1366#[derive(Debug, Clone, PartialEq, Eq)]
1367pub struct L1HandlerTransactionReceipt {
1368    /// The message hash as it appears on the L1 core contract
1369    pub message_hash: Hash256,
1370    /// The hash identifying the transaction
1371    pub transaction_hash: Felt,
1372    /// The fee that was charged by the sequencer
1373    pub actual_fee: FeePayment,
1374    /// Finality status of the tx
1375    pub finality_status: TransactionFinalityStatus,
1376    /// Messages sent
1377    pub messages_sent: Vec<MsgToL1>,
1378    /// The events emitted as part of this transaction
1379    pub events: Vec<Event>,
1380    /// The resources consumed by the transaction
1381    pub execution_resources: ExecutionResources,
1382    pub execution_result: ExecutionResult,
1383}
1384
1385/// The execution trace of an L1 handler transaction.
1386#[derive(Debug, Clone, PartialEq, Eq)]
1387pub struct L1HandlerTransactionTrace {
1388    /// The trace of the L1 handler call
1389    pub function_invocation: ExecuteInvocation,
1390    /// The state diffs induced by the transaction
1391    pub state_diff: Option<StateDiff>,
1392    /// The resources consumed by the transaction, includes both computation and data
1393    pub execution_resources: ExecutionResources,
1394}
1395
1396/// Layer-2 finality status.
1397///
1398/// The layer-2-only finality status of the transaction.
1399#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1400pub enum L2TransactionFinalityStatus {
1401    #[serde(rename = "PRE_CONFIRMED")]
1402    PreConfirmed,
1403    #[serde(rename = "ACCEPTED_ON_L2")]
1404    AcceptedOnL2,
1405}
1406
1407/// Layer-2 transaction status.
1408///
1409/// The layer-2-only finality status of the transaction, including the case the txn is still in the
1410/// mempool or failed validation during the block construction phase.
1411#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1412pub enum L2TransactionStatus {
1413    #[serde(rename = "RECEIVED")]
1414    Received,
1415    #[serde(rename = "CANDIDATE")]
1416    Candidate,
1417    #[serde(rename = "PRE_CONFIRMED")]
1418    PreConfirmed,
1419    #[serde(rename = "ACCEPTED_ON_L2")]
1420    AcceptedOnL2,
1421}
1422
1423/// Deprecated cairo entry point.
1424#[serde_as]
1425#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1426#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1427pub struct LegacyContractEntryPoint {
1428    /// The offset of the entry point in the program
1429    #[serde_as(as = "NumAsHex")]
1430    pub offset: u64,
1431    /// A unique identifier of the entry point (function) in the program
1432    #[serde_as(as = "UfeHex")]
1433    pub selector: Felt,
1434}
1435
1436/// Deprecated entry points by type.
1437#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1438#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1439pub struct LegacyEntryPointsByType {
1440    /// Deprecated constructor
1441    #[serde(rename = "CONSTRUCTOR")]
1442    pub constructor: Vec<LegacyContractEntryPoint>,
1443    /// Deprecated external
1444    #[serde(rename = "EXTERNAL")]
1445    pub external: Vec<LegacyContractEntryPoint>,
1446    /// Deprecated L1 handler
1447    #[serde(rename = "L1_HANDLER")]
1448    pub l1_handler: Vec<LegacyContractEntryPoint>,
1449}
1450
1451/// Event abi entry.
1452#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1453#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1454pub struct LegacyEventAbiEntry {
1455    /// Event abi type
1456    pub r#type: LegacyEventAbiType,
1457    /// The event name
1458    pub name: String,
1459    /// Typed parameter
1460    pub keys: Vec<LegacyTypedParameter>,
1461    /// Typed parameter
1462    pub data: Vec<LegacyTypedParameter>,
1463}
1464
1465/// Event abi type.
1466#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1467pub enum LegacyEventAbiType {
1468    #[serde(rename = "event")]
1469    Event,
1470}
1471
1472/// Function abi entry.
1473#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1474#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1475pub struct LegacyFunctionAbiEntry {
1476    /// Function abi type
1477    pub r#type: LegacyFunctionAbiType,
1478    /// The function name
1479    pub name: String,
1480    /// Typed parameter
1481    pub inputs: Vec<LegacyTypedParameter>,
1482    /// Typed parameter
1483    pub outputs: Vec<LegacyTypedParameter>,
1484    /// Function state mutability
1485    #[serde(skip_serializing_if = "Option::is_none")]
1486    #[serde(rename = "stateMutability")]
1487    pub state_mutability: Option<FunctionStateMutability>,
1488}
1489
1490/// Function abi type.
1491#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1492pub enum LegacyFunctionAbiType {
1493    #[serde(rename = "function")]
1494    Function,
1495    #[serde(rename = "l1_handler")]
1496    L1Handler,
1497    #[serde(rename = "constructor")]
1498    Constructor,
1499}
1500
1501/// Struct abi entry.
1502#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1503#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1504pub struct LegacyStructAbiEntry {
1505    /// Struct abi type
1506    pub r#type: LegacyStructAbiType,
1507    /// The struct name
1508    pub name: String,
1509    /// Size
1510    pub size: u64,
1511    /// Members
1512    pub members: Vec<LegacyStructMember>,
1513}
1514
1515/// Struct abi type.
1516#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1517pub enum LegacyStructAbiType {
1518    #[serde(rename = "struct")]
1519    Struct,
1520}
1521
1522/// Struct member.
1523#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1524#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1525pub struct LegacyStructMember {
1526    /// The parameter's name
1527    pub name: String,
1528    /// The parameter's type
1529    pub r#type: String,
1530    /// Offset of this property within the struct
1531    pub offset: u64,
1532}
1533
1534/// Typed parameter.
1535#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1536#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1537pub struct LegacyTypedParameter {
1538    /// The parameter's name
1539    pub name: String,
1540    /// The parameter's type
1541    pub r#type: String,
1542}
1543
1544/// Message fee estimation.
1545#[derive(Debug, Clone, PartialEq, Eq)]
1546pub struct MessageFeeEstimate {
1547    /// The Ethereum gas consumption of the transaction, charged for L1->L2 messages and, depending
1548    /// on the block's da_mode, state diffs
1549    pub l1_gas_consumed: u64,
1550    /// The gas price (in wei or fri, depending on the tx version) that was used in the cost
1551    /// estimation
1552    pub l1_gas_price: u128,
1553    /// The L2 gas consumption of the transaction
1554    pub l2_gas_consumed: u64,
1555    /// The L2 gas price (in wei or fri, depending on the tx version) that was used in the cost
1556    /// estimation
1557    pub l2_gas_price: u128,
1558    /// The Ethereum data gas consumption of the transaction
1559    pub l1_data_gas_consumed: u64,
1560    /// The data gas price (in wei or fri, depending on the tx version) that was used in the cost
1561    /// estimation
1562    pub l1_data_gas_price: u128,
1563    /// The estimated fee for the transaction (in wei or fri, depending on the tx version), equals
1564    /// to l1_gas_consumed*l1_gas_price + l1_data_gas_consumed*l1_data_gas_price +
1565    /// l2_gas_consumed*l2_gas_price
1566    pub overall_fee: u128,
1567}
1568
1569/// Message from L1.
1570#[serde_as]
1571#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1572#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1573pub struct MsgFromL1 {
1574    /// The address of the L1 contract sending the message
1575    pub from_address: EthAddress,
1576    /// The target L2 address the message is sent to
1577    #[serde_as(as = "UfeHex")]
1578    pub to_address: Felt,
1579    /// The selector of the l1_handler in invoke in the target contract
1580    #[serde_as(as = "UfeHex")]
1581    pub entry_point_selector: Felt,
1582    /// The payload of the message
1583    #[serde_as(as = "Vec<UfeHex>")]
1584    pub payload: Vec<Felt>,
1585}
1586
1587/// Message to L1.
1588#[serde_as]
1589#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1590#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1591pub struct MsgToL1 {
1592    /// The address of the L2 contract sending the message
1593    #[serde_as(as = "UfeHex")]
1594    pub from_address: Felt,
1595    /// The target L1 address the message is sent to
1596    #[serde_as(as = "UfeHex")]
1597    pub to_address: Felt,
1598    /// The payload of the message
1599    #[serde_as(as = "Vec<UfeHex>")]
1600    pub payload: Vec<Felt>,
1601}
1602
1603/// New transaction status.
1604#[serde_as]
1605#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1606#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1607pub struct NewTransactionStatus {
1608    #[serde_as(as = "UfeHex")]
1609    pub transaction_hash: Felt,
1610    pub status: TransactionStatus,
1611}
1612
1613/// Extra information on why trace is not available. Either it wasn't executed yet (received), or
1614/// the transaction failed (rejected).
1615#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1616#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1617pub struct NoTraceAvailableErrorData {
1618    pub status: SequencerTransactionStatus,
1619}
1620
1621/// Nonce update.
1622///
1623/// The updated nonce per contract address.
1624#[serde_as]
1625#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1626#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1627pub struct NonceUpdate {
1628    /// The address of the contract
1629    #[serde_as(as = "UfeHex")]
1630    pub contract_address: Felt,
1631    /// The nonce for the given address at the end of the block
1632    #[serde_as(as = "UfeHex")]
1633    pub nonce: Felt,
1634}
1635
1636/// Orderedevent.
1637///
1638/// An event alongside its order within the transaction.
1639#[serde_as]
1640#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1641#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1642pub struct OrderedEvent {
1643    /// The order of the event within the transaction
1644    pub order: u64,
1645    /// Keys
1646    #[serde_as(as = "Vec<UfeHex>")]
1647    pub keys: Vec<Felt>,
1648    /// Data
1649    #[serde_as(as = "Vec<UfeHex>")]
1650    pub data: Vec<Felt>,
1651}
1652
1653/// Orderedmessage.
1654///
1655/// A message alongside its order within the transaction.
1656#[serde_as]
1657#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1658#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1659pub struct OrderedMessage {
1660    /// The order of the message within the transaction
1661    pub order: u64,
1662    /// The address of the L2 contract sending the message
1663    #[serde_as(as = "UfeHex")]
1664    pub from_address: Felt,
1665    /// The target L1 address the message is sent to
1666    #[serde_as(as = "UfeHex")]
1667    pub to_address: Felt,
1668    /// The payload of the message
1669    #[serde_as(as = "Vec<UfeHex>")]
1670    pub payload: Vec<Felt>,
1671}
1672
1673/// Pre-confirmed block with transactions and receipts.
1674///
1675/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated
1676/// upon decentralization.
1677#[serde_as]
1678#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1679#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1680pub struct PreConfirmedBlockWithReceipts {
1681    /// The transactions in this block
1682    pub transactions: Vec<TransactionWithReceipt>,
1683    /// The block number of the block that the proposer is currently building. Note that this is a
1684    /// local view of the node, whose accuracy depends on its polling interval length.
1685    pub block_number: u64,
1686    /// The time in which the block was created, encoded in Unix time
1687    pub timestamp: u64,
1688    /// The Starknet identity of the sequencer submitting this block
1689    #[serde_as(as = "UfeHex")]
1690    pub sequencer_address: Felt,
1691    /// The price of L1 gas in the block
1692    pub l1_gas_price: ResourcePrice,
1693    /// The price of L2 gas in the block
1694    pub l2_gas_price: ResourcePrice,
1695    /// The price of L1 data gas in the block
1696    pub l1_data_gas_price: ResourcePrice,
1697    /// Specifies whether the data of this block is published via blob data or calldata
1698    pub l1_da_mode: L1DataAvailabilityMode,
1699    /// Semver of the current Starknet protocol
1700    pub starknet_version: String,
1701}
1702
1703/// Pre-confirmed block with transaction hashes.
1704///
1705/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated
1706/// upon decentralization.
1707#[serde_as]
1708#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1709#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1710pub struct PreConfirmedBlockWithTxHashes {
1711    /// The hashes of the transactions included in this block
1712    #[serde_as(as = "Vec<UfeHex>")]
1713    pub transactions: Vec<Felt>,
1714    /// The block number of the block that the proposer is currently building. Note that this is a
1715    /// local view of the node, whose accuracy depends on its polling interval length.
1716    pub block_number: u64,
1717    /// The time in which the block was created, encoded in Unix time
1718    pub timestamp: u64,
1719    /// The Starknet identity of the sequencer submitting this block
1720    #[serde_as(as = "UfeHex")]
1721    pub sequencer_address: Felt,
1722    /// The price of L1 gas in the block
1723    pub l1_gas_price: ResourcePrice,
1724    /// The price of L2 gas in the block
1725    pub l2_gas_price: ResourcePrice,
1726    /// The price of L1 data gas in the block
1727    pub l1_data_gas_price: ResourcePrice,
1728    /// Specifies whether the data of this block is published via blob data or calldata
1729    pub l1_da_mode: L1DataAvailabilityMode,
1730    /// Semver of the current Starknet protocol
1731    pub starknet_version: String,
1732}
1733
1734/// Pre-confirmed block with transactions.
1735///
1736/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated
1737/// upon decentralization.
1738#[serde_as]
1739#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1740#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1741pub struct PreConfirmedBlockWithTxs {
1742    /// The transactions in this block
1743    pub transactions: Vec<Transaction>,
1744    /// The block number of the block that the proposer is currently building. Note that this is a
1745    /// local view of the node, whose accuracy depends on its polling interval length.
1746    pub block_number: u64,
1747    /// The time in which the block was created, encoded in Unix time
1748    pub timestamp: u64,
1749    /// The Starknet identity of the sequencer submitting this block
1750    #[serde_as(as = "UfeHex")]
1751    pub sequencer_address: Felt,
1752    /// The price of L1 gas in the block
1753    pub l1_gas_price: ResourcePrice,
1754    /// The price of L2 gas in the block
1755    pub l2_gas_price: ResourcePrice,
1756    /// The price of L1 data gas in the block
1757    pub l1_data_gas_price: ResourcePrice,
1758    /// Specifies whether the data of this block is published via blob data or calldata
1759    pub l1_da_mode: L1DataAvailabilityMode,
1760    /// Semver of the current Starknet protocol
1761    pub starknet_version: String,
1762}
1763
1764/// Pre-confirmed state update.
1765///
1766/// Pre-confirmed state update.
1767#[serde_as]
1768#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1769#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1770pub struct PreConfirmedStateUpdate {
1771    /// The previous global state root
1772    #[serde_as(as = "UfeHex")]
1773    pub old_root: Felt,
1774    /// State diff
1775    pub state_diff: StateDiff,
1776}
1777
1778/// Price unit.
1779///
1780/// Units in which the fee is given.
1781#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1782pub enum PriceUnit {
1783    #[serde(rename = "WEI")]
1784    Wei,
1785    #[serde(rename = "FRI")]
1786    Fri,
1787}
1788
1789/// Price unit fri.
1790#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1791pub enum PriceUnitFri {
1792    #[serde(rename = "FRI")]
1793    Fri,
1794}
1795
1796/// Price unit wei.
1797#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1798pub enum PriceUnitWei {
1799    #[serde(rename = "WEI")]
1800    Wei,
1801}
1802
1803/// Reorg data.
1804///
1805/// Data about reorganized blocks, starting and ending block number and hash.
1806#[serde_as]
1807#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1808#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1809pub struct ReorgData {
1810    /// Hash of the first known block of the orphaned chain
1811    #[serde_as(as = "UfeHex")]
1812    pub starting_block_hash: Felt,
1813    /// Number of the first known block of the orphaned chain
1814    pub starting_block_number: u64,
1815    /// The last known block of the orphaned chain
1816    #[serde_as(as = "UfeHex")]
1817    pub ending_block_hash: Felt,
1818    /// Number of the last known block of the orphaned chain
1819    pub ending_block_number: u64,
1820}
1821
1822/// Replaced class.
1823///
1824/// The list of contracts whose class was replaced.
1825#[serde_as]
1826#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1827#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1828pub struct ReplacedClassItem {
1829    /// The address of the contract whose class was replaced
1830    #[serde_as(as = "UfeHex")]
1831    pub contract_address: Felt,
1832    /// The new class hash
1833    #[serde_as(as = "UfeHex")]
1834    pub class_hash: Felt,
1835}
1836
1837#[serde_as]
1838#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1839#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1840pub struct ResourceBounds {
1841    /// The max amount of the resource that can be used in the tx
1842    #[serde_as(as = "NumAsHex")]
1843    pub max_amount: u64,
1844    /// The max price per unit of this resource for this tx
1845    #[serde_as(as = "NumAsHex")]
1846    pub max_price_per_unit: u128,
1847}
1848
1849#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1850#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1851pub struct ResourceBoundsMapping {
1852    /// The max amount and max price per unit of L1 gas used in this tx
1853    pub l1_gas: ResourceBounds,
1854    /// The max amount and max price per unit of L1 blob gas used in this tx
1855    pub l1_data_gas: ResourceBounds,
1856    /// The max amount and max price per unit of L2 gas used in this tx
1857    pub l2_gas: ResourceBounds,
1858}
1859
1860#[serde_as]
1861#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1862#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1863pub struct ResourcePrice {
1864    /// The price of one unit of the given resource, denominated in fri (10^-18 strk)
1865    #[serde_as(as = "UfeHex")]
1866    pub price_in_fri: Felt,
1867    /// The price of one unit of the given resource, denominated in wei
1868    #[serde_as(as = "UfeHex")]
1869    pub price_in_wei: Felt,
1870}
1871
1872/// Result page request.
1873#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1874#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1875pub struct ResultPageRequest {
1876    /// The token returned from the previous query. If no token is provided the first page is
1877    /// returned.
1878    #[serde(skip_serializing_if = "Option::is_none")]
1879    pub continuation_token: Option<String>,
1880    /// Chunk size
1881    pub chunk_size: u64,
1882}
1883
1884#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1885#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1886pub struct RevertedInvocation {
1887    /// The revert reason for the failed invocation
1888    pub revert_reason: String,
1889}
1890
1891/// Transaction status.
1892///
1893/// The finality status of the transaction, including the case the txn is still in the mempool or
1894/// failed validation during the block construction phase.
1895#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1896pub enum SequencerTransactionStatus {
1897    #[serde(rename = "RECEIVED")]
1898    Received,
1899    #[serde(rename = "CANDIDATE")]
1900    Candidate,
1901    #[serde(rename = "PRE_CONFIRMED")]
1902    PreConfirmed,
1903    #[serde(rename = "ACCEPTED_ON_L2")]
1904    AcceptedOnL2,
1905    #[serde(rename = "ACCEPTED_ON_L1")]
1906    AcceptedOnL1,
1907}
1908
1909/// Sierra entry point.
1910#[serde_as]
1911#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1912#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1913pub struct SierraEntryPoint {
1914    /// A unique identifier of the entry point (function) in the program
1915    #[serde_as(as = "UfeHex")]
1916    pub selector: Felt,
1917    /// The index of the function in the program
1918    pub function_idx: u64,
1919}
1920
1921#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1922#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
1923pub struct SimulatedTransaction {
1924    /// The transaction's trace
1925    pub transaction_trace: TransactionTrace,
1926    /// The transaction's resources and fee
1927    pub fee_estimation: FeeEstimate,
1928}
1929
1930/// Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is
1931/// replicated locally (enough funds are expected to be in the account, and fee will be deducted
1932/// from the balance before the simulation of the next transaction). To skip the fee charge, use the
1933/// skip_fee_charge flag.
1934#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1935pub enum SimulationFlag {
1936    #[serde(rename = "SKIP_VALIDATE")]
1937    SkipValidate,
1938    #[serde(rename = "SKIP_FEE_CHARGE")]
1939    SkipFeeCharge,
1940}
1941
1942/// Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is
1943/// replicated locally.
1944#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1945pub enum SimulationFlagForEstimateFee {
1946    #[serde(rename = "SKIP_VALIDATE")]
1947    SkipValidate,
1948}
1949
1950/// JSON-RPC error codes
1951#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1952pub enum StarknetError {
1953    /// Failed to write transaction
1954    FailedToReceiveTransaction,
1955    /// Contract not found
1956    ContractNotFound,
1957    /// Requested entrypoint does not exist in the contract
1958    EntrypointNotFound,
1959    /// Block not found
1960    BlockNotFound,
1961    /// Invalid transaction index in a block
1962    InvalidTransactionIndex,
1963    /// Class hash not found
1964    ClassHashNotFound,
1965    /// Transaction hash not found
1966    TransactionHashNotFound,
1967    /// Requested page size is too big
1968    PageSizeTooBig,
1969    /// There are no blocks
1970    NoBlocks,
1971    /// The supplied continuation token is invalid or unknown
1972    InvalidContinuationToken,
1973    /// Too many keys provided in a filter
1974    TooManyKeysInFilter,
1975    /// Contract error
1976    ContractError(ContractErrorData),
1977    /// Transaction execution error
1978    TransactionExecutionError(TransactionExecutionErrorData),
1979    /// the node doesn't support storage proofs for blocks that are too far in the past
1980    StorageProofNotSupported,
1981    /// Class already declared
1982    ClassAlreadyDeclared,
1983    /// Invalid transaction nonce
1984    InvalidTransactionNonce(String),
1985    /// The transaction's resources don't cover validation or the minimal transaction fee
1986    InsufficientResourcesForValidate,
1987    /// Account balance is smaller than the transaction's maximal fee (calculated as the sum of each
1988    /// resource's limit x max price)
1989    InsufficientAccountBalance,
1990    /// Account validation failed
1991    ValidationFailure(String),
1992    /// Compilation failed
1993    CompilationFailed(String),
1994    /// Contract class size is too large
1995    ContractClassSizeIsTooLarge,
1996    /// Sender address is not an account contract
1997    NonAccount,
1998    /// A transaction with the same hash already exists in the mempool
1999    DuplicateTx,
2000    /// the compiled class hash did not match the one supplied in the transaction
2001    CompiledClassHashMismatch,
2002    /// the transaction version is not supported
2003    UnsupportedTxVersion,
2004    /// the contract class version is not supported
2005    UnsupportedContractClassVersion,
2006    /// An unexpected error occurred
2007    UnexpectedError(String),
2008    /// Replacement transaction is underpriced
2009    ReplacementTransactionUnderpriced,
2010    /// Transaction fee below minimum
2011    FeeBelowMinimum,
2012    /// No trace available for transaction
2013    NoTraceAvailable(NoTraceAvailableErrorData),
2014    /// Invalid subscription id
2015    InvalidSubscriptionId,
2016    /// Too many addresses in filter sender_address filter
2017    TooManyAddressesInFilter,
2018    /// Cannot go back more than 1024 blocks
2019    TooManyBlocksBack,
2020}
2021
2022#[cfg(feature = "std")]
2023impl std::error::Error for StarknetError {}
2024
2025impl core::fmt::Display for StarknetError {
2026    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
2027        match self {
2028            Self::FailedToReceiveTransaction => write!(f, "FailedToReceiveTransaction"),
2029            Self::ContractNotFound => write!(f, "ContractNotFound"),
2030            Self::EntrypointNotFound => write!(f, "EntrypointNotFound"),
2031            Self::BlockNotFound => write!(f, "BlockNotFound"),
2032            Self::InvalidTransactionIndex => write!(f, "InvalidTransactionIndex"),
2033            Self::ClassHashNotFound => write!(f, "ClassHashNotFound"),
2034            Self::TransactionHashNotFound => write!(f, "TransactionHashNotFound"),
2035            Self::PageSizeTooBig => write!(f, "PageSizeTooBig"),
2036            Self::NoBlocks => write!(f, "NoBlocks"),
2037            Self::InvalidContinuationToken => write!(f, "InvalidContinuationToken"),
2038            Self::TooManyKeysInFilter => write!(f, "TooManyKeysInFilter"),
2039            Self::ContractError(e) => write!(f, "ContractError: {e:?}"),
2040            Self::TransactionExecutionError(e) => write!(f, "TransactionExecutionError: {e:?}"),
2041            Self::StorageProofNotSupported => write!(f, "StorageProofNotSupported"),
2042            Self::ClassAlreadyDeclared => write!(f, "ClassAlreadyDeclared"),
2043            Self::InvalidTransactionNonce(e) => write!(f, "InvalidTransactionNonce: {e:?}"),
2044            Self::InsufficientResourcesForValidate => write!(f, "InsufficientResourcesForValidate"),
2045            Self::InsufficientAccountBalance => write!(f, "InsufficientAccountBalance"),
2046            Self::ValidationFailure(e) => write!(f, "ValidationFailure: {e:?}"),
2047            Self::CompilationFailed(e) => write!(f, "CompilationFailed: {e:?}"),
2048            Self::ContractClassSizeIsTooLarge => write!(f, "ContractClassSizeIsTooLarge"),
2049            Self::NonAccount => write!(f, "NonAccount"),
2050            Self::DuplicateTx => write!(f, "DuplicateTx"),
2051            Self::CompiledClassHashMismatch => write!(f, "CompiledClassHashMismatch"),
2052            Self::UnsupportedTxVersion => write!(f, "UnsupportedTxVersion"),
2053            Self::UnsupportedContractClassVersion => write!(f, "UnsupportedContractClassVersion"),
2054            Self::UnexpectedError(e) => write!(f, "UnexpectedError: {e:?}"),
2055            Self::ReplacementTransactionUnderpriced => {
2056                write!(f, "ReplacementTransactionUnderpriced")
2057            }
2058            Self::FeeBelowMinimum => write!(f, "FeeBelowMinimum"),
2059            Self::NoTraceAvailable(e) => write!(f, "NoTraceAvailable: {e:?}"),
2060            Self::InvalidSubscriptionId => write!(f, "InvalidSubscriptionId"),
2061            Self::TooManyAddressesInFilter => write!(f, "TooManyAddressesInFilter"),
2062            Self::TooManyBlocksBack => write!(f, "TooManyBlocksBack"),
2063        }
2064    }
2065}
2066
2067impl StarknetError {
2068    pub const fn code(&self) -> u32 {
2069        match self {
2070            Self::FailedToReceiveTransaction => 1,
2071            Self::ContractNotFound => 20,
2072            Self::EntrypointNotFound => 21,
2073            Self::BlockNotFound => 24,
2074            Self::InvalidTransactionIndex => 27,
2075            Self::ClassHashNotFound => 28,
2076            Self::TransactionHashNotFound => 29,
2077            Self::PageSizeTooBig => 31,
2078            Self::NoBlocks => 32,
2079            Self::InvalidContinuationToken => 33,
2080            Self::TooManyKeysInFilter => 34,
2081            Self::ContractError(_) => 40,
2082            Self::TransactionExecutionError(_) => 41,
2083            Self::StorageProofNotSupported => 42,
2084            Self::ClassAlreadyDeclared => 51,
2085            Self::InvalidTransactionNonce(_) => 52,
2086            Self::InsufficientResourcesForValidate => 53,
2087            Self::InsufficientAccountBalance => 54,
2088            Self::ValidationFailure(_) => 55,
2089            Self::CompilationFailed(_) => 56,
2090            Self::ContractClassSizeIsTooLarge => 57,
2091            Self::NonAccount => 58,
2092            Self::DuplicateTx => 59,
2093            Self::CompiledClassHashMismatch => 60,
2094            Self::UnsupportedTxVersion => 61,
2095            Self::UnsupportedContractClassVersion => 62,
2096            Self::UnexpectedError(_) => 63,
2097            Self::ReplacementTransactionUnderpriced => 64,
2098            Self::FeeBelowMinimum => 65,
2099            Self::NoTraceAvailable(_) => 10,
2100            Self::InvalidSubscriptionId => 66,
2101            Self::TooManyAddressesInFilter => 67,
2102            Self::TooManyBlocksBack => 68,
2103        }
2104    }
2105
2106    pub fn message(&self) -> &'static str {
2107        match self {
2108            Self::FailedToReceiveTransaction => "Failed to write transaction",
2109            Self::ContractNotFound => "Contract not found",
2110            Self::EntrypointNotFound => "Requested entrypoint does not exist in the contract",
2111            Self::BlockNotFound => "Block not found",
2112            Self::InvalidTransactionIndex => "Invalid transaction index in a block",
2113            Self::ClassHashNotFound => "Class hash not found",
2114            Self::TransactionHashNotFound => "Transaction hash not found",
2115            Self::PageSizeTooBig => "Requested page size is too big",
2116            Self::NoBlocks => "There are no blocks",
2117            Self::InvalidContinuationToken => {
2118                "The supplied continuation token is invalid or unknown"
2119            }
2120            Self::TooManyKeysInFilter => "Too many keys provided in a filter",
2121            Self::ContractError(_) => "Contract error",
2122            Self::TransactionExecutionError(_) => "Transaction execution error",
2123            Self::StorageProofNotSupported => {
2124                "the node doesn't support storage proofs for blocks that are too far in the past"
2125            }
2126            Self::ClassAlreadyDeclared => "Class already declared",
2127            Self::InvalidTransactionNonce(_) => "Invalid transaction nonce",
2128            Self::InsufficientResourcesForValidate => {
2129                "The transaction's resources don't cover validation or the minimal transaction fee"
2130            }
2131            Self::InsufficientAccountBalance => {
2132                "Account balance is smaller than the transaction's maximal fee (calculated as the sum of each resource's limit x max price)"
2133            }
2134            Self::ValidationFailure(_) => "Account validation failed",
2135            Self::CompilationFailed(_) => "Compilation failed",
2136            Self::ContractClassSizeIsTooLarge => "Contract class size is too large",
2137            Self::NonAccount => "Sender address is not an account contract",
2138            Self::DuplicateTx => "A transaction with the same hash already exists in the mempool",
2139            Self::CompiledClassHashMismatch => {
2140                "the compiled class hash did not match the one supplied in the transaction"
2141            }
2142            Self::UnsupportedTxVersion => "the transaction version is not supported",
2143            Self::UnsupportedContractClassVersion => "the contract class version is not supported",
2144            Self::UnexpectedError(_) => "An unexpected error occurred",
2145            Self::ReplacementTransactionUnderpriced => "Replacement transaction is underpriced",
2146            Self::FeeBelowMinimum => "Transaction fee below minimum",
2147            Self::NoTraceAvailable(_) => "No trace available for transaction",
2148            Self::InvalidSubscriptionId => "Invalid subscription id",
2149            Self::TooManyAddressesInFilter => "Too many addresses in filter sender_address filter",
2150            Self::TooManyBlocksBack => "Cannot go back more than 1024 blocks",
2151        }
2152    }
2153}
2154
2155/// The change in state applied in this block, given as a mapping of addresses to the new values
2156/// and/or new contracts.
2157#[serde_as]
2158#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2159#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2160pub struct StateDiff {
2161    /// Storage diffs
2162    pub storage_diffs: Vec<ContractStorageDiffItem>,
2163    /// Deprecated declared classes
2164    #[serde_as(as = "Vec<UfeHex>")]
2165    pub deprecated_declared_classes: Vec<Felt>,
2166    /// Declared classes
2167    pub declared_classes: Vec<DeclaredClassItem>,
2168    /// Deployed contracts
2169    pub deployed_contracts: Vec<DeployedContractItem>,
2170    /// Replaced classes
2171    pub replaced_classes: Vec<ReplacedClassItem>,
2172    /// Nonces
2173    pub nonces: Vec<NonceUpdate>,
2174}
2175
2176/// State update.
2177#[serde_as]
2178#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2179#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2180pub struct StateUpdate {
2181    /// Block hash
2182    #[serde_as(as = "UfeHex")]
2183    pub block_hash: Felt,
2184    /// The previous global state root
2185    #[serde_as(as = "UfeHex")]
2186    pub old_root: Felt,
2187    /// The new global state root
2188    #[serde_as(as = "UfeHex")]
2189    pub new_root: Felt,
2190    /// State diff
2191    pub state_diff: StateDiff,
2192}
2193
2194/// Storage diff item.
2195#[serde_as]
2196#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2197#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2198pub struct StorageEntry {
2199    /// The key of the changed value
2200    #[serde_as(as = "UfeHex")]
2201    pub key: Felt,
2202    /// The new value applied to the given address
2203    #[serde_as(as = "UfeHex")]
2204    pub value: Felt,
2205}
2206
2207#[serde_as]
2208#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2209#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2210pub struct StorageProof {
2211    #[serde_as(as = "MerkleNodeMap")]
2212    pub classes_proof: IndexMap<Felt, MerkleNode, RandomState>,
2213    pub contracts_proof: ContractsProof,
2214    #[serde_as(as = "Vec<MerkleNodeMap>")]
2215    pub contracts_storage_proofs: Vec<IndexMap<Felt, MerkleNode, RandomState>>,
2216    pub global_roots: GlobalRoots,
2217}
2218
2219/// Subscription id.
2220///
2221/// An identifier for this subscription stream used to associate events with this subscription.
2222#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
2223pub struct SubscriptionId(pub String);
2224
2225/// Sync status.
2226///
2227/// An object describing the node synchronization status.
2228#[serde_as]
2229#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2230#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2231pub struct SyncStatus {
2232    /// The hash of the block from which the sync started
2233    #[serde_as(as = "UfeHex")]
2234    pub starting_block_hash: Felt,
2235    /// The number (height) of the block from which the sync started
2236    pub starting_block_num: u64,
2237    /// The hash of the current block being synchronized
2238    #[serde_as(as = "UfeHex")]
2239    pub current_block_hash: Felt,
2240    /// The number (height) of the current block being synchronized
2241    pub current_block_num: u64,
2242    /// The hash of the estimated highest block to be synchronized
2243    #[serde_as(as = "UfeHex")]
2244    pub highest_block_hash: Felt,
2245    /// The number (height) of the estimated highest block to be synchronized
2246    pub highest_block_num: u64,
2247}
2248
2249/// More data about the execution failure.
2250#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2251#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2252pub struct TransactionExecutionErrorData {
2253    /// The index of the first transaction failing in a sequence of given transactions
2254    pub transaction_index: u64,
2255    /// The execution trace up to the point of failure
2256    pub execution_error: ContractExecutionError,
2257}
2258
2259/// Execution status.
2260///
2261/// The execution status of the transaction.
2262#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2263pub enum TransactionExecutionStatus {
2264    #[serde(rename = "SUCCEEDED")]
2265    Succeeded,
2266    #[serde(rename = "REVERTED")]
2267    Reverted,
2268}
2269
2270/// Finality status.
2271///
2272/// The finality status of the transaction.
2273#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2274pub enum TransactionFinalityStatus {
2275    #[serde(rename = "PRE_CONFIRMED")]
2276    PreConfirmed,
2277    #[serde(rename = "ACCEPTED_ON_L2")]
2278    AcceptedOnL2,
2279    #[serde(rename = "ACCEPTED_ON_L1")]
2280    AcceptedOnL1,
2281}
2282
2283/// Transaction receipt with block info.
2284#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2285pub struct TransactionReceiptWithBlockInfo {
2286    #[serde(flatten)]
2287    pub receipt: TransactionReceipt,
2288    #[serde(flatten)]
2289    pub block: ReceiptBlock,
2290}
2291
2292/// A single pair of transaction hash and corresponding trace.
2293#[serde_as]
2294#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2295#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2296pub struct TransactionTraceWithHash {
2297    #[serde_as(as = "UfeHex")]
2298    pub transaction_hash: Felt,
2299    pub trace_root: TransactionTrace,
2300}
2301
2302/// Either a tranasaction hash or full transaction details, based on subscription.
2303#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2304pub struct TransactionWithL2Status {
2305    #[serde(flatten)]
2306    pub txn: Transaction,
2307    /// Finality status of the transaction
2308    pub finality_status: L2TransactionStatus,
2309}
2310
2311/// Transaction and receipt.
2312#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2313#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2314pub struct TransactionWithReceipt {
2315    /// Transaction
2316    pub transaction: TransactionContent,
2317    /// Receipt
2318    pub receipt: TransactionReceipt,
2319}
2320
2321/// Request for method starknet_addDeclareTransaction
2322#[derive(Debug, Clone, PartialEq, Eq)]
2323pub struct AddDeclareTransactionRequest {
2324    /// Declare transaction required to declare a new class on Starknet
2325    pub declare_transaction: BroadcastedDeclareTransaction,
2326}
2327
2328/// Reference version of [AddDeclareTransactionRequest].
2329#[derive(Debug, Clone, PartialEq, Eq)]
2330pub struct AddDeclareTransactionRequestRef<'a> {
2331    pub declare_transaction: &'a BroadcastedDeclareTransaction,
2332}
2333
2334/// Request for method starknet_addDeployAccountTransaction
2335#[derive(Debug, Clone, PartialEq, Eq)]
2336pub struct AddDeployAccountTransactionRequest {
2337    /// The deploy account transaction
2338    pub deploy_account_transaction: BroadcastedDeployAccountTransaction,
2339}
2340
2341/// Reference version of [AddDeployAccountTransactionRequest].
2342#[derive(Debug, Clone, PartialEq, Eq)]
2343pub struct AddDeployAccountTransactionRequestRef<'a> {
2344    pub deploy_account_transaction: &'a BroadcastedDeployAccountTransaction,
2345}
2346
2347/// Request for method starknet_addInvokeTransaction
2348#[derive(Debug, Clone, PartialEq, Eq)]
2349pub struct AddInvokeTransactionRequest {
2350    /// The information needed to invoke the function (or account, for version 1 transactions)
2351    pub invoke_transaction: BroadcastedInvokeTransaction,
2352}
2353
2354/// Reference version of [AddInvokeTransactionRequest].
2355#[derive(Debug, Clone, PartialEq, Eq)]
2356pub struct AddInvokeTransactionRequestRef<'a> {
2357    pub invoke_transaction: &'a BroadcastedInvokeTransaction,
2358}
2359
2360/// Request for method starknet_blockHashAndNumber
2361#[derive(Debug, Clone, PartialEq, Eq)]
2362pub struct BlockHashAndNumberRequest;
2363
2364/// Request for method starknet_blockNumber
2365#[derive(Debug, Clone, PartialEq, Eq)]
2366pub struct BlockNumberRequest;
2367
2368/// Request for method starknet_call
2369#[derive(Debug, Clone, PartialEq, Eq)]
2370pub struct CallRequest {
2371    pub request: FunctionCall,
2372    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
2373    /// for the block referencing the state or call the transaction on.
2374    pub block_id: BlockId,
2375}
2376
2377/// Reference version of [CallRequest].
2378#[derive(Debug, Clone, PartialEq, Eq)]
2379pub struct CallRequestRef<'a> {
2380    pub request: &'a FunctionCall,
2381    pub block_id: &'a BlockId,
2382}
2383
2384/// Request for method starknet_chainId
2385#[derive(Debug, Clone, PartialEq, Eq)]
2386pub struct ChainIdRequest;
2387
2388/// Request for method starknet_estimateFee
2389#[derive(Debug, Clone, PartialEq, Eq)]
2390pub struct EstimateFeeRequest {
2391    pub request: Vec<BroadcastedTransaction>,
2392    /// describes what parts of the transaction should be executed
2393    pub simulation_flags: Vec<SimulationFlagForEstimateFee>,
2394    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
2395    /// for the block referencing the state or call the transaction on.
2396    pub block_id: BlockId,
2397}
2398
2399/// Reference version of [EstimateFeeRequest].
2400#[derive(Debug, Clone, PartialEq, Eq)]
2401pub struct EstimateFeeRequestRef<'a> {
2402    pub request: &'a [BroadcastedTransaction],
2403    pub simulation_flags: &'a [SimulationFlagForEstimateFee],
2404    pub block_id: &'a BlockId,
2405}
2406
2407/// Request for method starknet_estimateMessageFee
2408#[derive(Debug, Clone, PartialEq, Eq)]
2409pub struct EstimateMessageFeeRequest {
2410    /// the message's parameters
2411    pub message: MsgFromL1,
2412    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
2413    /// for the block referencing the state or call the transaction on.
2414    pub block_id: BlockId,
2415}
2416
2417/// Reference version of [EstimateMessageFeeRequest].
2418#[derive(Debug, Clone, PartialEq, Eq)]
2419pub struct EstimateMessageFeeRequestRef<'a> {
2420    pub message: &'a MsgFromL1,
2421    pub block_id: &'a BlockId,
2422}
2423
2424/// Request for method starknet_getBlockTransactionCount
2425#[derive(Debug, Clone, PartialEq, Eq)]
2426pub struct GetBlockTransactionCountRequest {
2427    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2428    pub block_id: BlockId,
2429}
2430
2431/// Reference version of [GetBlockTransactionCountRequest].
2432#[derive(Debug, Clone, PartialEq, Eq)]
2433pub struct GetBlockTransactionCountRequestRef<'a> {
2434    pub block_id: &'a BlockId,
2435}
2436
2437/// Request for method starknet_getBlockWithReceipts
2438#[derive(Debug, Clone, PartialEq, Eq)]
2439pub struct GetBlockWithReceiptsRequest {
2440    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2441    pub block_id: BlockId,
2442}
2443
2444/// Reference version of [GetBlockWithReceiptsRequest].
2445#[derive(Debug, Clone, PartialEq, Eq)]
2446pub struct GetBlockWithReceiptsRequestRef<'a> {
2447    pub block_id: &'a BlockId,
2448}
2449
2450/// Request for method starknet_getBlockWithTxHashes
2451#[derive(Debug, Clone, PartialEq, Eq)]
2452pub struct GetBlockWithTxHashesRequest {
2453    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2454    pub block_id: BlockId,
2455}
2456
2457/// Reference version of [GetBlockWithTxHashesRequest].
2458#[derive(Debug, Clone, PartialEq, Eq)]
2459pub struct GetBlockWithTxHashesRequestRef<'a> {
2460    pub block_id: &'a BlockId,
2461}
2462
2463/// Request for method starknet_getBlockWithTxs
2464#[derive(Debug, Clone, PartialEq, Eq)]
2465pub struct GetBlockWithTxsRequest {
2466    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2467    pub block_id: BlockId,
2468}
2469
2470/// Reference version of [GetBlockWithTxsRequest].
2471#[derive(Debug, Clone, PartialEq, Eq)]
2472pub struct GetBlockWithTxsRequestRef<'a> {
2473    pub block_id: &'a BlockId,
2474}
2475
2476/// Request for method starknet_getClassAt
2477#[derive(Debug, Clone, PartialEq, Eq)]
2478pub struct GetClassAtRequest {
2479    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2480    pub block_id: BlockId,
2481    /// The address of the contract whose class definition will be returned
2482    pub contract_address: Felt,
2483}
2484
2485/// Reference version of [GetClassAtRequest].
2486#[derive(Debug, Clone, PartialEq, Eq)]
2487pub struct GetClassAtRequestRef<'a> {
2488    pub block_id: &'a BlockId,
2489    pub contract_address: &'a Felt,
2490}
2491
2492/// Request for method starknet_getClassHashAt
2493#[derive(Debug, Clone, PartialEq, Eq)]
2494pub struct GetClassHashAtRequest {
2495    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2496    pub block_id: BlockId,
2497    /// The address of the contract whose class hash will be returned
2498    pub contract_address: Felt,
2499}
2500
2501/// Reference version of [GetClassHashAtRequest].
2502#[derive(Debug, Clone, PartialEq, Eq)]
2503pub struct GetClassHashAtRequestRef<'a> {
2504    pub block_id: &'a BlockId,
2505    pub contract_address: &'a Felt,
2506}
2507
2508/// Request for method starknet_getClass
2509#[derive(Debug, Clone, PartialEq, Eq)]
2510pub struct GetClassRequest {
2511    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2512    pub block_id: BlockId,
2513    /// The hash of the requested contract class
2514    pub class_hash: Felt,
2515}
2516
2517/// Reference version of [GetClassRequest].
2518#[derive(Debug, Clone, PartialEq, Eq)]
2519pub struct GetClassRequestRef<'a> {
2520    pub block_id: &'a BlockId,
2521    pub class_hash: &'a Felt,
2522}
2523
2524/// Request for method starknet_getEvents
2525#[derive(Debug, Clone, PartialEq, Eq)]
2526pub struct GetEventsRequest {
2527    pub filter: EventFilterWithPage,
2528}
2529
2530/// Reference version of [GetEventsRequest].
2531#[derive(Debug, Clone, PartialEq, Eq)]
2532pub struct GetEventsRequestRef<'a> {
2533    pub filter: &'a EventFilterWithPage,
2534}
2535
2536/// Request for method starknet_getMessagesStatus
2537#[derive(Debug, Clone, PartialEq, Eq)]
2538pub struct GetMessagesStatusRequest {
2539    pub transaction_hash: Hash256,
2540}
2541
2542/// Reference version of [GetMessagesStatusRequest].
2543#[derive(Debug, Clone, PartialEq, Eq)]
2544pub struct GetMessagesStatusRequestRef<'a> {
2545    pub transaction_hash: &'a Hash256,
2546}
2547
2548/// Request for method starknet_getNonce
2549#[derive(Debug, Clone, PartialEq, Eq)]
2550pub struct GetNonceRequest {
2551    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2552    pub block_id: BlockId,
2553    /// The address of the contract whose nonce we're seeking
2554    pub contract_address: Felt,
2555}
2556
2557/// Reference version of [GetNonceRequest].
2558#[derive(Debug, Clone, PartialEq, Eq)]
2559pub struct GetNonceRequestRef<'a> {
2560    pub block_id: &'a BlockId,
2561    pub contract_address: &'a Felt,
2562}
2563
2564/// Request for method starknet_getStateUpdate
2565#[derive(Debug, Clone, PartialEq, Eq)]
2566pub struct GetStateUpdateRequest {
2567    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2568    pub block_id: BlockId,
2569}
2570
2571/// Reference version of [GetStateUpdateRequest].
2572#[derive(Debug, Clone, PartialEq, Eq)]
2573pub struct GetStateUpdateRequestRef<'a> {
2574    pub block_id: &'a BlockId,
2575}
2576
2577/// Request for method starknet_getStorageAt
2578#[derive(Debug, Clone, PartialEq, Eq)]
2579pub struct GetStorageAtRequest {
2580    /// The address of the contract to read from
2581    pub contract_address: Felt,
2582    /// The key to the storage value for the given contract
2583    pub key: Felt,
2584    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2585    pub block_id: BlockId,
2586}
2587
2588/// Reference version of [GetStorageAtRequest].
2589#[derive(Debug, Clone, PartialEq, Eq)]
2590pub struct GetStorageAtRequestRef<'a> {
2591    pub contract_address: &'a Felt,
2592    pub key: &'a Felt,
2593    pub block_id: &'a BlockId,
2594}
2595
2596/// Request for method starknet_getStorageProof
2597#[derive(Debug, Clone, PartialEq, Eq)]
2598pub struct GetStorageProofRequest {
2599    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2600    pub block_id: ConfirmedBlockId,
2601    /// a list of the class hashes for which we want to prove membership in the classes trie
2602    pub class_hashes: Option<Vec<Felt>>,
2603    /// a list of contracts for which we want to prove membership in the global state trie
2604    pub contract_addresses: Option<Vec<Felt>>,
2605    /// a list of (contract_address, storage_keys) pairs
2606    pub contracts_storage_keys: Option<Vec<ContractStorageKeys>>,
2607}
2608
2609/// Reference version of [GetStorageProofRequest].
2610#[derive(Debug, Clone, PartialEq, Eq)]
2611pub struct GetStorageProofRequestRef<'a> {
2612    pub block_id: &'a ConfirmedBlockId,
2613    pub class_hashes: Option<&'a [Felt]>,
2614    pub contract_addresses: Option<&'a [Felt]>,
2615    pub contracts_storage_keys: Option<&'a [ContractStorageKeys]>,
2616}
2617
2618/// Request for method starknet_getTransactionByBlockIdAndIndex
2619#[derive(Debug, Clone, PartialEq, Eq)]
2620pub struct GetTransactionByBlockIdAndIndexRequest {
2621    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2622    pub block_id: BlockId,
2623    pub index: u64,
2624}
2625
2626/// Reference version of [GetTransactionByBlockIdAndIndexRequest].
2627#[derive(Debug, Clone, PartialEq, Eq)]
2628pub struct GetTransactionByBlockIdAndIndexRequestRef<'a> {
2629    pub block_id: &'a BlockId,
2630    pub index: &'a u64,
2631}
2632
2633/// Request for method starknet_getTransactionByHash
2634#[derive(Debug, Clone, PartialEq, Eq)]
2635pub struct GetTransactionByHashRequest {
2636    pub transaction_hash: Felt,
2637}
2638
2639/// Reference version of [GetTransactionByHashRequest].
2640#[derive(Debug, Clone, PartialEq, Eq)]
2641pub struct GetTransactionByHashRequestRef<'a> {
2642    pub transaction_hash: &'a Felt,
2643}
2644
2645/// Request for method starknet_getTransactionReceipt
2646#[derive(Debug, Clone, PartialEq, Eq)]
2647pub struct GetTransactionReceiptRequest {
2648    pub transaction_hash: Felt,
2649}
2650
2651/// Reference version of [GetTransactionReceiptRequest].
2652#[derive(Debug, Clone, PartialEq, Eq)]
2653pub struct GetTransactionReceiptRequestRef<'a> {
2654    pub transaction_hash: &'a Felt,
2655}
2656
2657/// Request for method starknet_getTransactionStatus
2658#[derive(Debug, Clone, PartialEq, Eq)]
2659pub struct GetTransactionStatusRequest {
2660    pub transaction_hash: Felt,
2661}
2662
2663/// Reference version of [GetTransactionStatusRequest].
2664#[derive(Debug, Clone, PartialEq, Eq)]
2665pub struct GetTransactionStatusRequestRef<'a> {
2666    pub transaction_hash: &'a Felt,
2667}
2668
2669/// Request for method starknet_simulateTransactions
2670#[derive(Debug, Clone, PartialEq, Eq)]
2671pub struct SimulateTransactionsRequest {
2672    /// The hash of the requested block, or number (height) of the requested block, or a block tag,
2673    /// for the block referencing the state or call the transaction on.
2674    pub block_id: BlockId,
2675    /// The transactions to simulate
2676    pub transactions: Vec<BroadcastedTransaction>,
2677    /// describes what parts of the transaction should be executed
2678    pub simulation_flags: Vec<SimulationFlag>,
2679}
2680
2681/// Reference version of [SimulateTransactionsRequest].
2682#[derive(Debug, Clone, PartialEq, Eq)]
2683pub struct SimulateTransactionsRequestRef<'a> {
2684    pub block_id: &'a BlockId,
2685    pub transactions: &'a [BroadcastedTransaction],
2686    pub simulation_flags: &'a [SimulationFlag],
2687}
2688
2689/// Request for method starknet_specVersion
2690#[derive(Debug, Clone, PartialEq, Eq)]
2691pub struct SpecVersionRequest;
2692
2693/// Request for method starknet_subscribeEvents
2694#[derive(Debug, Clone, PartialEq, Eq)]
2695pub struct SubscribeEventsRequest {
2696    pub from_address: Option<Felt>,
2697    pub keys: Option<Vec<Vec<Felt>>>,
2698    pub block_id: Option<ConfirmedBlockId>,
2699    pub finality_status: Option<L2TransactionFinalityStatus>,
2700}
2701
2702/// Reference version of [SubscribeEventsRequest].
2703#[derive(Debug, Clone, PartialEq, Eq)]
2704pub struct SubscribeEventsRequestRef<'a> {
2705    pub from_address: &'a Option<Felt>,
2706    pub keys: Option<&'a [Vec<Felt>]>,
2707    pub block_id: &'a Option<ConfirmedBlockId>,
2708    pub finality_status: &'a Option<L2TransactionFinalityStatus>,
2709}
2710
2711/// Request for method starknet_subscribeNewHeads
2712#[derive(Debug, Clone, PartialEq, Eq)]
2713pub struct SubscribeNewHeadsRequest {
2714    pub block_id: Option<ConfirmedBlockId>,
2715}
2716
2717/// Reference version of [SubscribeNewHeadsRequest].
2718#[derive(Debug, Clone, PartialEq, Eq)]
2719pub struct SubscribeNewHeadsRequestRef<'a> {
2720    pub block_id: &'a Option<ConfirmedBlockId>,
2721}
2722
2723/// Request for method starknet_subscribeNewTransactionReceipts
2724#[derive(Debug, Clone, PartialEq, Eq)]
2725pub struct SubscribeNewTransactionReceiptsRequest {
2726    pub finality_status: Option<Vec<L2TransactionFinalityStatus>>,
2727    pub sender_address: Option<Vec<Felt>>,
2728}
2729
2730/// Reference version of [SubscribeNewTransactionReceiptsRequest].
2731#[derive(Debug, Clone, PartialEq, Eq)]
2732pub struct SubscribeNewTransactionReceiptsRequestRef<'a> {
2733    pub finality_status: Option<&'a [L2TransactionFinalityStatus]>,
2734    pub sender_address: Option<&'a [Felt]>,
2735}
2736
2737/// Request for method starknet_subscribeNewTransactions
2738#[derive(Debug, Clone, PartialEq, Eq)]
2739pub struct SubscribeNewTransactionsRequest {
2740    pub finality_status: Option<Vec<L2TransactionStatus>>,
2741    pub sender_address: Option<Vec<Felt>>,
2742}
2743
2744/// Reference version of [SubscribeNewTransactionsRequest].
2745#[derive(Debug, Clone, PartialEq, Eq)]
2746pub struct SubscribeNewTransactionsRequestRef<'a> {
2747    pub finality_status: Option<&'a [L2TransactionStatus]>,
2748    pub sender_address: Option<&'a [Felt]>,
2749}
2750
2751/// Request for method starknet_subscribeTransactionStatus
2752#[derive(Debug, Clone, PartialEq, Eq)]
2753pub struct SubscribeTransactionStatusRequest {
2754    pub transaction_hash: Felt,
2755}
2756
2757/// Reference version of [SubscribeTransactionStatusRequest].
2758#[derive(Debug, Clone, PartialEq, Eq)]
2759pub struct SubscribeTransactionStatusRequestRef<'a> {
2760    pub transaction_hash: &'a Felt,
2761}
2762
2763/// Request for method starknet_subscriptionEvents
2764#[derive(Debug, Clone, PartialEq, Eq)]
2765pub struct SubscriptionEventsRequest {
2766    pub subscription_id: SubscriptionId,
2767    pub result: EmittedEventWithFinality,
2768}
2769
2770/// Reference version of [SubscriptionEventsRequest].
2771#[derive(Debug, Clone, PartialEq, Eq)]
2772pub struct SubscriptionEventsRequestRef<'a> {
2773    pub subscription_id: &'a SubscriptionId,
2774    pub result: &'a EmittedEventWithFinality,
2775}
2776
2777/// Request for method starknet_subscriptionNewHeads
2778#[derive(Debug, Clone, PartialEq, Eq)]
2779pub struct SubscriptionNewHeadsRequest {
2780    pub subscription_id: SubscriptionId,
2781    pub result: BlockHeader,
2782}
2783
2784/// Reference version of [SubscriptionNewHeadsRequest].
2785#[derive(Debug, Clone, PartialEq, Eq)]
2786pub struct SubscriptionNewHeadsRequestRef<'a> {
2787    pub subscription_id: &'a SubscriptionId,
2788    pub result: &'a BlockHeader,
2789}
2790
2791/// Request for method starknet_subscriptionNewTransactionReceipts
2792#[derive(Debug, Clone, PartialEq, Eq)]
2793pub struct SubscriptionNewTransactionReceiptsRequest {
2794    pub subscription_id: SubscriptionId,
2795    /// A transaction receipt
2796    pub result: TransactionReceiptWithBlockInfo,
2797}
2798
2799/// Reference version of [SubscriptionNewTransactionReceiptsRequest].
2800#[derive(Debug, Clone, PartialEq, Eq)]
2801pub struct SubscriptionNewTransactionReceiptsRequestRef<'a> {
2802    pub subscription_id: &'a SubscriptionId,
2803    pub result: &'a TransactionReceiptWithBlockInfo,
2804}
2805
2806/// Request for method starknet_subscriptionNewTransaction
2807#[derive(Debug, Clone, PartialEq, Eq)]
2808pub struct SubscriptionNewTransactionRequest {
2809    pub subscription_id: SubscriptionId,
2810    /// A transaction and its current finality status
2811    pub result: TransactionWithL2Status,
2812}
2813
2814/// Reference version of [SubscriptionNewTransactionRequest].
2815#[derive(Debug, Clone, PartialEq, Eq)]
2816pub struct SubscriptionNewTransactionRequestRef<'a> {
2817    pub subscription_id: &'a SubscriptionId,
2818    pub result: &'a TransactionWithL2Status,
2819}
2820
2821/// Request for method starknet_subscriptionReorg
2822#[derive(Debug, Clone, PartialEq, Eq)]
2823pub struct SubscriptionReorgRequest {
2824    pub subscription_id: SubscriptionId,
2825    pub result: ReorgData,
2826}
2827
2828/// Reference version of [SubscriptionReorgRequest].
2829#[derive(Debug, Clone, PartialEq, Eq)]
2830pub struct SubscriptionReorgRequestRef<'a> {
2831    pub subscription_id: &'a SubscriptionId,
2832    pub result: &'a ReorgData,
2833}
2834
2835/// Request for method starknet_subscriptionTransactionStatus
2836#[derive(Debug, Clone, PartialEq, Eq)]
2837pub struct SubscriptionTransactionStatusRequest {
2838    pub subscription_id: SubscriptionId,
2839    pub result: NewTransactionStatus,
2840}
2841
2842/// Reference version of [SubscriptionTransactionStatusRequest].
2843#[derive(Debug, Clone, PartialEq, Eq)]
2844pub struct SubscriptionTransactionStatusRequestRef<'a> {
2845    pub subscription_id: &'a SubscriptionId,
2846    pub result: &'a NewTransactionStatus,
2847}
2848
2849/// Request for method starknet_syncing
2850#[derive(Debug, Clone, PartialEq, Eq)]
2851pub struct SyncingRequest;
2852
2853/// Request for method starknet_traceBlockTransactions
2854#[derive(Debug, Clone, PartialEq, Eq)]
2855pub struct TraceBlockTransactionsRequest {
2856    /// The hash of the requested block, or number (height) of the requested block, or a block tag
2857    pub block_id: ConfirmedBlockId,
2858}
2859
2860/// Reference version of [TraceBlockTransactionsRequest].
2861#[derive(Debug, Clone, PartialEq, Eq)]
2862pub struct TraceBlockTransactionsRequestRef<'a> {
2863    pub block_id: &'a ConfirmedBlockId,
2864}
2865
2866/// Request for method starknet_traceTransaction
2867#[derive(Debug, Clone, PartialEq, Eq)]
2868pub struct TraceTransactionRequest {
2869    pub transaction_hash: Felt,
2870}
2871
2872/// Reference version of [TraceTransactionRequest].
2873#[derive(Debug, Clone, PartialEq, Eq)]
2874pub struct TraceTransactionRequestRef<'a> {
2875    pub transaction_hash: &'a Felt,
2876}
2877
2878/// Request for method starknet_unsubscribe
2879#[derive(Debug, Clone, PartialEq, Eq)]
2880pub struct UnsubscribeRequest {
2881    pub subscription_id: SubscriptionId,
2882}
2883
2884/// Reference version of [UnsubscribeRequest].
2885#[derive(Debug, Clone, PartialEq, Eq)]
2886pub struct UnsubscribeRequestRef<'a> {
2887    pub subscription_id: &'a SubscriptionId,
2888}
2889
2890impl Serialize for BroadcastedDeclareTransactionV3 {
2891    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2892        #[serde_as]
2893        #[derive(Serialize)]
2894        struct Tagged<'a> {
2895            pub r#type: &'a str,
2896            #[serde_as(as = "UfeHex")]
2897            pub sender_address: &'a Felt,
2898            #[serde_as(as = "UfeHex")]
2899            pub compiled_class_hash: &'a Felt,
2900            #[serde_as(as = "UfeHex")]
2901            pub version: &'a Felt,
2902            #[serde_as(as = "[UfeHex]")]
2903            pub signature: &'a [Felt],
2904            #[serde_as(as = "UfeHex")]
2905            pub nonce: &'a Felt,
2906            pub contract_class: &'a FlattenedSierraClass,
2907            pub resource_bounds: &'a ResourceBoundsMapping,
2908            #[serde_as(as = "NumAsHex")]
2909            pub tip: &'a u64,
2910            #[serde_as(as = "[UfeHex]")]
2911            pub paymaster_data: &'a [Felt],
2912            #[serde_as(as = "[UfeHex]")]
2913            pub account_deployment_data: &'a [Felt],
2914            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
2915            pub fee_data_availability_mode: &'a DataAvailabilityMode,
2916        }
2917
2918        let r#type = "DECLARE";
2919
2920        let version = &(if self.is_query {
2921            Felt::THREE + QUERY_VERSION_OFFSET
2922        } else {
2923            Felt::THREE
2924        });
2925
2926        let tagged = Tagged {
2927            r#type,
2928            sender_address: &self.sender_address,
2929            compiled_class_hash: &self.compiled_class_hash,
2930            version,
2931            signature: &self.signature,
2932            nonce: &self.nonce,
2933            contract_class: &self.contract_class,
2934            resource_bounds: &self.resource_bounds,
2935            tip: &self.tip,
2936            paymaster_data: &self.paymaster_data,
2937            account_deployment_data: &self.account_deployment_data,
2938            nonce_data_availability_mode: &self.nonce_data_availability_mode,
2939            fee_data_availability_mode: &self.fee_data_availability_mode,
2940        };
2941
2942        Tagged::serialize(&tagged, serializer)
2943    }
2944}
2945
2946impl<'de> Deserialize<'de> for BroadcastedDeclareTransactionV3 {
2947    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2948        #[serde_as]
2949        #[derive(Deserialize)]
2950        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
2951        struct Tagged {
2952            pub r#type: Option<String>,
2953            #[serde_as(as = "UfeHex")]
2954            pub sender_address: Felt,
2955            #[serde_as(as = "UfeHex")]
2956            pub compiled_class_hash: Felt,
2957            #[serde_as(as = "UfeHex")]
2958            pub version: Felt,
2959            #[serde_as(as = "Vec<UfeHex>")]
2960            pub signature: Vec<Felt>,
2961            #[serde_as(as = "UfeHex")]
2962            pub nonce: Felt,
2963            pub contract_class: FlattenedSierraClass,
2964            pub resource_bounds: ResourceBoundsMapping,
2965            #[serde_as(as = "NumAsHex")]
2966            pub tip: u64,
2967            #[serde_as(as = "Vec<UfeHex>")]
2968            pub paymaster_data: Vec<Felt>,
2969            #[serde_as(as = "Vec<UfeHex>")]
2970            pub account_deployment_data: Vec<Felt>,
2971            pub nonce_data_availability_mode: DataAvailabilityMode,
2972            pub fee_data_availability_mode: DataAvailabilityMode,
2973        }
2974
2975        let tagged = Tagged::deserialize(deserializer)?;
2976
2977        if let Some(tag_field) = &tagged.r#type {
2978            if tag_field != "DECLARE" {
2979                return Err(serde::de::Error::custom("invalid `type` value"));
2980            }
2981        }
2982
2983        let is_query = if tagged.version == Felt::THREE {
2984            false
2985        } else if tagged.version == Felt::THREE + QUERY_VERSION_OFFSET {
2986            true
2987        } else {
2988            return Err(serde::de::Error::custom("invalid `version` value"));
2989        };
2990
2991        Ok(Self {
2992            sender_address: tagged.sender_address,
2993            compiled_class_hash: tagged.compiled_class_hash,
2994            signature: tagged.signature,
2995            nonce: tagged.nonce,
2996            contract_class: OwnedPtr::new(tagged.contract_class),
2997            resource_bounds: tagged.resource_bounds,
2998            tip: tagged.tip,
2999            paymaster_data: tagged.paymaster_data,
3000            account_deployment_data: tagged.account_deployment_data,
3001            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
3002            fee_data_availability_mode: tagged.fee_data_availability_mode,
3003            is_query,
3004        })
3005    }
3006}
3007
3008impl Serialize for BroadcastedDeployAccountTransactionV3 {
3009    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3010        #[serde_as]
3011        #[derive(Serialize)]
3012        struct Tagged<'a> {
3013            pub r#type: &'a str,
3014            #[serde_as(as = "UfeHex")]
3015            pub version: &'a Felt,
3016            #[serde_as(as = "[UfeHex]")]
3017            pub signature: &'a [Felt],
3018            #[serde_as(as = "UfeHex")]
3019            pub nonce: &'a Felt,
3020            #[serde_as(as = "UfeHex")]
3021            pub contract_address_salt: &'a Felt,
3022            #[serde_as(as = "[UfeHex]")]
3023            pub constructor_calldata: &'a [Felt],
3024            #[serde_as(as = "UfeHex")]
3025            pub class_hash: &'a Felt,
3026            pub resource_bounds: &'a ResourceBoundsMapping,
3027            #[serde_as(as = "NumAsHex")]
3028            pub tip: &'a u64,
3029            #[serde_as(as = "[UfeHex]")]
3030            pub paymaster_data: &'a [Felt],
3031            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
3032            pub fee_data_availability_mode: &'a DataAvailabilityMode,
3033        }
3034
3035        let r#type = "DEPLOY_ACCOUNT";
3036
3037        let version = &(if self.is_query {
3038            Felt::THREE + QUERY_VERSION_OFFSET
3039        } else {
3040            Felt::THREE
3041        });
3042
3043        let tagged = Tagged {
3044            r#type,
3045            version,
3046            signature: &self.signature,
3047            nonce: &self.nonce,
3048            contract_address_salt: &self.contract_address_salt,
3049            constructor_calldata: &self.constructor_calldata,
3050            class_hash: &self.class_hash,
3051            resource_bounds: &self.resource_bounds,
3052            tip: &self.tip,
3053            paymaster_data: &self.paymaster_data,
3054            nonce_data_availability_mode: &self.nonce_data_availability_mode,
3055            fee_data_availability_mode: &self.fee_data_availability_mode,
3056        };
3057
3058        Tagged::serialize(&tagged, serializer)
3059    }
3060}
3061
3062impl<'de> Deserialize<'de> for BroadcastedDeployAccountTransactionV3 {
3063    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3064        #[serde_as]
3065        #[derive(Deserialize)]
3066        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3067        struct Tagged {
3068            pub r#type: Option<String>,
3069            #[serde_as(as = "UfeHex")]
3070            pub version: Felt,
3071            #[serde_as(as = "Vec<UfeHex>")]
3072            pub signature: Vec<Felt>,
3073            #[serde_as(as = "UfeHex")]
3074            pub nonce: Felt,
3075            #[serde_as(as = "UfeHex")]
3076            pub contract_address_salt: Felt,
3077            #[serde_as(as = "Vec<UfeHex>")]
3078            pub constructor_calldata: Vec<Felt>,
3079            #[serde_as(as = "UfeHex")]
3080            pub class_hash: Felt,
3081            pub resource_bounds: ResourceBoundsMapping,
3082            #[serde_as(as = "NumAsHex")]
3083            pub tip: u64,
3084            #[serde_as(as = "Vec<UfeHex>")]
3085            pub paymaster_data: Vec<Felt>,
3086            pub nonce_data_availability_mode: DataAvailabilityMode,
3087            pub fee_data_availability_mode: DataAvailabilityMode,
3088        }
3089
3090        let tagged = Tagged::deserialize(deserializer)?;
3091
3092        if let Some(tag_field) = &tagged.r#type {
3093            if tag_field != "DEPLOY_ACCOUNT" {
3094                return Err(serde::de::Error::custom("invalid `type` value"));
3095            }
3096        }
3097
3098        let is_query = if tagged.version == Felt::THREE {
3099            false
3100        } else if tagged.version == Felt::THREE + QUERY_VERSION_OFFSET {
3101            true
3102        } else {
3103            return Err(serde::de::Error::custom("invalid `version` value"));
3104        };
3105
3106        Ok(Self {
3107            signature: tagged.signature,
3108            nonce: tagged.nonce,
3109            contract_address_salt: tagged.contract_address_salt,
3110            constructor_calldata: tagged.constructor_calldata,
3111            class_hash: tagged.class_hash,
3112            resource_bounds: tagged.resource_bounds,
3113            tip: tagged.tip,
3114            paymaster_data: tagged.paymaster_data,
3115            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
3116            fee_data_availability_mode: tagged.fee_data_availability_mode,
3117            is_query,
3118        })
3119    }
3120}
3121
3122impl Serialize for BroadcastedInvokeTransactionV3 {
3123    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3124        #[serde_as]
3125        #[derive(Serialize)]
3126        struct Tagged<'a> {
3127            pub r#type: &'a str,
3128            #[serde_as(as = "UfeHex")]
3129            pub sender_address: &'a Felt,
3130            #[serde_as(as = "[UfeHex]")]
3131            pub calldata: &'a [Felt],
3132            #[serde_as(as = "UfeHex")]
3133            pub version: &'a Felt,
3134            #[serde_as(as = "[UfeHex]")]
3135            pub signature: &'a [Felt],
3136            #[serde_as(as = "UfeHex")]
3137            pub nonce: &'a Felt,
3138            pub resource_bounds: &'a ResourceBoundsMapping,
3139            #[serde_as(as = "NumAsHex")]
3140            pub tip: &'a u64,
3141            #[serde_as(as = "[UfeHex]")]
3142            pub paymaster_data: &'a [Felt],
3143            #[serde_as(as = "[UfeHex]")]
3144            pub account_deployment_data: &'a [Felt],
3145            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
3146            pub fee_data_availability_mode: &'a DataAvailabilityMode,
3147        }
3148
3149        let r#type = "INVOKE";
3150
3151        let version = &(if self.is_query {
3152            Felt::THREE + QUERY_VERSION_OFFSET
3153        } else {
3154            Felt::THREE
3155        });
3156
3157        let tagged = Tagged {
3158            r#type,
3159            sender_address: &self.sender_address,
3160            calldata: &self.calldata,
3161            version,
3162            signature: &self.signature,
3163            nonce: &self.nonce,
3164            resource_bounds: &self.resource_bounds,
3165            tip: &self.tip,
3166            paymaster_data: &self.paymaster_data,
3167            account_deployment_data: &self.account_deployment_data,
3168            nonce_data_availability_mode: &self.nonce_data_availability_mode,
3169            fee_data_availability_mode: &self.fee_data_availability_mode,
3170        };
3171
3172        Tagged::serialize(&tagged, serializer)
3173    }
3174}
3175
3176impl<'de> Deserialize<'de> for BroadcastedInvokeTransactionV3 {
3177    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3178        #[serde_as]
3179        #[derive(Deserialize)]
3180        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3181        struct Tagged {
3182            pub r#type: Option<String>,
3183            #[serde_as(as = "UfeHex")]
3184            pub sender_address: Felt,
3185            #[serde_as(as = "Vec<UfeHex>")]
3186            pub calldata: Vec<Felt>,
3187            #[serde_as(as = "UfeHex")]
3188            pub version: Felt,
3189            #[serde_as(as = "Vec<UfeHex>")]
3190            pub signature: Vec<Felt>,
3191            #[serde_as(as = "UfeHex")]
3192            pub nonce: Felt,
3193            pub resource_bounds: ResourceBoundsMapping,
3194            #[serde_as(as = "NumAsHex")]
3195            pub tip: u64,
3196            #[serde_as(as = "Vec<UfeHex>")]
3197            pub paymaster_data: Vec<Felt>,
3198            #[serde_as(as = "Vec<UfeHex>")]
3199            pub account_deployment_data: Vec<Felt>,
3200            pub nonce_data_availability_mode: DataAvailabilityMode,
3201            pub fee_data_availability_mode: DataAvailabilityMode,
3202        }
3203
3204        let tagged = Tagged::deserialize(deserializer)?;
3205
3206        if let Some(tag_field) = &tagged.r#type {
3207            if tag_field != "INVOKE" {
3208                return Err(serde::de::Error::custom("invalid `type` value"));
3209            }
3210        }
3211
3212        let is_query = if tagged.version == Felt::THREE {
3213            false
3214        } else if tagged.version == Felt::THREE + QUERY_VERSION_OFFSET {
3215            true
3216        } else {
3217            return Err(serde::de::Error::custom("invalid `version` value"));
3218        };
3219
3220        Ok(Self {
3221            sender_address: tagged.sender_address,
3222            calldata: tagged.calldata,
3223            signature: tagged.signature,
3224            nonce: tagged.nonce,
3225            resource_bounds: tagged.resource_bounds,
3226            tip: tagged.tip,
3227            paymaster_data: tagged.paymaster_data,
3228            account_deployment_data: tagged.account_deployment_data,
3229            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
3230            fee_data_availability_mode: tagged.fee_data_availability_mode,
3231            is_query,
3232        })
3233    }
3234}
3235
3236impl Serialize for DeclareTransactionReceipt {
3237    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3238        #[serde_as]
3239        #[derive(Serialize)]
3240        struct Tagged<'a> {
3241            pub r#type: &'a str,
3242            #[serde_as(as = "UfeHex")]
3243            pub transaction_hash: &'a Felt,
3244            pub actual_fee: &'a FeePayment,
3245            pub finality_status: &'a TransactionFinalityStatus,
3246            pub messages_sent: &'a [MsgToL1],
3247            pub events: &'a [Event],
3248            pub execution_resources: &'a ExecutionResources,
3249            #[serde(flatten)]
3250            pub execution_result: &'a ExecutionResult,
3251        }
3252
3253        let r#type = "DECLARE";
3254
3255        let tagged = Tagged {
3256            r#type,
3257            transaction_hash: &self.transaction_hash,
3258            actual_fee: &self.actual_fee,
3259            finality_status: &self.finality_status,
3260            messages_sent: &self.messages_sent,
3261            events: &self.events,
3262            execution_resources: &self.execution_resources,
3263            execution_result: &self.execution_result,
3264        };
3265
3266        Tagged::serialize(&tagged, serializer)
3267    }
3268}
3269
3270impl<'de> Deserialize<'de> for DeclareTransactionReceipt {
3271    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3272        #[serde_as]
3273        #[derive(Deserialize)]
3274        struct Tagged {
3275            pub r#type: Option<String>,
3276            #[serde_as(as = "UfeHex")]
3277            pub transaction_hash: Felt,
3278            pub actual_fee: FeePayment,
3279            pub finality_status: TransactionFinalityStatus,
3280            pub messages_sent: Vec<MsgToL1>,
3281            pub events: Vec<Event>,
3282            pub execution_resources: ExecutionResources,
3283            #[serde(flatten)]
3284            pub execution_result: ExecutionResult,
3285        }
3286
3287        let tagged = Tagged::deserialize(deserializer)?;
3288
3289        if let Some(tag_field) = &tagged.r#type {
3290            if tag_field != "DECLARE" {
3291                return Err(serde::de::Error::custom("invalid `type` value"));
3292            }
3293        }
3294
3295        Ok(Self {
3296            transaction_hash: tagged.transaction_hash,
3297            actual_fee: tagged.actual_fee,
3298            finality_status: tagged.finality_status,
3299            messages_sent: tagged.messages_sent,
3300            events: tagged.events,
3301            execution_resources: tagged.execution_resources,
3302            execution_result: tagged.execution_result,
3303        })
3304    }
3305}
3306
3307impl Serialize for DeclareTransactionTrace {
3308    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3309        #[derive(Serialize)]
3310        struct Tagged<'a> {
3311            #[serde(skip_serializing_if = "Option::is_none")]
3312            pub validate_invocation: &'a Option<FunctionInvocation>,
3313            #[serde(skip_serializing_if = "Option::is_none")]
3314            pub fee_transfer_invocation: &'a Option<FunctionInvocation>,
3315            #[serde(skip_serializing_if = "Option::is_none")]
3316            pub state_diff: &'a Option<StateDiff>,
3317            pub execution_resources: &'a ExecutionResources,
3318            pub r#type: &'a str,
3319        }
3320
3321        let r#type = "DECLARE";
3322
3323        let tagged = Tagged {
3324            validate_invocation: &self.validate_invocation,
3325            fee_transfer_invocation: &self.fee_transfer_invocation,
3326            state_diff: &self.state_diff,
3327            execution_resources: &self.execution_resources,
3328            r#type,
3329        };
3330
3331        Tagged::serialize(&tagged, serializer)
3332    }
3333}
3334
3335impl<'de> Deserialize<'de> for DeclareTransactionTrace {
3336    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3337        #[derive(Deserialize)]
3338        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3339        struct Tagged {
3340            #[serde(skip_serializing_if = "Option::is_none")]
3341            pub validate_invocation: Option<FunctionInvocation>,
3342            #[serde(skip_serializing_if = "Option::is_none")]
3343            pub fee_transfer_invocation: Option<FunctionInvocation>,
3344            #[serde(skip_serializing_if = "Option::is_none")]
3345            pub state_diff: Option<StateDiff>,
3346            pub execution_resources: ExecutionResources,
3347            pub r#type: Option<String>,
3348        }
3349
3350        let tagged = Tagged::deserialize(deserializer)?;
3351
3352        if let Some(tag_field) = &tagged.r#type {
3353            if tag_field != "DECLARE" {
3354                return Err(serde::de::Error::custom("invalid `type` value"));
3355            }
3356        }
3357
3358        Ok(Self {
3359            validate_invocation: tagged.validate_invocation,
3360            fee_transfer_invocation: tagged.fee_transfer_invocation,
3361            state_diff: tagged.state_diff,
3362            execution_resources: tagged.execution_resources,
3363        })
3364    }
3365}
3366
3367impl Serialize for DeclareTransactionV0 {
3368    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3369        #[serde_as]
3370        #[derive(Serialize)]
3371        struct Tagged<'a> {
3372            #[serde_as(as = "UfeHex")]
3373            pub transaction_hash: &'a Felt,
3374            pub r#type: &'a str,
3375            #[serde_as(as = "UfeHex")]
3376            pub sender_address: &'a Felt,
3377            #[serde_as(as = "UfeHex")]
3378            pub max_fee: &'a Felt,
3379            #[serde_as(as = "NumAsHex")]
3380            pub version: &'a u64,
3381            #[serde_as(as = "[UfeHex]")]
3382            pub signature: &'a [Felt],
3383            #[serde_as(as = "UfeHex")]
3384            pub class_hash: &'a Felt,
3385        }
3386
3387        let r#type = "DECLARE";
3388
3389        let version = &0;
3390
3391        let tagged = Tagged {
3392            transaction_hash: &self.transaction_hash,
3393            r#type,
3394            sender_address: &self.sender_address,
3395            max_fee: &self.max_fee,
3396            version,
3397            signature: &self.signature,
3398            class_hash: &self.class_hash,
3399        };
3400
3401        Tagged::serialize(&tagged, serializer)
3402    }
3403}
3404
3405impl<'de> Deserialize<'de> for DeclareTransactionV0 {
3406    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3407        #[serde_as]
3408        #[derive(Deserialize)]
3409        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3410        struct Tagged {
3411            #[serde_as(as = "UfeHex")]
3412            pub transaction_hash: Felt,
3413            pub r#type: Option<String>,
3414            #[serde_as(as = "UfeHex")]
3415            pub sender_address: Felt,
3416            #[serde_as(as = "UfeHex")]
3417            pub max_fee: Felt,
3418            #[serde_as(as = "Option<NumAsHex>")]
3419            pub version: Option<u64>,
3420            #[serde_as(as = "Vec<UfeHex>")]
3421            pub signature: Vec<Felt>,
3422            #[serde_as(as = "UfeHex")]
3423            pub class_hash: Felt,
3424        }
3425
3426        let tagged = Tagged::deserialize(deserializer)?;
3427
3428        if let Some(tag_field) = &tagged.r#type {
3429            if tag_field != "DECLARE" {
3430                return Err(serde::de::Error::custom("invalid `type` value"));
3431            }
3432        }
3433
3434        if let Some(tag_field) = &tagged.version {
3435            if tag_field != &0 {
3436                return Err(serde::de::Error::custom("invalid `version` value"));
3437            }
3438        }
3439
3440        Ok(Self {
3441            transaction_hash: tagged.transaction_hash,
3442            sender_address: tagged.sender_address,
3443            max_fee: tagged.max_fee,
3444            signature: tagged.signature,
3445            class_hash: tagged.class_hash,
3446        })
3447    }
3448}
3449
3450impl Serialize for DeclareTransactionV0Content {
3451    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3452        #[serde_as]
3453        #[derive(Serialize)]
3454        struct Tagged<'a> {
3455            pub r#type: &'a str,
3456            #[serde_as(as = "UfeHex")]
3457            pub sender_address: &'a Felt,
3458            #[serde_as(as = "UfeHex")]
3459            pub max_fee: &'a Felt,
3460            #[serde_as(as = "NumAsHex")]
3461            pub version: &'a u64,
3462            #[serde_as(as = "[UfeHex]")]
3463            pub signature: &'a [Felt],
3464            #[serde_as(as = "UfeHex")]
3465            pub class_hash: &'a Felt,
3466        }
3467
3468        let r#type = "DECLARE";
3469
3470        let version = &0;
3471
3472        let tagged = Tagged {
3473            r#type,
3474            sender_address: &self.sender_address,
3475            max_fee: &self.max_fee,
3476            version,
3477            signature: &self.signature,
3478            class_hash: &self.class_hash,
3479        };
3480
3481        Tagged::serialize(&tagged, serializer)
3482    }
3483}
3484
3485impl<'de> Deserialize<'de> for DeclareTransactionV0Content {
3486    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3487        #[serde_as]
3488        #[derive(Deserialize)]
3489        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3490        struct Tagged {
3491            pub r#type: Option<String>,
3492            #[serde_as(as = "UfeHex")]
3493            pub sender_address: Felt,
3494            #[serde_as(as = "UfeHex")]
3495            pub max_fee: Felt,
3496            #[serde_as(as = "Option<NumAsHex>")]
3497            pub version: Option<u64>,
3498            #[serde_as(as = "Vec<UfeHex>")]
3499            pub signature: Vec<Felt>,
3500            #[serde_as(as = "UfeHex")]
3501            pub class_hash: Felt,
3502        }
3503
3504        let tagged = Tagged::deserialize(deserializer)?;
3505
3506        if let Some(tag_field) = &tagged.r#type {
3507            if tag_field != "DECLARE" {
3508                return Err(serde::de::Error::custom("invalid `type` value"));
3509            }
3510        }
3511
3512        if let Some(tag_field) = &tagged.version {
3513            if tag_field != &0 {
3514                return Err(serde::de::Error::custom("invalid `version` value"));
3515            }
3516        }
3517
3518        Ok(Self {
3519            sender_address: tagged.sender_address,
3520            max_fee: tagged.max_fee,
3521            signature: tagged.signature,
3522            class_hash: tagged.class_hash,
3523        })
3524    }
3525}
3526
3527impl Serialize for DeclareTransactionV1 {
3528    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3529        #[serde_as]
3530        #[derive(Serialize)]
3531        struct Tagged<'a> {
3532            #[serde_as(as = "UfeHex")]
3533            pub transaction_hash: &'a Felt,
3534            pub r#type: &'a str,
3535            #[serde_as(as = "UfeHex")]
3536            pub sender_address: &'a Felt,
3537            #[serde_as(as = "UfeHex")]
3538            pub max_fee: &'a Felt,
3539            #[serde_as(as = "NumAsHex")]
3540            pub version: &'a u64,
3541            #[serde_as(as = "[UfeHex]")]
3542            pub signature: &'a [Felt],
3543            #[serde_as(as = "UfeHex")]
3544            pub nonce: &'a Felt,
3545            #[serde_as(as = "UfeHex")]
3546            pub class_hash: &'a Felt,
3547        }
3548
3549        let r#type = "DECLARE";
3550
3551        let version = &1;
3552
3553        let tagged = Tagged {
3554            transaction_hash: &self.transaction_hash,
3555            r#type,
3556            sender_address: &self.sender_address,
3557            max_fee: &self.max_fee,
3558            version,
3559            signature: &self.signature,
3560            nonce: &self.nonce,
3561            class_hash: &self.class_hash,
3562        };
3563
3564        Tagged::serialize(&tagged, serializer)
3565    }
3566}
3567
3568impl<'de> Deserialize<'de> for DeclareTransactionV1 {
3569    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3570        #[serde_as]
3571        #[derive(Deserialize)]
3572        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3573        struct Tagged {
3574            #[serde_as(as = "UfeHex")]
3575            pub transaction_hash: Felt,
3576            pub r#type: Option<String>,
3577            #[serde_as(as = "UfeHex")]
3578            pub sender_address: Felt,
3579            #[serde_as(as = "UfeHex")]
3580            pub max_fee: Felt,
3581            #[serde_as(as = "Option<NumAsHex>")]
3582            pub version: Option<u64>,
3583            #[serde_as(as = "Vec<UfeHex>")]
3584            pub signature: Vec<Felt>,
3585            #[serde_as(as = "UfeHex")]
3586            pub nonce: Felt,
3587            #[serde_as(as = "UfeHex")]
3588            pub class_hash: Felt,
3589        }
3590
3591        let tagged = Tagged::deserialize(deserializer)?;
3592
3593        if let Some(tag_field) = &tagged.r#type {
3594            if tag_field != "DECLARE" {
3595                return Err(serde::de::Error::custom("invalid `type` value"));
3596            }
3597        }
3598
3599        if let Some(tag_field) = &tagged.version {
3600            if tag_field != &1 {
3601                return Err(serde::de::Error::custom("invalid `version` value"));
3602            }
3603        }
3604
3605        Ok(Self {
3606            transaction_hash: tagged.transaction_hash,
3607            sender_address: tagged.sender_address,
3608            max_fee: tagged.max_fee,
3609            signature: tagged.signature,
3610            nonce: tagged.nonce,
3611            class_hash: tagged.class_hash,
3612        })
3613    }
3614}
3615
3616impl Serialize for DeclareTransactionV1Content {
3617    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3618        #[serde_as]
3619        #[derive(Serialize)]
3620        struct Tagged<'a> {
3621            pub r#type: &'a str,
3622            #[serde_as(as = "UfeHex")]
3623            pub sender_address: &'a Felt,
3624            #[serde_as(as = "UfeHex")]
3625            pub max_fee: &'a Felt,
3626            #[serde_as(as = "NumAsHex")]
3627            pub version: &'a u64,
3628            #[serde_as(as = "[UfeHex]")]
3629            pub signature: &'a [Felt],
3630            #[serde_as(as = "UfeHex")]
3631            pub nonce: &'a Felt,
3632            #[serde_as(as = "UfeHex")]
3633            pub class_hash: &'a Felt,
3634        }
3635
3636        let r#type = "DECLARE";
3637
3638        let version = &1;
3639
3640        let tagged = Tagged {
3641            r#type,
3642            sender_address: &self.sender_address,
3643            max_fee: &self.max_fee,
3644            version,
3645            signature: &self.signature,
3646            nonce: &self.nonce,
3647            class_hash: &self.class_hash,
3648        };
3649
3650        Tagged::serialize(&tagged, serializer)
3651    }
3652}
3653
3654impl<'de> Deserialize<'de> for DeclareTransactionV1Content {
3655    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3656        #[serde_as]
3657        #[derive(Deserialize)]
3658        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3659        struct Tagged {
3660            pub r#type: Option<String>,
3661            #[serde_as(as = "UfeHex")]
3662            pub sender_address: Felt,
3663            #[serde_as(as = "UfeHex")]
3664            pub max_fee: Felt,
3665            #[serde_as(as = "Option<NumAsHex>")]
3666            pub version: Option<u64>,
3667            #[serde_as(as = "Vec<UfeHex>")]
3668            pub signature: Vec<Felt>,
3669            #[serde_as(as = "UfeHex")]
3670            pub nonce: Felt,
3671            #[serde_as(as = "UfeHex")]
3672            pub class_hash: Felt,
3673        }
3674
3675        let tagged = Tagged::deserialize(deserializer)?;
3676
3677        if let Some(tag_field) = &tagged.r#type {
3678            if tag_field != "DECLARE" {
3679                return Err(serde::de::Error::custom("invalid `type` value"));
3680            }
3681        }
3682
3683        if let Some(tag_field) = &tagged.version {
3684            if tag_field != &1 {
3685                return Err(serde::de::Error::custom("invalid `version` value"));
3686            }
3687        }
3688
3689        Ok(Self {
3690            sender_address: tagged.sender_address,
3691            max_fee: tagged.max_fee,
3692            signature: tagged.signature,
3693            nonce: tagged.nonce,
3694            class_hash: tagged.class_hash,
3695        })
3696    }
3697}
3698
3699impl Serialize for DeclareTransactionV2 {
3700    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3701        #[serde_as]
3702        #[derive(Serialize)]
3703        struct Tagged<'a> {
3704            #[serde_as(as = "UfeHex")]
3705            pub transaction_hash: &'a Felt,
3706            pub r#type: &'a str,
3707            #[serde_as(as = "UfeHex")]
3708            pub sender_address: &'a Felt,
3709            #[serde_as(as = "UfeHex")]
3710            pub compiled_class_hash: &'a Felt,
3711            #[serde_as(as = "UfeHex")]
3712            pub max_fee: &'a Felt,
3713            #[serde_as(as = "NumAsHex")]
3714            pub version: &'a u64,
3715            #[serde_as(as = "[UfeHex]")]
3716            pub signature: &'a [Felt],
3717            #[serde_as(as = "UfeHex")]
3718            pub nonce: &'a Felt,
3719            #[serde_as(as = "UfeHex")]
3720            pub class_hash: &'a Felt,
3721        }
3722
3723        let r#type = "DECLARE";
3724
3725        let version = &2;
3726
3727        let tagged = Tagged {
3728            transaction_hash: &self.transaction_hash,
3729            r#type,
3730            sender_address: &self.sender_address,
3731            compiled_class_hash: &self.compiled_class_hash,
3732            max_fee: &self.max_fee,
3733            version,
3734            signature: &self.signature,
3735            nonce: &self.nonce,
3736            class_hash: &self.class_hash,
3737        };
3738
3739        Tagged::serialize(&tagged, serializer)
3740    }
3741}
3742
3743impl<'de> Deserialize<'de> for DeclareTransactionV2 {
3744    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3745        #[serde_as]
3746        #[derive(Deserialize)]
3747        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3748        struct Tagged {
3749            #[serde_as(as = "UfeHex")]
3750            pub transaction_hash: Felt,
3751            pub r#type: Option<String>,
3752            #[serde_as(as = "UfeHex")]
3753            pub sender_address: Felt,
3754            #[serde_as(as = "UfeHex")]
3755            pub compiled_class_hash: Felt,
3756            #[serde_as(as = "UfeHex")]
3757            pub max_fee: Felt,
3758            #[serde_as(as = "Option<NumAsHex>")]
3759            pub version: Option<u64>,
3760            #[serde_as(as = "Vec<UfeHex>")]
3761            pub signature: Vec<Felt>,
3762            #[serde_as(as = "UfeHex")]
3763            pub nonce: Felt,
3764            #[serde_as(as = "UfeHex")]
3765            pub class_hash: Felt,
3766        }
3767
3768        let tagged = Tagged::deserialize(deserializer)?;
3769
3770        if let Some(tag_field) = &tagged.r#type {
3771            if tag_field != "DECLARE" {
3772                return Err(serde::de::Error::custom("invalid `type` value"));
3773            }
3774        }
3775
3776        if let Some(tag_field) = &tagged.version {
3777            if tag_field != &2 {
3778                return Err(serde::de::Error::custom("invalid `version` value"));
3779            }
3780        }
3781
3782        Ok(Self {
3783            transaction_hash: tagged.transaction_hash,
3784            sender_address: tagged.sender_address,
3785            compiled_class_hash: tagged.compiled_class_hash,
3786            max_fee: tagged.max_fee,
3787            signature: tagged.signature,
3788            nonce: tagged.nonce,
3789            class_hash: tagged.class_hash,
3790        })
3791    }
3792}
3793
3794impl Serialize for DeclareTransactionV2Content {
3795    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3796        #[serde_as]
3797        #[derive(Serialize)]
3798        struct Tagged<'a> {
3799            pub r#type: &'a str,
3800            #[serde_as(as = "UfeHex")]
3801            pub sender_address: &'a Felt,
3802            #[serde_as(as = "UfeHex")]
3803            pub compiled_class_hash: &'a Felt,
3804            #[serde_as(as = "UfeHex")]
3805            pub max_fee: &'a Felt,
3806            #[serde_as(as = "NumAsHex")]
3807            pub version: &'a u64,
3808            #[serde_as(as = "[UfeHex]")]
3809            pub signature: &'a [Felt],
3810            #[serde_as(as = "UfeHex")]
3811            pub nonce: &'a Felt,
3812            #[serde_as(as = "UfeHex")]
3813            pub class_hash: &'a Felt,
3814        }
3815
3816        let r#type = "DECLARE";
3817
3818        let version = &2;
3819
3820        let tagged = Tagged {
3821            r#type,
3822            sender_address: &self.sender_address,
3823            compiled_class_hash: &self.compiled_class_hash,
3824            max_fee: &self.max_fee,
3825            version,
3826            signature: &self.signature,
3827            nonce: &self.nonce,
3828            class_hash: &self.class_hash,
3829        };
3830
3831        Tagged::serialize(&tagged, serializer)
3832    }
3833}
3834
3835impl<'de> Deserialize<'de> for DeclareTransactionV2Content {
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            pub r#type: Option<String>,
3842            #[serde_as(as = "UfeHex")]
3843            pub sender_address: Felt,
3844            #[serde_as(as = "UfeHex")]
3845            pub compiled_class_hash: Felt,
3846            #[serde_as(as = "UfeHex")]
3847            pub max_fee: Felt,
3848            #[serde_as(as = "Option<NumAsHex>")]
3849            pub version: Option<u64>,
3850            #[serde_as(as = "Vec<UfeHex>")]
3851            pub signature: Vec<Felt>,
3852            #[serde_as(as = "UfeHex")]
3853            pub nonce: Felt,
3854            #[serde_as(as = "UfeHex")]
3855            pub class_hash: Felt,
3856        }
3857
3858        let tagged = Tagged::deserialize(deserializer)?;
3859
3860        if let Some(tag_field) = &tagged.r#type {
3861            if tag_field != "DECLARE" {
3862                return Err(serde::de::Error::custom("invalid `type` value"));
3863            }
3864        }
3865
3866        if let Some(tag_field) = &tagged.version {
3867            if tag_field != &2 {
3868                return Err(serde::de::Error::custom("invalid `version` value"));
3869            }
3870        }
3871
3872        Ok(Self {
3873            sender_address: tagged.sender_address,
3874            compiled_class_hash: tagged.compiled_class_hash,
3875            max_fee: tagged.max_fee,
3876            signature: tagged.signature,
3877            nonce: tagged.nonce,
3878            class_hash: tagged.class_hash,
3879        })
3880    }
3881}
3882
3883impl Serialize for DeclareTransactionV3 {
3884    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3885        #[serde_as]
3886        #[derive(Serialize)]
3887        struct Tagged<'a> {
3888            #[serde_as(as = "UfeHex")]
3889            pub transaction_hash: &'a Felt,
3890            pub r#type: &'a str,
3891            #[serde_as(as = "UfeHex")]
3892            pub sender_address: &'a Felt,
3893            #[serde_as(as = "UfeHex")]
3894            pub compiled_class_hash: &'a Felt,
3895            #[serde_as(as = "NumAsHex")]
3896            pub version: &'a u64,
3897            #[serde_as(as = "[UfeHex]")]
3898            pub signature: &'a [Felt],
3899            #[serde_as(as = "UfeHex")]
3900            pub nonce: &'a Felt,
3901            #[serde_as(as = "UfeHex")]
3902            pub class_hash: &'a Felt,
3903            pub resource_bounds: &'a ResourceBoundsMapping,
3904            #[serde_as(as = "NumAsHex")]
3905            pub tip: &'a u64,
3906            #[serde_as(as = "[UfeHex]")]
3907            pub paymaster_data: &'a [Felt],
3908            #[serde_as(as = "[UfeHex]")]
3909            pub account_deployment_data: &'a [Felt],
3910            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
3911            pub fee_data_availability_mode: &'a DataAvailabilityMode,
3912        }
3913
3914        let r#type = "DECLARE";
3915
3916        let version = &3;
3917
3918        let tagged = Tagged {
3919            transaction_hash: &self.transaction_hash,
3920            r#type,
3921            sender_address: &self.sender_address,
3922            compiled_class_hash: &self.compiled_class_hash,
3923            version,
3924            signature: &self.signature,
3925            nonce: &self.nonce,
3926            class_hash: &self.class_hash,
3927            resource_bounds: &self.resource_bounds,
3928            tip: &self.tip,
3929            paymaster_data: &self.paymaster_data,
3930            account_deployment_data: &self.account_deployment_data,
3931            nonce_data_availability_mode: &self.nonce_data_availability_mode,
3932            fee_data_availability_mode: &self.fee_data_availability_mode,
3933        };
3934
3935        Tagged::serialize(&tagged, serializer)
3936    }
3937}
3938
3939impl<'de> Deserialize<'de> for DeclareTransactionV3 {
3940    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3941        #[serde_as]
3942        #[derive(Deserialize)]
3943        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
3944        struct Tagged {
3945            #[serde_as(as = "UfeHex")]
3946            pub transaction_hash: Felt,
3947            pub r#type: Option<String>,
3948            #[serde_as(as = "UfeHex")]
3949            pub sender_address: Felt,
3950            #[serde_as(as = "UfeHex")]
3951            pub compiled_class_hash: Felt,
3952            #[serde_as(as = "Option<NumAsHex>")]
3953            pub version: Option<u64>,
3954            #[serde_as(as = "Vec<UfeHex>")]
3955            pub signature: Vec<Felt>,
3956            #[serde_as(as = "UfeHex")]
3957            pub nonce: Felt,
3958            #[serde_as(as = "UfeHex")]
3959            pub class_hash: Felt,
3960            pub resource_bounds: ResourceBoundsMapping,
3961            #[serde_as(as = "NumAsHex")]
3962            pub tip: u64,
3963            #[serde_as(as = "Vec<UfeHex>")]
3964            pub paymaster_data: Vec<Felt>,
3965            #[serde_as(as = "Vec<UfeHex>")]
3966            pub account_deployment_data: Vec<Felt>,
3967            pub nonce_data_availability_mode: DataAvailabilityMode,
3968            pub fee_data_availability_mode: DataAvailabilityMode,
3969        }
3970
3971        let tagged = Tagged::deserialize(deserializer)?;
3972
3973        if let Some(tag_field) = &tagged.r#type {
3974            if tag_field != "DECLARE" {
3975                return Err(serde::de::Error::custom("invalid `type` value"));
3976            }
3977        }
3978
3979        if let Some(tag_field) = &tagged.version {
3980            if tag_field != &3 {
3981                return Err(serde::de::Error::custom("invalid `version` value"));
3982            }
3983        }
3984
3985        Ok(Self {
3986            transaction_hash: tagged.transaction_hash,
3987            sender_address: tagged.sender_address,
3988            compiled_class_hash: tagged.compiled_class_hash,
3989            signature: tagged.signature,
3990            nonce: tagged.nonce,
3991            class_hash: tagged.class_hash,
3992            resource_bounds: tagged.resource_bounds,
3993            tip: tagged.tip,
3994            paymaster_data: tagged.paymaster_data,
3995            account_deployment_data: tagged.account_deployment_data,
3996            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
3997            fee_data_availability_mode: tagged.fee_data_availability_mode,
3998        })
3999    }
4000}
4001
4002impl Serialize for DeclareTransactionV3Content {
4003    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4004        #[serde_as]
4005        #[derive(Serialize)]
4006        struct Tagged<'a> {
4007            pub r#type: &'a str,
4008            #[serde_as(as = "UfeHex")]
4009            pub sender_address: &'a Felt,
4010            #[serde_as(as = "UfeHex")]
4011            pub compiled_class_hash: &'a Felt,
4012            #[serde_as(as = "NumAsHex")]
4013            pub version: &'a u64,
4014            #[serde_as(as = "[UfeHex]")]
4015            pub signature: &'a [Felt],
4016            #[serde_as(as = "UfeHex")]
4017            pub nonce: &'a Felt,
4018            #[serde_as(as = "UfeHex")]
4019            pub class_hash: &'a Felt,
4020            pub resource_bounds: &'a ResourceBoundsMapping,
4021            #[serde_as(as = "NumAsHex")]
4022            pub tip: &'a u64,
4023            #[serde_as(as = "[UfeHex]")]
4024            pub paymaster_data: &'a [Felt],
4025            #[serde_as(as = "[UfeHex]")]
4026            pub account_deployment_data: &'a [Felt],
4027            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
4028            pub fee_data_availability_mode: &'a DataAvailabilityMode,
4029        }
4030
4031        let r#type = "DECLARE";
4032
4033        let version = &3;
4034
4035        let tagged = Tagged {
4036            r#type,
4037            sender_address: &self.sender_address,
4038            compiled_class_hash: &self.compiled_class_hash,
4039            version,
4040            signature: &self.signature,
4041            nonce: &self.nonce,
4042            class_hash: &self.class_hash,
4043            resource_bounds: &self.resource_bounds,
4044            tip: &self.tip,
4045            paymaster_data: &self.paymaster_data,
4046            account_deployment_data: &self.account_deployment_data,
4047            nonce_data_availability_mode: &self.nonce_data_availability_mode,
4048            fee_data_availability_mode: &self.fee_data_availability_mode,
4049        };
4050
4051        Tagged::serialize(&tagged, serializer)
4052    }
4053}
4054
4055impl<'de> Deserialize<'de> for DeclareTransactionV3Content {
4056    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4057        #[serde_as]
4058        #[derive(Deserialize)]
4059        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4060        struct Tagged {
4061            pub r#type: Option<String>,
4062            #[serde_as(as = "UfeHex")]
4063            pub sender_address: Felt,
4064            #[serde_as(as = "UfeHex")]
4065            pub compiled_class_hash: Felt,
4066            #[serde_as(as = "Option<NumAsHex>")]
4067            pub version: Option<u64>,
4068            #[serde_as(as = "Vec<UfeHex>")]
4069            pub signature: Vec<Felt>,
4070            #[serde_as(as = "UfeHex")]
4071            pub nonce: Felt,
4072            #[serde_as(as = "UfeHex")]
4073            pub class_hash: Felt,
4074            pub resource_bounds: ResourceBoundsMapping,
4075            #[serde_as(as = "NumAsHex")]
4076            pub tip: u64,
4077            #[serde_as(as = "Vec<UfeHex>")]
4078            pub paymaster_data: Vec<Felt>,
4079            #[serde_as(as = "Vec<UfeHex>")]
4080            pub account_deployment_data: Vec<Felt>,
4081            pub nonce_data_availability_mode: DataAvailabilityMode,
4082            pub fee_data_availability_mode: DataAvailabilityMode,
4083        }
4084
4085        let tagged = Tagged::deserialize(deserializer)?;
4086
4087        if let Some(tag_field) = &tagged.r#type {
4088            if tag_field != "DECLARE" {
4089                return Err(serde::de::Error::custom("invalid `type` value"));
4090            }
4091        }
4092
4093        if let Some(tag_field) = &tagged.version {
4094            if tag_field != &3 {
4095                return Err(serde::de::Error::custom("invalid `version` value"));
4096            }
4097        }
4098
4099        Ok(Self {
4100            sender_address: tagged.sender_address,
4101            compiled_class_hash: tagged.compiled_class_hash,
4102            signature: tagged.signature,
4103            nonce: tagged.nonce,
4104            class_hash: tagged.class_hash,
4105            resource_bounds: tagged.resource_bounds,
4106            tip: tagged.tip,
4107            paymaster_data: tagged.paymaster_data,
4108            account_deployment_data: tagged.account_deployment_data,
4109            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
4110            fee_data_availability_mode: tagged.fee_data_availability_mode,
4111        })
4112    }
4113}
4114
4115impl Serialize for DeployAccountTransactionReceipt {
4116    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4117        #[serde_as]
4118        #[derive(Serialize)]
4119        struct Tagged<'a> {
4120            #[serde_as(as = "UfeHex")]
4121            pub transaction_hash: &'a Felt,
4122            pub actual_fee: &'a FeePayment,
4123            pub finality_status: &'a TransactionFinalityStatus,
4124            pub messages_sent: &'a [MsgToL1],
4125            pub events: &'a [Event],
4126            pub execution_resources: &'a ExecutionResources,
4127            #[serde(flatten)]
4128            pub execution_result: &'a ExecutionResult,
4129            pub r#type: &'a str,
4130            #[serde_as(as = "UfeHex")]
4131            pub contract_address: &'a Felt,
4132        }
4133
4134        let r#type = "DEPLOY_ACCOUNT";
4135
4136        let tagged = Tagged {
4137            transaction_hash: &self.transaction_hash,
4138            actual_fee: &self.actual_fee,
4139            finality_status: &self.finality_status,
4140            messages_sent: &self.messages_sent,
4141            events: &self.events,
4142            execution_resources: &self.execution_resources,
4143            execution_result: &self.execution_result,
4144            r#type,
4145            contract_address: &self.contract_address,
4146        };
4147
4148        Tagged::serialize(&tagged, serializer)
4149    }
4150}
4151
4152impl<'de> Deserialize<'de> for DeployAccountTransactionReceipt {
4153    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4154        #[serde_as]
4155        #[derive(Deserialize)]
4156        struct Tagged {
4157            #[serde_as(as = "UfeHex")]
4158            pub transaction_hash: Felt,
4159            pub actual_fee: FeePayment,
4160            pub finality_status: TransactionFinalityStatus,
4161            pub messages_sent: Vec<MsgToL1>,
4162            pub events: Vec<Event>,
4163            pub execution_resources: ExecutionResources,
4164            #[serde(flatten)]
4165            pub execution_result: ExecutionResult,
4166            pub r#type: Option<String>,
4167            #[serde_as(as = "UfeHex")]
4168            pub contract_address: Felt,
4169        }
4170
4171        let tagged = Tagged::deserialize(deserializer)?;
4172
4173        if let Some(tag_field) = &tagged.r#type {
4174            if tag_field != "DEPLOY_ACCOUNT" {
4175                return Err(serde::de::Error::custom("invalid `type` value"));
4176            }
4177        }
4178
4179        Ok(Self {
4180            transaction_hash: tagged.transaction_hash,
4181            actual_fee: tagged.actual_fee,
4182            finality_status: tagged.finality_status,
4183            messages_sent: tagged.messages_sent,
4184            events: tagged.events,
4185            execution_resources: tagged.execution_resources,
4186            execution_result: tagged.execution_result,
4187            contract_address: tagged.contract_address,
4188        })
4189    }
4190}
4191
4192impl Serialize for DeployAccountTransactionTrace {
4193    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4194        #[derive(Serialize)]
4195        struct Tagged<'a> {
4196            #[serde(skip_serializing_if = "Option::is_none")]
4197            pub validate_invocation: &'a Option<FunctionInvocation>,
4198            pub constructor_invocation: &'a FunctionInvocation,
4199            #[serde(skip_serializing_if = "Option::is_none")]
4200            pub fee_transfer_invocation: &'a Option<FunctionInvocation>,
4201            #[serde(skip_serializing_if = "Option::is_none")]
4202            pub state_diff: &'a Option<StateDiff>,
4203            pub execution_resources: &'a ExecutionResources,
4204            pub r#type: &'a str,
4205        }
4206
4207        let r#type = "DEPLOY_ACCOUNT";
4208
4209        let tagged = Tagged {
4210            validate_invocation: &self.validate_invocation,
4211            constructor_invocation: &self.constructor_invocation,
4212            fee_transfer_invocation: &self.fee_transfer_invocation,
4213            state_diff: &self.state_diff,
4214            execution_resources: &self.execution_resources,
4215            r#type,
4216        };
4217
4218        Tagged::serialize(&tagged, serializer)
4219    }
4220}
4221
4222impl<'de> Deserialize<'de> for DeployAccountTransactionTrace {
4223    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4224        #[derive(Deserialize)]
4225        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4226        struct Tagged {
4227            #[serde(skip_serializing_if = "Option::is_none")]
4228            pub validate_invocation: Option<FunctionInvocation>,
4229            pub constructor_invocation: FunctionInvocation,
4230            #[serde(skip_serializing_if = "Option::is_none")]
4231            pub fee_transfer_invocation: Option<FunctionInvocation>,
4232            #[serde(skip_serializing_if = "Option::is_none")]
4233            pub state_diff: Option<StateDiff>,
4234            pub execution_resources: ExecutionResources,
4235            pub r#type: Option<String>,
4236        }
4237
4238        let tagged = Tagged::deserialize(deserializer)?;
4239
4240        if let Some(tag_field) = &tagged.r#type {
4241            if tag_field != "DEPLOY_ACCOUNT" {
4242                return Err(serde::de::Error::custom("invalid `type` value"));
4243            }
4244        }
4245
4246        Ok(Self {
4247            validate_invocation: tagged.validate_invocation,
4248            constructor_invocation: tagged.constructor_invocation,
4249            fee_transfer_invocation: tagged.fee_transfer_invocation,
4250            state_diff: tagged.state_diff,
4251            execution_resources: tagged.execution_resources,
4252        })
4253    }
4254}
4255
4256impl Serialize for DeployAccountTransactionV1 {
4257    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4258        #[serde_as]
4259        #[derive(Serialize)]
4260        struct Tagged<'a> {
4261            #[serde_as(as = "UfeHex")]
4262            pub transaction_hash: &'a Felt,
4263            pub r#type: &'a str,
4264            #[serde_as(as = "UfeHex")]
4265            pub max_fee: &'a Felt,
4266            #[serde_as(as = "NumAsHex")]
4267            pub version: &'a u64,
4268            #[serde_as(as = "[UfeHex]")]
4269            pub signature: &'a [Felt],
4270            #[serde_as(as = "UfeHex")]
4271            pub nonce: &'a Felt,
4272            #[serde_as(as = "UfeHex")]
4273            pub contract_address_salt: &'a Felt,
4274            #[serde_as(as = "[UfeHex]")]
4275            pub constructor_calldata: &'a [Felt],
4276            #[serde_as(as = "UfeHex")]
4277            pub class_hash: &'a Felt,
4278        }
4279
4280        let r#type = "DEPLOY_ACCOUNT";
4281
4282        let version = &1;
4283
4284        let tagged = Tagged {
4285            transaction_hash: &self.transaction_hash,
4286            r#type,
4287            max_fee: &self.max_fee,
4288            version,
4289            signature: &self.signature,
4290            nonce: &self.nonce,
4291            contract_address_salt: &self.contract_address_salt,
4292            constructor_calldata: &self.constructor_calldata,
4293            class_hash: &self.class_hash,
4294        };
4295
4296        Tagged::serialize(&tagged, serializer)
4297    }
4298}
4299
4300impl<'de> Deserialize<'de> for DeployAccountTransactionV1 {
4301    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4302        #[serde_as]
4303        #[derive(Deserialize)]
4304        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4305        struct Tagged {
4306            #[serde_as(as = "UfeHex")]
4307            pub transaction_hash: Felt,
4308            pub r#type: Option<String>,
4309            #[serde_as(as = "UfeHex")]
4310            pub max_fee: Felt,
4311            #[serde_as(as = "Option<NumAsHex>")]
4312            pub version: Option<u64>,
4313            #[serde_as(as = "Vec<UfeHex>")]
4314            pub signature: Vec<Felt>,
4315            #[serde_as(as = "UfeHex")]
4316            pub nonce: Felt,
4317            #[serde_as(as = "UfeHex")]
4318            pub contract_address_salt: Felt,
4319            #[serde_as(as = "Vec<UfeHex>")]
4320            pub constructor_calldata: Vec<Felt>,
4321            #[serde_as(as = "UfeHex")]
4322            pub class_hash: Felt,
4323        }
4324
4325        let tagged = Tagged::deserialize(deserializer)?;
4326
4327        if let Some(tag_field) = &tagged.r#type {
4328            if tag_field != "DEPLOY_ACCOUNT" {
4329                return Err(serde::de::Error::custom("invalid `type` value"));
4330            }
4331        }
4332
4333        if let Some(tag_field) = &tagged.version {
4334            if tag_field != &1 {
4335                return Err(serde::de::Error::custom("invalid `version` value"));
4336            }
4337        }
4338
4339        Ok(Self {
4340            transaction_hash: tagged.transaction_hash,
4341            max_fee: tagged.max_fee,
4342            signature: tagged.signature,
4343            nonce: tagged.nonce,
4344            contract_address_salt: tagged.contract_address_salt,
4345            constructor_calldata: tagged.constructor_calldata,
4346            class_hash: tagged.class_hash,
4347        })
4348    }
4349}
4350
4351impl Serialize for DeployAccountTransactionV1Content {
4352    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4353        #[serde_as]
4354        #[derive(Serialize)]
4355        struct Tagged<'a> {
4356            pub r#type: &'a str,
4357            #[serde_as(as = "UfeHex")]
4358            pub max_fee: &'a Felt,
4359            #[serde_as(as = "NumAsHex")]
4360            pub version: &'a u64,
4361            #[serde_as(as = "[UfeHex]")]
4362            pub signature: &'a [Felt],
4363            #[serde_as(as = "UfeHex")]
4364            pub nonce: &'a Felt,
4365            #[serde_as(as = "UfeHex")]
4366            pub contract_address_salt: &'a Felt,
4367            #[serde_as(as = "[UfeHex]")]
4368            pub constructor_calldata: &'a [Felt],
4369            #[serde_as(as = "UfeHex")]
4370            pub class_hash: &'a Felt,
4371        }
4372
4373        let r#type = "DEPLOY_ACCOUNT";
4374
4375        let version = &1;
4376
4377        let tagged = Tagged {
4378            r#type,
4379            max_fee: &self.max_fee,
4380            version,
4381            signature: &self.signature,
4382            nonce: &self.nonce,
4383            contract_address_salt: &self.contract_address_salt,
4384            constructor_calldata: &self.constructor_calldata,
4385            class_hash: &self.class_hash,
4386        };
4387
4388        Tagged::serialize(&tagged, serializer)
4389    }
4390}
4391
4392impl<'de> Deserialize<'de> for DeployAccountTransactionV1Content {
4393    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4394        #[serde_as]
4395        #[derive(Deserialize)]
4396        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4397        struct Tagged {
4398            pub r#type: Option<String>,
4399            #[serde_as(as = "UfeHex")]
4400            pub max_fee: Felt,
4401            #[serde_as(as = "Option<NumAsHex>")]
4402            pub version: Option<u64>,
4403            #[serde_as(as = "Vec<UfeHex>")]
4404            pub signature: Vec<Felt>,
4405            #[serde_as(as = "UfeHex")]
4406            pub nonce: Felt,
4407            #[serde_as(as = "UfeHex")]
4408            pub contract_address_salt: Felt,
4409            #[serde_as(as = "Vec<UfeHex>")]
4410            pub constructor_calldata: Vec<Felt>,
4411            #[serde_as(as = "UfeHex")]
4412            pub class_hash: Felt,
4413        }
4414
4415        let tagged = Tagged::deserialize(deserializer)?;
4416
4417        if let Some(tag_field) = &tagged.r#type {
4418            if tag_field != "DEPLOY_ACCOUNT" {
4419                return Err(serde::de::Error::custom("invalid `type` value"));
4420            }
4421        }
4422
4423        if let Some(tag_field) = &tagged.version {
4424            if tag_field != &1 {
4425                return Err(serde::de::Error::custom("invalid `version` value"));
4426            }
4427        }
4428
4429        Ok(Self {
4430            max_fee: tagged.max_fee,
4431            signature: tagged.signature,
4432            nonce: tagged.nonce,
4433            contract_address_salt: tagged.contract_address_salt,
4434            constructor_calldata: tagged.constructor_calldata,
4435            class_hash: tagged.class_hash,
4436        })
4437    }
4438}
4439
4440impl Serialize for DeployAccountTransactionV3 {
4441    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4442        #[serde_as]
4443        #[derive(Serialize)]
4444        struct Tagged<'a> {
4445            #[serde_as(as = "UfeHex")]
4446            pub transaction_hash: &'a Felt,
4447            pub r#type: &'a str,
4448            #[serde_as(as = "NumAsHex")]
4449            pub version: &'a u64,
4450            #[serde_as(as = "[UfeHex]")]
4451            pub signature: &'a [Felt],
4452            #[serde_as(as = "UfeHex")]
4453            pub nonce: &'a Felt,
4454            #[serde_as(as = "UfeHex")]
4455            pub contract_address_salt: &'a Felt,
4456            #[serde_as(as = "[UfeHex]")]
4457            pub constructor_calldata: &'a [Felt],
4458            #[serde_as(as = "UfeHex")]
4459            pub class_hash: &'a Felt,
4460            pub resource_bounds: &'a ResourceBoundsMapping,
4461            #[serde_as(as = "NumAsHex")]
4462            pub tip: &'a u64,
4463            #[serde_as(as = "[UfeHex]")]
4464            pub paymaster_data: &'a [Felt],
4465            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
4466            pub fee_data_availability_mode: &'a DataAvailabilityMode,
4467        }
4468
4469        let r#type = "DEPLOY_ACCOUNT";
4470
4471        let version = &3;
4472
4473        let tagged = Tagged {
4474            transaction_hash: &self.transaction_hash,
4475            r#type,
4476            version,
4477            signature: &self.signature,
4478            nonce: &self.nonce,
4479            contract_address_salt: &self.contract_address_salt,
4480            constructor_calldata: &self.constructor_calldata,
4481            class_hash: &self.class_hash,
4482            resource_bounds: &self.resource_bounds,
4483            tip: &self.tip,
4484            paymaster_data: &self.paymaster_data,
4485            nonce_data_availability_mode: &self.nonce_data_availability_mode,
4486            fee_data_availability_mode: &self.fee_data_availability_mode,
4487        };
4488
4489        Tagged::serialize(&tagged, serializer)
4490    }
4491}
4492
4493impl<'de> Deserialize<'de> for DeployAccountTransactionV3 {
4494    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4495        #[serde_as]
4496        #[derive(Deserialize)]
4497        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4498        struct Tagged {
4499            #[serde_as(as = "UfeHex")]
4500            pub transaction_hash: Felt,
4501            pub r#type: Option<String>,
4502            #[serde_as(as = "Option<NumAsHex>")]
4503            pub version: Option<u64>,
4504            #[serde_as(as = "Vec<UfeHex>")]
4505            pub signature: Vec<Felt>,
4506            #[serde_as(as = "UfeHex")]
4507            pub nonce: Felt,
4508            #[serde_as(as = "UfeHex")]
4509            pub contract_address_salt: Felt,
4510            #[serde_as(as = "Vec<UfeHex>")]
4511            pub constructor_calldata: Vec<Felt>,
4512            #[serde_as(as = "UfeHex")]
4513            pub class_hash: Felt,
4514            pub resource_bounds: ResourceBoundsMapping,
4515            #[serde_as(as = "NumAsHex")]
4516            pub tip: u64,
4517            #[serde_as(as = "Vec<UfeHex>")]
4518            pub paymaster_data: Vec<Felt>,
4519            pub nonce_data_availability_mode: DataAvailabilityMode,
4520            pub fee_data_availability_mode: DataAvailabilityMode,
4521        }
4522
4523        let tagged = Tagged::deserialize(deserializer)?;
4524
4525        if let Some(tag_field) = &tagged.r#type {
4526            if tag_field != "DEPLOY_ACCOUNT" {
4527                return Err(serde::de::Error::custom("invalid `type` value"));
4528            }
4529        }
4530
4531        if let Some(tag_field) = &tagged.version {
4532            if tag_field != &3 {
4533                return Err(serde::de::Error::custom("invalid `version` value"));
4534            }
4535        }
4536
4537        Ok(Self {
4538            transaction_hash: tagged.transaction_hash,
4539            signature: tagged.signature,
4540            nonce: tagged.nonce,
4541            contract_address_salt: tagged.contract_address_salt,
4542            constructor_calldata: tagged.constructor_calldata,
4543            class_hash: tagged.class_hash,
4544            resource_bounds: tagged.resource_bounds,
4545            tip: tagged.tip,
4546            paymaster_data: tagged.paymaster_data,
4547            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
4548            fee_data_availability_mode: tagged.fee_data_availability_mode,
4549        })
4550    }
4551}
4552
4553impl Serialize for DeployAccountTransactionV3Content {
4554    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4555        #[serde_as]
4556        #[derive(Serialize)]
4557        struct Tagged<'a> {
4558            pub r#type: &'a str,
4559            #[serde_as(as = "NumAsHex")]
4560            pub version: &'a u64,
4561            #[serde_as(as = "[UfeHex]")]
4562            pub signature: &'a [Felt],
4563            #[serde_as(as = "UfeHex")]
4564            pub nonce: &'a Felt,
4565            #[serde_as(as = "UfeHex")]
4566            pub contract_address_salt: &'a Felt,
4567            #[serde_as(as = "[UfeHex]")]
4568            pub constructor_calldata: &'a [Felt],
4569            #[serde_as(as = "UfeHex")]
4570            pub class_hash: &'a Felt,
4571            pub resource_bounds: &'a ResourceBoundsMapping,
4572            #[serde_as(as = "NumAsHex")]
4573            pub tip: &'a u64,
4574            #[serde_as(as = "[UfeHex]")]
4575            pub paymaster_data: &'a [Felt],
4576            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
4577            pub fee_data_availability_mode: &'a DataAvailabilityMode,
4578        }
4579
4580        let r#type = "DEPLOY_ACCOUNT";
4581
4582        let version = &3;
4583
4584        let tagged = Tagged {
4585            r#type,
4586            version,
4587            signature: &self.signature,
4588            nonce: &self.nonce,
4589            contract_address_salt: &self.contract_address_salt,
4590            constructor_calldata: &self.constructor_calldata,
4591            class_hash: &self.class_hash,
4592            resource_bounds: &self.resource_bounds,
4593            tip: &self.tip,
4594            paymaster_data: &self.paymaster_data,
4595            nonce_data_availability_mode: &self.nonce_data_availability_mode,
4596            fee_data_availability_mode: &self.fee_data_availability_mode,
4597        };
4598
4599        Tagged::serialize(&tagged, serializer)
4600    }
4601}
4602
4603impl<'de> Deserialize<'de> for DeployAccountTransactionV3Content {
4604    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4605        #[serde_as]
4606        #[derive(Deserialize)]
4607        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4608        struct Tagged {
4609            pub r#type: Option<String>,
4610            #[serde_as(as = "Option<NumAsHex>")]
4611            pub version: Option<u64>,
4612            #[serde_as(as = "Vec<UfeHex>")]
4613            pub signature: Vec<Felt>,
4614            #[serde_as(as = "UfeHex")]
4615            pub nonce: Felt,
4616            #[serde_as(as = "UfeHex")]
4617            pub contract_address_salt: Felt,
4618            #[serde_as(as = "Vec<UfeHex>")]
4619            pub constructor_calldata: Vec<Felt>,
4620            #[serde_as(as = "UfeHex")]
4621            pub class_hash: Felt,
4622            pub resource_bounds: ResourceBoundsMapping,
4623            #[serde_as(as = "NumAsHex")]
4624            pub tip: u64,
4625            #[serde_as(as = "Vec<UfeHex>")]
4626            pub paymaster_data: Vec<Felt>,
4627            pub nonce_data_availability_mode: DataAvailabilityMode,
4628            pub fee_data_availability_mode: DataAvailabilityMode,
4629        }
4630
4631        let tagged = Tagged::deserialize(deserializer)?;
4632
4633        if let Some(tag_field) = &tagged.r#type {
4634            if tag_field != "DEPLOY_ACCOUNT" {
4635                return Err(serde::de::Error::custom("invalid `type` value"));
4636            }
4637        }
4638
4639        if let Some(tag_field) = &tagged.version {
4640            if tag_field != &3 {
4641                return Err(serde::de::Error::custom("invalid `version` value"));
4642            }
4643        }
4644
4645        Ok(Self {
4646            signature: tagged.signature,
4647            nonce: tagged.nonce,
4648            contract_address_salt: tagged.contract_address_salt,
4649            constructor_calldata: tagged.constructor_calldata,
4650            class_hash: tagged.class_hash,
4651            resource_bounds: tagged.resource_bounds,
4652            tip: tagged.tip,
4653            paymaster_data: tagged.paymaster_data,
4654            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
4655            fee_data_availability_mode: tagged.fee_data_availability_mode,
4656        })
4657    }
4658}
4659
4660impl Serialize for DeployTransaction {
4661    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4662        #[serde_as]
4663        #[derive(Serialize)]
4664        struct Tagged<'a> {
4665            #[serde_as(as = "UfeHex")]
4666            pub transaction_hash: &'a Felt,
4667            #[serde_as(as = "UfeHex")]
4668            pub version: &'a Felt,
4669            pub r#type: &'a str,
4670            #[serde_as(as = "UfeHex")]
4671            pub contract_address_salt: &'a Felt,
4672            #[serde_as(as = "[UfeHex]")]
4673            pub constructor_calldata: &'a [Felt],
4674            #[serde_as(as = "UfeHex")]
4675            pub class_hash: &'a Felt,
4676        }
4677
4678        let r#type = "DEPLOY";
4679
4680        let tagged = Tagged {
4681            transaction_hash: &self.transaction_hash,
4682            version: &self.version,
4683            r#type,
4684            contract_address_salt: &self.contract_address_salt,
4685            constructor_calldata: &self.constructor_calldata,
4686            class_hash: &self.class_hash,
4687        };
4688
4689        Tagged::serialize(&tagged, serializer)
4690    }
4691}
4692
4693impl<'de> Deserialize<'de> for DeployTransaction {
4694    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4695        #[serde_as]
4696        #[derive(Deserialize)]
4697        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4698        struct Tagged {
4699            #[serde_as(as = "UfeHex")]
4700            pub transaction_hash: Felt,
4701            #[serde_as(as = "UfeHex")]
4702            pub version: Felt,
4703            pub r#type: Option<String>,
4704            #[serde_as(as = "UfeHex")]
4705            pub contract_address_salt: Felt,
4706            #[serde_as(as = "Vec<UfeHex>")]
4707            pub constructor_calldata: Vec<Felt>,
4708            #[serde_as(as = "UfeHex")]
4709            pub class_hash: Felt,
4710        }
4711
4712        let tagged = Tagged::deserialize(deserializer)?;
4713
4714        if let Some(tag_field) = &tagged.r#type {
4715            if tag_field != "DEPLOY" {
4716                return Err(serde::de::Error::custom("invalid `type` value"));
4717            }
4718        }
4719
4720        Ok(Self {
4721            transaction_hash: tagged.transaction_hash,
4722            version: tagged.version,
4723            contract_address_salt: tagged.contract_address_salt,
4724            constructor_calldata: tagged.constructor_calldata,
4725            class_hash: tagged.class_hash,
4726        })
4727    }
4728}
4729
4730impl Serialize for DeployTransactionContent {
4731    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4732        #[serde_as]
4733        #[derive(Serialize)]
4734        struct Tagged<'a> {
4735            #[serde_as(as = "UfeHex")]
4736            pub version: &'a Felt,
4737            pub r#type: &'a str,
4738            #[serde_as(as = "UfeHex")]
4739            pub contract_address_salt: &'a Felt,
4740            #[serde_as(as = "[UfeHex]")]
4741            pub constructor_calldata: &'a [Felt],
4742            #[serde_as(as = "UfeHex")]
4743            pub class_hash: &'a Felt,
4744        }
4745
4746        let r#type = "DEPLOY";
4747
4748        let tagged = Tagged {
4749            version: &self.version,
4750            r#type,
4751            contract_address_salt: &self.contract_address_salt,
4752            constructor_calldata: &self.constructor_calldata,
4753            class_hash: &self.class_hash,
4754        };
4755
4756        Tagged::serialize(&tagged, serializer)
4757    }
4758}
4759
4760impl<'de> Deserialize<'de> for DeployTransactionContent {
4761    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4762        #[serde_as]
4763        #[derive(Deserialize)]
4764        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4765        struct Tagged {
4766            #[serde_as(as = "UfeHex")]
4767            pub version: Felt,
4768            pub r#type: Option<String>,
4769            #[serde_as(as = "UfeHex")]
4770            pub contract_address_salt: Felt,
4771            #[serde_as(as = "Vec<UfeHex>")]
4772            pub constructor_calldata: Vec<Felt>,
4773            #[serde_as(as = "UfeHex")]
4774            pub class_hash: Felt,
4775        }
4776
4777        let tagged = Tagged::deserialize(deserializer)?;
4778
4779        if let Some(tag_field) = &tagged.r#type {
4780            if tag_field != "DEPLOY" {
4781                return Err(serde::de::Error::custom("invalid `type` value"));
4782            }
4783        }
4784
4785        Ok(Self {
4786            version: tagged.version,
4787            contract_address_salt: tagged.contract_address_salt,
4788            constructor_calldata: tagged.constructor_calldata,
4789            class_hash: tagged.class_hash,
4790        })
4791    }
4792}
4793
4794impl Serialize for DeployTransactionReceipt {
4795    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4796        #[serde_as]
4797        #[derive(Serialize)]
4798        struct Tagged<'a> {
4799            #[serde_as(as = "UfeHex")]
4800            pub transaction_hash: &'a Felt,
4801            pub actual_fee: &'a FeePayment,
4802            pub finality_status: &'a TransactionFinalityStatus,
4803            pub messages_sent: &'a [MsgToL1],
4804            pub events: &'a [Event],
4805            pub execution_resources: &'a ExecutionResources,
4806            #[serde(flatten)]
4807            pub execution_result: &'a ExecutionResult,
4808            pub r#type: &'a str,
4809            #[serde_as(as = "UfeHex")]
4810            pub contract_address: &'a Felt,
4811        }
4812
4813        let r#type = "DEPLOY";
4814
4815        let tagged = Tagged {
4816            transaction_hash: &self.transaction_hash,
4817            actual_fee: &self.actual_fee,
4818            finality_status: &self.finality_status,
4819            messages_sent: &self.messages_sent,
4820            events: &self.events,
4821            execution_resources: &self.execution_resources,
4822            execution_result: &self.execution_result,
4823            r#type,
4824            contract_address: &self.contract_address,
4825        };
4826
4827        Tagged::serialize(&tagged, serializer)
4828    }
4829}
4830
4831impl<'de> Deserialize<'de> for DeployTransactionReceipt {
4832    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4833        #[serde_as]
4834        #[derive(Deserialize)]
4835        struct Tagged {
4836            #[serde_as(as = "UfeHex")]
4837            pub transaction_hash: Felt,
4838            pub actual_fee: FeePayment,
4839            pub finality_status: TransactionFinalityStatus,
4840            pub messages_sent: Vec<MsgToL1>,
4841            pub events: Vec<Event>,
4842            pub execution_resources: ExecutionResources,
4843            #[serde(flatten)]
4844            pub execution_result: ExecutionResult,
4845            pub r#type: Option<String>,
4846            #[serde_as(as = "UfeHex")]
4847            pub contract_address: Felt,
4848        }
4849
4850        let tagged = Tagged::deserialize(deserializer)?;
4851
4852        if let Some(tag_field) = &tagged.r#type {
4853            if tag_field != "DEPLOY" {
4854                return Err(serde::de::Error::custom("invalid `type` value"));
4855            }
4856        }
4857
4858        Ok(Self {
4859            transaction_hash: tagged.transaction_hash,
4860            actual_fee: tagged.actual_fee,
4861            finality_status: tagged.finality_status,
4862            messages_sent: tagged.messages_sent,
4863            events: tagged.events,
4864            execution_resources: tagged.execution_resources,
4865            execution_result: tagged.execution_result,
4866            contract_address: tagged.contract_address,
4867        })
4868    }
4869}
4870
4871impl Serialize for FeeEstimate {
4872    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4873        #[serde_as]
4874        #[derive(Serialize)]
4875        struct Tagged<'a> {
4876            #[serde_as(as = "NumAsHex")]
4877            pub l1_gas_consumed: &'a u64,
4878            #[serde_as(as = "NumAsHex")]
4879            pub l1_gas_price: &'a u128,
4880            #[serde_as(as = "NumAsHex")]
4881            pub l2_gas_consumed: &'a u64,
4882            #[serde_as(as = "NumAsHex")]
4883            pub l2_gas_price: &'a u128,
4884            #[serde_as(as = "NumAsHex")]
4885            pub l1_data_gas_consumed: &'a u64,
4886            #[serde_as(as = "NumAsHex")]
4887            pub l1_data_gas_price: &'a u128,
4888            #[serde_as(as = "NumAsHex")]
4889            pub overall_fee: &'a u128,
4890            pub unit: &'a PriceUnitFri,
4891        }
4892
4893        let unit = &PriceUnitFri::Fri;
4894
4895        let tagged = Tagged {
4896            l1_gas_consumed: &self.l1_gas_consumed,
4897            l1_gas_price: &self.l1_gas_price,
4898            l2_gas_consumed: &self.l2_gas_consumed,
4899            l2_gas_price: &self.l2_gas_price,
4900            l1_data_gas_consumed: &self.l1_data_gas_consumed,
4901            l1_data_gas_price: &self.l1_data_gas_price,
4902            overall_fee: &self.overall_fee,
4903            unit,
4904        };
4905
4906        Tagged::serialize(&tagged, serializer)
4907    }
4908}
4909
4910impl<'de> Deserialize<'de> for FeeEstimate {
4911    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4912        #[serde_as]
4913        #[derive(Deserialize)]
4914        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
4915        struct Tagged {
4916            #[serde_as(as = "NumAsHex")]
4917            pub l1_gas_consumed: u64,
4918            #[serde_as(as = "NumAsHex")]
4919            pub l1_gas_price: u128,
4920            #[serde_as(as = "NumAsHex")]
4921            pub l2_gas_consumed: u64,
4922            #[serde_as(as = "NumAsHex")]
4923            pub l2_gas_price: u128,
4924            #[serde_as(as = "NumAsHex")]
4925            pub l1_data_gas_consumed: u64,
4926            #[serde_as(as = "NumAsHex")]
4927            pub l1_data_gas_price: u128,
4928            #[serde_as(as = "NumAsHex")]
4929            pub overall_fee: u128,
4930            pub unit: Option<PriceUnitFri>,
4931        }
4932
4933        let tagged = Tagged::deserialize(deserializer)?;
4934
4935        if let Some(tag_field) = &tagged.unit {
4936            if tag_field != &PriceUnitFri::Fri {
4937                return Err(serde::de::Error::custom("invalid `unit` value"));
4938            }
4939        }
4940
4941        Ok(Self {
4942            l1_gas_consumed: tagged.l1_gas_consumed,
4943            l1_gas_price: tagged.l1_gas_price,
4944            l2_gas_consumed: tagged.l2_gas_consumed,
4945            l2_gas_price: tagged.l2_gas_price,
4946            l1_data_gas_consumed: tagged.l1_data_gas_consumed,
4947            l1_data_gas_price: tagged.l1_data_gas_price,
4948            overall_fee: tagged.overall_fee,
4949        })
4950    }
4951}
4952
4953impl Serialize for InvokeTransactionReceipt {
4954    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4955        #[serde_as]
4956        #[derive(Serialize)]
4957        struct Tagged<'a> {
4958            pub r#type: &'a str,
4959            #[serde_as(as = "UfeHex")]
4960            pub transaction_hash: &'a Felt,
4961            pub actual_fee: &'a FeePayment,
4962            pub finality_status: &'a TransactionFinalityStatus,
4963            pub messages_sent: &'a [MsgToL1],
4964            pub events: &'a [Event],
4965            pub execution_resources: &'a ExecutionResources,
4966            #[serde(flatten)]
4967            pub execution_result: &'a ExecutionResult,
4968        }
4969
4970        let r#type = "INVOKE";
4971
4972        let tagged = Tagged {
4973            r#type,
4974            transaction_hash: &self.transaction_hash,
4975            actual_fee: &self.actual_fee,
4976            finality_status: &self.finality_status,
4977            messages_sent: &self.messages_sent,
4978            events: &self.events,
4979            execution_resources: &self.execution_resources,
4980            execution_result: &self.execution_result,
4981        };
4982
4983        Tagged::serialize(&tagged, serializer)
4984    }
4985}
4986
4987impl<'de> Deserialize<'de> for InvokeTransactionReceipt {
4988    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4989        #[serde_as]
4990        #[derive(Deserialize)]
4991        struct Tagged {
4992            pub r#type: Option<String>,
4993            #[serde_as(as = "UfeHex")]
4994            pub transaction_hash: Felt,
4995            pub actual_fee: FeePayment,
4996            pub finality_status: TransactionFinalityStatus,
4997            pub messages_sent: Vec<MsgToL1>,
4998            pub events: Vec<Event>,
4999            pub execution_resources: ExecutionResources,
5000            #[serde(flatten)]
5001            pub execution_result: ExecutionResult,
5002        }
5003
5004        let tagged = Tagged::deserialize(deserializer)?;
5005
5006        if let Some(tag_field) = &tagged.r#type {
5007            if tag_field != "INVOKE" {
5008                return Err(serde::de::Error::custom("invalid `type` value"));
5009            }
5010        }
5011
5012        Ok(Self {
5013            transaction_hash: tagged.transaction_hash,
5014            actual_fee: tagged.actual_fee,
5015            finality_status: tagged.finality_status,
5016            messages_sent: tagged.messages_sent,
5017            events: tagged.events,
5018            execution_resources: tagged.execution_resources,
5019            execution_result: tagged.execution_result,
5020        })
5021    }
5022}
5023
5024impl Serialize for InvokeTransactionTrace {
5025    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5026        #[derive(Serialize)]
5027        struct Tagged<'a> {
5028            #[serde(skip_serializing_if = "Option::is_none")]
5029            pub validate_invocation: &'a Option<FunctionInvocation>,
5030            pub execute_invocation: &'a ExecuteInvocation,
5031            #[serde(skip_serializing_if = "Option::is_none")]
5032            pub fee_transfer_invocation: &'a Option<FunctionInvocation>,
5033            #[serde(skip_serializing_if = "Option::is_none")]
5034            pub state_diff: &'a Option<StateDiff>,
5035            pub execution_resources: &'a ExecutionResources,
5036            pub r#type: &'a str,
5037        }
5038
5039        let r#type = "INVOKE";
5040
5041        let tagged = Tagged {
5042            validate_invocation: &self.validate_invocation,
5043            execute_invocation: &self.execute_invocation,
5044            fee_transfer_invocation: &self.fee_transfer_invocation,
5045            state_diff: &self.state_diff,
5046            execution_resources: &self.execution_resources,
5047            r#type,
5048        };
5049
5050        Tagged::serialize(&tagged, serializer)
5051    }
5052}
5053
5054impl<'de> Deserialize<'de> for InvokeTransactionTrace {
5055    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5056        #[derive(Deserialize)]
5057        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5058        struct Tagged {
5059            #[serde(skip_serializing_if = "Option::is_none")]
5060            pub validate_invocation: Option<FunctionInvocation>,
5061            pub execute_invocation: ExecuteInvocation,
5062            #[serde(skip_serializing_if = "Option::is_none")]
5063            pub fee_transfer_invocation: Option<FunctionInvocation>,
5064            #[serde(skip_serializing_if = "Option::is_none")]
5065            pub state_diff: Option<StateDiff>,
5066            pub execution_resources: ExecutionResources,
5067            pub r#type: Option<String>,
5068        }
5069
5070        let tagged = Tagged::deserialize(deserializer)?;
5071
5072        if let Some(tag_field) = &tagged.r#type {
5073            if tag_field != "INVOKE" {
5074                return Err(serde::de::Error::custom("invalid `type` value"));
5075            }
5076        }
5077
5078        Ok(Self {
5079            validate_invocation: tagged.validate_invocation,
5080            execute_invocation: tagged.execute_invocation,
5081            fee_transfer_invocation: tagged.fee_transfer_invocation,
5082            state_diff: tagged.state_diff,
5083            execution_resources: tagged.execution_resources,
5084        })
5085    }
5086}
5087
5088impl Serialize for InvokeTransactionV0 {
5089    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5090        #[serde_as]
5091        #[derive(Serialize)]
5092        struct Tagged<'a> {
5093            #[serde_as(as = "UfeHex")]
5094            pub transaction_hash: &'a Felt,
5095            pub r#type: &'a str,
5096            #[serde_as(as = "UfeHex")]
5097            pub max_fee: &'a Felt,
5098            #[serde_as(as = "NumAsHex")]
5099            pub version: &'a u64,
5100            #[serde_as(as = "[UfeHex]")]
5101            pub signature: &'a [Felt],
5102            #[serde_as(as = "UfeHex")]
5103            pub contract_address: &'a Felt,
5104            #[serde_as(as = "UfeHex")]
5105            pub entry_point_selector: &'a Felt,
5106            #[serde_as(as = "[UfeHex]")]
5107            pub calldata: &'a [Felt],
5108        }
5109
5110        let r#type = "INVOKE";
5111
5112        let version = &0;
5113
5114        let tagged = Tagged {
5115            transaction_hash: &self.transaction_hash,
5116            r#type,
5117            max_fee: &self.max_fee,
5118            version,
5119            signature: &self.signature,
5120            contract_address: &self.contract_address,
5121            entry_point_selector: &self.entry_point_selector,
5122            calldata: &self.calldata,
5123        };
5124
5125        Tagged::serialize(&tagged, serializer)
5126    }
5127}
5128
5129impl<'de> Deserialize<'de> for InvokeTransactionV0 {
5130    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5131        #[serde_as]
5132        #[derive(Deserialize)]
5133        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5134        struct Tagged {
5135            #[serde_as(as = "UfeHex")]
5136            pub transaction_hash: Felt,
5137            pub r#type: Option<String>,
5138            #[serde_as(as = "UfeHex")]
5139            pub max_fee: Felt,
5140            #[serde_as(as = "Option<NumAsHex>")]
5141            pub version: Option<u64>,
5142            #[serde_as(as = "Vec<UfeHex>")]
5143            pub signature: Vec<Felt>,
5144            #[serde_as(as = "UfeHex")]
5145            pub contract_address: Felt,
5146            #[serde_as(as = "UfeHex")]
5147            pub entry_point_selector: Felt,
5148            #[serde_as(as = "Vec<UfeHex>")]
5149            pub calldata: Vec<Felt>,
5150        }
5151
5152        let tagged = Tagged::deserialize(deserializer)?;
5153
5154        if let Some(tag_field) = &tagged.r#type {
5155            if tag_field != "INVOKE" {
5156                return Err(serde::de::Error::custom("invalid `type` value"));
5157            }
5158        }
5159
5160        if let Some(tag_field) = &tagged.version {
5161            if tag_field != &0 {
5162                return Err(serde::de::Error::custom("invalid `version` value"));
5163            }
5164        }
5165
5166        Ok(Self {
5167            transaction_hash: tagged.transaction_hash,
5168            max_fee: tagged.max_fee,
5169            signature: tagged.signature,
5170            contract_address: tagged.contract_address,
5171            entry_point_selector: tagged.entry_point_selector,
5172            calldata: tagged.calldata,
5173        })
5174    }
5175}
5176
5177impl Serialize for InvokeTransactionV0Content {
5178    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5179        #[serde_as]
5180        #[derive(Serialize)]
5181        struct Tagged<'a> {
5182            pub r#type: &'a str,
5183            #[serde_as(as = "UfeHex")]
5184            pub max_fee: &'a Felt,
5185            #[serde_as(as = "NumAsHex")]
5186            pub version: &'a u64,
5187            #[serde_as(as = "[UfeHex]")]
5188            pub signature: &'a [Felt],
5189            #[serde_as(as = "UfeHex")]
5190            pub contract_address: &'a Felt,
5191            #[serde_as(as = "UfeHex")]
5192            pub entry_point_selector: &'a Felt,
5193            #[serde_as(as = "[UfeHex]")]
5194            pub calldata: &'a [Felt],
5195        }
5196
5197        let r#type = "INVOKE";
5198
5199        let version = &0;
5200
5201        let tagged = Tagged {
5202            r#type,
5203            max_fee: &self.max_fee,
5204            version,
5205            signature: &self.signature,
5206            contract_address: &self.contract_address,
5207            entry_point_selector: &self.entry_point_selector,
5208            calldata: &self.calldata,
5209        };
5210
5211        Tagged::serialize(&tagged, serializer)
5212    }
5213}
5214
5215impl<'de> Deserialize<'de> for InvokeTransactionV0Content {
5216    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5217        #[serde_as]
5218        #[derive(Deserialize)]
5219        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5220        struct Tagged {
5221            pub r#type: Option<String>,
5222            #[serde_as(as = "UfeHex")]
5223            pub max_fee: Felt,
5224            #[serde_as(as = "Option<NumAsHex>")]
5225            pub version: Option<u64>,
5226            #[serde_as(as = "Vec<UfeHex>")]
5227            pub signature: Vec<Felt>,
5228            #[serde_as(as = "UfeHex")]
5229            pub contract_address: Felt,
5230            #[serde_as(as = "UfeHex")]
5231            pub entry_point_selector: Felt,
5232            #[serde_as(as = "Vec<UfeHex>")]
5233            pub calldata: Vec<Felt>,
5234        }
5235
5236        let tagged = Tagged::deserialize(deserializer)?;
5237
5238        if let Some(tag_field) = &tagged.r#type {
5239            if tag_field != "INVOKE" {
5240                return Err(serde::de::Error::custom("invalid `type` value"));
5241            }
5242        }
5243
5244        if let Some(tag_field) = &tagged.version {
5245            if tag_field != &0 {
5246                return Err(serde::de::Error::custom("invalid `version` value"));
5247            }
5248        }
5249
5250        Ok(Self {
5251            max_fee: tagged.max_fee,
5252            signature: tagged.signature,
5253            contract_address: tagged.contract_address,
5254            entry_point_selector: tagged.entry_point_selector,
5255            calldata: tagged.calldata,
5256        })
5257    }
5258}
5259
5260impl Serialize for InvokeTransactionV1 {
5261    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5262        #[serde_as]
5263        #[derive(Serialize)]
5264        struct Tagged<'a> {
5265            #[serde_as(as = "UfeHex")]
5266            pub transaction_hash: &'a Felt,
5267            pub r#type: &'a str,
5268            #[serde_as(as = "UfeHex")]
5269            pub sender_address: &'a Felt,
5270            #[serde_as(as = "[UfeHex]")]
5271            pub calldata: &'a [Felt],
5272            #[serde_as(as = "UfeHex")]
5273            pub max_fee: &'a Felt,
5274            #[serde_as(as = "NumAsHex")]
5275            pub version: &'a u64,
5276            #[serde_as(as = "[UfeHex]")]
5277            pub signature: &'a [Felt],
5278            #[serde_as(as = "UfeHex")]
5279            pub nonce: &'a Felt,
5280        }
5281
5282        let r#type = "INVOKE";
5283
5284        let version = &1;
5285
5286        let tagged = Tagged {
5287            transaction_hash: &self.transaction_hash,
5288            r#type,
5289            sender_address: &self.sender_address,
5290            calldata: &self.calldata,
5291            max_fee: &self.max_fee,
5292            version,
5293            signature: &self.signature,
5294            nonce: &self.nonce,
5295        };
5296
5297        Tagged::serialize(&tagged, serializer)
5298    }
5299}
5300
5301impl<'de> Deserialize<'de> for InvokeTransactionV1 {
5302    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5303        #[serde_as]
5304        #[derive(Deserialize)]
5305        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5306        struct Tagged {
5307            #[serde_as(as = "UfeHex")]
5308            pub transaction_hash: Felt,
5309            pub r#type: Option<String>,
5310            #[serde_as(as = "UfeHex")]
5311            pub sender_address: Felt,
5312            #[serde_as(as = "Vec<UfeHex>")]
5313            pub calldata: Vec<Felt>,
5314            #[serde_as(as = "UfeHex")]
5315            pub max_fee: Felt,
5316            #[serde_as(as = "Option<NumAsHex>")]
5317            pub version: Option<u64>,
5318            #[serde_as(as = "Vec<UfeHex>")]
5319            pub signature: Vec<Felt>,
5320            #[serde_as(as = "UfeHex")]
5321            pub nonce: Felt,
5322        }
5323
5324        let tagged = Tagged::deserialize(deserializer)?;
5325
5326        if let Some(tag_field) = &tagged.r#type {
5327            if tag_field != "INVOKE" {
5328                return Err(serde::de::Error::custom("invalid `type` value"));
5329            }
5330        }
5331
5332        if let Some(tag_field) = &tagged.version {
5333            if tag_field != &1 {
5334                return Err(serde::de::Error::custom("invalid `version` value"));
5335            }
5336        }
5337
5338        Ok(Self {
5339            transaction_hash: tagged.transaction_hash,
5340            sender_address: tagged.sender_address,
5341            calldata: tagged.calldata,
5342            max_fee: tagged.max_fee,
5343            signature: tagged.signature,
5344            nonce: tagged.nonce,
5345        })
5346    }
5347}
5348
5349impl Serialize for InvokeTransactionV1Content {
5350    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5351        #[serde_as]
5352        #[derive(Serialize)]
5353        struct Tagged<'a> {
5354            pub r#type: &'a str,
5355            #[serde_as(as = "UfeHex")]
5356            pub sender_address: &'a Felt,
5357            #[serde_as(as = "[UfeHex]")]
5358            pub calldata: &'a [Felt],
5359            #[serde_as(as = "UfeHex")]
5360            pub max_fee: &'a Felt,
5361            #[serde_as(as = "NumAsHex")]
5362            pub version: &'a u64,
5363            #[serde_as(as = "[UfeHex]")]
5364            pub signature: &'a [Felt],
5365            #[serde_as(as = "UfeHex")]
5366            pub nonce: &'a Felt,
5367        }
5368
5369        let r#type = "INVOKE";
5370
5371        let version = &1;
5372
5373        let tagged = Tagged {
5374            r#type,
5375            sender_address: &self.sender_address,
5376            calldata: &self.calldata,
5377            max_fee: &self.max_fee,
5378            version,
5379            signature: &self.signature,
5380            nonce: &self.nonce,
5381        };
5382
5383        Tagged::serialize(&tagged, serializer)
5384    }
5385}
5386
5387impl<'de> Deserialize<'de> for InvokeTransactionV1Content {
5388    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5389        #[serde_as]
5390        #[derive(Deserialize)]
5391        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5392        struct Tagged {
5393            pub r#type: Option<String>,
5394            #[serde_as(as = "UfeHex")]
5395            pub sender_address: Felt,
5396            #[serde_as(as = "Vec<UfeHex>")]
5397            pub calldata: Vec<Felt>,
5398            #[serde_as(as = "UfeHex")]
5399            pub max_fee: Felt,
5400            #[serde_as(as = "Option<NumAsHex>")]
5401            pub version: Option<u64>,
5402            #[serde_as(as = "Vec<UfeHex>")]
5403            pub signature: Vec<Felt>,
5404            #[serde_as(as = "UfeHex")]
5405            pub nonce: Felt,
5406        }
5407
5408        let tagged = Tagged::deserialize(deserializer)?;
5409
5410        if let Some(tag_field) = &tagged.r#type {
5411            if tag_field != "INVOKE" {
5412                return Err(serde::de::Error::custom("invalid `type` value"));
5413            }
5414        }
5415
5416        if let Some(tag_field) = &tagged.version {
5417            if tag_field != &1 {
5418                return Err(serde::de::Error::custom("invalid `version` value"));
5419            }
5420        }
5421
5422        Ok(Self {
5423            sender_address: tagged.sender_address,
5424            calldata: tagged.calldata,
5425            max_fee: tagged.max_fee,
5426            signature: tagged.signature,
5427            nonce: tagged.nonce,
5428        })
5429    }
5430}
5431
5432impl Serialize for InvokeTransactionV3 {
5433    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5434        #[serde_as]
5435        #[derive(Serialize)]
5436        struct Tagged<'a> {
5437            #[serde_as(as = "UfeHex")]
5438            pub transaction_hash: &'a Felt,
5439            pub r#type: &'a str,
5440            #[serde_as(as = "UfeHex")]
5441            pub sender_address: &'a Felt,
5442            #[serde_as(as = "[UfeHex]")]
5443            pub calldata: &'a [Felt],
5444            #[serde_as(as = "NumAsHex")]
5445            pub version: &'a u64,
5446            #[serde_as(as = "[UfeHex]")]
5447            pub signature: &'a [Felt],
5448            #[serde_as(as = "UfeHex")]
5449            pub nonce: &'a Felt,
5450            pub resource_bounds: &'a ResourceBoundsMapping,
5451            #[serde_as(as = "NumAsHex")]
5452            pub tip: &'a u64,
5453            #[serde_as(as = "[UfeHex]")]
5454            pub paymaster_data: &'a [Felt],
5455            #[serde_as(as = "[UfeHex]")]
5456            pub account_deployment_data: &'a [Felt],
5457            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
5458            pub fee_data_availability_mode: &'a DataAvailabilityMode,
5459        }
5460
5461        let r#type = "INVOKE";
5462
5463        let version = &3;
5464
5465        let tagged = Tagged {
5466            transaction_hash: &self.transaction_hash,
5467            r#type,
5468            sender_address: &self.sender_address,
5469            calldata: &self.calldata,
5470            version,
5471            signature: &self.signature,
5472            nonce: &self.nonce,
5473            resource_bounds: &self.resource_bounds,
5474            tip: &self.tip,
5475            paymaster_data: &self.paymaster_data,
5476            account_deployment_data: &self.account_deployment_data,
5477            nonce_data_availability_mode: &self.nonce_data_availability_mode,
5478            fee_data_availability_mode: &self.fee_data_availability_mode,
5479        };
5480
5481        Tagged::serialize(&tagged, serializer)
5482    }
5483}
5484
5485impl<'de> Deserialize<'de> for InvokeTransactionV3 {
5486    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5487        #[serde_as]
5488        #[derive(Deserialize)]
5489        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5490        struct Tagged {
5491            #[serde_as(as = "UfeHex")]
5492            pub transaction_hash: Felt,
5493            pub r#type: Option<String>,
5494            #[serde_as(as = "UfeHex")]
5495            pub sender_address: Felt,
5496            #[serde_as(as = "Vec<UfeHex>")]
5497            pub calldata: Vec<Felt>,
5498            #[serde_as(as = "Option<NumAsHex>")]
5499            pub version: Option<u64>,
5500            #[serde_as(as = "Vec<UfeHex>")]
5501            pub signature: Vec<Felt>,
5502            #[serde_as(as = "UfeHex")]
5503            pub nonce: Felt,
5504            pub resource_bounds: ResourceBoundsMapping,
5505            #[serde_as(as = "NumAsHex")]
5506            pub tip: u64,
5507            #[serde_as(as = "Vec<UfeHex>")]
5508            pub paymaster_data: Vec<Felt>,
5509            #[serde_as(as = "Vec<UfeHex>")]
5510            pub account_deployment_data: Vec<Felt>,
5511            pub nonce_data_availability_mode: DataAvailabilityMode,
5512            pub fee_data_availability_mode: DataAvailabilityMode,
5513        }
5514
5515        let tagged = Tagged::deserialize(deserializer)?;
5516
5517        if let Some(tag_field) = &tagged.r#type {
5518            if tag_field != "INVOKE" {
5519                return Err(serde::de::Error::custom("invalid `type` value"));
5520            }
5521        }
5522
5523        if let Some(tag_field) = &tagged.version {
5524            if tag_field != &3 {
5525                return Err(serde::de::Error::custom("invalid `version` value"));
5526            }
5527        }
5528
5529        Ok(Self {
5530            transaction_hash: tagged.transaction_hash,
5531            sender_address: tagged.sender_address,
5532            calldata: tagged.calldata,
5533            signature: tagged.signature,
5534            nonce: tagged.nonce,
5535            resource_bounds: tagged.resource_bounds,
5536            tip: tagged.tip,
5537            paymaster_data: tagged.paymaster_data,
5538            account_deployment_data: tagged.account_deployment_data,
5539            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
5540            fee_data_availability_mode: tagged.fee_data_availability_mode,
5541        })
5542    }
5543}
5544
5545impl Serialize for InvokeTransactionV3Content {
5546    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5547        #[serde_as]
5548        #[derive(Serialize)]
5549        struct Tagged<'a> {
5550            pub r#type: &'a str,
5551            #[serde_as(as = "UfeHex")]
5552            pub sender_address: &'a Felt,
5553            #[serde_as(as = "[UfeHex]")]
5554            pub calldata: &'a [Felt],
5555            #[serde_as(as = "NumAsHex")]
5556            pub version: &'a u64,
5557            #[serde_as(as = "[UfeHex]")]
5558            pub signature: &'a [Felt],
5559            #[serde_as(as = "UfeHex")]
5560            pub nonce: &'a Felt,
5561            pub resource_bounds: &'a ResourceBoundsMapping,
5562            #[serde_as(as = "NumAsHex")]
5563            pub tip: &'a u64,
5564            #[serde_as(as = "[UfeHex]")]
5565            pub paymaster_data: &'a [Felt],
5566            #[serde_as(as = "[UfeHex]")]
5567            pub account_deployment_data: &'a [Felt],
5568            pub nonce_data_availability_mode: &'a DataAvailabilityMode,
5569            pub fee_data_availability_mode: &'a DataAvailabilityMode,
5570        }
5571
5572        let r#type = "INVOKE";
5573
5574        let version = &3;
5575
5576        let tagged = Tagged {
5577            r#type,
5578            sender_address: &self.sender_address,
5579            calldata: &self.calldata,
5580            version,
5581            signature: &self.signature,
5582            nonce: &self.nonce,
5583            resource_bounds: &self.resource_bounds,
5584            tip: &self.tip,
5585            paymaster_data: &self.paymaster_data,
5586            account_deployment_data: &self.account_deployment_data,
5587            nonce_data_availability_mode: &self.nonce_data_availability_mode,
5588            fee_data_availability_mode: &self.fee_data_availability_mode,
5589        };
5590
5591        Tagged::serialize(&tagged, serializer)
5592    }
5593}
5594
5595impl<'de> Deserialize<'de> for InvokeTransactionV3Content {
5596    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5597        #[serde_as]
5598        #[derive(Deserialize)]
5599        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5600        struct Tagged {
5601            pub r#type: Option<String>,
5602            #[serde_as(as = "UfeHex")]
5603            pub sender_address: Felt,
5604            #[serde_as(as = "Vec<UfeHex>")]
5605            pub calldata: Vec<Felt>,
5606            #[serde_as(as = "Option<NumAsHex>")]
5607            pub version: Option<u64>,
5608            #[serde_as(as = "Vec<UfeHex>")]
5609            pub signature: Vec<Felt>,
5610            #[serde_as(as = "UfeHex")]
5611            pub nonce: Felt,
5612            pub resource_bounds: ResourceBoundsMapping,
5613            #[serde_as(as = "NumAsHex")]
5614            pub tip: u64,
5615            #[serde_as(as = "Vec<UfeHex>")]
5616            pub paymaster_data: Vec<Felt>,
5617            #[serde_as(as = "Vec<UfeHex>")]
5618            pub account_deployment_data: Vec<Felt>,
5619            pub nonce_data_availability_mode: DataAvailabilityMode,
5620            pub fee_data_availability_mode: DataAvailabilityMode,
5621        }
5622
5623        let tagged = Tagged::deserialize(deserializer)?;
5624
5625        if let Some(tag_field) = &tagged.r#type {
5626            if tag_field != "INVOKE" {
5627                return Err(serde::de::Error::custom("invalid `type` value"));
5628            }
5629        }
5630
5631        if let Some(tag_field) = &tagged.version {
5632            if tag_field != &3 {
5633                return Err(serde::de::Error::custom("invalid `version` value"));
5634            }
5635        }
5636
5637        Ok(Self {
5638            sender_address: tagged.sender_address,
5639            calldata: tagged.calldata,
5640            signature: tagged.signature,
5641            nonce: tagged.nonce,
5642            resource_bounds: tagged.resource_bounds,
5643            tip: tagged.tip,
5644            paymaster_data: tagged.paymaster_data,
5645            account_deployment_data: tagged.account_deployment_data,
5646            nonce_data_availability_mode: tagged.nonce_data_availability_mode,
5647            fee_data_availability_mode: tagged.fee_data_availability_mode,
5648        })
5649    }
5650}
5651
5652impl Serialize for L1HandlerTransaction {
5653    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5654        #[serde_as]
5655        #[derive(Serialize)]
5656        struct Tagged<'a> {
5657            #[serde_as(as = "UfeHex")]
5658            pub transaction_hash: &'a Felt,
5659            #[serde_as(as = "UfeHex")]
5660            pub version: &'a Felt,
5661            pub r#type: &'a str,
5662            #[serde_as(as = "NumAsHex")]
5663            pub nonce: &'a u64,
5664            #[serde_as(as = "UfeHex")]
5665            pub contract_address: &'a Felt,
5666            #[serde_as(as = "UfeHex")]
5667            pub entry_point_selector: &'a Felt,
5668            #[serde_as(as = "[UfeHex]")]
5669            pub calldata: &'a [Felt],
5670        }
5671
5672        let r#type = "L1_HANDLER";
5673
5674        let tagged = Tagged {
5675            transaction_hash: &self.transaction_hash,
5676            version: &self.version,
5677            r#type,
5678            nonce: &self.nonce,
5679            contract_address: &self.contract_address,
5680            entry_point_selector: &self.entry_point_selector,
5681            calldata: &self.calldata,
5682        };
5683
5684        Tagged::serialize(&tagged, serializer)
5685    }
5686}
5687
5688impl<'de> Deserialize<'de> for L1HandlerTransaction {
5689    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5690        #[serde_as]
5691        #[derive(Deserialize)]
5692        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5693        struct Tagged {
5694            #[serde_as(as = "UfeHex")]
5695            pub transaction_hash: Felt,
5696            #[serde_as(as = "UfeHex")]
5697            pub version: Felt,
5698            pub r#type: Option<String>,
5699            #[serde_as(as = "NumAsHex")]
5700            pub nonce: u64,
5701            #[serde_as(as = "UfeHex")]
5702            pub contract_address: Felt,
5703            #[serde_as(as = "UfeHex")]
5704            pub entry_point_selector: Felt,
5705            #[serde_as(as = "Vec<UfeHex>")]
5706            pub calldata: Vec<Felt>,
5707        }
5708
5709        let tagged = Tagged::deserialize(deserializer)?;
5710
5711        if let Some(tag_field) = &tagged.r#type {
5712            if tag_field != "L1_HANDLER" {
5713                return Err(serde::de::Error::custom("invalid `type` value"));
5714            }
5715        }
5716
5717        Ok(Self {
5718            transaction_hash: tagged.transaction_hash,
5719            version: tagged.version,
5720            nonce: tagged.nonce,
5721            contract_address: tagged.contract_address,
5722            entry_point_selector: tagged.entry_point_selector,
5723            calldata: tagged.calldata,
5724        })
5725    }
5726}
5727
5728impl Serialize for L1HandlerTransactionContent {
5729    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5730        #[serde_as]
5731        #[derive(Serialize)]
5732        struct Tagged<'a> {
5733            #[serde_as(as = "UfeHex")]
5734            pub version: &'a Felt,
5735            pub r#type: &'a str,
5736            #[serde_as(as = "NumAsHex")]
5737            pub nonce: &'a u64,
5738            #[serde_as(as = "UfeHex")]
5739            pub contract_address: &'a Felt,
5740            #[serde_as(as = "UfeHex")]
5741            pub entry_point_selector: &'a Felt,
5742            #[serde_as(as = "[UfeHex]")]
5743            pub calldata: &'a [Felt],
5744        }
5745
5746        let r#type = "L1_HANDLER";
5747
5748        let tagged = Tagged {
5749            version: &self.version,
5750            r#type,
5751            nonce: &self.nonce,
5752            contract_address: &self.contract_address,
5753            entry_point_selector: &self.entry_point_selector,
5754            calldata: &self.calldata,
5755        };
5756
5757        Tagged::serialize(&tagged, serializer)
5758    }
5759}
5760
5761impl<'de> Deserialize<'de> for L1HandlerTransactionContent {
5762    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5763        #[serde_as]
5764        #[derive(Deserialize)]
5765        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5766        struct Tagged {
5767            #[serde_as(as = "UfeHex")]
5768            pub version: Felt,
5769            pub r#type: Option<String>,
5770            #[serde_as(as = "NumAsHex")]
5771            pub nonce: u64,
5772            #[serde_as(as = "UfeHex")]
5773            pub contract_address: Felt,
5774            #[serde_as(as = "UfeHex")]
5775            pub entry_point_selector: Felt,
5776            #[serde_as(as = "Vec<UfeHex>")]
5777            pub calldata: Vec<Felt>,
5778        }
5779
5780        let tagged = Tagged::deserialize(deserializer)?;
5781
5782        if let Some(tag_field) = &tagged.r#type {
5783            if tag_field != "L1_HANDLER" {
5784                return Err(serde::de::Error::custom("invalid `type` value"));
5785            }
5786        }
5787
5788        Ok(Self {
5789            version: tagged.version,
5790            nonce: tagged.nonce,
5791            contract_address: tagged.contract_address,
5792            entry_point_selector: tagged.entry_point_selector,
5793            calldata: tagged.calldata,
5794        })
5795    }
5796}
5797
5798impl Serialize for L1HandlerTransactionReceipt {
5799    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5800        #[serde_as]
5801        #[derive(Serialize)]
5802        struct Tagged<'a> {
5803            pub r#type: &'a str,
5804            pub message_hash: &'a Hash256,
5805            #[serde_as(as = "UfeHex")]
5806            pub transaction_hash: &'a Felt,
5807            pub actual_fee: &'a FeePayment,
5808            pub finality_status: &'a TransactionFinalityStatus,
5809            pub messages_sent: &'a [MsgToL1],
5810            pub events: &'a [Event],
5811            pub execution_resources: &'a ExecutionResources,
5812            #[serde(flatten)]
5813            pub execution_result: &'a ExecutionResult,
5814        }
5815
5816        let r#type = "L1_HANDLER";
5817
5818        let tagged = Tagged {
5819            r#type,
5820            message_hash: &self.message_hash,
5821            transaction_hash: &self.transaction_hash,
5822            actual_fee: &self.actual_fee,
5823            finality_status: &self.finality_status,
5824            messages_sent: &self.messages_sent,
5825            events: &self.events,
5826            execution_resources: &self.execution_resources,
5827            execution_result: &self.execution_result,
5828        };
5829
5830        Tagged::serialize(&tagged, serializer)
5831    }
5832}
5833
5834impl<'de> Deserialize<'de> for L1HandlerTransactionReceipt {
5835    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5836        #[serde_as]
5837        #[derive(Deserialize)]
5838        struct Tagged {
5839            pub r#type: Option<String>,
5840            pub message_hash: Hash256,
5841            #[serde_as(as = "UfeHex")]
5842            pub transaction_hash: Felt,
5843            pub actual_fee: FeePayment,
5844            pub finality_status: TransactionFinalityStatus,
5845            pub messages_sent: Vec<MsgToL1>,
5846            pub events: Vec<Event>,
5847            pub execution_resources: ExecutionResources,
5848            #[serde(flatten)]
5849            pub execution_result: ExecutionResult,
5850        }
5851
5852        let tagged = Tagged::deserialize(deserializer)?;
5853
5854        if let Some(tag_field) = &tagged.r#type {
5855            if tag_field != "L1_HANDLER" {
5856                return Err(serde::de::Error::custom("invalid `type` value"));
5857            }
5858        }
5859
5860        Ok(Self {
5861            message_hash: tagged.message_hash,
5862            transaction_hash: tagged.transaction_hash,
5863            actual_fee: tagged.actual_fee,
5864            finality_status: tagged.finality_status,
5865            messages_sent: tagged.messages_sent,
5866            events: tagged.events,
5867            execution_resources: tagged.execution_resources,
5868            execution_result: tagged.execution_result,
5869        })
5870    }
5871}
5872
5873impl Serialize for L1HandlerTransactionTrace {
5874    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5875        #[derive(Serialize)]
5876        struct Tagged<'a> {
5877            pub function_invocation: &'a ExecuteInvocation,
5878            #[serde(skip_serializing_if = "Option::is_none")]
5879            pub state_diff: &'a Option<StateDiff>,
5880            pub execution_resources: &'a ExecutionResources,
5881            pub r#type: &'a str,
5882        }
5883
5884        let r#type = "L1_HANDLER";
5885
5886        let tagged = Tagged {
5887            function_invocation: &self.function_invocation,
5888            state_diff: &self.state_diff,
5889            execution_resources: &self.execution_resources,
5890            r#type,
5891        };
5892
5893        Tagged::serialize(&tagged, serializer)
5894    }
5895}
5896
5897impl<'de> Deserialize<'de> for L1HandlerTransactionTrace {
5898    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5899        #[derive(Deserialize)]
5900        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5901        struct Tagged {
5902            pub function_invocation: ExecuteInvocation,
5903            #[serde(skip_serializing_if = "Option::is_none")]
5904            pub state_diff: Option<StateDiff>,
5905            pub execution_resources: ExecutionResources,
5906            pub r#type: Option<String>,
5907        }
5908
5909        let tagged = Tagged::deserialize(deserializer)?;
5910
5911        if let Some(tag_field) = &tagged.r#type {
5912            if tag_field != "L1_HANDLER" {
5913                return Err(serde::de::Error::custom("invalid `type` value"));
5914            }
5915        }
5916
5917        Ok(Self {
5918            function_invocation: tagged.function_invocation,
5919            state_diff: tagged.state_diff,
5920            execution_resources: tagged.execution_resources,
5921        })
5922    }
5923}
5924
5925impl Serialize for MessageFeeEstimate {
5926    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5927        #[serde_as]
5928        #[derive(Serialize)]
5929        struct Tagged<'a> {
5930            #[serde_as(as = "NumAsHex")]
5931            pub l1_gas_consumed: &'a u64,
5932            #[serde_as(as = "NumAsHex")]
5933            pub l1_gas_price: &'a u128,
5934            #[serde_as(as = "NumAsHex")]
5935            pub l2_gas_consumed: &'a u64,
5936            #[serde_as(as = "NumAsHex")]
5937            pub l2_gas_price: &'a u128,
5938            #[serde_as(as = "NumAsHex")]
5939            pub l1_data_gas_consumed: &'a u64,
5940            #[serde_as(as = "NumAsHex")]
5941            pub l1_data_gas_price: &'a u128,
5942            #[serde_as(as = "NumAsHex")]
5943            pub overall_fee: &'a u128,
5944            pub unit: &'a PriceUnitWei,
5945        }
5946
5947        let unit = &PriceUnitWei::Wei;
5948
5949        let tagged = Tagged {
5950            l1_gas_consumed: &self.l1_gas_consumed,
5951            l1_gas_price: &self.l1_gas_price,
5952            l2_gas_consumed: &self.l2_gas_consumed,
5953            l2_gas_price: &self.l2_gas_price,
5954            l1_data_gas_consumed: &self.l1_data_gas_consumed,
5955            l1_data_gas_price: &self.l1_data_gas_price,
5956            overall_fee: &self.overall_fee,
5957            unit,
5958        };
5959
5960        Tagged::serialize(&tagged, serializer)
5961    }
5962}
5963
5964impl<'de> Deserialize<'de> for MessageFeeEstimate {
5965    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5966        #[serde_as]
5967        #[derive(Deserialize)]
5968        #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
5969        struct Tagged {
5970            #[serde_as(as = "NumAsHex")]
5971            pub l1_gas_consumed: u64,
5972            #[serde_as(as = "NumAsHex")]
5973            pub l1_gas_price: u128,
5974            #[serde_as(as = "NumAsHex")]
5975            pub l2_gas_consumed: u64,
5976            #[serde_as(as = "NumAsHex")]
5977            pub l2_gas_price: u128,
5978            #[serde_as(as = "NumAsHex")]
5979            pub l1_data_gas_consumed: u64,
5980            #[serde_as(as = "NumAsHex")]
5981            pub l1_data_gas_price: u128,
5982            #[serde_as(as = "NumAsHex")]
5983            pub overall_fee: u128,
5984            pub unit: Option<PriceUnitWei>,
5985        }
5986
5987        let tagged = Tagged::deserialize(deserializer)?;
5988
5989        if let Some(tag_field) = &tagged.unit {
5990            if tag_field != &PriceUnitWei::Wei {
5991                return Err(serde::de::Error::custom("invalid `unit` value"));
5992            }
5993        }
5994
5995        Ok(Self {
5996            l1_gas_consumed: tagged.l1_gas_consumed,
5997            l1_gas_price: tagged.l1_gas_price,
5998            l2_gas_consumed: tagged.l2_gas_consumed,
5999            l2_gas_price: tagged.l2_gas_price,
6000            l1_data_gas_consumed: tagged.l1_data_gas_consumed,
6001            l1_data_gas_price: tagged.l1_data_gas_price,
6002            overall_fee: tagged.overall_fee,
6003        })
6004    }
6005}
6006
6007impl Serialize for AddDeclareTransactionRequest {
6008    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6009        #[derive(Serialize)]
6010        struct AsObject<'a> {
6011            declare_transaction: Field0<'a>,
6012        }
6013
6014        #[derive(Serialize)]
6015        #[serde(transparent)]
6016        struct Field0<'a> {
6017            pub value: &'a BroadcastedDeclareTransaction,
6018        }
6019
6020        AsObject::serialize(
6021            &AsObject {
6022                declare_transaction: Field0 {
6023                    value: &self.declare_transaction,
6024                },
6025            },
6026            serializer,
6027        )
6028    }
6029}
6030
6031impl Serialize for AddDeclareTransactionRequestRef<'_> {
6032    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6033        #[derive(Serialize)]
6034        struct AsObject<'a> {
6035            declare_transaction: Field0<'a>,
6036        }
6037
6038        #[derive(Serialize)]
6039        #[serde(transparent)]
6040        struct Field0<'a> {
6041            pub value: &'a BroadcastedDeclareTransaction,
6042        }
6043
6044        AsObject::serialize(
6045            &AsObject {
6046                declare_transaction: Field0 {
6047                    value: self.declare_transaction,
6048                },
6049            },
6050            serializer,
6051        )
6052    }
6053}
6054
6055impl<'de> Deserialize<'de> for AddDeclareTransactionRequest {
6056    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6057        #[derive(Deserialize)]
6058        struct AsObject {
6059            declare_transaction: Field0,
6060        }
6061
6062        #[derive(Deserialize)]
6063        #[serde(transparent)]
6064        struct Field0 {
6065            pub value: BroadcastedDeclareTransaction,
6066        }
6067
6068        let temp = serde_json::Value::deserialize(deserializer)?;
6069
6070        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6071            let field0 = serde_json::from_value::<Field0>(
6072                elements
6073                    .pop()
6074                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6075            )
6076            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6077
6078            Ok(Self {
6079                declare_transaction: field0.value,
6080            })
6081        } else if let Ok(object) = AsObject::deserialize(&temp) {
6082            Ok(Self {
6083                declare_transaction: object.declare_transaction.value,
6084            })
6085        } else {
6086            Err(serde::de::Error::custom("invalid sequence length"))
6087        }
6088    }
6089}
6090
6091impl Serialize for AddDeployAccountTransactionRequest {
6092    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6093        #[derive(Serialize)]
6094        struct AsObject<'a> {
6095            deploy_account_transaction: Field0<'a>,
6096        }
6097
6098        #[derive(Serialize)]
6099        #[serde(transparent)]
6100        struct Field0<'a> {
6101            pub value: &'a BroadcastedDeployAccountTransaction,
6102        }
6103
6104        AsObject::serialize(
6105            &AsObject {
6106                deploy_account_transaction: Field0 {
6107                    value: &self.deploy_account_transaction,
6108                },
6109            },
6110            serializer,
6111        )
6112    }
6113}
6114
6115impl Serialize for AddDeployAccountTransactionRequestRef<'_> {
6116    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6117        #[derive(Serialize)]
6118        struct AsObject<'a> {
6119            deploy_account_transaction: Field0<'a>,
6120        }
6121
6122        #[derive(Serialize)]
6123        #[serde(transparent)]
6124        struct Field0<'a> {
6125            pub value: &'a BroadcastedDeployAccountTransaction,
6126        }
6127
6128        AsObject::serialize(
6129            &AsObject {
6130                deploy_account_transaction: Field0 {
6131                    value: self.deploy_account_transaction,
6132                },
6133            },
6134            serializer,
6135        )
6136    }
6137}
6138
6139impl<'de> Deserialize<'de> for AddDeployAccountTransactionRequest {
6140    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6141        #[derive(Deserialize)]
6142        struct AsObject {
6143            deploy_account_transaction: Field0,
6144        }
6145
6146        #[derive(Deserialize)]
6147        #[serde(transparent)]
6148        struct Field0 {
6149            pub value: BroadcastedDeployAccountTransaction,
6150        }
6151
6152        let temp = serde_json::Value::deserialize(deserializer)?;
6153
6154        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6155            let field0 = serde_json::from_value::<Field0>(
6156                elements
6157                    .pop()
6158                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6159            )
6160            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6161
6162            Ok(Self {
6163                deploy_account_transaction: field0.value,
6164            })
6165        } else if let Ok(object) = AsObject::deserialize(&temp) {
6166            Ok(Self {
6167                deploy_account_transaction: object.deploy_account_transaction.value,
6168            })
6169        } else {
6170            Err(serde::de::Error::custom("invalid sequence length"))
6171        }
6172    }
6173}
6174
6175impl Serialize for AddInvokeTransactionRequest {
6176    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6177        #[derive(Serialize)]
6178        struct AsObject<'a> {
6179            invoke_transaction: Field0<'a>,
6180        }
6181
6182        #[derive(Serialize)]
6183        #[serde(transparent)]
6184        struct Field0<'a> {
6185            pub value: &'a BroadcastedInvokeTransaction,
6186        }
6187
6188        AsObject::serialize(
6189            &AsObject {
6190                invoke_transaction: Field0 {
6191                    value: &self.invoke_transaction,
6192                },
6193            },
6194            serializer,
6195        )
6196    }
6197}
6198
6199impl Serialize for AddInvokeTransactionRequestRef<'_> {
6200    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6201        #[derive(Serialize)]
6202        struct AsObject<'a> {
6203            invoke_transaction: Field0<'a>,
6204        }
6205
6206        #[derive(Serialize)]
6207        #[serde(transparent)]
6208        struct Field0<'a> {
6209            pub value: &'a BroadcastedInvokeTransaction,
6210        }
6211
6212        AsObject::serialize(
6213            &AsObject {
6214                invoke_transaction: Field0 {
6215                    value: self.invoke_transaction,
6216                },
6217            },
6218            serializer,
6219        )
6220    }
6221}
6222
6223impl<'de> Deserialize<'de> for AddInvokeTransactionRequest {
6224    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6225        #[derive(Deserialize)]
6226        struct AsObject {
6227            invoke_transaction: Field0,
6228        }
6229
6230        #[derive(Deserialize)]
6231        #[serde(transparent)]
6232        struct Field0 {
6233            pub value: BroadcastedInvokeTransaction,
6234        }
6235
6236        let temp = serde_json::Value::deserialize(deserializer)?;
6237
6238        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6239            let field0 = serde_json::from_value::<Field0>(
6240                elements
6241                    .pop()
6242                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6243            )
6244            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6245
6246            Ok(Self {
6247                invoke_transaction: field0.value,
6248            })
6249        } else if let Ok(object) = AsObject::deserialize(&temp) {
6250            Ok(Self {
6251                invoke_transaction: object.invoke_transaction.value,
6252            })
6253        } else {
6254            Err(serde::de::Error::custom("invalid sequence length"))
6255        }
6256    }
6257}
6258
6259impl Serialize for BlockHashAndNumberRequest {
6260    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6261        use serde::ser::SerializeSeq;
6262
6263        let seq = serializer.serialize_seq(Some(0))?;
6264        seq.end()
6265    }
6266}
6267
6268impl<'de> Deserialize<'de> for BlockHashAndNumberRequest {
6269    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6270        let elements = Vec::<()>::deserialize(deserializer)?;
6271        if !elements.is_empty() {
6272            return Err(serde::de::Error::custom("invalid sequence length"));
6273        }
6274        Ok(Self)
6275    }
6276}
6277
6278impl Serialize for BlockNumberRequest {
6279    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6280        use serde::ser::SerializeSeq;
6281
6282        let seq = serializer.serialize_seq(Some(0))?;
6283        seq.end()
6284    }
6285}
6286
6287impl<'de> Deserialize<'de> for BlockNumberRequest {
6288    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6289        let elements = Vec::<()>::deserialize(deserializer)?;
6290        if !elements.is_empty() {
6291            return Err(serde::de::Error::custom("invalid sequence length"));
6292        }
6293        Ok(Self)
6294    }
6295}
6296
6297impl Serialize for CallRequest {
6298    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6299        #[derive(Serialize)]
6300        struct AsObject<'a> {
6301            request: Field0<'a>,
6302            block_id: Field1<'a>,
6303        }
6304
6305        #[derive(Serialize)]
6306        #[serde(transparent)]
6307        struct Field0<'a> {
6308            pub value: &'a FunctionCall,
6309        }
6310
6311        #[derive(Serialize)]
6312        #[serde(transparent)]
6313        struct Field1<'a> {
6314            pub value: &'a BlockId,
6315        }
6316
6317        AsObject::serialize(
6318            &AsObject {
6319                request: Field0 {
6320                    value: &self.request,
6321                },
6322                block_id: Field1 {
6323                    value: &self.block_id,
6324                },
6325            },
6326            serializer,
6327        )
6328    }
6329}
6330
6331impl Serialize for CallRequestRef<'_> {
6332    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6333        #[derive(Serialize)]
6334        struct AsObject<'a> {
6335            request: Field0<'a>,
6336            block_id: Field1<'a>,
6337        }
6338
6339        #[derive(Serialize)]
6340        #[serde(transparent)]
6341        struct Field0<'a> {
6342            pub value: &'a FunctionCall,
6343        }
6344
6345        #[derive(Serialize)]
6346        #[serde(transparent)]
6347        struct Field1<'a> {
6348            pub value: &'a BlockId,
6349        }
6350
6351        AsObject::serialize(
6352            &AsObject {
6353                request: Field0 {
6354                    value: self.request,
6355                },
6356                block_id: Field1 {
6357                    value: self.block_id,
6358                },
6359            },
6360            serializer,
6361        )
6362    }
6363}
6364
6365impl<'de> Deserialize<'de> for CallRequest {
6366    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6367        #[derive(Deserialize)]
6368        struct AsObject {
6369            request: Field0,
6370            block_id: Field1,
6371        }
6372
6373        #[derive(Deserialize)]
6374        #[serde(transparent)]
6375        struct Field0 {
6376            pub value: FunctionCall,
6377        }
6378
6379        #[derive(Deserialize)]
6380        #[serde(transparent)]
6381        struct Field1 {
6382            pub value: BlockId,
6383        }
6384
6385        let temp = serde_json::Value::deserialize(deserializer)?;
6386
6387        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6388            let field1 = serde_json::from_value::<Field1>(
6389                elements
6390                    .pop()
6391                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6392            )
6393            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6394            let field0 = serde_json::from_value::<Field0>(
6395                elements
6396                    .pop()
6397                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6398            )
6399            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6400
6401            Ok(Self {
6402                request: field0.value,
6403                block_id: field1.value,
6404            })
6405        } else if let Ok(object) = AsObject::deserialize(&temp) {
6406            Ok(Self {
6407                request: object.request.value,
6408                block_id: object.block_id.value,
6409            })
6410        } else {
6411            Err(serde::de::Error::custom("invalid sequence length"))
6412        }
6413    }
6414}
6415
6416impl Serialize for ChainIdRequest {
6417    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6418        use serde::ser::SerializeSeq;
6419
6420        let seq = serializer.serialize_seq(Some(0))?;
6421        seq.end()
6422    }
6423}
6424
6425impl<'de> Deserialize<'de> for ChainIdRequest {
6426    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6427        let elements = Vec::<()>::deserialize(deserializer)?;
6428        if !elements.is_empty() {
6429            return Err(serde::de::Error::custom("invalid sequence length"));
6430        }
6431        Ok(Self)
6432    }
6433}
6434
6435impl Serialize for EstimateFeeRequest {
6436    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6437        #[derive(Serialize)]
6438        struct AsObject<'a> {
6439            request: Field0<'a>,
6440            simulation_flags: Field1<'a>,
6441            block_id: Field2<'a>,
6442        }
6443
6444        #[derive(Serialize)]
6445        #[serde(transparent)]
6446        struct Field0<'a> {
6447            pub value: &'a [BroadcastedTransaction],
6448        }
6449
6450        #[derive(Serialize)]
6451        #[serde(transparent)]
6452        struct Field1<'a> {
6453            pub value: &'a [SimulationFlagForEstimateFee],
6454        }
6455
6456        #[derive(Serialize)]
6457        #[serde(transparent)]
6458        struct Field2<'a> {
6459            pub value: &'a BlockId,
6460        }
6461
6462        AsObject::serialize(
6463            &AsObject {
6464                request: Field0 {
6465                    value: &self.request,
6466                },
6467                simulation_flags: Field1 {
6468                    value: &self.simulation_flags,
6469                },
6470                block_id: Field2 {
6471                    value: &self.block_id,
6472                },
6473            },
6474            serializer,
6475        )
6476    }
6477}
6478
6479impl Serialize for EstimateFeeRequestRef<'_> {
6480    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6481        #[derive(Serialize)]
6482        struct AsObject<'a> {
6483            request: Field0<'a>,
6484            simulation_flags: Field1<'a>,
6485            block_id: Field2<'a>,
6486        }
6487
6488        #[derive(Serialize)]
6489        #[serde(transparent)]
6490        struct Field0<'a> {
6491            pub value: &'a [BroadcastedTransaction],
6492        }
6493
6494        #[derive(Serialize)]
6495        #[serde(transparent)]
6496        struct Field1<'a> {
6497            pub value: &'a [SimulationFlagForEstimateFee],
6498        }
6499
6500        #[derive(Serialize)]
6501        #[serde(transparent)]
6502        struct Field2<'a> {
6503            pub value: &'a BlockId,
6504        }
6505
6506        AsObject::serialize(
6507            &AsObject {
6508                request: Field0 {
6509                    value: self.request,
6510                },
6511                simulation_flags: Field1 {
6512                    value: self.simulation_flags,
6513                },
6514                block_id: Field2 {
6515                    value: self.block_id,
6516                },
6517            },
6518            serializer,
6519        )
6520    }
6521}
6522
6523impl<'de> Deserialize<'de> for EstimateFeeRequest {
6524    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6525        #[derive(Deserialize)]
6526        struct AsObject {
6527            request: Field0,
6528            simulation_flags: Field1,
6529            block_id: Field2,
6530        }
6531
6532        #[derive(Deserialize)]
6533        #[serde(transparent)]
6534        struct Field0 {
6535            pub value: Vec<BroadcastedTransaction>,
6536        }
6537
6538        #[derive(Deserialize)]
6539        #[serde(transparent)]
6540        struct Field1 {
6541            pub value: Vec<SimulationFlagForEstimateFee>,
6542        }
6543
6544        #[derive(Deserialize)]
6545        #[serde(transparent)]
6546        struct Field2 {
6547            pub value: BlockId,
6548        }
6549
6550        let temp = serde_json::Value::deserialize(deserializer)?;
6551
6552        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6553            let field2 = serde_json::from_value::<Field2>(
6554                elements
6555                    .pop()
6556                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6557            )
6558            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6559            let field1 = serde_json::from_value::<Field1>(
6560                elements
6561                    .pop()
6562                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6563            )
6564            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6565            let field0 = serde_json::from_value::<Field0>(
6566                elements
6567                    .pop()
6568                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6569            )
6570            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6571
6572            Ok(Self {
6573                request: field0.value,
6574                simulation_flags: field1.value,
6575                block_id: field2.value,
6576            })
6577        } else if let Ok(object) = AsObject::deserialize(&temp) {
6578            Ok(Self {
6579                request: object.request.value,
6580                simulation_flags: object.simulation_flags.value,
6581                block_id: object.block_id.value,
6582            })
6583        } else {
6584            Err(serde::de::Error::custom("invalid sequence length"))
6585        }
6586    }
6587}
6588
6589impl Serialize for EstimateMessageFeeRequest {
6590    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6591        #[derive(Serialize)]
6592        struct AsObject<'a> {
6593            message: Field0<'a>,
6594            block_id: Field1<'a>,
6595        }
6596
6597        #[derive(Serialize)]
6598        #[serde(transparent)]
6599        struct Field0<'a> {
6600            pub value: &'a MsgFromL1,
6601        }
6602
6603        #[derive(Serialize)]
6604        #[serde(transparent)]
6605        struct Field1<'a> {
6606            pub value: &'a BlockId,
6607        }
6608
6609        AsObject::serialize(
6610            &AsObject {
6611                message: Field0 {
6612                    value: &self.message,
6613                },
6614                block_id: Field1 {
6615                    value: &self.block_id,
6616                },
6617            },
6618            serializer,
6619        )
6620    }
6621}
6622
6623impl Serialize for EstimateMessageFeeRequestRef<'_> {
6624    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6625        #[derive(Serialize)]
6626        struct AsObject<'a> {
6627            message: Field0<'a>,
6628            block_id: Field1<'a>,
6629        }
6630
6631        #[derive(Serialize)]
6632        #[serde(transparent)]
6633        struct Field0<'a> {
6634            pub value: &'a MsgFromL1,
6635        }
6636
6637        #[derive(Serialize)]
6638        #[serde(transparent)]
6639        struct Field1<'a> {
6640            pub value: &'a BlockId,
6641        }
6642
6643        AsObject::serialize(
6644            &AsObject {
6645                message: Field0 {
6646                    value: self.message,
6647                },
6648                block_id: Field1 {
6649                    value: self.block_id,
6650                },
6651            },
6652            serializer,
6653        )
6654    }
6655}
6656
6657impl<'de> Deserialize<'de> for EstimateMessageFeeRequest {
6658    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6659        #[derive(Deserialize)]
6660        struct AsObject {
6661            message: Field0,
6662            block_id: Field1,
6663        }
6664
6665        #[derive(Deserialize)]
6666        #[serde(transparent)]
6667        struct Field0 {
6668            pub value: MsgFromL1,
6669        }
6670
6671        #[derive(Deserialize)]
6672        #[serde(transparent)]
6673        struct Field1 {
6674            pub value: BlockId,
6675        }
6676
6677        let temp = serde_json::Value::deserialize(deserializer)?;
6678
6679        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6680            let field1 = serde_json::from_value::<Field1>(
6681                elements
6682                    .pop()
6683                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6684            )
6685            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6686            let field0 = serde_json::from_value::<Field0>(
6687                elements
6688                    .pop()
6689                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6690            )
6691            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6692
6693            Ok(Self {
6694                message: field0.value,
6695                block_id: field1.value,
6696            })
6697        } else if let Ok(object) = AsObject::deserialize(&temp) {
6698            Ok(Self {
6699                message: object.message.value,
6700                block_id: object.block_id.value,
6701            })
6702        } else {
6703            Err(serde::de::Error::custom("invalid sequence length"))
6704        }
6705    }
6706}
6707
6708impl Serialize for GetBlockTransactionCountRequest {
6709    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6710        #[derive(Serialize)]
6711        struct AsObject<'a> {
6712            block_id: Field0<'a>,
6713        }
6714
6715        #[derive(Serialize)]
6716        #[serde(transparent)]
6717        struct Field0<'a> {
6718            pub value: &'a BlockId,
6719        }
6720
6721        AsObject::serialize(
6722            &AsObject {
6723                block_id: Field0 {
6724                    value: &self.block_id,
6725                },
6726            },
6727            serializer,
6728        )
6729    }
6730}
6731
6732impl Serialize for GetBlockTransactionCountRequestRef<'_> {
6733    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6734        #[derive(Serialize)]
6735        struct AsObject<'a> {
6736            block_id: Field0<'a>,
6737        }
6738
6739        #[derive(Serialize)]
6740        #[serde(transparent)]
6741        struct Field0<'a> {
6742            pub value: &'a BlockId,
6743        }
6744
6745        AsObject::serialize(
6746            &AsObject {
6747                block_id: Field0 {
6748                    value: self.block_id,
6749                },
6750            },
6751            serializer,
6752        )
6753    }
6754}
6755
6756impl<'de> Deserialize<'de> for GetBlockTransactionCountRequest {
6757    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6758        #[derive(Deserialize)]
6759        struct AsObject {
6760            block_id: Field0,
6761        }
6762
6763        #[derive(Deserialize)]
6764        #[serde(transparent)]
6765        struct Field0 {
6766            pub value: BlockId,
6767        }
6768
6769        let temp = serde_json::Value::deserialize(deserializer)?;
6770
6771        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6772            let field0 = serde_json::from_value::<Field0>(
6773                elements
6774                    .pop()
6775                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6776            )
6777            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6778
6779            Ok(Self {
6780                block_id: field0.value,
6781            })
6782        } else if let Ok(object) = AsObject::deserialize(&temp) {
6783            Ok(Self {
6784                block_id: object.block_id.value,
6785            })
6786        } else {
6787            Err(serde::de::Error::custom("invalid sequence length"))
6788        }
6789    }
6790}
6791
6792impl Serialize for GetBlockWithReceiptsRequest {
6793    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6794        #[derive(Serialize)]
6795        struct AsObject<'a> {
6796            block_id: Field0<'a>,
6797        }
6798
6799        #[derive(Serialize)]
6800        #[serde(transparent)]
6801        struct Field0<'a> {
6802            pub value: &'a BlockId,
6803        }
6804
6805        AsObject::serialize(
6806            &AsObject {
6807                block_id: Field0 {
6808                    value: &self.block_id,
6809                },
6810            },
6811            serializer,
6812        )
6813    }
6814}
6815
6816impl Serialize for GetBlockWithReceiptsRequestRef<'_> {
6817    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6818        #[derive(Serialize)]
6819        struct AsObject<'a> {
6820            block_id: Field0<'a>,
6821        }
6822
6823        #[derive(Serialize)]
6824        #[serde(transparent)]
6825        struct Field0<'a> {
6826            pub value: &'a BlockId,
6827        }
6828
6829        AsObject::serialize(
6830            &AsObject {
6831                block_id: Field0 {
6832                    value: self.block_id,
6833                },
6834            },
6835            serializer,
6836        )
6837    }
6838}
6839
6840impl<'de> Deserialize<'de> for GetBlockWithReceiptsRequest {
6841    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6842        #[derive(Deserialize)]
6843        struct AsObject {
6844            block_id: Field0,
6845        }
6846
6847        #[derive(Deserialize)]
6848        #[serde(transparent)]
6849        struct Field0 {
6850            pub value: BlockId,
6851        }
6852
6853        let temp = serde_json::Value::deserialize(deserializer)?;
6854
6855        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6856            let field0 = serde_json::from_value::<Field0>(
6857                elements
6858                    .pop()
6859                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6860            )
6861            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6862
6863            Ok(Self {
6864                block_id: field0.value,
6865            })
6866        } else if let Ok(object) = AsObject::deserialize(&temp) {
6867            Ok(Self {
6868                block_id: object.block_id.value,
6869            })
6870        } else {
6871            Err(serde::de::Error::custom("invalid sequence length"))
6872        }
6873    }
6874}
6875
6876impl Serialize for GetBlockWithTxHashesRequest {
6877    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6878        #[derive(Serialize)]
6879        struct AsObject<'a> {
6880            block_id: Field0<'a>,
6881        }
6882
6883        #[derive(Serialize)]
6884        #[serde(transparent)]
6885        struct Field0<'a> {
6886            pub value: &'a BlockId,
6887        }
6888
6889        AsObject::serialize(
6890            &AsObject {
6891                block_id: Field0 {
6892                    value: &self.block_id,
6893                },
6894            },
6895            serializer,
6896        )
6897    }
6898}
6899
6900impl Serialize for GetBlockWithTxHashesRequestRef<'_> {
6901    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6902        #[derive(Serialize)]
6903        struct AsObject<'a> {
6904            block_id: Field0<'a>,
6905        }
6906
6907        #[derive(Serialize)]
6908        #[serde(transparent)]
6909        struct Field0<'a> {
6910            pub value: &'a BlockId,
6911        }
6912
6913        AsObject::serialize(
6914            &AsObject {
6915                block_id: Field0 {
6916                    value: self.block_id,
6917                },
6918            },
6919            serializer,
6920        )
6921    }
6922}
6923
6924impl<'de> Deserialize<'de> for GetBlockWithTxHashesRequest {
6925    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6926        #[derive(Deserialize)]
6927        struct AsObject {
6928            block_id: Field0,
6929        }
6930
6931        #[derive(Deserialize)]
6932        #[serde(transparent)]
6933        struct Field0 {
6934            pub value: BlockId,
6935        }
6936
6937        let temp = serde_json::Value::deserialize(deserializer)?;
6938
6939        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
6940            let field0 = serde_json::from_value::<Field0>(
6941                elements
6942                    .pop()
6943                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
6944            )
6945            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
6946
6947            Ok(Self {
6948                block_id: field0.value,
6949            })
6950        } else if let Ok(object) = AsObject::deserialize(&temp) {
6951            Ok(Self {
6952                block_id: object.block_id.value,
6953            })
6954        } else {
6955            Err(serde::de::Error::custom("invalid sequence length"))
6956        }
6957    }
6958}
6959
6960impl Serialize for GetBlockWithTxsRequest {
6961    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6962        #[derive(Serialize)]
6963        struct AsObject<'a> {
6964            block_id: Field0<'a>,
6965        }
6966
6967        #[derive(Serialize)]
6968        #[serde(transparent)]
6969        struct Field0<'a> {
6970            pub value: &'a BlockId,
6971        }
6972
6973        AsObject::serialize(
6974            &AsObject {
6975                block_id: Field0 {
6976                    value: &self.block_id,
6977                },
6978            },
6979            serializer,
6980        )
6981    }
6982}
6983
6984impl Serialize for GetBlockWithTxsRequestRef<'_> {
6985    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6986        #[derive(Serialize)]
6987        struct AsObject<'a> {
6988            block_id: Field0<'a>,
6989        }
6990
6991        #[derive(Serialize)]
6992        #[serde(transparent)]
6993        struct Field0<'a> {
6994            pub value: &'a BlockId,
6995        }
6996
6997        AsObject::serialize(
6998            &AsObject {
6999                block_id: Field0 {
7000                    value: self.block_id,
7001                },
7002            },
7003            serializer,
7004        )
7005    }
7006}
7007
7008impl<'de> Deserialize<'de> for GetBlockWithTxsRequest {
7009    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7010        #[derive(Deserialize)]
7011        struct AsObject {
7012            block_id: Field0,
7013        }
7014
7015        #[derive(Deserialize)]
7016        #[serde(transparent)]
7017        struct Field0 {
7018            pub value: BlockId,
7019        }
7020
7021        let temp = serde_json::Value::deserialize(deserializer)?;
7022
7023        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7024            let field0 = serde_json::from_value::<Field0>(
7025                elements
7026                    .pop()
7027                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7028            )
7029            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7030
7031            Ok(Self {
7032                block_id: field0.value,
7033            })
7034        } else if let Ok(object) = AsObject::deserialize(&temp) {
7035            Ok(Self {
7036                block_id: object.block_id.value,
7037            })
7038        } else {
7039            Err(serde::de::Error::custom("invalid sequence length"))
7040        }
7041    }
7042}
7043
7044impl Serialize for GetClassAtRequest {
7045    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7046        #[derive(Serialize)]
7047        struct AsObject<'a> {
7048            block_id: Field0<'a>,
7049            contract_address: Field1<'a>,
7050        }
7051
7052        #[derive(Serialize)]
7053        #[serde(transparent)]
7054        struct Field0<'a> {
7055            pub value: &'a BlockId,
7056        }
7057
7058        #[serde_as]
7059        #[derive(Serialize)]
7060        #[serde(transparent)]
7061        struct Field1<'a> {
7062            #[serde_as(as = "UfeHex")]
7063            pub value: &'a Felt,
7064        }
7065
7066        AsObject::serialize(
7067            &AsObject {
7068                block_id: Field0 {
7069                    value: &self.block_id,
7070                },
7071                contract_address: Field1 {
7072                    value: &self.contract_address,
7073                },
7074            },
7075            serializer,
7076        )
7077    }
7078}
7079
7080impl Serialize for GetClassAtRequestRef<'_> {
7081    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7082        #[derive(Serialize)]
7083        struct AsObject<'a> {
7084            block_id: Field0<'a>,
7085            contract_address: Field1<'a>,
7086        }
7087
7088        #[derive(Serialize)]
7089        #[serde(transparent)]
7090        struct Field0<'a> {
7091            pub value: &'a BlockId,
7092        }
7093
7094        #[serde_as]
7095        #[derive(Serialize)]
7096        #[serde(transparent)]
7097        struct Field1<'a> {
7098            #[serde_as(as = "UfeHex")]
7099            pub value: &'a Felt,
7100        }
7101
7102        AsObject::serialize(
7103            &AsObject {
7104                block_id: Field0 {
7105                    value: self.block_id,
7106                },
7107                contract_address: Field1 {
7108                    value: self.contract_address,
7109                },
7110            },
7111            serializer,
7112        )
7113    }
7114}
7115
7116impl<'de> Deserialize<'de> for GetClassAtRequest {
7117    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7118        #[derive(Deserialize)]
7119        struct AsObject {
7120            block_id: Field0,
7121            contract_address: Field1,
7122        }
7123
7124        #[derive(Deserialize)]
7125        #[serde(transparent)]
7126        struct Field0 {
7127            pub value: BlockId,
7128        }
7129
7130        #[serde_as]
7131        #[derive(Deserialize)]
7132        #[serde(transparent)]
7133        struct Field1 {
7134            #[serde_as(as = "UfeHex")]
7135            pub value: Felt,
7136        }
7137
7138        let temp = serde_json::Value::deserialize(deserializer)?;
7139
7140        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7141            let field1 = serde_json::from_value::<Field1>(
7142                elements
7143                    .pop()
7144                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7145            )
7146            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7147            let field0 = serde_json::from_value::<Field0>(
7148                elements
7149                    .pop()
7150                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7151            )
7152            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7153
7154            Ok(Self {
7155                block_id: field0.value,
7156                contract_address: field1.value,
7157            })
7158        } else if let Ok(object) = AsObject::deserialize(&temp) {
7159            Ok(Self {
7160                block_id: object.block_id.value,
7161                contract_address: object.contract_address.value,
7162            })
7163        } else {
7164            Err(serde::de::Error::custom("invalid sequence length"))
7165        }
7166    }
7167}
7168
7169impl Serialize for GetClassHashAtRequest {
7170    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7171        #[derive(Serialize)]
7172        struct AsObject<'a> {
7173            block_id: Field0<'a>,
7174            contract_address: Field1<'a>,
7175        }
7176
7177        #[derive(Serialize)]
7178        #[serde(transparent)]
7179        struct Field0<'a> {
7180            pub value: &'a BlockId,
7181        }
7182
7183        #[serde_as]
7184        #[derive(Serialize)]
7185        #[serde(transparent)]
7186        struct Field1<'a> {
7187            #[serde_as(as = "UfeHex")]
7188            pub value: &'a Felt,
7189        }
7190
7191        AsObject::serialize(
7192            &AsObject {
7193                block_id: Field0 {
7194                    value: &self.block_id,
7195                },
7196                contract_address: Field1 {
7197                    value: &self.contract_address,
7198                },
7199            },
7200            serializer,
7201        )
7202    }
7203}
7204
7205impl Serialize for GetClassHashAtRequestRef<'_> {
7206    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7207        #[derive(Serialize)]
7208        struct AsObject<'a> {
7209            block_id: Field0<'a>,
7210            contract_address: Field1<'a>,
7211        }
7212
7213        #[derive(Serialize)]
7214        #[serde(transparent)]
7215        struct Field0<'a> {
7216            pub value: &'a BlockId,
7217        }
7218
7219        #[serde_as]
7220        #[derive(Serialize)]
7221        #[serde(transparent)]
7222        struct Field1<'a> {
7223            #[serde_as(as = "UfeHex")]
7224            pub value: &'a Felt,
7225        }
7226
7227        AsObject::serialize(
7228            &AsObject {
7229                block_id: Field0 {
7230                    value: self.block_id,
7231                },
7232                contract_address: Field1 {
7233                    value: self.contract_address,
7234                },
7235            },
7236            serializer,
7237        )
7238    }
7239}
7240
7241impl<'de> Deserialize<'de> for GetClassHashAtRequest {
7242    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7243        #[derive(Deserialize)]
7244        struct AsObject {
7245            block_id: Field0,
7246            contract_address: Field1,
7247        }
7248
7249        #[derive(Deserialize)]
7250        #[serde(transparent)]
7251        struct Field0 {
7252            pub value: BlockId,
7253        }
7254
7255        #[serde_as]
7256        #[derive(Deserialize)]
7257        #[serde(transparent)]
7258        struct Field1 {
7259            #[serde_as(as = "UfeHex")]
7260            pub value: Felt,
7261        }
7262
7263        let temp = serde_json::Value::deserialize(deserializer)?;
7264
7265        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7266            let field1 = serde_json::from_value::<Field1>(
7267                elements
7268                    .pop()
7269                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7270            )
7271            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7272            let field0 = serde_json::from_value::<Field0>(
7273                elements
7274                    .pop()
7275                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7276            )
7277            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7278
7279            Ok(Self {
7280                block_id: field0.value,
7281                contract_address: field1.value,
7282            })
7283        } else if let Ok(object) = AsObject::deserialize(&temp) {
7284            Ok(Self {
7285                block_id: object.block_id.value,
7286                contract_address: object.contract_address.value,
7287            })
7288        } else {
7289            Err(serde::de::Error::custom("invalid sequence length"))
7290        }
7291    }
7292}
7293
7294impl Serialize for GetClassRequest {
7295    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7296        #[derive(Serialize)]
7297        struct AsObject<'a> {
7298            block_id: Field0<'a>,
7299            class_hash: Field1<'a>,
7300        }
7301
7302        #[derive(Serialize)]
7303        #[serde(transparent)]
7304        struct Field0<'a> {
7305            pub value: &'a BlockId,
7306        }
7307
7308        #[serde_as]
7309        #[derive(Serialize)]
7310        #[serde(transparent)]
7311        struct Field1<'a> {
7312            #[serde_as(as = "UfeHex")]
7313            pub value: &'a Felt,
7314        }
7315
7316        AsObject::serialize(
7317            &AsObject {
7318                block_id: Field0 {
7319                    value: &self.block_id,
7320                },
7321                class_hash: Field1 {
7322                    value: &self.class_hash,
7323                },
7324            },
7325            serializer,
7326        )
7327    }
7328}
7329
7330impl Serialize for GetClassRequestRef<'_> {
7331    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7332        #[derive(Serialize)]
7333        struct AsObject<'a> {
7334            block_id: Field0<'a>,
7335            class_hash: Field1<'a>,
7336        }
7337
7338        #[derive(Serialize)]
7339        #[serde(transparent)]
7340        struct Field0<'a> {
7341            pub value: &'a BlockId,
7342        }
7343
7344        #[serde_as]
7345        #[derive(Serialize)]
7346        #[serde(transparent)]
7347        struct Field1<'a> {
7348            #[serde_as(as = "UfeHex")]
7349            pub value: &'a Felt,
7350        }
7351
7352        AsObject::serialize(
7353            &AsObject {
7354                block_id: Field0 {
7355                    value: self.block_id,
7356                },
7357                class_hash: Field1 {
7358                    value: self.class_hash,
7359                },
7360            },
7361            serializer,
7362        )
7363    }
7364}
7365
7366impl<'de> Deserialize<'de> for GetClassRequest {
7367    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7368        #[derive(Deserialize)]
7369        struct AsObject {
7370            block_id: Field0,
7371            class_hash: Field1,
7372        }
7373
7374        #[derive(Deserialize)]
7375        #[serde(transparent)]
7376        struct Field0 {
7377            pub value: BlockId,
7378        }
7379
7380        #[serde_as]
7381        #[derive(Deserialize)]
7382        #[serde(transparent)]
7383        struct Field1 {
7384            #[serde_as(as = "UfeHex")]
7385            pub value: Felt,
7386        }
7387
7388        let temp = serde_json::Value::deserialize(deserializer)?;
7389
7390        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7391            let field1 = serde_json::from_value::<Field1>(
7392                elements
7393                    .pop()
7394                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7395            )
7396            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7397            let field0 = serde_json::from_value::<Field0>(
7398                elements
7399                    .pop()
7400                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7401            )
7402            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7403
7404            Ok(Self {
7405                block_id: field0.value,
7406                class_hash: field1.value,
7407            })
7408        } else if let Ok(object) = AsObject::deserialize(&temp) {
7409            Ok(Self {
7410                block_id: object.block_id.value,
7411                class_hash: object.class_hash.value,
7412            })
7413        } else {
7414            Err(serde::de::Error::custom("invalid sequence length"))
7415        }
7416    }
7417}
7418
7419impl Serialize for GetEventsRequest {
7420    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7421        #[derive(Serialize)]
7422        struct AsObject<'a> {
7423            filter: Field0<'a>,
7424        }
7425
7426        #[derive(Serialize)]
7427        #[serde(transparent)]
7428        struct Field0<'a> {
7429            pub value: &'a EventFilterWithPage,
7430        }
7431
7432        AsObject::serialize(
7433            &AsObject {
7434                filter: Field0 {
7435                    value: &self.filter,
7436                },
7437            },
7438            serializer,
7439        )
7440    }
7441}
7442
7443impl Serialize for GetEventsRequestRef<'_> {
7444    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7445        #[derive(Serialize)]
7446        struct AsObject<'a> {
7447            filter: Field0<'a>,
7448        }
7449
7450        #[derive(Serialize)]
7451        #[serde(transparent)]
7452        struct Field0<'a> {
7453            pub value: &'a EventFilterWithPage,
7454        }
7455
7456        AsObject::serialize(
7457            &AsObject {
7458                filter: Field0 { value: self.filter },
7459            },
7460            serializer,
7461        )
7462    }
7463}
7464
7465impl<'de> Deserialize<'de> for GetEventsRequest {
7466    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7467        #[derive(Deserialize)]
7468        struct AsObject {
7469            filter: Field0,
7470        }
7471
7472        #[derive(Deserialize)]
7473        #[serde(transparent)]
7474        struct Field0 {
7475            pub value: EventFilterWithPage,
7476        }
7477
7478        let temp = serde_json::Value::deserialize(deserializer)?;
7479
7480        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7481            let field0 = serde_json::from_value::<Field0>(
7482                elements
7483                    .pop()
7484                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7485            )
7486            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7487
7488            Ok(Self {
7489                filter: field0.value,
7490            })
7491        } else if let Ok(object) = AsObject::deserialize(&temp) {
7492            Ok(Self {
7493                filter: object.filter.value,
7494            })
7495        } else {
7496            Err(serde::de::Error::custom("invalid sequence length"))
7497        }
7498    }
7499}
7500
7501impl Serialize for GetMessagesStatusRequest {
7502    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7503        #[derive(Serialize)]
7504        struct AsObject<'a> {
7505            transaction_hash: Field0<'a>,
7506        }
7507
7508        #[derive(Serialize)]
7509        #[serde(transparent)]
7510        struct Field0<'a> {
7511            pub value: &'a Hash256,
7512        }
7513
7514        AsObject::serialize(
7515            &AsObject {
7516                transaction_hash: Field0 {
7517                    value: &self.transaction_hash,
7518                },
7519            },
7520            serializer,
7521        )
7522    }
7523}
7524
7525impl Serialize for GetMessagesStatusRequestRef<'_> {
7526    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7527        #[derive(Serialize)]
7528        struct AsObject<'a> {
7529            transaction_hash: Field0<'a>,
7530        }
7531
7532        #[derive(Serialize)]
7533        #[serde(transparent)]
7534        struct Field0<'a> {
7535            pub value: &'a Hash256,
7536        }
7537
7538        AsObject::serialize(
7539            &AsObject {
7540                transaction_hash: Field0 {
7541                    value: self.transaction_hash,
7542                },
7543            },
7544            serializer,
7545        )
7546    }
7547}
7548
7549impl<'de> Deserialize<'de> for GetMessagesStatusRequest {
7550    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7551        #[derive(Deserialize)]
7552        struct AsObject {
7553            transaction_hash: Field0,
7554        }
7555
7556        #[derive(Deserialize)]
7557        #[serde(transparent)]
7558        struct Field0 {
7559            pub value: Hash256,
7560        }
7561
7562        let temp = serde_json::Value::deserialize(deserializer)?;
7563
7564        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7565            let field0 = serde_json::from_value::<Field0>(
7566                elements
7567                    .pop()
7568                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7569            )
7570            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7571
7572            Ok(Self {
7573                transaction_hash: field0.value,
7574            })
7575        } else if let Ok(object) = AsObject::deserialize(&temp) {
7576            Ok(Self {
7577                transaction_hash: object.transaction_hash.value,
7578            })
7579        } else {
7580            Err(serde::de::Error::custom("invalid sequence length"))
7581        }
7582    }
7583}
7584
7585impl Serialize for GetNonceRequest {
7586    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7587        #[derive(Serialize)]
7588        struct AsObject<'a> {
7589            block_id: Field0<'a>,
7590            contract_address: Field1<'a>,
7591        }
7592
7593        #[derive(Serialize)]
7594        #[serde(transparent)]
7595        struct Field0<'a> {
7596            pub value: &'a BlockId,
7597        }
7598
7599        #[serde_as]
7600        #[derive(Serialize)]
7601        #[serde(transparent)]
7602        struct Field1<'a> {
7603            #[serde_as(as = "UfeHex")]
7604            pub value: &'a Felt,
7605        }
7606
7607        AsObject::serialize(
7608            &AsObject {
7609                block_id: Field0 {
7610                    value: &self.block_id,
7611                },
7612                contract_address: Field1 {
7613                    value: &self.contract_address,
7614                },
7615            },
7616            serializer,
7617        )
7618    }
7619}
7620
7621impl Serialize for GetNonceRequestRef<'_> {
7622    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7623        #[derive(Serialize)]
7624        struct AsObject<'a> {
7625            block_id: Field0<'a>,
7626            contract_address: Field1<'a>,
7627        }
7628
7629        #[derive(Serialize)]
7630        #[serde(transparent)]
7631        struct Field0<'a> {
7632            pub value: &'a BlockId,
7633        }
7634
7635        #[serde_as]
7636        #[derive(Serialize)]
7637        #[serde(transparent)]
7638        struct Field1<'a> {
7639            #[serde_as(as = "UfeHex")]
7640            pub value: &'a Felt,
7641        }
7642
7643        AsObject::serialize(
7644            &AsObject {
7645                block_id: Field0 {
7646                    value: self.block_id,
7647                },
7648                contract_address: Field1 {
7649                    value: self.contract_address,
7650                },
7651            },
7652            serializer,
7653        )
7654    }
7655}
7656
7657impl<'de> Deserialize<'de> for GetNonceRequest {
7658    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7659        #[derive(Deserialize)]
7660        struct AsObject {
7661            block_id: Field0,
7662            contract_address: Field1,
7663        }
7664
7665        #[derive(Deserialize)]
7666        #[serde(transparent)]
7667        struct Field0 {
7668            pub value: BlockId,
7669        }
7670
7671        #[serde_as]
7672        #[derive(Deserialize)]
7673        #[serde(transparent)]
7674        struct Field1 {
7675            #[serde_as(as = "UfeHex")]
7676            pub value: Felt,
7677        }
7678
7679        let temp = serde_json::Value::deserialize(deserializer)?;
7680
7681        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7682            let field1 = serde_json::from_value::<Field1>(
7683                elements
7684                    .pop()
7685                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7686            )
7687            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7688            let field0 = serde_json::from_value::<Field0>(
7689                elements
7690                    .pop()
7691                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7692            )
7693            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7694
7695            Ok(Self {
7696                block_id: field0.value,
7697                contract_address: field1.value,
7698            })
7699        } else if let Ok(object) = AsObject::deserialize(&temp) {
7700            Ok(Self {
7701                block_id: object.block_id.value,
7702                contract_address: object.contract_address.value,
7703            })
7704        } else {
7705            Err(serde::de::Error::custom("invalid sequence length"))
7706        }
7707    }
7708}
7709
7710impl Serialize for GetStateUpdateRequest {
7711    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7712        #[derive(Serialize)]
7713        struct AsObject<'a> {
7714            block_id: Field0<'a>,
7715        }
7716
7717        #[derive(Serialize)]
7718        #[serde(transparent)]
7719        struct Field0<'a> {
7720            pub value: &'a BlockId,
7721        }
7722
7723        AsObject::serialize(
7724            &AsObject {
7725                block_id: Field0 {
7726                    value: &self.block_id,
7727                },
7728            },
7729            serializer,
7730        )
7731    }
7732}
7733
7734impl Serialize for GetStateUpdateRequestRef<'_> {
7735    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7736        #[derive(Serialize)]
7737        struct AsObject<'a> {
7738            block_id: Field0<'a>,
7739        }
7740
7741        #[derive(Serialize)]
7742        #[serde(transparent)]
7743        struct Field0<'a> {
7744            pub value: &'a BlockId,
7745        }
7746
7747        AsObject::serialize(
7748            &AsObject {
7749                block_id: Field0 {
7750                    value: self.block_id,
7751                },
7752            },
7753            serializer,
7754        )
7755    }
7756}
7757
7758impl<'de> Deserialize<'de> for GetStateUpdateRequest {
7759    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7760        #[derive(Deserialize)]
7761        struct AsObject {
7762            block_id: Field0,
7763        }
7764
7765        #[derive(Deserialize)]
7766        #[serde(transparent)]
7767        struct Field0 {
7768            pub value: BlockId,
7769        }
7770
7771        let temp = serde_json::Value::deserialize(deserializer)?;
7772
7773        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7774            let field0 = serde_json::from_value::<Field0>(
7775                elements
7776                    .pop()
7777                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7778            )
7779            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7780
7781            Ok(Self {
7782                block_id: field0.value,
7783            })
7784        } else if let Ok(object) = AsObject::deserialize(&temp) {
7785            Ok(Self {
7786                block_id: object.block_id.value,
7787            })
7788        } else {
7789            Err(serde::de::Error::custom("invalid sequence length"))
7790        }
7791    }
7792}
7793
7794impl Serialize for GetStorageAtRequest {
7795    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7796        #[derive(Serialize)]
7797        struct AsObject<'a> {
7798            contract_address: Field0<'a>,
7799            key: Field1<'a>,
7800            block_id: Field2<'a>,
7801        }
7802
7803        #[serde_as]
7804        #[derive(Serialize)]
7805        #[serde(transparent)]
7806        struct Field0<'a> {
7807            #[serde_as(as = "UfeHex")]
7808            pub value: &'a Felt,
7809        }
7810
7811        #[serde_as]
7812        #[derive(Serialize)]
7813        #[serde(transparent)]
7814        struct Field1<'a> {
7815            #[serde_as(as = "UfeHex")]
7816            pub value: &'a Felt,
7817        }
7818
7819        #[derive(Serialize)]
7820        #[serde(transparent)]
7821        struct Field2<'a> {
7822            pub value: &'a BlockId,
7823        }
7824
7825        AsObject::serialize(
7826            &AsObject {
7827                contract_address: Field0 {
7828                    value: &self.contract_address,
7829                },
7830                key: Field1 { value: &self.key },
7831                block_id: Field2 {
7832                    value: &self.block_id,
7833                },
7834            },
7835            serializer,
7836        )
7837    }
7838}
7839
7840impl Serialize for GetStorageAtRequestRef<'_> {
7841    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7842        #[derive(Serialize)]
7843        struct AsObject<'a> {
7844            contract_address: Field0<'a>,
7845            key: Field1<'a>,
7846            block_id: Field2<'a>,
7847        }
7848
7849        #[serde_as]
7850        #[derive(Serialize)]
7851        #[serde(transparent)]
7852        struct Field0<'a> {
7853            #[serde_as(as = "UfeHex")]
7854            pub value: &'a Felt,
7855        }
7856
7857        #[serde_as]
7858        #[derive(Serialize)]
7859        #[serde(transparent)]
7860        struct Field1<'a> {
7861            #[serde_as(as = "UfeHex")]
7862            pub value: &'a Felt,
7863        }
7864
7865        #[derive(Serialize)]
7866        #[serde(transparent)]
7867        struct Field2<'a> {
7868            pub value: &'a BlockId,
7869        }
7870
7871        AsObject::serialize(
7872            &AsObject {
7873                contract_address: Field0 {
7874                    value: self.contract_address,
7875                },
7876                key: Field1 { value: self.key },
7877                block_id: Field2 {
7878                    value: self.block_id,
7879                },
7880            },
7881            serializer,
7882        )
7883    }
7884}
7885
7886impl<'de> Deserialize<'de> for GetStorageAtRequest {
7887    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7888        #[derive(Deserialize)]
7889        struct AsObject {
7890            contract_address: Field0,
7891            key: Field1,
7892            block_id: Field2,
7893        }
7894
7895        #[serde_as]
7896        #[derive(Deserialize)]
7897        #[serde(transparent)]
7898        struct Field0 {
7899            #[serde_as(as = "UfeHex")]
7900            pub value: Felt,
7901        }
7902
7903        #[serde_as]
7904        #[derive(Deserialize)]
7905        #[serde(transparent)]
7906        struct Field1 {
7907            #[serde_as(as = "UfeHex")]
7908            pub value: Felt,
7909        }
7910
7911        #[derive(Deserialize)]
7912        #[serde(transparent)]
7913        struct Field2 {
7914            pub value: BlockId,
7915        }
7916
7917        let temp = serde_json::Value::deserialize(deserializer)?;
7918
7919        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
7920            let field2 = serde_json::from_value::<Field2>(
7921                elements
7922                    .pop()
7923                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7924            )
7925            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7926            let field1 = serde_json::from_value::<Field1>(
7927                elements
7928                    .pop()
7929                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7930            )
7931            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7932            let field0 = serde_json::from_value::<Field0>(
7933                elements
7934                    .pop()
7935                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
7936            )
7937            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
7938
7939            Ok(Self {
7940                contract_address: field0.value,
7941                key: field1.value,
7942                block_id: field2.value,
7943            })
7944        } else if let Ok(object) = AsObject::deserialize(&temp) {
7945            Ok(Self {
7946                contract_address: object.contract_address.value,
7947                key: object.key.value,
7948                block_id: object.block_id.value,
7949            })
7950        } else {
7951            Err(serde::de::Error::custom("invalid sequence length"))
7952        }
7953    }
7954}
7955
7956impl Serialize for GetStorageProofRequest {
7957    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7958        #[derive(Serialize)]
7959        struct AsObject<'a> {
7960            block_id: Field0<'a>,
7961            #[serde(skip_serializing_if = "Option::is_none")]
7962            class_hashes: Option<Field1<'a>>,
7963            #[serde(skip_serializing_if = "Option::is_none")]
7964            contract_addresses: Option<Field2<'a>>,
7965            #[serde(skip_serializing_if = "Option::is_none")]
7966            contracts_storage_keys: Option<Field3<'a>>,
7967        }
7968
7969        #[derive(Serialize)]
7970        #[serde(transparent)]
7971        struct Field0<'a> {
7972            pub value: &'a ConfirmedBlockId,
7973        }
7974
7975        #[serde_as]
7976        #[derive(Serialize)]
7977        #[serde(transparent)]
7978        struct Field1<'a> {
7979            #[serde_as(as = "[UfeHex]")]
7980            pub value: &'a [Felt],
7981        }
7982
7983        #[serde_as]
7984        #[derive(Serialize)]
7985        #[serde(transparent)]
7986        struct Field2<'a> {
7987            #[serde_as(as = "[UfeHex]")]
7988            pub value: &'a [Felt],
7989        }
7990
7991        #[derive(Serialize)]
7992        #[serde(transparent)]
7993        struct Field3<'a> {
7994            pub value: &'a [ContractStorageKeys],
7995        }
7996
7997        AsObject::serialize(
7998            &AsObject {
7999                block_id: Field0 {
8000                    value: &self.block_id,
8001                },
8002                class_hashes: self.class_hashes.as_ref().map(|f| Field1 { value: f }),
8003                contract_addresses: self
8004                    .contract_addresses
8005                    .as_ref()
8006                    .map(|f| Field2 { value: f }),
8007                contracts_storage_keys: self
8008                    .contracts_storage_keys
8009                    .as_ref()
8010                    .map(|f| Field3 { value: f }),
8011            },
8012            serializer,
8013        )
8014    }
8015}
8016
8017impl Serialize for GetStorageProofRequestRef<'_> {
8018    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8019        #[derive(Serialize)]
8020        struct AsObject<'a> {
8021            block_id: Field0<'a>,
8022            #[serde(skip_serializing_if = "Option::is_none")]
8023            class_hashes: Option<Field1<'a>>,
8024            #[serde(skip_serializing_if = "Option::is_none")]
8025            contract_addresses: Option<Field2<'a>>,
8026            #[serde(skip_serializing_if = "Option::is_none")]
8027            contracts_storage_keys: Option<Field3<'a>>,
8028        }
8029
8030        #[derive(Serialize)]
8031        #[serde(transparent)]
8032        struct Field0<'a> {
8033            pub value: &'a ConfirmedBlockId,
8034        }
8035
8036        #[serde_as]
8037        #[derive(Serialize)]
8038        #[serde(transparent)]
8039        struct Field1<'a> {
8040            #[serde_as(as = "[UfeHex]")]
8041            pub value: &'a [Felt],
8042        }
8043
8044        #[serde_as]
8045        #[derive(Serialize)]
8046        #[serde(transparent)]
8047        struct Field2<'a> {
8048            #[serde_as(as = "[UfeHex]")]
8049            pub value: &'a [Felt],
8050        }
8051
8052        #[derive(Serialize)]
8053        #[serde(transparent)]
8054        struct Field3<'a> {
8055            pub value: &'a [ContractStorageKeys],
8056        }
8057
8058        AsObject::serialize(
8059            &AsObject {
8060                block_id: Field0 {
8061                    value: self.block_id,
8062                },
8063                class_hashes: self.class_hashes.as_ref().map(|f| Field1 { value: f }),
8064                contract_addresses: self
8065                    .contract_addresses
8066                    .as_ref()
8067                    .map(|f| Field2 { value: f }),
8068                contracts_storage_keys: self
8069                    .contracts_storage_keys
8070                    .as_ref()
8071                    .map(|f| Field3 { value: f }),
8072            },
8073            serializer,
8074        )
8075    }
8076}
8077
8078impl<'de> Deserialize<'de> for GetStorageProofRequest {
8079    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8080        #[derive(Deserialize)]
8081        struct AsObject {
8082            block_id: Field0,
8083            #[serde(skip_serializing_if = "Option::is_none")]
8084            class_hashes: Option<Field1>,
8085            #[serde(skip_serializing_if = "Option::is_none")]
8086            contract_addresses: Option<Field2>,
8087            #[serde(skip_serializing_if = "Option::is_none")]
8088            contracts_storage_keys: Option<Field3>,
8089        }
8090
8091        #[derive(Deserialize)]
8092        #[serde(transparent)]
8093        struct Field0 {
8094            pub value: ConfirmedBlockId,
8095        }
8096
8097        #[serde_as]
8098        #[derive(Deserialize)]
8099        #[serde(transparent)]
8100        struct Field1 {
8101            #[serde_as(as = "Vec<UfeHex>")]
8102            pub value: Vec<Felt>,
8103        }
8104
8105        #[serde_as]
8106        #[derive(Deserialize)]
8107        #[serde(transparent)]
8108        struct Field2 {
8109            #[serde_as(as = "Vec<UfeHex>")]
8110            pub value: Vec<Felt>,
8111        }
8112
8113        #[derive(Deserialize)]
8114        #[serde(transparent)]
8115        struct Field3 {
8116            pub value: Vec<ContractStorageKeys>,
8117        }
8118
8119        let temp = serde_json::Value::deserialize(deserializer)?;
8120
8121        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
8122            let element_count = elements.len();
8123
8124            let field3 = if element_count > 3 {
8125                Some(
8126                    serde_json::from_value::<Field3>(elements.pop().unwrap()).map_err(|err| {
8127                        serde::de::Error::custom(format!("failed to parse element: {err}"))
8128                    })?,
8129                )
8130            } else {
8131                None
8132            };
8133            let field2 = if element_count > 2 {
8134                Some(
8135                    serde_json::from_value::<Field2>(elements.pop().unwrap()).map_err(|err| {
8136                        serde::de::Error::custom(format!("failed to parse element: {err}"))
8137                    })?,
8138                )
8139            } else {
8140                None
8141            };
8142            let field1 = if element_count > 1 {
8143                Some(
8144                    serde_json::from_value::<Field1>(elements.pop().unwrap()).map_err(|err| {
8145                        serde::de::Error::custom(format!("failed to parse element: {err}"))
8146                    })?,
8147                )
8148            } else {
8149                None
8150            };
8151            let field0 = serde_json::from_value::<Field0>(
8152                elements
8153                    .pop()
8154                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8155            )
8156            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8157
8158            Ok(Self {
8159                block_id: field0.value,
8160                class_hashes: field1.map(|f| f.value),
8161                contract_addresses: field2.map(|f| f.value),
8162                contracts_storage_keys: field3.map(|f| f.value),
8163            })
8164        } else if let Ok(object) = AsObject::deserialize(&temp) {
8165            Ok(Self {
8166                block_id: object.block_id.value,
8167                class_hashes: object.class_hashes.map(|f| f.value),
8168                contract_addresses: object.contract_addresses.map(|f| f.value),
8169                contracts_storage_keys: object.contracts_storage_keys.map(|f| f.value),
8170            })
8171        } else {
8172            Err(serde::de::Error::custom("invalid sequence length"))
8173        }
8174    }
8175}
8176
8177impl Serialize for GetTransactionByBlockIdAndIndexRequest {
8178    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8179        #[derive(Serialize)]
8180        struct AsObject<'a> {
8181            block_id: Field0<'a>,
8182            index: Field1<'a>,
8183        }
8184
8185        #[derive(Serialize)]
8186        #[serde(transparent)]
8187        struct Field0<'a> {
8188            pub value: &'a BlockId,
8189        }
8190
8191        #[derive(Serialize)]
8192        #[serde(transparent)]
8193        struct Field1<'a> {
8194            pub value: &'a u64,
8195        }
8196
8197        AsObject::serialize(
8198            &AsObject {
8199                block_id: Field0 {
8200                    value: &self.block_id,
8201                },
8202                index: Field1 { value: &self.index },
8203            },
8204            serializer,
8205        )
8206    }
8207}
8208
8209impl Serialize for GetTransactionByBlockIdAndIndexRequestRef<'_> {
8210    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8211        #[derive(Serialize)]
8212        struct AsObject<'a> {
8213            block_id: Field0<'a>,
8214            index: Field1<'a>,
8215        }
8216
8217        #[derive(Serialize)]
8218        #[serde(transparent)]
8219        struct Field0<'a> {
8220            pub value: &'a BlockId,
8221        }
8222
8223        #[derive(Serialize)]
8224        #[serde(transparent)]
8225        struct Field1<'a> {
8226            pub value: &'a u64,
8227        }
8228
8229        AsObject::serialize(
8230            &AsObject {
8231                block_id: Field0 {
8232                    value: self.block_id,
8233                },
8234                index: Field1 { value: self.index },
8235            },
8236            serializer,
8237        )
8238    }
8239}
8240
8241impl<'de> Deserialize<'de> for GetTransactionByBlockIdAndIndexRequest {
8242    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8243        #[derive(Deserialize)]
8244        struct AsObject {
8245            block_id: Field0,
8246            index: Field1,
8247        }
8248
8249        #[derive(Deserialize)]
8250        #[serde(transparent)]
8251        struct Field0 {
8252            pub value: BlockId,
8253        }
8254
8255        #[derive(Deserialize)]
8256        #[serde(transparent)]
8257        struct Field1 {
8258            pub value: u64,
8259        }
8260
8261        let temp = serde_json::Value::deserialize(deserializer)?;
8262
8263        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
8264            let field1 = serde_json::from_value::<Field1>(
8265                elements
8266                    .pop()
8267                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8268            )
8269            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8270            let field0 = serde_json::from_value::<Field0>(
8271                elements
8272                    .pop()
8273                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8274            )
8275            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8276
8277            Ok(Self {
8278                block_id: field0.value,
8279                index: field1.value,
8280            })
8281        } else if let Ok(object) = AsObject::deserialize(&temp) {
8282            Ok(Self {
8283                block_id: object.block_id.value,
8284                index: object.index.value,
8285            })
8286        } else {
8287            Err(serde::de::Error::custom("invalid sequence length"))
8288        }
8289    }
8290}
8291
8292impl Serialize for GetTransactionByHashRequest {
8293    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8294        #[derive(Serialize)]
8295        struct AsObject<'a> {
8296            transaction_hash: Field0<'a>,
8297        }
8298
8299        #[serde_as]
8300        #[derive(Serialize)]
8301        #[serde(transparent)]
8302        struct Field0<'a> {
8303            #[serde_as(as = "UfeHex")]
8304            pub value: &'a Felt,
8305        }
8306
8307        AsObject::serialize(
8308            &AsObject {
8309                transaction_hash: Field0 {
8310                    value: &self.transaction_hash,
8311                },
8312            },
8313            serializer,
8314        )
8315    }
8316}
8317
8318impl Serialize for GetTransactionByHashRequestRef<'_> {
8319    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8320        #[derive(Serialize)]
8321        struct AsObject<'a> {
8322            transaction_hash: Field0<'a>,
8323        }
8324
8325        #[serde_as]
8326        #[derive(Serialize)]
8327        #[serde(transparent)]
8328        struct Field0<'a> {
8329            #[serde_as(as = "UfeHex")]
8330            pub value: &'a Felt,
8331        }
8332
8333        AsObject::serialize(
8334            &AsObject {
8335                transaction_hash: Field0 {
8336                    value: self.transaction_hash,
8337                },
8338            },
8339            serializer,
8340        )
8341    }
8342}
8343
8344impl<'de> Deserialize<'de> for GetTransactionByHashRequest {
8345    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8346        #[derive(Deserialize)]
8347        struct AsObject {
8348            transaction_hash: Field0,
8349        }
8350
8351        #[serde_as]
8352        #[derive(Deserialize)]
8353        #[serde(transparent)]
8354        struct Field0 {
8355            #[serde_as(as = "UfeHex")]
8356            pub value: Felt,
8357        }
8358
8359        let temp = serde_json::Value::deserialize(deserializer)?;
8360
8361        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
8362            let field0 = serde_json::from_value::<Field0>(
8363                elements
8364                    .pop()
8365                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8366            )
8367            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8368
8369            Ok(Self {
8370                transaction_hash: field0.value,
8371            })
8372        } else if let Ok(object) = AsObject::deserialize(&temp) {
8373            Ok(Self {
8374                transaction_hash: object.transaction_hash.value,
8375            })
8376        } else {
8377            Err(serde::de::Error::custom("invalid sequence length"))
8378        }
8379    }
8380}
8381
8382impl Serialize for GetTransactionReceiptRequest {
8383    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8384        #[derive(Serialize)]
8385        struct AsObject<'a> {
8386            transaction_hash: Field0<'a>,
8387        }
8388
8389        #[serde_as]
8390        #[derive(Serialize)]
8391        #[serde(transparent)]
8392        struct Field0<'a> {
8393            #[serde_as(as = "UfeHex")]
8394            pub value: &'a Felt,
8395        }
8396
8397        AsObject::serialize(
8398            &AsObject {
8399                transaction_hash: Field0 {
8400                    value: &self.transaction_hash,
8401                },
8402            },
8403            serializer,
8404        )
8405    }
8406}
8407
8408impl Serialize for GetTransactionReceiptRequestRef<'_> {
8409    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8410        #[derive(Serialize)]
8411        struct AsObject<'a> {
8412            transaction_hash: Field0<'a>,
8413        }
8414
8415        #[serde_as]
8416        #[derive(Serialize)]
8417        #[serde(transparent)]
8418        struct Field0<'a> {
8419            #[serde_as(as = "UfeHex")]
8420            pub value: &'a Felt,
8421        }
8422
8423        AsObject::serialize(
8424            &AsObject {
8425                transaction_hash: Field0 {
8426                    value: self.transaction_hash,
8427                },
8428            },
8429            serializer,
8430        )
8431    }
8432}
8433
8434impl<'de> Deserialize<'de> for GetTransactionReceiptRequest {
8435    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8436        #[derive(Deserialize)]
8437        struct AsObject {
8438            transaction_hash: Field0,
8439        }
8440
8441        #[serde_as]
8442        #[derive(Deserialize)]
8443        #[serde(transparent)]
8444        struct Field0 {
8445            #[serde_as(as = "UfeHex")]
8446            pub value: Felt,
8447        }
8448
8449        let temp = serde_json::Value::deserialize(deserializer)?;
8450
8451        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
8452            let field0 = serde_json::from_value::<Field0>(
8453                elements
8454                    .pop()
8455                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8456            )
8457            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8458
8459            Ok(Self {
8460                transaction_hash: field0.value,
8461            })
8462        } else if let Ok(object) = AsObject::deserialize(&temp) {
8463            Ok(Self {
8464                transaction_hash: object.transaction_hash.value,
8465            })
8466        } else {
8467            Err(serde::de::Error::custom("invalid sequence length"))
8468        }
8469    }
8470}
8471
8472impl Serialize for GetTransactionStatusRequest {
8473    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8474        #[derive(Serialize)]
8475        struct AsObject<'a> {
8476            transaction_hash: Field0<'a>,
8477        }
8478
8479        #[serde_as]
8480        #[derive(Serialize)]
8481        #[serde(transparent)]
8482        struct Field0<'a> {
8483            #[serde_as(as = "UfeHex")]
8484            pub value: &'a Felt,
8485        }
8486
8487        AsObject::serialize(
8488            &AsObject {
8489                transaction_hash: Field0 {
8490                    value: &self.transaction_hash,
8491                },
8492            },
8493            serializer,
8494        )
8495    }
8496}
8497
8498impl Serialize for GetTransactionStatusRequestRef<'_> {
8499    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8500        #[derive(Serialize)]
8501        struct AsObject<'a> {
8502            transaction_hash: Field0<'a>,
8503        }
8504
8505        #[serde_as]
8506        #[derive(Serialize)]
8507        #[serde(transparent)]
8508        struct Field0<'a> {
8509            #[serde_as(as = "UfeHex")]
8510            pub value: &'a Felt,
8511        }
8512
8513        AsObject::serialize(
8514            &AsObject {
8515                transaction_hash: Field0 {
8516                    value: self.transaction_hash,
8517                },
8518            },
8519            serializer,
8520        )
8521    }
8522}
8523
8524impl<'de> Deserialize<'de> for GetTransactionStatusRequest {
8525    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8526        #[derive(Deserialize)]
8527        struct AsObject {
8528            transaction_hash: Field0,
8529        }
8530
8531        #[serde_as]
8532        #[derive(Deserialize)]
8533        #[serde(transparent)]
8534        struct Field0 {
8535            #[serde_as(as = "UfeHex")]
8536            pub value: Felt,
8537        }
8538
8539        let temp = serde_json::Value::deserialize(deserializer)?;
8540
8541        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
8542            let field0 = serde_json::from_value::<Field0>(
8543                elements
8544                    .pop()
8545                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8546            )
8547            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8548
8549            Ok(Self {
8550                transaction_hash: field0.value,
8551            })
8552        } else if let Ok(object) = AsObject::deserialize(&temp) {
8553            Ok(Self {
8554                transaction_hash: object.transaction_hash.value,
8555            })
8556        } else {
8557            Err(serde::de::Error::custom("invalid sequence length"))
8558        }
8559    }
8560}
8561
8562impl Serialize for SimulateTransactionsRequest {
8563    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8564        #[derive(Serialize)]
8565        struct AsObject<'a> {
8566            block_id: Field0<'a>,
8567            transactions: Field1<'a>,
8568            simulation_flags: Field2<'a>,
8569        }
8570
8571        #[derive(Serialize)]
8572        #[serde(transparent)]
8573        struct Field0<'a> {
8574            pub value: &'a BlockId,
8575        }
8576
8577        #[derive(Serialize)]
8578        #[serde(transparent)]
8579        struct Field1<'a> {
8580            pub value: &'a [BroadcastedTransaction],
8581        }
8582
8583        #[derive(Serialize)]
8584        #[serde(transparent)]
8585        struct Field2<'a> {
8586            pub value: &'a [SimulationFlag],
8587        }
8588
8589        AsObject::serialize(
8590            &AsObject {
8591                block_id: Field0 {
8592                    value: &self.block_id,
8593                },
8594                transactions: Field1 {
8595                    value: &self.transactions,
8596                },
8597                simulation_flags: Field2 {
8598                    value: &self.simulation_flags,
8599                },
8600            },
8601            serializer,
8602        )
8603    }
8604}
8605
8606impl Serialize for SimulateTransactionsRequestRef<'_> {
8607    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8608        #[derive(Serialize)]
8609        struct AsObject<'a> {
8610            block_id: Field0<'a>,
8611            transactions: Field1<'a>,
8612            simulation_flags: Field2<'a>,
8613        }
8614
8615        #[derive(Serialize)]
8616        #[serde(transparent)]
8617        struct Field0<'a> {
8618            pub value: &'a BlockId,
8619        }
8620
8621        #[derive(Serialize)]
8622        #[serde(transparent)]
8623        struct Field1<'a> {
8624            pub value: &'a [BroadcastedTransaction],
8625        }
8626
8627        #[derive(Serialize)]
8628        #[serde(transparent)]
8629        struct Field2<'a> {
8630            pub value: &'a [SimulationFlag],
8631        }
8632
8633        AsObject::serialize(
8634            &AsObject {
8635                block_id: Field0 {
8636                    value: self.block_id,
8637                },
8638                transactions: Field1 {
8639                    value: self.transactions,
8640                },
8641                simulation_flags: Field2 {
8642                    value: self.simulation_flags,
8643                },
8644            },
8645            serializer,
8646        )
8647    }
8648}
8649
8650impl<'de> Deserialize<'de> for SimulateTransactionsRequest {
8651    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8652        #[derive(Deserialize)]
8653        struct AsObject {
8654            block_id: Field0,
8655            transactions: Field1,
8656            simulation_flags: Field2,
8657        }
8658
8659        #[derive(Deserialize)]
8660        #[serde(transparent)]
8661        struct Field0 {
8662            pub value: BlockId,
8663        }
8664
8665        #[derive(Deserialize)]
8666        #[serde(transparent)]
8667        struct Field1 {
8668            pub value: Vec<BroadcastedTransaction>,
8669        }
8670
8671        #[derive(Deserialize)]
8672        #[serde(transparent)]
8673        struct Field2 {
8674            pub value: Vec<SimulationFlag>,
8675        }
8676
8677        let temp = serde_json::Value::deserialize(deserializer)?;
8678
8679        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
8680            let field2 = serde_json::from_value::<Field2>(
8681                elements
8682                    .pop()
8683                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8684            )
8685            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8686            let field1 = serde_json::from_value::<Field1>(
8687                elements
8688                    .pop()
8689                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8690            )
8691            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8692            let field0 = serde_json::from_value::<Field0>(
8693                elements
8694                    .pop()
8695                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
8696            )
8697            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
8698
8699            Ok(Self {
8700                block_id: field0.value,
8701                transactions: field1.value,
8702                simulation_flags: field2.value,
8703            })
8704        } else if let Ok(object) = AsObject::deserialize(&temp) {
8705            Ok(Self {
8706                block_id: object.block_id.value,
8707                transactions: object.transactions.value,
8708                simulation_flags: object.simulation_flags.value,
8709            })
8710        } else {
8711            Err(serde::de::Error::custom("invalid sequence length"))
8712        }
8713    }
8714}
8715
8716impl Serialize for SpecVersionRequest {
8717    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8718        use serde::ser::SerializeSeq;
8719
8720        let seq = serializer.serialize_seq(Some(0))?;
8721        seq.end()
8722    }
8723}
8724
8725impl<'de> Deserialize<'de> for SpecVersionRequest {
8726    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8727        let elements = Vec::<()>::deserialize(deserializer)?;
8728        if !elements.is_empty() {
8729            return Err(serde::de::Error::custom("invalid sequence length"));
8730        }
8731        Ok(Self)
8732    }
8733}
8734
8735impl Serialize for SubscribeEventsRequest {
8736    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8737        #[derive(Serialize)]
8738        struct AsObject<'a> {
8739            #[serde(skip_serializing_if = "Option::is_none")]
8740            from_address: Option<Field0<'a>>,
8741            #[serde(skip_serializing_if = "Option::is_none")]
8742            keys: Option<Field1<'a>>,
8743            #[serde(skip_serializing_if = "Option::is_none")]
8744            block_id: Option<Field2<'a>>,
8745            #[serde(skip_serializing_if = "Option::is_none")]
8746            finality_status: Option<Field3<'a>>,
8747        }
8748
8749        #[serde_as]
8750        #[derive(Serialize)]
8751        #[serde(transparent)]
8752        struct Field0<'a> {
8753            #[serde_as(as = "UfeHex")]
8754            pub value: &'a Felt,
8755        }
8756
8757        #[serde_as]
8758        #[derive(Serialize)]
8759        #[serde(transparent)]
8760        struct Field1<'a> {
8761            #[serde_as(as = "[Vec<UfeHex>]")]
8762            pub value: &'a [Vec<Felt>],
8763        }
8764
8765        #[derive(Serialize)]
8766        #[serde(transparent)]
8767        struct Field2<'a> {
8768            pub value: &'a ConfirmedBlockId,
8769        }
8770
8771        #[derive(Serialize)]
8772        #[serde(transparent)]
8773        struct Field3<'a> {
8774            pub value: &'a L2TransactionFinalityStatus,
8775        }
8776
8777        AsObject::serialize(
8778            &AsObject {
8779                from_address: self.from_address.as_ref().map(|f| Field0 { value: f }),
8780                keys: self.keys.as_ref().map(|f| Field1 { value: f }),
8781                block_id: self.block_id.as_ref().map(|f| Field2 { value: f }),
8782                finality_status: self.finality_status.as_ref().map(|f| Field3 { value: f }),
8783            },
8784            serializer,
8785        )
8786    }
8787}
8788
8789impl Serialize for SubscribeEventsRequestRef<'_> {
8790    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8791        #[derive(Serialize)]
8792        struct AsObject<'a> {
8793            #[serde(skip_serializing_if = "Option::is_none")]
8794            from_address: Option<Field0<'a>>,
8795            #[serde(skip_serializing_if = "Option::is_none")]
8796            keys: Option<Field1<'a>>,
8797            #[serde(skip_serializing_if = "Option::is_none")]
8798            block_id: Option<Field2<'a>>,
8799            #[serde(skip_serializing_if = "Option::is_none")]
8800            finality_status: Option<Field3<'a>>,
8801        }
8802
8803        #[serde_as]
8804        #[derive(Serialize)]
8805        #[serde(transparent)]
8806        struct Field0<'a> {
8807            #[serde_as(as = "UfeHex")]
8808            pub value: &'a Felt,
8809        }
8810
8811        #[serde_as]
8812        #[derive(Serialize)]
8813        #[serde(transparent)]
8814        struct Field1<'a> {
8815            #[serde_as(as = "[Vec<UfeHex>]")]
8816            pub value: &'a [Vec<Felt>],
8817        }
8818
8819        #[derive(Serialize)]
8820        #[serde(transparent)]
8821        struct Field2<'a> {
8822            pub value: &'a ConfirmedBlockId,
8823        }
8824
8825        #[derive(Serialize)]
8826        #[serde(transparent)]
8827        struct Field3<'a> {
8828            pub value: &'a L2TransactionFinalityStatus,
8829        }
8830
8831        AsObject::serialize(
8832            &AsObject {
8833                from_address: self.from_address.as_ref().map(|f| Field0 { value: f }),
8834                keys: self.keys.as_ref().map(|f| Field1 { value: f }),
8835                block_id: self.block_id.as_ref().map(|f| Field2 { value: f }),
8836                finality_status: self.finality_status.as_ref().map(|f| Field3 { value: f }),
8837            },
8838            serializer,
8839        )
8840    }
8841}
8842
8843impl<'de> Deserialize<'de> for SubscribeEventsRequest {
8844    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8845        #[derive(Deserialize)]
8846        struct AsObject {
8847            #[serde(skip_serializing_if = "Option::is_none")]
8848            from_address: Option<Field0>,
8849            #[serde(skip_serializing_if = "Option::is_none")]
8850            keys: Option<Field1>,
8851            #[serde(skip_serializing_if = "Option::is_none")]
8852            block_id: Option<Field2>,
8853            #[serde(skip_serializing_if = "Option::is_none")]
8854            finality_status: Option<Field3>,
8855        }
8856
8857        #[serde_as]
8858        #[derive(Deserialize)]
8859        #[serde(transparent)]
8860        struct Field0 {
8861            #[serde_as(as = "UfeHex")]
8862            pub value: Felt,
8863        }
8864
8865        #[serde_as]
8866        #[derive(Deserialize)]
8867        #[serde(transparent)]
8868        struct Field1 {
8869            #[serde_as(as = "Vec<Vec<UfeHex>>")]
8870            pub value: Vec<Vec<Felt>>,
8871        }
8872
8873        #[derive(Deserialize)]
8874        #[serde(transparent)]
8875        struct Field2 {
8876            pub value: ConfirmedBlockId,
8877        }
8878
8879        #[derive(Deserialize)]
8880        #[serde(transparent)]
8881        struct Field3 {
8882            pub value: L2TransactionFinalityStatus,
8883        }
8884
8885        let temp = serde_json::Value::deserialize(deserializer)?;
8886
8887        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
8888            let element_count = elements.len();
8889
8890            let field3 = if element_count > 3 {
8891                Some(
8892                    serde_json::from_value::<Field3>(elements.pop().unwrap()).map_err(|err| {
8893                        serde::de::Error::custom(format!("failed to parse element: {err}"))
8894                    })?,
8895                )
8896            } else {
8897                None
8898            };
8899            let field2 = if element_count > 2 {
8900                Some(
8901                    serde_json::from_value::<Field2>(elements.pop().unwrap()).map_err(|err| {
8902                        serde::de::Error::custom(format!("failed to parse element: {err}"))
8903                    })?,
8904                )
8905            } else {
8906                None
8907            };
8908            let field1 = if element_count > 1 {
8909                Some(
8910                    serde_json::from_value::<Field1>(elements.pop().unwrap()).map_err(|err| {
8911                        serde::de::Error::custom(format!("failed to parse element: {err}"))
8912                    })?,
8913                )
8914            } else {
8915                None
8916            };
8917            let field0 = if element_count > 0 {
8918                Some(
8919                    serde_json::from_value::<Field0>(elements.pop().unwrap()).map_err(|err| {
8920                        serde::de::Error::custom(format!("failed to parse element: {err}"))
8921                    })?,
8922                )
8923            } else {
8924                None
8925            };
8926
8927            Ok(Self {
8928                from_address: field0.map(|f| f.value),
8929                keys: field1.map(|f| f.value),
8930                block_id: field2.map(|f| f.value),
8931                finality_status: field3.map(|f| f.value),
8932            })
8933        } else if let Ok(object) = AsObject::deserialize(&temp) {
8934            Ok(Self {
8935                from_address: object.from_address.map(|f| f.value),
8936                keys: object.keys.map(|f| f.value),
8937                block_id: object.block_id.map(|f| f.value),
8938                finality_status: object.finality_status.map(|f| f.value),
8939            })
8940        } else {
8941            Err(serde::de::Error::custom("invalid sequence length"))
8942        }
8943    }
8944}
8945
8946impl Serialize for SubscribeNewHeadsRequest {
8947    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8948        #[derive(Serialize)]
8949        struct AsObject<'a> {
8950            #[serde(skip_serializing_if = "Option::is_none")]
8951            block_id: Option<Field0<'a>>,
8952        }
8953
8954        #[derive(Serialize)]
8955        #[serde(transparent)]
8956        struct Field0<'a> {
8957            pub value: &'a ConfirmedBlockId,
8958        }
8959
8960        AsObject::serialize(
8961            &AsObject {
8962                block_id: self.block_id.as_ref().map(|f| Field0 { value: f }),
8963            },
8964            serializer,
8965        )
8966    }
8967}
8968
8969impl Serialize for SubscribeNewHeadsRequestRef<'_> {
8970    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8971        #[derive(Serialize)]
8972        struct AsObject<'a> {
8973            #[serde(skip_serializing_if = "Option::is_none")]
8974            block_id: Option<Field0<'a>>,
8975        }
8976
8977        #[derive(Serialize)]
8978        #[serde(transparent)]
8979        struct Field0<'a> {
8980            pub value: &'a ConfirmedBlockId,
8981        }
8982
8983        AsObject::serialize(
8984            &AsObject {
8985                block_id: self.block_id.as_ref().map(|f| Field0 { value: f }),
8986            },
8987            serializer,
8988        )
8989    }
8990}
8991
8992impl<'de> Deserialize<'de> for SubscribeNewHeadsRequest {
8993    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8994        #[derive(Deserialize)]
8995        struct AsObject {
8996            #[serde(skip_serializing_if = "Option::is_none")]
8997            block_id: Option<Field0>,
8998        }
8999
9000        #[derive(Deserialize)]
9001        #[serde(transparent)]
9002        struct Field0 {
9003            pub value: ConfirmedBlockId,
9004        }
9005
9006        let temp = serde_json::Value::deserialize(deserializer)?;
9007
9008        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9009            let element_count = elements.len();
9010
9011            let field0 = if element_count > 0 {
9012                Some(
9013                    serde_json::from_value::<Field0>(elements.pop().unwrap()).map_err(|err| {
9014                        serde::de::Error::custom(format!("failed to parse element: {err}"))
9015                    })?,
9016                )
9017            } else {
9018                None
9019            };
9020
9021            Ok(Self {
9022                block_id: field0.map(|f| f.value),
9023            })
9024        } else if let Ok(object) = AsObject::deserialize(&temp) {
9025            Ok(Self {
9026                block_id: object.block_id.map(|f| f.value),
9027            })
9028        } else {
9029            Err(serde::de::Error::custom("invalid sequence length"))
9030        }
9031    }
9032}
9033
9034impl Serialize for SubscribeNewTransactionReceiptsRequest {
9035    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9036        #[derive(Serialize)]
9037        struct AsObject<'a> {
9038            #[serde(skip_serializing_if = "Option::is_none")]
9039            finality_status: Option<Field0<'a>>,
9040            #[serde(skip_serializing_if = "Option::is_none")]
9041            sender_address: Option<Field1<'a>>,
9042        }
9043
9044        #[derive(Serialize)]
9045        #[serde(transparent)]
9046        struct Field0<'a> {
9047            pub value: &'a [L2TransactionFinalityStatus],
9048        }
9049
9050        #[serde_as]
9051        #[derive(Serialize)]
9052        #[serde(transparent)]
9053        struct Field1<'a> {
9054            #[serde_as(as = "[UfeHex]")]
9055            pub value: &'a [Felt],
9056        }
9057
9058        AsObject::serialize(
9059            &AsObject {
9060                finality_status: self.finality_status.as_ref().map(|f| Field0 { value: f }),
9061                sender_address: self.sender_address.as_ref().map(|f| Field1 { value: f }),
9062            },
9063            serializer,
9064        )
9065    }
9066}
9067
9068impl Serialize for SubscribeNewTransactionReceiptsRequestRef<'_> {
9069    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9070        #[derive(Serialize)]
9071        struct AsObject<'a> {
9072            #[serde(skip_serializing_if = "Option::is_none")]
9073            finality_status: Option<Field0<'a>>,
9074            #[serde(skip_serializing_if = "Option::is_none")]
9075            sender_address: Option<Field1<'a>>,
9076        }
9077
9078        #[derive(Serialize)]
9079        #[serde(transparent)]
9080        struct Field0<'a> {
9081            pub value: &'a [L2TransactionFinalityStatus],
9082        }
9083
9084        #[serde_as]
9085        #[derive(Serialize)]
9086        #[serde(transparent)]
9087        struct Field1<'a> {
9088            #[serde_as(as = "[UfeHex]")]
9089            pub value: &'a [Felt],
9090        }
9091
9092        AsObject::serialize(
9093            &AsObject {
9094                finality_status: self.finality_status.as_ref().map(|f| Field0 { value: f }),
9095                sender_address: self.sender_address.as_ref().map(|f| Field1 { value: f }),
9096            },
9097            serializer,
9098        )
9099    }
9100}
9101
9102impl<'de> Deserialize<'de> for SubscribeNewTransactionReceiptsRequest {
9103    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9104        #[derive(Deserialize)]
9105        struct AsObject {
9106            #[serde(skip_serializing_if = "Option::is_none")]
9107            finality_status: Option<Field0>,
9108            #[serde(skip_serializing_if = "Option::is_none")]
9109            sender_address: Option<Field1>,
9110        }
9111
9112        #[derive(Deserialize)]
9113        #[serde(transparent)]
9114        struct Field0 {
9115            pub value: Vec<L2TransactionFinalityStatus>,
9116        }
9117
9118        #[serde_as]
9119        #[derive(Deserialize)]
9120        #[serde(transparent)]
9121        struct Field1 {
9122            #[serde_as(as = "Vec<UfeHex>")]
9123            pub value: Vec<Felt>,
9124        }
9125
9126        let temp = serde_json::Value::deserialize(deserializer)?;
9127
9128        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9129            let element_count = elements.len();
9130
9131            let field1 = if element_count > 1 {
9132                Some(
9133                    serde_json::from_value::<Field1>(elements.pop().unwrap()).map_err(|err| {
9134                        serde::de::Error::custom(format!("failed to parse element: {err}"))
9135                    })?,
9136                )
9137            } else {
9138                None
9139            };
9140            let field0 = if element_count > 0 {
9141                Some(
9142                    serde_json::from_value::<Field0>(elements.pop().unwrap()).map_err(|err| {
9143                        serde::de::Error::custom(format!("failed to parse element: {err}"))
9144                    })?,
9145                )
9146            } else {
9147                None
9148            };
9149
9150            Ok(Self {
9151                finality_status: field0.map(|f| f.value),
9152                sender_address: field1.map(|f| f.value),
9153            })
9154        } else if let Ok(object) = AsObject::deserialize(&temp) {
9155            Ok(Self {
9156                finality_status: object.finality_status.map(|f| f.value),
9157                sender_address: object.sender_address.map(|f| f.value),
9158            })
9159        } else {
9160            Err(serde::de::Error::custom("invalid sequence length"))
9161        }
9162    }
9163}
9164
9165impl Serialize for SubscribeNewTransactionsRequest {
9166    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9167        #[derive(Serialize)]
9168        struct AsObject<'a> {
9169            #[serde(skip_serializing_if = "Option::is_none")]
9170            finality_status: Option<Field0<'a>>,
9171            #[serde(skip_serializing_if = "Option::is_none")]
9172            sender_address: Option<Field1<'a>>,
9173        }
9174
9175        #[derive(Serialize)]
9176        #[serde(transparent)]
9177        struct Field0<'a> {
9178            pub value: &'a [L2TransactionStatus],
9179        }
9180
9181        #[serde_as]
9182        #[derive(Serialize)]
9183        #[serde(transparent)]
9184        struct Field1<'a> {
9185            #[serde_as(as = "[UfeHex]")]
9186            pub value: &'a [Felt],
9187        }
9188
9189        AsObject::serialize(
9190            &AsObject {
9191                finality_status: self.finality_status.as_ref().map(|f| Field0 { value: f }),
9192                sender_address: self.sender_address.as_ref().map(|f| Field1 { value: f }),
9193            },
9194            serializer,
9195        )
9196    }
9197}
9198
9199impl Serialize for SubscribeNewTransactionsRequestRef<'_> {
9200    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9201        #[derive(Serialize)]
9202        struct AsObject<'a> {
9203            #[serde(skip_serializing_if = "Option::is_none")]
9204            finality_status: Option<Field0<'a>>,
9205            #[serde(skip_serializing_if = "Option::is_none")]
9206            sender_address: Option<Field1<'a>>,
9207        }
9208
9209        #[derive(Serialize)]
9210        #[serde(transparent)]
9211        struct Field0<'a> {
9212            pub value: &'a [L2TransactionStatus],
9213        }
9214
9215        #[serde_as]
9216        #[derive(Serialize)]
9217        #[serde(transparent)]
9218        struct Field1<'a> {
9219            #[serde_as(as = "[UfeHex]")]
9220            pub value: &'a [Felt],
9221        }
9222
9223        AsObject::serialize(
9224            &AsObject {
9225                finality_status: self.finality_status.as_ref().map(|f| Field0 { value: f }),
9226                sender_address: self.sender_address.as_ref().map(|f| Field1 { value: f }),
9227            },
9228            serializer,
9229        )
9230    }
9231}
9232
9233impl<'de> Deserialize<'de> for SubscribeNewTransactionsRequest {
9234    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9235        #[derive(Deserialize)]
9236        struct AsObject {
9237            #[serde(skip_serializing_if = "Option::is_none")]
9238            finality_status: Option<Field0>,
9239            #[serde(skip_serializing_if = "Option::is_none")]
9240            sender_address: Option<Field1>,
9241        }
9242
9243        #[derive(Deserialize)]
9244        #[serde(transparent)]
9245        struct Field0 {
9246            pub value: Vec<L2TransactionStatus>,
9247        }
9248
9249        #[serde_as]
9250        #[derive(Deserialize)]
9251        #[serde(transparent)]
9252        struct Field1 {
9253            #[serde_as(as = "Vec<UfeHex>")]
9254            pub value: Vec<Felt>,
9255        }
9256
9257        let temp = serde_json::Value::deserialize(deserializer)?;
9258
9259        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9260            let element_count = elements.len();
9261
9262            let field1 = if element_count > 1 {
9263                Some(
9264                    serde_json::from_value::<Field1>(elements.pop().unwrap()).map_err(|err| {
9265                        serde::de::Error::custom(format!("failed to parse element: {err}"))
9266                    })?,
9267                )
9268            } else {
9269                None
9270            };
9271            let field0 = if element_count > 0 {
9272                Some(
9273                    serde_json::from_value::<Field0>(elements.pop().unwrap()).map_err(|err| {
9274                        serde::de::Error::custom(format!("failed to parse element: {err}"))
9275                    })?,
9276                )
9277            } else {
9278                None
9279            };
9280
9281            Ok(Self {
9282                finality_status: field0.map(|f| f.value),
9283                sender_address: field1.map(|f| f.value),
9284            })
9285        } else if let Ok(object) = AsObject::deserialize(&temp) {
9286            Ok(Self {
9287                finality_status: object.finality_status.map(|f| f.value),
9288                sender_address: object.sender_address.map(|f| f.value),
9289            })
9290        } else {
9291            Err(serde::de::Error::custom("invalid sequence length"))
9292        }
9293    }
9294}
9295
9296impl Serialize for SubscribeTransactionStatusRequest {
9297    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9298        #[derive(Serialize)]
9299        struct AsObject<'a> {
9300            transaction_hash: Field0<'a>,
9301        }
9302
9303        #[serde_as]
9304        #[derive(Serialize)]
9305        #[serde(transparent)]
9306        struct Field0<'a> {
9307            #[serde_as(as = "UfeHex")]
9308            pub value: &'a Felt,
9309        }
9310
9311        AsObject::serialize(
9312            &AsObject {
9313                transaction_hash: Field0 {
9314                    value: &self.transaction_hash,
9315                },
9316            },
9317            serializer,
9318        )
9319    }
9320}
9321
9322impl Serialize for SubscribeTransactionStatusRequestRef<'_> {
9323    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9324        #[derive(Serialize)]
9325        struct AsObject<'a> {
9326            transaction_hash: Field0<'a>,
9327        }
9328
9329        #[serde_as]
9330        #[derive(Serialize)]
9331        #[serde(transparent)]
9332        struct Field0<'a> {
9333            #[serde_as(as = "UfeHex")]
9334            pub value: &'a Felt,
9335        }
9336
9337        AsObject::serialize(
9338            &AsObject {
9339                transaction_hash: Field0 {
9340                    value: self.transaction_hash,
9341                },
9342            },
9343            serializer,
9344        )
9345    }
9346}
9347
9348impl<'de> Deserialize<'de> for SubscribeTransactionStatusRequest {
9349    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9350        #[derive(Deserialize)]
9351        struct AsObject {
9352            transaction_hash: Field0,
9353        }
9354
9355        #[serde_as]
9356        #[derive(Deserialize)]
9357        #[serde(transparent)]
9358        struct Field0 {
9359            #[serde_as(as = "UfeHex")]
9360            pub value: Felt,
9361        }
9362
9363        let temp = serde_json::Value::deserialize(deserializer)?;
9364
9365        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9366            let field0 = serde_json::from_value::<Field0>(
9367                elements
9368                    .pop()
9369                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9370            )
9371            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9372
9373            Ok(Self {
9374                transaction_hash: field0.value,
9375            })
9376        } else if let Ok(object) = AsObject::deserialize(&temp) {
9377            Ok(Self {
9378                transaction_hash: object.transaction_hash.value,
9379            })
9380        } else {
9381            Err(serde::de::Error::custom("invalid sequence length"))
9382        }
9383    }
9384}
9385
9386impl Serialize for SubscriptionEventsRequest {
9387    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9388        #[derive(Serialize)]
9389        struct AsObject<'a> {
9390            subscription_id: Field0<'a>,
9391            result: Field1<'a>,
9392        }
9393
9394        #[derive(Serialize)]
9395        #[serde(transparent)]
9396        struct Field0<'a> {
9397            pub value: &'a SubscriptionId,
9398        }
9399
9400        #[derive(Serialize)]
9401        #[serde(transparent)]
9402        struct Field1<'a> {
9403            pub value: &'a EmittedEventWithFinality,
9404        }
9405
9406        AsObject::serialize(
9407            &AsObject {
9408                subscription_id: Field0 {
9409                    value: &self.subscription_id,
9410                },
9411                result: Field1 {
9412                    value: &self.result,
9413                },
9414            },
9415            serializer,
9416        )
9417    }
9418}
9419
9420impl Serialize for SubscriptionEventsRequestRef<'_> {
9421    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9422        #[derive(Serialize)]
9423        struct AsObject<'a> {
9424            subscription_id: Field0<'a>,
9425            result: Field1<'a>,
9426        }
9427
9428        #[derive(Serialize)]
9429        #[serde(transparent)]
9430        struct Field0<'a> {
9431            pub value: &'a SubscriptionId,
9432        }
9433
9434        #[derive(Serialize)]
9435        #[serde(transparent)]
9436        struct Field1<'a> {
9437            pub value: &'a EmittedEventWithFinality,
9438        }
9439
9440        AsObject::serialize(
9441            &AsObject {
9442                subscription_id: Field0 {
9443                    value: self.subscription_id,
9444                },
9445                result: Field1 { value: self.result },
9446            },
9447            serializer,
9448        )
9449    }
9450}
9451
9452impl<'de> Deserialize<'de> for SubscriptionEventsRequest {
9453    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9454        #[derive(Deserialize)]
9455        struct AsObject {
9456            subscription_id: Field0,
9457            result: Field1,
9458        }
9459
9460        #[derive(Deserialize)]
9461        #[serde(transparent)]
9462        struct Field0 {
9463            pub value: SubscriptionId,
9464        }
9465
9466        #[derive(Deserialize)]
9467        #[serde(transparent)]
9468        struct Field1 {
9469            pub value: EmittedEventWithFinality,
9470        }
9471
9472        let temp = serde_json::Value::deserialize(deserializer)?;
9473
9474        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9475            let field1 = serde_json::from_value::<Field1>(
9476                elements
9477                    .pop()
9478                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9479            )
9480            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9481            let field0 = serde_json::from_value::<Field0>(
9482                elements
9483                    .pop()
9484                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9485            )
9486            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9487
9488            Ok(Self {
9489                subscription_id: field0.value,
9490                result: field1.value,
9491            })
9492        } else if let Ok(object) = AsObject::deserialize(&temp) {
9493            Ok(Self {
9494                subscription_id: object.subscription_id.value,
9495                result: object.result.value,
9496            })
9497        } else {
9498            Err(serde::de::Error::custom("invalid sequence length"))
9499        }
9500    }
9501}
9502
9503impl Serialize for SubscriptionNewHeadsRequest {
9504    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9505        #[derive(Serialize)]
9506        struct AsObject<'a> {
9507            subscription_id: Field0<'a>,
9508            result: Field1<'a>,
9509        }
9510
9511        #[derive(Serialize)]
9512        #[serde(transparent)]
9513        struct Field0<'a> {
9514            pub value: &'a SubscriptionId,
9515        }
9516
9517        #[derive(Serialize)]
9518        #[serde(transparent)]
9519        struct Field1<'a> {
9520            pub value: &'a BlockHeader,
9521        }
9522
9523        AsObject::serialize(
9524            &AsObject {
9525                subscription_id: Field0 {
9526                    value: &self.subscription_id,
9527                },
9528                result: Field1 {
9529                    value: &self.result,
9530                },
9531            },
9532            serializer,
9533        )
9534    }
9535}
9536
9537impl Serialize for SubscriptionNewHeadsRequestRef<'_> {
9538    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9539        #[derive(Serialize)]
9540        struct AsObject<'a> {
9541            subscription_id: Field0<'a>,
9542            result: Field1<'a>,
9543        }
9544
9545        #[derive(Serialize)]
9546        #[serde(transparent)]
9547        struct Field0<'a> {
9548            pub value: &'a SubscriptionId,
9549        }
9550
9551        #[derive(Serialize)]
9552        #[serde(transparent)]
9553        struct Field1<'a> {
9554            pub value: &'a BlockHeader,
9555        }
9556
9557        AsObject::serialize(
9558            &AsObject {
9559                subscription_id: Field0 {
9560                    value: self.subscription_id,
9561                },
9562                result: Field1 { value: self.result },
9563            },
9564            serializer,
9565        )
9566    }
9567}
9568
9569impl<'de> Deserialize<'de> for SubscriptionNewHeadsRequest {
9570    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9571        #[derive(Deserialize)]
9572        struct AsObject {
9573            subscription_id: Field0,
9574            result: Field1,
9575        }
9576
9577        #[derive(Deserialize)]
9578        #[serde(transparent)]
9579        struct Field0 {
9580            pub value: SubscriptionId,
9581        }
9582
9583        #[derive(Deserialize)]
9584        #[serde(transparent)]
9585        struct Field1 {
9586            pub value: BlockHeader,
9587        }
9588
9589        let temp = serde_json::Value::deserialize(deserializer)?;
9590
9591        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9592            let field1 = serde_json::from_value::<Field1>(
9593                elements
9594                    .pop()
9595                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9596            )
9597            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9598            let field0 = serde_json::from_value::<Field0>(
9599                elements
9600                    .pop()
9601                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9602            )
9603            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9604
9605            Ok(Self {
9606                subscription_id: field0.value,
9607                result: field1.value,
9608            })
9609        } else if let Ok(object) = AsObject::deserialize(&temp) {
9610            Ok(Self {
9611                subscription_id: object.subscription_id.value,
9612                result: object.result.value,
9613            })
9614        } else {
9615            Err(serde::de::Error::custom("invalid sequence length"))
9616        }
9617    }
9618}
9619
9620impl Serialize for SubscriptionNewTransactionReceiptsRequest {
9621    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9622        #[derive(Serialize)]
9623        struct AsObject<'a> {
9624            subscription_id: Field0<'a>,
9625            result: Field1<'a>,
9626        }
9627
9628        #[derive(Serialize)]
9629        #[serde(transparent)]
9630        struct Field0<'a> {
9631            pub value: &'a SubscriptionId,
9632        }
9633
9634        #[derive(Serialize)]
9635        #[serde(transparent)]
9636        struct Field1<'a> {
9637            pub value: &'a TransactionReceiptWithBlockInfo,
9638        }
9639
9640        AsObject::serialize(
9641            &AsObject {
9642                subscription_id: Field0 {
9643                    value: &self.subscription_id,
9644                },
9645                result: Field1 {
9646                    value: &self.result,
9647                },
9648            },
9649            serializer,
9650        )
9651    }
9652}
9653
9654impl Serialize for SubscriptionNewTransactionReceiptsRequestRef<'_> {
9655    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9656        #[derive(Serialize)]
9657        struct AsObject<'a> {
9658            subscription_id: Field0<'a>,
9659            result: Field1<'a>,
9660        }
9661
9662        #[derive(Serialize)]
9663        #[serde(transparent)]
9664        struct Field0<'a> {
9665            pub value: &'a SubscriptionId,
9666        }
9667
9668        #[derive(Serialize)]
9669        #[serde(transparent)]
9670        struct Field1<'a> {
9671            pub value: &'a TransactionReceiptWithBlockInfo,
9672        }
9673
9674        AsObject::serialize(
9675            &AsObject {
9676                subscription_id: Field0 {
9677                    value: self.subscription_id,
9678                },
9679                result: Field1 { value: self.result },
9680            },
9681            serializer,
9682        )
9683    }
9684}
9685
9686impl<'de> Deserialize<'de> for SubscriptionNewTransactionReceiptsRequest {
9687    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9688        #[derive(Deserialize)]
9689        struct AsObject {
9690            subscription_id: Field0,
9691            result: Field1,
9692        }
9693
9694        #[derive(Deserialize)]
9695        #[serde(transparent)]
9696        struct Field0 {
9697            pub value: SubscriptionId,
9698        }
9699
9700        #[derive(Deserialize)]
9701        #[serde(transparent)]
9702        struct Field1 {
9703            pub value: TransactionReceiptWithBlockInfo,
9704        }
9705
9706        let temp = serde_json::Value::deserialize(deserializer)?;
9707
9708        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9709            let field1 = serde_json::from_value::<Field1>(
9710                elements
9711                    .pop()
9712                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9713            )
9714            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9715            let field0 = serde_json::from_value::<Field0>(
9716                elements
9717                    .pop()
9718                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9719            )
9720            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9721
9722            Ok(Self {
9723                subscription_id: field0.value,
9724                result: field1.value,
9725            })
9726        } else if let Ok(object) = AsObject::deserialize(&temp) {
9727            Ok(Self {
9728                subscription_id: object.subscription_id.value,
9729                result: object.result.value,
9730            })
9731        } else {
9732            Err(serde::de::Error::custom("invalid sequence length"))
9733        }
9734    }
9735}
9736
9737impl Serialize for SubscriptionNewTransactionRequest {
9738    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9739        #[derive(Serialize)]
9740        struct AsObject<'a> {
9741            subscription_id: Field0<'a>,
9742            result: Field1<'a>,
9743        }
9744
9745        #[derive(Serialize)]
9746        #[serde(transparent)]
9747        struct Field0<'a> {
9748            pub value: &'a SubscriptionId,
9749        }
9750
9751        #[derive(Serialize)]
9752        #[serde(transparent)]
9753        struct Field1<'a> {
9754            pub value: &'a TransactionWithL2Status,
9755        }
9756
9757        AsObject::serialize(
9758            &AsObject {
9759                subscription_id: Field0 {
9760                    value: &self.subscription_id,
9761                },
9762                result: Field1 {
9763                    value: &self.result,
9764                },
9765            },
9766            serializer,
9767        )
9768    }
9769}
9770
9771impl Serialize for SubscriptionNewTransactionRequestRef<'_> {
9772    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9773        #[derive(Serialize)]
9774        struct AsObject<'a> {
9775            subscription_id: Field0<'a>,
9776            result: Field1<'a>,
9777        }
9778
9779        #[derive(Serialize)]
9780        #[serde(transparent)]
9781        struct Field0<'a> {
9782            pub value: &'a SubscriptionId,
9783        }
9784
9785        #[derive(Serialize)]
9786        #[serde(transparent)]
9787        struct Field1<'a> {
9788            pub value: &'a TransactionWithL2Status,
9789        }
9790
9791        AsObject::serialize(
9792            &AsObject {
9793                subscription_id: Field0 {
9794                    value: self.subscription_id,
9795                },
9796                result: Field1 { value: self.result },
9797            },
9798            serializer,
9799        )
9800    }
9801}
9802
9803impl<'de> Deserialize<'de> for SubscriptionNewTransactionRequest {
9804    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9805        #[derive(Deserialize)]
9806        struct AsObject {
9807            subscription_id: Field0,
9808            result: Field1,
9809        }
9810
9811        #[derive(Deserialize)]
9812        #[serde(transparent)]
9813        struct Field0 {
9814            pub value: SubscriptionId,
9815        }
9816
9817        #[derive(Deserialize)]
9818        #[serde(transparent)]
9819        struct Field1 {
9820            pub value: TransactionWithL2Status,
9821        }
9822
9823        let temp = serde_json::Value::deserialize(deserializer)?;
9824
9825        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9826            let field1 = serde_json::from_value::<Field1>(
9827                elements
9828                    .pop()
9829                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9830            )
9831            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9832            let field0 = serde_json::from_value::<Field0>(
9833                elements
9834                    .pop()
9835                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9836            )
9837            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9838
9839            Ok(Self {
9840                subscription_id: field0.value,
9841                result: field1.value,
9842            })
9843        } else if let Ok(object) = AsObject::deserialize(&temp) {
9844            Ok(Self {
9845                subscription_id: object.subscription_id.value,
9846                result: object.result.value,
9847            })
9848        } else {
9849            Err(serde::de::Error::custom("invalid sequence length"))
9850        }
9851    }
9852}
9853
9854impl Serialize for SubscriptionReorgRequest {
9855    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9856        #[derive(Serialize)]
9857        struct AsObject<'a> {
9858            subscription_id: Field0<'a>,
9859            result: Field1<'a>,
9860        }
9861
9862        #[derive(Serialize)]
9863        #[serde(transparent)]
9864        struct Field0<'a> {
9865            pub value: &'a SubscriptionId,
9866        }
9867
9868        #[derive(Serialize)]
9869        #[serde(transparent)]
9870        struct Field1<'a> {
9871            pub value: &'a ReorgData,
9872        }
9873
9874        AsObject::serialize(
9875            &AsObject {
9876                subscription_id: Field0 {
9877                    value: &self.subscription_id,
9878                },
9879                result: Field1 {
9880                    value: &self.result,
9881                },
9882            },
9883            serializer,
9884        )
9885    }
9886}
9887
9888impl Serialize for SubscriptionReorgRequestRef<'_> {
9889    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9890        #[derive(Serialize)]
9891        struct AsObject<'a> {
9892            subscription_id: Field0<'a>,
9893            result: Field1<'a>,
9894        }
9895
9896        #[derive(Serialize)]
9897        #[serde(transparent)]
9898        struct Field0<'a> {
9899            pub value: &'a SubscriptionId,
9900        }
9901
9902        #[derive(Serialize)]
9903        #[serde(transparent)]
9904        struct Field1<'a> {
9905            pub value: &'a ReorgData,
9906        }
9907
9908        AsObject::serialize(
9909            &AsObject {
9910                subscription_id: Field0 {
9911                    value: self.subscription_id,
9912                },
9913                result: Field1 { value: self.result },
9914            },
9915            serializer,
9916        )
9917    }
9918}
9919
9920impl<'de> Deserialize<'de> for SubscriptionReorgRequest {
9921    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9922        #[derive(Deserialize)]
9923        struct AsObject {
9924            subscription_id: Field0,
9925            result: Field1,
9926        }
9927
9928        #[derive(Deserialize)]
9929        #[serde(transparent)]
9930        struct Field0 {
9931            pub value: SubscriptionId,
9932        }
9933
9934        #[derive(Deserialize)]
9935        #[serde(transparent)]
9936        struct Field1 {
9937            pub value: ReorgData,
9938        }
9939
9940        let temp = serde_json::Value::deserialize(deserializer)?;
9941
9942        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
9943            let field1 = serde_json::from_value::<Field1>(
9944                elements
9945                    .pop()
9946                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9947            )
9948            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9949            let field0 = serde_json::from_value::<Field0>(
9950                elements
9951                    .pop()
9952                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
9953            )
9954            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
9955
9956            Ok(Self {
9957                subscription_id: field0.value,
9958                result: field1.value,
9959            })
9960        } else if let Ok(object) = AsObject::deserialize(&temp) {
9961            Ok(Self {
9962                subscription_id: object.subscription_id.value,
9963                result: object.result.value,
9964            })
9965        } else {
9966            Err(serde::de::Error::custom("invalid sequence length"))
9967        }
9968    }
9969}
9970
9971impl Serialize for SubscriptionTransactionStatusRequest {
9972    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9973        #[derive(Serialize)]
9974        struct AsObject<'a> {
9975            subscription_id: Field0<'a>,
9976            result: Field1<'a>,
9977        }
9978
9979        #[derive(Serialize)]
9980        #[serde(transparent)]
9981        struct Field0<'a> {
9982            pub value: &'a SubscriptionId,
9983        }
9984
9985        #[derive(Serialize)]
9986        #[serde(transparent)]
9987        struct Field1<'a> {
9988            pub value: &'a NewTransactionStatus,
9989        }
9990
9991        AsObject::serialize(
9992            &AsObject {
9993                subscription_id: Field0 {
9994                    value: &self.subscription_id,
9995                },
9996                result: Field1 {
9997                    value: &self.result,
9998                },
9999            },
10000            serializer,
10001        )
10002    }
10003}
10004
10005impl Serialize for SubscriptionTransactionStatusRequestRef<'_> {
10006    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10007        #[derive(Serialize)]
10008        struct AsObject<'a> {
10009            subscription_id: Field0<'a>,
10010            result: Field1<'a>,
10011        }
10012
10013        #[derive(Serialize)]
10014        #[serde(transparent)]
10015        struct Field0<'a> {
10016            pub value: &'a SubscriptionId,
10017        }
10018
10019        #[derive(Serialize)]
10020        #[serde(transparent)]
10021        struct Field1<'a> {
10022            pub value: &'a NewTransactionStatus,
10023        }
10024
10025        AsObject::serialize(
10026            &AsObject {
10027                subscription_id: Field0 {
10028                    value: self.subscription_id,
10029                },
10030                result: Field1 { value: self.result },
10031            },
10032            serializer,
10033        )
10034    }
10035}
10036
10037impl<'de> Deserialize<'de> for SubscriptionTransactionStatusRequest {
10038    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10039        #[derive(Deserialize)]
10040        struct AsObject {
10041            subscription_id: Field0,
10042            result: Field1,
10043        }
10044
10045        #[derive(Deserialize)]
10046        #[serde(transparent)]
10047        struct Field0 {
10048            pub value: SubscriptionId,
10049        }
10050
10051        #[derive(Deserialize)]
10052        #[serde(transparent)]
10053        struct Field1 {
10054            pub value: NewTransactionStatus,
10055        }
10056
10057        let temp = serde_json::Value::deserialize(deserializer)?;
10058
10059        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
10060            let field1 = serde_json::from_value::<Field1>(
10061                elements
10062                    .pop()
10063                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
10064            )
10065            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
10066            let field0 = serde_json::from_value::<Field0>(
10067                elements
10068                    .pop()
10069                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
10070            )
10071            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
10072
10073            Ok(Self {
10074                subscription_id: field0.value,
10075                result: field1.value,
10076            })
10077        } else if let Ok(object) = AsObject::deserialize(&temp) {
10078            Ok(Self {
10079                subscription_id: object.subscription_id.value,
10080                result: object.result.value,
10081            })
10082        } else {
10083            Err(serde::de::Error::custom("invalid sequence length"))
10084        }
10085    }
10086}
10087
10088impl Serialize for SyncingRequest {
10089    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10090        use serde::ser::SerializeSeq;
10091
10092        let seq = serializer.serialize_seq(Some(0))?;
10093        seq.end()
10094    }
10095}
10096
10097impl<'de> Deserialize<'de> for SyncingRequest {
10098    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10099        let elements = Vec::<()>::deserialize(deserializer)?;
10100        if !elements.is_empty() {
10101            return Err(serde::de::Error::custom("invalid sequence length"));
10102        }
10103        Ok(Self)
10104    }
10105}
10106
10107impl Serialize for TraceBlockTransactionsRequest {
10108    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10109        #[derive(Serialize)]
10110        struct AsObject<'a> {
10111            block_id: Field0<'a>,
10112        }
10113
10114        #[derive(Serialize)]
10115        #[serde(transparent)]
10116        struct Field0<'a> {
10117            pub value: &'a ConfirmedBlockId,
10118        }
10119
10120        AsObject::serialize(
10121            &AsObject {
10122                block_id: Field0 {
10123                    value: &self.block_id,
10124                },
10125            },
10126            serializer,
10127        )
10128    }
10129}
10130
10131impl Serialize for TraceBlockTransactionsRequestRef<'_> {
10132    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10133        #[derive(Serialize)]
10134        struct AsObject<'a> {
10135            block_id: Field0<'a>,
10136        }
10137
10138        #[derive(Serialize)]
10139        #[serde(transparent)]
10140        struct Field0<'a> {
10141            pub value: &'a ConfirmedBlockId,
10142        }
10143
10144        AsObject::serialize(
10145            &AsObject {
10146                block_id: Field0 {
10147                    value: self.block_id,
10148                },
10149            },
10150            serializer,
10151        )
10152    }
10153}
10154
10155impl<'de> Deserialize<'de> for TraceBlockTransactionsRequest {
10156    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10157        #[derive(Deserialize)]
10158        struct AsObject {
10159            block_id: Field0,
10160        }
10161
10162        #[derive(Deserialize)]
10163        #[serde(transparent)]
10164        struct Field0 {
10165            pub value: ConfirmedBlockId,
10166        }
10167
10168        let temp = serde_json::Value::deserialize(deserializer)?;
10169
10170        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
10171            let field0 = serde_json::from_value::<Field0>(
10172                elements
10173                    .pop()
10174                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
10175            )
10176            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
10177
10178            Ok(Self {
10179                block_id: field0.value,
10180            })
10181        } else if let Ok(object) = AsObject::deserialize(&temp) {
10182            Ok(Self {
10183                block_id: object.block_id.value,
10184            })
10185        } else {
10186            Err(serde::de::Error::custom("invalid sequence length"))
10187        }
10188    }
10189}
10190
10191impl Serialize for TraceTransactionRequest {
10192    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10193        #[derive(Serialize)]
10194        struct AsObject<'a> {
10195            transaction_hash: Field0<'a>,
10196        }
10197
10198        #[serde_as]
10199        #[derive(Serialize)]
10200        #[serde(transparent)]
10201        struct Field0<'a> {
10202            #[serde_as(as = "UfeHex")]
10203            pub value: &'a Felt,
10204        }
10205
10206        AsObject::serialize(
10207            &AsObject {
10208                transaction_hash: Field0 {
10209                    value: &self.transaction_hash,
10210                },
10211            },
10212            serializer,
10213        )
10214    }
10215}
10216
10217impl Serialize for TraceTransactionRequestRef<'_> {
10218    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10219        #[derive(Serialize)]
10220        struct AsObject<'a> {
10221            transaction_hash: Field0<'a>,
10222        }
10223
10224        #[serde_as]
10225        #[derive(Serialize)]
10226        #[serde(transparent)]
10227        struct Field0<'a> {
10228            #[serde_as(as = "UfeHex")]
10229            pub value: &'a Felt,
10230        }
10231
10232        AsObject::serialize(
10233            &AsObject {
10234                transaction_hash: Field0 {
10235                    value: self.transaction_hash,
10236                },
10237            },
10238            serializer,
10239        )
10240    }
10241}
10242
10243impl<'de> Deserialize<'de> for TraceTransactionRequest {
10244    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10245        #[derive(Deserialize)]
10246        struct AsObject {
10247            transaction_hash: Field0,
10248        }
10249
10250        #[serde_as]
10251        #[derive(Deserialize)]
10252        #[serde(transparent)]
10253        struct Field0 {
10254            #[serde_as(as = "UfeHex")]
10255            pub value: Felt,
10256        }
10257
10258        let temp = serde_json::Value::deserialize(deserializer)?;
10259
10260        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
10261            let field0 = serde_json::from_value::<Field0>(
10262                elements
10263                    .pop()
10264                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
10265            )
10266            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
10267
10268            Ok(Self {
10269                transaction_hash: field0.value,
10270            })
10271        } else if let Ok(object) = AsObject::deserialize(&temp) {
10272            Ok(Self {
10273                transaction_hash: object.transaction_hash.value,
10274            })
10275        } else {
10276            Err(serde::de::Error::custom("invalid sequence length"))
10277        }
10278    }
10279}
10280
10281impl Serialize for UnsubscribeRequest {
10282    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10283        #[derive(Serialize)]
10284        struct AsObject<'a> {
10285            subscription_id: Field0<'a>,
10286        }
10287
10288        #[derive(Serialize)]
10289        #[serde(transparent)]
10290        struct Field0<'a> {
10291            pub value: &'a SubscriptionId,
10292        }
10293
10294        AsObject::serialize(
10295            &AsObject {
10296                subscription_id: Field0 {
10297                    value: &self.subscription_id,
10298                },
10299            },
10300            serializer,
10301        )
10302    }
10303}
10304
10305impl Serialize for UnsubscribeRequestRef<'_> {
10306    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10307        #[derive(Serialize)]
10308        struct AsObject<'a> {
10309            subscription_id: Field0<'a>,
10310        }
10311
10312        #[derive(Serialize)]
10313        #[serde(transparent)]
10314        struct Field0<'a> {
10315            pub value: &'a SubscriptionId,
10316        }
10317
10318        AsObject::serialize(
10319            &AsObject {
10320                subscription_id: Field0 {
10321                    value: self.subscription_id,
10322                },
10323            },
10324            serializer,
10325        )
10326    }
10327}
10328
10329impl<'de> Deserialize<'de> for UnsubscribeRequest {
10330    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10331        #[derive(Deserialize)]
10332        struct AsObject {
10333            subscription_id: Field0,
10334        }
10335
10336        #[derive(Deserialize)]
10337        #[serde(transparent)]
10338        struct Field0 {
10339            pub value: SubscriptionId,
10340        }
10341
10342        let temp = serde_json::Value::deserialize(deserializer)?;
10343
10344        if let Ok(mut elements) = Vec::<serde_json::Value>::deserialize(&temp) {
10345            let field0 = serde_json::from_value::<Field0>(
10346                elements
10347                    .pop()
10348                    .ok_or_else(|| serde::de::Error::custom("invalid sequence length"))?,
10349            )
10350            .map_err(|err| serde::de::Error::custom(format!("failed to parse element: {err}")))?;
10351
10352            Ok(Self {
10353                subscription_id: field0.value,
10354            })
10355        } else if let Ok(object) = AsObject::deserialize(&temp) {
10356            Ok(Self {
10357                subscription_id: object.subscription_id.value,
10358            })
10359        } else {
10360            Err(serde::de::Error::custom("invalid sequence length"))
10361        }
10362    }
10363}