1+ use std:: env;
12use std:: fs:: File ;
23use std:: io:: Write ;
34use std:: path:: PathBuf ;
@@ -6,7 +7,7 @@ use std::str::FromStr;
67use aligned_sdk:: core:: errors:: SubmitError ;
78use aligned_sdk:: core:: types:: Chain :: Holesky ;
89use aligned_sdk:: core:: types:: { AlignedVerificationData , ProvingSystemId , VerificationData } ;
9- use aligned_sdk:: sdk:: { get_next_nonce, submit_and_wait } ;
10+ use aligned_sdk:: sdk:: { get_next_nonce, submit_and_wait_verification } ;
1011use env_logger:: Env ;
1112use ethers:: signers:: { LocalWallet , Signer } ;
1213use ethers:: types:: Address ;
@@ -49,14 +50,17 @@ async fn main() -> Result<(), SubmitError> {
4950 proof_generator_addr,
5051 } ;
5152
52- let wallet = LocalWallet :: from_str ( WALLET_PRIVATE_KEY ) . expect ( "Failed to create wallet" ) ;
53+ // Create a wallet and set chain id to holesky
54+ let wallet = LocalWallet :: from_str ( WALLET_PRIVATE_KEY )
55+ . expect ( "Failed to create wallet" )
56+ . with_chain_id ( 17000u64 ) ;
5357
5458 let nonce = get_next_nonce ( RPC_URL , wallet. address ( ) , BATCHER_PAYMENTS_ADDRESS )
5559 . await
5660 . expect ( "Failed to get next nonce" ) ;
5761
5862 info ! ( "Submitting Fibonacci proof to Aligned and waiting for verification..." ) ;
59- let aligned_verification_data = submit_and_wait (
63+ let aligned_verification_data = submit_and_wait_verification (
6064 BATCHER_URL ,
6165 RPC_URL ,
6266 Holesky ,
@@ -66,20 +70,24 @@ async fn main() -> Result<(), SubmitError> {
6670 )
6771 . await ?;
6872
69- let batch_inclusion_data_directory_path = PathBuf :: from ( "./ batch_inclusion_data" ) ;
73+ let batch_inclusion_data_directory_path = PathBuf :: from ( "batch_inclusion_data" ) ;
7074
7175 info ! (
7276 "Saving verification data to {:?}" ,
7377 batch_inclusion_data_directory_path
7478 ) ;
75- if let Some ( aligned_verification_data) = aligned_verification_data {
76- save_response (
77- batch_inclusion_data_directory_path,
78- & aligned_verification_data,
79- ) ?;
80- } else {
81- return Err ( SubmitError :: EmptyVerificationDataList ) ;
82- }
79+
80+ info ! ( "Proof submitted to aligned. See the batch in the explorer:" ) ;
81+
82+ info ! (
83+ "https://explorer.alignedlayer.com/batches/0x{}" ,
84+ hex:: encode( aligned_verification_data. batch_merkle_root)
85+ ) ;
86+
87+ save_response (
88+ batch_inclusion_data_directory_path,
89+ & aligned_verification_data,
90+ ) ?;
8391
8492 Ok ( ( ) )
8593}
@@ -104,13 +112,19 @@ fn save_response(
104112 let batch_inclusion_data_path =
105113 batch_inclusion_data_directory_path. join ( batch_inclusion_data_file_name) ;
106114
107- let data = serde_json:: to_vec ( & aligned_verification_data) ? ;
115+ let data = serde_json:: to_vec ( & aligned_verification_data) . unwrap ( ) ;
108116
109117 let mut file = File :: create ( & batch_inclusion_data_path)
110118 . map_err ( |e| SubmitError :: IoError ( batch_inclusion_data_path. clone ( ) , e) ) ?;
111-
112119 file. write_all ( data. as_slice ( ) )
113120 . map_err ( |e| SubmitError :: IoError ( batch_inclusion_data_path. clone ( ) , e) ) ?;
114121
122+ let current_dir = env:: current_dir ( ) . expect ( "Failed to get current directory" ) ;
123+
124+ info ! (
125+ "Saved batch inclusion data to {:?}" ,
126+ current_dir. join( batch_inclusion_data_path)
127+ ) ;
128+
115129 Ok ( ( ) )
116130}
0 commit comments