|
1 | | -use std::time::Duration; |
| 1 | +use std::{str::FromStr, time::Duration}; |
2 | 2 |
|
3 | 3 | use alloy::{ |
4 | 4 | network::EthereumWallet, |
@@ -43,11 +43,15 @@ pub struct ProofAggregator { |
43 | 43 | proof_aggregation_service: AlignedProofAggregationServiceContract, |
44 | 44 | } |
45 | 45 |
|
| 46 | +pub struct Config { |
| 47 | + pub rpc_url: String, |
| 48 | + pub private_key: String, |
| 49 | +} |
| 50 | + |
46 | 51 | impl ProofAggregator { |
47 | | - // TODO read .yaml config file |
48 | | - pub fn new(rpc_url: &str) -> Self { |
49 | | - let rpc_url = rpc_url.parse().expect("correct url"); |
50 | | - let signer = PrivateKeySigner::random(); |
| 52 | + pub fn new(config: Config) -> Self { |
| 53 | + let rpc_url = config.rpc_url.parse().expect("correct url"); |
| 54 | + let signer = PrivateKeySigner::from_str(&config.private_key).expect("valid string"); |
51 | 55 | let wallet = EthereumWallet::from(signer); |
52 | 56 | let provider = ProviderBuilder::new().wallet(wallet).on_http(rpc_url); |
53 | 57 | let proof_aggregation_service = |
@@ -127,8 +131,8 @@ impl ProofAggregator { |
127 | 131 | } |
128 | 132 | }; |
129 | 133 |
|
130 | | - let receipt = self.send_blob_transaction(leaves).await?; |
131 | | - self.send_proof_to_verify_on_chain(&receipt.transaction_hash.0, output.proof) |
| 134 | + let blob_tx_hash = self.send_blob_transaction(leaves).await?; |
| 135 | + self.send_proof_to_verify_on_chain(&blob_tx_hash, output.proof) |
132 | 136 | .await?; |
133 | 137 |
|
134 | 138 | Ok(()) |
@@ -166,8 +170,8 @@ impl ProofAggregator { |
166 | 170 | async fn send_blob_transaction( |
167 | 171 | &self, |
168 | 172 | leaves: Vec<[u8; 32]>, |
169 | | - ) -> Result<TransactionReceipt, AggregatedProofSubmissionError> { |
170 | | - Err(AggregatedProofSubmissionError::SendBlobTransaction) |
| 173 | + ) -> Result<[u8; 32], AggregatedProofSubmissionError> { |
| 174 | + Ok([0u8; 32]) |
171 | 175 | } |
172 | 176 |
|
173 | 177 | async fn set_aggregated_proof_as_missed(&self) {} |
|
0 commit comments