@@ -4,21 +4,17 @@ use std::io;
44use std:: str:: FromStr ;
55use std:: sync:: Arc ;
66
7- use aligned_sdk:: sdk :: { submit , verify_proof_onchain } ;
8- use aligned_sdk:: types :: { AlignedVerificationData , Chain , ProvingSystemId , VerificationData } ;
7+ use aligned_sdk:: core :: types :: { AlignedVerificationData , Chain , ProvingSystemId , VerificationData } ;
8+ use aligned_sdk:: sdk :: submit_and_wait ;
99use clap:: Parser ;
1010use dialoguer:: Confirm ;
11- use ethers:: core:: k256:: ecdsa:: SigningKey ;
1211use ethers:: prelude:: * ;
1312use ethers:: providers:: { Http , Provider } ;
1413use ethers:: signers:: { LocalWallet , Signer } ;
1514use ethers:: types:: { Address , Bytes , H160 , U256 } ;
1615use sp1_sdk:: { ProverClient , SP1Stdin } ;
1716
18- abigen ! (
19- VerifierContract ,
20- "VerifierContract.json" ,
21- ) ;
17+ abigen ! ( VerifierContract , "VerifierContract.json" , ) ;
2218
2319const BATCHER_URL : & str = "wss://batcher.alignedlayer.com" ;
2420const BATCHER_PAYMENTS_ADDRESS : & str = "0x815aeCA64a974297942D2Bbf034ABEe22a38A003" ;
@@ -112,24 +108,36 @@ async fn main() {
112108 pub_input : None ,
113109 } ;
114110
115- match submit_proof_and_wait_for_verification (
116- verification_data,
111+ match submit_and_wait (
112+ BATCHER_URL ,
113+ & rpc_url,
114+ Chain :: Holesky ,
115+ & verification_data,
117116 wallet. clone ( ) ,
118- rpc_url. clone ( ) ,
119- ) . await {
120- Ok ( aligned_verification_data) => {
121- println ! ( "Proof verified in Aligned, claiming prize..." ) ;
122-
123- if let Err ( e) = verify_batch_inclusion (
124- aligned_verification_data. clone ( ) ,
125- signer. clone ( ) ,
126- args. verifier_contract_address ,
127- )
117+ )
118+ . await
119+ {
120+ Ok ( maybe_aligned_verification_data) => match maybe_aligned_verification_data {
121+ Some ( aligned_verification_data) => {
122+ println ! (
123+ "Proof submitted and verified successfully on batch {}, claiming prize..." ,
124+ hex:: encode( aligned_verification_data. batch_merkle_root)
125+ ) ;
126+
127+ if let Err ( e) = verify_batch_inclusion (
128+ aligned_verification_data. clone ( ) ,
129+ signer. clone ( ) ,
130+ args. verifier_contract_address ,
131+ )
128132 . await
129- {
130- println ! ( "Failed to claim prize: {:?}" , e) ;
133+ {
134+ println ! ( "Failed to claim prize: {:?}" , e) ;
135+ }
131136 }
132- }
137+ None => {
138+ println ! ( "Proof submission failed. No verification data" ) ;
139+ }
140+ } ,
133141 Err ( e) => {
134142 println ! ( "Proof verification failed: {:?}" , e) ;
135143 }
@@ -178,46 +186,6 @@ fn read_answer() -> char {
178186 }
179187}
180188
181- async fn submit_proof_and_wait_for_verification (
182- verification_data : VerificationData ,
183- wallet : Wallet < SigningKey > ,
184- rpc_url : String ,
185- ) -> anyhow:: Result < AlignedVerificationData > {
186- let res = submit ( BATCHER_URL , & verification_data, wallet. clone ( ) )
187- . await
188- . map_err ( |e| anyhow:: anyhow!( "Failed to submit proof for verification: {:?}" , e) ) ?;
189-
190- match res {
191- Some ( aligned_verification_data) => {
192- println ! (
193- "Proof submitted successfully on batch {}, waiting for verification..." ,
194- hex:: encode( aligned_verification_data. batch_merkle_root)
195- ) ;
196-
197- for _ in 0 ..10 {
198- if verify_proof_onchain (
199- aligned_verification_data. clone ( ) ,
200- Chain :: Holesky ,
201- rpc_url. as_str ( ) ,
202- )
203- . await
204- . is_ok_and ( |r| r)
205- {
206- return Ok ( aligned_verification_data) ;
207- }
208-
209- println ! ( "Proof not verified yet. Waiting 10 seconds before checking again..." ) ;
210- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 10 ) ) . await ;
211- }
212-
213- anyhow:: bail!( "Proof verification failed" ) ;
214- }
215- None => {
216- anyhow:: bail!( "Proof submission failed, no verification data" ) ;
217- }
218- }
219- }
220-
221189async fn pay_batcher (
222190 from : Address ,
223191 signer : Arc < SignerMiddleware < Provider < Http > , LocalWallet > > ,
0 commit comments