1
- use crate :: helpers:: constants:: { ACCOUNT_FILE_PATH , CONTRACTS_DIR , DEVNET_ENV_FILE , URL } ;
1
+ use crate :: helpers:: constants:: {
2
+ ACCOUNT_FILE_PATH , CONTRACTS_DIR , DEVNET_ENV_FILE , DEVNET_OZ_CLASS_HASH , URL ,
3
+ } ;
2
4
use camino:: Utf8PathBuf ;
3
5
use primitive_types:: U256 ;
4
6
use serde:: de:: DeserializeOwned ;
5
7
use serde:: Deserialize ;
6
8
use serde_json:: { json, Map , Value } ;
7
- use sncast:: { apply_optional, get_keystore_password} ;
9
+ use sncast:: { apply_optional, get_chain_id , get_keystore_password} ;
8
10
use sncast:: { get_account, get_provider, parse_number} ;
9
- use starknet:: accounts:: { Account , Call , Execution } ;
11
+ use starknet:: accounts:: { Account , AccountFactory , Call , Execution , OpenZeppelinAccountFactory } ;
10
12
use starknet:: contract:: ContractFactory ;
11
13
use starknet:: core:: types:: contract:: { CompiledClass , SierraClass } ;
12
14
use starknet:: core:: types:: TransactionReceipt ;
@@ -15,7 +17,7 @@ use starknet::core::utils::get_contract_address;
15
17
use starknet:: core:: utils:: get_selector_from_name;
16
18
use starknet:: providers:: jsonrpc:: HttpTransport ;
17
19
use starknet:: providers:: JsonRpcClient ;
18
- use starknet:: signers:: SigningKey ;
20
+ use starknet:: signers:: { LocalWallet , SigningKey } ;
19
21
use std:: env;
20
22
use std:: fs;
21
23
use std:: fs:: OpenOptions ;
@@ -69,6 +71,46 @@ pub async fn declare_contract(account: &str, path: &str, shortname: &str) -> Fie
69
71
class_hash
70
72
}
71
73
74
+ pub async fn deploy_keystore_account ( ) {
75
+ let keystore_path = "tests/data/keystore/predeployed_key.json" ;
76
+ let account_path = "tests/data/keystore/predeployed_account.json" ;
77
+ let private_key =
78
+ SigningKey :: from_keystore ( keystore_path, "123" ) . expect ( "Could not get the private_key" ) ;
79
+
80
+ let provider = get_provider ( URL ) . expect ( "Could not get the provider" ) ;
81
+ let chain_id = get_chain_id ( & provider)
82
+ . await
83
+ . expect ( "Could not get chain_id from provider" ) ;
84
+
85
+ let contents =
86
+ std:: fs:: read_to_string ( account_path) . expect ( "Failed to read keystore account file" ) ;
87
+ let items: serde_json:: Value = serde_json:: from_str ( & contents)
88
+ . unwrap_or_else ( |_| panic ! ( "Failed to parse keystore account file at = {account_path}" ) ) ;
89
+
90
+ let factory = OpenZeppelinAccountFactory :: new (
91
+ parse_number ( DEVNET_OZ_CLASS_HASH ) . expect ( "Could not parse DEVNET_OZ_CLASS_HASH" ) ,
92
+ chain_id,
93
+ LocalWallet :: from_signing_key ( private_key) ,
94
+ provider,
95
+ )
96
+ . await
97
+ . expect ( "Could not create Account Factory" ) ;
98
+
99
+ mint_token (
100
+ items[ "deployment" ] [ "address" ]
101
+ . as_str ( )
102
+ . expect ( "Could not get address" ) ,
103
+ 9_999_999_999_999_999_999 ,
104
+ )
105
+ . await ;
106
+
107
+ factory
108
+ . deploy ( parse_number ( "0xa5d90c65b1b1339" ) . expect ( "Could not parse salt" ) )
109
+ . send ( )
110
+ . await
111
+ . expect ( "Could not deploy keystore account" ) ;
112
+ }
113
+
72
114
pub async fn declare_deploy_contract ( account : & str , path : & str , shortname : & str ) {
73
115
let class_hash = declare_contract ( account, path, shortname) . await ;
74
116
0 commit comments