Struct Config

Source
pub struct Config<'a> {
Show 17 fields pub profile: Profile, pub artifacts: PathBuf, pub monorepo: MonorepoConfig, pub l1_client: L1Client, pub l2_client: L2Client, pub rollup_client: RollupClient, pub l1_client_url: Option<String>, pub l1_client_port: Option<u16>, pub l2_client_url: Option<String>, pub l2_client_port: Option<u16>, pub rollup_client_url: Option<String>, pub rollup_client_port: Option<u16>, pub deployer: Option<String>, pub challenger: ChallengerAgent, pub enable_sequencing: bool, pub enable_fault_proofs: bool, pub eth_rpc_jwt: Option<String>, /* private fields */
}
Expand description

OP Stack Configuration

§Defaults

All configuration values have a default, documented in the fields section below. Config::default() returns the default values for the default profile while Config::with_root() returns the values based on the given directory. Config::load() starts with the default profile and merges various providers into the config, same for Config::load_with_root(), but there the default values are determined by Config::with_root()

§Provider Details

Config is a Figment Provider with the following characteristics:

  • Profile

    The profile is set to the value of the profile field.

  • Metadata

    This provider is named OP Stack Config. It does not specify a Source and uses default interpolation.

  • Data

    The data emitted by this provider are the keys and values corresponding to the fields and values of the structure. The dictionary is emitted to the “default” meta-profile.

Note that these behaviors differ from those of Config::figment().

Fields§

§profile: Profile

The selected profile. (default: default default)

Note: This field is never serialized nor deserialized. When a Config is merged into a Figment as a Provider, this profile is selected on the Figment. When a Config is extracted, this field is set to the extracting Figment’s selected Profile.

§artifacts: PathBuf

The path to the op stack artifact directory. (default: default .stack)

§monorepo: MonorepoConfig

The Optimism Monorepo configuration options.

§l1_client: L1Client

The type of L1 Client to use. (default: default L1Client::Geth)

§l2_client: L2Client

The type of L2 Client to use. (default: default L2Client::OpGeth)

§rollup_client: RollupClient

The type of Rollup Client to use. (default: default RollupClient::OpNode)

§l1_client_url: Option<String>

The L1 Client base URL.

§l1_client_port: Option<u16>

The L1 Client port.

§l2_client_url: Option<String>

The L2 Client URL.

§l2_client_port: Option<u16>

The L2 Client port.

§rollup_client_url: Option<String>

The rollup client URL.

§rollup_client_port: Option<u16>

The rollup client port.

§deployer: Option<String>

Deployer is the contract deployer. By default, this is a hardhat test account.

§challenger: ChallengerAgent

The challenger agent to use. (default: default ChallengerAgent::OpChallengerGo)

§enable_sequencing: bool

Enable Sequencing. (default: default false)

§enable_fault_proofs: bool

Enable Fault Proofs. (default: default false)

§eth_rpc_jwt: Option<String>

Stack Stage Components

This is a table array of [StageConfig]s, each of which represents a stage in the stack and is orchestrated by the [StageManager].

The parsing of [StageConfig]s is done by the [StageConfig::from_toml] function. This allows for different configuration formats to be used for each stage. JWT secret that should be used for any rpc calls

Implementations§

Source§

impl Config<'_>

Source

pub const DEFAULT_PROFILE: Profile

The default profile: “default”

Source

pub const PROFILE_SECTION: &'static str = "profile"

TOML section for profiles

Source

pub const FILE_NAME: &'static str = "stack.toml"

File name of config toml file

Source

pub const STACK_DIR_NAME: &'static str = ".stack"

The name of the directory rollup reserves for itself under the user’s home directory: ~

Source

pub const STANDALONE_SECTIONS: &'static [&'static str]

Standalone sections in the config which get integrated into the selected profile

Source

pub fn load() -> Self

Returns the current Config

See Config::figment

Source

pub fn load_with_root(root: impl Into<PathBuf>) -> Self

Returns the current Config

See Config::figment_with_root

Source

pub fn from_provider<T: Provider>(provider: T) -> Self

Extract a Config from provider, panicking if extraction fails.

§Panics

If extraction fails, prints an error message indicating the failure and panics. For a version that doesn’t panic, use Config::try_from().

