Skip to content

Commit

Permalink
feat: add sepolia-integration network
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xJonathanLEI committed Dec 19, 2023
1 parent 89bab93 commit e196118
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
3 changes: 2 additions & 1 deletion book/src/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ To use the sequencer gateway anyways, use the `--network <NETWORK>` option, wher
- `mainnet`
- `goerli`
- `sepolia`
- `integration`
- `goerli-integration`
- `sepolia-integration`
For example, to check the latest block number on `mainnet`:
Expand Down
7 changes: 4 additions & 3 deletions src/casm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
33 changes: 20 additions & 13 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pub enum Network {
Mainnet,
Goerli,
Sepolia,
Integration,
GoerliIntegration,
SepoliaIntegration,
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
Expand All @@ -29,7 +30,8 @@ impl ValueEnum for Network {
Self::Mainnet,
Self::Goerli,
Self::Sepolia,
Self::Integration,
Self::GoerliIntegration,
Self::SepoliaIntegration,
]
}

Expand All @@ -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")),
}
}
}
Expand All @@ -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)),
}
}
Expand All @@ -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"),
}
}
}
Expand All @@ -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
})
Expand Down
10 changes: 8 additions & 2 deletions src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)
}
Expand Down

0 comments on commit e196118

Please sign in to comment.