From b7e8acb12602e9b4f28ac9a06172b55766aed8fd Mon Sep 17 00:00:00 2001 From: FrancoGiachetta Date: Wed, 21 Aug 2024 15:27:56 -0300 Subject: [PATCH] solved undeclared classhash --- rpc-state-reader/src/blockifier_state_reader.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rpc-state-reader/src/blockifier_state_reader.rs b/rpc-state-reader/src/blockifier_state_reader.rs index 182e4dc..1641503 100644 --- a/rpc-state-reader/src/blockifier_state_reader.rs +++ b/rpc-state-reader/src/blockifier_state_reader.rs @@ -358,9 +358,10 @@ pub fn execute_tx_configurable_with_state( } SNTransaction::Declare(tx) => { let block_number = block_context.block_info().block_number; + let network = parse_to_rpc_chain(&chain_id.to_string()); // we need to retrieve the next block in order to get the contract_class let next_block_state_reader = RpcStateReader( - RpcState::new_rpc(RpcChain::MainNet, (block_number.next()).unwrap().into()) + RpcState::new_rpc(network, (block_number.next()).unwrap().into()) .unwrap(), ); let contract_class = next_block_state_reader @@ -492,6 +493,15 @@ pub fn execute_tx_with_blockifier( account_transaction.execute(state, &context, false, true) } +fn parse_to_rpc_chain(network: &str) -> RpcChain { + match network { + "alpha-mainnet" => RpcChain::MainNet, + "alpha4" => RpcChain::TestNet, + "alpha4-2" => RpcChain::TestNet2, + _ => panic!("Invalid network name {}", network) + } +} + pub fn fetch_block_context(state: &RpcState, block_number: BlockNumber) -> BlockContext { let rpc_block_info = state.get_block_info().unwrap(); let gas_price = state.get_gas_price(block_number.0).unwrap();