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

Commit

Permalink
feat: improve gnosis chain configuration (#2640)
Browse files Browse the repository at this point in the history
* feat: improve gnosis chain configuration

- rename xdai to gnosis in chain enum
- remove mention of xdai in serde/strum
- add average blocktime for gnosis and chiado
- mark gnosis and chiado as supporting eip 1559 and push0
- use gnosisscan as gnosis' block explorer

* fix: reintroduce xdai alias in serde and strum

---------

Co-authored-by: luzzifoss <[email protected]>
  • Loading branch information
luzzif and luzzifoss authored Oct 18, 2023
1 parent 23f5766 commit d253514
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ethers-contract/src/multicall/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub const MULTICALL_SUPPORTED_CHAIN_IDS: &[u64] = {
ArbitrumTestnet as u64, // Arbitrum Rinkeby
Polygon as u64, // Polygon
PolygonMumbai as u64, // Polygon Mumbai
XDai as u64, // Gnosis Chain
Gnosis as u64, // Gnosis Chain
Avalanche as u64, // Avalanche
AvalancheFuji as u64, // Avalanche Fuji
FantomTestnet as u64, // Fantom Testnet
Expand Down
36 changes: 17 additions & 19 deletions ethers-core/src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub enum Chain {

#[strum(to_string = "xdai", serialize = "gnosis", serialize = "gnosis-chain")]
#[serde(alias = "xdai", alias = "gnosis", alias = "gnosis_chain")]
XDai = 100,
Gnosis = 100,

Polygon = 137,
#[strum(to_string = "mumbai", serialize = "polygon-mumbai")]
Expand Down Expand Up @@ -304,13 +304,12 @@ impl Chain {
Celo | CeloAlfajores | CeloBaklava => 5_000,
FilecoinCalibrationTestnet | FilecoinMainnet => 30_000,
ScrollAlphaTestnet => 3_000,
Gnosis | Chiado => 5_000,
// Explicitly exhaustive. See NB above.
Morden | Ropsten | Rinkeby | Goerli | Kovan | XDai | Chiado | Sepolia | Holesky |
Moonbase | MoonbeamDev | OptimismKovan | Poa | Sokol | Rsk | EmeraldTestnet |
Boba | Base | BaseGoerli | ZkSync | ZkSyncTestnet | PolygonZkEvm |
PolygonZkEvmTestnet | Metis | Linea | LineaTestnet | Mantle | MantleTestnet => {
return None
}
Morden | Ropsten | Rinkeby | Goerli | Kovan | Sepolia | Holesky | Moonbase |
MoonbeamDev | OptimismKovan | Poa | Sokol | Rsk | EmeraldTestnet | Boba | Base |
BaseGoerli | ZkSync | ZkSyncTestnet | PolygonZkEvm | PolygonZkEvmTestnet | Metis |
Linea | LineaTestnet | Mantle | MantleTestnet => return None,
};

Some(Duration::from_millis(ms))
Expand Down Expand Up @@ -371,13 +370,15 @@ impl Chain {
FilecoinMainnet |
Linea |
LineaTestnet |
FilecoinCalibrationTestnet => false,
FilecoinCalibrationTestnet |
Gnosis |
Chiado => false,

// Unknown / not applicable, default to false for backwards compatibility
Dev | AnvilHardhat | Morden | Ropsten | Rinkeby | Cronos | CronosTestnet | Kovan |
Sokol | Poa | XDai | Moonbeam | MoonbeamDev | Moonriver | Moonbase | Evmos |
EvmosTestnet | Chiado | Aurora | AuroraTestnet | Canto | CantoTestnet |
ScrollAlphaTestnet | Metis => false,
Sokol | Poa | Moonbeam | MoonbeamDev | Moonriver | Moonbase | Evmos |
EvmosTestnet | Aurora | AuroraTestnet | Canto | CantoTestnet | ScrollAlphaTestnet |
Metis => false,
}
}

Expand All @@ -387,7 +388,7 @@ impl Chain {
/// `<https://eips.ethereum.org/EIPS/eip-3855>`
pub const fn supports_push0(&self) -> bool {
match self {
Chain::Mainnet | Chain::Goerli | Chain::Sepolia => true,
Chain::Mainnet | Chain::Goerli | Chain::Sepolia | Chain::Gnosis | Chain::Chiado => true,
_ => false,
}
}
Expand Down Expand Up @@ -477,10 +478,7 @@ impl Chain {
Moonbase => ("https://api-moonbase.moonscan.io/api", "https://moonbase.moonscan.io/"),
Moonriver => ("https://api-moonriver.moonscan.io/api", "https://moonriver.moonscan.io"),

// blockscout API is etherscan compatible
XDai => {
("https://blockscout.com/xdai/mainnet/api", "https://blockscout.com/xdai/mainnet")
}
Gnosis => ("https://api.gnosisscan.io/api", "https://gnosisscan.io"),

ScrollAlphaTestnet => {
("https://blockscout.scroll.io/api", "https://blockscout.scroll.io/")
Expand Down Expand Up @@ -610,7 +608,8 @@ impl Chain {
Linea |
Mantle |
MantleTestnet |
BaseGoerli => "ETHERSCAN_API_KEY",
BaseGoerli |
Gnosis => "ETHERSCAN_API_KEY",

Avalanche | AvalancheFuji => "SNOWTRACE_API_KEY",

Expand All @@ -625,7 +624,6 @@ impl Chain {
Boba => "BOBASCAN_API_KEY",

// Explicitly exhaustive. See NB above.
XDai |
ScrollAlphaTestnet |
Metis |
Chiado |
Expand Down Expand Up @@ -712,7 +710,7 @@ mod tests {
(Mainnet, &["ethlive"]),
(BinanceSmartChain, &["bsc", "binance-smart-chain"]),
(BinanceSmartChainTestnet, &["bsc-testnet", "binance-smart-chain-testnet"]),
(XDai, &["xdai", "gnosis", "gnosis-chain"]),
(Gnosis, &["gnosis", "gnosis-chain"]),
(PolygonMumbai, &["mumbai"]),
(PolygonZkEvm, &["zkevm", "polygon-zkevm"]),
(PolygonZkEvmTestnet, &["zkevm-testnet", "polygon-zkevm-testnet"]),
Expand Down
1 change: 0 additions & 1 deletion ethers-etherscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ impl Client {
.map_err(Into::into),

// Backwards compatibility, ideally these should return an error.
Chain::XDai |
Chain::Chiado |
Chain::Sepolia |
Chain::Rsk |
Expand Down

0 comments on commit d253514

Please sign in to comment.