diff --git a/bin/katana/src/cli/init/mod.rs b/bin/katana/src/cli/init/mod.rs index 51d1724a5b..007d551f13 100644 --- a/bin/katana/src/cli/init/mod.rs +++ b/bin/katana/src/cli/init/mod.rs @@ -9,10 +9,10 @@ use std::sync::Arc; use anyhow::{Context, Result}; use clap::Args; use inquire::{Confirm, CustomType}; -use katana_chain_spec::{SettlementLayer, DEV_UNALLOCATED}; +use katana_chain_spec::{DEV_UNALLOCATED, SettlementLayer}; use katana_primitives::chain::ChainId; -use katana_primitives::genesis::allocation::DevAllocationsGenerator; use katana_primitives::genesis::Genesis; +use katana_primitives::genesis::allocation::DevAllocationsGenerator; use katana_primitives::{ContractAddress, Felt}; use lazy_static::lazy_static; use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount}; @@ -23,27 +23,6 @@ use starknet::providers::{JsonRpcClient, Provider, Url}; use starknet::signers::{LocalWallet, SigningKey}; use tokio::runtime::Runtime; -#[derive(Debug)] -struct InitInput { - /// the account address that is used to send the transactions for contract - /// deployment/initialization. - account: ContractAddress, - - // the id of the new chain to be initialized. - id: String, - - // the chain id of the settlement layer. - settlement_id: String, - - // the rpc url for the settlement layer. - rpc_url: Url, - - settlement_contract: ContractAddress, - - // path at which the config file will be written at. - output_path: PathBuf, -} - #[derive(Debug, Args)] pub struct InitArgs { /// The path to where the config file will be written at. @@ -74,7 +53,7 @@ impl InitArgs { chain_spec.store(input.output_path) } - fn prompt(&self, rt: &Runtime) -> Result { + fn prompt(&self, rt: &Runtime) -> Result { let chain_id = CustomType::::new("Id") .with_help_message("This will be the id of your rollup chain.") // checks that the input is a valid ascii string. @@ -158,7 +137,7 @@ impl InitArgs { .0 }; - Ok(InitInput { + Ok(PromptOutcome { account: account_address, settlement_contract, settlement_id: parse_cairo_short_string(&l1_chain_id)?, @@ -169,6 +148,27 @@ impl InitArgs { } } +#[derive(Debug)] +struct PromptOutcome { + /// the account address that is used to send the transactions for contract + /// deployment/initialization. + account: ContractAddress, + + // the id of the new chain to be initialized. + id: String, + + // the chain id of the settlement layer. + settlement_id: String, + + // the rpc url for the settlement layer. + rpc_url: Url, + + settlement_contract: ContractAddress, + + // path at which the config file will be written at. + output_path: PathBuf, +} + // > CONFIG_DIR/$chain_id/config.json fn config_path(id: &str) -> Result { Ok(config_dir(id)?.join("config").with_extension("json")) diff --git a/crates/katana/core/src/backend/mod.rs b/crates/katana/core/src/backend/mod.rs index 1e08a27da4..b429e875c8 100644 --- a/crates/katana/core/src/backend/mod.rs +++ b/crates/katana/core/src/backend/mod.rs @@ -10,10 +10,10 @@ use katana_primitives::block::{ use katana_primitives::da::L1DataAvailabilityMode; use katana_primitives::env::BlockEnv; use katana_primitives::receipt::{Event, ReceiptWithTxHash}; -use katana_primitives::state::{StateUpdates, compute_state_diff_hash}; +use katana_primitives::state::{compute_state_diff_hash, StateUpdates}; use katana_primitives::transaction::{TxHash, TxWithHash}; use katana_primitives::version::CURRENT_STARKNET_VERSION; -use katana_primitives::{ContractAddress, Felt, address}; +use katana_primitives::{address, ContractAddress, Felt}; use katana_provider::traits::block::{BlockHashProvider, BlockWriter}; use katana_provider::traits::trie::TrieWriter; use katana_trie::compute_merkle_root;