Skip to content

Commit

Permalink
feat: add world (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Oct 17, 2024
1 parent 2070d7b commit 67eba9e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 7 deletions.
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.

37 changes: 30 additions & 7 deletions src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use num_enum::TryFromPrimitiveError;

#[allow(unused_imports)]
use alloc::string::String;

// When adding a new chain:
// 1. add new variant to the NamedChain enum;
// 2. add extra information in the last `impl` block (explorer URLs, block time) when applicable;
Expand Down Expand Up @@ -361,6 +360,12 @@ pub enum NamedChain {
#[strum(to_string = "soneium-minato-testnet")]
#[cfg_attr(feature = "serde", serde(alias = "soneium-minato-testnet"))]
SoneiumMinatoTestnet = 1946,

#[cfg_attr(feature = "serde", serde(alias = "worldchain"))]
World = 480,
#[strum(to_string = "world-sepolia")]
#[cfg_attr(feature = "serde", serde(alias = "worldchain-sepolia", alias = "world-sepolia"))]
WorldSepolia = 4801,
}

// This must be implemented manually so we avoid a conflict with `TryFromPrimitive` where it treats
Expand Down Expand Up @@ -507,6 +512,8 @@ impl NamedChain {
| OpBNBTestnet
| SoneiumMinatoTestnet
| Odyssey
| World
| WorldSepolia
)
}

Expand Down Expand Up @@ -611,6 +618,8 @@ impl NamedChain {

Immutable | ImmutableTestnet => 2_000,

World | WorldSepolia => 2_000,

Morden | Ropsten | Rinkeby | Goerli | Kovan | Sepolia | Holesky | MantleTestnet
| Moonbase | MoonbeamDev | OptimismKovan | Poa | Sokol | Rsk | EmeraldTestnet
| Boba | ZkSync | ZkSyncTestnet | PolygonZkEvm | PolygonZkEvmTestnet | Metis
Expand Down Expand Up @@ -732,7 +741,9 @@ impl NamedChain {
| Koi
| Immutable
| ImmutableTestnet
| SoneiumMinatoTestnet => false,
| SoneiumMinatoTestnet
| World
| WorldSepolia => false,

// Unknown / not applicable, default to false for backwards compatibility.
Dev | AnvilHardhat | Morden | Ropsten | Rinkeby | Cronos | CronosTestnet | Kovan
Expand Down Expand Up @@ -811,6 +822,8 @@ impl NamedChain {
| Immutable
| ImmutableTestnet
| SoneiumMinatoTestnet
| World
| WorldSepolia
)
}

Expand Down Expand Up @@ -882,7 +895,8 @@ impl NamedChain {
| XaiSepolia
| Koi
| ImmutableTestnet
| SoneiumMinatoTestnet => true,
| SoneiumMinatoTestnet
| WorldSepolia => true,

// Dev chains.
Dev | AnvilHardhat => true,
Expand All @@ -894,7 +908,7 @@ impl NamedChain {
| Emerald | FilecoinMainnet | Avalanche | Celo | Aurora | Canto | Boba | Base
| Fraxtal | Linea | ZkSync | Mantle | GravityAlphaMainnet | Xai | Zora | Pgn | Mode
| Viction | Elastos | Degen | OpBNBMainnet | Ronin | Taiko | Flare | Acala | Karura
| Darwinia | Cfx | Crab | Pulsechain | Etherlink | Immutable => false,
| Darwinia | Cfx | Crab | Pulsechain | Etherlink | Immutable | World => false,
}
}

Expand Down Expand Up @@ -938,6 +952,8 @@ impl NamedChain {
Immutable => "IMX",
ImmutableTestnet => "tIMX",

World | WorldSepolia => "WRLD",

_ => return None,
})
}
Expand Down Expand Up @@ -1251,6 +1267,14 @@ impl NamedChain {
Odyssey => {
("https://odyssey-explorer.ithaca.xyz/api", "https://odyssey-explorer.ithaca.xyz")
}
World => (
"https://worldchain-mainnet.explorer.alchemy.com/api",
"https://worldchain-mainnet.explorer.alchemy.com",
),
WorldSepolia => (
"https://worldchain-sepolia.explorer.alchemy.com/api",
"https://worldchain-sepolia.explorer.alchemy.com",
),
})
}

Expand Down Expand Up @@ -1330,9 +1354,8 @@ impl NamedChain {
Acala | AcalaMandalaTestnet | AcalaTestnet | Canto | CantoTestnet | Etherlink
| EtherlinkTestnet | Flare | FlareCoston2 | KakarotSepolia | Karura | KaruraTestnet
| Mode | ModeSepolia | Pgn | PgnSepolia | Shimmer | Zora | ZoraGoerli | ZoraSepolia
| Darwinia | Crab | Koi | Immutable | ImmutableTestnet | SoneiumMinatoTestnet => {
"BLOCKSCOUT_API_KEY"
}
| Darwinia | Crab | Koi | Immutable | ImmutableTestnet | SoneiumMinatoTestnet
| World | WorldSepolia => "BLOCKSCOUT_API_KEY",

Boba => "BOBASCAN_API_KEY",

Expand Down

0 comments on commit 67eba9e

Please sign in to comment.