diff --git a/Cargo.lock b/Cargo.lock index 75ed9c259bfc..293c5b631f16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,6 +121,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/?branch=onbjerg/alloy-temp-provider-trait#f59761220ee2951c42a44dfd4a7038e4ab17eea4" dependencies = [ "alloy-primitives", "serde", @@ -131,6 +132,7 @@ dependencies = [ [[package]] name = "alloy-networks" version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/?branch=onbjerg/alloy-temp-provider-trait#f59761220ee2951c42a44dfd4a7038e4ab17eea4" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -164,6 +166,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/?branch=onbjerg/alloy-temp-provider-trait#f59761220ee2951c42a44dfd4a7038e4ab17eea4" dependencies = [ "alloy-networks", "alloy-primitives", @@ -204,6 +207,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/?branch=onbjerg/alloy-temp-provider-trait#f59761220ee2951c42a44dfd4a7038e4ab17eea4" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -220,6 +224,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/?branch=onbjerg/alloy-temp-provider-trait#f59761220ee2951c42a44dfd4a7038e4ab17eea4" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -270,6 +275,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/?branch=onbjerg/alloy-temp-provider-trait#f59761220ee2951c42a44dfd4a7038e4ab17eea4" dependencies = [ "alloy-json-rpc", "base64 0.21.5", @@ -285,6 +291,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/?branch=onbjerg/alloy-temp-provider-trait#f59761220ee2951c42a44dfd4a7038e4ab17eea4" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -2849,7 +2856,6 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "alloy-providers", "async-trait", "clap", "color-eyre", diff --git a/Cargo.toml b/Cargo.toml index 1e76da5c8060..4f9cf429050d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -157,10 +157,10 @@ alloy-dyn-abi = "0.4.1" alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" -alloy-providers = { path = "../../alloy-rs/alloy/crates/providers" } -alloy-transport = { path = "../../alloy-rs/alloy/crates/transport" } -alloy-transport-http = { path = "../../alloy-rs/alloy/crates/transport-http" } -alloy-rpc-types = { path = "../../alloy-rs/alloy/crates/rpc-types" } +alloy-providers = "0.1.0" +alloy-transport = "0.1.0" +alloy-transport-http = "0.1.0" +alloy-rpc-types = "0.1.0" alloy-chains = "0.1.2" alloy-rlp = "0.3.3" @@ -211,6 +211,11 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +alloy-providers = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" } + alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-primitives = { git = "https://github.com/alloy-rs/core/" } alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } diff --git a/crates/anvil/core/src/eth/transaction/ethers_compat.rs b/crates/anvil/core/src/eth/transaction/ethers_compat.rs index 72508eb351a5..6fb9253ff788 100644 --- a/crates/anvil/core/src/eth/transaction/ethers_compat.rs +++ b/crates/anvil/core/src/eth/transaction/ethers_compat.rs @@ -124,7 +124,7 @@ pub fn to_ethers_state_override(ov: StateOverride) -> EthStateOverride { pub fn to_alloy_state_override(ov: EthStateOverride) -> StateOverride { ov.into_iter() .map(|(addr, o)| (addr.to_alloy(), AlloyAccountOverride { - nonce: o.nonce.map(|n| rU64::from(n)), + nonce: o.nonce.map(rU64::from), balance: o.balance.map(|b| b.to_alloy()), code: o.code.map(|c| c.0.into()), state_diff: o.state_diff.map(|s| s.into_iter().map(|(k, v)| (k.to_alloy(), rU256::from_be_bytes(v.to_alloy().0))).collect()), @@ -305,7 +305,7 @@ fn to_alloy_transaction_with_hash_and_sender( max_priority_fee_per_gas: Some(t.gas_price.to_alloy().to::()), gas: t.gas_limit.to_alloy(), input: t.input.clone().0.into(), - chain_id: t.chain_id().map(|c| rU64::from(c)), + chain_id: t.chain_id().map(rU64::from), signature: Some(Signature { r: t.signature.r.to_alloy(), s: t.signature.s.to_alloy(), @@ -316,7 +316,6 @@ fn to_alloy_transaction_with_hash_and_sender( transaction_type: None, max_fee_per_blob_gas: None, blob_versioned_hashes: vec![], - ..Default::default() }, TypedTransaction::EIP2930(t) => AlloyTransaction { hash: hash.to_alloy(), @@ -343,7 +342,6 @@ fn to_alloy_transaction_with_hash_and_sender( transaction_type: Some(rU64::from(1)), max_fee_per_blob_gas: None, blob_versioned_hashes: vec![], - ..Default::default() }, TypedTransaction::EIP1559(t) => AlloyTransaction { hash: hash.to_alloy(), @@ -370,7 +368,6 @@ fn to_alloy_transaction_with_hash_and_sender( transaction_type: Some(rU64::from(2)), max_fee_per_blob_gas: None, blob_versioned_hashes: vec![], - ..Default::default() }, } } diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 5e32d9ec3376..a643a06e54ce 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -194,9 +194,9 @@ impl NodeArgs { }; NodeConfig::default() - .with_gas_limit(self.evm_opts.gas_limit.map(|g| U256::from(g))) + .with_gas_limit(self.evm_opts.gas_limit.map(U256::from)) .disable_block_gas_limit(self.evm_opts.disable_block_gas_limit) - .with_gas_price(self.evm_opts.gas_price.map(|g| U256::from(g))) + .with_gas_price(self.evm_opts.gas_price.map(U256::from)) .with_hardfork(self.hardfork) .with_blocktime(self.block_time.map(Duration::from_secs)) .with_no_mining(self.no_mining) @@ -210,13 +210,13 @@ impl NodeArgs { .or_else(|| self.evm_opts.fork_url.as_ref().and_then(|f| f.block)), ) .with_fork_headers(self.evm_opts.fork_headers) - .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from).map(|c| U256::from(c))) + .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from).map(U256::from)) .fork_request_timeout(self.evm_opts.fork_request_timeout.map(Duration::from_millis)) .fork_request_retries(self.evm_opts.fork_request_retries) .fork_retry_backoff(self.evm_opts.fork_retry_backoff.map(Duration::from_millis)) .fork_compute_units_per_second(compute_units_per_second) .with_eth_rpc_url(self.evm_opts.fork_url.map(|fork| fork.url)) - .with_base_fee(self.evm_opts.block_base_fee_per_gas.map(|f| U256::from(f))) + .with_base_fee(self.evm_opts.block_base_fee_per_gas.map(U256::from)) .with_storage_caching(self.evm_opts.no_storage_caching) .with_server_config(self.server_config) .with_host(self.host) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index a807cdedc316..50ecf45d7116 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -475,7 +475,7 @@ impl NodeConfig { #[must_use] pub fn with_gas_limit(mut self, gas_limit: Option) -> Self { if let Some(gas_limit) = gas_limit { - self.gas_limit = gas_limit.into(); + self.gas_limit = gas_limit; } self } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 3a01b1c0a63b..a5131b274566 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -9,7 +9,7 @@ use crate::{ validate::TransactionValidator, }, error::{ - decode_revert_reason, BlockchainError, FeeHistoryError, InvalidTransactionError, + BlockchainError, FeeHistoryError, InvalidTransactionError, Result, ToRpcResponseResult, }, fees::{FeeDetails, FeeHistoryCache}, @@ -602,10 +602,10 @@ impl EthApi { if let BlockRequest::Number(number) = &block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number.to::()) { - return Ok(fork + return fork .get_balance(address, number.to::()) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -768,10 +768,10 @@ impl EthApi { if let BlockRequest::Number(number) = &block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number.to::()) { - return Ok(fork + return fork .get_code(address, number.to::()) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -796,10 +796,10 @@ impl EthApi { // if we're in forking mode, or still on the forked block (no blocks mined yet) then // we can delegate the call if fork.predates_fork_inclusive(number.to::()) { - return Ok(fork + return fork .get_proof(address, keys, Some((*number).into())) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -984,10 +984,10 @@ impl EthApi { "not available on past forked blocks".to_string(), )); } - return Ok(fork + return fork .call(&request, Some(number.to::().into())) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -1035,10 +1035,10 @@ impl EthApi { if let BlockRequest::Number(number) = &block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number.to::()) { - return Ok(fork + return fork .create_access_list(&request, Some(number.to::().into())) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -1166,10 +1166,10 @@ impl EthApi { self.backend.ensure_block_number(Some(BlockId::Hash(block_hash.into()))).await?; if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return Ok(fork + return fork .uncle_by_block_hash_and_index(block_hash, idx.into()) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } // It's impossible to have uncles outside of fork mode @@ -1188,10 +1188,10 @@ impl EthApi { let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?; if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return Ok(fork + return fork .uncle_by_block_number_and_index(number, idx.into()) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } // It's impossible to have uncles outside of fork mode @@ -1266,14 +1266,14 @@ impl EthApi { // if we're still at the forked block we don't have any history and can't compute it // efficiently, instead we fetch it from the fork if fork.predates_fork_inclusive(number) { - return Ok(fork + return fork .fee_history( block_count, BlockNumber::Number(number), &reward_percentiles, ) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } @@ -1788,7 +1788,7 @@ impl EthApi { latest_block_number: latest_block_number_uint, instance_id: *self.instance_id.read(), forked_network: fork_config.map(|cfg| ForkedNetwork { - chain_id: U256::from(cfg.chain_id()).into(), + chain_id: U256::from(cfg.chain_id()), fork_block_number: U64::from(cfg.block_number()), fork_block_hash: cfg.block_hash(), }), @@ -1910,7 +1910,7 @@ impl EthApi { }; for tx in block_txs.iter_mut() { if let Some(receipt) = self.backend.mined_transaction_receipt(tx.hash) { - if let Some(output) = receipt.out { + if let Some(_output) = receipt.out { // insert revert reason if failure // TODO: Support for additional fields // if receipt.inner.status_code.unwrap_or_default().to::() == 0 { @@ -2161,10 +2161,10 @@ impl EthApi { if let BlockRequest::Number(number) = &block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number.to::()) { - return Ok(fork + return fork .estimate_gas(&request, Some((*number).into())) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -2539,10 +2539,10 @@ impl EthApi { if let BlockRequest::Number(number) = &block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number.to::()) { - return Ok(fork + return fork .get_nonce(address, (*number).to::()) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -2566,7 +2566,7 @@ impl EthApi { ) -> Result<(U256, U256)> { let highest_nonce = self.get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))).await?; - let nonce = request.nonce.map(|n| U256::from(n)).unwrap_or(highest_nonce); + let nonce = request.nonce.map(U256::from).unwrap_or(highest_nonce); Ok((nonce, highest_nonce)) } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 3bbc2c78a61b..92afb90fb486 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -61,7 +61,7 @@ impl ClientFork { self.config.write().update_url(url)?; let override_chain_id = self.config.read().override_chain_id; let chain_id = if let Some(chain_id) = override_chain_id { - chain_id.into() + chain_id } else { self.provider().get_chain_id().await?.to::() }; @@ -239,7 +239,7 @@ impl ClientFork { number: Option, ) -> Result { let index = B256::from(index); - self.provider().get_storage_at(address, index.into(), number.map(Into::into)).await + self.provider().get_storage_at(address, index, number.map(Into::into)).await } pub async fn logs(&self, filter: &Filter) -> Result, TransportError> { @@ -353,7 +353,7 @@ impl ClientFork { let mut storage = self.storage_write(); storage.transactions.insert(hash, tx.clone()); - return Ok(Some(tx)); + Ok(Some(tx)) } pub async fn trace_transaction(&self, hash: B256) -> Result, TransportError> { @@ -481,7 +481,7 @@ impl ClientFork { }; storage.transactions.extend(block_txs.iter().map(|tx| (tx.hash, tx.clone()))); storage.hashes.insert(block_number, hash); - storage.blocks.insert(hash, block.clone().into()); + storage.blocks.insert(hash, block.clone()); return Ok(Some(block)); } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ce5c92c2429a..0df0aca9fde2 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1010,7 +1010,7 @@ impl Backend { let (exit, out, gas, state) = match overrides { None => self.call_with_state(state, request, fee_details, block), Some(overrides) => { - let state = state::apply_state_override(overrides.into_iter().map(|(k, v)| (k, v)).collect(), state)?; + let state = state::apply_state_override(overrides.into_iter().collect(), state)?; self.call_with_state(state, request, fee_details, block) }, }?; @@ -1227,7 +1227,7 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return Ok(fork.logs(&filter).await.map_err(|_| BlockchainError::DataUnavailable)?); + return fork.logs(&filter).await.map_err(|_| BlockchainError::DataUnavailable); } Ok(Vec::new()) @@ -1360,10 +1360,10 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return Ok(fork + return fork .block_by_hash(hash) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } Ok(None) @@ -1379,10 +1379,10 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return Ok(fork + return fork .block_by_hash_full(hash) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } Ok(None) @@ -1436,10 +1436,10 @@ impl Backend { if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork_inclusive(number) { - return Ok(fork + return fork .block_by_number(number) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } @@ -1458,10 +1458,10 @@ impl Backend { if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork_inclusive(number) { - return Ok(fork + return fork .block_by_number_full(number) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } @@ -1968,7 +1968,7 @@ impl Backend { .map(|f| f.to_alloy()) .unwrap_or(self.base_fee()) .checked_add(t.max_priority_fee_per_gas.to_alloy()) - .unwrap_or_else(|| U256::MAX), + .unwrap_or(U256::MAX), }; let inner = TransactionReceipt { @@ -2009,7 +2009,7 @@ impl Backend { state_root: None, logs_bloom: Bloom::from_slice(logs_bloom.as_bytes()), // TODO: Should this be unwrap_or_default, or is this guaranteed to exist? - transaction_type: transaction_type.map(|t| U8::from(t)).unwrap_or_default(), + transaction_type: transaction_type.map(U8::from).unwrap_or_default(), effective_gas_price: effective_gas_price.to::(), blob_gas_price: None, blob_gas_used: None, @@ -2030,10 +2030,10 @@ impl Backend { if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork(number) { - return Ok(fork + return fork .transaction_by_block_number_and_index(number, index.into()) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } } @@ -2050,10 +2050,10 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return Ok(fork + return fork .transaction_by_block_hash_and_index(hash, index.into()) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } Ok(None) @@ -2092,10 +2092,10 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return Ok(fork + return fork .transaction_by_hash(hash) .await - .map_err(|_| BlockchainError::DataUnavailable)?); + .map_err(|_| BlockchainError::DataUnavailable); } Ok(None) @@ -2380,7 +2380,7 @@ pub fn transaction_build( transaction.gas_price = Some( base_fee .checked_add(max_priority_fee_per_gas) - .unwrap_or_else(|| U256::MAX) + .unwrap_or(U256::MAX) .to::(), ); } diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index 25c9fadf2b50..0a2410343316 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -143,13 +143,13 @@ where *account, new_account_state .iter() - .map(|(key, value)| ((*key).into(), ((*value).into()))) + .map(|(key, value)| ((*key).into(), (*value))) .collect(), )?; } (None, Some(account_state_diff)) => { for (key, value) in account_state_diff.iter() { - cache_db.insert_account_storage(*account, (*key).into(), (*value).into())?; + cache_db.insert_account_storage(*account, (*key).into(), *value)?; } } }; diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index f273ddcb5ab4..49ce78a70152 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -192,7 +192,7 @@ impl OtsBlockTransactions { }; let receipt_futs = - block_txs.iter().map(|tx| async { backend.transaction_receipt(tx.clone()).await }); + block_txs.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); let receipts: Vec = join_all(receipt_futs) .await diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 8da3b399840a..a737ae223c0a 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -140,7 +140,7 @@ impl From for AccountInfo { let GenesisAccount { code, balance, nonce, .. } = acc; let code = code.map(|code| Bytecode::new_raw(code.to_vec().into())); AccountInfo { - balance: balance, + balance, nonce: nonce.unwrap_or_default(), code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), code, diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 18ed693012e5..4481f8cc5225 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,13 +1,13 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::{FixedBytes, B256, U256}; +use alloy_primitives::{B256, U256}; use alloy_providers::provider::TempProvider; -use alloy_rpc_types::{Filter, Topic}; +use alloy_rpc_types::{Filter}; use alloy_sol_types::SolValue; use eyre::WrapErr; use foundry_common::provider::alloy::ProviderBuilder; use foundry_compilers::utils::RuntimeOrHandle; use foundry_evm_core::fork::CreateFork; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_utils::types::{ToEthers}; impl Cheatcode for activeForkCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { @@ -219,24 +219,20 @@ impl Cheatcode for isPersistentCall { impl Cheatcode for rpcCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { - /* - todo what do we do here let Self { method, params } = self; let url = ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; - + let method: &'static str = Box::new(method.clone()).leak(); let params_json: serde_json::Value = serde_json::from_str(params)?; let result = RuntimeOrHandle::new() - .block_on(provider.request(method, params_json)) + .block_on(provider.raw_request(&method, params_json)) .map_err(|err| fmt_err!("{method:?}: {err}"))?; let result_as_tokens = crate::json::value_to_token(&result) .map_err(|err| fmt_err!("failed to parse result: {err}"))?; Ok(result_as_tokens.abi_encode()) - */ - Ok(1.abi_encode()) } } diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index e9df2f1b8f63..679d658b6dca 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -22,7 +22,6 @@ foundry-compilers = { workspace = true, features = ["full"] } alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true -alloy-providers.workspace = true ethers-core.workspace = true ethers-providers.workspace = true diff --git a/crates/common/src/provider/alloy.rs b/crates/common/src/provider/alloy.rs index 3ab076cbd1ca..93a05f050adc 100644 --- a/crates/common/src/provider/alloy.rs +++ b/crates/common/src/provider/alloy.rs @@ -35,7 +35,7 @@ pub type RpcUrl = String; /// # Examples /// /// ``` -/// use foundry_common::get_http_provider; +/// use foundry_common::provider::alloy::get_http_provider; /// /// let retry_provider = get_http_provider("http://localhost:8545"); /// ``` @@ -216,14 +216,14 @@ impl ProviderBuilder { pub fn build(self) -> Result { let ProviderBuilder { url, - chain, - max_retry, - timeout_retry, - initial_backoff, - timeout, - compute_units_per_second, + chain: _, + max_retry: _, + timeout_retry: _, + initial_backoff: _, + timeout: _, + compute_units_per_second: _, jwt, - headers, + headers: _, } = self; let url = url?; diff --git a/crates/common/src/provider/ethers.rs b/crates/common/src/provider/ethers.rs index 201b5d3c695b..c8d58e2078ac 100644 --- a/crates/common/src/provider/ethers.rs +++ b/crates/common/src/provider/ethers.rs @@ -34,7 +34,7 @@ pub type RpcUrl = String; /// # Examples /// /// ``` -/// use foundry_common::get_http_provider; +/// use foundry_common::provider::ethers::get_http_provider; /// /// let retry_provider = get_http_provider("http://localhost:8545"); /// ``` diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index a7a8a2e9d343..437857748a57 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -1,5 +1,5 @@ use crate::utils::apply_chain_and_block_specific_env_changes; -use alloy_primitives::{Address, U256, U64}; +use alloy_primitives::{Address, U256}; use alloy_providers::provider::TempProvider; use alloy_rpc_types::{Block, BlockNumberOrTag}; use eyre::WrapErr; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 48f9b929fec7..90b743dc8568 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -462,7 +462,7 @@ async fn create_fork(mut fork: CreateFork) -> eyre::Result<(CreatedFork, Handler // we need to use the block number from the block because the env's number can be different on // some L2s (e.g. Arbitrum). - let number = block.header.number.unwrap_or_else(|| meta.block_env.number); + let number = block.header.number.unwrap_or(meta.block_env.number); // determine the cache path if caching is enabled let cache_path = if fork.enable_caching { diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 796f2bdd5009..54b06146b89b 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -189,7 +189,7 @@ impl EvmOpts { .unwrap_or_else(|_| panic!("Failed to establish provider to {url}")); if let Ok(id) = RuntimeOrHandle::new().block_on(provider.get_chainid()) { - return Chain::try_from(id.as_u64()).ok(); + return Some(Chain::from(id.as_u64())); } } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 606b21bfc914..80826a9acb32 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -4,7 +4,7 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{Address, Bytes}; use anvil::{spawn, NodeConfig}; use foundry_test_utils::{util::OutputExt, ScriptOutcome, ScriptTester}; -use foundry_utils::{rpc, types::ToEthers}; +use foundry_utils::{rpc}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; diff --git a/crates/forge/tests/fixtures/can_create_template_contract.stdout b/crates/forge/tests/fixtures/can_create_template_contract.stdout index fd625cee305f..622c81ac4a88 100644 --- a/crates/forge/tests/fixtures/can_create_template_contract.stdout +++ b/crates/forge/tests/fixtures/can_create_template_contract.stdout @@ -1,4 +1,4 @@ -Compiling 22 files with 0.8.23 +Compiling 24 files with 0.8.23 Solc 0.8.23 finished in 2.27s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout index 2e35831523fb..a4132c617c0a 100644 --- a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout +++ b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout @@ -1,4 +1,4 @@ -Compiling 22 files with 0.8.23 +Compiling 24 files with 0.8.23 Solc 0.8.23 finished in 1.95s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout index 525e68ac13f8..8cb09c22ced0 100644 --- a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout +++ b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout @@ -1,4 +1,4 @@ -Compiling 23 files with 0.8.23 +Compiling 25 files with 0.8.23 Solc 0.8.23 finished in 2.82s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266