Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: Immutable zkEVM and Immutable zkEVM testnet #88

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Features

- Add immutable mainnet and testnet ([#88](https://github.com/alloy-rs/chains/issues/88))

## [0.1.30](https://github.com/alloy-rs/chains/releases/tag/v0.1.30) - 2024-09-06

### Features
Expand Down
24 changes: 24 additions & 0 deletions assets/chains.json

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

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

/// Returns the Immutable zkEVM mainnet chain.
#[inline]
pub const fn immutable() -> Self {
Self::from_named(NamedChain::Immutable)
}

/// Returns the Immutable zkEVM testnet chain.
#[inline]
pub const fn immutable_testnet() -> Self {
Self::from_named(NamedChain::ImmutableTestnet)
}

/// Returns the kind of this chain.
#[inline]
pub const fn kind(&self) -> &ChainKind {
Expand Down
40 changes: 35 additions & 5 deletions src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ pub enum NamedChain {
#[strum(to_string = "pulsechain-testnet")]
#[cfg_attr(feature = "serde", serde(alias = "pulsechain-testnet"))]
PulsechainTestnet = 943,

#[strum(to_string = "immutable")]
#[cfg_attr(feature = "serde", serde(alias = "immutable"))]
Immutable = 13371,
#[strum(to_string = "immutable-testnet")]
#[cfg_attr(feature = "serde", serde(alias = "immutable-testnet"))]
ImmutableTestnet = 13473,
}

// This must be implemented manually so we avoid a conflict with `TryFromPrimitive` where it treats
Expand Down Expand Up @@ -583,6 +590,8 @@ impl NamedChain {

C::Pulsechain => 10000,
C::PulsechainTestnet => 10101,

C::Immutable | C::ImmutableTestnet => 2_000,
}))
}

Expand Down Expand Up @@ -696,7 +705,9 @@ impl NamedChain {
| C::Crab
| C::Pulsechain
| C::PulsechainTestnet
| C::Koi => false,
| C::Koi
| C::Immutable
| C::ImmutableTestnet => false,

// Unknown / not applicable, default to false for backwards compatibility.
C::Dev
Expand Down Expand Up @@ -786,7 +797,9 @@ impl NamedChain {
| C::CfxTestnet
| C::Pulsechain
| C::PulsechainTestnet
| C::Koi => true,
| C::Koi
| C::Immutable
| C::ImmutableTestnet => true,
_ => false,
}
}
Expand Down Expand Up @@ -862,7 +875,8 @@ impl NamedChain {
| C::PulsechainTestnet
| C::GravityAlphaTestnetSepolia
| C::XaiSepolia
| C::Koi => true,
| C::Koi
| C::ImmutableTestnet => true,

// Dev chains.
C::Dev | C::AnvilHardhat => true,
Expand Down Expand Up @@ -921,7 +935,8 @@ impl NamedChain {
| C::Cfx
| C::Crab
| C::Pulsechain
| C::Etherlink => false,
| C::Etherlink
| C::Immutable => false,
}
}

Expand Down Expand Up @@ -975,6 +990,9 @@ impl NamedChain {
C::Cfx | C::CfxTestnet => "CFX",
C::Pulsechain | C::PulsechainTestnet => "PLS",

C::Immutable => "IMX",
C::ImmutableTestnet => "tIMX",

_ => return None,
})
}
Expand Down Expand Up @@ -1300,6 +1318,14 @@ impl NamedChain {
"https://api.scan.v4.testnet.pulsechain.com",
"https://scan.v4.testnet.pulsechain.com",
),

C::Immutable => {
("https://explorer.immutable.com/api", "https://explorer.immutable.com")
}
C::ImmutableTestnet => (
"https://explorer.testnet.immutable.com/api",
"https://explorer.testnet.immutable.com",
),
})
}

Expand Down Expand Up @@ -1399,7 +1425,9 @@ impl NamedChain {
| C::ZoraSepolia
| C::Darwinia
| C::Crab
| C::Koi => "BLOCKSCOUT_API_KEY",
| C::Koi
| C::Immutable
| C::ImmutableTestnet => "BLOCKSCOUT_API_KEY",

C::Boba => "BOBASCAN_API_KEY",

Expand Down Expand Up @@ -1556,6 +1584,8 @@ mod tests {
(SyndrSepolia, &["syndr-sepolia"]),
(LineaGoerli, &["linea-goerli"]),
(AutonomysNovaTestnet, &["autonomys-nova-testnet"]),
(Immutable, &["immutable"]),
(ImmutableTestnet, &["immutable-testnet"]),
];

for &(chain, aliases) in ALIASES {
Expand Down
Loading