@@ -95,6 +95,7 @@ pub struct BuilderConfig {
9595 pub oauth_token_refresh_interval : u64 ,
9696}
9797
98+ /// Error loading the configuration.
9899#[ derive( Debug , thiserror:: Error ) ]
99100pub enum ConfigError {
100101 /// Error loading from environment variable
@@ -148,7 +149,11 @@ pub type WalletlessProvider = FillProvider<
148149 BoxTransport ,
149150 Ethereum ,
150151> ;
151- pub type ZenithInstance = Zenith :: ZenithInstance < BoxTransport , Provider , alloy:: network:: Ethereum > ;
152+
153+ /// A Zenith contract instance, using some provider `P` (defaults to
154+ /// [`Provider`]).
155+ pub type ZenithInstance < P = Provider > =
156+ Zenith :: ZenithInstance < BoxTransport , P , alloy:: network:: Ethereum > ;
152157
153158impl BuilderConfig {
154159 /// Load the builder configuration from environment variables.
@@ -187,10 +192,12 @@ impl BuilderConfig {
187192 } )
188193 }
189194
195+ /// Connect to the Builder signer.
190196 pub async fn connect_builder_signer ( & self ) -> Result < LocalOrAws , ConfigError > {
191197 LocalOrAws :: load ( & self . builder_key , Some ( self . host_chain_id ) ) . await . map_err ( Into :: into)
192198 }
193199
200+ /// Connect to the Sequencer signer.
194201 pub async fn connect_sequencer_signer ( & self ) -> Result < Option < LocalOrAws > , ConfigError > {
195202 match & self . sequencer_key {
196203 Some ( sequencer_key) => LocalOrAws :: load ( sequencer_key, Some ( self . host_chain_id ) )
@@ -221,6 +228,7 @@ impl BuilderConfig {
221228 . map_err ( Into :: into)
222229 }
223230
231+ /// Connect additional broadcast providers.
224232 pub async fn connect_additional_broadcast (
225233 & self ,
226234 ) -> Result < Vec < RootProvider < BoxTransport > > , ConfigError > {
@@ -233,33 +241,41 @@ impl BuilderConfig {
233241 Ok ( providers)
234242 }
235243
236- pub fn connect_zenith ( & self , provider : Provider ) -> ZenithInstance {
244+ /// Connect to the Zenith instance, using the specified provider.
245+ pub const fn connect_zenith ( & self , provider : Provider ) -> ZenithInstance {
237246 Zenith :: new ( self . zenith_address , provider)
238247 }
239248}
240249
250+ /// Load a string from an environment variable.
241251pub fn load_string ( key : & str ) -> Result < String , ConfigError > {
242252 env:: var ( key) . map_err ( |_| ConfigError :: missing ( key) )
243253}
244254
255+ /// Load a string from an environment variable, returning None if the variable
256+ /// is not set.
245257fn load_string_option ( key : & str ) -> Option < String > {
246258 load_string ( key) . ok ( )
247259}
248260
261+ /// Load a boolean from an environment variable.
249262pub fn load_u64 ( key : & str ) -> Result < u64 , ConfigError > {
250263 let val = load_string ( key) ?;
251264 val. parse :: < u64 > ( ) . map_err ( Into :: into)
252265}
253266
267+ /// Load a u16 from an environment variable.
254268fn load_u16 ( key : & str ) -> Result < u16 , ConfigError > {
255269 let val = load_string ( key) ?;
256270 val. parse :: < u16 > ( ) . map_err ( Into :: into)
257271}
258272
273+ /// Load a URL from an environment variable.
259274pub fn load_url ( key : & str ) -> Result < Cow < ' static , str > , ConfigError > {
260275 load_string ( key) . map ( Into :: into)
261276}
262277
278+ /// Load an address from an environment variable.
263279pub fn load_address ( key : & str ) -> Result < Address , ConfigError > {
264280 let address = load_string ( key) ?;
265281 Address :: from_str ( & address) . map_err ( Into :: into)
0 commit comments