Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

chore: Add ZKSync into the Chain type #2302

Merged
merged 1 commit into from
Apr 13, 2023
Merged
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
13 changes: 12 additions & 1 deletion ethers-core/src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ pub enum Chain {
Boba = 288,

BaseGoerli = 84531,

#[strum(to_string = "zksync")]
#[serde(alias = "zksync")]
ZkSync = 324,
}

// === impl Chain ===
Expand Down Expand Up @@ -276,7 +280,7 @@ impl Chain {
// Explicitly exhaustive. See NB above.
Morden | Ropsten | Rinkeby | Goerli | Kovan | XDai | Chiado | Sepolia | Moonbase |
MoonbeamDev | Optimism | OptimismGoerli | OptimismKovan | Poa | Sokol | Rsk |
EmeraldTestnet | Boba | BaseGoerli => return None,
EmeraldTestnet | Boba | BaseGoerli | ZkSync => return None,
};

Some(Duration::from_millis(ms))
Expand Down Expand Up @@ -316,6 +320,7 @@ impl Chain {
CeloAlfajores |
CeloBaklava |
Boba |
ZkSync |
BaseGoerli => true,

// Known EIP-1559 chains
Expand Down Expand Up @@ -472,6 +477,10 @@ impl Chain {

BaseGoerli => ("https://api-goerli.basescan.org/api", "https://goerli.basescan.org"),

ZkSync => {
("https://zksync2-mainnet-explorer.zksync.io/", "https://explorer.zksync.io/")
}

AnvilHardhat | Dev | Morden | MoonbeamDev | FilecoinMainnet => {
// this is explicitly exhaustive so we don't forget to add new urls when adding a
// new chain
Expand Down Expand Up @@ -547,6 +556,7 @@ impl Chain {
EvmosTestnet |
AnvilHardhat |
Dev |
ZkSync |
FilecoinMainnet |
FilecoinHyperspaceTestnet => return None,
};
Expand Down Expand Up @@ -620,6 +630,7 @@ mod tests {
(PolygonMumbai, &["mumbai"]),
(AnvilHardhat, &["anvil", "hardhat"]),
(AvalancheFuji, &["fuji"]),
(ZkSync, &["zksync"]),
];

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