Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 594e0f6

Browse files
committed
fixes
1 parent 82f871d commit 594e0f6

File tree

4 files changed

+88
-2
lines changed

4 files changed

+88
-2
lines changed

README.md

+73-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,73 @@
1-
# superchain
2-
Rust Bindings for the superchain-registry.
1+
# `superchain`
2+
3+
Rust Bindings for the [superchain-registry][sr].
4+
5+
The best way to work with this repo is through the [`superchain`][sup]
6+
crate. [`superchain`][sup] is an optionally `no_std` crate that provides
7+
core types and bindings for the Superchain.
8+
9+
It re-exports two crates:
10+
- [`superchain-primitives`][scp]
11+
- [`superchain-registry`][scr] _Only available if `serde` feature flag is enabled_
12+
13+
[`superchain-primitives`][scp] defines core types used in the `superchain-registry`
14+
along with a few default values for core chains.
15+
16+
[`superchain-registry`][scr] provides bindings to all chains in the `superchain`.
17+
18+
## Usage
19+
20+
Add the following to your `Cargo.toml`.
21+
22+
```toml
23+
[dependencies]
24+
superchain = "0.2"
25+
```
26+
27+
To make make `superchain` `no_std`, toggle `default-features` off like so.
28+
29+
```toml
30+
[dependencies]
31+
superchain = { version = "0.2", default-features = false }
32+
```
33+
34+
## Example
35+
36+
[`superchain-registry`][scr] exposes lazily defined mappings from chain id
37+
to chain configurations that the [`superchain`][sup] re-exports. Below
38+
demonstrates getting the `RollupConfig` for OP Mainnet (Chain ID `10`).
39+
40+
```rust
41+
use superchain::ROLLUP_CONFIGS;
42+
43+
let op_chain_id = 10;
44+
let op_rollup_config = ROLLUP_CONFIGS.get(&op_chain_id);
45+
println!("OP Mainnet Rollup Config: {:?}", op_rollup_config);
46+
```
47+
48+
A mapping from chain id to `ChainConfig` is also available.
49+
50+
```rust
51+
use superchain::OPCHAINS;
52+
53+
let op_chain_id = 10;
54+
let op_chain_config = OPCHAINS.get(&op_chain_id);
55+
println!("OP Mainnet Chain Config: {:?}", op_chain_config);
56+
```
57+
58+
## Feature Flags
59+
60+
- `serde`: Enables [`serde`][s] support for types and makes [`superchain-registry`][scr] types available.
61+
- `std`: Uses the standard library to pull in environment variables.
62+
63+
<!-- Hyperlinks -->
64+
65+
[sp]: ./crates/superchain-primitives
66+
67+
[s]: https://crates.io/crates/serde
68+
[sr]: https://github.com/ethereum-optimism/superchain-registry
69+
[scr]: https://crates.io/crates/superchain-registry
70+
[sup]: https://crates.io/crates/superchain
71+
[scp]: https://crates.io/crates/superchain-primitives
72+
[superchain]: https://github.com/anton-rs/superchain
73+

crates/primitives/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#![doc = include_str!("../README.md")]
2+
#![doc(
3+
html_logo_url = "https://raw.githubusercontent.com/anton-rs/superchain/main/assets/superchain.png",
4+
html_favicon_url = "https://avatars.githubusercontent.com/u/139668603?s=256",
5+
issue_tracker_base_url = "https://github.com/anton-rs/superchain/issues/"
6+
)]
27
#![warn(missing_debug_implementations, missing_docs, rustdoc::all)]
38
#![deny(unused_must_use, rust_2018_idioms)]
49
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

crates/registry/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#![doc = include_str!("../README.md")]
2+
#![doc(
3+
html_logo_url = "https://raw.githubusercontent.com/anton-rs/superchain/main/assets/superchain.png",
4+
html_favicon_url = "https://avatars.githubusercontent.com/u/139668603?s=256",
5+
issue_tracker_base_url = "https://github.com/anton-rs/superchain/issues/"
6+
)]
27
#![warn(missing_debug_implementations, missing_docs, rustdoc::all)]
38
#![deny(unused_must_use, rust_2018_idioms)]
49
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

crates/superchain/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#![doc = include_str!("../README.md")]
2+
#![doc(
3+
html_logo_url = "https://raw.githubusercontent.com/anton-rs/superchain/main/assets/superchain.png",
4+
html_favicon_url = "https://avatars.githubusercontent.com/u/139668603?s=256",
5+
issue_tracker_base_url = "https://github.com/anton-rs/superchain/issues/"
6+
)]
27
#![warn(missing_debug_implementations, missing_docs, rustdoc::all)]
38
#![deny(unused_must_use, rust_2018_idioms)]
49
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

0 commit comments

Comments
 (0)