From e35c1055f8172820b9d054c9e40c44b5a7d9bf3f Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Tue, 12 Dec 2023 20:07:45 +0000 Subject: [PATCH] feat: remove goerli-2 network The network is now gone. --- book/src/providers.md | 5 ++--- src/casm.rs | 7 +++---- src/network.rs | 27 ++++++--------------------- src/provider.rs | 11 +++++------ 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/book/src/providers.md b/book/src/providers.md index 6a368e1..b9e8db3 100644 --- a/book/src/providers.md +++ b/book/src/providers.md @@ -6,7 +6,7 @@ Currently, two providers are supported: [JSON-RPC](#json-rpc) and the [sequencer > ℹ️ **Note** > -> When no provider option is supplied, Starkli falls back to using the sequencer gateway provider for the `goerli-1` network. +> When no provider option is supplied, Starkli falls back to using the sequencer gateway provider for the `goerli` network. ## JSON-RPC @@ -58,8 +58,7 @@ Historically, before the JSON-RPC API became available, access to the network ha To use the sequencer gateway anyways, use the `--network ` option, where `` is one of the following: - `mainnet` -- `goerli-1` -- `goerli-2` +- `goerli` - `integration` For example, to check the latest block number on `mainnet`: diff --git a/src/casm.rs b/src/casm.rs index 4ccab51..2da1713 100644 --- a/src/casm.rs +++ b/src/casm.rs @@ -72,10 +72,9 @@ impl CasmArgs { match network { Some(network) => { let auto_version = match network { - Network::Mainnet - | Network::Goerli1 - | Network::Goerli2 - | Network::Integration => CompilerVersion::V2_1_0, + Network::Mainnet | Network::Goerli | Network::Integration => { + CompilerVersion::V2_1_0 + } }; eprintln!( diff --git a/src/network.rs b/src/network.rs index b34cbc6..22dfeba 100644 --- a/src/network.rs +++ b/src/network.rs @@ -11,8 +11,7 @@ use crate::provider::ExtendedProvider; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Network { Mainnet, - Goerli1, - Goerli2, + Goerli, Integration, } @@ -25,29 +24,19 @@ pub trait NetworkSource { impl ValueEnum for Network { fn value_variants<'a>() -> &'a [Self] { - &[ - Self::Mainnet, - Self::Goerli1, - Self::Goerli2, - Self::Integration, - ] + &[Self::Mainnet, Self::Goerli, Self::Integration] } fn to_possible_value(&self) -> Option { match self { Network::Mainnet => Some(PossibleValue::new("mainnet").aliases(["alpha-mainnet"])), - Network::Goerli1 => Some(PossibleValue::new("goerli-1").aliases([ + Network::Goerli => Some(PossibleValue::new("goerli-1").aliases([ "goerli", "goerli1", "alpha-goerli", "alpha-goerli1", "alpha-goerli-1", ])), - Network::Goerli2 => Some(PossibleValue::new("goerli-2").aliases([ - "goerli2", - "alpha-goerli2", - "alpha-goerli-2", - ])), Network::Integration => Some(PossibleValue::new("integration")), } } @@ -60,8 +49,7 @@ impl FromStr for Network { match s { "mainnet" | "alpha-mainnet" => Ok(Self::Mainnet), "goerli" | "goerli1" | "goerli-1" | "alpha-goerli" | "alpha-goerli1" - | "alpha-goerli-1" => Ok(Self::Goerli1), - "goerli2" | "goerli-2" | "alpha-goerli2" | "alpha-goerli-2" => Ok(Self::Goerli2), + | "alpha-goerli-1" => Ok(Self::Goerli), "integration" => Ok(Self::Integration), _ => Err(anyhow::anyhow!("unknown network: {}", s)), } @@ -72,8 +60,7 @@ impl Display for Network { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Mainnet => write!(f, "mainnet"), - Self::Goerli1 => write!(f, "goerli-1"), - Self::Goerli2 => write!(f, "goerli-2"), + Self::Goerli => write!(f, "goerli"), Self::Integration => write!(f, "integration"), } } @@ -95,9 +82,7 @@ impl NetworkSource for ExtendedProvider { } else if chain_id == starknet::core::chain_id::MAINNET { Some(Network::Mainnet) } else if chain_id == starknet::core::chain_id::TESTNET { - Some(Network::Goerli1) - } else if chain_id == starknet::core::chain_id::TESTNET2 { - Some(Network::Goerli2) + Some(Network::Goerli) } else { None }) diff --git a/src/provider.rs b/src/provider.rs index 3455e53..d02eb12 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -25,7 +25,7 @@ pub struct ProviderArgs { network: Option, } -/// We need this because integration network has the same chain ID as `goerli-1`. We would otherwise +/// We need this because integration network has the same chain ID as `goerli`. We would otherwise /// has no way of telling them apart. We could generally just ignore this, but it would actually /// cause issues when deciding what Sierra compiler version to use depending on network, so we still /// need this. @@ -67,8 +67,7 @@ impl ProviderArgs { ExtendedProvider::new( AnyProvider::SequencerGateway(match network { Network::Mainnet => SequencerGatewayProvider::starknet_alpha_mainnet(), - Network::Goerli1 => SequencerGatewayProvider::starknet_alpha_goerli(), - Network::Goerli2 => SequencerGatewayProvider::starknet_alpha_goerli_2(), + Network::Goerli => SequencerGatewayProvider::starknet_alpha_goerli(), Network::Integration => SequencerGatewayProvider::new( Url::parse("https://external.integration.starknet.io/gateway").unwrap(), Url::parse("https://external.integration.starknet.io/feeder_gateway") @@ -77,17 +76,17 @@ impl ProviderArgs { ), }), match network { - Network::Mainnet | Network::Goerli1 | Network::Goerli2 => false, + Network::Mainnet | Network::Goerli => false, Network::Integration => true, }, ) } (None, None) => { - // If nothing is provided we fall back to using sequencer gateway for goerli-1 + // If nothing is provided we fall back to using sequencer gateway for goerli eprintln!( "{}", "WARNING: no valid provider option found. Falling back to using the sequencer \ - gateway for the goerli-1 network. Doing this is discouraged. See \ + gateway for the goerli network. Doing this is discouraged. See \ https://book.starkli.rs/providers for more details." .bright_magenta() );