Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if FORK_URL is defined, use that as url #36

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.


Expand Down
24 changes: 15 additions & 9 deletions src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ async fn run(
}

pub async fn simulate(transaction: SimulationRequest, config: Config) -> Result<Json, Rejection> {
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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -315,9 +319,11 @@ pub async fn simulate_stateful_new(
config: Config,
state: Arc<SharedSimulationState>,
) -> Result<Json, Rejection> {
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,
Expand Down