@@ -66,34 +66,27 @@ pub struct BuilderConfig {
66
66
/// URL for Host RPC node.
67
67
#[ from_env(
68
68
var = "HOST_RPC_URL" ,
69
- desc = "URL for Host RPC node. This MUST be a valid HTTP or WS URL, starting with http://, https://, ws:// or wss://" ,
70
- infallible
69
+ desc = "URL for Host RPC node. This MUST be a valid HTTP or WS URL, starting with http://, https://, ws:// or wss://"
71
70
) ]
72
- pub host_rpc_url : Cow < ' static , str > ,
71
+ pub host_rpc_url : url :: Url ,
73
72
74
73
/// URL for the Rollup RPC node.
75
74
#[ from_env(
76
75
var = "ROLLUP_RPC_URL" ,
77
- desc = "URL for Rollup RPC node. This MUST be a valid WS url starting with ws:// or wss://. Http providers are not supported." ,
78
- infallible
76
+ desc = "URL for Rollup RPC node. This MUST be a valid WS url starting with ws:// or wss://. Http providers are not supported."
79
77
) ]
80
- pub ru_rpc_url : Cow < ' static , str > ,
78
+ pub ru_rpc_url : url :: Url ,
81
79
82
80
/// URL of the tx pool to poll for incoming transactions.
83
- #[ from_env(
84
- var = "TX_POOL_URL" ,
85
- desc = "URL of the tx pool to poll for incoming transactions" ,
86
- infallible
87
- ) ]
88
- pub tx_pool_url : Cow < ' static , str > ,
81
+ #[ from_env( var = "TX_POOL_URL" , desc = "URL of the tx pool to poll for incoming transactions" ) ]
82
+ pub tx_pool_url : url:: Url ,
89
83
90
84
/// Additional RPC URLs to which the builder should broadcast transactions.
91
85
/// * Should not include the `HOST_RPC_URL` value, as that is already sent to by default.
92
86
/// * Setting this can incur `already known` errors.
93
87
#[ from_env(
94
88
var = "TX_BROADCAST_URLS" ,
95
89
desc = "Additional RPC URLs to which the builder broadcasts transactions" ,
96
- infallible,
97
90
optional
98
91
) ]
99
92
pub tx_broadcast_urls : Vec < Cow < ' static , str > > ,
@@ -190,15 +183,13 @@ impl BuilderConfig {
190
183
tokio:: sync:: OnceCell :: const_new ( ) ;
191
184
192
185
ONCE . get_or_try_init ( || async {
193
- let url = url:: Url :: parse ( & self . ru_rpc_url ) ?;
194
-
195
- let scheme = url. scheme ( ) ;
186
+ let scheme = self . ru_rpc_url . scheme ( ) ;
196
187
eyre:: ensure!(
197
188
scheme == "ws" || scheme == "wss" ,
198
189
"Invalid Rollup RPC URL scheme: {scheme}. Expected ws:// or wss://"
199
190
) ;
200
191
201
- RootProvider :: connect_with ( BuiltInConnectionString :: Ws ( url , None ) )
192
+ RootProvider :: connect_with ( BuiltInConnectionString :: Ws ( self . ru_rpc_url . clone ( ) , None ) )
202
193
. await
203
194
. map_err ( Into :: into)
204
195
} )
@@ -216,7 +207,7 @@ impl BuilderConfig {
216
207
. with_nonce_management ( SimpleNonceManager :: default ( ) )
217
208
. fetch_chain_id ( )
218
209
. wallet ( EthereumWallet :: from ( builder_signer) )
219
- . connect ( & self . host_rpc_url )
210
+ . connect ( self . host_rpc_url . as_str ( ) )
220
211
. await
221
212
. map_err ( Into :: into)
222
213
}
@@ -225,8 +216,8 @@ impl BuilderConfig {
225
216
pub fn connect_additional_broadcast ( & self ) -> Vec < RootProvider > {
226
217
self . tx_broadcast_urls
227
218
. iter ( )
228
- . map ( |url_str | {
229
- let url = url:: Url :: parse ( url_str ) . expect ( "failed to parse URL " ) ;
219
+ . map ( |url | {
220
+ let url = url. parse :: < url :: Url > ( ) . expect ( "Invalid URL in tx_broadcast_urls " ) ;
230
221
RootProvider :: new_http ( url)
231
222
} )
232
223
. collect :: < Vec < _ > > ( )
0 commit comments