From e196118cc55f94072c3aff60f74f2a86a39bbcd7 Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Tue, 19 Dec 2023 20:21:19 +0000 Subject: [PATCH] feat: add sepolia-integration network For backward compatibility reasons, the `integration` identifier still points to the `goerli-integration` network. This will change once the `goerli-integration` network eventually shuts down. --- book/src/providers.md | 3 ++- src/casm.rs | 7 ++++--- src/network.rs | 33 ++++++++++++++++++++------------- src/provider.rs | 10 ++++++++-- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/book/src/providers.md b/book/src/providers.md index b214661..a28cf06 100644 --- a/book/src/providers.md +++ b/book/src/providers.md @@ -60,7 +60,8 @@ To use the sequencer gateway anyways, use the `--network ` option, wher - `mainnet` - `goerli` - `sepolia` -- `integration` +- `goerli-integration` +- `sepolia-integration` For example, to check the latest block number on `mainnet`: diff --git a/src/casm.rs b/src/casm.rs index 33a288a..c4096e9 100644 --- a/src/casm.rs +++ b/src/casm.rs @@ -73,9 +73,10 @@ impl CasmArgs { Some(network) => { let auto_version = match network { Network::Mainnet => CompilerVersion::V2_1_0, - Network::Goerli | Network::Sepolia | Network::Integration => { - CompilerVersion::V2_4_0 - } + Network::Goerli + | Network::Sepolia + | Network::GoerliIntegration + | Network::SepoliaIntegration => CompilerVersion::V2_4_0, }; eprintln!( diff --git a/src/network.rs b/src/network.rs index cbb9680..d0003b3 100644 --- a/src/network.rs +++ b/src/network.rs @@ -13,7 +13,8 @@ pub enum Network { Mainnet, Goerli, Sepolia, - Integration, + GoerliIntegration, + SepoliaIntegration, } #[cfg_attr(not(target_arch = "wasm32"), async_trait)] @@ -29,7 +30,8 @@ impl ValueEnum for Network { Self::Mainnet, Self::Goerli, Self::Sepolia, - Self::Integration, + Self::GoerliIntegration, + Self::SepoliaIntegration, ] } @@ -46,7 +48,10 @@ impl ValueEnum for Network { Network::Sepolia => { Some(PossibleValue::new("sepolia").aliases(["alpha-sepolia", "sepolia-testnet"])) } - Network::Integration => Some(PossibleValue::new("integration")), + Network::GoerliIntegration => { + Some(PossibleValue::new("goerli-integration").aliases(["integration"])) + } + Network::SepoliaIntegration => Some(PossibleValue::new("sepolia-integration")), } } } @@ -60,7 +65,8 @@ impl FromStr for Network { "goerli" | "goerli1" | "goerli-1" | "alpha-goerli" | "alpha-goerli1" | "alpha-goerli-1" => Ok(Self::Goerli), "sepolia" | "alpha-sepolia" | "sepolia-testnet" => Ok(Self::Sepolia), - "integration" => Ok(Self::Integration), + "goerli-integration" | "integration" => Ok(Self::GoerliIntegration), + "sepolia-integration" => Ok(Self::SepoliaIntegration), _ => Err(anyhow::anyhow!("unknown network: {}", s)), } } @@ -72,7 +78,8 @@ impl Display for Network { Self::Mainnet => write!(f, "mainnet"), Self::Goerli => write!(f, "goerli"), Self::Sepolia => write!(f, "sepolia"), - Self::Integration => write!(f, "integration"), + Self::GoerliIntegration => write!(f, "goerli-integration"), + Self::SepoliaIntegration => write!(f, "sepolia-integration"), } } } @@ -84,18 +91,18 @@ impl NetworkSource for ExtendedProvider { let chain_id = self.chain_id().await?; let is_integration = self.is_integration(); - Ok(if is_integration { - if chain_id == starknet::core::chain_id::TESTNET { - Some(Network::Integration) - } else { - None - } - } else if chain_id == starknet::core::chain_id::MAINNET { + Ok(if chain_id == starknet::core::chain_id::MAINNET { Some(Network::Mainnet) } else if chain_id == starknet::core::chain_id::TESTNET { - Some(Network::Goerli) + if is_integration { + Some(Network::GoerliIntegration) + } else { + Some(Network::Goerli) + } } else if chain_id == short_string!("SN_SEPOLIA") { Some(Network::Sepolia) + } else if chain_id == short_string!("SN_INTEGRATION_SEPOLIA") { + Some(Network::SepoliaIntegration) } else { None }) diff --git a/src/provider.rs b/src/provider.rs index 19fc1ef..f80465f 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -74,16 +74,22 @@ impl ProviderArgs { Url::parse("https://alpha-sepolia.starknet.io/feeder_gateway").unwrap(), short_string!("SN_SEPOLIA"), ), - Network::Integration => SequencerGatewayProvider::new( + Network::GoerliIntegration => SequencerGatewayProvider::new( Url::parse("https://external.integration.starknet.io/gateway").unwrap(), Url::parse("https://external.integration.starknet.io/feeder_gateway") .unwrap(), chain_id::TESTNET, ), + Network::SepoliaIntegration => SequencerGatewayProvider::new( + Url::parse("https://integration-sepolia.starknet.io/gateway").unwrap(), + Url::parse("https://integration-sepolia.starknet.io/feeder_gateway") + .unwrap(), + short_string!("SN_INTEGRATION_SEPOLIA"), + ), }), match network { Network::Mainnet | Network::Goerli | Network::Sepolia => false, - Network::Integration => true, + Network::GoerliIntegration | Network::SepoliaIntegration => true, }, ) }