Skip to content

Commit

Permalink
Changes after review: use EtherscanOpts, remove short -e from evm_ver…
Browse files Browse the repository at this point in the history
…sion

Simplify test to avoid rate limiting.
  • Loading branch information
grandizzy committed Nov 11, 2024
1 parent 12bbe9e commit 26ee3d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 8 additions & 6 deletions crates/cast/bin/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cast::revm::primitives::EnvWithHandlerCfg;
use clap::Parser;
use eyre::{Result, WrapErr};
use foundry_cli::{
opts::RpcOpts,
opts::{EtherscanOpts, RpcOpts},
utils::{handle_traces, init_progress, TraceResult},
};
use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE};
Expand Down Expand Up @@ -58,17 +58,16 @@ pub struct RunArgs {
#[arg(long, short)]
label: Vec<String>,

/// Etherscan API key.
#[arg(long)]
pub etherscan_api_key: Option<String>,
#[command(flatten)]
etherscan: EtherscanOpts,

#[command(flatten)]
rpc: RpcOpts,

/// The EVM version to use.
///
/// Overrides the version specified in the config.
#[arg(long, short)]
#[arg(long)]
evm_version: Option<EvmVersion>,

/// Sets the number of assumed available compute units per second for this provider
Expand Down Expand Up @@ -102,7 +101,6 @@ impl RunArgs {
let figment = Into::<Figment>::into(&self.rpc).merge(&self);
let evm_opts = figment.extract::<EvmOpts>()?;
let mut config = Config::try_from(figment)?.sanitized();
config.etherscan_api_key = self.etherscan_api_key;

let compute_units_per_second =
if self.no_rate_limit { Some(u64::MAX) } else { self.compute_units_per_second };
Expand Down Expand Up @@ -274,6 +272,10 @@ impl figment::Provider for RunArgs {
map.insert("alphanet".into(), self.alphanet.into());
}

if let Some(api_key) = &self.etherscan.key {
map.insert("etherscan_api_key".into(), api_key.as_str().into());
}

if let Some(evm_version) = self.evm_version {
map.insert("evm_version".into(), figment::value::Value::serialize(evm_version)?);
}
Expand Down
18 changes: 8 additions & 10 deletions crates/cast/tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1505,10 +1505,11 @@ casttest!(fetch_constructor_args_from_etherscan, |_prj, cmd| {
});

// <https://github.com/foundry-rs/foundry/issues/3473>
casttest!(test_non_mainnet_traces, |_prj, cmd| {
casttest!(test_non_mainnet_traces, |prj, cmd| {
prj.clear();
cmd.args([
"run",
"0x8346762a8c1d7ce70be23c1b68ff920ffb6bca8fd62323e6c1d108f209e0b45d",
"0xa003e419e2d7502269eb5eda56947b580120e00abfd5b5460d08f8af44a0c24f",
"--rpc-url",
next_rpc_endpoint(NamedChain::Optimism).as_str(),
"--etherscan-api-key",
Expand All @@ -1518,14 +1519,11 @@ casttest!(test_non_mainnet_traces, |_prj, cmd| {
.stdout_eq(str![[r#"
Executing previous transactions from the block.
Traces:
[429891] FuturesMarket::modifyPositionWithTracking(79573547589616810 [7.957e16], 0x4b57454e54410000000000000000000000000000000000000000000000000000)
├─ [9111] SystemStatus::requireFuturesMarketActive(0x7345544800000000000000000000000000000000000000000000000000000000) [staticcall]
│ └─ ← [Stop]
├─ [2789] SystemStatus::requireSynthActive(0x7345544800000000000000000000000000000000000000000000000000000000) [staticcall]
│ └─ ← [Stop]
├─ [70705] ExchangeCircuitBreaker::rateWithBreakCircuit(0x7345544800000000000000000000000000000000000000000000000000000000)
│ ├─ [399] SystemStatus::systemSuspended() [staticcall]
│ │ └─ ← [Return] false
[33841] FiatTokenProxy::fallback(0x111111125421cA6dc452d289314280a0f8842A65, 164054805 [1.64e8])
├─ [26673] FiatTokenV2_2::approve(0x111111125421cA6dc452d289314280a0f8842A65, 164054805 [1.64e8]) [delegatecall]
│ ├─ emit Approval(owner: 0x9a95Af47C51562acfb2107F44d7967DF253197df, spender: 0x111111125421cA6dc452d289314280a0f8842A65, value: 164054805 [1.64e8])
│ └─ ← [Return] true
└─ ← [Return] true
...
"#]]);
Expand Down

0 comments on commit 26ee3d7

Please sign in to comment.