From dfeea2c58a1ea5b69c55b249d1fe501c5c2a34de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kami=C5=84ski?= Date: Wed, 3 Jul 2024 15:18:20 +0200 Subject: [PATCH] add V3 transaction variants, generate with updated openrpc --- .../starknet-types-rpc/src/custom/block_id.rs | 24 +- crates/starknet-types-rpc/src/custom/query.rs | 25 +- .../src/custom/syncing_status.rs | 6 +- crates/starknet-types-rpc/src/lib.rs | 1 + crates/starknet-types-rpc/src/v0_7_1/mod.rs | 3 - .../src/v0_7_1/starknet_api_openrpc.rs | 335 ++++++++++-------- .../src/v0_7_1/starknet_api_openrpc.toml | 6 +- .../src/v0_7_1/starknet_trace_api_openrpc.rs | 60 ++-- .../v0_7_1/starknet_trace_api_openrpc.toml | 5 +- .../src/v0_7_1/starknet_write_api.rs | 33 +- .../src/v0_7_1/starknet_write_api.toml | 5 +- 11 files changed, 283 insertions(+), 220 deletions(-) diff --git a/crates/starknet-types-rpc/src/custom/block_id.rs b/crates/starknet-types-rpc/src/custom/block_id.rs index 3cd469ba..632fc115 100644 --- a/crates/starknet-types-rpc/src/custom/block_id.rs +++ b/crates/starknet-types-rpc/src/custom/block_id.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use crate::{BlockHash, BlockNumber, BlockTag}; /// A hexadecimal number. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Eq, Hash, PartialEq)] pub enum BlockId { /// The tag of the block. Tag(BlockTag), @@ -31,19 +31,19 @@ enum BlockIdHelper { Number(BlockNumberHelper), } -impl serde::Serialize for BlockId { +impl serde::Serialize for BlockId { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { - match *self { + match self { BlockId::Tag(tag) => tag.serialize(serializer), BlockId::Hash(block_hash) => { let helper = BlockHashHelper { block_hash }; helper.serialize(serializer) } BlockId::Number(block_number) => { - let helper = BlockNumberHelper { block_number }; + let helper = BlockNumberHelper { block_number: *block_number }; helper.serialize(serializer) } } @@ -66,7 +66,7 @@ impl<'de, F: Deserialize<'de>> serde::Deserialize<'de> for BlockId { #[test] fn block_id_from_hash() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let s = "{\"block_hash\":\"0x123\"}"; let block_id: BlockId = serde_json::from_str(s).unwrap(); @@ -75,7 +75,7 @@ fn block_id_from_hash() { #[test] fn block_id_from_number() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let s = "{\"block_number\":123}"; let block_id: BlockId = serde_json::from_str(s).unwrap(); @@ -84,7 +84,7 @@ fn block_id_from_number() { #[test] fn block_id_from_latest() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let s = "\"latest\""; let block_id: BlockId = serde_json::from_str(s).unwrap(); @@ -93,7 +93,7 @@ fn block_id_from_latest() { #[test] fn block_id_from_pending() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let s = "\"pending\""; let block_id: BlockId = serde_json::from_str(s).unwrap(); @@ -103,7 +103,7 @@ fn block_id_from_pending() { #[cfg(test)] #[test] fn block_id_to_hash() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let block_id = BlockId::Hash(Felt::from_hex("0x123").unwrap()); let s = serde_json::to_string(&block_id).unwrap(); @@ -113,7 +113,7 @@ fn block_id_to_hash() { #[cfg(test)] #[test] fn block_id_to_number() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let block_id = BlockId::::Number(123); let s = serde_json::to_string(&block_id).unwrap(); @@ -123,7 +123,7 @@ fn block_id_to_number() { #[cfg(test)] #[test] fn block_id_to_latest() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let block_id = BlockId::::Tag(BlockTag::Latest); let s = serde_json::to_string(&block_id).unwrap(); @@ -133,7 +133,7 @@ fn block_id_to_latest() { #[cfg(test)] #[test] fn block_id_to_pending() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let block_id = BlockId::::Tag(BlockTag::Pending); let s = serde_json::to_string(&block_id).unwrap(); diff --git a/crates/starknet-types-rpc/src/custom/query.rs b/crates/starknet-types-rpc/src/custom/query.rs index 1d0bd472..af8ef11f 100644 --- a/crates/starknet-types-rpc/src/custom/query.rs +++ b/crates/starknet-types-rpc/src/custom/query.rs @@ -3,26 +3,30 @@ use serde::{Deserialize, Serialize}; -use crate::{ - BroadcastedDeclareTxnV1, BroadcastedDeclareTxnV2, DeployAccountTxnV1, InvokeTxnV0, InvokeTxnV1, -}; +use crate::{BroadcastedDeclareTxnV1, BroadcastedDeclareTxnV2, BroadcastedDeclareTxnV3, + DeployAccountTxnV1, DeployAccountTxnV3, InvokeTxnV0, InvokeTxnV1, InvokeTxnV3}; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(tag = "version")] pub enum BroadcastedDeclareTxn { #[serde(rename = "0x1")] V1(BroadcastedDeclareTxnV1), #[serde(rename = "0x2")] V2(BroadcastedDeclareTxnV2), + #[serde(rename = "0x3")] + V3(BroadcastedDeclareTxnV3), /// Query-only broadcasted declare transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000001")] QueryV1(BroadcastedDeclareTxnV1), /// Query-only broadcasted declare transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000002")] QueryV2(BroadcastedDeclareTxnV2), + /// Query-only broadcasted declare transaction. + #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000003")] + QueryV3(BroadcastedDeclareTxnV3), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(tag = "version")] pub enum BroadcastedDeployAccountTxn { #[serde(rename = "0x1")] @@ -30,19 +34,28 @@ pub enum BroadcastedDeployAccountTxn { /// Query-only broadcasted deploy account transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000001")] QueryV1(DeployAccountTxnV1), + /// Query-only broadcasted deploy account transaction. + #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000003")] + QueryV3(DeployAccountTxnV3), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(tag = "version")] pub enum BroadcastedInvokeTxn { #[serde(rename = "0x0")] V0(InvokeTxnV0), #[serde(rename = "0x1")] V1(InvokeTxnV1), + #[serde(rename = "0x3")] + V3(InvokeTxnV3), + /// Query-only broadcasted invoke transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000000")] QueryV0(InvokeTxnV0), /// Query-only broadcasted invoke transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000001")] QueryV1(InvokeTxnV1), + /// Query-only broadcasted invoke transaction. + #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000003")] + QueryV3(InvokeTxnV3), } diff --git a/crates/starknet-types-rpc/src/custom/syncing_status.rs b/crates/starknet-types-rpc/src/custom/syncing_status.rs index 3e1744b1..ff94dbe0 100644 --- a/crates/starknet-types-rpc/src/custom/syncing_status.rs +++ b/crates/starknet-types-rpc/src/custom/syncing_status.rs @@ -72,7 +72,7 @@ impl<'de, F: Deserialize<'de>> Deserialize<'de> for SyncingStatus { #[cfg(test)] #[test] fn syncing_status_from_false() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let s = "false"; let syncing_status: SyncingStatus = serde_json::from_str(s).unwrap(); @@ -82,7 +82,7 @@ fn syncing_status_from_false() { #[cfg(test)] #[test] fn syncing_status_to_false() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let syncing_status = SyncingStatus::::NotSyncing; let s = serde_json::to_string(&syncing_status).unwrap(); @@ -92,7 +92,7 @@ fn syncing_status_to_false() { #[cfg(test)] #[test] fn syncing_status_from_true() { - use crate::Felt; + pub use starknet_types_core::felt::Felt; let s = "true"; assert!(serde_json::from_str::>(s).is_err()); } diff --git a/crates/starknet-types-rpc/src/lib.rs b/crates/starknet-types-rpc/src/lib.rs index 75a1d6e1..dfb4ddcd 100644 --- a/crates/starknet-types-rpc/src/lib.rs +++ b/crates/starknet-types-rpc/src/lib.rs @@ -17,6 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; +extern crate core; mod custom; mod custom_serde; diff --git a/crates/starknet-types-rpc/src/v0_7_1/mod.rs b/crates/starknet-types-rpc/src/v0_7_1/mod.rs index 708fae19..2df2c821 100644 --- a/crates/starknet-types-rpc/src/v0_7_1/mod.rs +++ b/crates/starknet-types-rpc/src/v0_7_1/mod.rs @@ -1,7 +1,4 @@ //! v0.7.1 of the API. - -pub use starknet_types_core::felt::Felt; - pub use crate::custom::{ BlockId, BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn, SyncingStatus, diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.rs b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.rs index 39256771..50050541 100644 --- a/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.rs +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.rs @@ -1,23 +1,30 @@ // -// This file was automatically generated by openrpc-gen first, then manually edited. +// This file was automatically generated by openrpc-gen. +// +// Do not edit it manually and instead edit either the source OpenRPC document, +// the configuration file, or open an issue or pull request on the openrpc-gen +// GitHub repository. +// +// https://github.com/nils-mathieu/openrpc-gen +// use super::{BlockId, BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn}; use crate::custom_serde::NumAsHex; use alloc::string::String; use alloc::vec::Vec; -use core::marker::PhantomData; use serde::ser::SerializeMap; use serde::{Deserialize, Serialize}; +use std::marker::PhantomData; pub type Address = F; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct TransactionAndReceipt { pub receipt: TxnReceipt, pub transaction: Txn, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct TxnWithHash { #[serde(flatten)] pub transaction: Txn, @@ -26,7 +33,7 @@ pub struct TxnWithHash { pub type BlockHash = F; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct BlockHeader { pub block_hash: BlockHash, /// The block number (its height) @@ -53,7 +60,7 @@ pub struct BlockHeader { pub type BlockNumber = u64; /// The status of the block -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum BlockStatus { #[serde(rename = "ACCEPTED_ON_L1")] AcceptedOnL1, @@ -66,7 +73,7 @@ pub enum BlockStatus { } /// A tag specifying a dynamic reference to a block -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum BlockTag { #[serde(rename = "latest")] Latest, @@ -75,7 +82,7 @@ pub enum BlockTag { } /// The block object -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct BlockWithReceipts { /// The transactions in this block pub transactions: Vec>, @@ -85,7 +92,7 @@ pub struct BlockWithReceipts { } /// The block object -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct BlockWithTxs { /// The transactions in this block pub transactions: Vec>, @@ -95,7 +102,7 @@ pub struct BlockWithTxs { } /// The block object -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct BlockWithTxHashes { /// The hashes of the transactions included in this block pub transactions: Vec>, @@ -104,7 +111,7 @@ pub struct BlockWithTxHashes { pub block_header: BlockHeader, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct BroadcastedDeclareTxnV1 { /// The class to be declared pub contract_class: DeprecatedContractClass, @@ -116,8 +123,8 @@ pub struct BroadcastedDeclareTxnV1 { pub signature: Signature, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub struct BroadcastedDeclareTxnV2 { +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BroadcastedDeclareTxnV2 { /// The hash of the Cairo assembly resulting from the Sierra compilation pub compiled_class_hash: F, /// The class to be declared @@ -130,7 +137,42 @@ pub struct BroadcastedDeclareTxnV2 { pub signature: Signature, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BroadcastedDeclareTxnV3 { + /// data needed to deploy the account contract from which this tx will be initiated + pub account_deployment_data: Vec, + /// The hash of the Cairo assembly resulting from the Sierra compilation + pub compiled_class_hash: F, + /// The class to be declared + pub contract_class: ContractClass, + /// The storage domain of the account's balance from which fee will be charged + pub fee_data_availability_mode: DaMode, + pub nonce: F, + /// The storage domain of the account's nonce (an account has a nonce per DA mode) + pub nonce_data_availability_mode: DaMode, + /// data needed to allow the paymaster to pay for the transaction in native tokens + pub paymaster_data: Vec, + /// resource bounds for the transaction execution + pub resource_bounds: ResourceBoundsMapping, + /// The address of the account contract sending the declaration transaction + pub sender_address: Address, + pub signature: Signature, + /// the tip for the transaction + pub tip: U64, + /// Version of the transaction scheme + pub version: Version, +} + +/// Version of the transaction scheme +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum Version { + #[serde(rename = "0x100000000000000000000000000000003")] + X100000000000000000000000000000003, + #[serde(rename = "0x3")] + X3, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(tag = "type")] pub enum BroadcastedTxn { #[serde(rename = "INVOKE")] @@ -144,7 +186,7 @@ pub enum BroadcastedTxn { /// StarkNet chain id, given in hex representation. pub type ChainId = u64; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct CommonReceiptProperties { /// The fee that was charged by the sequencer pub actual_fee: FeePayment, @@ -161,7 +203,7 @@ pub struct CommonReceiptProperties { pub anon: Anonymous, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum Anonymous { /// Common properties for a transaction receipt that was executed successfully @@ -171,14 +213,14 @@ pub enum Anonymous { } /// Common properties for a transaction receipt that was executed successfully -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct SuccessfulCommonReceiptProperties { /// The execution status of the transaction pub execution_status: String, /* SUCCEEDED */ } /// Common properties for a transaction receipt that was reverted -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct RevertedCommonReceiptProperties { /// The execution status of the transaction pub execution_status: String, /* REVERTED */ @@ -187,7 +229,7 @@ pub struct RevertedCommonReceiptProperties { } /// The resources consumed by the VM -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ComputationResources { /// the number of BITWISE builtin instances #[serde(default)] @@ -222,7 +264,7 @@ pub struct ComputationResources { pub type ContractAbi = Vec; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum ContractAbiEntry { Function(FunctionAbiEntry), @@ -230,7 +272,7 @@ pub enum ContractAbiEntry { Struct(StructAbiEntry), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ContractClass { /// The class ABI, as supplied by the user declaring the class #[serde(default)] @@ -242,7 +284,7 @@ pub struct ContractClass { pub sierra_program: Vec, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EntryPointsByType { #[serde(rename = "CONSTRUCTOR")] pub constructor: Vec>, @@ -252,7 +294,7 @@ pub struct EntryPointsByType { pub l1_handler: Vec>, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ContractStorageDiffItem { /// The contract address for which the storage changed pub address: F, @@ -260,7 +302,7 @@ pub struct ContractStorageDiffItem { pub storage_entries: Vec>, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct KeyValuePair { /// The key of the changed value #[serde(default)] @@ -271,13 +313,13 @@ pub struct KeyValuePair { } /// Specifies a storage domain in Starknet. Each domain has different gurantess regarding availability -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum DaMode { L1, L2, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(tag = "version")] pub enum DeclareTxn { #[serde(rename = "0x0")] @@ -290,13 +332,13 @@ pub enum DeclareTxn { V3(DeclareTxnV3), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeclareTxnReceipt { #[serde(flatten)] pub common_receipt_properties: CommonReceiptProperties, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeclareTxnV0 { /// The hash of the declared class pub class_hash: F, @@ -307,7 +349,7 @@ pub struct DeclareTxnV0 { pub signature: Signature, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeclareTxnV1 { /// The hash of the declared class pub class_hash: F, @@ -319,7 +361,7 @@ pub struct DeclareTxnV1 { pub signature: Signature, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeclareTxnV2 { /// The hash of the declared class pub class_hash: F, @@ -333,7 +375,7 @@ pub struct DeclareTxnV2 { pub signature: Signature, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeclareTxnV3 { /// data needed to deploy the account contract from which this tx will be initiated pub account_deployment_data: Vec, @@ -357,7 +399,7 @@ pub struct DeclareTxnV3 { pub tip: U64, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeployedContractItem { /// The address of the contract pub address: F, @@ -366,7 +408,7 @@ pub struct DeployedContractItem { } /// deploys a new account contract -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(tag = "version")] pub enum DeployAccountTxn { #[serde(rename = "0x1")] @@ -375,7 +417,7 @@ pub enum DeployAccountTxn { V3(DeployAccountTxnV3), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeployAccountTxnReceipt { #[serde(flatten)] pub common_receipt_properties: CommonReceiptProperties, @@ -384,7 +426,7 @@ pub struct DeployAccountTxnReceipt { } /// Deploys an account contract, charges fee from the pre-funded account addresses -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeployAccountTxnV1 { /// The hash of the deployed contract's class pub class_hash: F, @@ -399,7 +441,7 @@ pub struct DeployAccountTxnV1 { } /// Deploys an account contract, charges fee from the pre-funded account addresses -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeployAccountTxnV3 { /// The hash of the deployed contract's class pub class_hash: F, @@ -421,7 +463,7 @@ pub struct DeployAccountTxnV3 { pub tip: U64, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeployTxn { /// The hash of the deployed contract's class pub class_hash: F, @@ -433,7 +475,7 @@ pub struct DeployTxn { pub version: F, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeployTxnReceipt { #[serde(flatten)] pub common_receipt_properties: CommonReceiptProperties, @@ -441,7 +483,7 @@ pub struct DeployTxnReceipt { pub contract_address: F, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeprecatedCairoEntryPoint { /// The offset of the entry point in the program #[serde(with = "NumAsHex")] @@ -451,7 +493,7 @@ pub struct DeprecatedCairoEntryPoint { } /// The definition of a StarkNet contract class -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeprecatedContractClass { #[serde(default)] pub abi: Option, @@ -460,7 +502,7 @@ pub struct DeprecatedContractClass { pub program: String, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeprecatedEntryPointsByType { #[serde(default)] #[serde(rename = "CONSTRUCTOR")] @@ -474,7 +516,7 @@ pub struct DeprecatedEntryPointsByType { } /// Event information decorated with metadata on where it was emitted / An event emitted as a result of transaction execution -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EmittedEvent { /// The event information #[serde(flatten)] @@ -493,14 +535,14 @@ pub struct EmittedEvent { pub type EthAddress = String; /// A StarkNet event -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct Event { pub from_address: Address, pub data: Vec, pub keys: Vec, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EventsChunk { /// Use this token in a subsequent query to obtain the next page. Should not appear if there are no more pages. #[serde(default)] @@ -508,7 +550,7 @@ pub struct EventsChunk { pub events: Vec>, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EventAbiEntry { pub data: Vec, pub keys: Vec, @@ -521,7 +563,7 @@ pub struct EventAbiEntry { pub type EventAbiType = String; /// the resources consumed by the transaction, includes both computation and data -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ExecutionResources { /// the number of BITWISE builtin instances #[serde(default)] @@ -555,7 +597,7 @@ pub struct ExecutionResources { pub data_availability: DataAvailability, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DataAvailability { /// the data gas consumed by this transaction's data, 0 if it uses gas for DA pub l1_data_gas: u64, @@ -563,7 +605,7 @@ pub struct DataAvailability { pub l1_gas: u64, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct FeeEstimate { /// The Ethereum data gas consumption of the transaction pub data_gas_consumed: F, @@ -580,7 +622,7 @@ pub struct FeeEstimate { } /// fee payment info as it appears in receipts -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct FeePayment { /// amount paid pub amount: F, @@ -588,7 +630,7 @@ pub struct FeePayment { pub unit: PriceUnit, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct FunctionAbiEntry { pub inputs: Vec, /// The function name @@ -601,7 +643,7 @@ pub struct FunctionAbiEntry { pub ty: FunctionAbiType, } -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum FunctionAbiType { #[serde(rename = "constructor")] Constructor, @@ -612,7 +654,7 @@ pub enum FunctionAbiType { } /// Function call information -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct FunctionCall { /// The parameters passed to the function pub calldata: Vec, @@ -623,7 +665,7 @@ pub struct FunctionCall { pub type FunctionStateMutability = String; /// Initiate a transaction from an account -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(tag = "version")] pub enum InvokeTxn { #[serde(rename = "0x0")] @@ -634,14 +676,14 @@ pub enum InvokeTxn { V3(InvokeTxnV3), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct InvokeTxnReceipt { #[serde(flatten)] pub common_receipt_properties: CommonReceiptProperties, } /// invokes a specific function in the desired contract (not necessarily an account) -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct InvokeTxnV0 { /// The parameters passed to the function pub calldata: Vec, @@ -652,7 +694,7 @@ pub struct InvokeTxnV0 { pub signature: Signature, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct InvokeTxnV1 { /// The data expected by the account's `execute` function (in most usecases, this includes the called contract address and a function selector) pub calldata: Vec, @@ -663,7 +705,7 @@ pub struct InvokeTxnV1 { pub signature: Signature, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct InvokeTxnV3 { /// data needed to deploy the account contract from which this tx will be initiated pub account_deployment_data: Vec, @@ -684,7 +726,7 @@ pub struct InvokeTxnV3 { pub tip: U64, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct L1HandlerTxn { /// The L1->L2 message nonce field of the SN Core L1 contract at the time the transaction was sent #[serde(with = "NumAsHex")] @@ -696,7 +738,7 @@ pub struct L1HandlerTxn { } /// receipt for l1 handler transaction -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct L1HandlerTxnReceipt { /// The message hash as it appears on the L1 core contract #[serde(with = "NumAsHex")] @@ -705,7 +747,7 @@ pub struct L1HandlerTxnReceipt { pub common_receipt_properties: CommonReceiptProperties, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct MsgFromL1 { /// The selector of the l1_handler in invoke in the target contract pub entry_point_selector: F, @@ -717,7 +759,7 @@ pub struct MsgFromL1 { pub to_address: Address, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct MsgToL1 { /// The address of the L2 contract sending the message pub from_address: F, @@ -727,7 +769,7 @@ pub struct MsgToL1 { pub to_address: F, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct PendingBlockHeader { /// specifies whether the data of this block is published via blob data or calldata pub l1_da_mode: L1DaMode, @@ -746,7 +788,7 @@ pub struct PendingBlockHeader { } /// specifies whether the data of this block is published via blob data or calldata -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum L1DaMode { #[serde(rename = "BLOB")] Blob, @@ -755,7 +797,7 @@ pub enum L1DaMode { } /// The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct PendingBlockWithReceipts { /// The transactions in this block pub transactions: Vec>, @@ -764,7 +806,7 @@ pub struct PendingBlockWithReceipts { } /// The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct PendingBlockWithTxs { /// The transactions in this block pub transactions: Vec>, @@ -773,7 +815,7 @@ pub struct PendingBlockWithTxs { } /// The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct PendingBlockWithTxHashes { /// The hashes of the transactions included in this block pub transactions: Vec>, @@ -782,14 +824,14 @@ pub struct PendingBlockWithTxHashes { } /// Pending state update -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct PendingStateUpdate { /// The previous global state root pub old_root: F, pub state_diff: StateDiff, } -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum PriceUnit { #[serde(rename = "FRI")] Fri, @@ -797,7 +839,7 @@ pub enum PriceUnit { Wei, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ResourceBounds { /// the max amount of the resource that can be used in the tx pub max_amount: U64, @@ -805,7 +847,7 @@ pub struct ResourceBounds { pub max_price_per_unit: U128, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ResourceBoundsMapping { /// The max amount and max price per unit of L1 gas used in this tx pub l1_gas: ResourceBounds, @@ -813,7 +855,7 @@ pub struct ResourceBoundsMapping { pub l2_gas: ResourceBounds, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ResourcePrice { /// the price of one unit of the given resource, denominated in fri (10^-18 strk) pub price_in_fri: F, @@ -821,7 +863,7 @@ pub struct ResourcePrice { pub price_in_wei: F, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct SierraEntryPoint { /// The index of the function in the program pub function_idx: u64, @@ -836,7 +878,7 @@ pub type Signature = Vec; pub type SimulationFlagForEstimateFee = String; /// The change in state applied in this block, given as a mapping of addresses to the new values and/or new contracts -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct StateDiff { pub declared_classes: Vec>, pub deployed_contracts: Vec>, @@ -847,7 +889,7 @@ pub struct StateDiff { } /// The declared class hash and compiled class hash -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct NewClasses { /// The hash of the declared class #[serde(default)] @@ -858,7 +900,7 @@ pub struct NewClasses { } /// The updated nonce per contract address -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct NonceUpdate { /// The address of the contract #[serde(default)] @@ -869,7 +911,7 @@ pub struct NonceUpdate { } /// The list of contracts whose class was replaced -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ReplacedClass { /// The new class hash #[serde(default)] @@ -879,7 +921,7 @@ pub struct ReplacedClass { pub contract_address: Option>, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct StateUpdate { pub block_hash: BlockHash, /// The new global state root @@ -892,7 +934,7 @@ pub struct StateUpdate { /// A storage key. Represented as up to 62 hex digits, 3 bits, and 5 leading zeroes. pub type StorageKey = String; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct StructAbiEntry { pub members: Vec, /// The struct name @@ -904,7 +946,7 @@ pub struct StructAbiEntry { pub type StructAbiType = String; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct StructMember { #[serde(flatten)] pub typed_parameter: TypedParameter, @@ -914,7 +956,7 @@ pub struct StructMember { } /// An object describing the node synchronization status -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct SyncStatus { /// The hash of the current block being synchronized pub current_block_hash: BlockHash, @@ -931,7 +973,7 @@ pub struct SyncStatus { } /// The transaction schema, as it appears inside a block -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(tag = "type")] pub enum Txn { #[serde(rename = "INVOKE")] @@ -947,7 +989,7 @@ pub enum Txn { } /// The execution status of the transaction -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum TxnExecutionStatus { #[serde(rename = "REVERTED")] Reverted, @@ -956,7 +998,7 @@ pub enum TxnExecutionStatus { } /// The finality status of the transaction -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum TxnFinalityStatus { #[serde(rename = "ACCEPTED_ON_L1")] L1, @@ -965,10 +1007,9 @@ pub enum TxnFinalityStatus { } /// The transaction hash, as assigned in StarkNet -// pub type TxnHash Deserialize<'de>> = F; pub type TxnHash = F; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(tag = "type")] pub enum TxnReceipt { #[serde(rename = "INVOKE")] @@ -983,7 +1024,7 @@ pub enum TxnReceipt { DeployAccount(DeployAccountTxnReceipt), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct TxnReceiptWithBlockInfo { #[serde(flatten)] pub transaction_receipt: TxnReceipt, @@ -996,7 +1037,7 @@ pub struct TxnReceiptWithBlockInfo { } /// The finality status of the transaction, including the case the txn is still in the mempool or failed validation during the block construction phase -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum TxnStatus { #[serde(rename = "ACCEPTED_ON_L1")] AcceptedOnL1, @@ -1008,7 +1049,7 @@ pub enum TxnStatus { Rejected, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct TypedParameter { /// The parameter's name pub name: String, @@ -1023,42 +1064,42 @@ pub type U128 = String; /// 64 bit integers, represented by hex string of length at most 16 pub type U64 = String; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct BlockHashAndNumber { pub block_hash: BlockHash, pub block_number: BlockNumber, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum StarknetGetBlockWithTxsAndReceiptsResult { Block(BlockWithReceipts), Pending(PendingBlockWithReceipts), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum MaybePendingBlockWithTxHashes { Block(BlockWithTxHashes), Pending(PendingBlockWithTxHashes), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum MaybePendingBlockWithTxs { Block(BlockWithTxs), Pending(PendingBlockWithTxs), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum MaybeDeprecatedContractClass { Deprecated(DeprecatedContractClass), ContractClass(ContractClass), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub struct EventFilterWithPageRequest { +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct EventFilterWithPageRequest { #[serde(default)] pub address: Option>, #[serde(default)] @@ -1074,14 +1115,14 @@ pub struct EventFilterWithPageRequest { pub continuation_token: Option, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum MaybePendingStateUpdate { Block(StateUpdate), Pending(PendingStateUpdate), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct TxnFinalityAndExecutionStatus { #[serde(default)] pub execution_status: Option, @@ -1158,7 +1199,7 @@ pub struct GetBlockWithTxHashesParams { pub block_id: BlockId, } -impl Serialize for GetBlockWithTxHashesParams { +impl Serialize for GetBlockWithTxHashesParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1170,7 +1211,7 @@ impl Serialize for GetBlockWithTxHashesParams { } } -impl<'de, F: Serialize + Deserialize<'de>> Deserialize<'de> for GetBlockWithTxHashesParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockWithTxHashesParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1179,7 +1220,7 @@ impl<'de, F: Serialize + Deserialize<'de>> Deserialize<'de> for GetBlockWithTxHa marker: PhantomData, } - impl<'de, F: Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetBlockWithTxHashesParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -1237,7 +1278,7 @@ pub struct GetBlockWithTxsParams { pub block_id: BlockId, } -impl Serialize for GetBlockWithTxsParams { +impl Serialize for GetBlockWithTxsParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1249,7 +1290,7 @@ impl Serialize for GetBlockWithTxsParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetBlockWithTxsParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockWithTxsParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1258,7 +1299,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetBlockW marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetBlockWithTxsParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -1316,7 +1357,7 @@ pub struct GetBlockWithReceiptsParams { pub block_id: BlockId, } -impl Serialize for GetBlockWithReceiptsParams { +impl Serialize for GetBlockWithReceiptsParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1328,7 +1369,7 @@ impl Serialize for GetBlockWithReceiptsParams { } } -impl<'de, F: Copy + Deserialize<'de>> Deserialize<'de> for GetBlockWithReceiptsParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockWithReceiptsParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1337,7 +1378,7 @@ impl<'de, F: Copy + Deserialize<'de>> Deserialize<'de> for GetBlockWithReceiptsP marker: PhantomData, } - impl<'de, F: Copy + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetBlockWithReceiptsParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -1395,7 +1436,7 @@ pub struct GetStateUpdateParams { pub block_id: BlockId, } -impl Serialize for GetStateUpdateParams { +impl Serialize for GetStateUpdateParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1407,7 +1448,7 @@ impl Serialize for GetStateUpdateParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetStateUpdateParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetStateUpdateParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1416,7 +1457,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetStateU marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetStateUpdateParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -1478,7 +1519,7 @@ pub struct GetStorageAtParams { pub block_id: BlockId, } -impl Serialize for GetStorageAtParams { +impl Serialize for GetStorageAtParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1492,7 +1533,7 @@ impl Serialize for GetStorageAtParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetStorageAtParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetStorageAtParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1501,7 +1542,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetStorag marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetStorageAtParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -1695,7 +1736,7 @@ pub struct GetTransactionByBlockIdAndIndexParams { pub index: u64, } -impl Serialize for GetTransactionByBlockIdAndIndexParams { +impl Serialize for GetTransactionByBlockIdAndIndexParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1708,9 +1749,7 @@ impl Serialize for GetTransactionByBlockIdAndIndexParams } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> - for GetTransactionByBlockIdAndIndexParams -{ +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetTransactionByBlockIdAndIndexParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1719,7 +1758,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetTransactionByBlockIdAndIndexParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -1847,7 +1886,7 @@ pub struct GetClassParams { pub class_hash: F, } -impl Serialize for GetClassParams { +impl Serialize for GetClassParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1860,7 +1899,7 @@ impl Serialize for GetClassParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetClassParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetClassParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1869,7 +1908,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetClassP marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetClassParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -1937,7 +1976,7 @@ pub struct GetClassHashAtParams { pub contract_address: Address, } -impl Serialize for GetClassHashAtParams { +impl Serialize for GetClassHashAtParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -1950,7 +1989,7 @@ impl Serialize for GetClassHashAtParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetClassHashAtParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetClassHashAtParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -1959,7 +1998,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetClassH marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetClassHashAtParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -2027,7 +2066,7 @@ pub struct GetClassAtParams { pub contract_address: Address, } -impl Serialize for GetClassAtParams { +impl Serialize for GetClassAtParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -2040,7 +2079,7 @@ impl Serialize for GetClassAtParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetClassAtParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetClassAtParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -2049,7 +2088,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetClassA marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetClassAtParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -2115,7 +2154,7 @@ pub struct GetBlockTransactionCountParams { pub block_id: BlockId, } -impl Serialize for GetBlockTransactionCountParams { +impl Serialize for GetBlockTransactionCountParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -2127,9 +2166,7 @@ impl Serialize for GetBlockTransactionCountParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> - for GetBlockTransactionCountParams -{ +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockTransactionCountParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -2138,7 +2175,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetBlockTransactionCountParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -2198,7 +2235,7 @@ pub struct CallParams { pub block_id: BlockId, } -impl Serialize for CallParams { +impl Serialize for CallParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -2211,7 +2248,7 @@ impl Serialize for CallParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for CallParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for CallParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -2220,7 +2257,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for CallParam marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = CallParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -2287,7 +2324,7 @@ pub struct EstimateFeeParams { pub block_id: BlockId, } -impl Serialize for EstimateFeeParams { +impl Serialize for EstimateFeeParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -2301,9 +2338,7 @@ impl Serialize for EstimateFeeParams { } } -impl<'de, F: Copy + Default + Serialize + Deserialize<'de>> Deserialize<'de> - for EstimateFeeParams -{ +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for EstimateFeeParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -2312,7 +2347,7 @@ impl<'de, F: Copy + Default + Serialize + Deserialize<'de>> Deserialize<'de> marker: PhantomData, } - impl<'de, F: Default + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Default + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = EstimateFeeParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -2386,7 +2421,7 @@ pub struct EstimateMessageFeeParams { pub block_id: BlockId, } -impl Serialize for EstimateMessageFeeParams { +impl Serialize for EstimateMessageFeeParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -2399,7 +2434,7 @@ impl Serialize for EstimateMessageFeeParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for EstimateMessageFeeParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for EstimateMessageFeeParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -2408,7 +2443,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for EstimateM marker: PhantomData, } - impl<'de, F: Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = EstimateMessageFeeParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -2718,12 +2753,12 @@ impl<'de> Deserialize<'de> for SyncingParams { /// Parameters of the `starknet_getEvents` method. #[derive(Clone, Debug, Eq, PartialEq)] -pub struct GetEventsParams { +pub struct GetEventsParams { /// The conditions used to filter the returned events pub filter: EventFilterWithPageRequest, } -impl Serialize for GetEventsParams { +impl Serialize for GetEventsParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -2735,7 +2770,7 @@ impl Serialize for GetEventsParams { } } -impl<'de, F: Copy + Default + Deserialize<'de>> Deserialize<'de> for GetEventsParams { +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for GetEventsParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -2744,7 +2779,7 @@ impl<'de, F: Copy + Default + Deserialize<'de>> Deserialize<'de> for GetEventsPa marker: PhantomData, } - impl<'de, F: Copy + Default + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Default + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetEventsParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -2776,7 +2811,7 @@ impl<'de, F: Copy + Default + Deserialize<'de>> Deserialize<'de> for GetEventsPa A: serde::de::MapAccess<'de>, { #[derive(Deserialize)] - struct Helper { + struct Helper { filter: EventFilterWithPageRequest, } @@ -2804,7 +2839,7 @@ pub struct GetNonceParams { pub contract_address: Address, } -impl Serialize for GetNonceParams { +impl Serialize for GetNonceParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -2817,7 +2852,7 @@ impl Serialize for GetNonceParams { } } -impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetNonceParams { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetNonceParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -2826,7 +2861,7 @@ impl<'de, F: Copy + Serialize + Deserialize<'de>> Deserialize<'de> for GetNonceP marker: PhantomData, } - impl<'de, F: Copy + Serialize + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = GetNonceParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.toml b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.toml index 4af9cc5c..e7e4c971 100644 --- a/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.toml +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.toml @@ -4,9 +4,10 @@ run-rustfmt = true [generation] additional-imports = [ "crate::custom_serde::NumAsHex", - "super::{BlockId, Felt, BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn}", + "super::{BlockId, BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn}", "alloc::vec::Vec", "alloc::string::String", + "std::marker::PhantomData" ] method-name-prefix = "starknet_" param-types = true @@ -23,6 +24,7 @@ preserve = [ "#/components/schemas/SYNC_STATUS", "#/components/schemas/BROADCASTED_DECLARE_TXN_V1", "#/components/schemas/BROADCASTED_DECLARE_TXN_V2", + "#/components/schemas/BROADCASTED_DECLARE_TXN_V3", "#/components/schemas/COMPUTATION_RESOURCES", ] @@ -30,7 +32,7 @@ preserve = [ # Too tricky to automatically fix cleanly "#/components/schemas/BLOCK_ID" = "BlockId" "#/methods/starknet_syncing/result/_anon" = "SyncingStatus" -"#/components/schemas/FELT" = "Felt" +"#/components/schemas/FELT" = "F" # Query-only types "#/components/schemas/BROADCASTED_DECLARE_TXN" = "BroadcastedDeclareTxn" diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.rs b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.rs index a360ec02..23948364 100644 --- a/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.rs +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.rs @@ -1,5 +1,12 @@ // -// This file was automatically generated by openrpc-gen first, then manually edited. +// This file was automatically generated by openrpc-gen. +// +// Do not edit it manually and instead edit either the source OpenRPC document, +// the configuration file, or open an issue or pull request on the openrpc-gen +// GitHub repository. +// +// https://github.com/nils-mathieu/openrpc-gen +// use super::{ BlockId, BroadcastedTxn, ComputationResources, Event, ExecutionResources, FeeEstimate, @@ -9,8 +16,9 @@ use alloc::string::String; use alloc::vec::Vec; use serde::ser::SerializeMap; use serde::{Deserialize, Serialize}; +use std::marker::PhantomData; -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum CallType { #[serde(rename = "CALL")] Regular, @@ -20,7 +28,7 @@ pub enum CallType { LibraryCall, } -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum EntryPointType { #[serde(rename = "CONSTRUCTOR")] Constructor, @@ -30,7 +38,7 @@ pub enum EntryPointType { L1Handler, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct FunctionInvocation { #[serde(flatten)] pub function_call: FunctionCall, @@ -55,7 +63,7 @@ pub struct FunctionInvocation { pub type NestedCall = FunctionInvocation; /// an event alongside its order within the transaction -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct OrderedEvent { /// the order of the event within the transaction #[serde(default)] @@ -65,7 +73,7 @@ pub struct OrderedEvent { } /// a message alongside its order within the transaction -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct OrderedMessage { /// the order of the message within the transaction #[serde(default)] @@ -75,7 +83,7 @@ pub struct OrderedMessage { } /// Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is replicated locally (enough funds are expected to be in the account, and fee will be deducted from the balance before the simulation of the next transaction). To skip the fee charge, use the SKIP_FEE_CHARGE flag. -#[derive(Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] pub enum SimulationFlag { #[serde(rename = "SKIP_FEE_CHARGE")] FeeCharge, @@ -83,7 +91,7 @@ pub enum SimulationFlag { Validate, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(tag = "type")] pub enum TransactionTrace { /// the execution trace of an invoke transaction @@ -101,7 +109,7 @@ pub enum TransactionTrace { } /// the execution trace of an invoke transaction -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct InvokeTransactionTrace { /// the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) pub execute_invocation: ExecuteInvocation, @@ -117,21 +125,21 @@ pub struct InvokeTransactionTrace { } /// the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(untagged)] pub enum ExecuteInvocation { FunctionInvocation(FunctionInvocation), Anon(RevertedInvocation), } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct RevertedInvocation { /// the revert reason for the failed execution pub revert_reason: String, } /// the execution trace of a declare transaction -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeclareTransactionTrace { /// the resources consumed by the transaction, includes both computation and data pub execution_resources: ExecutionResources, @@ -145,7 +153,7 @@ pub struct DeclareTransactionTrace { } /// the execution trace of a deploy account transaction -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct DeployAccountTransactionTrace { /// the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) pub constructor_invocation: FunctionInvocation, @@ -161,7 +169,7 @@ pub struct DeployAccountTransactionTrace { } /// the execution trace of an L1 handler transaction -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct L1HandlerTransactionTrace { /// the resources consumed by the transaction, includes both computation and data pub execution_resources: ExecutionResources, @@ -172,7 +180,7 @@ pub struct L1HandlerTransactionTrace { pub state_diff: Option>, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct SimulateTransactionsResult { #[serde(default)] pub fee_estimation: Option>, @@ -181,7 +189,7 @@ pub struct SimulateTransactionsResult { } /// A single pair of transaction hash and corresponding trace -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct TraceBlockTransactionsResult { #[serde(default)] pub trace_root: Option>, @@ -214,7 +222,7 @@ impl<'de, F: Deserialize<'de>> Deserialize<'de> for TraceTransactionParams { D: serde::Deserializer<'de>, { struct Visitor { - marker: core::marker::PhantomData, + marker: PhantomData, } impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { @@ -263,7 +271,7 @@ impl<'de, F: Deserialize<'de>> Deserialize<'de> for TraceTransactionParams { } deserializer.deserialize_any(Visitor:: { - marker: core::marker::PhantomData, + marker: PhantomData, }) } } @@ -279,7 +287,7 @@ pub struct SimulateTransactionsParams { pub simulation_flags: Vec, } -impl Serialize for SimulateTransactionsParams { +impl Serialize for SimulateTransactionsParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -293,16 +301,16 @@ impl Serialize for SimulateTransactionsParams } } -impl<'de, F: Copy + Default + Deserialize<'de>> Deserialize<'de> for SimulateTransactionsParams { +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for SimulateTransactionsParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { struct Visitor { - marker: core::marker::PhantomData, + marker: PhantomData, } - impl<'de, F: Copy + Default + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Default + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = SimulateTransactionsParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -362,7 +370,7 @@ impl<'de, F: Copy + Default + Deserialize<'de>> Deserialize<'de> for SimulateTra } deserializer.deserialize_any(Visitor:: { - marker: core::marker::PhantomData, + marker: PhantomData, }) } } @@ -374,7 +382,7 @@ pub struct TraceBlockTransactionsParams { pub block_id: BlockId, } -impl Serialize for TraceBlockTransactionsParams { +impl Serialize for TraceBlockTransactionsParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -392,7 +400,7 @@ impl<'de, F: Deserialize<'de>> Deserialize<'de> for TraceBlockTransactionsParams D: serde::Deserializer<'de>, { struct Visitor { - marker: core::marker::PhantomData, + marker: PhantomData, } impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { @@ -441,7 +449,7 @@ impl<'de, F: Deserialize<'de>> Deserialize<'de> for TraceBlockTransactionsParams } deserializer.deserialize_any(Visitor:: { - marker: core::marker::PhantomData, + marker: PhantomData, }) } } diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.toml b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.toml index c7d82fc6..582891ce 100644 --- a/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.toml +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.toml @@ -3,9 +3,10 @@ run-rustfmt = true [generation] additional-imports = [ - "super::{Felt, FunctionCall, Event, MsgToL1, BlockId, FeeEstimate, BroadcastedTxn, StateDiff, TxnHash, ExecutionResources, ComputationResources}", + "super::{FunctionCall, Event, MsgToL1, BlockId, FeeEstimate, BroadcastedTxn, StateDiff, TxnHash, ExecutionResources, ComputationResources}", "alloc::vec::Vec", "alloc::string::String", + "std::marker::PhantomData" ] method-name-prefix = "starknet_" param-types = true @@ -22,7 +23,7 @@ flatten = [ ] [fixes.replace] -"#/components/schemas/FELT" = "Felt" +"#/components/schemas/FELT" = "F" "#/components/schemas/FUNCTION_CALL" = "FunctionCall" "#/components/schemas/EVENT" = "Event" "#/components/schemas/MSG_TO_L1" = "MsgToL1" diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.rs b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.rs index e7d8c35f..cfc40a6a 100644 --- a/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.rs +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.rs @@ -1,38 +1,43 @@ // -// This file was automatically generated by openrpc-gen first, then manually edited. +// This file was automatically generated by openrpc-gen. +// +// Do not edit it manually and instead edit either the source OpenRPC document, +// the configuration file, or open an issue or pull request on the openrpc-gen +// GitHub repository. +// +// https://github.com/nils-mathieu/openrpc-gen +// -use super::{ - BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn, Felt, TxnHash, -}; -use core::marker::PhantomData; +use super::{BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn, TxnHash}; use serde::ser::SerializeMap; use serde::{Deserialize, Serialize}; +use std::marker::PhantomData; -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ClassAndTxnHash { pub class_hash: F, pub transaction_hash: TxnHash, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct ContractAndTxnHash { - pub contract_address: Felt, + pub contract_address: F, pub transaction_hash: TxnHash, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct AddInvokeTransactionResult { pub transaction_hash: TxnHash, } /// Parameters of the `starknet_addInvokeTransaction` method. #[derive(Clone, Debug, Eq, PartialEq)] -pub struct AddInvokeTransactionParams { +pub struct AddInvokeTransactionParams { /// The information needed to invoke the function (or account, for version 1 transactions) pub invoke_transaction: BroadcastedInvokeTxn, } -impl Serialize for AddInvokeTransactionParams { +impl Serialize for AddInvokeTransactionParams { #[allow(unused_mut)] fn serialize(&self, serializer: S) -> Result where @@ -44,7 +49,7 @@ impl Serialize for AddInvokeTransactionParams { } } -impl<'de, F: Deserialize<'de>> Deserialize<'de> for AddInvokeTransactionParams { +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for AddInvokeTransactionParams { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -53,7 +58,7 @@ impl<'de, F: Deserialize<'de>> Deserialize<'de> for AddInvokeTransactionParams, } - impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + impl<'de, F: Default + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { type Value = AddInvokeTransactionParams; fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -85,7 +90,7 @@ impl<'de, F: Deserialize<'de>> Deserialize<'de> for AddInvokeTransactionParams, { #[derive(Deserialize)] - struct Helper { + struct Helper { invoke_transaction: BroadcastedInvokeTxn, } diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.toml b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.toml index f452d94e..a38e4dc2 100644 --- a/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.toml +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.toml @@ -3,7 +3,8 @@ run-rustfmt = true [generation] additional-imports = [ - "super::{BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn, Felt, TxnHash}", + "super::{BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn, TxnHash}", + "std::marker::PhantomData" ] method-name-prefix = "starknet_" param-types = true @@ -21,7 +22,7 @@ strip-enum-variants = true "#/components/schemas/BROADCASTED_DEPLOY_ACCOUNT_TXN" = "BroadcastedDeployAccountTxn" "#/components/schemas/BROADCASTED_INVOKE_TXN" = "BroadcastedInvokeTxn" "#/components/schemas/DECLARE_TXN" = "DeclareTxn" -"#/components/schemas/FELT" = "Felt" +"#/components/schemas/FELT" = "F" "#/components/schemas/FUNCTION_CALL" = "FunctionCall" "#/components/schemas/SIGNATURE" = "Signature" "#/components/schemas/TXN_HASH" = "TxnHash"