diff --git a/Cargo.toml b/Cargo.toml index d89a973..a419ffe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ name = "init4-bin-base" description = "Internal utilities for binaries produced by the init4 team" keywords = ["init4", "bin", "base"] -version = "0.12.4" +version = "0.12.5" edition = "2021" rust-version = "1.83" authors = ["init4", "James Prestwich", "evalir"] diff --git a/src/utils/calc.rs b/src/utils/calc.rs index 733e947..7197b04 100644 --- a/src/utils/calc.rs +++ b/src/utils/calc.rs @@ -263,7 +263,7 @@ impl SlotCalculator { } impl FromEnv for SlotCalculator { - type Error = FromEnvErr; + type Error = ParseIntError; fn inventory() -> Vec<&'static EnvItemInfo> { vec![ diff --git a/src/utils/from_env.rs b/src/utils/from_env.rs index 357c37d..c2d429f 100644 --- a/src/utils/from_env.rs +++ b/src/utils/from_env.rs @@ -1,5 +1,5 @@ use signet_constants::{ - HostConstants, RollupConstants, SignetConstants, SignetEnvironmentConstants, + HostConstants, ParseChainError, RollupConstants, SignetConstants, SignetEnvironmentConstants, SignetSystemConstants, }; use std::{convert::Infallible, env::VarError, num::ParseIntError, str::FromStr}; @@ -670,6 +670,23 @@ impl FromEnvVar for tracing::Level { } } +impl FromEnv for SignetSystemConstants { + type Error = ParseChainError; + + fn inventory() -> Vec<&'static EnvItemInfo> { + vec![&EnvItemInfo { + var: "CHAIN_NAME", + description: + "The name of the chain. If set, the other environment variables are ignored.", + optional: true, + }] + } + + fn from_env() -> Result> { + SignetSystemConstants::from_env_var("CHAIN_NAME") + } +} + #[cfg(test)] mod test { use std::{borrow::Cow, time::Duration};