diff --git a/README.md b/README.md index d5b8a31..1d96790 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Example response: ``` Notes: - +- `chainId` must be the same as the `chainId` of the `FORK_URL` environment variable, if defined. - `blockNumber` can be omitted and the latest block will be used, however providing a `blockNumber` is recommended where possible to use the cache. ### POST /api/v1/simulate-bundle @@ -82,7 +82,7 @@ Example response: Notes: -- `chainId` must be the same in all transactions. +- `chainId` must be the same in all transactions and it must match the `chainId` of `FORK_URL` environment variable, if defined. - `blockNumber` can be included and incremented when a multi-block simulation is required, or omitted in all transactions to use latest. ### POST /api/v1/simulate-stateful @@ -148,7 +148,7 @@ Example response: ``` Notes: -- `chainId` must be the same in all transactions. +- `chainId` must be the same in all transactions and it must match the `chainId` of `FORK_URL` environment variable, if defined. - `blockNumber` can be included and incremented when a multi-block simulation is required, or omitted in all transactions to use latest. diff --git a/src/simulation.rs b/src/simulation.rs index 1595d5c..642fdfa 100644 --- a/src/simulation.rs +++ b/src/simulation.rs @@ -227,9 +227,11 @@ async fn run( } pub async fn simulate(transaction: SimulationRequest, config: Config) -> Result { - let fork_url = config - .fork_url - .unwrap_or(chain_id_to_fork_url(transaction.chain_id)?); + let fork_url = if let Some(url) = config.fork_url { + url + } else { + chain_id_to_fork_url(transaction.chain_id)? + }; let mut evm = Evm::new( None, fork_url, @@ -262,9 +264,11 @@ pub async fn simulate_bundle( let first_block_number = transactions[0].block_number; let first_block_timestamp = transactions[0].block_timestamp; - let fork_url = config - .fork_url - .unwrap_or(chain_id_to_fork_url(first_chain_id)?); + let fork_url = if let Some(url) = config.fork_url { + url + } else { + chain_id_to_fork_url(first_chain_id)? + }; let mut evm = Evm::new( None, fork_url, @@ -315,9 +319,11 @@ pub async fn simulate_stateful_new( config: Config, state: Arc, ) -> Result { - let fork_url = config - .fork_url - .unwrap_or(chain_id_to_fork_url(stateful_simulation_request.chain_id)?); + let fork_url = if let Some(url) = config.fork_url { + url + } else { + chain_id_to_fork_url(stateful_simulation_request.chain_id)? + }; let mut evm = Evm::new( None, fork_url,