Skip to content

Commit

Permalink
feat: add Linea Sepolia (#100)
Browse files Browse the repository at this point in the history
Added Linea Sepolia as it's now the main testnet for Linea.

Some notes:
I defined blockchain explorer's API key environment variable's default
name for Linea Sepolia as "ETHERSCAN_API_KEY" for compatibility, because
it's already defined like this for Linea mainnet and I don't want to
break existing code. The correct name would be "LINEASCAN_API_KEY"
  • Loading branch information
kfastov authored Oct 15, 2024
1 parent 9a9db78 commit e66543b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions assets/chains.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ impl Chain {
Self::from_named(NamedChain::LineaGoerli)
}

/// Returns the linea sepolia chain.
#[inline]
pub const fn linea_sepolia() -> Self {
Self::from_named(NamedChain::LineaSepolia)
}

/// Returns the mode mainnet chain.
#[inline]
pub const fn mode() -> Self {
Expand Down
11 changes: 10 additions & 1 deletion src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ pub enum NamedChain {
Linea = 59144,
#[cfg_attr(feature = "serde", serde(alias = "linea-goerli"))]
LineaGoerli = 59140,
#[cfg_attr(feature = "serde", serde(alias = "linea-sepolia"))]
LineaSepolia = 59141,

#[strum(to_string = "zksync")]
#[cfg_attr(feature = "serde", serde(alias = "zksync"))]
Expand Down Expand Up @@ -612,7 +614,7 @@ impl NamedChain {
Morden | Ropsten | Rinkeby | Goerli | Kovan | Sepolia | Holesky | MantleTestnet
| Moonbase | MoonbeamDev | OptimismKovan | Poa | Sokol | Rsk | EmeraldTestnet
| Boba | ZkSync | ZkSyncTestnet | PolygonZkEvm | PolygonZkEvmTestnet | Metis
| Linea | LineaGoerli | KakarotSepolia => return None,
| Linea | LineaGoerli | LineaSepolia | KakarotSepolia => return None,
}))
}

Expand Down Expand Up @@ -695,6 +697,7 @@ impl NamedChain {
| FilecoinMainnet
| Linea
| LineaGoerli
| LineaSepolia
| FilecoinCalibrationTestnet
| Gnosis
| Chiado
Expand Down Expand Up @@ -847,6 +850,7 @@ impl NamedChain {
| FilecoinCalibrationTestnet
| FraxtalTestnet
| LineaGoerli
| LineaSepolia
| MantleTestnet
| MantleSepolia
| MoonbeamDev
Expand Down Expand Up @@ -1141,6 +1145,9 @@ impl NamedChain {
LineaGoerli => {
("https://explorer.goerli.linea.build/api", "https://explorer.goerli.linea.build")
}
LineaSepolia => {
("https://api-sepolia.lineascan.build/api", "https://sepolia.lineascan.build")
}

Mantle => ("https://explorer.mantle.xyz/api", "https://explorer.mantle.xyz"),
MantleTestnet => {
Expand Down Expand Up @@ -1292,6 +1299,7 @@ impl NamedChain {
| CeloBaklava
| Base
| Linea
| LineaSepolia
| Mantle
| MantleTestnet
| MantleSepolia
Expand Down Expand Up @@ -1523,6 +1531,7 @@ mod tests {
(Syndr, &["syndr"]),
(SyndrSepolia, &["syndr-sepolia"]),
(LineaGoerli, &["linea-goerli"]),
(LineaSepolia, &["linea-sepolia"]),
(AutonomysNovaTestnet, &["autonomys-nova-testnet"]),
(Immutable, &["immutable"]),
(ImmutableTestnet, &["immutable-testnet"]),
Expand Down

0 comments on commit e66543b

Please sign in to comment.