§Example
use op_config::Config;
use figment::providers::{Toml, Format, Env};

// Use default `Figment`, but allow values from `other.toml`
// to supersede its values.
let figment = Config::figment()
    .merge(Toml::file("other.toml").nested());

let config = Config::from_provider(figment);
Source

pub fn from_toml(path: impl Into<PathBuf>) -> Result<Self, ExtractConfigError>

Attempts to build a Config using a PathBuf toml file. If the file does not exist, it will be created with default values.

Source

pub fn try_from<T: Provider>(provider: T) -> Result<Self, ExtractConfigError>

Attempts to extract a Config from provider, returning the result.

§Example
use op_config::Config;
use figment::providers::{Toml, Format, Env};

// Use default `Figment`, but allow values from `other.toml`
// to supersede its values.
let figment = Config::figment()
    .merge(Toml::file("other.toml").nested());

let config = Config::try_from(figment);
Source

pub fn figment() -> Figment

Returns the default figment

The default figment reads from the following sources, in ascending priority order:

  1. Config::default() (see defaults)
  2. stack.toml or filename in OP_STACK_CONFIG environment variable
  3. OP_STACK_ prefixed environment variables

The profile selected is the value set in the OP_STACK_PROFILE environment variable. If it is not set, it defaults to default.

§Example
use op_config::Config;
use serde::Deserialize;

let my_config = Config::figment().extract::<Config>();
Source

pub fn figment_with_root(root: impl Into<PathBuf>) -> Figment

Returns the default figment enhanced with additional context extracted from the provided root, like remappings and directories.

§Example
use op_config::Config;
use serde::Deserialize;

let my_config = Config::figment_with_root(".").extract::<Config>();
Source

pub fn with_root(root: impl Into<PathBuf>) -> Self

Creates a new Config that adds additional context extracted from the provided root.

§Example
use op_config::Config;
let my_config = Config::with_root(".");
Source

pub fn create_artifacts_dir(&self) -> Result<()>

Creates the artifacts directory if it doesn’t exist.

Source

pub fn selected_profile() -> Profile

Returns the selected profile

If the STACK_PROFILE env variable is not set, this returns the DEFAULT_PROFILE

Source

pub fn stack_dir_toml() -> Option<PathBuf>

Returns the path to the global toml file that’s stored at ~/.stack/stack.toml

Source

pub fn stack_dir() -> Option<PathBuf>

Returns the path to the config dir ~/.stack/

Source

pub fn force_overwrites(self, force: bool) -> Self

Force monorepo artifact overwrites.

Source

pub fn set_l1_client(&mut self) -> Result<()>

Sets the l1 client to use via a cli prompt.

Source

pub fn set_l2_client(&mut self) -> Result<()>

Sets the l2 client to use via a cli prompt.

Source

pub fn set_rollup_client(&mut self) -> Result<()>

Sets the rollup client to use via a cli prompt.

Source

pub fn set_challenger(&mut self) -> Result<()>

Sets the challenger agent to use via a cli prompt.

Trait Implementations§

Source§

impl<'a> Clone for Config<'a>

Source§

fn clone(&self) -> Config<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Config<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, 'a> Deserialize<'de> for Config<'a>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Config<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Config<'_>> for Figment

Source§

fn from(c: Config<'_>) -> Figment

Converts to this type from the input type.
Source§

impl<'a> PartialEq for Config<'a>

Source§

fn eq(&self, other: &Config<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Provider for Config<'_>

Source§

fn metadata(&self) -> Metadata

Returns the Metadata for this provider, identifying itself and its configuration sources.
Source§

fn data(&self) -> Result<Map<Profile, Dict>, Error>

Returns the configuration data.
Source§

fn profile(&self) -> Option<Profile>

Optionally returns a profile to set on the Figment this provider is merged into. The profile is only set if self is merged.
Source§

impl<'a> Serialize for Config<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> StructuralPartialEq for Config<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Config<'a>

§

impl<'a> RefUnwindSafe for Config<'a>

§

impl<'a> Send for Config<'a>

§

impl<'a> Sync for Config<'a>

§

impl<'a> Unpin for Config<'a>

§

impl<'a> UnwindSafe for Config<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Paint for T
where T: ?Sized,

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> JsonSchemaMaybe for T