From f98f048efa776f1f8da81a19f337a9b8c2f4b8f7 Mon Sep 17 00:00:00 2001 From: "Lucas @ StarkWare" <70894690+LucasLvy@users.noreply.github.com> Date: Tue, 23 Jul 2024 18:06:53 +0200 Subject: [PATCH] chore(rpc): generate latest spec (#60) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maciej KamiƄski --- crates/starknet-types-rpc/Cargo.toml | 2 +- crates/starknet-types-rpc/Makefile | 14 + crates/starknet-types-rpc/README.md | 4 +- .../starknet-types-rpc/src/custom/block_id.rs | 54 +- crates/starknet-types-rpc/src/custom/query.rs | 49 +- .../src/custom/syncing_status.rs | 32 +- crates/starknet-types-rpc/src/lib.rs | 6 +- crates/starknet-types-rpc/src/v0_7_1/mod.rs | 13 + .../src/v0_7_1/starknet_api_openrpc.json | 3990 +++++++++++++++++ .../src/v0_7_1/starknet_api_openrpc.rs | 2921 ++++++++++++ .../src/v0_7_1/starknet_api_openrpc.toml | 93 + .../v0_7_1/starknet_trace_api_openrpc.json | 517 +++ .../src/v0_7_1/starknet_trace_api_openrpc.rs | 455 ++ .../v0_7_1/starknet_trace_api_openrpc.toml | 57 + .../src/v0_7_1/starknet_write_api.json | 299 ++ .../src/v0_7_1/starknet_write_api.rs | 278 ++ .../src/v0_7_1/starknet_write_api.toml | 36 + 17 files changed, 8767 insertions(+), 53 deletions(-) create mode 100644 crates/starknet-types-rpc/Makefile create mode 100644 crates/starknet-types-rpc/src/v0_7_1/mod.rs create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.json create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.rs create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.toml create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.json create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.rs create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.toml create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.json create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.rs create mode 100644 crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.toml diff --git a/crates/starknet-types-rpc/Cargo.toml b/crates/starknet-types-rpc/Cargo.toml index 05f9983f..03d54079 100644 --- a/crates/starknet-types-rpc/Cargo.toml +++ b/crates/starknet-types-rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "starknet-types-rpc" -version = "0.6.0" +version = "0.7.1" edition = "2021" license = "MIT" homepage = "https://github.com/starknet-io/types-rs" diff --git a/crates/starknet-types-rpc/Makefile b/crates/starknet-types-rpc/Makefile new file mode 100644 index 00000000..11661690 --- /dev/null +++ b/crates/starknet-types-rpc/Makefile @@ -0,0 +1,14 @@ +SRC_DIR ?= src/v0_7_1 + +define generate_spec + echo "Generating types for $(1)"; + openrpc-gen --config $(1).toml --document $(1).json --output $(1).rs ; +endef + +BASE_NAMES := starknet_api_openrpc starknet_trace_api_openrpc starknet_write_api +# Default target that depends on all generated .rs files +all: + $(foreach file,$(BASE_NAMES),$(call generate_spec,$(SRC_DIR)/$(file))) + +# Phony target to avoid conflicts with actual files +.PHONY: all diff --git a/crates/starknet-types-rpc/README.md b/crates/starknet-types-rpc/README.md index 84be17d6..c53f3481 100644 --- a/crates/starknet-types-rpc/README.md +++ b/crates/starknet-types-rpc/README.md @@ -28,9 +28,11 @@ After having built `openrpc-gen`, you can use the following command to generate Rust files: ```bash -openrpc-gen --config configs/v0.5.0.toml --document configs/spec_v0.5.0.json --output src/generated/v0.5.0.rs +make all ``` +NOTE: Currently the `starknet_trace_api_openrpc` file requires a modification for `starknet_simulateTransactions` (nested `schema` in the result, see previous version for infos) + *Note that this first step is normally already done for you upon cloning the repository.* ### Building the generated files diff --git a/crates/starknet-types-rpc/src/custom/block_id.rs b/crates/starknet-types-rpc/src/custom/block_id.rs index 4c933a87..e5b92ebf 100644 --- a/crates/starknet-types-rpc/src/custom/block_id.rs +++ b/crates/starknet-types-rpc/src/custom/block_id.rs @@ -3,19 +3,19 @@ use serde::{Deserialize, Deserializer, Serialize}; use crate::{BlockHash, BlockNumber, BlockTag}; /// A hexadecimal number. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub enum BlockId { +#[derive(Debug, Clone, Eq, Hash, PartialEq)] +pub enum BlockId { /// The tag of the block. Tag(BlockTag), /// The hash of the block. - Hash(BlockHash), + Hash(BlockHash), /// The height of the block. Number(BlockNumber), } #[derive(Serialize, Deserialize)] -struct BlockHashHelper { - block_hash: BlockHash, +struct BlockHashHelper { + block_hash: BlockHash, } #[derive(Serialize, Deserialize)] @@ -25,32 +25,34 @@ struct BlockNumberHelper { #[derive(Deserialize)] #[serde(untagged)] -enum BlockIdHelper { +enum BlockIdHelper { Tag(BlockTag), - Hash(BlockHashHelper), + Hash(BlockHashHelper), 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) } } } } -impl<'de> serde::Deserialize<'de> for BlockId { +impl<'de, F: Deserialize<'de>> serde::Deserialize<'de> for BlockId { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, @@ -66,38 +68,44 @@ impl<'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(); + let block_id: BlockId = serde_json::from_str(s).unwrap(); assert_eq!(block_id, BlockId::Hash(Felt::from_hex("0x123").unwrap())); } #[test] fn block_id_from_number() { + pub use starknet_types_core::felt::Felt; + let s = "{\"block_number\":123}"; - let block_id: BlockId = serde_json::from_str(s).unwrap(); + let block_id: BlockId = serde_json::from_str(s).unwrap(); assert_eq!(block_id, BlockId::Number(123)); } #[test] fn block_id_from_latest() { + pub use starknet_types_core::felt::Felt; + let s = "\"latest\""; - let block_id: BlockId = serde_json::from_str(s).unwrap(); + let block_id: BlockId = serde_json::from_str(s).unwrap(); assert_eq!(block_id, BlockId::Tag(BlockTag::Latest)); } #[test] fn block_id_from_pending() { + pub use starknet_types_core::felt::Felt; + let s = "\"pending\""; - let block_id: BlockId = serde_json::from_str(s).unwrap(); + let block_id: BlockId = serde_json::from_str(s).unwrap(); assert_eq!(block_id, BlockId::Tag(BlockTag::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(); @@ -107,7 +115,9 @@ fn block_id_to_hash() { #[cfg(test)] #[test] fn block_id_to_number() { - let block_id = BlockId::Number(123); + pub use starknet_types_core::felt::Felt; + + let block_id = BlockId::::Number(123); let s = serde_json::to_string(&block_id).unwrap(); assert_eq!(s, "{\"block_number\":123}"); } @@ -115,7 +125,9 @@ fn block_id_to_number() { #[cfg(test)] #[test] fn block_id_to_latest() { - let block_id = BlockId::Tag(BlockTag::Latest); + pub use starknet_types_core::felt::Felt; + + let block_id = BlockId::::Tag(BlockTag::Latest); let s = serde_json::to_string(&block_id).unwrap(); assert_eq!(s, "\"latest\""); } @@ -123,7 +135,9 @@ fn block_id_to_latest() { #[cfg(test)] #[test] fn block_id_to_pending() { - let block_id = BlockId::Tag(BlockTag::Pending); + pub use starknet_types_core::felt::Felt; + + let block_id = BlockId::::Tag(BlockTag::Pending); let s = serde_json::to_string(&block_id).unwrap(); assert_eq!(s, "\"pending\""); } diff --git a/crates/starknet-types-rpc/src/custom/query.rs b/crates/starknet-types-rpc/src/custom/query.rs index bc5576cf..a96e2de1 100644 --- a/crates/starknet-types-rpc/src/custom/query.rs +++ b/crates/starknet-types-rpc/src/custom/query.rs @@ -4,45 +4,60 @@ use serde::{Deserialize, Serialize}; use crate::{ - BroadcastedDeclareTxnV1, BroadcastedDeclareTxnV2, DeployAccountTxnV1, InvokeTxnV0, InvokeTxnV1, + BroadcastedDeclareTxnV1, BroadcastedDeclareTxnV2, BroadcastedDeclareTxnV3, DeployAccountTxnV1, + DeployAccountTxnV3, InvokeTxnV0, InvokeTxnV1, InvokeTxnV3, }; -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(tag = "version")] -pub enum BroadcastedDeclareTxn { +pub enum BroadcastedDeclareTxn { #[serde(rename = "0x1")] - V1(BroadcastedDeclareTxnV1), + V1(BroadcastedDeclareTxnV1), #[serde(rename = "0x2")] - V2(BroadcastedDeclareTxnV2), + V2(BroadcastedDeclareTxnV2), + #[serde(rename = "0x3")] + V3(BroadcastedDeclareTxnV3), /// Query-only broadcasted declare transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000001")] - QueryV1(BroadcastedDeclareTxnV1), + QueryV1(BroadcastedDeclareTxnV1), /// Query-only broadcasted declare transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000002")] - QueryV2(BroadcastedDeclareTxnV2), + QueryV2(BroadcastedDeclareTxnV2), + /// Query-only broadcasted declare transaction. + #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000003")] + QueryV3(BroadcastedDeclareTxnV3), } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(tag = "version")] -pub enum BroadcastedDeployAccountTxn { +pub enum BroadcastedDeployAccountTxn { #[serde(rename = "0x1")] - V1(DeployAccountTxnV1), + V1(DeployAccountTxnV1), /// Query-only broadcasted deploy account transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000001")] - QueryV1(DeployAccountTxnV1), + QueryV1(DeployAccountTxnV1), + /// Query-only broadcasted deploy account transaction. + #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000003")] + QueryV3(DeployAccountTxnV3), } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(tag = "version")] -pub enum BroadcastedInvokeTxn { +pub enum BroadcastedInvokeTxn { #[serde(rename = "0x0")] - V0(InvokeTxnV0), + V0(InvokeTxnV0), #[serde(rename = "0x1")] - V1(InvokeTxnV1), + V1(InvokeTxnV1), + #[serde(rename = "0x3")] + V3(InvokeTxnV3), + /// Query-only broadcasted invoke transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000000")] - QueryV0(InvokeTxnV0), + QueryV0(InvokeTxnV0), /// Query-only broadcasted invoke transaction. #[serde(rename = "0x0000000000000000000000000000000100000000000000000000000000000001")] - QueryV1(InvokeTxnV1), + 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 2f23e406..d81b57f0 100644 --- a/crates/starknet-types-rpc/src/custom/syncing_status.rs +++ b/crates/starknet-types-rpc/src/custom/syncing_status.rs @@ -1,3 +1,4 @@ +use core::marker::PhantomData; use serde::de::Visitor; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -5,14 +6,14 @@ use crate::SyncStatus; /// The syncing status of a node. #[derive(Clone, Debug)] -pub enum SyncingStatus { +pub enum SyncingStatus { /// The node is not syncing. NotSyncing, /// The node is syncing. - Syncing(SyncStatus), + Syncing(SyncStatus), } -impl Serialize for SyncingStatus { +impl Serialize for SyncingStatus { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -24,15 +25,17 @@ impl Serialize for SyncingStatus { } } -impl<'de> Deserialize<'de> for SyncingStatus { +impl<'de, F: Deserialize<'de>> Deserialize<'de> for SyncingStatus { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct SyncingStatusVisitor; + struct SyncingStatusVisitor { + marker: PhantomData, + } - impl<'de> Visitor<'de> for SyncingStatusVisitor { - type Value = SyncingStatus; + impl<'de, F: Deserialize<'de>> Visitor<'de> for SyncingStatusVisitor { + type Value = SyncingStatus; fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { writeln!(formatter, "a syncing status") @@ -60,22 +63,28 @@ impl<'de> Deserialize<'de> for SyncingStatus { } } - deserializer.deserialize_any(SyncingStatusVisitor) + deserializer.deserialize_any(SyncingStatusVisitor:: { + marker: PhantomData, + }) } } #[cfg(test)] #[test] fn syncing_status_from_false() { + pub use starknet_types_core::felt::Felt; + let s = "false"; - let syncing_status: SyncingStatus = serde_json::from_str(s).unwrap(); + let syncing_status: SyncingStatus = serde_json::from_str(s).unwrap(); assert!(matches!(syncing_status, SyncingStatus::NotSyncing)); } #[cfg(test)] #[test] fn syncing_status_to_false() { - let syncing_status = SyncingStatus::NotSyncing; + pub use starknet_types_core::felt::Felt; + + let syncing_status = SyncingStatus::::NotSyncing; let s = serde_json::to_string(&syncing_status).unwrap(); assert_eq!(s, "false"); } @@ -83,6 +92,7 @@ fn syncing_status_to_false() { #[cfg(test)] #[test] fn syncing_status_from_true() { + pub use starknet_types_core::felt::Felt; let s = "true"; - assert!(serde_json::from_str::(s).is_err()); + 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 a1863264..dfb4ddcd 100644 --- a/crates/starknet-types-rpc/src/lib.rs +++ b/crates/starknet-types-rpc/src/lib.rs @@ -17,13 +17,13 @@ #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; +extern crate core; mod custom; mod custom_serde; // // Generated files. -// -pub mod v0_5_0; +pub mod v0_7_1; -pub use self::v0_5_0::*; +pub use self::v0_7_1::*; diff --git a/crates/starknet-types-rpc/src/v0_7_1/mod.rs b/crates/starknet-types-rpc/src/v0_7_1/mod.rs new file mode 100644 index 00000000..2df2c821 --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/mod.rs @@ -0,0 +1,13 @@ +//! v0.7.1 of the API. +pub use crate::custom::{ + BlockId, BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn, + SyncingStatus, +}; + +mod starknet_api_openrpc; +mod starknet_trace_api_openrpc; +mod starknet_write_api; + +pub use self::starknet_api_openrpc::*; +pub use self::starknet_trace_api_openrpc::*; +pub use self::starknet_write_api::*; diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.json b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.json new file mode 100644 index 00000000..1e7927d7 --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.json @@ -0,0 +1,3990 @@ +{ + "openrpc": "1.0.0-rc1", + "info": { + "version": "0.7.1", + "title": "StarkNet Node API", + "license": {} + }, + "servers": [], + "methods": [ + { + "name": "starknet_specVersion", + "summary": "Returns the version of the Starknet JSON-RPC specification being used", + "params": [], + "result": { + "name": "result", + "description": "Semver of Starknet's JSON-RPC spec being used", + "required": true, + "schema": { + "title": "JSON-RPC spec version", + "type": "string" + } + } + }, + { + "name": "starknet_getBlockWithTxHashes", + "summary": "Get block information with transaction hashes given the block id", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "The resulting block information with transaction hashes", + "schema": { + "title": "Starknet get block hash with tx hashes result", + "oneOf": [ + { + "title": "Block with transaction hashes", + "$ref": "#/components/schemas/BLOCK_WITH_TX_HASHES" + }, + { + "title": "Pending block with transaction hashes", + "$ref": "#/components/schemas/PENDING_BLOCK_WITH_TX_HASHES" + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getBlockWithTxs", + "summary": "Get block information with full transactions given the block id", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "The resulting block information with full transactions", + "schema": { + "title": "Starknet get block with txs result", + "oneOf": [ + { + "title": "Block with transactions", + "$ref": "#/components/schemas/BLOCK_WITH_TXS" + }, + { + "title": "Pending block with transactions", + "$ref": "#/components/schemas/PENDING_BLOCK_WITH_TXS" + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getBlockWithReceipts", + "summary": "Get block information with full transactions and receipts given the block id", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "The resulting block information with full transactions", + "schema": { + "title": "Starknet get block with txs and receipts result", + "oneOf": [ + { + "title": "Block with transactions", + "$ref": "#/components/schemas/BLOCK_WITH_RECEIPTS" + }, + { + "title": "Pending block with transactions", + "$ref": "#/components/schemas/PENDING_BLOCK_WITH_RECEIPTS" + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getStateUpdate", + "summary": "Get the information about the result of executing the requested block", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "The information about the state update of the requested block", + "schema": { + "title": "Starknet get state update result", + "oneOf": [ + { + "title": "State update", + "$ref": "#/components/schemas/STATE_UPDATE" + }, + { + "title": "Pending state update", + "$ref": "#/components/schemas/PENDING_STATE_UPDATE" + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getStorageAt", + "summary": "Get the value of the storage at the given address and key", + "params": [ + { + "name": "contract_address", + "description": "The address of the contract to read from", + "summary": "The address of the contract to read from", + "required": true, + "schema": { + "title": "Address", + "$ref": "#/components/schemas/ADDRESS" + } + }, + { + "name": "key", + "description": "The key to the storage value for the given contract", + "summary": "The key to the storage value for the given contract", + "required": true, + "schema": { + "title": "Storage key", + "$ref": "#/components/schemas/STORAGE_KEY" + } + }, + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "The value at the given key for the given contract. 0 if no value is found", + "summary": "The value at the given key for the given contract.", + "schema": { + "title": "Field element", + "$ref": "#/components/schemas/FELT" + } + }, + "errors": [ + { + "$ref": "#/components/errors/CONTRACT_NOT_FOUND" + }, + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getTransactionStatus", + "summary": "Gets the transaction status (possibly reflecting that the tx is still in the mempool, or dropped from it)", + "paramStructure": "by-name", + "params": [ + { + "name": "transaction_hash", + "summary": "The hash of the requested transaction", + "required": true, + "schema": { + "title": "Transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + } + ], + "result": { + "name": "result", + "schema": { + "title": "Transaction status", + "type": "object", + "properties": { + "finality_status": { + "title": "finality status", + "$ref": "#/components/schemas/TXN_STATUS" + }, + "execution_status": { + "title": "execution status", + "$ref": "#/components/schemas/TXN_EXECUTION_STATUS" + } + }, + "required": [ + "finality_status" + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/TXN_HASH_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getTransactionByHash", + "summary": "Get the details and status of a submitted transaction", + "paramStructure": "by-name", + "params": [ + { + "name": "transaction_hash", + "summary": "The hash of the requested transaction", + "required": true, + "schema": { + "title": "Transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + } + ], + "result": { + "name": "result", + "schema": { + "title": "Transaction", + "allOf": [ + { + "$ref": "#/components/schemas/TXN" + }, + { + "type": "object", + "properties": { + "transaction_hash": { + "title": "transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/TXN_HASH_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getTransactionByBlockIdAndIndex", + "summary": "Get the details of a transaction by a given block id and index", + "description": "Get the details of the transaction given by the identified block and index in that block. If no transaction is found, null is returned.", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + }, + { + "name": "index", + "summary": "The index in the block to search for the transaction", + "required": true, + "schema": { + "title": "Index", + "type": "integer", + "minimum": 0 + } + } + ], + "result": { + "name": "transactionResult", + "schema": { + "title": "Transaction", + "allOf": [ + { + "$ref": "#/components/schemas/TXN" + }, + { + "type": "object", + "properties": { + "transaction_hash": { + "title": "transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + }, + { + "$ref": "#/components/errors/INVALID_TXN_INDEX" + } + ] + }, + { + "name": "starknet_getTransactionReceipt", + "summary": "Get the transaction receipt by the transaction hash", + "paramStructure": "by-name", + "params": [ + { + "name": "transaction_hash", + "summary": "The hash of the requested transaction", + "required": true, + "schema": { + "title": "Transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + } + ], + "result": { + "name": "result", + "schema": { + "title": "Transaction receipt with block info", + "$ref": "#/components/schemas/TXN_RECEIPT_WITH_BLOCK_INFO" + } + }, + "errors": [ + { + "$ref": "#/components/errors/TXN_HASH_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getClass", + "summary": "Get the contract class definition in the given block associated with the given hash", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + }, + { + "name": "class_hash", + "description": "The hash of the requested contract class", + "required": true, + "schema": { + "title": "Field element", + "$ref": "#/components/schemas/FELT" + } + } + ], + "result": { + "name": "result", + "description": "The contract class, if found", + "schema": { + "title": "Starknet get class result", + "oneOf": [ + { + "title": "Deprecated contract class", + "$ref": "#/components/schemas/DEPRECATED_CONTRACT_CLASS" + }, + { + "title": "Contract class", + "$ref": "#/components/schemas/CONTRACT_CLASS" + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + }, + { + "$ref": "#/components/errors/CLASS_HASH_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getClassHashAt", + "summary": "Get the contract class hash in the given block for the contract deployed at the given address", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + }, + { + "name": "contract_address", + "description": "The address of the contract whose class hash will be returned", + "required": true, + "schema": { + "title": "Address", + "$ref": "#/components/schemas/ADDRESS" + } + } + ], + "result": { + "name": "result", + "description": "The class hash of the given contract", + "schema": { + "title": "Field element", + "$ref": "#/components/schemas/FELT" + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + }, + { + "$ref": "#/components/errors/CONTRACT_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getClassAt", + "summary": "Get the contract class definition in the given block at the given address", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + }, + { + "name": "contract_address", + "description": "The address of the contract whose class definition will be returned", + "required": true, + "schema": { + "title": "Address", + "$ref": "#/components/schemas/ADDRESS" + } + } + ], + "result": { + "name": "result", + "description": "The contract class", + "schema": { + "title": "Starknet get class at result", + "oneOf": [ + { + "title": "Deprecated contract class", + "$ref": "#/components/schemas/DEPRECATED_CONTRACT_CLASS" + }, + { + "title": "Contract class", + "$ref": "#/components/schemas/CONTRACT_CLASS" + } + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + }, + { + "$ref": "#/components/errors/CONTRACT_NOT_FOUND" + } + ] + }, + { + "name": "starknet_getBlockTransactionCount", + "summary": "Get the number of transactions in a block given a block id", + "description": "Returns the number of transactions in the designated block.", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "The number of transactions in the designated block", + "summary": "The number of transactions in the designated block", + "schema": { + "title": "Block transaction count", + "type": "integer", + "minimum": 0 + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_call", + "summary": "call a starknet function without creating a StarkNet transaction", + "description": "Calls a function in a contract and returns the return value. Using this call will not create a transaction; hence, will not change the state", + "params": [ + { + "name": "request", + "summary": "The details of the function call", + "schema": { + "title": "Function call", + "$ref": "#/components/schemas/FUNCTION_CALL" + }, + "required": true + }, + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on.", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "summary": "The function's return value", + "description": "The function's return value, as defined in the Cairo output", + "schema": { + "type": "array", + "title": "Field element", + "items": { + "$ref": "#/components/schemas/FELT" + } + } + }, + "errors": [ + { + "$ref": "#/components/errors/CONTRACT_NOT_FOUND" + }, + { + "$ref": "#/components/errors/CONTRACT_ERROR" + }, + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_estimateFee", + "summary": "estimate the fee for of StarkNet transactions", + "description": "Estimates the resources required by a given sequence of transactions when applied on a given state. If one of the transactions reverts or fails due to any reason (e.g. validation failure or an internal error), a TRANSACTION_EXECUTION_ERROR is returned. For v0-2 transactions the estimate is given in wei, and for v3 transactions it is given in fri.", + "params": [ + { + "name": "request", + "summary": "The transaction to estimate", + "schema": { + "type": "array", + "description": "a sequence of transactions to estimate, running each transaction on the state resulting from applying all the previous ones", + "title": "Transaction", + "items": { + "$ref": "#/components/schemas/BROADCASTED_TXN" + } + }, + "required": true + }, + { + "name": "simulation_flags", + "description": "describes what parts of the transaction should be executed", + "required": true, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SIMULATION_FLAG_FOR_ESTIMATE_FEE" + } + } + }, + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on.", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "the fee estimations", + "schema": { + "title": "Estimation", + "type": "array", + "description": "a sequence of fee estimatione where the i'th estimate corresponds to the i'th transaction", + "items": { + "$ref": "#/components/schemas/FEE_ESTIMATE" + } + } + }, + "errors": [ + { + "$ref": "#/components/errors/TRANSACTION_EXECUTION_ERROR" + }, + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_estimateMessageFee", + "summary": "estimate the L2 fee of a message sent on L1", + "description": "estimates the resources required by the l1_handler transaction induced by the message", + "params": [ + { + "name": "message", + "description": "the message's parameters", + "schema": { + "$ref": "#/components/schemas/MSG_FROM_L1" + }, + "required": true + }, + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on.", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "result", + "description": "the fee estimation", + "schema": { + "$ref": "#/components/schemas/FEE_ESTIMATE" + } + }, + "errors": [ + { + "$ref": "#/components/errors/CONTRACT_ERROR" + }, + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + }, + { + "name": "starknet_blockNumber", + "summary": "Get the most recent accepted block number", + "params": [], + "result": { + "name": "result", + "description": "The latest block number", + "schema": { + "title": "Block number", + "$ref": "#/components/schemas/BLOCK_NUMBER" + } + }, + "errors": [ + { + "$ref": "#/components/errors/NO_BLOCKS" + } + ] + }, + { + "name": "starknet_blockHashAndNumber", + "summary": "Get the most recent accepted block hash and number", + "params": [], + "result": { + "name": "result", + "description": "The latest block hash and number", + "schema": { + "title": "Starknet block hash and number result", + "type": "object", + "properties": { + "block_hash": { + "title": "Block hash", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "block_number": { + "title": "Block number", + "$ref": "#/components/schemas/BLOCK_NUMBER" + } + }, + "required": [ + "block_hash", + "block_number" + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/NO_BLOCKS" + } + ] + }, + { + "name": "starknet_chainId", + "summary": "Return the currently configured StarkNet chain id", + "params": [], + "result": { + "name": "result", + "description": "The chain id this node is connected to", + "schema": { + "title": "Chain id", + "$ref": "#/components/schemas/CHAIN_ID" + } + } + }, + { + "name": "starknet_syncing", + "summary": "Returns an object about the sync status, or false if the node is not synching", + "params": [], + "result": { + "name": "syncing", + "summary": "The state of the synchronization, or false if the node is not synchronizing", + "description": "The status of the node, if it is currently synchronizing state. FALSE otherwise", + "schema": { + "title": "SyncingStatus", + "oneOf": [ + { + "type": "boolean", + "title": "False", + "description": "only legal value is FALSE here" + }, + { + "title": "Sync status", + "$ref": "#/components/schemas/SYNC_STATUS" + } + ] + } + } + }, + { + "name": "starknet_getEvents", + "summary": "Returns all events matching the given filter", + "description": "Returns all event objects matching the conditions in the provided filter", + "params": [ + { + "name": "filter", + "summary": "The conditions used to filter the returned events", + "required": true, + "schema": { + "title": "Events request", + "allOf": [ + { + "title": "Event filter", + "$ref": "#/components/schemas/EVENT_FILTER" + }, + { + "title": "Result page request", + "$ref": "#/components/schemas/RESULT_PAGE_REQUEST" + } + ] + } + } + ], + "result": { + "name": "events", + "description": "All the event objects matching the filter", + "schema": { + "title": "Events chunk", + "$ref": "#/components/schemas/EVENTS_CHUNK" + } + }, + "errors": [ + { + "$ref": "#/components/errors/PAGE_SIZE_TOO_BIG" + }, + { + "$ref": "#/components/errors/INVALID_CONTINUATION_TOKEN" + }, + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + }, + { + "$ref": "#/components/errors/TOO_MANY_KEYS_IN_FILTER" + } + ] + }, + { + "name": "starknet_getNonce", + "summary": "Get the nonce associated with the given address in the given block", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "title": "Block id", + "$ref": "#/components/schemas/BLOCK_ID" + } + }, + { + "name": "contract_address", + "description": "The address of the contract whose nonce we're seeking", + "required": true, + "schema": { + "title": "Address", + "$ref": "#/components/schemas/ADDRESS" + } + } + ], + "result": { + "name": "result", + "description": "The contract's nonce at the requested state", + "schema": { + "title": "Field element", + "$ref": "#/components/schemas/FELT" + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + }, + { + "$ref": "#/components/errors/CONTRACT_NOT_FOUND" + } + ] + } + ], + "components": { + "contentDescriptors": {}, + "schemas": { + "EVENTS_CHUNK": { + "title": "Events chunk", + "type": "object", + "properties": { + "events": { + "type": "array", + "title": "Matching Events", + "items": { + "$ref": "#/components/schemas/EMITTED_EVENT" + } + }, + "continuation_token": { + "title": "Continuation token", + "description": "Use this token in a subsequent query to obtain the next page. Should not appear if there are no more pages.", + "type": "string" + } + }, + "required": [ + "events" + ] + }, + "RESULT_PAGE_REQUEST": { + "title": "Result page request", + "type": "object", + "properties": { + "continuation_token": { + "title": "Continuation token", + "description": "The token returned from the previous query. If no token is provided the first page is returned.", + "type": "string" + }, + "chunk_size": { + "title": "Chunk size", + "type": "integer", + "minimum": 1 + } + }, + "required": [ + "chunk_size" + ] + }, + "EMITTED_EVENT": { + "title": "Emitted event", + "description": "Event information decorated with metadata on where it was emitted / An event emitted as a result of transaction execution", + "allOf": [ + { + "title": "Event", + "description": "The event information", + "$ref": "#/components/schemas/EVENT" + }, + { + "title": "Event context", + "description": "The event emission information", + "type": "object", + "properties": { + "block_hash": { + "title": "Block hash", + "description": "The hash of the block in which the event was emitted", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "block_number": { + "title": "Block number", + "description": "The number of the block in which the event was emitted", + "$ref": "#/components/schemas/BLOCK_NUMBER" + }, + "transaction_hash": { + "title": "Transaction hash", + "description": "The transaction that emitted the event", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + ] + }, + "EVENT": { + "title": "Event", + "description": "A StarkNet event", + "allOf": [ + { + "title": "Event emitter", + "type": "object", + "properties": { + "from_address": { + "title": "From address", + "$ref": "#/components/schemas/ADDRESS" + } + }, + "required": [ + "from_address" + ] + }, + { + "title": "Event content", + "$ref": "#/components/schemas/EVENT_CONTENT" + } + ] + }, + "EVENT_CONTENT": { + "title": "Event content", + "description": "The content of an event", + "type": "object", + "properties": { + "keys": { + "type": "array", + "title": "Keys", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "data": { + "type": "array", + "title": "Data", + "items": { + "$ref": "#/components/schemas/FELT" + } + } + }, + "required": [ + "keys", + "data" + ] + }, + "EVENT_FILTER": { + "title": "Event filter", + "description": "An event filter/query", + "type": "object", + "properties": { + "from_block": { + "title": "from block", + "$ref": "#/components/schemas/BLOCK_ID" + }, + "to_block": { + "title": "to block", + "$ref": "#/components/schemas/BLOCK_ID" + }, + "address": { + "title": "from contract", + "$ref": "#/components/schemas/ADDRESS" + }, + "keys": { + "title": "Keys", + "description": "The values used to filter the events", + "type": "array", + "items": { + "title": "Keys", + "description": "Per key (by position), designate the possible values to be matched for events to be returned. Empty array designates 'any' value", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + } + } + } + }, + "required": [] + }, + "BLOCK_ID": { + "title": "Block id", + "description": "Block hash, number or tag", + "oneOf": [ + { + "title": "Block hash", + "type": "object", + "properties": { + "block_hash": { + "title": "Block hash", + "$ref": "#/components/schemas/BLOCK_HASH" + } + }, + "required": [ + "block_hash" + ] + }, + { + "title": "Block number", + "type": "object", + "properties": { + "block_number": { + "title": "Block number", + "$ref": "#/components/schemas/BLOCK_NUMBER" + } + }, + "required": [ + "block_number" + ] + }, + { + "title": "Block tag", + "$ref": "#/components/schemas/BLOCK_TAG" + } + ] + }, + "BLOCK_TAG": { + "title": "Block tag", + "type": "string", + "description": "A tag specifying a dynamic reference to a block", + "enum": [ + "latest", + "pending" + ] + }, + "SYNC_STATUS": { + "title": "Sync status", + "type": "object", + "description": "An object describing the node synchronization status", + "properties": { + "starting_block_hash": { + "title": "Starting block hash", + "description": "The hash of the block from which the sync started", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "starting_block_num": { + "title": "Starting block number", + "description": "The number (height) of the block from which the sync started", + "$ref": "#/components/schemas/BLOCK_NUMBER" + }, + "current_block_hash": { + "title": "Current block hash", + "description": "The hash of the current block being synchronized", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "current_block_num": { + "title": "Current block number", + "description": "The number (height) of the current block being synchronized", + "$ref": "#/components/schemas/BLOCK_NUMBER" + }, + "highest_block_hash": { + "title": "Highest block hash", + "description": "The hash of the estimated highest block to be synchronized", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "highest_block_num": { + "title": "Highest block number", + "description": "The number (height) of the estimated highest block to be synchronized", + "$ref": "#/components/schemas/BLOCK_NUMBER" + } + }, + "required": [ + "starting_block_hash", + "starting_block_num", + "current_block_hash", + "current_block_num", + "highest_block_hash", + "highest_block_num" + ] + }, + "NUM_AS_HEX": { + "title": "Number as hex", + "description": "An integer number in hex format (0x...)", + "type": "string", + "pattern": "^0x[a-fA-F0-9]+$" + }, + "u64": { + "type": "string", + "title": "u64", + "description": "64 bit integers, represented by hex string of length at most 16", + "pattern": "^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,15})$" + }, + "u128": { + "type": "string", + "title": "u128", + "description": "64 bit integers, represented by hex string of length at most 32", + "pattern": "^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,31})$" + }, + "CHAIN_ID": { + "title": "Chain id", + "description": "StarkNet chain id, given in hex representation.", + "type": "string", + "pattern": "^0x[a-fA-F0-9]+$" + }, + "STATE_DIFF": { + "description": "The change in state applied in this block, given as a mapping of addresses to the new values and/or new contracts", + "type": "object", + "properties": { + "storage_diffs": { + "title": "Storage diffs", + "type": "array", + "items": { + "description": "The changes in the storage per contract address", + "$ref": "#/components/schemas/CONTRACT_STORAGE_DIFF_ITEM" + } + }, + "deprecated_declared_classes": { + "title": "Deprecated declared classes", + "type": "array", + "items": { + "description": "The hash of the declared class", + "$ref": "#/components/schemas/FELT" + } + }, + "declared_classes": { + "title": "Declared classes", + "type": "array", + "items": { + "title": "New classes", + "type": "object", + "description": "The declared class hash and compiled class hash", + "properties": { + "class_hash": { + "title": "Class hash", + "description": "The hash of the declared class", + "$ref": "#/components/schemas/FELT" + }, + "compiled_class_hash": { + "title": "Compiled class hash", + "description": "The Cairo assembly hash corresponding to the declared class", + "$ref": "#/components/schemas/FELT" + } + } + } + }, + "deployed_contracts": { + "title": "Deployed contracts", + "type": "array", + "items": { + "description": "A new contract deployed as part of the state update", + "$ref": "#/components/schemas/DEPLOYED_CONTRACT_ITEM" + } + }, + "replaced_classes": { + "title": "Replaced classes", + "type": "array", + "items": { + "description": "The list of contracts whose class was replaced", + "title": "Replaced class", + "type": "object", + "properties": { + "contract_address": { + "title": "Contract address", + "description": "The address of the contract whose class was replaced", + "$ref": "#/components/schemas/ADDRESS" + }, + "class_hash": { + "title": "Class hash", + "description": "The new class hash", + "$ref": "#/components/schemas/FELT" + } + } + } + }, + "nonces": { + "title": "Nonces", + "type": "array", + "items": { + "title": "Nonce update", + "description": "The updated nonce per contract address", + "type": "object", + "properties": { + "contract_address": { + "title": "Contract address", + "description": "The address of the contract", + "$ref": "#/components/schemas/ADDRESS" + }, + "nonce": { + "title": "Nonce", + "description": "The nonce for the given address at the end of the block", + "$ref": "#/components/schemas/FELT" + } + } + } + } + }, + "required": [ + "storage_diffs", + "deprecated_declared_classes", + "declared_classes", + "replaced_classes", + "deployed_contracts", + "nonces" + ] + }, + "PENDING_STATE_UPDATE": { + "title": "Pending state update", + "description": "Pending state update", + "type": "object", + "properties": { + "old_root": { + "title": "Old root", + "description": "The previous global state root", + "$ref": "#/components/schemas/FELT" + }, + "state_diff": { + "title": "State diff", + "$ref": "#/components/schemas/STATE_DIFF" + } + }, + "required": [ + "old_root", + "state_diff" + ], + "additionalProperties": false + }, + "STATE_UPDATE": { + "title": "State update", + "type": "object", + "properties": { + "block_hash": { + "title": "Block hash", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "old_root": { + "title": "Old root", + "description": "The previous global state root", + "$ref": "#/components/schemas/FELT" + }, + "new_root": { + "title": "New root", + "description": "The new global state root", + "$ref": "#/components/schemas/FELT" + }, + "state_diff": { + "title": "State diff", + "$ref": "#/components/schemas/STATE_DIFF" + } + }, + "required": [ + "state_diff", + "block_hash", + "old_root", + "new_root" + ] + }, + "ADDRESS": { + "title": "Address", + "$ref": "#/components/schemas/FELT" + }, + "STORAGE_KEY": { + "type": "string", + "title": "Storage key", + "$comment": "A storage key, represented as a string of hex digits", + "description": "A storage key. Represented as up to 62 hex digits, 3 bits, and 5 leading zeroes.", + "pattern": "^0x(0|[0-7]{1}[a-fA-F0-9]{0,62}$)" + }, + "ETH_ADDRESS": { + "title": "Ethereum address", + "type": "string", + "$comment": "An ethereum address", + "description": "an ethereum address represented as 40 hex digits", + "pattern": "^0x[a-fA-F0-9]{40}$" + }, + "TXN_HASH": { + "$ref": "#/components/schemas/FELT", + "description": "The transaction hash, as assigned in StarkNet", + "title": "Transaction hash" + }, + "FELT": { + "type": "string", + "title": "Field element", + "description": "A field element. represented by at most 63 hex digits", + "pattern": "^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$" + }, + "BLOCK_NUMBER": { + "title": "Block number", + "description": "The block's number (its height)", + "type": "integer", + "minimum": 0 + }, + "BLOCK_HASH": { + "title": "Block hash", + "$ref": "#/components/schemas/FELT" + }, + "BLOCK_BODY_WITH_TX_HASHES": { + "title": "Block body with transaction hashes", + "type": "object", + "properties": { + "transactions": { + "title": "Transaction hashes", + "description": "The hashes of the transactions included in this block", + "type": "array", + "items": { + "description": "The hash of a single transaction", + "$ref": "#/components/schemas/TXN_HASH" + } + } + }, + "required": [ + "transactions" + ] + }, + "BLOCK_BODY_WITH_TXS": { + "title": "Block body with transactions", + "type": "object", + "properties": { + "transactions": { + "title": "Transactions", + "description": "The transactions in this block", + "type": "array", + "items": { + "title": "transactions in block", + "type": "object", + "allOf": [ + { + "title": "transaction", + "$ref": "#/components/schemas/TXN" + }, + { + "type": "object", + "properties": { + "transaction_hash": { + "title": "transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + ] + } + } + }, + "required": [ + "transactions" + ] + }, + "BLOCK_BODY_WITH_RECEIPTS": { + "title": "Block body with transactions and receipts", + "type": "object", + "properties": { + "transactions": { + "title": "Transactions", + "description": "The transactions in this block", + "type": "array", + "items": { + "type": "object", + "title": "transaction and receipt", + "properties": { + "transaction": { + "title": "transaction", + "$ref": "#/components/schemas/TXN" + }, + "receipt": { + "title": "receipt", + "$ref": "#/components/schemas/TXN_RECEIPT" + } + }, + "required": [ + "transaction", + "receipt" + ] + } + } + }, + "required": [ + "transactions" + ] + }, + "BLOCK_HEADER": { + "title": "Block header", + "type": "object", + "properties": { + "block_hash": { + "title": "Block hash", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "parent_hash": { + "title": "Parent hash", + "description": "The hash of this block's parent", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "block_number": { + "title": "Block number", + "description": "The block number (its height)", + "$ref": "#/components/schemas/BLOCK_NUMBER" + }, + "new_root": { + "title": "New root", + "description": "The new global state root", + "$ref": "#/components/schemas/FELT" + }, + "timestamp": { + "title": "Timestamp", + "description": "The time in which the block was created, encoded in Unix time", + "type": "integer", + "minimum": 0 + }, + "sequencer_address": { + "title": "Sequencer address", + "description": "The StarkNet identity of the sequencer submitting this block", + "$ref": "#/components/schemas/FELT" + }, + "l1_gas_price": { + "title": "L1 gas price", + "description": "The price of l1 gas in the block", + "$ref": "#/components/schemas/RESOURCE_PRICE" + }, + "l1_data_gas_price": { + "title": "L1 data gas price", + "description": "The price of l1 data gas in the block", + "$ref": "#/components/schemas/RESOURCE_PRICE" + }, + "l1_da_mode": { + "title": "L1 da mode", + "type": "string", + "description": "specifies whether the data of this block is published via blob data or calldata", + "enum": [ + "BLOB", + "CALLDATA" + ] + }, + "starknet_version": { + "title": "Starknet version", + "description": "Semver of the current Starknet protocol", + "type": "string" + } + }, + "required": [ + "block_hash", + "parent_hash", + "block_number", + "new_root", + "timestamp", + "sequencer_address", + "l1_gas_price", + "l1_data_gas_price", + "l1_da_mode", + "starknet_version" + ] + }, + "PENDING_BLOCK_HEADER": { + "title": "Pending block header", + "type": "object", + "properties": { + "parent_hash": { + "title": "Parent hash", + "description": "The hash of this block's parent", + "$ref": "#/components/schemas/BLOCK_HASH" + }, + "timestamp": { + "title": "Timestamp", + "description": "The time in which the block was created, encoded in Unix time", + "type": "integer", + "minimum": 0 + }, + "sequencer_address": { + "title": "Sequencer address", + "description": "The StarkNet identity of the sequencer submitting this block", + "$ref": "#/components/schemas/FELT" + }, + "l1_gas_price": { + "title": "L1 gas price", + "description": "The price of l1 gas in the block", + "$ref": "#/components/schemas/RESOURCE_PRICE" + }, + "l1_data_gas_price": { + "title": "L1 data gas price", + "description": "The price of l1 data gas in the block", + "$ref": "#/components/schemas/RESOURCE_PRICE" + }, + "l1_da_mode": { + "title": "L1 da mode", + "type": "string", + "description": "specifies whether the data of this block is published via blob data or calldata", + "enum": [ + "BLOB", + "CALLDATA" + ] + }, + "starknet_version": { + "title": "Starknet version", + "description": "Semver of the current Starknet protocol", + "type": "string" + } + }, + "required": [ + "parent_hash", + "timestamp", + "sequencer_address", + "l1_gas_price", + "l1_data_gas_price", + "l1_da_mode", + "starknet_version" + ], + "not": { + "required": [ + "block_hash", + "block_number", + "new_root" + ] + } + }, + "BLOCK_WITH_TX_HASHES": { + "title": "Block with transaction hashes", + "description": "The block object", + "allOf": [ + { + "title": "Block status", + "type": "object", + "properties": { + "status": { + "title": "Status", + "$ref": "#/components/schemas/BLOCK_STATUS" + } + }, + "required": [ + "status" + ] + }, + { + "title": "Block header", + "$ref": "#/components/schemas/BLOCK_HEADER" + }, + { + "title": "Block body with transaction hashes", + "$ref": "#/components/schemas/BLOCK_BODY_WITH_TX_HASHES" + } + ] + }, + "BLOCK_WITH_TXS": { + "title": "Block with transactions", + "description": "The block object", + "allOf": [ + { + "title": "block with txs", + "type": "object", + "properties": { + "status": { + "title": "Status", + "$ref": "#/components/schemas/BLOCK_STATUS" + } + }, + "required": [ + "status" + ] + }, + { + "title": "Block header", + "$ref": "#/components/schemas/BLOCK_HEADER" + }, + { + "title": "Block body with transactions", + "$ref": "#/components/schemas/BLOCK_BODY_WITH_TXS" + } + ] + }, + "BLOCK_WITH_RECEIPTS": { + "title": "Block with transactions and receipts", + "description": "The block object", + "allOf": [ + { + "title": "block with txs", + "type": "object", + "properties": { + "status": { + "title": "Status", + "$ref": "#/components/schemas/BLOCK_STATUS" + } + }, + "required": [ + "status" + ] + }, + { + "title": "Block header", + "$ref": "#/components/schemas/BLOCK_HEADER" + }, + { + "title": "Block body with transactions and receipts", + "$ref": "#/components/schemas/BLOCK_BODY_WITH_RECEIPTS" + } + ] + }, + "PENDING_BLOCK_WITH_TX_HASHES": { + "title": "Pending block with transaction hashes", + "description": "The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization.", + "allOf": [ + { + "title": "Block body with transactions hashes", + "$ref": "#/components/schemas/BLOCK_BODY_WITH_TX_HASHES" + }, + { + "title": "Pending block header", + "$ref": "#/components/schemas/PENDING_BLOCK_HEADER" + } + ] + }, + "PENDING_BLOCK_WITH_TXS": { + "title": "Pending block with transactions", + "description": "The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization.", + "allOf": [ + { + "title": "Block body with transactions", + "$ref": "#/components/schemas/BLOCK_BODY_WITH_TXS" + }, + { + "title": "Pending block header", + "$ref": "#/components/schemas/PENDING_BLOCK_HEADER" + } + ] + }, + "PENDING_BLOCK_WITH_RECEIPTS": { + "title": "Pending block with transactions and receipts", + "description": "The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization.", + "allOf": [ + { + "title": "Block body with transactions and receipts", + "$ref": "#/components/schemas/BLOCK_BODY_WITH_RECEIPTS" + }, + { + "title": "Pending block header", + "$ref": "#/components/schemas/PENDING_BLOCK_HEADER" + } + ] + }, + "DEPLOYED_CONTRACT_ITEM": { + "title": "Deployed contract item", + "type": "object", + "properties": { + "address": { + "title": "Address", + "description": "The address of the contract", + "$ref": "#/components/schemas/FELT" + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the contract code", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "address", + "class_hash" + ] + }, + "CONTRACT_STORAGE_DIFF_ITEM": { + "title": "Contract storage diff item", + "type": "object", + "properties": { + "address": { + "title": "Address", + "description": "The contract address for which the storage changed", + "$ref": "#/components/schemas/FELT" + }, + "storage_entries": { + "title": "Storage entries", + "description": "The changes in the storage of the contract", + "type": "array", + "items": { + "title": "Storage diff item", + "type": "object", + "properties": { + "key": { + "title": "Key", + "description": "The key of the changed value", + "$ref": "#/components/schemas/FELT" + }, + "value": { + "title": "Value", + "description": "The new value applied to the given address", + "$ref": "#/components/schemas/FELT" + } + } + } + } + }, + "required": [ + "address", + "storage_entries" + ] + }, + "TXN": { + "title": "Transaction", + "description": "The transaction schema, as it appears inside a block", + "oneOf": [ + { + "title": "Invoke transaction", + "$ref": "#/components/schemas/INVOKE_TXN" + }, + { + "title": "L1 handler transaction", + "$ref": "#/components/schemas/L1_HANDLER_TXN" + }, + { + "title": "Declare transaction", + "$ref": "#/components/schemas/DECLARE_TXN" + }, + { + "title": "Deploy transaction", + "$ref": "#/components/schemas/DEPLOY_TXN" + }, + { + "title": "Deploy account transaction", + "$ref": "#/components/schemas/DEPLOY_ACCOUNT_TXN" + } + ] + }, + "SIGNATURE": { + "title": "Signature", + "description": "A transaction signature", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "DECLARE_TXN": { + "title": "Declare transaction", + "oneOf": [ + { + "title": "Declare transaction V0", + "$ref": "#/components/schemas/DECLARE_TXN_V0" + }, + { + "title": "Declare transaction V1", + "$ref": "#/components/schemas/DECLARE_TXN_V1" + }, + { + "title": "Declare transaction V2", + "$ref": "#/components/schemas/DECLARE_TXN_V2" + }, + { + "title": "Declare transaction V3", + "$ref": "#/components/schemas/DECLARE_TXN_V3" + } + ] + }, + "DECLARE_TXN_V0": { + "title": "Declare Contract Transaction V0", + "description": "Declare Contract Transaction V0", + "allOf": [ + { + "type": "object", + "title": "Declare txn v0", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + }, + "sender_address": { + "title": "Sender address", + "description": "The address of the account contract sending the declaration transaction", + "$ref": "#/components/schemas/ADDRESS" + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x0", + "0x100000000000000000000000000000000" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the declared class", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "type", + "sender_address", + "max_fee", + "version", + "signature", + "class_hash" + ] + } + ] + }, + "DECLARE_TXN_V1": { + "title": "Declare Contract Transaction V1", + "description": "Declare Contract Transaction V1", + "allOf": [ + { + "type": "object", + "title": "Declare txn v1", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + }, + "sender_address": { + "title": "Sender address", + "description": "The address of the account contract sending the declaration transaction", + "$ref": "#/components/schemas/ADDRESS" + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x1", + "0x100000000000000000000000000000001" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the declared class", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "type", + "sender_address", + "max_fee", + "version", + "signature", + "nonce", + "class_hash" + ] + } + ] + }, + "DECLARE_TXN_V2": { + "title": "Declare Transaction V2", + "description": "Declare Contract Transaction V2", + "allOf": [ + { + "type": "object", + "title": "Declare txn v2", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + }, + "sender_address": { + "title": "Sender address", + "description": "The address of the account contract sending the declaration transaction", + "$ref": "#/components/schemas/ADDRESS" + }, + "compiled_class_hash": { + "title": "Compiled class hash", + "description": "The hash of the Cairo assembly resulting from the Sierra compilation", + "$ref": "#/components/schemas/FELT" + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x2", + "0x100000000000000000000000000000002" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the declared class", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "type", + "sender_address", + "compiled_class_hash", + "max_fee", + "version", + "signature", + "nonce", + "class_hash" + ] + } + ] + }, + "DECLARE_TXN_V3": { + "title": "Declare Transaction V3", + "description": "Declare Contract Transaction V3", + "allOf": [ + { + "type": "object", + "title": "Declare txn v3", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + }, + "sender_address": { + "title": "Sender address", + "description": "The address of the account contract sending the declaration transaction", + "$ref": "#/components/schemas/ADDRESS" + }, + "compiled_class_hash": { + "title": "Compiled class hash", + "description": "The hash of the Cairo assembly resulting from the Sierra compilation", + "$ref": "#/components/schemas/FELT" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x3", + "0x100000000000000000000000000000003" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the declared class", + "$ref": "#/components/schemas/FELT" + }, + "resource_bounds": { + "title": "Resource bounds", + "description": "resource bounds for the transaction execution", + "$ref": "#/components/schemas/RESOURCE_BOUNDS_MAPPING" + }, + "tip": { + "title": "Tip", + "$ref": "#/components/schemas/u64", + "description": "the tip for the transaction" + }, + "paymaster_data": { + "title": "Paymaster data", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + }, + "description": "data needed to allow the paymaster to pay for the transaction in native tokens" + }, + "account_deployment_data": { + "title": "Account deployment data", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + }, + "description": "data needed to deploy the account contract from which this tx will be initiated" + }, + "nonce_data_availability_mode": { + "title": "Nonce DA mode", + "description": "The storage domain of the account's nonce (an account has a nonce per DA mode)", + "$ref": "#/components/schemas/DA_MODE" + }, + "fee_data_availability_mode": { + "title": "Fee DA mode", + "description": "The storage domain of the account's balance from which fee will be charged", + "$ref": "#/components/schemas/DA_MODE" + } + }, + "required": [ + "type", + "sender_address", + "compiled_class_hash", + "version", + "signature", + "nonce", + "class_hash", + "resource_bounds", + "tip", + "paymaster_data", + "account_deployment_data", + "nonce_data_availability_mode", + "fee_data_availability_mode" + ] + } + ] + }, + "BROADCASTED_TXN": { + "oneOf": [ + { + "$ref": "#/components/schemas/BROADCASTED_INVOKE_TXN" + }, + { + "$ref": "#/components/schemas/BROADCASTED_DECLARE_TXN" + }, + { + "$ref": "#/components/schemas/BROADCASTED_DEPLOY_ACCOUNT_TXN" + } + ] + }, + "BROADCASTED_INVOKE_TXN": { + "title": "Broadcasted invoke transaction", + "$ref": "#/components/schemas/INVOKE_TXN" + }, + "BROADCASTED_DEPLOY_ACCOUNT_TXN": { + "title": "Broadcasted deploy account transaction", + "$ref": "#/components/schemas/DEPLOY_ACCOUNT_TXN" + }, + "BROADCASTED_DECLARE_TXN": { + "title": "Broadcasted declare transaction", + "oneOf": [ + { + "title": "Broadcasted declare transaction V1", + "$ref": "#/components/schemas/BROADCASTED_DECLARE_TXN_V1" + }, + { + "title": "Broadcasted declare transaction V2", + "$ref": "#/components/schemas/BROADCASTED_DECLARE_TXN_V2" + }, + { + "title": "Broadcasted declare transaction V3", + "$ref": "#/components/schemas/BROADCASTED_DECLARE_TXN_V3" + } + ] + }, + "BROADCASTED_DECLARE_TXN_V1": { + "title": "Broadcasted declare contract transaction V1", + "allOf": [ + { + "type": "object", + "title": "Declare txn v1", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + }, + "sender_address": { + "title": "Sender address", + "description": "The address of the account contract sending the declaration transaction", + "$ref": "#/components/schemas/ADDRESS" + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x1", + "0x100000000000000000000000000000001" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "contract_class": { + "title": "Contract class", + "description": "The class to be declared", + "$ref": "#/components/schemas/DEPRECATED_CONTRACT_CLASS" + } + }, + "required": [ + "type", + "sender_address", + "max_fee", + "version", + "signature", + "nonce", + "contract_class" + ] + } + ] + }, + "BROADCASTED_DECLARE_TXN_V2": { + "title": "Broadcasted declare Transaction V2", + "description": "Broadcasted declare Contract Transaction V2", + "allOf": [ + { + "type": "object", + "title": "Declare txn v2", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + }, + "sender_address": { + "title": "Sender address", + "description": "The address of the account contract sending the declaration transaction", + "$ref": "#/components/schemas/ADDRESS" + }, + "compiled_class_hash": { + "title": "Compiled class hash", + "description": "The hash of the Cairo assembly resulting from the Sierra compilation", + "$ref": "#/components/schemas/FELT" + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x2", + "0x100000000000000000000000000000002" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "contract_class": { + "title": "Contract class", + "description": "The class to be declared", + "$ref": "#/components/schemas/CONTRACT_CLASS" + } + }, + "required": [ + "type", + "sender_address", + "compiled_class_hash", + "max_fee", + "version", + "signature", + "nonce", + "contract_class" + ] + } + ] + }, + "BROADCASTED_DECLARE_TXN_V3": { + "title": "Broadcasted declare Transaction V3", + "description": "Broadcasted declare Contract Transaction V3", + "allOf": [ + { + "type": "object", + "title": "Declare txn v3", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + }, + "sender_address": { + "title": "Sender address", + "description": "The address of the account contract sending the declaration transaction", + "$ref": "#/components/schemas/ADDRESS" + }, + "compiled_class_hash": { + "title": "Compiled class hash", + "description": "The hash of the Cairo assembly resulting from the Sierra compilation", + "$ref": "#/components/schemas/FELT" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x3", + "0x100000000000000000000000000000003" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "contract_class": { + "title": "Contract class", + "description": "The class to be declared", + "$ref": "#/components/schemas/CONTRACT_CLASS" + }, + "resource_bounds": { + "title": "Resource bounds", + "description": "resource bounds for the transaction execution", + "$ref": "#/components/schemas/RESOURCE_BOUNDS_MAPPING" + }, + "tip": { + "title": "Tip", + "$ref": "#/components/schemas/u64", + "description": "the tip for the transaction" + }, + "paymaster_data": { + "title": "Paymaster data", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + }, + "description": "data needed to allow the paymaster to pay for the transaction in native tokens" + }, + "account_deployment_data": { + "title": "Account deployment data", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + }, + "description": "data needed to deploy the account contract from which this tx will be initiated" + }, + "nonce_data_availability_mode": { + "title": "Nonce DA mode", + "description": "The storage domain of the account's nonce (an account has a nonce per DA mode)", + "$ref": "#/components/schemas/DA_MODE" + }, + "fee_data_availability_mode": { + "title": "Fee DA mode", + "description": "The storage domain of the account's balance from which fee will be charged", + "$ref": "#/components/schemas/DA_MODE" + } + }, + "required": [ + "type", + "sender_address", + "compiled_class_hash", + "version", + "signature", + "nonce", + "contract_class", + "resource_bounds", + "tip", + "paymaster_data", + "account_deployment_data", + "nonce_data_availability_mode", + "fee_data_availability_mode" + ] + } + ] + }, + "DEPLOY_ACCOUNT_TXN": { + "title": "Deploy account transaction", + "description": "deploys a new account contract", + "oneOf": [ + { + "title": "Deploy account V1", + "$ref": "#/components/schemas/DEPLOY_ACCOUNT_TXN_V1" + }, + { + "title": "Deploy account V3", + "$ref": "#/components/schemas/DEPLOY_ACCOUNT_TXN_V3" + } + ] + }, + "DEPLOY_ACCOUNT_TXN_V1": { + "title": "Deploy account transaction", + "description": "Deploys an account contract, charges fee from the pre-funded account addresses", + "type": "object", + "properties": { + "type": { + "title": "Deploy account", + "type": "string", + "enum": [ + "DEPLOY_ACCOUNT" + ] + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x1", + "0x100000000000000000000000000000001" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "contract_address_salt": { + "title": "Contract address salt", + "description": "The salt for the address of the deployed contract", + "$ref": "#/components/schemas/FELT" + }, + "constructor_calldata": { + "type": "array", + "description": "The parameters passed to the constructor", + "title": "Constructor calldata", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the deployed contract's class", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "max_fee", + "version", + "signature", + "nonce", + "type", + "contract_address_salt", + "constructor_calldata", + "class_hash" + ] + }, + "DEPLOY_ACCOUNT_TXN_V3": { + "title": "Deploy account transaction", + "description": "Deploys an account contract, charges fee from the pre-funded account addresses", + "type": "object", + "properties": { + "type": { + "title": "Deploy account", + "type": "string", + "enum": [ + "DEPLOY_ACCOUNT" + ] + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x3", + "0x100000000000000000000000000000003" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "contract_address_salt": { + "title": "Contract address salt", + "description": "The salt for the address of the deployed contract", + "$ref": "#/components/schemas/FELT" + }, + "constructor_calldata": { + "type": "array", + "description": "The parameters passed to the constructor", + "title": "Constructor calldata", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the deployed contract's class", + "$ref": "#/components/schemas/FELT" + }, + "resource_bounds": { + "title": "Resource bounds", + "description": "resource bounds for the transaction execution", + "$ref": "#/components/schemas/RESOURCE_BOUNDS_MAPPING" + }, + "tip": { + "title": "Tip", + "$ref": "#/components/schemas/u64", + "description": "the tip for the transaction" + }, + "paymaster_data": { + "title": "Paymaster data", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + }, + "description": "data needed to allow the paymaster to pay for the transaction in native tokens" + }, + "nonce_data_availability_mode": { + "title": "Nonce DA mode", + "description": "The storage domain of the account's nonce (an account has a nonce per DA mode)", + "$ref": "#/components/schemas/DA_MODE" + }, + "fee_data_availability_mode": { + "title": "Fee DA mode", + "description": "The storage domain of the account's balance from which fee will be charged", + "$ref": "#/components/schemas/DA_MODE" + } + }, + "required": [ + "version", + "signature", + "nonce", + "type", + "contract_address_salt", + "constructor_calldata", + "class_hash", + "resource_bounds", + "tip", + "paymaster_data", + "nonce_data_availability_mode", + "fee_data_availability_mode" + ] + }, + "DEPLOY_TXN": { + "title": "Deploy Contract Transaction", + "description": "The structure of a deploy transaction. Note that this transaction type is deprecated and will no longer be supported in future versions", + "allOf": [ + { + "type": "object", + "title": "Deploy txn", + "properties": { + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "$ref": "#/components/schemas/FELT" + }, + "type": { + "title": "Deploy", + "type": "string", + "enum": [ + "DEPLOY" + ] + }, + "contract_address_salt": { + "description": "The salt for the address of the deployed contract", + "title": "Contract address salt", + "$ref": "#/components/schemas/FELT" + }, + "constructor_calldata": { + "type": "array", + "title": "Constructor calldata", + "description": "The parameters passed to the constructor", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the deployed contract's class", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "version", + "type", + "constructor_calldata", + "contract_address_salt", + "class_hash" + ] + } + ] + }, + "INVOKE_TXN_V0": { + "title": "Invoke transaction V0", + "description": "invokes a specific function in the desired contract (not necessarily an account)", + "type": "object", + "properties": { + "type": { + "title": "Type", + "type": "string", + "enum": [ + "INVOKE" + ] + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x0", + "0x100000000000000000000000000000000" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "contract_address": { + "title": "Contract address", + "$ref": "#/components/schemas/ADDRESS" + }, + "entry_point_selector": { + "title": "Entry point selector", + "$ref": "#/components/schemas/FELT" + }, + "calldata": { + "title": "Calldata", + "type": "array", + "description": "The parameters passed to the function", + "items": { + "$ref": "#/components/schemas/FELT" + } + } + }, + "required": [ + "type", + "contract_address", + "entry_point_selector", + "calldata", + "max_fee", + "version", + "signature" + ] + }, + "INVOKE_TXN_V1": { + "title": "Invoke transaction V1", + "description": "initiates a transaction from a given account", + "allOf": [ + { + "type": "object", + "properties": { + "type": { + "title": "Type", + "type": "string", + "enum": [ + "INVOKE" + ] + }, + "sender_address": { + "title": "sender address", + "$ref": "#/components/schemas/ADDRESS" + }, + "calldata": { + "type": "array", + "title": "calldata", + "description": "The data expected by the account's `execute` function (in most usecases, this includes the called contract address and a function selector)", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "max_fee": { + "title": "Max fee", + "$ref": "#/components/schemas/FELT", + "description": "The maximal fee that can be charged for including the transaction" + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x1", + "0x100000000000000000000000000000001" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "type", + "sender_address", + "calldata", + "max_fee", + "version", + "signature", + "nonce" + ] + } + ] + }, + "INVOKE_TXN_V3": { + "title": "Invoke transaction V3", + "description": "initiates a transaction from a given account", + "allOf": [ + { + "type": "object", + "properties": { + "type": { + "title": "Type", + "type": "string", + "enum": [ + "INVOKE" + ] + }, + "sender_address": { + "title": "sender address", + "$ref": "#/components/schemas/ADDRESS" + }, + "calldata": { + "type": "array", + "title": "calldata", + "description": "The data expected by the account's `execute` function (in most usecases, this includes the called contract address and a function selector)", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x3", + "0x100000000000000000000000000000003" + ] + }, + "signature": { + "title": "Signature", + "$ref": "#/components/schemas/SIGNATURE" + }, + "nonce": { + "title": "Nonce", + "$ref": "#/components/schemas/FELT" + }, + "resource_bounds": { + "title": "Resource bounds", + "description": "resource bounds for the transaction execution", + "$ref": "#/components/schemas/RESOURCE_BOUNDS_MAPPING" + }, + "tip": { + "title": "Tip", + "$ref": "#/components/schemas/u64", + "description": "the tip for the transaction" + }, + "paymaster_data": { + "title": "Paymaster data", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + }, + "description": "data needed to allow the paymaster to pay for the transaction in native tokens" + }, + "account_deployment_data": { + "title": "Account deployment data", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + }, + "description": "data needed to deploy the account contract from which this tx will be initiated" + }, + "nonce_data_availability_mode": { + "title": "Nonce DA mode", + "description": "The storage domain of the account's nonce (an account has a nonce per DA mode)", + "$ref": "#/components/schemas/DA_MODE" + }, + "fee_data_availability_mode": { + "title": "Fee DA mode", + "description": "The storage domain of the account's balance from which fee will be charged", + "$ref": "#/components/schemas/DA_MODE" + } + }, + "required": [ + "type", + "sender_address", + "calldata", + "version", + "signature", + "nonce", + "resource_bounds", + "tip", + "paymaster_data", + "account_deployment_data", + "nonce_data_availability_mode", + "fee_data_availability_mode" + ] + } + ] + }, + "INVOKE_TXN": { + "title": "Invoke transaction", + "description": "Initiate a transaction from an account", + "oneOf": [ + { + "title": "Invoke transaction V0", + "$ref": "#/components/schemas/INVOKE_TXN_V0" + }, + { + "title": "Invoke transaction V1", + "$ref": "#/components/schemas/INVOKE_TXN_V1" + }, + { + "title": "Invoke transaction V3", + "$ref": "#/components/schemas/INVOKE_TXN_V3" + } + ] + }, + "L1_HANDLER_TXN": { + "title": "L1 Handler transaction", + "allOf": [ + { + "type": "object", + "title": "L1 handler transaction", + "description": "a call to an l1_handler on an L2 contract induced by a message from L1", + "properties": { + "version": { + "title": "Version", + "description": "Version of the transaction scheme", + "type": "string", + "enum": [ + "0x0" + ] + }, + "type": { + "title": "type", + "type": "string", + "enum": [ + "L1_HANDLER" + ] + }, + "nonce": { + "title": "Nonce", + "description": "The L1->L2 message nonce field of the SN Core L1 contract at the time the transaction was sent", + "$ref": "#/components/schemas/NUM_AS_HEX" + } + }, + "required": [ + "version", + "type", + "nonce" + ] + }, + { + "title": "Function call", + "$ref": "#/components/schemas/FUNCTION_CALL" + } + ] + }, + "COMMON_RECEIPT_PROPERTIES": { + "allOf": [ + { + "title": "Common receipt properties", + "description": "Common properties for a transaction receipt", + "type": "object", + "properties": { + "transaction_hash": { + "title": "Transaction hash", + "$ref": "#/components/schemas/TXN_HASH", + "description": "The hash identifying the transaction" + }, + "actual_fee": { + "title": "Actual fee", + "$ref": "#/components/schemas/FEE_PAYMENT", + "description": "The fee that was charged by the sequencer" + }, + "finality_status": { + "title": "Finality status", + "description": "finality status of the tx", + "$ref": "#/components/schemas/TXN_FINALITY_STATUS" + }, + "messages_sent": { + "type": "array", + "title": "Messages sent", + "items": { + "$ref": "#/components/schemas/MSG_TO_L1" + } + }, + "events": { + "description": "The events emitted as part of this transaction", + "title": "Events", + "type": "array", + "items": { + "$ref": "#/components/schemas/EVENT" + } + }, + "execution_resources": { + "title": "Execution resources", + "description": "The resources consumed by the transaction", + "$ref": "#/components/schemas/EXECUTION_RESOURCES" + } + }, + "required": [ + "transaction_hash", + "actual_fee", + "finality_status", + "messages_sent", + "events", + "execution_resources" + ] + }, + { + "oneOf": [ + { + "title": "Successful Common receipt properties", + "description": "Common properties for a transaction receipt that was executed successfully", + "type": "object", + "properties": { + "execution_status": { + "title": "Execution status", + "type": "string", + "enum": [ + "SUCCEEDED" + ], + "description": "The execution status of the transaction" + } + }, + "required": [ + "execution_status" + ] + }, + { + "title": "Reverted Common receipt properties", + "description": "Common properties for a transaction receipt that was reverted", + "type": "object", + "properties": { + "execution_status": { + "title": "Execution status", + "type": "string", + "enum": [ + "REVERTED" + ], + "description": "The execution status of the transaction" + }, + "revert_reason": { + "title": "Revert reason", + "name": "revert reason", + "description": "the revert reason for the failed execution", + "type": "string" + } + }, + "required": [ + "execution_status", + "revert_reason" + ] + } + ] + } + ] + }, + "INVOKE_TXN_RECEIPT": { + "title": "Invoke Transaction Receipt", + "allOf": [ + { + "title": "Type", + "type": "object", + "properties": { + "type": { + "title": "Type", + "type": "string", + "enum": [ + "INVOKE" + ] + } + }, + "required": [ + "type" + ] + }, + { + "title": "Common receipt properties", + "$ref": "#/components/schemas/COMMON_RECEIPT_PROPERTIES" + } + ] + }, + "DECLARE_TXN_RECEIPT": { + "title": "Declare Transaction Receipt", + "allOf": [ + { + "title": "Declare txn receipt", + "type": "object", + "properties": { + "type": { + "title": "Declare", + "type": "string", + "enum": [ + "DECLARE" + ] + } + }, + "required": [ + "type" + ] + }, + { + "title": "Common receipt properties", + "$ref": "#/components/schemas/COMMON_RECEIPT_PROPERTIES" + } + ] + }, + "DEPLOY_ACCOUNT_TXN_RECEIPT": { + "title": "Deploy Account Transaction Receipt", + "allOf": [ + { + "title": "Common receipt properties", + "$ref": "#/components/schemas/COMMON_RECEIPT_PROPERTIES" + }, + { + "title": "DeployAccount txn receipt", + "type": "object", + "properties": { + "type": { + "title": "Deploy account", + "type": "string", + "enum": [ + "DEPLOY_ACCOUNT" + ] + }, + "contract_address": { + "title": "Contract address", + "description": "The address of the deployed contract", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "type", + "contract_address" + ] + } + ] + }, + "DEPLOY_TXN_RECEIPT": { + "title": "Deploy Transaction Receipt", + "allOf": [ + { + "title": "Common receipt properties", + "$ref": "#/components/schemas/COMMON_RECEIPT_PROPERTIES" + }, + { + "title": "Deploy txn receipt", + "type": "object", + "properties": { + "type": { + "title": "Deploy", + "type": "string", + "enum": [ + "DEPLOY" + ] + }, + "contract_address": { + "title": "Contract address", + "description": "The address of the deployed contract", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "type", + "contract_address" + ] + } + ] + }, + "L1_HANDLER_TXN_RECEIPT": { + "title": "L1 Handler Transaction Receipt", + "description": "receipt for l1 handler transaction", + "allOf": [ + { + "title": "Transaction type", + "type": "object", + "properties": { + "type": { + "title": "type", + "type": "string", + "enum": [ + "L1_HANDLER" + ] + }, + "message_hash": { + "title": "Message hash", + "description": "The message hash as it appears on the L1 core contract", + "$ref": "#/components/schemas/NUM_AS_HEX" + } + }, + "required": [ + "type", + "message_hash" + ] + }, + { + "title": "Common receipt properties", + "$ref": "#/components/schemas/COMMON_RECEIPT_PROPERTIES" + } + ] + }, + "TXN_RECEIPT": { + "title": "Transaction Receipt", + "oneOf": [ + { + "title": "Invoke transaction receipt", + "$ref": "#/components/schemas/INVOKE_TXN_RECEIPT" + }, + { + "title": "L1 handler transaction receipt", + "$ref": "#/components/schemas/L1_HANDLER_TXN_RECEIPT" + }, + { + "title": "Declare transaction receipt", + "$ref": "#/components/schemas/DECLARE_TXN_RECEIPT" + }, + { + "title": "Deploy transaction receipt", + "$ref": "#/components/schemas/DEPLOY_TXN_RECEIPT" + }, + { + "title": "Deploy account transaction receipt", + "$ref": "#/components/schemas/DEPLOY_ACCOUNT_TXN_RECEIPT" + } + ] + }, + "TXN_RECEIPT_WITH_BLOCK_INFO": { + "title": "Transaction receipt with block info", + "allOf": [ + { + "title": "Transaction receipt", + "$ref": "#/components/schemas/TXN_RECEIPT" + }, + { + "type": "object", + "properties": { + "block_hash": { + "title": "Block hash", + "$ref": "#/components/schemas/BLOCK_HASH", + "description": "If this field is missing, it means the receipt belongs to the pending block" + }, + "block_number": { + "title": "Block number", + "$ref": "#/components/schemas/BLOCK_NUMBER", + "description": "If this field is missing, it means the receipt belongs to the pending block" + } + } + } + ] + }, + "MSG_TO_L1": { + "title": "Message to L1", + "type": "object", + "properties": { + "from_address": { + "description": "The address of the L2 contract sending the message", + "$ref": "#/components/schemas/FELT" + }, + "to_address": { + "title": "To address", + "description": "The target L1 address the message is sent to", + "$ref": "#/components/schemas/FELT" + }, + "payload": { + "description": "The payload of the message", + "title": "Payload", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + } + } + }, + "required": [ + "from_address", + "to_address", + "payload" + ] + }, + "MSG_FROM_L1": { + "title": "Message from L1", + "type": "object", + "properties": { + "from_address": { + "description": "The address of the L1 contract sending the message", + "$ref": "#/components/schemas/ETH_ADDRESS" + }, + "to_address": { + "title": "To address", + "description": "The target L2 address the message is sent to", + "$ref": "#/components/schemas/ADDRESS" + }, + "entry_point_selector": { + "title": "Selector", + "description": "The selector of the l1_handler in invoke in the target contract", + "$ref": "#/components/schemas/FELT" + }, + "payload": { + "description": "The payload of the message", + "title": "Payload", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + } + } + }, + "required": [ + "from_address", + "to_address", + "payload", + "entry_point_selector" + ] + }, + "TXN_STATUS": { + "title": "Transaction status", + "type": "string", + "enum": [ + "RECEIVED", + "REJECTED", + "ACCEPTED_ON_L2", + "ACCEPTED_ON_L1" + ], + "description": "The finality status of the transaction, including the case the txn is still in the mempool or failed validation during the block construction phase" + }, + "TXN_FINALITY_STATUS": { + "title": "Finality status", + "type": "string", + "enum": [ + "ACCEPTED_ON_L2", + "ACCEPTED_ON_L1" + ], + "description": "The finality status of the transaction" + }, + "TXN_EXECUTION_STATUS": { + "title": "Execution status", + "type": "string", + "enum": [ + "SUCCEEDED", + "REVERTED" + ], + "description": "The execution status of the transaction" + }, + "TXN_TYPE": { + "title": "Transaction type", + "type": "string", + "enum": [ + "DECLARE", + "DEPLOY", + "DEPLOY_ACCOUNT", + "INVOKE", + "L1_HANDLER" + ], + "description": "The type of the transaction" + }, + "BLOCK_STATUS": { + "title": "Block status", + "type": "string", + "enum": [ + "PENDING", + "ACCEPTED_ON_L2", + "ACCEPTED_ON_L1", + "REJECTED" + ], + "description": "The status of the block" + }, + "FUNCTION_CALL": { + "title": "Function call", + "type": "object", + "description": "Function call information", + "properties": { + "contract_address": { + "title": "Contract address", + "$ref": "#/components/schemas/ADDRESS" + }, + "entry_point_selector": { + "title": "Entry point selector", + "$ref": "#/components/schemas/FELT" + }, + "calldata": { + "title": "Calldata", + "type": "array", + "description": "The parameters passed to the function", + "items": { + "$ref": "#/components/schemas/FELT" + } + } + }, + "required": [ + "contract_address", + "entry_point_selector", + "calldata" + ] + }, + "CONTRACT_CLASS": { + "title": "Contract class", + "type": "object", + "properties": { + "sierra_program": { + "title": "Sierra program", + "type": "array", + "description": "The list of Sierra instructions of which the program consists", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "contract_class_version": { + "title": "Contract class version", + "type": "string", + "description": "The version of the contract class object. Currently, the Starknet OS supports version 0.1.0" + }, + "entry_points_by_type": { + "title": "Entry points by type", + "type": "object", + "properties": { + "CONSTRUCTOR": { + "type": "array", + "title": "Constructor", + "items": { + "$ref": "#/components/schemas/SIERRA_ENTRY_POINT" + } + }, + "EXTERNAL": { + "title": "External", + "type": "array", + "items": { + "$ref": "#/components/schemas/SIERRA_ENTRY_POINT" + } + }, + "L1_HANDLER": { + "title": "L1 handler", + "type": "array", + "items": { + "$ref": "#/components/schemas/SIERRA_ENTRY_POINT" + } + } + }, + "required": [ + "CONSTRUCTOR", + "EXTERNAL", + "L1_HANDLER" + ] + }, + "abi": { + "title": "ABI", + "type": "string", + "description": "The class ABI, as supplied by the user declaring the class" + } + }, + "required": [ + "sierra_program", + "contract_class_version", + "entry_points_by_type" + ] + }, + "DEPRECATED_CONTRACT_CLASS": { + "title": "Deprecated contract class", + "description": "The definition of a StarkNet contract class", + "type": "object", + "properties": { + "program": { + "type": "string", + "title": "Program", + "description": "A base64 representation of the compressed program code", + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$" + }, + "entry_points_by_type": { + "type": "object", + "title": "Deprecated entry points by type", + "properties": { + "CONSTRUCTOR": { + "type": "array", + "title": "Deprecated constructor", + "items": { + "$ref": "#/components/schemas/DEPRECATED_CAIRO_ENTRY_POINT" + } + }, + "EXTERNAL": { + "type": "array", + "title": "Deprecated external", + "items": { + "$ref": "#/components/schemas/DEPRECATED_CAIRO_ENTRY_POINT" + } + }, + "L1_HANDLER": { + "type": "array", + "title": "Deprecated L1 handler", + "items": { + "$ref": "#/components/schemas/DEPRECATED_CAIRO_ENTRY_POINT" + } + } + } + }, + "abi": { + "title": "Contract ABI", + "$ref": "#/components/schemas/CONTRACT_ABI" + } + }, + "required": [ + "program", + "entry_points_by_type" + ] + }, + "DEPRECATED_CAIRO_ENTRY_POINT": { + "title": "Deprecated Cairo entry point", + "type": "object", + "properties": { + "offset": { + "title": "Offset", + "description": "The offset of the entry point in the program", + "$ref": "#/components/schemas/NUM_AS_HEX" + }, + "selector": { + "title": "Selector", + "description": "A unique identifier of the entry point (function) in the program", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "offset", + "selector" + ] + }, + "SIERRA_ENTRY_POINT": { + "title": "Sierra entry point", + "type": "object", + "properties": { + "selector": { + "title": "Selector", + "description": "A unique identifier of the entry point (function) in the program", + "$ref": "#/components/schemas/FELT" + }, + "function_idx": { + "title": "Function index", + "description": "The index of the function in the program", + "type": "integer" + } + }, + "required": [ + "selector", + "function_idx" + ] + }, + "CONTRACT_ABI": { + "title": "Contract ABI", + "type": "array", + "items": { + "$ref": "#/components/schemas/CONTRACT_ABI_ENTRY" + } + }, + "CONTRACT_ABI_ENTRY": { + "title": "Contract ABI entry", + "oneOf": [ + { + "title": "Function ABI entry", + "$ref": "#/components/schemas/FUNCTION_ABI_ENTRY" + }, + { + "title": "Event ABI entry", + "$ref": "#/components/schemas/EVENT_ABI_ENTRY" + }, + { + "title": "Struct ABI entry", + "$ref": "#/components/schemas/STRUCT_ABI_ENTRY" + } + ] + }, + "STRUCT_ABI_TYPE": { + "title": "Struct ABI type", + "type": "string", + "enum": [ + "struct" + ] + }, + "EVENT_ABI_TYPE": { + "title": "Event ABI type", + "type": "string", + "enum": [ + "event" + ] + }, + "FUNCTION_ABI_TYPE": { + "title": "Function ABI type", + "type": "string", + "enum": [ + "function", + "l1_handler", + "constructor" + ] + }, + "STRUCT_ABI_ENTRY": { + "title": "Struct ABI entry", + "type": "object", + "properties": { + "type": { + "title": "Struct ABI type", + "$ref": "#/components/schemas/STRUCT_ABI_TYPE" + }, + "name": { + "title": "Struct name", + "description": "The struct name", + "type": "string" + }, + "size": { + "title": "Size", + "type": "integer", + "minimum": 1 + }, + "members": { + "type": "array", + "title": "Members", + "items": { + "$ref": "#/components/schemas/STRUCT_MEMBER" + } + } + }, + "required": [ + "type", + "name", + "size", + "members" + ] + }, + "STRUCT_MEMBER": { + "title": "Struct member", + "allOf": [ + { + "title": "Typed parameter", + "$ref": "#/components/schemas/TYPED_PARAMETER" + }, + { + "type": "object", + "title": "Offset", + "properties": { + "offset": { + "title": "Offset", + "description": "offset of this property within the struct", + "type": "integer" + } + } + } + ] + }, + "EVENT_ABI_ENTRY": { + "title": "Event ABI entry", + "type": "object", + "properties": { + "type": { + "title": "Event ABI type", + "$ref": "#/components/schemas/EVENT_ABI_TYPE" + }, + "name": { + "title": "Event name", + "description": "The event name", + "type": "string" + }, + "keys": { + "type": "array", + "title": "Typed parameter", + "items": { + "$ref": "#/components/schemas/TYPED_PARAMETER" + } + }, + "data": { + "type": "array", + "title": "Typed parameter", + "items": { + "$ref": "#/components/schemas/TYPED_PARAMETER" + } + } + }, + "required": [ + "type", + "name", + "keys", + "data" + ] + }, + "FUNCTION_STATE_MUTABILITY": { + "title": "Function state mutability type", + "type": "string", + "enum": [ + "view" + ] + }, + "FUNCTION_ABI_ENTRY": { + "title": "Function ABI entry", + "type": "object", + "properties": { + "type": { + "title": "Function ABI type", + "$ref": "#/components/schemas/FUNCTION_ABI_TYPE" + }, + "name": { + "title": "Function name", + "description": "The function name", + "type": "string" + }, + "inputs": { + "type": "array", + "title": "Typed parameter", + "items": { + "$ref": "#/components/schemas/TYPED_PARAMETER" + } + }, + "outputs": { + "type": "array", + "title": "Typed parameter", + "items": { + "$ref": "#/components/schemas/TYPED_PARAMETER" + } + }, + "stateMutability": { + "title": "Function state mutability", + "$ref": "#/components/schemas/FUNCTION_STATE_MUTABILITY" + } + }, + "required": [ + "type", + "name", + "inputs", + "outputs" + ] + }, + "TYPED_PARAMETER": { + "title": "Typed parameter", + "type": "object", + "properties": { + "name": { + "title": "Parameter name", + "description": "The parameter's name", + "type": "string" + }, + "type": { + "title": "Parameter type", + "description": "The parameter's type", + "type": "string" + } + }, + "required": [ + "name", + "type" + ] + }, + "SIMULATION_FLAG_FOR_ESTIMATE_FEE": { + "type": "string", + "enum": [ + "SKIP_VALIDATE" + ], + "description": "Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is replicated locally" + }, + "PRICE_UNIT": { + "title": "price unit", + "type": "string", + "enum": [ + "WEI", + "FRI" + ] + }, + "FEE_ESTIMATE": { + "title": "Fee estimation", + "type": "object", + "properties": { + "gas_consumed": { + "title": "Gas consumed", + "description": "The Ethereum gas consumption of the transaction", + "$ref": "#/components/schemas/FELT" + }, + "gas_price": { + "title": "Gas price", + "description": "The gas price (in wei or fri, depending on the tx version) that was used in the cost estimation", + "$ref": "#/components/schemas/FELT" + }, + "data_gas_consumed": { + "title": "Data gas consumed", + "description": "The Ethereum data gas consumption of the transaction", + "$ref": "#/components/schemas/FELT" + }, + "data_gas_price": { + "title": "Data gas price", + "description": "The data gas price (in wei or fri, depending on the tx version) that was used in the cost estimation", + "$ref": "#/components/schemas/FELT" + }, + "overall_fee": { + "title": "Overall fee", + "description": "The estimated fee for the transaction (in wei or fri, depending on the tx version), equals to gas_consumed*gas_price + data_gas_consumed*data_gas_price", + "$ref": "#/components/schemas/FELT" + }, + "unit": { + "title": "Fee unit", + "description": "units in which the fee is given", + "$ref": "#/components/schemas/PRICE_UNIT" + } + }, + "required": [ + "gas_consumed", + "gas_price", + "data_gas_consumed", + "data_gas_price", + "overall_fee", + "unit" + ] + }, + "FEE_PAYMENT": { + "title": "Fee Payment", + "description": "fee payment info as it appears in receipts", + "type": "object", + "properties": { + "amount": { + "title": "Amount", + "description": "amount paid", + "$ref": "#/components/schemas/FELT" + }, + "unit": { + "title": "Fee unit", + "description": "units in which the fee is given", + "$ref": "#/components/schemas/PRICE_UNIT" + } + }, + "required": [ + "amount", + "unit" + ] + }, + "DA_MODE": { + "title": "DA mode", + "type": "string", + "description": "Specifies a storage domain in Starknet. Each domain has different gurantess regarding availability", + "enum": [ + "L1", + "L2" + ] + }, + "RESOURCE_BOUNDS_MAPPING": { + "type": "object", + "properties": { + "l1_gas": { + "title": "L1 Gas", + "description": "The max amount and max price per unit of L1 gas used in this tx", + "$ref": "#/components/schemas/RESOURCE_BOUNDS" + }, + "l2_gas": { + "title": "L2 Gas", + "description": "The max amount and max price per unit of L2 gas used in this tx", + "$ref": "#/components/schemas/RESOURCE_BOUNDS" + } + }, + "required": [ + "l1_gas", + "l2_gas" + ] + }, + "RESOURCE_BOUNDS": { + "type": "object", + "properties": { + "max_amount": { + "title": "max amount", + "description": "the max amount of the resource that can be used in the tx", + "$ref": "#/components/schemas/u64" + }, + "max_price_per_unit": { + "title": "max price", + "description": "the max price per unit of this resource for this tx", + "$ref": "#/components/schemas/u128" + } + }, + "required": [ + "max_amount", + "max_price_per_unit" + ] + }, + "RESOURCE_PRICE": { + "type": "object", + "properties": { + "price_in_fri": { + "title": "price in fri", + "description": "the price of one unit of the given resource, denominated in fri (10^-18 strk)", + "$ref": "#/components/schemas/FELT" + }, + "price_in_wei": { + "title": "price in wei", + "description": "the price of one unit of the given resource, denominated in wei", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "price_in_wei", + "price_in_fri" + ] + }, + "COMPUTATION_RESOURCES": { + "title": "Computation resources", + "description": "The resources consumed by the VM", + "type": "object", + "properties": { + "steps": { + "title": "Steps", + "description": "The number of Cairo steps used", + "type": "integer", + "not": { + "const": 0 + } + }, + "memory_holes": { + "title": "Memory holes", + "description": "The number of unused memory cells (each cell is roughly equivalent to a step)", + "type": "integer", + "not": { + "const": 0 + } + }, + "range_check_builtin_applications": { + "title": "Range check applications", + "description": "The number of RANGE_CHECK builtin instances", + "type": "integer", + "not": { + "const": 0 + } + }, + "pedersen_builtin_applications": { + "title": "Pedersen applications", + "description": "The number of Pedersen builtin instances", + "type": "integer", + "not": { + "const": 0 + } + }, + "poseidon_builtin_applications": { + "title": "Poseidon applications", + "description": "The number of Poseidon builtin instances", + "type": "integer", + "not": { + "const": 0 + } + }, + "ec_op_builtin_applications": { + "title": "EC_OP applications", + "description": "the number of EC_OP builtin instances", + "type": "integer", + "not": { + "const": 0 + } + }, + "ecdsa_builtin_applications": { + "title": "ECDSA applications", + "description": "the number of ECDSA builtin instances", + "type": "integer", + "not": { + "const": 0 + } + }, + "bitwise_builtin_applications": { + "title": "BITWISE applications", + "description": "the number of BITWISE builtin instances", + "type": "integer", + "not": { + "const": 0 + } + }, + "keccak_builtin_applications": { + "title": "Keccak applications", + "description": "The number of KECCAK builtin instances", + "type": "integer", + "not": { + "const": 0 + } + }, + "segment_arena_builtin": { + "title": "Segment arena", + "description": "The number of accesses to the segment arena", + "type": "integer", + "not": { + "const": 0 + } + } + }, + "required": [ + "steps" + ] + }, + "EXECUTION_RESOURCES": { + "type": "object", + "title": "Execution resources", + "description": "the resources consumed by the transaction, includes both computation and data", + "allOf": [ + { + "title": "ComputationResources", + "$ref": "#/components/schemas/COMPUTATION_RESOURCES" + }, + { + "type": "object", + "title": "DataResources", + "description": "the data-availability resources of this transaction", + "properties": { + "data_availability": { + "type": "object", + "properties": { + "l1_gas": { + "title": "L1Gas", + "description": "the gas consumed by this transaction's data, 0 if it uses data gas for DA", + "type": "integer" + }, + "l1_data_gas": { + "title": "L1DataGas", + "description": "the data gas consumed by this transaction's data, 0 if it uses gas for DA", + "type": "integer" + } + }, + "required": [ + "l1_gas", + "l1_data_gas" + ] + } + }, + "required": [ + "data_availability" + ] + } + ] + } + }, + "errors": { + "FAILED_TO_RECEIVE_TXN": { + "code": 1, + "message": "Failed to write transaction" + }, + "CONTRACT_NOT_FOUND": { + "code": 20, + "message": "Contract not found" + }, + "BLOCK_NOT_FOUND": { + "code": 24, + "message": "Block not found" + }, + "INVALID_TXN_INDEX": { + "code": 27, + "message": "Invalid transaction index in a block" + }, + "CLASS_HASH_NOT_FOUND": { + "code": 28, + "message": "Class hash not found" + }, + "TXN_HASH_NOT_FOUND": { + "code": 29, + "message": "Transaction hash not found" + }, + "PAGE_SIZE_TOO_BIG": { + "code": 31, + "message": "Requested page size is too big" + }, + "NO_BLOCKS": { + "code": 32, + "message": "There are no blocks" + }, + "INVALID_CONTINUATION_TOKEN": { + "code": 33, + "message": "The supplied continuation token is invalid or unknown" + }, + "TOO_MANY_KEYS_IN_FILTER": { + "code": 34, + "message": "Too many keys provided in a filter" + }, + "CONTRACT_ERROR": { + "code": 40, + "message": "Contract error", + "data": { + "type": "object", + "description": "More data about the execution failure", + "properties": { + "revert_error": { + "title": "revert error", + "description": "a string encoding the execution trace up to the point of failure", + "type": "string" + } + }, + "required": "revert_error" + } + }, + "TRANSACTION_EXECUTION_ERROR": { + "code": 41, + "message": "Transaction execution error", + "data": { + "type": "object", + "description": "More data about the execution failure", + "properties": { + "transaction_index": { + "title": "Transaction index", + "description": "The index of the first transaction failing in a sequence of given transactions", + "type": "integer" + }, + "execution_error": { + "title": "revert error", + "description": "a string encoding the execution trace up to the point of failure", + "type": "string" + } + }, + "required": [ + "transaction_index", + "execution_error" + ] + } + } + } + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..58e4a97c --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.rs @@ -0,0 +1,2921 @@ +// +// 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}; + +pub type Address = F; + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct TransactionAndReceipt { + pub receipt: TxnReceipt, + pub transaction: Txn, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct TxnWithHash { + #[serde(flatten)] + pub transaction: Txn, + pub transaction_hash: TxnHash, +} + +pub type BlockHash = F; + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BlockHeader { + pub block_hash: BlockHash, + /// The block number (its height) + pub block_number: BlockNumber, + /// specifies whether the data of this block is published via blob data or calldata + pub l1_da_mode: L1DaMode, + /// The price of l1 data gas in the block + pub l1_data_gas_price: ResourcePrice, + /// The price of l1 gas in the block + pub l1_gas_price: ResourcePrice, + /// The new global state root + pub new_root: F, + /// The hash of this block's parent + pub parent_hash: BlockHash, + /// The StarkNet identity of the sequencer submitting this block + pub sequencer_address: F, + /// Semver of the current Starknet protocol + pub starknet_version: String, + /// The time in which the block was created, encoded in Unix time + pub timestamp: u64, +} + +/// The block's number (its height) +pub type BlockNumber = u64; + +/// The status of the block +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum BlockStatus { + #[serde(rename = "ACCEPTED_ON_L1")] + AcceptedOnL1, + #[serde(rename = "ACCEPTED_ON_L2")] + AcceptedOnL2, + #[serde(rename = "PENDING")] + Pending, + #[serde(rename = "REJECTED")] + Rejected, +} + +/// A tag specifying a dynamic reference to a block +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum BlockTag { + #[serde(rename = "latest")] + Latest, + #[serde(rename = "pending")] + Pending, +} + +/// The block object +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BlockWithReceipts { + /// The transactions in this block + pub transactions: Vec>, + pub status: BlockStatus, + #[serde(flatten)] + pub block_header: BlockHeader, +} + +/// The block object +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BlockWithTxs { + /// The transactions in this block + pub transactions: Vec>, + pub status: BlockStatus, + #[serde(flatten)] + pub block_header: BlockHeader, +} + +/// The block object +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BlockWithTxHashes { + /// The hashes of the transactions included in this block + pub transactions: Vec>, + pub status: BlockStatus, + #[serde(flatten)] + pub block_header: BlockHeader, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BroadcastedDeclareTxnV1 { + /// The class to be declared + pub contract_class: DeprecatedContractClass, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + pub nonce: F, + /// The address of the account contract sending the declaration transaction + pub sender_address: Address, + pub signature: Signature, +} + +#[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 + pub contract_class: ContractClass, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + pub nonce: F, + /// The address of the account contract sending the declaration transaction + pub sender_address: Address, + pub signature: Signature, +} + +#[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")] + Invoke(BroadcastedInvokeTxn), + #[serde(rename = "DECLARE")] + Declare(BroadcastedDeclareTxn), + #[serde(rename = "DEPLOY_ACCOUNT")] + DeployAccount(BroadcastedDeployAccountTxn), +} + +/// StarkNet chain id, given in hex representation. +pub type ChainId = u64; + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct CommonReceiptProperties { + /// The fee that was charged by the sequencer + pub actual_fee: FeePayment, + /// The events emitted as part of this transaction + pub events: Vec>, + /// The resources consumed by the transaction + pub execution_resources: ExecutionResources, + /// finality status of the tx + pub finality_status: TxnFinalityStatus, + pub messages_sent: Vec>, + /// The hash identifying the transaction + pub transaction_hash: TxnHash, + #[serde(flatten)] + pub anon: Anonymous, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum Anonymous { + /// Common properties for a transaction receipt that was executed successfully + Successful(SuccessfulCommonReceiptProperties), + /// Common properties for a transaction receipt that was reverted + Reverted(RevertedCommonReceiptProperties), +} + +/// Common properties for a transaction receipt that was executed successfully +#[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, Hash, PartialEq, Serialize, Deserialize)] +pub struct RevertedCommonReceiptProperties { + /// The execution status of the transaction + pub execution_status: String, /* REVERTED */ + /// the revert reason for the failed execution + pub revert_reason: String, +} + +/// The resources consumed by the VM +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ComputationResources { + /// the number of BITWISE builtin instances + #[serde(default)] + pub bitwise_builtin_applications: Option, + /// the number of EC_OP builtin instances + #[serde(default)] + pub ec_op_builtin_applications: Option, + /// the number of ECDSA builtin instances + #[serde(default)] + pub ecdsa_builtin_applications: Option, + /// The number of KECCAK builtin instances + #[serde(default)] + pub keccak_builtin_applications: Option, + /// The number of unused memory cells (each cell is roughly equivalent to a step) + #[serde(default)] + pub memory_holes: Option, + /// The number of Pedersen builtin instances + #[serde(default)] + pub pedersen_builtin_applications: Option, + /// The number of Poseidon builtin instances + #[serde(default)] + pub poseidon_builtin_applications: Option, + /// The number of RANGE_CHECK builtin instances + #[serde(default)] + pub range_check_builtin_applications: Option, + /// The number of accesses to the segment arena + #[serde(default)] + pub segment_arena_builtin: Option, + /// The number of Cairo steps used + pub steps: u64, +} + +pub type ContractAbi = Vec; + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum ContractAbiEntry { + Function(FunctionAbiEntry), + Event(EventAbiEntry), + Struct(StructAbiEntry), +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ContractClass { + /// The class ABI, as supplied by the user declaring the class + #[serde(default)] + pub abi: Option, + /// The version of the contract class object. Currently, the Starknet OS supports version 0.1.0 + pub contract_class_version: String, + pub entry_points_by_type: EntryPointsByType, + /// The list of Sierra instructions of which the program consists + pub sierra_program: Vec, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct EntryPointsByType { + #[serde(rename = "CONSTRUCTOR")] + pub constructor: Vec>, + #[serde(rename = "EXTERNAL")] + pub external: Vec>, + #[serde(rename = "L1_HANDLER")] + pub l1_handler: Vec>, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ContractStorageDiffItem { + /// The contract address for which the storage changed + pub address: F, + /// The changes in the storage of the contract + pub storage_entries: Vec>, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct KeyValuePair { + /// The key of the changed value + #[serde(default)] + pub key: Option, + /// The new value applied to the given address + #[serde(default)] + pub value: Option, +} + +/// Specifies a storage domain in Starknet. Each domain has different gurantess regarding availability +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum DaMode { + L1, + L2, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(tag = "version")] +pub enum DeclareTxn { + #[serde(rename = "0x0")] + V0(DeclareTxnV0), + #[serde(rename = "0x1")] + V1(DeclareTxnV1), + #[serde(rename = "0x2")] + V2(DeclareTxnV2), + #[serde(rename = "0x3")] + V3(DeclareTxnV3), +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeclareTxnReceipt { + #[serde(flatten)] + pub common_receipt_properties: CommonReceiptProperties, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeclareTxnV0 { + /// The hash of the declared class + pub class_hash: F, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + /// The address of the account contract sending the declaration transaction + pub sender_address: Address, + pub signature: Signature, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeclareTxnV1 { + /// The hash of the declared class + pub class_hash: F, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + pub nonce: F, + /// The address of the account contract sending the declaration transaction + pub sender_address: Address, + pub signature: Signature, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeclareTxnV2 { + /// The hash of the declared class + pub class_hash: F, + /// The hash of the Cairo assembly resulting from the Sierra compilation + pub compiled_class_hash: F, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + pub nonce: F, + /// The address of the account contract sending the declaration transaction + pub sender_address: Address, + pub signature: Signature, +} + +#[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, + /// The hash of the declared class + pub class_hash: F, + /// The hash of the Cairo assembly resulting from the Sierra compilation + pub compiled_class_hash: F, + /// 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, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeployedContractItem { + /// The address of the contract + pub address: F, + /// The hash of the contract code + pub class_hash: F, +} + +/// deploys a new account contract +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(tag = "version")] +pub enum DeployAccountTxn { + #[serde(rename = "0x1")] + V1(DeployAccountTxnV1), + #[serde(rename = "0x3")] + V3(DeployAccountTxnV3), +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeployAccountTxnReceipt { + #[serde(flatten)] + pub common_receipt_properties: CommonReceiptProperties, + /// The address of the deployed contract + pub contract_address: F, +} + +/// Deploys an account contract, charges fee from the pre-funded account addresses +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeployAccountTxnV1 { + /// The hash of the deployed contract's class + pub class_hash: F, + /// The parameters passed to the constructor + pub constructor_calldata: Vec, + /// The salt for the address of the deployed contract + pub contract_address_salt: F, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + pub nonce: F, + pub signature: Signature, +} + +/// Deploys an account contract, charges fee from the pre-funded account addresses +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeployAccountTxnV3 { + /// The hash of the deployed contract's class + pub class_hash: F, + /// The parameters passed to the constructor + pub constructor_calldata: Vec, + /// The salt for the address of the deployed contract + pub contract_address_salt: F, + /// 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, + pub signature: Signature, + /// the tip for the transaction + pub tip: U64, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeployTxn { + /// The hash of the deployed contract's class + pub class_hash: F, + /// The parameters passed to the constructor + pub constructor_calldata: Vec, + /// The salt for the address of the deployed contract + pub contract_address_salt: F, + /// Version of the transaction scheme + pub version: F, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeployTxnReceipt { + #[serde(flatten)] + pub common_receipt_properties: CommonReceiptProperties, + /// The address of the deployed contract + pub contract_address: F, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeprecatedCairoEntryPoint { + /// The offset of the entry point in the program + #[serde(with = "NumAsHex")] + pub offset: u64, + /// A unique identifier of the entry point (function) in the program + pub selector: F, +} + +/// The definition of a StarkNet contract class +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeprecatedContractClass { + #[serde(default)] + pub abi: Option, + pub entry_points_by_type: DeprecatedEntryPointsByType, + /// A base64 representation of the compressed program code + pub program: String, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeprecatedEntryPointsByType { + #[serde(default)] + #[serde(rename = "CONSTRUCTOR")] + pub constructor: Option>>, + #[serde(default)] + #[serde(rename = "EXTERNAL")] + pub external: Option>>, + #[serde(default)] + #[serde(rename = "L1_HANDLER")] + pub l1_handler: Option>>, +} + +/// Event information decorated with metadata on where it was emitted / An event emitted as a result of transaction execution +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct EmittedEvent { + /// The event information + #[serde(flatten)] + pub event: Event, + /// The hash of the block in which the event was emitted + #[serde(default)] + pub block_hash: Option>, + /// The number of the block in which the event was emitted + #[serde(default)] + pub block_number: Option, + /// The transaction that emitted the event + pub transaction_hash: TxnHash, +} + +/// an ethereum address represented as 40 hex digits +pub type EthAddress = String; + +/// A StarkNet event +#[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, 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)] + pub continuation_token: Option, + pub events: Vec>, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct EventAbiEntry { + pub data: Vec, + pub keys: Vec, + /// The event name + pub name: String, + #[serde(rename = "type")] + pub ty: EventAbiType, +} + +pub type EventAbiType = String; + +/// the resources consumed by the transaction, includes both computation and data +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ExecutionResources { + /// the number of BITWISE builtin instances + #[serde(default)] + pub bitwise_builtin_applications: Option, + /// the number of EC_OP builtin instances + #[serde(default)] + pub ec_op_builtin_applications: Option, + /// the number of ECDSA builtin instances + #[serde(default)] + pub ecdsa_builtin_applications: Option, + /// The number of KECCAK builtin instances + #[serde(default)] + pub keccak_builtin_applications: Option, + /// The number of unused memory cells (each cell is roughly equivalent to a step) + #[serde(default)] + pub memory_holes: Option, + /// The number of Pedersen builtin instances + #[serde(default)] + pub pedersen_builtin_applications: Option, + /// The number of Poseidon builtin instances + #[serde(default)] + pub poseidon_builtin_applications: Option, + /// The number of RANGE_CHECK builtin instances + #[serde(default)] + pub range_check_builtin_applications: Option, + /// The number of accesses to the segment arena + #[serde(default)] + pub segment_arena_builtin: Option, + /// The number of Cairo steps used + pub steps: u64, + pub data_availability: DataAvailability, +} + +#[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, + /// the gas consumed by this transaction's data, 0 if it uses data gas for DA + pub l1_gas: u64, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct FeeEstimate { + /// The Ethereum data gas consumption of the transaction + pub data_gas_consumed: F, + /// The data gas price (in wei or fri, depending on the tx version) that was used in the cost estimation + pub data_gas_price: F, + /// The Ethereum gas consumption of the transaction + pub gas_consumed: F, + /// The gas price (in wei or fri, depending on the tx version) that was used in the cost estimation + pub gas_price: F, + /// The estimated fee for the transaction (in wei or fri, depending on the tx version), equals to gas_consumed*gas_price + data_gas_consumed*data_gas_price + pub overall_fee: F, + /// units in which the fee is given + pub unit: PriceUnit, +} + +/// fee payment info as it appears in receipts +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct FeePayment { + /// amount paid + pub amount: F, + /// units in which the fee is given + pub unit: PriceUnit, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct FunctionAbiEntry { + pub inputs: Vec, + /// The function name + pub name: String, + pub outputs: Vec, + #[serde(default)] + #[serde(rename = "stateMutability")] + pub state_mutability: Option, + #[serde(rename = "type")] + pub ty: FunctionAbiType, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum FunctionAbiType { + #[serde(rename = "constructor")] + Constructor, + #[serde(rename = "function")] + Function, + #[serde(rename = "l1_handler")] + L1Handler, +} + +/// Function call information +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct FunctionCall { + /// The parameters passed to the function + pub calldata: Vec, + pub contract_address: Address, + pub entry_point_selector: F, +} + +pub type FunctionStateMutability = String; + +/// Initiate a transaction from an account +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(tag = "version")] +pub enum InvokeTxn { + #[serde(rename = "0x0")] + V0(InvokeTxnV0), + #[serde(rename = "0x1")] + V1(InvokeTxnV1), + #[serde(rename = "0x3")] + V3(InvokeTxnV3), +} + +#[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, Hash, PartialEq, Serialize, Deserialize)] +pub struct InvokeTxnV0 { + /// The parameters passed to the function + pub calldata: Vec, + pub contract_address: Address, + pub entry_point_selector: F, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + pub signature: Signature, +} + +#[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, + /// The maximal fee that can be charged for including the transaction + pub max_fee: F, + pub nonce: F, + pub sender_address: Address, + pub signature: Signature, +} + +#[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, + /// 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, + /// 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, + pub sender_address: Address, + pub signature: Signature, + /// the tip for the transaction + pub tip: U64, +} + +#[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")] + pub nonce: u64, + /// Version of the transaction scheme + pub version: String, /* 0x0 */ + #[serde(flatten)] + pub function_call: FunctionCall, +} + +/// receipt for l1 handler transaction +#[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")] + pub message_hash: u64, + #[serde(flatten)] + pub common_receipt_properties: CommonReceiptProperties, +} + +#[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, + /// The address of the L1 contract sending the message + pub from_address: EthAddress, + /// The payload of the message + pub payload: Vec, + /// The target L2 address the message is sent to + pub to_address: Address, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct MsgToL1 { + /// The address of the L2 contract sending the message + pub from_address: F, + /// The payload of the message + pub payload: Vec, + /// The target L1 address the message is sent to + pub to_address: F, +} + +#[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, + /// The price of l1 data gas in the block + pub l1_data_gas_price: ResourcePrice, + /// The price of l1 gas in the block + pub l1_gas_price: ResourcePrice, + /// The hash of this block's parent + pub parent_hash: BlockHash, + /// The StarkNet identity of the sequencer submitting this block + pub sequencer_address: F, + /// Semver of the current Starknet protocol + pub starknet_version: String, + /// The time in which the block was created, encoded in Unix time + pub timestamp: u64, +} + +/// specifies whether the data of this block is published via blob data or calldata +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum L1DaMode { + #[serde(rename = "BLOB")] + Blob, + #[serde(rename = "CALLDATA")] + Calldata, +} + +/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization. +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct PendingBlockWithReceipts { + /// The transactions in this block + pub transactions: Vec>, + #[serde(flatten)] + pub pending_block_header: PendingBlockHeader, +} + +/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization. +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct PendingBlockWithTxs { + /// The transactions in this block + pub transactions: Vec>, + #[serde(flatten)] + pub pending_block_header: PendingBlockHeader, +} + +/// The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization. +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct PendingBlockWithTxHashes { + /// The hashes of the transactions included in this block + pub transactions: Vec>, + #[serde(flatten)] + pub pending_block_header: PendingBlockHeader, +} + +/// Pending state update +#[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(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum PriceUnit { + #[serde(rename = "FRI")] + Fri, + #[serde(rename = "WEI")] + Wei, +} + +#[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, + /// the max price per unit of this resource for this tx + pub max_price_per_unit: U128, +} + +#[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, + /// The max amount and max price per unit of L2 gas used in this tx + pub l2_gas: ResourceBounds, +} + +#[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, + /// the price of one unit of the given resource, denominated in wei + pub price_in_wei: F, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct SierraEntryPoint { + /// The index of the function in the program + pub function_idx: u64, + /// A unique identifier of the entry point (function) in the program + pub selector: F, +} + +/// A transaction signature +pub type Signature = Vec; + +/// Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is replicated locally +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, Hash, PartialEq, Serialize, Deserialize)] +pub struct StateDiff { + pub declared_classes: Vec>, + pub deployed_contracts: Vec>, + pub deprecated_declared_classes: Vec, + pub nonces: Vec>, + pub replaced_classes: Vec>, + pub storage_diffs: Vec>, +} + +/// The declared class hash and compiled class hash +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct NewClasses { + /// The hash of the declared class + #[serde(default)] + pub class_hash: Option, + /// The Cairo assembly hash corresponding to the declared class + #[serde(default)] + pub compiled_class_hash: Option, +} + +/// The updated nonce per contract address +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct NonceUpdate { + /// The address of the contract + #[serde(default)] + pub contract_address: Option>, + /// The nonce for the given address at the end of the block + #[serde(default)] + pub nonce: Option, +} + +/// The list of contracts whose class was replaced +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ReplacedClass { + /// The new class hash + #[serde(default)] + pub class_hash: Option, + /// The address of the contract whose class was replaced + #[serde(default)] + pub contract_address: Option>, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct StateUpdate { + pub block_hash: BlockHash, + /// The new global state root + pub new_root: F, + /// The previous global state root + pub old_root: F, + pub state_diff: StateDiff, +} + +/// A storage key. Represented as up to 62 hex digits, 3 bits, and 5 leading zeroes. +pub type StorageKey = String; + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct StructAbiEntry { + pub members: Vec, + /// The struct name + pub name: String, + pub size: u64, + #[serde(rename = "type")] + pub ty: StructAbiType, +} + +pub type StructAbiType = String; + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct StructMember { + #[serde(flatten)] + pub typed_parameter: TypedParameter, + /// offset of this property within the struct + #[serde(default)] + pub offset: Option, +} + +/// An object describing the node synchronization status +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct SyncStatus { + /// The hash of the current block being synchronized + pub current_block_hash: BlockHash, + /// The number (height) of the current block being synchronized + pub current_block_num: BlockNumber, + /// The hash of the estimated highest block to be synchronized + pub highest_block_hash: BlockHash, + /// The number (height) of the estimated highest block to be synchronized + pub highest_block_num: BlockNumber, + /// The hash of the block from which the sync started + pub starting_block_hash: BlockHash, + /// The number (height) of the block from which the sync started + pub starting_block_num: BlockNumber, +} + +/// The transaction schema, as it appears inside a block +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(tag = "type")] +pub enum Txn { + #[serde(rename = "INVOKE")] + Invoke(InvokeTxn), + #[serde(rename = "L1_HANDLER")] + L1Handler(L1HandlerTxn), + #[serde(rename = "DECLARE")] + Declare(DeclareTxn), + #[serde(rename = "DEPLOY")] + Deploy(DeployTxn), + #[serde(rename = "DEPLOY_ACCOUNT")] + DeployAccount(DeployAccountTxn), +} + +/// The execution status of the transaction +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum TxnExecutionStatus { + #[serde(rename = "REVERTED")] + Reverted, + #[serde(rename = "SUCCEEDED")] + Succeeded, +} + +/// The finality status of the transaction +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum TxnFinalityStatus { + #[serde(rename = "ACCEPTED_ON_L1")] + L1, + #[serde(rename = "ACCEPTED_ON_L2")] + L2, +} + +/// The transaction hash, as assigned in StarkNet +pub type TxnHash = F; + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(tag = "type")] +pub enum TxnReceipt { + #[serde(rename = "INVOKE")] + Invoke(InvokeTxnReceipt), + #[serde(rename = "L1_HANDLER")] + L1Handler(L1HandlerTxnReceipt), + #[serde(rename = "DECLARE")] + Declare(DeclareTxnReceipt), + #[serde(rename = "DEPLOY")] + Deploy(DeployTxnReceipt), + #[serde(rename = "DEPLOY_ACCOUNT")] + DeployAccount(DeployAccountTxnReceipt), +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct TxnReceiptWithBlockInfo { + #[serde(flatten)] + pub transaction_receipt: TxnReceipt, + /// If this field is missing, it means the receipt belongs to the pending block + #[serde(default)] + pub block_hash: Option>, + /// If this field is missing, it means the receipt belongs to the pending block + #[serde(default)] + pub block_number: Option, +} + +/// 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(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum TxnStatus { + #[serde(rename = "ACCEPTED_ON_L1")] + AcceptedOnL1, + #[serde(rename = "ACCEPTED_ON_L2")] + AcceptedOnL2, + #[serde(rename = "RECEIVED")] + Received, + #[serde(rename = "REJECTED")] + Rejected, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct TypedParameter { + /// The parameter's name + pub name: String, + /// The parameter's type + #[serde(rename = "type")] + pub ty: String, +} + +/// 64 bit integers, represented by hex string of length at most 32 +pub type U128 = String; + +/// 64 bit integers, represented by hex string of length at most 16 +pub type U64 = String; + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct BlockHashAndNumber { + pub block_hash: BlockHash, + pub block_number: BlockNumber, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum StarknetGetBlockWithTxsAndReceiptsResult { + Block(BlockWithReceipts), + Pending(PendingBlockWithReceipts), +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum MaybePendingBlockWithTxHashes { + Block(BlockWithTxHashes), + Pending(PendingBlockWithTxHashes), +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum MaybePendingBlockWithTxs { + Block(BlockWithTxs), + Pending(PendingBlockWithTxs), +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum MaybeDeprecatedContractClass { + Deprecated(DeprecatedContractClass), + ContractClass(ContractClass), +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct EventFilterWithPageRequest { + #[serde(default)] + pub address: Option>, + #[serde(default)] + pub from_block: Option>, + /// The values used to filter the events + #[serde(default)] + pub keys: Option>>, + #[serde(default)] + pub to_block: Option>, + pub chunk_size: u64, + /// The token returned from the previous query. If no token is provided the first page is returned. + #[serde(default)] + pub continuation_token: Option, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum MaybePendingStateUpdate { + Block(StateUpdate), + Pending(PendingStateUpdate), +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct TxnFinalityAndExecutionStatus { + #[serde(default)] + pub execution_status: Option, + pub finality_status: TxnStatus, +} + +/// Parameters of the `starknet_specVersion` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct SpecVersionParams {} + +impl Serialize for SpecVersionParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.end() + } +} + +impl<'de> Deserialize<'de> for SpecVersionParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor; + + impl<'de> serde::de::Visitor<'de> for Visitor { + type Value = SpecVersionParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_specVersion`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 1, + &"expected 0 parameters", + )); + } + + Ok(SpecVersionParams {}) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper {} + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(SpecVersionParams {}) + } + } + + deserializer.deserialize_any(Visitor) + } +} + +/// Parameters of the `starknet_getBlockWithTxHashes` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetBlockWithTxHashesParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, +} + +impl Serialize for GetBlockWithTxHashesParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockWithTxHashesParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getBlockWithTxHashes`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(GetBlockWithTxHashesParams { block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetBlockWithTxHashesParams { + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getBlockWithTxs` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetBlockWithTxsParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, +} + +impl Serialize for GetBlockWithTxsParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockWithTxsParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getBlockWithTxs`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(GetBlockWithTxsParams { block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetBlockWithTxsParams { + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getBlockWithReceipts` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetBlockWithReceiptsParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, +} + +impl Serialize for GetBlockWithReceiptsParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockWithReceiptsParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getBlockWithReceipts`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(GetBlockWithReceiptsParams { block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetBlockWithReceiptsParams { + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getStateUpdate` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetStateUpdateParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, +} + +impl Serialize for GetStateUpdateParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetStateUpdateParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getStateUpdate`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(GetStateUpdateParams { block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetStateUpdateParams { + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getStorageAt` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetStorageAtParams { + /// The address of the contract to read from + pub contract_address: Address, + /// The key to the storage value for the given contract + pub key: StorageKey, + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, +} + +impl Serialize for GetStorageAtParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("contract_address", &self.contract_address)?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetStorageAtParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getStorageAt`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let contract_address: Address = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 3 parameters"))?; + let key: StorageKey = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 3 parameters"))?; + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(3, &"expected 3 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 4, + &"expected 3 parameters", + )); + } + + Ok(GetStorageAtParams { + contract_address, + key, + block_id, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + contract_address: Address, + key: StorageKey, + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetStorageAtParams { + contract_address: helper.contract_address, + key: helper.key, + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getTransactionStatus` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetTransactionStatusParams { + /// The hash of the requested transaction + pub transaction_hash: TxnHash, +} + +impl Serialize for GetTransactionStatusParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("transaction_hash", &self.transaction_hash)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetTransactionStatusParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + type Value = GetTransactionStatusParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_getTransactionStatus`") + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + transaction_hash: TxnHash, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetTransactionStatusParams { + transaction_hash: helper.transaction_hash, + }) + } + } + + deserializer.deserialize_map(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getTransactionByHash` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetTransactionByHashParams { + /// The hash of the requested transaction + pub transaction_hash: TxnHash, +} + +impl Serialize for GetTransactionByHashParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("transaction_hash", &self.transaction_hash)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetTransactionByHashParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + type Value = GetTransactionByHashParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_getTransactionByHash`") + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + transaction_hash: TxnHash, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetTransactionByHashParams { + transaction_hash: helper.transaction_hash, + }) + } + } + + deserializer.deserialize_map(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getTransactionByBlockIdAndIndex` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetTransactionByBlockIdAndIndexParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, + /// The index in the block to search for the transaction + pub index: u64, +} + +impl Serialize for GetTransactionByBlockIdAndIndexParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.serialize_entry("index", &self.index)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetTransactionByBlockIdAndIndexParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!( + f, + "the parameters for `starknet_getTransactionByBlockIdAndIndex`" + ) + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 2 parameters"))?; + let index: u64 = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 2 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 3, + &"expected 2 parameters", + )); + } + + Ok(GetTransactionByBlockIdAndIndexParams { block_id, index }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + index: u64, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetTransactionByBlockIdAndIndexParams { + block_id: helper.block_id, + index: helper.index, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getTransactionReceipt` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetTransactionReceiptParams { + /// The hash of the requested transaction + pub transaction_hash: TxnHash, +} + +impl Serialize for GetTransactionReceiptParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("transaction_hash", &self.transaction_hash)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetTransactionReceiptParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + type Value = GetTransactionReceiptParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_getTransactionReceipt`") + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + transaction_hash: TxnHash, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetTransactionReceiptParams { + transaction_hash: helper.transaction_hash, + }) + } + } + + deserializer.deserialize_map(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getClass` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetClassParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, + /// The hash of the requested contract class + pub class_hash: F, +} + +impl Serialize for GetClassParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.serialize_entry("class_hash", &self.class_hash)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetClassParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getClass`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 2 parameters"))?; + let class_hash: F = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 2 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 3, + &"expected 2 parameters", + )); + } + + Ok(GetClassParams { + block_id, + class_hash, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + class_hash: F, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetClassParams { + block_id: helper.block_id, + class_hash: helper.class_hash, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getClassHashAt` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetClassHashAtParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, + /// The address of the contract whose class hash will be returned + pub contract_address: Address, +} + +impl Serialize for GetClassHashAtParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.serialize_entry("contract_address", &self.contract_address)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetClassHashAtParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getClassHashAt`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 2 parameters"))?; + let contract_address: Address = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 2 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 3, + &"expected 2 parameters", + )); + } + + Ok(GetClassHashAtParams { + block_id, + contract_address, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + contract_address: Address, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetClassHashAtParams { + block_id: helper.block_id, + contract_address: helper.contract_address, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getClassAt` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetClassAtParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, + /// The address of the contract whose class definition will be returned + pub contract_address: Address, +} + +impl Serialize for GetClassAtParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.serialize_entry("contract_address", &self.contract_address)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetClassAtParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getClassAt`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 2 parameters"))?; + let contract_address: Address = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 2 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 3, + &"expected 2 parameters", + )); + } + + Ok(GetClassAtParams { + block_id, + contract_address, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + contract_address: Address, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetClassAtParams { + block_id: helper.block_id, + contract_address: helper.contract_address, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getBlockTransactionCount` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetBlockTransactionCountParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, +} + +impl Serialize for GetBlockTransactionCountParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetBlockTransactionCountParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getBlockTransactionCount`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(GetBlockTransactionCountParams { block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetBlockTransactionCountParams { + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_call` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CallParams { + /// The details of the function call + pub request: FunctionCall, + /// The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on. + pub block_id: BlockId, +} + +impl Serialize for CallParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("request", &self.request)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for CallParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_call`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let request: FunctionCall = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 2 parameters"))?; + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 2 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 3, + &"expected 2 parameters", + )); + } + + Ok(CallParams { request, block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + request: FunctionCall, + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(CallParams { + request: helper.request, + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_estimateFee` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct EstimateFeeParams { + /// The transaction to estimate + pub request: Vec>, + /// describes what parts of the transaction should be executed + pub simulation_flags: Vec, + /// The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on. + pub block_id: BlockId, +} + +impl Serialize for EstimateFeeParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("request", &self.request)?; + map.serialize_entry("simulation_flags", &self.simulation_flags)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for EstimateFeeParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_estimateFee`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let request: Vec> = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 3 parameters"))?; + let simulation_flags: Vec = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 3 parameters"))?; + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(3, &"expected 3 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 4, + &"expected 3 parameters", + )); + } + + Ok(EstimateFeeParams { + request, + simulation_flags, + block_id, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + request: Vec>, + simulation_flags: Vec, + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(EstimateFeeParams { + request: helper.request, + simulation_flags: helper.simulation_flags, + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_estimateMessageFee` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct EstimateMessageFeeParams { + /// the message's parameters + pub message: MsgFromL1, + /// The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on. + pub block_id: BlockId, +} + +impl Serialize for EstimateMessageFeeParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("message", &self.message)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for EstimateMessageFeeParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_estimateMessageFee`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let message: MsgFromL1 = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 2 parameters"))?; + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 2 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 3, + &"expected 2 parameters", + )); + } + + Ok(EstimateMessageFeeParams { message, block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + message: MsgFromL1, + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(EstimateMessageFeeParams { + message: helper.message, + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_blockNumber` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct BlockNumberParams {} + +impl Serialize for BlockNumberParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.end() + } +} + +impl<'de> Deserialize<'de> for BlockNumberParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor; + + impl<'de> serde::de::Visitor<'de> for Visitor { + type Value = BlockNumberParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_blockNumber`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 1, + &"expected 0 parameters", + )); + } + + Ok(BlockNumberParams {}) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper {} + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(BlockNumberParams {}) + } + } + + deserializer.deserialize_any(Visitor) + } +} + +/// Parameters of the `starknet_blockHashAndNumber` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct BlockHashAndNumberParams {} + +impl Serialize for BlockHashAndNumberParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.end() + } +} + +impl<'de> Deserialize<'de> for BlockHashAndNumberParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor; + + impl<'de> serde::de::Visitor<'de> for Visitor { + type Value = BlockHashAndNumberParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_blockHashAndNumber`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 1, + &"expected 0 parameters", + )); + } + + Ok(BlockHashAndNumberParams {}) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper {} + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(BlockHashAndNumberParams {}) + } + } + + deserializer.deserialize_any(Visitor) + } +} + +/// Parameters of the `starknet_chainId` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ChainIdParams {} + +impl Serialize for ChainIdParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.end() + } +} + +impl<'de> Deserialize<'de> for ChainIdParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor; + + impl<'de> serde::de::Visitor<'de> for Visitor { + type Value = ChainIdParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_chainId`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 1, + &"expected 0 parameters", + )); + } + + Ok(ChainIdParams {}) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper {} + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(ChainIdParams {}) + } + } + + deserializer.deserialize_any(Visitor) + } +} + +/// Parameters of the `starknet_syncing` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct SyncingParams {} + +impl Serialize for SyncingParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.end() + } +} + +impl<'de> Deserialize<'de> for SyncingParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor; + + impl<'de> serde::de::Visitor<'de> for Visitor { + type Value = SyncingParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_syncing`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 1, + &"expected 0 parameters", + )); + } + + Ok(SyncingParams {}) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper {} + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(SyncingParams {}) + } + } + + deserializer.deserialize_any(Visitor) + } +} + +/// Parameters of the `starknet_getEvents` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetEventsParams { + /// The conditions used to filter the returned events + pub filter: EventFilterWithPageRequest, +} + +impl Serialize for GetEventsParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("filter", &self.filter)?; + map.end() + } +} + +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for GetEventsParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getEvents`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let filter: EventFilterWithPageRequest = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(GetEventsParams { filter }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + filter: EventFilterWithPageRequest, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetEventsParams { + filter: helper.filter, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_getNonce` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct GetNonceParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, + /// The address of the contract whose nonce we're seeking + pub contract_address: Address, +} + +impl Serialize for GetNonceParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.serialize_entry("contract_address", &self.contract_address)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for GetNonceParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_getNonce`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 2 parameters"))?; + let contract_address: Address = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 2 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 3, + &"expected 2 parameters", + )); + } + + Ok(GetNonceParams { + block_id, + contract_address, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + contract_address: Address, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(GetNonceParams { + block_id: helper.block_id, + contract_address: helper.contract_address, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} 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 new file mode 100644 index 00000000..7851f0ce --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_api_openrpc.toml @@ -0,0 +1,93 @@ +debug-path = false +run-rustfmt = true + +[generation] +additional-imports = [ + "crate::custom_serde::NumAsHex", + "super::{BlockId, BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn}", + "alloc::vec::Vec", + "alloc::string::String", + "core::marker::PhantomData" +] +method-name-prefix = "starknet_" +param-types = true +use-core = true + +[formatters] +num-as-hex = "NumAsHex" + +[fixes] +strip-enum-variants = true +flatten = ["#/components/schemas/NUM_AS_HEX"] +preserve = [ + "#/components/schemas/BLOCK_TAG", + "#/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", +] + +[fixes.replace] +# Too tricky to automatically fix cleanly +"#/components/schemas/BLOCK_ID" = "BlockId" +"#/methods/starknet_syncing/result/_anon" = "SyncingStatus" +"#/components/schemas/FELT" = "F" + +# Query-only types +"#/components/schemas/BROADCASTED_DECLARE_TXN" = "BroadcastedDeclareTxn" +"#/components/schemas/BROADCASTED_DEPLOY_ACCOUNT_TXN" = "BroadcastedDeployAccountTxn" +"#/components/schemas/BROADCASTED_INVOKE_TXN" = "BroadcastedInvokeTxn" + +# Duplicates +"#/methods/starknet_getClassAt/result/_anon" = "MaybeDeprecatedContractClass" +"#/methods/starknet_getTransactionByBlockIdAndIndex/result/_anon" = "TxnWithHash" +"#/methods/starknet_getTransactionByHash/result/_anon" = "TxnWithHash" +"#/components/schemas/BLOCK_HEADER/l1_da_mode/_anon" = "L1DaMode" + +[fixes.rename] +# Broken Enum Variants +"#/methods/starknet_getBlockWithTxHashes/result/_anon/variant0" = "Block" +"#/methods/starknet_getBlockWithTxs/result/_anon/variant0" = "Block" +"#/methods/starknet_getStateUpdate/result/_anon/variant0" = "Block" +"#/methods/starknet_getBlockWithReceipts/result/_anon/variant0" = "Block" +"#/methods/starknet_getClass/result/_anon/variant1" = "ContractClass" + +# Anonymous Types +"#/components/schemas/BLOCK_BODY_WITH_TXS/transactions/_anon/_anon" = "TxnWithHash" +"#/components/schemas/EXECUTION_RESOURCES/field1/_anon/data_availability/_anon" = "DataAvailability" +"#/components/schemas/CONTRACT_STORAGE_DIFF_ITEM/storage_entries/_anon/_anon" = "KeyValuePair" +"#/methods/starknet_blockHashAndNumber/result/_anon" = "BlockHashAndNumber" +"#/methods/starknet_getBlockWithTxHashes/result/_anon" = "MaybePendingBlockWithTxHashes" +"#/methods/starknet_getBlockWithTxs/result/_anon" = "MaybePendingBlockWithTxs" +"#/methods/starknet_getClass/result/_anon" = "MaybeDeprecatedContractClass" +"#/methods/starknet_getEvents/params/filter/_anon" = "EventFilterWithPageRequest" +"#/methods/starknet_getStateUpdate/result/_anon" = "MaybePendingStateUpdate" +"#/methods/starknet_getTransactionStatus/result/_anon" = "TxnFinalityAndExecutionStatus" + +# Broken convert_case +"#/components/schemas/FUNCTION_ABI_ENTRY/stateMutability" = "state_mutability" + +[fixes.tagged-enums] +"#/components/schemas/DECLARE_TXN" = "version" +"#/components/schemas/INVOKE_TXN" = "version" +"#/components/schemas/TXN" = "type" +"#/components/schemas/TXN_RECEIPT" = "type" +"#/components/schemas/DEPLOY_ACCOUNT_TXN" = "version" +"#/components/schemas/BROADCASTED_TXN" = "type" + +[fixes.set-tags] +"#/components/schemas/BROADCASTED_DECLARE_TXN_V1/_anon/version" = "0x1" +"#/components/schemas/BROADCASTED_DECLARE_TXN_V2/_anon/version" = "0x2" +"#/components/schemas/INVOKE_TXN_V0/version" = "0x0" +"#/components/schemas/INVOKE_TXN_V1/_anon/version" = "0x1" +"#/components/schemas/INVOKE_TXN_V3/_anon/version" = "0x3" +"#/components/schemas/DECLARE_TXN_V0/_anon/version" = "0x0" +"#/components/schemas/DECLARE_TXN_V1/_anon/version" = "0x1" +"#/components/schemas/DECLARE_TXN_V2/_anon/version" = "0x2" +"#/components/schemas/DECLARE_TXN_V3/_anon/version" = "0x3" +"#/components/schemas/DEPLOY_ACCOUNT_TXN_V1/version" = "0x1" +"#/components/schemas/DEPLOY_ACCOUNT_TXN_V3/version" = "0x3" + +[primitives] +integer = "u64" diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.json b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.json new file mode 100644 index 00000000..ca0fb143 --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.json @@ -0,0 +1,517 @@ +{ + "openrpc": "1.0.0-rc1", + "info": { + "version": "0.7.1", + "title": "StarkNet Trace API", + "license": {} + }, + "servers": [], + "methods": [ + { + "name": "starknet_traceTransaction", + "summary": "For a given executed transaction, return the trace of its execution, including internal calls", + "description": "Returns the execution trace of the transaction designated by the input hash", + "params": [ + { + "name": "transaction_hash", + "summary": "The hash of the transaction to trace", + "required": true, + "schema": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/TXN_HASH" + } + } + ], + "result": { + "name": "trace", + "description": "The function call trace of the transaction designated by the given hash", + "schema": { + "$ref": "#/components/schemas/TRANSACTION_TRACE" + } + }, + "errors": [ + { + "$ref": "#/components/errors/TXN_HASH_NOT_FOUND" + }, + { + "$ref": "#/components/errors/NO_TRACE_AVAILABLE" + } + ] + }, + { + "name": "starknet_simulateTransactions", + "summary": "Simulate a given sequence of transactions on the requested state, and generate the execution traces. Note that some of the transactions may revert, in which case no error is thrown, but revert details can be seen on the returned trace object. . Note that some of the transactions may revert, this will be reflected by the revert_error property in the trace. Other types of failures (e.g. unexpected error or failure in the validation phase) will result in TRANSACTION_EXECUTION_ERROR.", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on.", + "required": true, + "schema": { + "$ref": "#/components/schemas/BLOCK_ID" + } + }, + { + "name": "transactions", + "description": "The transactions to simulate", + "required": true, + "schema": { + "type": "array", + "description": "a sequence of transactions to simulate, running each transaction on the state resulting from applying all the previous ones", + "items": { + "$ref": "#/components/schemas/BROADCASTED_TXN" + } + } + }, + { + "name": "simulation_flags", + "description": "describes what parts of the transaction should be executed", + "required": true, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SIMULATION_FLAG" + } + } + } + ], + "result": { + "name": "simulated_transactions", + "description": "The execution trace and consuemd resources of the required transactions", + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "transaction_trace": { + "title": "the transaction's trace", + "$ref": "#/components/schemas/TRANSACTION_TRACE" + }, + "fee_estimation": { + "title": "the transaction's resources and fee", + "$ref": "#/components/schemas/FEE_ESTIMATE" + } + } + } + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + }, + { + "$ref": "#/components/errors/TRANSACTION_EXECUTION_ERROR" + } + ] + }, + { + "name": "starknet_traceBlockTransactions", + "summary": "Retrieve traces for all transactions in the given block", + "description": "Returns the execution traces of all transactions included in the given block", + "params": [ + { + "name": "block_id", + "description": "The hash of the requested block, or number (height) of the requested block, or a block tag", + "required": true, + "schema": { + "$ref": "#/components/schemas/BLOCK_ID" + } + } + ], + "result": { + "name": "traces", + "description": "The traces of all transactions in the block", + "schema": { + "type": "array", + "items": { + "type": "object", + "description": "A single pair of transaction hash and corresponding trace", + "properties": { + "transaction_hash": { + "$ref": "#/components/schemas/FELT" + }, + "trace_root": { + "$ref": "#/components/schemas/TRANSACTION_TRACE" + } + } + } + } + }, + "errors": [ + { + "$ref": "#/components/errors/BLOCK_NOT_FOUND" + } + ] + } + ], + "components": { + "contentDescriptors": {}, + "schemas": { + "TRANSACTION_TRACE": { + "oneOf": [ + { + "name": "INVOKE_TXN_TRACE", + "type": "object", + "description": "the execution trace of an invoke transaction", + "properties": { + "validate_invocation": { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "execute_invocation": { + "description": "the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)", + "oneOf": [ + { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + { + "type": "object", + "properties": { + "revert_reason": { + "name": "revert reason", + "description": "the revert reason for the failed execution", + "type": "string" + } + }, + "required": [ + "revert_reason" + ] + } + ] + }, + "fee_transfer_invocation": { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "state_diff": { + "title": "state_diff", + "description": "the state diffs induced by the transaction", + "$ref": "#/components/schemas/STATE_DIFF" + }, + "execution_resources": { + "title": "Execution resources", + "description": "the resources consumed by the transaction, includes both computation and data", + "$ref": "#/components/schemas/EXECUTION_RESOURCES" + }, + "type": { + "title": "Type", + "type": "string", + "enum": [ + "INVOKE" + ] + } + }, + "required": [ + "type", + "execute_invocation", + "execution_resources" + ] + }, + { + "name": "DECLARE_TXN_TRACE", + "type": "object", + "description": "the execution trace of a declare transaction", + "properties": { + "validate_invocation": { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "fee_transfer_invocation": { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "state_diff": { + "title": "state_diff", + "description": "the state diffs induced by the transaction", + "$ref": "#/components/schemas/STATE_DIFF" + }, + "execution_resources": { + "title": "Execution resources", + "description": "the resources consumed by the transaction, includes both computation and data", + "$ref": "#/components/schemas/EXECUTION_RESOURCES" + }, + "type": { + "title": "Type", + "type": "string", + "enum": [ + "DECLARE" + ] + } + }, + "required": [ + "type", + "execution_resources" + ] + }, + { + "name": "DEPLOY_ACCOUNT_TXN_TRACE", + "type": "object", + "description": "the execution trace of a deploy account transaction", + "properties": { + "validate_invocation": { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "constructor_invocation": { + "description": "the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)", + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "fee_transfer_invocation": { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "state_diff": { + "title": "state_diff", + "description": "the state diffs induced by the transaction", + "$ref": "#/components/schemas/STATE_DIFF" + }, + "execution_resources": { + "title": "Execution resources", + "description": "the resources consumed by the transaction, includes both computation and data", + "$ref": "#/components/schemas/EXECUTION_RESOURCES" + }, + "type": { + "title": "Type", + "type": "string", + "enum": [ + "DEPLOY_ACCOUNT" + ] + } + }, + "required": [ + "type", + "execution_resources", + "constructor_invocation" + ] + }, + { + "name": "L1_HANDLER_TXN_TRACE", + "type": "object", + "description": "the execution trace of an L1 handler transaction", + "properties": { + "function_invocation": { + "description": "the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)", + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "state_diff": { + "title": "state_diff", + "description": "the state diffs induced by the transaction", + "$ref": "#/components/schemas/STATE_DIFF" + }, + "execution_resources": { + "title": "Execution resources", + "description": "the resources consumed by the transaction, includes both computation and data", + "$ref": "#/components/schemas/EXECUTION_RESOURCES" + }, + "type": { + "title": "Type", + "type": "string", + "enum": [ + "L1_HANDLER" + ] + } + }, + "required": [ + "type", + "function_invocation", + "execution_resources" + ] + } + ] + }, + "SIMULATION_FLAG": { + "type": "string", + "enum": [ + "SKIP_VALIDATE", + "SKIP_FEE_CHARGE" + ], + "description": "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." + }, + "NESTED_CALL": { + "$ref": "#/components/schemas/FUNCTION_INVOCATION" + }, + "FUNCTION_INVOCATION": { + "allOf": [ + { + "$ref": "#/components/schemas/FUNCTION_CALL" + }, + { + "type": "object", + "properties": { + "caller_address": { + "title": "Caller Address", + "description": "The address of the invoking contract. 0 for the root invocation", + "$ref": "#/components/schemas/FELT" + }, + "class_hash": { + "title": "Class hash", + "description": "The hash of the class being called", + "$ref": "#/components/schemas/FELT" + }, + "entry_point_type": { + "$ref": "#/components/schemas/ENTRY_POINT_TYPE" + }, + "call_type": { + "$ref": "#/components/schemas/CALL_TYPE" + }, + "result": { + "title": "Invocation Result", + "description": "The value returned from the function invocation", + "type": "array", + "items": { + "$ref": "#/components/schemas/FELT" + } + }, + "calls": { + "title": "Nested Calls", + "description": "The calls made by this invocation", + "type": "array", + "items": { + "$ref": "#/components/schemas/NESTED_CALL" + } + }, + "events": { + "title": "Invocation Events", + "description": "The events emitted in this invocation", + "type": "array", + "items": { + "$ref": "#/components/schemas/ORDERED_EVENT" + } + }, + "messages": { + "title": "L1 Messages", + "description": "The messages sent by this invocation to L1", + "type": "array", + "items": { + "$ref": "#/components/schemas/ORDERED_MESSAGE" + } + }, + "execution_resources": { + "title": "Computation resources", + "description": "Resources consumed by the internal call. This is named execution_resources for legacy reasons", + "$ref": "#/components/schemas/COMPUTATION_RESOURCES" + } + }, + "required": [ + "caller_address", + "class_hash", + "entry_point_type", + "call_type", + "result", + "calls", + "events", + "messages", + "execution_resources" + ] + } + ] + }, + "ENTRY_POINT_TYPE": { + "type": "string", + "enum": [ + "EXTERNAL", + "L1_HANDLER", + "CONSTRUCTOR" + ] + }, + "CALL_TYPE": { + "type": "string", + "enum": [ + "LIBRARY_CALL", + "CALL", + "DELEGATE" + ] + }, + "ORDERED_EVENT": { + "type": "object", + "title": "orderedEvent", + "description": "an event alongside its order within the transaction", + "allOf": [ + { + "type": "object", + "properties": { + "order": { + "title": "order", + "description": "the order of the event within the transaction", + "type": "integer" + } + } + }, + { + "$ref": "#/components/schemas/EVENT" + } + ] + }, + "ORDERED_MESSAGE": { + "type": "object", + "title": "orderedMessage", + "description": "a message alongside its order within the transaction", + "allOf": [ + { + "type": "object", + "properties": { + "order": { + "title": "order", + "description": "the order of the message within the transaction", + "type": "integer" + } + } + }, + { + "$ref": "#/components/schemas/MSG_TO_L1" + } + ] + }, + "FELT": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/FELT" + }, + "FUNCTION_CALL": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/FUNCTION_CALL" + }, + "EVENT": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/EVENT_CONTENT" + }, + "MSG_TO_L1": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/MSG_TO_L1" + }, + "BLOCK_ID": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/BLOCK_ID" + }, + "FEE_ESTIMATE": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/FEE_ESTIMATE" + }, + "BROADCASTED_TXN": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/BROADCASTED_TXN" + }, + "STATE_DIFF": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/STATE_DIFF" + }, + "COMPUTATION_RESOURCES": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/COMPUTATION_RESOURCES" + }, + "EXECUTION_RESOURCES": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/EXECUTION_RESOURCES" + } + }, + "errors": { + "NO_TRACE_AVAILABLE": { + "code": 10, + "message": "No trace available for transaction", + "data": { + "type": "object", + "description": "Extra information on why trace is not available. Either it wasn't executed yet (RECEIVED), or the transaction failed (REJECTED)", + "properties": { + "status": { + "type": "string", + "enum": [ + "RECEIVED", + "REJECTED" + ] + } + } + } + }, + "TXN_HASH_NOT_FOUND": { + "$ref": "./api/starknet_api_openrpc.json#/components/errors/TXN_HASH_NOT_FOUND" + }, + "BLOCK_NOT_FOUND": { + "$ref": "./api/starknet_api_openrpc.json#/components/errors/BLOCK_NOT_FOUND" + }, + "TRANSACTION_EXECUTION_ERROR": { + "$ref": "./api/starknet_api_openrpc.json#/components/errors/TRANSACTION_EXECUTION_ERROR" + } + } + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..6d9cde4d --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.rs @@ -0,0 +1,455 @@ +// +// 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, + FunctionCall, MsgToL1, StateDiff, TxnHash, +}; +use alloc::string::String; +use alloc::vec::Vec; +use core::marker::PhantomData; +use serde::ser::SerializeMap; +use serde::{Deserialize, Serialize}; + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum CallType { + #[serde(rename = "CALL")] + Regular, + #[serde(rename = "DELEGATE")] + Delegate, + #[serde(rename = "LIBRARY_CALL")] + LibraryCall, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum EntryPointType { + #[serde(rename = "CONSTRUCTOR")] + Constructor, + #[serde(rename = "EXTERNAL")] + External, + #[serde(rename = "L1_HANDLER")] + L1Handler, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct FunctionInvocation { + #[serde(flatten)] + pub function_call: FunctionCall, + pub call_type: CallType, + /// The address of the invoking contract. 0 for the root invocation + pub caller_address: F, + /// The calls made by this invocation + pub calls: Vec>, + /// The hash of the class being called + pub class_hash: F, + pub entry_point_type: EntryPointType, + /// The events emitted in this invocation + pub events: Vec>, + /// Resources consumed by the internal call. This is named execution_resources for legacy reasons + pub execution_resources: ComputationResources, + /// The messages sent by this invocation to L1 + pub messages: Vec>, + /// The value returned from the function invocation + pub result: Vec, +} + +pub type NestedCall = FunctionInvocation; + +/// an event alongside its order within the transaction +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct OrderedEvent { + /// the order of the event within the transaction + #[serde(default)] + pub order: Option, + #[serde(flatten)] + pub event: Event, +} + +/// a message alongside its order within the transaction +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct OrderedMessage { + /// the order of the message within the transaction + #[serde(default)] + pub order: Option, + #[serde(flatten)] + pub msg_to_l_1: MsgToL1, +} + +/// 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(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +pub enum SimulationFlag { + #[serde(rename = "SKIP_FEE_CHARGE")] + FeeCharge, + #[serde(rename = "SKIP_VALIDATE")] + Validate, +} + +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(tag = "type")] +pub enum TransactionTrace { + /// the execution trace of an invoke transaction + #[serde(rename = "INVOKE")] + Invoke(InvokeTransactionTrace), + /// the execution trace of a declare transaction + #[serde(rename = "DECLARE")] + Declare(DeclareTransactionTrace), + /// the execution trace of a deploy account transaction + #[serde(rename = "DEPLOY_ACCOUNT")] + DeployAccount(DeployAccountTransactionTrace), + /// the execution trace of an L1 handler transaction + #[serde(rename = "L1_HANDLER")] + L1Handler(L1HandlerTransactionTrace), +} + +/// the execution trace of an invoke transaction +#[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, + /// the resources consumed by the transaction, includes both computation and data + pub execution_resources: ExecutionResources, + #[serde(default)] + pub fee_transfer_invocation: Option>, + /// the state diffs induced by the transaction + #[serde(default)] + pub state_diff: Option>, + #[serde(default)] + pub validate_invocation: Option>, +} + +/// the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) +#[derive(Eq, Hash, PartialEq, Serialize, Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum ExecuteInvocation { + FunctionInvocation(FunctionInvocation), + Anon(RevertedInvocation), +} + +#[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, Hash, PartialEq, Serialize, Deserialize)] +pub struct DeclareTransactionTrace { + /// the resources consumed by the transaction, includes both computation and data + pub execution_resources: ExecutionResources, + #[serde(default)] + pub fee_transfer_invocation: Option>, + /// the state diffs induced by the transaction + #[serde(default)] + pub state_diff: Option>, + #[serde(default)] + pub validate_invocation: Option>, +} + +/// the execution trace of a deploy account transaction +#[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, + /// the resources consumed by the transaction, includes both computation and data + pub execution_resources: ExecutionResources, + #[serde(default)] + pub fee_transfer_invocation: Option>, + /// the state diffs induced by the transaction + #[serde(default)] + pub state_diff: Option>, + #[serde(default)] + pub validate_invocation: Option>, +} + +/// the execution trace of an L1 handler transaction +#[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, + /// the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions) + pub function_invocation: FunctionInvocation, + /// the state diffs induced by the transaction + #[serde(default)] + pub state_diff: Option>, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct SimulateTransactionsResult { + #[serde(default)] + pub fee_estimation: Option>, + #[serde(default)] + pub transaction_trace: Option>, +} + +/// A single pair of transaction hash and corresponding trace +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct TraceBlockTransactionsResult { + #[serde(default)] + pub trace_root: Option>, + #[serde(default)] + pub transaction_hash: Option, +} + +/// Parameters of the `starknet_traceTransaction` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct TraceTransactionParams { + /// The hash of the transaction to trace + pub transaction_hash: TxnHash, +} + +impl Serialize for TraceTransactionParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("transaction_hash", &self.transaction_hash)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for TraceTransactionParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + type Value = TraceTransactionParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_traceTransaction`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let transaction_hash: TxnHash = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(TraceTransactionParams { transaction_hash }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + transaction_hash: TxnHash, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(TraceTransactionParams { + transaction_hash: helper.transaction_hash, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_simulateTransactions` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct SimulateTransactionsParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on. + pub block_id: BlockId, + /// The transactions to simulate + pub transactions: Vec>, + /// describes what parts of the transaction should be executed + pub simulation_flags: Vec, +} + +impl Serialize for SimulateTransactionsParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.serialize_entry("transactions", &self.transactions)?; + map.serialize_entry("simulation_flags", &self.simulation_flags)?; + map.end() + } +} + +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for SimulateTransactionsParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_simulateTransactions`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 3 parameters"))?; + let transactions: Vec> = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(2, &"expected 3 parameters"))?; + let simulation_flags: Vec = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(3, &"expected 3 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 4, + &"expected 3 parameters", + )); + } + + Ok(SimulateTransactionsParams { + block_id, + transactions, + simulation_flags, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + transactions: Vec>, + simulation_flags: Vec, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(SimulateTransactionsParams { + block_id: helper.block_id, + transactions: helper.transactions, + simulation_flags: helper.simulation_flags, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_traceBlockTransactions` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct TraceBlockTransactionsParams { + /// The hash of the requested block, or number (height) of the requested block, or a block tag + pub block_id: BlockId, +} + +impl Serialize for TraceBlockTransactionsParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("block_id", &self.block_id)?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for TraceBlockTransactionsParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + type Value = TraceBlockTransactionsParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_traceBlockTransactions`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let block_id: BlockId = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(TraceBlockTransactionsParams { block_id }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + block_id: BlockId, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(TraceBlockTransactionsParams { + block_id: helper.block_id, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + 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 new file mode 100644 index 00000000..b670eb5d --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_trace_api_openrpc.toml @@ -0,0 +1,57 @@ +debug-path = false +run-rustfmt = true + +[generation] +additional-imports = [ + "super::{FunctionCall, Event, MsgToL1, BlockId, FeeEstimate, BroadcastedTxn, StateDiff, TxnHash, ExecutionResources, ComputationResources}", + "alloc::vec::Vec", + "alloc::string::String", + "core::marker::PhantomData" +] +method-name-prefix = "starknet_" +param-types = true +use-core = true + +[formatters] +num-as-hex = "NumAsHex" + +[fixes] +strip-enum-variants = true +flatten = [ + "#/components/schemas/EXECUTION_RESOURCES", + "#/components/schemas/COMPUTATION_RESOURCES", +] + +[fixes.replace] +"#/components/schemas/FELT" = "F" +"#/components/schemas/FUNCTION_CALL" = "FunctionCall" +"#/components/schemas/EVENT" = "Event" +"#/components/schemas/MSG_TO_L1" = "MsgToL1" +"#/components/schemas/BLOCK_ID" = "BlockId" +"#/components/schemas/FEE_ESTIMATE" = "FeeEstimate" +"#/components/schemas/BROADCASTED_TXN" = "BroadcastedTxn" +"#/components/schemas/STATE_DIFF" = "StateDiff" +"./starknet_api_openrpc.json#/components/schemas/TXN_HASH" = "TxnHash" +"./api/starknet_api_openrpc.json#/components/schemas/EXECUTION_RESOURCES" = "ExecutionResources" +"./api/starknet_api_openrpc.json#/components/schemas/COMPUTATION_RESOURCES" = "ComputationResources" + +[fixes.rename] +"#/components/schemas/CALL_TYPE/CALL" = "Regular" +"#/components/schemas/TRANSACTION_TRACE/variant0" = "Invoke" +"#/components/schemas/TRANSACTION_TRACE/variant0/_anon" = "InvokeTransactionTrace" +"#/components/schemas/TRANSACTION_TRACE/variant1" = "Declare" +"#/components/schemas/TRANSACTION_TRACE/variant1/_anon" = "DeclareTransactionTrace" +"#/components/schemas/TRANSACTION_TRACE/variant2" = "DeployAccount" +"#/components/schemas/TRANSACTION_TRACE/variant2/_anon" = "DeployAccountTransactionTrace" +"#/components/schemas/TRANSACTION_TRACE/variant3" = "L1Handler" +"#/components/schemas/TRANSACTION_TRACE/variant3/_anon" = "L1HandlerTransactionTrace" +"#/components/schemas/TRANSACTION_TRACE/variant0/_anon/execute_invocation/_anon/variant1/_anon" = "RevertedInvocation" +"#/components/schemas/TRANSACTION_TRACE/variant0/_anon/execute_invocation/_anon" = "ExecuteInvocation" +"#/methods/starknet_simulateTransactions/result/_anon/_anon" = "SimulateTransactionsResult" +"#/methods/starknet_traceBlockTransactions/result/_anon/_anon" = "TraceBlockTransactionsResult" + +[fixes.tagged-enums] +"#/components/schemas/TRANSACTION_TRACE" = "type" + +[primitives] +integer = "u64" diff --git a/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.json b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.json new file mode 100644 index 00000000..281ab9b4 --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.json @@ -0,0 +1,299 @@ +{ + "openrpc": "1.0.0-rc1", + "info": { + "version": "0.7.1", + "title": "StarkNet Node Write API", + "license": {} + }, + "servers": [], + "methods": [ + { + "name": "starknet_addInvokeTransaction", + "summary": "Submit a new transaction to be added to the chain", + "params": [ + { + "name": "invoke_transaction", + "description": "The information needed to invoke the function (or account, for version 1 transactions)", + "required": true, + "schema": { + "$ref": "#/components/schemas/BROADCASTED_INVOKE_TXN" + } + } + ], + "result": { + "name": "result", + "description": "The result of the transaction submission", + "schema": { + "type": "object", + "properties": { + "transaction_hash": { + "title": "The hash of the invoke transaction", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/INSUFFICIENT_ACCOUNT_BALANCE" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_MAX_FEE" + }, + { + "$ref": "#/components/errors/INVALID_TRANSACTION_NONCE" + }, + { + "$ref": "#/components/errors/VALIDATION_FAILURE" + }, + { + "$ref": "#/components/errors/NON_ACCOUNT" + }, + { + "$ref": "#/components/errors/DUPLICATE_TX" + }, + { + "$ref": "#/components/errors/UNSUPPORTED_TX_VERSION" + }, + { + "$ref": "#/components/errors/UNEXPECTED_ERROR" + } + ] + }, + { + "name": "starknet_addDeclareTransaction", + "summary": "Submit a new class declaration transaction", + "params": [ + { + "name": "declare_transaction", + "description": "Declare transaction required to declare a new class on Starknet", + "required": true, + "schema": { + "title": "Declare transaction", + "$ref": "#/components/schemas/BROADCASTED_DECLARE_TXN" + } + } + ], + "result": { + "name": "result", + "description": "The result of the transaction submission", + "schema": { + "type": "object", + "properties": { + "transaction_hash": { + "title": "The hash of the declare transaction", + "$ref": "#/components/schemas/TXN_HASH" + }, + "class_hash": { + "title": "The hash of the declared class", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "transaction_hash", + "class_hash" + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/CLASS_ALREADY_DECLARED" + }, + { + "$ref": "#/components/errors/COMPILATION_FAILED" + }, + { + "$ref": "#/components/errors/COMPILED_CLASS_HASH_MISMATCH" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_ACCOUNT_BALANCE" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_MAX_FEE" + }, + { + "$ref": "#/components/errors/INVALID_TRANSACTION_NONCE" + }, + { + "$ref": "#/components/errors/VALIDATION_FAILURE" + }, + { + "$ref": "#/components/errors/NON_ACCOUNT" + }, + { + "$ref": "#/components/errors/DUPLICATE_TX" + }, + { + "$ref": "#/components/errors/CONTRACT_CLASS_SIZE_IS_TOO_LARGE" + }, + { + "$ref": "#/components/errors/UNSUPPORTED_TX_VERSION" + }, + { + "$ref": "#/components/errors/UNSUPPORTED_CONTRACT_CLASS_VERSION" + }, + { + "$ref": "#/components/errors/UNEXPECTED_ERROR" + } + ] + }, + { + "name": "starknet_addDeployAccountTransaction", + "summary": "Submit a new deploy account transaction", + "params": [ + { + "name": "deploy_account_transaction", + "description": "The deploy account transaction", + "required": true, + "schema": { + "$ref": "#/components/schemas/BROADCASTED_DEPLOY_ACCOUNT_TXN" + } + } + ], + "result": { + "name": "result", + "description": "The result of the transaction submission", + "schema": { + "type": "object", + "properties": { + "transaction_hash": { + "title": "The hash of the deploy transaction", + "$ref": "#/components/schemas/TXN_HASH" + }, + "contract_address": { + "title": "The address of the new contract", + "$ref": "#/components/schemas/FELT" + } + }, + "required": [ + "transaction_hash", + "contract_address" + ] + } + }, + "errors": [ + { + "$ref": "#/components/errors/INSUFFICIENT_ACCOUNT_BALANCE" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_MAX_FEE" + }, + { + "$ref": "#/components/errors/INVALID_TRANSACTION_NONCE" + }, + { + "$ref": "#/components/errors/VALIDATION_FAILURE" + }, + { + "$ref": "#/components/errors/NON_ACCOUNT" + }, + { + "$ref": "#/components/errors/CLASS_HASH_NOT_FOUND" + }, + { + "$ref": "#/components/errors/DUPLICATE_TX" + }, + { + "$ref": "#/components/errors/UNSUPPORTED_TX_VERSION" + }, + { + "$ref": "#/components/errors/UNEXPECTED_ERROR" + } + ] + } + ], + "components": { + "contentDescriptors": {}, + "schemas": { + "NUM_AS_HEX": { + "title": "An integer number in hex format (0x...)", + "type": "string", + "pattern": "^0x[a-fA-F0-9]+$" + }, + "SIGNATURE": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/SIGNATURE" + }, + "FELT": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/FELT" + }, + "TXN_HASH": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/TXN_HASH" + }, + "BROADCASTED_INVOKE_TXN": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/BROADCASTED_INVOKE_TXN" + }, + "BROADCASTED_DECLARE_TXN": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/BROADCASTED_DECLARE_TXN" + }, + "BROADCASTED_DEPLOY_ACCOUNT_TXN": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/BROADCASTED_DEPLOY_ACCOUNT_TXN" + }, + "FUNCTION_CALL": { + "$ref": "./starknet_api_openrpc.json#/components/schemas/FUNCTION_CALL" + } + }, + "errors": { + "CLASS_HASH_NOT_FOUND": { + "code": 28, + "message": "Class hash not found" + }, + "CLASS_ALREADY_DECLARED": { + "code": 51, + "message": "Class already declared" + }, + "INVALID_TRANSACTION_NONCE": { + "code": 52, + "message": "Invalid transaction nonce" + }, + "INSUFFICIENT_MAX_FEE": { + "code": 53, + "message": "Max fee is smaller than the minimal transaction cost (validation plus fee transfer)" + }, + "INSUFFICIENT_ACCOUNT_BALANCE": { + "code": 54, + "message": "Account balance is smaller than the transaction's max_fee" + }, + "VALIDATION_FAILURE": { + "code": 55, + "message": "Account validation failed", + "data": "string" + }, + "COMPILATION_FAILED": { + "code": 56, + "message": "Compilation failed" + }, + "CONTRACT_CLASS_SIZE_IS_TOO_LARGE": { + "code": 57, + "message": "Contract class size it too large" + }, + "NON_ACCOUNT": { + "code": 58, + "message": "Sender address in not an account contract" + }, + "DUPLICATE_TX": { + "code": 59, + "message": "A transaction with the same hash already exists in the mempool" + }, + "COMPILED_CLASS_HASH_MISMATCH": { + "code": 60, + "message": "the compiled class hash did not match the one supplied in the transaction" + }, + "UNSUPPORTED_TX_VERSION": { + "code": 61, + "message": "the transaction version is not supported" + }, + "UNSUPPORTED_CONTRACT_CLASS_VERSION": { + "code": 62, + "message": "the contract class version is not supported" + }, + "UNEXPECTED_ERROR": { + "code": 63, + "message": "An unexpected error occurred", + "data": "string" + } + } + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..e379d571 --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.rs @@ -0,0 +1,278 @@ +// +// 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, TxnHash}; +use core::marker::PhantomData; +use serde::ser::SerializeMap; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ClassAndTxnHash { + pub class_hash: F, + pub transaction_hash: TxnHash, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct ContractAndTxnHash { + pub contract_address: F, + pub transaction_hash: TxnHash, +} + +#[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 { + /// The information needed to invoke the function (or account, for version 1 transactions) + pub invoke_transaction: BroadcastedInvokeTxn, +} + +impl Serialize for AddInvokeTransactionParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("invoke_transaction", &self.invoke_transaction)?; + map.end() + } +} + +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for AddInvokeTransactionParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + 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 { + write!(f, "the parameters for `starknet_addInvokeTransaction`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let invoke_transaction: BroadcastedInvokeTxn = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(AddInvokeTransactionParams { invoke_transaction }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + invoke_transaction: BroadcastedInvokeTxn, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(AddInvokeTransactionParams { + invoke_transaction: helper.invoke_transaction, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_addDeclareTransaction` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct AddDeclareTransactionParams { + /// Declare transaction required to declare a new class on Starknet + pub declare_transaction: BroadcastedDeclareTxn, +} + +impl Serialize for AddDeclareTransactionParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("declare_transaction", &self.declare_transaction)?; + map.end() + } +} + +impl<'de, F: Default + Deserialize<'de>> Deserialize<'de> for AddDeclareTransactionParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + impl<'de, F: Default + Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + type Value = AddDeclareTransactionParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(f, "the parameters for `starknet_addDeclareTransaction`") + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let declare_transaction: BroadcastedDeclareTxn = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(AddDeclareTransactionParams { + declare_transaction, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + declare_transaction: BroadcastedDeclareTxn, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(AddDeclareTransactionParams { + declare_transaction: helper.declare_transaction, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} + +/// Parameters of the `starknet_addDeployAccountTransaction` method. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct AddDeployAccountTransactionParams { + /// The deploy account transaction + pub deploy_account_transaction: BroadcastedDeployAccountTxn, +} + +impl Serialize for AddDeployAccountTransactionParams { + #[allow(unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry( + "deploy_account_transaction", + &self.deploy_account_transaction, + )?; + map.end() + } +} + +impl<'de, F: Deserialize<'de>> Deserialize<'de> for AddDeployAccountTransactionParams { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct Visitor { + marker: PhantomData, + } + + impl<'de, F: Deserialize<'de>> serde::de::Visitor<'de> for Visitor { + type Value = AddDeployAccountTransactionParams; + + fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + write!( + f, + "the parameters for `starknet_addDeployAccountTransaction`" + ) + } + + #[allow(unused_mut)] + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let deploy_account_transaction: BroadcastedDeployAccountTxn = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &"expected 1 parameters"))?; + + if seq.next_element::()?.is_some() { + return Err(serde::de::Error::invalid_length( + 2, + &"expected 1 parameters", + )); + } + + Ok(AddDeployAccountTransactionParams { + deploy_account_transaction, + }) + } + + #[allow(unused_variables)] + fn visit_map(self, map: A) -> Result + where + A: serde::de::MapAccess<'de>, + { + #[derive(Deserialize)] + struct Helper { + deploy_account_transaction: BroadcastedDeployAccountTxn, + } + + let helper = + Helper::deserialize(serde::de::value::MapAccessDeserializer::new(map))?; + + Ok(AddDeployAccountTransactionParams { + deploy_account_transaction: helper.deploy_account_transaction, + }) + } + } + + deserializer.deserialize_any(Visitor:: { + marker: PhantomData, + }) + } +} 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 new file mode 100644 index 00000000..486146c8 --- /dev/null +++ b/crates/starknet-types-rpc/src/v0_7_1/starknet_write_api.toml @@ -0,0 +1,36 @@ +debug-path = false +run-rustfmt = true + +[generation] +additional-imports = [ + "super::{BroadcastedDeclareTxn, BroadcastedDeployAccountTxn, BroadcastedInvokeTxn, TxnHash}", + "core::marker::PhantomData" +] +method-name-prefix = "starknet_" +param-types = true +use-core = true +result-types = false + +[formatters] +num-as-hex = "NumAsHex" + +[fixes] +strip-enum-variants = true + +[fixes.replace] +"#/components/schemas/BROADCASTED_DECLARE_TXN" = "BroadcastedDeclareTxn" +"#/components/schemas/BROADCASTED_DEPLOY_ACCOUNT_TXN" = "BroadcastedDeployAccountTxn" +"#/components/schemas/BROADCASTED_INVOKE_TXN" = "BroadcastedInvokeTxn" +"#/components/schemas/DECLARE_TXN" = "DeclareTxn" +"#/components/schemas/FELT" = "F" +"#/components/schemas/FUNCTION_CALL" = "FunctionCall" +"#/components/schemas/SIGNATURE" = "Signature" +"#/components/schemas/TXN_HASH" = "TxnHash" + +[fixes.rename] +"#/methods/starknet_addDeclareTransaction/result/_anon" = "ClassAndTxnHash" +"#/methods/starknet_addDeployAccountTransaction/result/_anon" = "ContractAndTxnHash" +"#/methods/starknet_addInvokeTransaction/result/_anon" = "AddInvokeTransactionResult" + +[primitives] +integer = "u64"