1
- use near_workspaces:: types:: { AccountId , KeyType , NearToken , SecretKey } ;
1
+ use near_workspaces:: types:: { AccountId , NearToken } ;
2
2
use serde_json:: json;
3
3
4
+ const TEN_NEAR : NearToken = NearToken :: from_near ( 10 ) ;
5
+
4
6
#[ tokio:: test]
5
7
async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
6
8
let sandbox = near_workspaces:: sandbox ( ) . await ?;
7
- let contract_wasm = near_workspaces:: compile_project ( "./" ) . await ?;
8
- let contract = sandbox. dev_deploy ( & contract_wasm) . await ?;
9
+ let root = sandbox. root_account ( ) ?;
9
10
10
- let alice = sandbox
11
- . create_tla (
12
- "alice.test.near" . parse ( ) . unwrap ( ) ,
13
- SecretKey :: from_random ( KeyType :: ED25519 ) ,
14
- )
15
- . await ?
16
- . unwrap ( ) ;
11
+ // Create accounts
12
+ let alice = create_subaccount ( & root, "alice" ) . await ?;
13
+ let bob = create_subaccount ( & root, "bob" ) . await ?;
17
14
18
- let bob = sandbox. dev_create_account ( ) . await ?;
15
+ let contract_wasm = near_workspaces:: compile_project ( "./" ) . await ?;
16
+ let contract = sandbox. dev_deploy ( & contract_wasm) . await ?;
19
17
20
18
let res = contract
21
19
. call ( "create_factory_subaccount_and_deploy" )
@@ -50,3 +48,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
50
48
51
49
Ok ( ( ) )
52
50
}
51
+
52
+ async fn create_subaccount (
53
+ root : & near_workspaces:: Account ,
54
+ name : & str ,
55
+ ) -> Result < near_workspaces:: Account , Box < dyn std:: error:: Error > > {
56
+ let subaccount = root
57
+ . create_subaccount ( name)
58
+ . initial_balance ( TEN_NEAR )
59
+ . transact ( )
60
+ . await ?
61
+ . unwrap ( ) ;
62
+
63
+ Ok ( subaccount)
64
+ }
0 commit comments