kona_registry/
lib.rs

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