33
44use std:: { collections:: HashSet , str:: FromStr } ;
55
6- use alloy_primitives:: Address ;
7- use alloy_sol_types:: Eip712Domain ;
6+ use alloy:: dyn_abi:: Eip712Domain ;
7+ use alloy:: primitives:: Address ;
8+ use alloy:: signers:: local:: PrivateKeySigner ;
89use anyhow:: Result ;
9- use ethers_signers:: LocalWallet ;
1010use jsonrpsee:: { proc_macros:: rpc, server:: ServerBuilder , server:: ServerHandle } ;
1111use lazy_static:: lazy_static;
1212use prometheus:: { register_counter, register_int_counter, Counter , IntCounter } ;
@@ -91,7 +91,7 @@ pub trait Rpc {
9191}
9292
9393struct RpcImpl {
94- wallet : LocalWallet ,
94+ wallet : PrivateKeySigner ,
9595 accepted_addresses : HashSet < Address > ,
9696 domain_separator : Eip712Domain ,
9797}
@@ -128,7 +128,7 @@ fn check_api_version_deprecation(api_version: &TapRpcApiVersion) -> Option<JsonR
128128
129129fn aggregate_receipts_ (
130130 api_version : String ,
131- wallet : & LocalWallet ,
131+ wallet : & PrivateKeySigner ,
132132 accepted_addresses : & HashSet < Address > ,
133133 domain_separator : & Eip712Domain ,
134134 receipts : Vec < EIP712SignedMessage < Receipt > > ,
@@ -210,7 +210,7 @@ impl RpcServer for RpcImpl {
210210
211211pub async fn run_server (
212212 port : u16 ,
213- wallet : LocalWallet ,
213+ wallet : PrivateKeySigner ,
214214 accepted_addresses : HashSet < Address > ,
215215 domain_separator : Eip712Domain ,
216216 max_request_body_size : u32 ,
@@ -243,9 +243,7 @@ mod tests {
243243 use std:: collections:: HashSet ;
244244 use std:: str:: FromStr ;
245245
246- use alloy_primitives:: Address ;
247- use alloy_sol_types:: Eip712Domain ;
248- use ethers_signers:: { coins_bip39:: English , LocalWallet , MnemonicBuilder , Signer } ;
246+ use alloy:: { dyn_abi:: Eip712Domain , primitives:: Address , signers:: local:: PrivateKeySigner } ;
249247 use jsonrpsee:: { core:: client:: ClientT , http_client:: HttpClientBuilder , rpc_params} ;
250248 use rand:: prelude:: * ;
251249 use rand:: seq:: SliceRandom ;
@@ -259,25 +257,14 @@ mod tests {
259257
260258 #[ derive( Clone ) ]
261259 struct Keys {
262- wallet : LocalWallet ,
260+ wallet : PrivateKeySigner ,
263261 address : Address ,
264262 }
265263
266- fn keys ( index : u32 ) -> Keys {
267- let wallet: LocalWallet = MnemonicBuilder :: < English > :: default ( )
268- . phrase ( "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" )
269- . index ( index)
270- . unwrap ( )
271- . build ( )
272- . unwrap ( ) ;
273- // Alloy library does not have feature parity with ethers library (yet) This workaround is needed to get the address
274- // to convert to an alloy Address. This will not be needed when the alloy library has wallet support.
275- let address: [ u8 ; 20 ] = wallet. address ( ) . into ( ) ;
276-
277- Keys {
278- wallet,
279- address : address. into ( ) ,
280- }
264+ fn keys ( ) -> Keys {
265+ let wallet = PrivateKeySigner :: random ( ) ;
266+ let address = wallet. address ( ) ;
267+ Keys { wallet, address }
281268 }
282269
283270 #[ fixture]
@@ -319,7 +306,7 @@ mod tests {
319306 http_max_concurrent_connections : u32 ,
320307 ) {
321308 // The keys that will be used to sign the new RAVs
322- let keys_main = keys ( 0 ) ;
309+ let keys_main = keys ( ) ;
323310
324311 // Start the JSON-RPC server.
325312 let ( handle, local_addr) = server:: run_server (
@@ -362,10 +349,10 @@ mod tests {
362349 #[ values( 0 , 1 , 2 ) ] random_seed : u64 ,
363350 ) {
364351 // The keys that will be used to sign the new RAVs
365- let keys_main = keys ( 0 ) ;
352+ let keys_main = keys ( ) ;
366353 // Extra keys to test the server's ability to accept multiple signers as input
367- let keys_0 = keys ( 1 ) ;
368- let keys_1 = keys ( 2 ) ;
354+ let keys_0 = keys ( ) ;
355+ let keys_1 = keys ( ) ;
369356 // Vector of all wallets to make it easier to select one randomly
370357 let all_wallets = vec ! [ keys_main. clone( ) , keys_0. clone( ) , keys_1. clone( ) ] ;
371358 // PRNG for selecting a random wallet
@@ -443,10 +430,10 @@ mod tests {
443430 #[ values( 0 , 1 , 2 , 3 , 4 ) ] random_seed : u64 ,
444431 ) {
445432 // The keys that will be used to sign the new RAVs
446- let keys_main = keys ( 0 ) ;
433+ let keys_main = keys ( ) ;
447434 // Extra keys to test the server's ability to accept multiple signers as input
448- let keys_0 = keys ( 1 ) ;
449- let keys_1 = keys ( 2 ) ;
435+ let keys_0 = keys ( ) ;
436+ let keys_1 = keys ( ) ;
450437 // Vector of all wallets to make it easier to select one randomly
451438 let all_wallets = vec ! [ keys_main. clone( ) , keys_0. clone( ) , keys_1. clone( ) ] ;
452439 // PRNG for selecting a random wallet
@@ -528,7 +515,7 @@ mod tests {
528515 allocation_ids : Vec < Address > ,
529516 ) {
530517 // The keys that will be used to sign the new RAVs
531- let keys_main = keys ( 0 ) ;
518+ let keys_main = keys ( ) ;
532519
533520 // Start the JSON-RPC server.
534521 let ( handle, local_addr) = server:: run_server (
@@ -611,7 +598,7 @@ mod tests {
611598 #[ values( "0.0" ) ] api_version : & str ,
612599 ) {
613600 // The keys that will be used to sign the new RAVs
614- let keys_main = keys ( 0 ) ;
601+ let keys_main = keys ( ) ;
615602
616603 // Set the request byte size limit to a value that easily triggers the HTTP 413
617604 // error.
0 commit comments