@@ -12,8 +12,7 @@ async fn main() -> Result<()> {
1212 let mut rng = thread_rng ( ) ;
1313
1414 // Private key of Alice, the first default Anvil account.
15- let private_key =
16- hex:: decode ( "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" ) ?;
15+ let private_key = hex ! ( "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" ) ;
1716
1817 // Password to encrypt the keystore file with.
1918 let password = "test" ;
@@ -22,26 +21,26 @@ async fn main() -> Result<()> {
2221 let ( wallet, file_path) =
2322 Wallet :: encrypt_keystore ( & dir, & mut rng, private_key, password, None ) . unwrap ( ) ;
2423
25- let key_file_path = dir. path ( ) . join ( file_path. clone ( ) ) ;
24+ let keystore_file_path = dir. path ( ) . join ( file_path. clone ( ) ) ;
2625
27- println ! ( "Wrote keystore for {:?} to {:?}" , wallet. address( ) , key_file_path ) ;
26+ println ! ( "Wrote keystore for {:?} to {:?}" , wallet. address( ) , keystore_file_path ) ;
2827
2928 // Read the keystore file back.
30- let recovered_wallet = Wallet :: decrypt_keystore ( key_file_path . clone ( ) , password) ?;
29+ let recovered_wallet = Wallet :: decrypt_keystore ( keystore_file_path . clone ( ) , password) ?;
3130
3231 println ! (
3332 "Read keystore from {:?}, recovered address: {:?}" ,
34- key_file_path ,
33+ keystore_file_path ,
3534 recovered_wallet. address( )
3635 ) ;
3736
3837 // Assert that the address of the original key and the recovered key are the same.
3938 assert_eq ! ( wallet. address( ) , recovered_wallet. address( ) ) ;
4039
4140 // Display the contents of the keystore file.
42- let keystore_contents = read_to_string ( key_file_path ) ?;
41+ let keystore_contents = read_to_string ( keystore_file_path ) ?;
4342
44- print ! ( "Keystore file contents: {:?}\n " , keystore_contents) ;
43+ println ! ( "Keystore file contents: {:?}" , keystore_contents) ;
4544
4645 Ok ( ( ) )
4746}
0 commit comments