@@ -40,6 +40,7 @@ use futures_util::{
4040/// * `verification_data` - An array of verification data of each proof.
4141/// * `wallet` - The wallet used to sign the proof.
4242/// * `nonce` - The nonce of the submitter address. See `get_next_nonce`.
43+ /// * `payment_service_addr` - The address of the payment service contract.
4344/// # Returns
4445/// * An array of aligned verification data obtained when submitting the proof.
4546/// # Errors
@@ -66,13 +67,19 @@ pub async fn submit_multiple_and_wait_verification(
6667 verification_data : & [ VerificationData ] ,
6768 wallet : Wallet < SigningKey > ,
6869 nonce : U256 ,
70+ payment_service_addr : & str ,
6971) -> Result < Vec < AlignedVerificationData > , errors:: SubmitError > {
7072 let aligned_verification_data =
7173 submit_multiple ( batcher_url, verification_data, wallet, nonce) . await ?;
7274
7375 for aligned_verification_data_item in aligned_verification_data. iter ( ) {
74- await_batch_verification ( aligned_verification_data_item, eth_rpc_url, chain. clone ( ) )
75- . await ?;
76+ await_batch_verification (
77+ aligned_verification_data_item,
78+ eth_rpc_url,
79+ chain. clone ( ) ,
80+ payment_service_addr,
81+ )
82+ . await ?;
7683 }
7784
7885 Ok ( aligned_verification_data)
@@ -182,6 +189,7 @@ async fn _submit_multiple(
182189/// * `verification_data` - The verification data of the proof.
183190/// * `wallet` - The wallet used to sign the proof.
184191/// * `nonce` - The nonce of the submitter address. See `get_next_nonce`.
192+ /// * `payment_service_addr` - The address of the payment service contract.
185193/// # Returns
186194/// * The aligned verification data obtained when submitting the proof.
187195/// # Errors
@@ -208,6 +216,7 @@ pub async fn submit_and_wait_verification(
208216 verification_data : & VerificationData ,
209217 wallet : Wallet < SigningKey > ,
210218 nonce : U256 ,
219+ payment_service_addr : & str ,
211220) -> Result < AlignedVerificationData , errors:: SubmitError > {
212221 let verification_data = vec ! [ verification_data. clone( ) ] ;
213222
@@ -218,6 +227,7 @@ pub async fn submit_and_wait_verification(
218227 & verification_data,
219228 wallet,
220229 nonce,
230+ payment_service_addr,
221231 )
222232 . await ?;
223233
@@ -265,6 +275,7 @@ pub async fn submit(
265275/// * `aligned_verification_data` - The aligned verification data obtained when submitting the proofs.
266276/// * `chain` - The chain on which the verification will be done.
267277/// * `eth_rpc_url` - The URL of the Ethereum RPC node.
278+ /// * `payment_service_addr` - The address of the payment service.
268279/// # Returns
269280/// * A boolean indicating whether the proof was verified on-chain and is included in the batch.
270281/// # Errors
@@ -275,25 +286,38 @@ pub async fn is_proof_verified(
275286 aligned_verification_data : & AlignedVerificationData ,
276287 chain : Chain ,
277288 eth_rpc_url : & str ,
289+ payment_service_addr : & str ,
278290) -> Result < bool , errors:: VerificationError > {
279291 let eth_rpc_provider =
280292 Provider :: < Http > :: try_from ( eth_rpc_url) . map_err ( |e : url:: ParseError | {
281293 errors:: VerificationError :: EthereumProviderError ( e. to_string ( ) )
282294 } ) ?;
283- _is_proof_verified ( aligned_verification_data, chain, eth_rpc_provider) . await
295+
296+ _is_proof_verified (
297+ aligned_verification_data,
298+ chain,
299+ eth_rpc_provider,
300+ payment_service_addr,
301+ )
302+ . await
284303}
285304
286305async fn _is_proof_verified (
287306 aligned_verification_data : & AlignedVerificationData ,
288307 chain : Chain ,
289308 eth_rpc_provider : Provider < Http > ,
309+ payment_service_addr : & str ,
290310) -> Result < bool , errors:: VerificationError > {
291311 let contract_address = match chain {
292312 Chain :: Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8" ,
293313 Chain :: Holesky => "0x58F280BeBE9B34c9939C3C39e0890C81f163B623" ,
294314 Chain :: HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B" ,
295315 } ;
296316
317+ let payment_service_addr = payment_service_addr
318+ . parse :: < Address > ( )
319+ . map_err ( |e| errors:: VerificationError :: HexDecodingError ( e. to_string ( ) ) ) ?;
320+
297321 // All the elements from the merkle proof have to be concatenated
298322 let merkle_proof: Vec < u8 > = aligned_verification_data
299323 . batch_inclusion_proof
@@ -317,6 +341,7 @@ async fn _is_proof_verified(
317341 aligned_verification_data. batch_merkle_root ,
318342 merkle_proof. into ( ) ,
319343 aligned_verification_data. index_in_batch . into ( ) ,
344+ payment_service_addr,
320345 ) ;
321346
322347 let result = call
@@ -405,6 +430,8 @@ mod test {
405430
406431 use ethers:: signers:: LocalWallet ;
407432
433+ const BATCHER_PAYMENT_SERVICE_ADDR : & str = "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0" ;
434+
408435 #[ tokio:: test]
409436 async fn test_submit_success ( ) {
410437 let base_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
@@ -438,6 +465,7 @@ mod test {
438465 & verification_data,
439466 wallet,
440467 U256 :: zero ( ) ,
468+ BATCHER_PAYMENT_SERVICE_ADDR ,
441469 )
442470 . await
443471 . unwrap ( ) ;
@@ -471,6 +499,7 @@ mod test {
471499 & verification_data,
472500 wallet,
473501 U256 :: zero ( ) ,
502+ BATCHER_PAYMENT_SERVICE_ADDR ,
474503 )
475504 . await ;
476505
@@ -512,6 +541,7 @@ mod test {
512541 & verification_data,
513542 wallet,
514543 U256 :: zero ( ) ,
544+ BATCHER_PAYMENT_SERVICE_ADDR ,
515545 )
516546 . await
517547 . unwrap ( ) ;
@@ -522,6 +552,7 @@ mod test {
522552 & aligned_verification_data[ 0 ] ,
523553 Chain :: Devnet ,
524554 "http://localhost:8545" ,
555+ BATCHER_PAYMENT_SERVICE_ADDR ,
525556 )
526557 . await
527558 . unwrap ( ) ;
@@ -562,6 +593,7 @@ mod test {
562593 & verification_data,
563594 wallet,
564595 U256 :: zero ( ) ,
596+ BATCHER_PAYMENT_SERVICE_ADDR ,
565597 )
566598 . await
567599 . unwrap ( ) ;
@@ -577,6 +609,7 @@ mod test {
577609 & aligned_verification_data_modified,
578610 Chain :: Devnet ,
579611 "http://localhost:8545" ,
612+ BATCHER_PAYMENT_SERVICE_ADDR ,
580613 )
581614 . await
582615 . unwrap ( ) ;
0 commit comments