1use ethers::prelude::*;
3use std::sync::Arc;
4
5const ETHEREUM_RPC: &str = "https://reth-ethereum.ithaca.xyz/rpc";
6const BASE_RPC: &str = "";
7const ARB_RPC: &str = "";
8const BSC_RPC: &str = "";
9const HYPEREVM_RPC: &str = "";
10const PLASMA_RPC: &str = "";
11
12pub enum EvmType {
13 Ethereum,
14 Arb,
15 Bsc,
16 Base,
17 HyperEVM,
18 Plasma,
19}
20
21#[derive(Clone)]
22pub struct Evm {
23 pub provider: Arc<Provider<Http>>,
24}
25
26impl Evm {
27 pub async fn new(evm_type: EvmType) -> Result<Self, String> {
28 let mut rpc: &str = "";
29 match evm_type {
30 EvmType::Ethereum => {
31 rpc = ETHEREUM_RPC;
32 }
33 EvmType::Arb => {
34 rpc = ARB_RPC;
36 }
37 EvmType::Bsc => {
38 rpc = BSC_RPC;
39 }
40 EvmType::Base => {
41 rpc = BASE_RPC;
42 }
43 EvmType::HyperEVM => {
44 rpc = HYPEREVM_RPC;
45 }
46 EvmType::Plasma => {
47 rpc = PLASMA_RPC;
48 }
49 }
50 match Provider::<Http>::try_from(rpc) {
51 Ok(p) => {
52 return Ok(Self {
53 provider: Arc::new(p),
54 });
55 }
56 Err(e) => Err(format!("create provider error: {:?}", e).to_string()),
57 }
58 }
59}