@@ -9,9 +9,9 @@ use alloy::{
99 } ,
1010 Identity , ProviderBuilder , RootProvider ,
1111 } ,
12- transports:: BoxTransport ,
1312} ;
1413use std:: { borrow:: Cow , env, num, str:: FromStr } ;
14+
1515use zenith_types:: Zenith ;
1616
1717// Keys for .env variables that need to be set to configure the builder.
@@ -125,7 +125,7 @@ impl ConfigError {
125125 }
126126}
127127
128- /// Provider type used to read & write.
128+ /// Defines a full provider
129129pub type Provider = FillProvider <
130130 JoinFill <
131131 JoinFill <
@@ -134,26 +134,22 @@ pub type Provider = FillProvider<
134134 > ,
135135 WalletFiller < EthereumWallet > ,
136136 > ,
137- RootProvider < BoxTransport > ,
138- BoxTransport ,
137+ RootProvider ,
139138 Ethereum ,
140139> ;
141140
142- /// Provider type used to read-only.
141+ /// Defines a read-only wallet
143142pub type WalletlessProvider = FillProvider <
144143 JoinFill <
145144 Identity ,
146145 JoinFill < GasFiller , JoinFill < BlobGasFiller , JoinFill < NonceFiller , ChainIdFiller > > > ,
147146 > ,
148- RootProvider < BoxTransport > ,
149- BoxTransport ,
147+ RootProvider ,
150148 Ethereum ,
151149> ;
152150
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 > ;
151+ /// Defines a [`Zenith`] instance that is generic over [`Provider`]
152+ pub type ZenithInstance = Zenith :: ZenithInstance < ( ) , Provider , alloy:: network:: Ethereum > ;
157153
158154impl BuilderConfig {
159155 /// Load the builder configuration from environment variables.
@@ -210,32 +206,36 @@ impl BuilderConfig {
210206
211207 /// Connect to the Rollup rpc provider.
212208 pub async fn connect_ru_provider ( & self ) -> Result < WalletlessProvider , ConfigError > {
213- ProviderBuilder :: new ( )
214- . with_recommended_fillers ( )
209+ let provider = ProviderBuilder :: new ( )
215210 . on_builtin ( & self . ru_rpc_url )
216211 . await
217- . map_err ( Into :: into)
212+ . map_err ( ConfigError :: Provider ) ?;
213+
214+ Ok ( provider)
218215 }
219216
220217 /// Connect to the Host rpc provider.
221218 pub async fn connect_host_provider ( & self ) -> Result < Provider , ConfigError > {
222219 let builder_signer = self . connect_builder_signer ( ) . await ?;
223- ProviderBuilder :: new ( )
224- . with_recommended_fillers ( )
220+ let provider = ProviderBuilder :: new ( )
225221 . wallet ( EthereumWallet :: from ( builder_signer) )
226222 . on_builtin ( & self . host_rpc_url )
227223 . await
228- . map_err ( Into :: into)
224+ . map_err ( ConfigError :: Provider ) ?;
225+
226+ Ok ( provider)
229227 }
230228
231- /// Connect additional broadcast providers.
229+ /// Connect additionally configured non-host providers to broadcast transactions to .
232230 pub async fn connect_additional_broadcast (
233231 & self ,
234- ) -> Result < Vec < RootProvider < BoxTransport > > , ConfigError > {
235- let mut providers = Vec :: with_capacity ( self . tx_broadcast_urls . len ( ) ) ;
232+ ) -> Result < Vec < WalletlessProvider > , ConfigError > {
233+ let mut providers: Vec < WalletlessProvider > =
234+ Vec :: with_capacity ( self . tx_broadcast_urls . len ( ) ) ;
236235 for url in self . tx_broadcast_urls . iter ( ) {
237236 let provider =
238- ProviderBuilder :: new ( ) . on_builtin ( url) . await . map_err ( Into :: < ConfigError > :: into) ?;
237+ ProviderBuilder :: new ( ) . on_builtin ( url) . await . map_err ( ConfigError :: Provider ) ?;
238+
239239 providers. push ( provider) ;
240240 }
241241 Ok ( providers)
@@ -278,5 +278,6 @@ pub fn load_url(key: &str) -> Result<Cow<'static, str>, ConfigError> {
278278/// Load an address from an environment variable.
279279pub fn load_address ( key : & str ) -> Result < Address , ConfigError > {
280280 let address = load_string ( key) ?;
281- Address :: from_str ( & address) . map_err ( Into :: into)
281+ Address :: from_str ( & address)
282+ . map_err ( |_| ConfigError :: Var ( format ! ( "Invalid address format for {}" , key) ) )
282283}
0 commit comments