@@ -66,34 +66,27 @@ pub struct BuilderConfig {
6666 /// URL for Host RPC node.
6767 #[ from_env(
6868 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://"
7170 ) ]
72- pub host_rpc_url : Cow < ' static , str > ,
71+ pub host_rpc_url : url :: Url ,
7372
7473 /// URL for the Rollup RPC node.
7574 #[ from_env(
7675 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."
7977 ) ]
80- pub ru_rpc_url : Cow < ' static , str > ,
78+ pub ru_rpc_url : url :: Url ,
8179
8280 /// 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 ,
8983
9084 /// Additional RPC URLs to which the builder should broadcast transactions.
9185 /// * Should not include the `HOST_RPC_URL` value, as that is already sent to by default.
9286 /// * Setting this can incur `already known` errors.
9387 #[ from_env(
9488 var = "TX_BROADCAST_URLS" ,
9589 desc = "Additional RPC URLs to which the builder broadcasts transactions" ,
96- infallible,
9790 optional
9891 ) ]
9992 pub tx_broadcast_urls : Vec < Cow < ' static , str > > ,
@@ -190,15 +183,13 @@ impl BuilderConfig {
190183 tokio:: sync:: OnceCell :: const_new ( ) ;
191184
192185 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 ( ) ;
196187 eyre:: ensure!(
197188 scheme == "ws" || scheme == "wss" ,
198189 "Invalid Rollup RPC URL scheme: {scheme}. Expected ws:// or wss://"
199190 ) ;
200191
201- RootProvider :: connect_with ( BuiltInConnectionString :: Ws ( url , None ) )
192+ RootProvider :: connect_with ( BuiltInConnectionString :: Ws ( self . ru_rpc_url . clone ( ) , None ) )
202193 . await
203194 . map_err ( Into :: into)
204195 } )
@@ -216,7 +207,7 @@ impl BuilderConfig {
216207 . with_nonce_management ( SimpleNonceManager :: default ( ) )
217208 . fetch_chain_id ( )
218209 . wallet ( EthereumWallet :: from ( builder_signer) )
219- . connect ( & self . host_rpc_url )
210+ . connect ( self . host_rpc_url . as_str ( ) )
220211 . await
221212 . map_err ( Into :: into)
222213 }
@@ -225,8 +216,8 @@ impl BuilderConfig {
225216 pub fn connect_additional_broadcast ( & self ) -> Vec < RootProvider > {
226217 self . tx_broadcast_urls
227218 . 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 " ) ;
230221 RootProvider :: new_http ( url)
231222 } )
232223 . collect :: < Vec < _ > > ( )
0 commit comments