@@ -9,9 +9,9 @@ use alloy::{
9
9
} ,
10
10
Identity , ProviderBuilder , RootProvider ,
11
11
} ,
12
- transports:: BoxTransport ,
13
12
} ;
14
13
use std:: { borrow:: Cow , env, num, str:: FromStr } ;
14
+
15
15
use zenith_types:: Zenith ;
16
16
17
17
// Keys for .env variables that need to be set to configure the builder.
@@ -125,7 +125,7 @@ impl ConfigError {
125
125
}
126
126
}
127
127
128
- /// Provider type used to read & write.
128
+ /// Defines a full provider
129
129
pub type Provider = FillProvider <
130
130
JoinFill <
131
131
JoinFill <
@@ -134,26 +134,22 @@ pub type Provider = FillProvider<
134
134
> ,
135
135
WalletFiller < EthereumWallet > ,
136
136
> ,
137
- RootProvider < BoxTransport > ,
138
- BoxTransport ,
137
+ RootProvider ,
139
138
Ethereum ,
140
139
> ;
141
140
142
- /// Provider type used to read-only.
141
+ /// Defines a read-only wallet
143
142
pub type WalletlessProvider = FillProvider <
144
143
JoinFill <
145
144
Identity ,
146
145
JoinFill < GasFiller , JoinFill < BlobGasFiller , JoinFill < NonceFiller , ChainIdFiller > > > ,
147
146
> ,
148
- RootProvider < BoxTransport > ,
149
- BoxTransport ,
147
+ RootProvider ,
150
148
Ethereum ,
151
149
> ;
152
150
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 > ;
157
153
158
154
impl BuilderConfig {
159
155
/// Load the builder configuration from environment variables.
@@ -210,32 +206,33 @@ impl BuilderConfig {
210
206
211
207
/// Connect to the Rollup rpc provider.
212
208
pub async fn connect_ru_provider ( & self ) -> Result < WalletlessProvider , ConfigError > {
213
- ProviderBuilder :: new ( )
214
- . with_recommended_fillers ( )
209
+ let provider = ProviderBuilder :: new ( )
215
210
. on_builtin ( & self . ru_rpc_url )
216
211
. await
217
- . map_err ( Into :: into)
212
+ . map_err ( ConfigError :: Provider ) ?;
213
+
214
+ Ok ( provider)
218
215
}
219
216
220
217
/// Connect to the Host rpc provider.
221
218
pub async fn connect_host_provider ( & self ) -> Result < Provider , ConfigError > {
222
219
let builder_signer = self . connect_builder_signer ( ) . await ?;
223
- ProviderBuilder :: new ( )
224
- . with_recommended_fillers ( )
220
+ let provider = ProviderBuilder :: new ( )
225
221
. wallet ( EthereumWallet :: from ( builder_signer) )
226
222
. on_builtin ( & self . host_rpc_url )
227
223
. await
228
- . map_err ( Into :: into)
224
+ . map_err ( ConfigError :: Provider ) ?;
225
+
226
+ Ok ( provider)
229
227
}
230
228
231
- /// Connect additional broadcast providers.
232
- pub async fn connect_additional_broadcast (
233
- & self ,
234
- ) -> Result < Vec < RootProvider < BoxTransport > > , ConfigError > {
235
- let mut providers = Vec :: with_capacity ( self . tx_broadcast_urls . len ( ) ) ;
229
+ /// Connect additionally configured non-host providers to broadcast transactions to.
230
+ pub async fn connect_additional_broadcast ( & self ) -> Result < Vec < WalletlessProvider > , ConfigError > {
231
+ let mut providers: Vec < WalletlessProvider > = Vec :: with_capacity ( self . tx_broadcast_urls . len ( ) ) ;
236
232
for url in self . tx_broadcast_urls . iter ( ) {
237
233
let provider =
238
- ProviderBuilder :: new ( ) . on_builtin ( url) . await . map_err ( Into :: < ConfigError > :: into) ?;
234
+ ProviderBuilder :: new ( ) . on_builtin ( url) . await . map_err ( ConfigError :: Provider ) ?;
235
+
239
236
providers. push ( provider) ;
240
237
}
241
238
Ok ( providers)
@@ -278,5 +275,6 @@ pub fn load_url(key: &str) -> Result<Cow<'static, str>, ConfigError> {
278
275
/// Load an address from an environment variable.
279
276
pub fn load_address ( key : & str ) -> Result < Address , ConfigError > {
280
277
let address = load_string ( key) ?;
281
- Address :: from_str ( & address) . map_err ( Into :: into)
278
+ Address :: from_str ( & address)
279
+ . map_err ( |_| ConfigError :: Var ( format ! ( "Invalid address format for {}" , key) ) )
282
280
}
0 commit comments