File tree Expand file tree Collapse file tree 5 files changed +44
-10
lines changed Expand file tree Collapse file tree 5 files changed +44
-10
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,13 @@ pub enum SubCommand {
22
22
Init ,
23
23
/// Shows information about the Goki workspace.
24
24
Show ,
25
+ /// Shows the balance of the deployer.
26
+ Balance {
27
+ /// Cluster.
28
+ #[ clap( short, long) ]
29
+ #[ clap( default_value = "devnet" ) ]
30
+ cluster : Cluster ,
31
+ } ,
25
32
/// Requests an airdrop of SOL from the Solana network.
26
33
Airdrop {
27
34
/// Cluster to request from.
@@ -172,12 +179,15 @@ impl Opts {
172
179
} => {
173
180
subcommands:: airdrop:: process (
174
181
& workspace,
175
- cluster,
182
+ & cluster,
176
183
amount. as_str ( ) ,
177
184
iterations,
178
185
interval,
179
186
) ?;
180
187
}
188
+ SubCommand :: Balance { cluster } => {
189
+ subcommands:: balance:: process ( & workspace, & cluster) ?;
190
+ }
181
191
SubCommand :: Transfer {
182
192
cluster,
183
193
from,
Original file line number Diff line number Diff line change @@ -6,22 +6,28 @@ use crate::workspace::Workspace;
6
6
7
7
pub fn process (
8
8
workspace : & Workspace ,
9
- cluster : Cluster ,
9
+ cluster : & Cluster ,
10
10
amount : & str ,
11
11
iterations : u32 ,
12
12
interval : u64 ,
13
13
) -> Result < ( ) > {
14
- if cluster == Cluster :: Mainnet {
14
+ if * cluster == Cluster :: Mainnet {
15
15
return Err ( format_err ! ( "cannot request an airdrop from mainnet" ) ) ;
16
16
}
17
17
18
- for _ in 0 ..iterations {
19
- workspace. exec_deployer_command ( & cluster, |cmd| {
20
- cmd. arg ( "airdrop" ) . arg ( amount) ;
21
- Ok ( ( ) )
22
- } ) ?;
18
+ let ctx = workspace. new_cluster_context ( cluster) ?;
19
+ let deployer = ctx. parse_wallet_alias ( "deployer" ) ?;
23
20
24
- thread:: sleep ( Duration :: from_millis ( interval) ) ;
21
+ for i in 0 ..iterations {
22
+ match ctx. exec_args ( & [ "airdrop" , amount] , & deployer) {
23
+ Ok ( _) => { }
24
+ Err ( err) => {
25
+ println ! ( "Error performing airdrop: {}" , err) ;
26
+ }
27
+ }
28
+ if i != iterations - 1 {
29
+ thread:: sleep ( Duration :: from_millis ( interval) ) ;
30
+ }
25
31
}
26
32
27
33
Ok ( ( ) )
Original file line number Diff line number Diff line change
1
+ use anchor_client:: Cluster ;
2
+ use anyhow:: Result ;
3
+
4
+ use crate :: workspace:: Workspace ;
5
+
6
+ pub fn process ( workspace : & Workspace , cluster : & Cluster ) -> Result < ( ) > {
7
+ let ctx = workspace. new_cluster_context ( cluster) ?;
8
+ let deployer = ctx. parse_wallet_alias ( "deployer" ) ?;
9
+
10
+ println ! ( "Deployer:" ) ;
11
+ ctx. exec_args ( & [ "account" , & deployer] , & deployer) ?;
12
+
13
+ Ok ( ( ) )
14
+ }
Original file line number Diff line number Diff line change 1
1
pub mod airdrop;
2
+ pub mod balance;
2
3
pub mod deploy;
3
4
pub mod init;
4
5
pub mod pull;
Original file line number Diff line number Diff line change @@ -82,7 +82,10 @@ pub fn exec_command(command: &mut Command) -> Result<Output> {
82
82
print_command ( command) ;
83
83
let exit = exec_command_unhandled ( command) ?;
84
84
if !exit. status . success ( ) {
85
- std:: process:: exit ( exit. status . code ( ) . unwrap_or ( 1 ) ) ;
85
+ return Err ( format_err ! (
86
+ "Command returned with exit code {}" ,
87
+ exit. status. code( ) . unwrap_or_default( )
88
+ ) ) ;
86
89
}
87
90
Ok ( exit)
88
91
}
You can’t perform that action at this time.
0 commit comments