1#![doc = include_str!("../README.md")]
2#![doc(
3 html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg",
4 html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico"
5)]
6#![cfg_attr(not(test), warn(unused_crate_dependencies))]
7#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
8#![cfg_attr(not(any(test, feature = "std")), no_std)]
9
10extern crate alloc;
11
12pub use alloy_primitives::map::{DefaultHashBuilder, HashMap};
13pub use op_alloy_genesis::{ChainConfig, RollupConfig};
14
15pub mod chain_list;
16pub use chain_list::{Chain, ChainList};
17
18pub mod superchain;
19pub use superchain::Registry;
20
21#[cfg(test)]
22pub mod test_utils;
23
24lazy_static::lazy_static! {
25 static ref _INIT: Registry = Registry::from_chain_list();
27
28 pub static ref CHAINS: alloc::vec::Vec<Chain> = _INIT.chains.clone();
30
31 pub static ref OPCHAINS: HashMap<u64, ChainConfig, DefaultHashBuilder> = _INIT.op_chains.clone();
33
34 pub static ref ROLLUP_CONFIGS: HashMap<u64, RollupConfig, DefaultHashBuilder> = _INIT.rollup_configs.clone();
36}
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_hardcoded_rollup_configs() {
44 let test_cases = vec![
45 (10, test_utils::OP_MAINNET_CONFIG),
46 (8453, test_utils::BASE_MAINNET_CONFIG),
47 (11155420, test_utils::OP_SEPOLIA_CONFIG),
48 (84532, test_utils::BASE_SEPOLIA_CONFIG),
49 ];
50
51 for (chain_id, expected) in test_cases {
52 let derived = super::ROLLUP_CONFIGS.get(&chain_id).unwrap();
53 assert_eq!(expected, *derived);
54 }
55 }
56}