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
profilefield. -
Metadata
This provider is named
OP Stack Config. It does not specify aSourceand 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: ProfileThe 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: PathBufThe path to the op stack artifact directory. (default: default .stack)
monorepo: MonorepoConfigThe Optimism Monorepo configuration options.
l1_client: L1ClientThe type of L1 Client to use. (default: default L1Client::Geth)
l2_client: L2ClientThe type of L2 Client to use. (default: default L2Client::OpGeth)
rollup_client: RollupClientThe 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: ChallengerAgentThe challenger agent to use. (default: default ChallengerAgent::OpChallengerGo)
enable_sequencing: boolEnable Sequencing. (default: default false)
enable_fault_proofs: boolEnable 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<'_>
impl Config<'_>
Sourcepub const DEFAULT_PROFILE: Profile
pub const DEFAULT_PROFILE: Profile
The default profile: “default”
Sourcepub const PROFILE_SECTION: &'static str = "profile"
pub const PROFILE_SECTION: &'static str = "profile"
TOML section for profiles
Sourcepub const STACK_DIR_NAME: &'static str = ".stack"
pub const STACK_DIR_NAME: &'static str = ".stack"
The name of the directory rollup reserves for itself under the user’s home directory: ~
Sourcepub const STANDALONE_SECTIONS: &'static [&'static str]
pub const STANDALONE_SECTIONS: &'static [&'static str]
Standalone sections in the config which get integrated into the selected profile
Sourcepub fn load_with_root(root: impl Into<PathBuf>) -> Self
pub fn load_with_root(root: impl Into<PathBuf>) -> Self
Returns the current Config
See Config::figment_with_root
Sourcepub fn from_provider<T: Provider>(provider: T) -> Self
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);Sourcepub fn from_toml(path: impl Into<PathBuf>) -> Result<Self, ExtractConfigError>
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.
Sourcepub fn try_from<T: Provider>(provider: T) -> Result<Self, ExtractConfigError>
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);Sourcepub fn figment() -> Figment
pub fn figment() -> Figment
Returns the default figment
The default figment reads from the following sources, in ascending priority order:
Config::default()(see defaults)stack.tomlor filename inOP_STACK_CONFIGenvironment variableOP_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>();Sourcepub fn figment_with_root(root: impl Into<PathBuf>) -> Figment
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>();Sourcepub fn with_root(root: impl Into<PathBuf>) -> Self
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(".");Sourcepub fn create_artifacts_dir(&self) -> Result<()>
pub fn create_artifacts_dir(&self) -> Result<()>
Creates the artifacts directory if it doesn’t exist.
Sourcepub fn selected_profile() -> Profile
pub fn selected_profile() -> Profile
Returns the selected profile
If the STACK_PROFILE env variable is not set, this returns the DEFAULT_PROFILE
Sourcepub fn stack_dir_toml() -> Option<PathBuf>
pub fn stack_dir_toml() -> Option<PathBuf>
Returns the path to the global toml file that’s stored at ~/.stack/stack.toml
Sourcepub fn force_overwrites(self, force: bool) -> Self
pub fn force_overwrites(self, force: bool) -> Self
Force monorepo artifact overwrites.
Sourcepub fn set_l1_client(&mut self) -> Result<()>
pub fn set_l1_client(&mut self) -> Result<()>
Sets the l1 client to use via a cli prompt.
Sourcepub fn set_l2_client(&mut self) -> Result<()>
pub fn set_l2_client(&mut self) -> Result<()>
Sets the l2 client to use via a cli prompt.
Sourcepub fn set_rollup_client(&mut self) -> Result<()>
pub fn set_rollup_client(&mut self) -> Result<()>
Sets the rollup client to use via a cli prompt.
Sourcepub fn set_challenger(&mut self) -> Result<()>
pub fn set_challenger(&mut self) -> Result<()>
Sets the challenger agent to use via a cli prompt.
Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Config<'a>
impl<'de, 'a> Deserialize<'de> for Config<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Provider for Config<'_>
impl Provider for Config<'_>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
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 bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
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>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
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 rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
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 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.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
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);