From 594e0f6f6f59f38a4913ee8c516ce18eb13fa6c9 Mon Sep 17 00:00:00 2001 From: refcell Date: Tue, 27 Aug 2024 18:27:42 -0400 Subject: [PATCH] fixes --- README.md | 75 +++++++++++++++++++++++++++++++++++- crates/primitives/src/lib.rs | 5 +++ crates/registry/src/lib.rs | 5 +++ crates/superchain/src/lib.rs | 5 +++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f73ff2..190a5fe 100644 --- a/README.md +++ b/README.md @@ -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. + + + +[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 + diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index b10f44b..48ffc1a 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -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))] diff --git a/crates/registry/src/lib.rs b/crates/registry/src/lib.rs index fb342a9..0f44d30 100644 --- a/crates/registry/src/lib.rs +++ b/crates/registry/src/lib.rs @@ -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))] diff --git a/crates/superchain/src/lib.rs b/crates/superchain/src/lib.rs index d4a1f60..fb00f65 100644 --- a/crates/superchain/src/lib.rs +++ b/crates/superchain/src/lib.rs @@ -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))]