Skip to content

Commit 63b5eac

Browse files
committed
feat: proof agg service contract
1 parent 2586e4d commit 63b5eac

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use std::sync::Arc;
2+
3+
use ethers::prelude::*;
4+
5+
use crate::core::errors::VerificationError;
6+
7+
abigen!(
8+
ProofAggregationServiceContract,
9+
"abi/AlignedProofAggregationService.json"
10+
);
11+
12+
pub type AlignedProofAggregationService = ProofAggregationServiceContract<Provider<Http>>;
13+
14+
pub async fn aligned_proof_aggregation_service(
15+
provider: Provider<Http>,
16+
contract_address: H160,
17+
) -> Result<AlignedProofAggregationService, VerificationError> {
18+
let client = Arc::new(provider);
19+
20+
// Verify that the contract has code at the given address
21+
let code = client
22+
.get_code(contract_address, None)
23+
.await
24+
.map_err(|e| VerificationError::EthereumProviderError(e.to_string()))?;
25+
if code.is_empty() {
26+
return Err(VerificationError::EthereumNotAContract(contract_address));
27+
}
28+
29+
Ok(AlignedProofAggregationService::new(
30+
contract_address,
31+
client,
32+
))
33+
}

0 commit comments

Comments
 (0)