10 releases
new 0.8.5 | Dec 19, 2024 |
---|---|
0.8.4 | Dec 17, 2024 |
0.7.3 | Dec 4, 2024 |
0.7.1 | Nov 28, 2024 |
0.6.8 | Nov 20, 2024 |
#178 in Magic Beans
4,103 downloads per month
Used in 3 crates
125KB
2K
SLoC
op-alloy-registry
op-alloy-registry
is a no_std
crate that exports rust type definitions for chains
in the superchain-registry
. Since it reads static files to read configurations for
various chains into instantiated objects, the op-alloy-registry
crate requires
serde
as a dependency. To use the op-alloy-registry
crate, add the crate
as a dependency to a Cargo.toml
.
op-alloy-registry = "0.6.7"
op-alloy-registry
declares lazy evaluated statics that expose ChainConfig
s, RollupConfig
s,
and Chain
objects for all chains with static definitions in the superchain registry. The way this works
is the golang side of the superchain registry contains an "internal code generation" script that has
been modified to output configuration files to the crates/registry
directory in the
etc
folder that are read by the op-alloy-registry
rust crate. These static config files
contain an up-to-date list of all superchain configurations with their chain configs. It is expected
that if the commit hash of the superchain-registry
pulled in as a git submodule has breaking
changes, the tests in this crate (op-alloy-registry
) will break and updates will need to be made.
There are three core statics exposed by the op-alloy-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
.
op-alloy-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]
op-alloy-registry = "0.6.7"
To make op-alloy-registry
no_std
, toggle default-features
off like so.
[dependencies]
op-alloy-registry = { version = "0.6.7", default-features = false }
Below demonstrates getting the RollupConfig
for OP Mainnet (Chain ID 10
).
use op_alloy_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.
use op_alloy_registry::OPCHAINS;
let op_chain_id = 10;
let op_chain_config = OPCHAINS.get(&op_chain_id);
println!("OP Mainnet Chain Config: {:?}", op_chain_config);
Feature Flags
std
: Uses the standard library to pull in environment variables.
Credits
superchain-registry contributors for building and maintaining superchain types.
alloy and op-alloy for creating and maintaining high quality Ethereum and Optimism types in rust.
Dependencies
~15MB
~335K SLoC