foundry_evm_networks/
lib.rs1use crate::celo::transfer::{CELO_TRANSFER_ADDRESS, PRECOMPILE_ID_CELO_TRANSFER};
6use alloy_evm::precompiles::PrecompilesMap;
7use alloy_primitives::Address;
8use clap::Parser;
9use serde::{Deserialize, Serialize};
10use std::collections::BTreeMap;
11
12pub mod celo;
13
14#[derive(Clone, Debug, Default, Parser, Copy, Serialize, Deserialize)]
15pub struct NetworkConfigs {
16 #[arg(help_heading = "Networks", long, visible_alias = "optimism")]
18 #[serde(skip)]
20 pub optimism: bool,
21 #[arg(help_heading = "Networks", long)]
23 pub celo: bool,
24}
25
26impl NetworkConfigs {
27 pub fn celo(mut self, celo: bool) -> Self {
28 self.celo = celo;
29 self
30 }
31
32 pub fn with_optimism() -> Self {
33 Self { optimism: true, ..Default::default() }
34 }
35
36 pub fn inject_precompiles(self, precompiles: &mut PrecompilesMap) {
38 if self.celo {
39 precompiles.apply_precompile(&CELO_TRANSFER_ADDRESS, move |_| {
40 Some(celo::transfer::precompile())
41 });
42 }
43 }
44
45 pub fn precompiles(self) -> BTreeMap<String, Address> {
47 let mut precompiles = BTreeMap::new();
48 if self.celo {
49 precompiles
50 .insert(PRECOMPILE_ID_CELO_TRANSFER.name().to_string(), CELO_TRANSFER_ADDRESS);
51 }
52 precompiles
53 }
54}