@@ -474,6 +474,14 @@ fn resolve_mint_info(
474
474
}
475
475
}
476
476
477
+ fn validate_mint ( config : & Config , token : Pubkey ) -> Result < ( ) , Error > {
478
+ let mint = config. rpc_client . get_account ( & token) ;
479
+ if mint. is_err ( ) || Mint :: unpack ( & mint. unwrap ( ) . data ) . is_err ( ) {
480
+ return Err ( format ! ( "Invalid mint account {:?}" , token) . into ( ) ) ;
481
+ }
482
+ Ok ( ( ) )
483
+ }
484
+
477
485
#[ allow( clippy:: too_many_arguments) ]
478
486
fn command_transfer (
479
487
config : & Config ,
@@ -884,6 +892,9 @@ fn command_supply(config: &Config, address: Pubkey) -> CommandResult {
884
892
}
885
893
886
894
fn command_accounts ( config : & Config , token : Option < Pubkey > ) -> CommandResult {
895
+ if let Some ( token) = token {
896
+ validate_mint ( config, token) ?;
897
+ }
887
898
let accounts = config. rpc_client . get_token_accounts_by_owner (
888
899
& config. owner ,
889
900
match token {
@@ -1006,10 +1017,7 @@ fn command_accounts(config: &Config, token: Option<Pubkey>) -> CommandResult {
1006
1017
1007
1018
fn command_address ( config : & Config , token : Option < Pubkey > ) -> CommandResult {
1008
1019
if let Some ( token) = token {
1009
- let mint = config. rpc_client . get_account ( & token) ;
1010
- if mint. is_err ( ) || Mint :: unpack ( & mint. unwrap ( ) . data ) . is_err ( ) {
1011
- return Err ( format ! ( "Invalid mint account {:?}" , token) . into ( ) ) ;
1012
- }
1020
+ validate_mint ( config, token) ?;
1013
1021
let associated_token_address = get_associated_token_address ( & config. owner , & token) ;
1014
1022
println ! ( "Wallet address: {:?}" , config. owner) ;
1015
1023
println ! ( "Associated token address: {:?}" , associated_token_address) ;
0 commit comments