From 489c3fa15523ca272e38c1c3f9dce4c8e75bff50 Mon Sep 17 00:00:00 2001 From: "0xAWM.eth" <29773064+0xAWM@users.noreply.github.com> Date: Sun, 15 Oct 2023 08:56:57 +0800 Subject: [PATCH] etherscan_key as env --- src/evm/mod.rs | 56 ++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/src/evm/mod.rs b/src/evm/mod.rs index fe381255a..bb6c51095 100644 --- a/src/evm/mod.rs +++ b/src/evm/mod.rs @@ -30,14 +30,11 @@ use blaz::offchain_artifacts::OffChainArtifact; use blaz::offchain_config::OffchainConfig; use clap::Parser; use config::{Config, FuzzerTypes, StorageFetchingMode}; -use contract_utils::{set_hash, ContractLoader}; +use contract_utils::ContractLoader; use ethers::types::Transaction; -use hex::{decode, encode}; -use host::PANIC_ON_BUG; use input::{ConciseEVMInput, EVMInput}; -use middlewares::middleware::Middleware; use onchain::endpoints::{Chain, OnChainConfig}; -use onchain::flashloan::{DummyPriceOracle, Flashloan}; +use onchain::flashloan::DummyPriceOracle; use oracles::erc20::IERC20OracleFlashloan; use oracles::v2_pair::PairBalanceOracle; use producers::erc20::ERC20Producer; @@ -54,7 +51,7 @@ use vm::EVMState; pub fn parse_constructor_args_string(input: String) -> HashMap> { let mut map = HashMap::new(); - if input.len() == 0 { + if input.is_empty() { return map; } @@ -73,7 +70,6 @@ pub fn parse_constructor_args_string(input: String) -> HashMap, } -#[derive(Deserialize)] -struct Response { - data: ResponseData, -} - -#[derive(Deserialize)] -struct ResponseData { - id: u16, - result: TXResult, -} - -#[derive(Deserialize)] -struct TXResult { - input: String, -} - /// CLI for ItyFuzz for EVM smart contracts #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] @@ -336,17 +316,22 @@ pub fn evm_main(args: EvmArgs) { let onchain_clone = onchain.clone(); - if onchain.is_some() && args.onchain_etherscan_api_key.is_some() { + let etherscan_api_key = match args.onchain_etherscan_api_key { + Some(v) => v, + None => std::env::var("ETHERSCAN_API_KEY").unwrap_or_default(), + }; + + if onchain.is_some() && !etherscan_api_key.is_empty() { onchain .as_mut() .unwrap() .etherscan_api_key - .push(args.onchain_etherscan_api_key.unwrap()); + .push(etherscan_api_key); } let pair_producer = Rc::new(RefCell::new(PairProducer::new())); let erc20_producer = Rc::new(RefCell::new(ERC20Producer::new())); - let mut flashloan_oracle = Rc::new(RefCell::new({ + let flashloan_oracle = Rc::new(RefCell::new({ IERC20OracleFlashloan::new(pair_producer.clone(), erc20_producer.clone()) })); @@ -361,14 +346,21 @@ pub fn evm_main(args: EvmArgs) { RefCell< dyn Oracle< EVMState, - EVMAddress, - _, - _, - EVMAddress, - EVMU256, + revm_primitives::B160, + revm_primitives::Bytecode, + bytes::Bytes, + revm_primitives::B160, + revm_primitives::ruint::Uint<256, 4>, Vec, EVMInput, - EVMFuzzState, + FuzzState< + EVMInput, + EVMState, + revm_primitives::B160, + revm_primitives::B160, + Vec, + ConciseEVMInput, + >, ConciseEVMInput, >, >,