Skip to content

Commit

Permalink
solved undeclared classhash
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoGiachetta committed Aug 21, 2024
1 parent dad93b6 commit b7e8acb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rpc-state-reader/src/blockifier_state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b7e8acb

Please sign in to comment.