Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Aug 27, 2024
1 parent 82f871d commit 594e0f6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
75 changes: 73 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# superchain
Rust Bindings for the superchain-registry.
# `superchain`

Rust Bindings for the [superchain-registry][sr].

The best way to work with this repo is through the [`superchain`][sup]
crate. [`superchain`][sup] is an optionally `no_std` crate that provides
core types and bindings for the Superchain.

It re-exports two crates:
- [`superchain-primitives`][scp]
- [`superchain-registry`][scr] _Only available if `serde` feature flag is enabled_

[`superchain-primitives`][scp] defines core types used in the `superchain-registry`
along with a few default values for core chains.

[`superchain-registry`][scr] provides bindings to all chains in the `superchain`.

## Usage

Add the following to your `Cargo.toml`.

```toml
[dependencies]
superchain = "0.2"
```

To make make `superchain` `no_std`, toggle `default-features` off like so.

```toml
[dependencies]
superchain = { version = "0.2", default-features = false }
```

## Example

[`superchain-registry`][scr] exposes lazily defined mappings from chain id
to chain configurations that the [`superchain`][sup] re-exports. Below
demonstrates getting the `RollupConfig` for OP Mainnet (Chain ID `10`).

```rust
use superchain::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.

```rust
use superchain::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

- `serde`: Enables [`serde`][s] support for types and makes [`superchain-registry`][scr] types available.
- `std`: Uses the standard library to pull in environment variables.

<!-- Hyperlinks -->

[sp]: ./crates/superchain-primitives

[s]: https://crates.io/crates/serde
[sr]: https://github.com/ethereum-optimism/superchain-registry
[scr]: https://crates.io/crates/superchain-registry
[sup]: https://crates.io/crates/superchain
[scp]: https://crates.io/crates/superchain-primitives
[superchain]: https://github.com/anton-rs/superchain

5 changes: 5 additions & 0 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/anton-rs/superchain/main/assets/superchain.png",
html_favicon_url = "https://avatars.githubusercontent.com/u/139668603?s=256",
issue_tracker_base_url = "https://github.com/anton-rs/superchain/issues/"
)]
#![warn(missing_debug_implementations, missing_docs, rustdoc::all)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
Expand Down
5 changes: 5 additions & 0 deletions crates/registry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/anton-rs/superchain/main/assets/superchain.png",
html_favicon_url = "https://avatars.githubusercontent.com/u/139668603?s=256",
issue_tracker_base_url = "https://github.com/anton-rs/superchain/issues/"
)]
#![warn(missing_debug_implementations, missing_docs, rustdoc::all)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
Expand Down
5 changes: 5 additions & 0 deletions crates/superchain/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/anton-rs/superchain/main/assets/superchain.png",
html_favicon_url = "https://avatars.githubusercontent.com/u/139668603?s=256",
issue_tracker_base_url = "https://github.com/anton-rs/superchain/issues/"
)]
#![warn(missing_debug_implementations, missing_docs, rustdoc::all)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
Expand Down

0 comments on commit 594e0f6

Please sign in to comment.