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 {
2222 Init ,
2323 /// Shows information about the Goki workspace.
2424 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+ } ,
2532 /// Requests an airdrop of SOL from the Solana network.
2633 Airdrop {
2734 /// Cluster to request from.
@@ -172,12 +179,15 @@ impl Opts {
172179 } => {
173180 subcommands:: airdrop:: process (
174181 & workspace,
175- cluster,
182+ & cluster,
176183 amount. as_str ( ) ,
177184 iterations,
178185 interval,
179186 ) ?;
180187 }
188+ SubCommand :: Balance { cluster } => {
189+ subcommands:: balance:: process ( & workspace, & cluster) ?;
190+ }
181191 SubCommand :: Transfer {
182192 cluster,
183193 from,
Original file line number Diff line number Diff line change @@ -6,22 +6,28 @@ use crate::workspace::Workspace;
66
77pub fn process (
88 workspace : & Workspace ,
9- cluster : Cluster ,
9+ cluster : & Cluster ,
1010 amount : & str ,
1111 iterations : u32 ,
1212 interval : u64 ,
1313) -> Result < ( ) > {
14- if cluster == Cluster :: Mainnet {
14+ if * cluster == Cluster :: Mainnet {
1515 return Err ( format_err ! ( "cannot request an airdrop from mainnet" ) ) ;
1616 }
1717
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" ) ?;
2320
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+ }
2531 }
2632
2733 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 11pub mod airdrop;
2+ pub mod balance;
23pub mod deploy;
34pub mod init;
45pub 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> {
8282 print_command ( command) ;
8383 let exit = exec_command_unhandled ( command) ?;
8484 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+ ) ) ;
8689 }
8790 Ok ( exit)
8891}
You can’t perform that action at this time.
0 commit comments