Skip to content

Commit

Permalink
feat: remove goerli-2 network
Browse files Browse the repository at this point in the history
The network is now gone.
  • Loading branch information
xJonathanLEI committed Dec 12, 2023
1 parent 42c7cfc commit e35c105
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
5 changes: 2 additions & 3 deletions book/src/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 <NETWORK>` option, where `<NETWORK>` is one of the following:
- `mainnet`
- `goerli-1`
- `goerli-2`
- `goerli`
- `integration`
For example, to check the latest block number on `mainnet`:
Expand Down
7 changes: 3 additions & 4 deletions src/casm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
27 changes: 6 additions & 21 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use crate::provider::ExtendedProvider;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Network {
Mainnet,
Goerli1,
Goerli2,
Goerli,
Integration,
}

Expand All @@ -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<PossibleValue> {
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")),
}
}
Expand All @@ -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)),
}
Expand All @@ -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"),
}
}
Expand All @@ -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
})
Expand Down
11 changes: 5 additions & 6 deletions src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct ProviderArgs {
network: Option<Network>,
}

/// 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.
Expand Down Expand Up @@ -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")
Expand All @@ -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()
);
Expand Down

0 comments on commit e35c105

Please sign in to comment.