diff --git a/evmlib/src/lib.rs b/evmlib/src/lib.rs index 8bf3734265..0093aeac0e 100644 --- a/evmlib/src/lib.rs +++ b/evmlib/src/lib.rs @@ -33,13 +33,25 @@ static PUBLIC_ARBITRUM_ONE_HTTP_RPC_URL: LazyLock = LazyLock::new( .expect("Invalid RPC URL") }); +static PUBLIC_ARBITRUM_SEPOLIA_HTTP_RPC_URL: LazyLock = LazyLock::new(|| { + "https://sepolia-rollup.arbitrum.io/rpc" + .parse() + .expect("Invalid RPC URL") +}); + const ARBITRUM_ONE_PAYMENT_TOKEN_ADDRESS: Address = address!("4bc1aCE0E66170375462cB4E6Af42Ad4D5EC689C"); +const ARBITRUM_SEPOLIA_PAYMENT_TOKEN_ADDRESS: Address = + address!("4bc1aCE0E66170375462cB4E6Af42Ad4D5EC689C"); + // Should be updated when the smart contract changes! const ARBITRUM_ONE_DATA_PAYMENTS_ADDRESS: Address = address!("887930F30EDEb1B255Cd2273C3F4400919df2EFe"); +const ARBITRUM_SEPOLIA_DATA_PAYMENTS_ADDRESS: Address = + address!("e6D6bB5Fa796baA8c1ADc439Ac0fd66fd2A1858b"); + #[serde_as] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct CustomNetwork { @@ -64,6 +76,7 @@ impl CustomNetwork { #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum Network { ArbitrumOne, + ArbitrumSepolia, Custom(CustomNetwork), } @@ -71,6 +84,7 @@ impl std::fmt::Display for Network { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Network::ArbitrumOne => write!(f, "evm-arbitrum-one"), + Network::ArbitrumSepolia => write!(f, "evm-arbitrum-sepolia"), Network::Custom(_) => write!(f, "evm-custom"), } } @@ -88,6 +102,7 @@ impl Network { pub fn identifier(&self) -> &str { match self { Network::ArbitrumOne => "arbitrum-one", + Network::ArbitrumSepolia => "arbitrum-sepolia", Network::Custom(_) => "custom", } } @@ -95,6 +110,7 @@ impl Network { pub fn rpc_url(&self) -> &reqwest::Url { match self { Network::ArbitrumOne => &PUBLIC_ARBITRUM_ONE_HTTP_RPC_URL, + Network::ArbitrumSepolia => &PUBLIC_ARBITRUM_SEPOLIA_HTTP_RPC_URL, Network::Custom(custom) => &custom.rpc_url_http, } } @@ -102,6 +118,7 @@ impl Network { pub fn payment_token_address(&self) -> &Address { match self { Network::ArbitrumOne => &ARBITRUM_ONE_PAYMENT_TOKEN_ADDRESS, + Network::ArbitrumSepolia => &ARBITRUM_SEPOLIA_PAYMENT_TOKEN_ADDRESS, Network::Custom(custom) => &custom.payment_token_address, } } @@ -109,6 +126,7 @@ impl Network { pub fn data_payments_address(&self) -> &Address { match self { Network::ArbitrumOne => &ARBITRUM_ONE_DATA_PAYMENTS_ADDRESS, + Network::ArbitrumSepolia => &ARBITRUM_SEPOLIA_DATA_PAYMENTS_ADDRESS, Network::Custom(custom) => &custom.data_payments_address, } } diff --git a/evmlib/src/utils.rs b/evmlib/src/utils.rs index 00b018fa09..e6f657938b 100644 --- a/evmlib/src/utils.rs +++ b/evmlib/src/utils.rs @@ -88,11 +88,18 @@ pub fn get_evm_network_from_env() -> Result { .map(|v| v == "arbitrum-one") .unwrap_or(false); + let use_arbitrum_sepolia = std::env::var("EVM_NETWORK") + .map(|v| v == "arbitrum-sepolia") + .unwrap_or(false); + if use_local_evm { local_evm_network_from_csv() } else if use_arbitrum_one { info!("Using Arbitrum One EVM network as EVM_NETWORK is set to 'arbitrum-one'"); Ok(Network::ArbitrumOne) + } else if use_arbitrum_sepolia { + info!("Using Arbitrum Sepolia EVM network as EVM_NETWORK is set to 'arbitrum-sepolia'"); + Ok(Network::ArbitrumSepolia) } else if let Ok(evm_vars) = evm_vars { info!("Using custom EVM network from environment variables"); Ok(Network::Custom(CustomNetwork::new( diff --git a/sn_node/src/bin/safenode/subcommands.rs b/sn_node/src/bin/safenode/subcommands.rs index 7c5ec3aa51..c2b0389465 100644 --- a/sn_node/src/bin/safenode/subcommands.rs +++ b/sn_node/src/bin/safenode/subcommands.rs @@ -2,10 +2,14 @@ use clap::Subcommand; use sn_evm::EvmNetwork; #[derive(Subcommand, Clone, Debug)] +#[allow(clippy::enum_variant_names)] pub(crate) enum EvmNetworkCommand { /// Use the Arbitrum One network EvmArbitrumOne, + /// Use the Arbitrum Sepolia network + EvmArbitrumSepolia, + /// Use a custom network EvmCustom { /// The RPC URL for the custom network @@ -27,6 +31,7 @@ impl Into for EvmNetworkCommand { fn into(self) -> EvmNetwork { match self { Self::EvmArbitrumOne => EvmNetwork::ArbitrumOne, + Self::EvmArbitrumSepolia => EvmNetwork::ArbitrumSepolia, Self::EvmCustom { rpc_url, payment_token_address, diff --git a/sn_node_manager/src/bin/cli/subcommands/evm_network.rs b/sn_node_manager/src/bin/cli/subcommands/evm_network.rs index a77893f609..1683e00e99 100644 --- a/sn_node_manager/src/bin/cli/subcommands/evm_network.rs +++ b/sn_node_manager/src/bin/cli/subcommands/evm_network.rs @@ -16,6 +16,9 @@ pub enum EvmNetworkCommand { /// Use the Arbitrum One network EvmArbitrumOne, + /// Use the Arbitrum Sepolia network + EvmArbitrumSepolia, + /// Use a custom network EvmCustom { /// The RPC URL for the custom network @@ -41,6 +44,7 @@ impl TryInto for EvmNetworkCommand { fn try_into(self) -> Result { match self { Self::EvmArbitrumOne => Ok(EvmNetwork::ArbitrumOne), + Self::EvmArbitrumSepolia => Ok(EvmNetwork::ArbitrumSepolia), Self::EvmLocal => { if !cfg!(feature = "local") { return Err(color_eyre::eyre::eyre!(