Registry
kona-registry
is a no_std
crate that exports rust type definitions for chains
in the superchain-registry
. These are lazily evaluated statics that provide
ChainConfig
s, RollupConfig
s, and Chain
objects for all chains with static definitions
in the superchain-registry
.
Since it reads static files to read configurations for various chains into instantiated
objects, the kona-registry
crate requires serde
as a dependency.
There are three core statics exposed by the kona-registry
.
CHAINS
: A list of chain objects containing the superchain metadata for this chain.OPCHAINS
: A map from chain id toChainConfig
.ROLLUP_CONFIGS
: A map from chain id toRollupConfig
.
kona-registry
exports the complete list of chains within the superchain, as well as each
chain's RollupConfig
s and ChainConfig
s.
Usage
Add the following to your Cargo.toml
.
[dependencies]
kona-registry = "0.1.0"
To make kona-registry
no_std
, toggle default-features
off like so.
[dependencies]
kona-registry = { version = "0.1.0", default-features = false }
Below demonstrates getting the RollupConfig
for OP Mainnet (Chain ID 10
).
#![allow(unused)] fn main() { use kona_registry::ROLLUP_CONFIGS; let op_chain_id = 10; let op_rollup_config = ROLLUP_CONFIGS.get(&op_chain_id); println!("OP Mainnet Rollup Config: {:?}", op_rollup_config); }
A mapping from chain id to ChainConfig
is also available.
#![allow(unused)] fn main() { use kona_registry::OPCHAINS; let op_chain_id = 10; let op_chain_config = OPCHAINS.get(&op_chain_id); println!("OP Mainnet Chain Config: {:?}", op_chain_config); }