@@ -10,39 +10,48 @@ use alloy::providers::fillers::JoinFill;
10
10
use alloy:: providers:: fillers:: NonceFiller ;
11
11
use alloy:: providers:: fillers:: WalletFiller ;
12
12
use alloy:: providers:: { Provider , ProviderBuilder , RootProvider } ;
13
- use alloy:: signers:: Signer as _ ;
14
- use alloy_network :: Ethereum ;
13
+ use alloy:: signers:: local :: PrivateKeySigner ;
14
+ // use alloy::signers::Signer as _ ;
15
15
use alloy_network:: EthereumWallet ;
16
16
use alloy_primitives:: Address ;
17
- use alloy_transport :: BoxTransport ;
17
+ use alloy_provider :: fillers :: BlobGasFiller ;
18
18
use alloy_transport_ws:: WsConnect ;
19
19
use anyhow:: Context ;
20
20
use clap:: Parser ;
21
- use secure_signer:: cryptography:: secp256k1:: Secp256k1 ;
21
+ // use secure_signer::cryptography::secp256k1::Secp256k1;
22
22
use secure_signer:: key:: TryFromCanonicalString ;
23
- use secure_signer_eth:: Signer ;
24
- use secure_signer_loader:: { identifiers:: SignerIdentifier , Load } ;
23
+ // use secure_signer_eth::Signer;
24
+ use secure_signer_loader:: { identifiers:: SignerIdentifier /* Load*/ } ;
25
25
use serde:: { Deserialize , Serialize } ;
26
- use tracing:: info;
26
+ // use tracing::info;
27
27
28
28
#[ derive( Parser , Debug , Serialize , Deserialize , Clone ) ]
29
+ #[ clap( help_expected = true ) ]
29
30
pub struct Config {
30
31
/// The address of the MCR settlement contract.
32
+ #[ arg( long) ]
31
33
pub mcr_contract_address : String ,
32
34
/// The Ethereum RPC connection URL.
35
+ #[ arg( long) ]
33
36
pub rpc_url : String ,
34
37
/// The Ethereum WebSocket connection URL.
38
+ #[ arg( long) ]
35
39
pub ws_url : String ,
36
40
/// The Ethereum chain ID.
41
+ #[ arg( long) ]
37
42
pub chain_id : u64 ,
38
43
/// The signer identifier.
39
44
#[ arg( value_parser = SignerIdentifier :: try_from_canonical_string) ]
45
+ #[ arg( long) ]
40
46
pub signer_identifier : SignerIdentifier ,
41
47
/// Whether to run in settlement admin mode.
48
+ #[ arg( long) ]
42
49
pub run_commitment_admin_mode : bool ,
43
50
/// The gas limit for transactions.
51
+ #[ arg( long) ]
44
52
pub gas_limit : u64 ,
45
53
/// The number of retries for sending transactions.
54
+ #[ arg( long) ]
46
55
pub transaction_send_retries : u32 ,
47
56
}
48
57
@@ -78,42 +87,66 @@ impl Config {
78
87
FillProvider <
79
88
JoinFill <
80
89
JoinFill <
81
- JoinFill < JoinFill < alloy:: providers:: Identity , GasFiller > , NonceFiller > ,
82
- ChainIdFiller ,
90
+ alloy:: providers:: Identity ,
91
+ JoinFill <
92
+ GasFiller ,
93
+ JoinFill < BlobGasFiller , JoinFill < NonceFiller , ChainIdFiller > > ,
94
+ > ,
83
95
> ,
84
96
WalletFiller < EthereumWallet > ,
85
97
> ,
86
- RootProvider < BoxTransport > ,
87
- BoxTransport ,
88
- Ethereum ,
98
+ RootProvider ,
99
+ > ,
100
+ FillProvider <
101
+ JoinFill <
102
+ alloy:: providers:: Identity ,
103
+ JoinFill <
104
+ GasFiller ,
105
+ JoinFill < BlobGasFiller , JoinFill < NonceFiller , ChainIdFiller > > ,
106
+ > ,
107
+ > ,
108
+ RootProvider ,
89
109
> ,
90
110
> ,
91
111
anyhow:: Error ,
92
112
> {
93
- let signer_identifier: Box < dyn Load < Secp256k1 > + Send > =
113
+ let raw_key = self . signer_identifier . try_raw_private_key ( ) . context ( "failed to get the raw private key from the signer identifier; only local signers are currently supported" ) ?;
114
+ // add the 0x
115
+ let raw_key_string = format ! ( "0x{}" , hex:: encode( raw_key) ) ;
116
+ let private_key_signer: PrivateKeySigner = raw_key_string. parse ( ) ?;
117
+ let signer_address = private_key_signer. address ( ) ;
118
+
119
+ /*let signer_identifier: Box<dyn Load<Secp256k1> + Send> =
94
120
Box::new(self.signer_identifier.clone());
95
121
let signer_provider = signer_identifier.load().await?;
96
- let signer = Signer :: try_new ( signer_provider, Some ( self . chain_id ) ) . await ?;
122
+
123
+ let signer = Signer::try_new(signer_provider, Some(self.chain_id)).await?;*
97
124
98
125
let signer_address = signer.address();
99
- info ! ( "Signer address: {}" , signer_address) ;
126
+ info!("Signer address: {}", signer_address);*/
100
127
let contract_address = self
101
128
. mcr_contract_address
102
129
. parse ( )
103
- . context ( "Failed to parse the contract address for the MCR settlement client" ) ?;
130
+ . context ( "failed to parse the contract address for the MCR settlement client" ) ?;
104
131
105
132
// Build the rpc provider
106
133
let rpc_provider = ProviderBuilder :: new ( )
107
- . with_recommended_fillers ( )
108
- . wallet ( EthereumWallet :: from ( signer) )
109
- . on_builtin ( & self . rpc_url )
134
+ . wallet ( EthereumWallet :: from ( private_key_signer) )
135
+ . connect ( & self . rpc_url )
136
+ . await
137
+ . context ( "failed to create the RPC provider for the MCR settlement client" ) ?;
138
+
139
+ // Build the ws provider
140
+ let ws = WsConnect :: new ( self . ws_url ) ;
141
+ let ws_provider = ProviderBuilder :: new ( )
142
+ . on_ws ( ws)
110
143
. await
111
- . context ( "Failed to create the RPC provider for the MCR settlement client" ) ?;
144
+ . context ( "failed to create the WebSocket provider for the MCR settlement client" ) ?;
112
145
113
146
let client = Self :: build_with_provider (
114
147
self . run_commitment_admin_mode ,
115
148
rpc_provider,
116
- self . ws_url ,
149
+ ws_provider ,
117
150
signer_address,
118
151
contract_address,
119
152
self . gas_limit ,
@@ -127,26 +160,19 @@ impl Config {
127
160
}
128
161
129
162
// Helper to build the MCR client with a custom provider.
130
- async fn build_with_provider < S , P > (
163
+ async fn build_with_provider < R , W > (
131
164
run_commitment_admin_mode : bool ,
132
- rpc_provider : P ,
133
- ws_url : S ,
165
+ rpc_provider : R ,
166
+ ws_provider : W ,
134
167
signer_address : Address ,
135
168
contract_address : Address ,
136
169
gas_limit : u64 ,
137
170
send_transaction_retries : u32 ,
138
- ) -> Result < Client < P > , anyhow:: Error >
171
+ ) -> Result < Client < R , W > , anyhow:: Error >
139
172
where
140
- P : Provider + Clone ,
141
- S : Into < String > ,
173
+ R : Provider + Clone ,
174
+ W : Provider + Clone ,
142
175
{
143
- let ws = WsConnect :: new ( ws_url) ;
144
-
145
- let ws_provider = ProviderBuilder :: new ( )
146
- . on_ws ( ws)
147
- . await
148
- . context ( "Failed to create the WebSocket provider for the MCR settlement client" ) ?;
149
-
150
176
let rule1: Box < dyn VerifyRule > = Box :: new ( SendTransactionErrorRule :: < UnderPriced > :: new ( ) ) ;
151
177
let rule2: Box < dyn VerifyRule > =
152
178
Box :: new ( SendTransactionErrorRule :: < InsufficentFunds > :: new ( ) ) ;
0 commit comments