@@ -8,8 +8,8 @@ use solana_account_decoder::{
8
8
UiAccountData ,
9
9
} ;
10
10
use solana_clap_utils:: {
11
- input_parsers:: pubkey_of ,
12
- input_validators:: { is_amount, is_keypair , is_pubkey_or_keypair , is_url } ,
11
+ input_parsers:: pubkey_of_signer ,
12
+ input_validators:: { is_amount, is_url , is_valid_pubkey , is_valid_signer } ,
13
13
keypair:: signer_from_path,
14
14
} ;
15
15
use solana_cli_output:: display:: println_name_value;
@@ -739,7 +739,7 @@ fn main() {
739
739
Arg :: with_name ( "owner" )
740
740
. long ( "owner" )
741
741
. value_name ( "KEYPAIR" )
742
- . validator ( is_keypair )
742
+ . validator ( is_valid_signer )
743
743
. takes_value ( true )
744
744
. global ( true )
745
745
. help (
@@ -752,7 +752,7 @@ fn main() {
752
752
Arg :: with_name ( "fee_payer" )
753
753
. long ( "fee-payer" )
754
754
. value_name ( "KEYPAIR" )
755
- . validator ( is_keypair )
755
+ . validator ( is_valid_signer )
756
756
. takes_value ( true )
757
757
. global ( true )
758
758
. help (
@@ -777,7 +777,7 @@ fn main() {
777
777
. arg (
778
778
Arg :: with_name ( "token_keypair" )
779
779
. value_name ( "KEYPAIR" )
780
- . validator ( is_keypair )
780
+ . validator ( is_valid_signer )
781
781
. takes_value ( true )
782
782
. index ( 1 )
783
783
. help (
@@ -800,7 +800,7 @@ fn main() {
800
800
. about ( "Create a new token account" )
801
801
. arg (
802
802
Arg :: with_name ( "token" )
803
- . validator ( is_pubkey_or_keypair )
803
+ . validator ( is_valid_pubkey )
804
804
. value_name ( "TOKEN_ADDRESS" )
805
805
. takes_value ( true )
806
806
. index ( 1 )
@@ -810,7 +810,7 @@ fn main() {
810
810
. arg (
811
811
Arg :: with_name ( "account_keypair" )
812
812
. value_name ( "KEYPAIR" )
813
- . validator ( is_keypair )
813
+ . validator ( is_valid_signer )
814
814
. takes_value ( true )
815
815
. index ( 2 )
816
816
. help (
@@ -825,7 +825,7 @@ fn main() {
825
825
. about ( "Authorize a new signing keypair to a token or token account" )
826
826
. arg (
827
827
Arg :: with_name ( "address" )
828
- . validator ( is_pubkey_or_keypair )
828
+ . validator ( is_valid_pubkey )
829
829
. value_name ( "TOKEN_ADDRESS" )
830
830
. takes_value ( true )
831
831
. index ( 1 )
@@ -845,7 +845,7 @@ fn main() {
845
845
)
846
846
. arg (
847
847
Arg :: with_name ( "new_authority" )
848
- . validator ( is_pubkey_or_keypair )
848
+ . validator ( is_valid_pubkey )
849
849
. value_name ( "AUTHORITY_ADDRESS" )
850
850
. takes_value ( true )
851
851
. index ( 3 )
@@ -865,7 +865,7 @@ fn main() {
865
865
. about ( "Transfer tokens between accounts" )
866
866
. arg (
867
867
Arg :: with_name ( "sender" )
868
- . validator ( is_pubkey_or_keypair )
868
+ . validator ( is_valid_pubkey )
869
869
. value_name ( "SENDER_TOKEN_ACCOUNT_ADDRESS" )
870
870
. takes_value ( true )
871
871
. index ( 1 )
@@ -883,7 +883,7 @@ fn main() {
883
883
)
884
884
. arg (
885
885
Arg :: with_name ( "recipient" )
886
- . validator ( is_pubkey_or_keypair )
886
+ . validator ( is_valid_pubkey )
887
887
. value_name ( "RECIPIENT_TOKEN_ACCOUNT_ADDRESS" )
888
888
. takes_value ( true )
889
889
. index ( 3 )
@@ -896,7 +896,7 @@ fn main() {
896
896
. about ( "Burn tokens from an account" )
897
897
. arg (
898
898
Arg :: with_name ( "source" )
899
- . validator ( is_pubkey_or_keypair )
899
+ . validator ( is_valid_pubkey )
900
900
. value_name ( "SOURCE_TOKEN_ACCOUNT_ADDRESS" )
901
901
. takes_value ( true )
902
902
. index ( 1 )
@@ -918,7 +918,7 @@ fn main() {
918
918
. about ( "Mint new tokens" )
919
919
. arg (
920
920
Arg :: with_name ( "token" )
921
- . validator ( is_pubkey_or_keypair )
921
+ . validator ( is_valid_pubkey )
922
922
. value_name ( "TOKEN_ADDRESS" )
923
923
. takes_value ( true )
924
924
. index ( 1 )
@@ -936,7 +936,7 @@ fn main() {
936
936
)
937
937
. arg (
938
938
Arg :: with_name ( "recipient" )
939
- . validator ( is_pubkey_or_keypair )
939
+ . validator ( is_valid_pubkey )
940
940
. value_name ( "RECIPIENT_TOKEN_ACCOUNT_ADDRESS" )
941
941
. takes_value ( true )
942
942
. index ( 3 )
@@ -949,7 +949,7 @@ fn main() {
949
949
. about ( "Freeze a token account" )
950
950
. arg (
951
951
Arg :: with_name ( "account" )
952
- . validator ( is_pubkey_or_keypair )
952
+ . validator ( is_valid_pubkey )
953
953
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
954
954
. takes_value ( true )
955
955
. index ( 1 )
@@ -962,7 +962,7 @@ fn main() {
962
962
. about ( "Thaw a token account" )
963
963
. arg (
964
964
Arg :: with_name ( "account" )
965
- . validator ( is_pubkey_or_keypair )
965
+ . validator ( is_valid_pubkey )
966
966
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
967
967
. takes_value ( true )
968
968
. index ( 1 )
@@ -975,7 +975,7 @@ fn main() {
975
975
. about ( "Get token account balance" )
976
976
. arg (
977
977
Arg :: with_name ( "address" )
978
- . validator ( is_pubkey_or_keypair )
978
+ . validator ( is_valid_pubkey )
979
979
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
980
980
. takes_value ( true )
981
981
. index ( 1 )
@@ -988,7 +988,7 @@ fn main() {
988
988
. about ( "Get token supply" )
989
989
. arg (
990
990
Arg :: with_name ( "address" )
991
- . validator ( is_pubkey_or_keypair )
991
+ . validator ( is_valid_pubkey )
992
992
. value_name ( "TOKEN_ADDRESS" )
993
993
. takes_value ( true )
994
994
. index ( 1 )
@@ -1001,7 +1001,7 @@ fn main() {
1001
1001
. about ( "List all token accounts by owner" )
1002
1002
. arg (
1003
1003
Arg :: with_name ( "token" )
1004
- . validator ( is_pubkey_or_keypair )
1004
+ . validator ( is_valid_pubkey )
1005
1005
. value_name ( "TOKEN_ADDRESS" )
1006
1006
. takes_value ( true )
1007
1007
. index ( 1 )
@@ -1026,7 +1026,7 @@ fn main() {
1026
1026
. about ( "Unwrap a SOL token account" )
1027
1027
. arg (
1028
1028
Arg :: with_name ( "address" )
1029
- . validator ( is_pubkey_or_keypair )
1029
+ . validator ( is_valid_pubkey )
1030
1030
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
1031
1031
. takes_value ( true )
1032
1032
. index ( 1 )
@@ -1039,7 +1039,7 @@ fn main() {
1039
1039
. about ( "Query details of an SPL Token account by address" )
1040
1040
. arg (
1041
1041
Arg :: with_name ( "address" )
1042
- . validator ( is_pubkey_or_keypair )
1042
+ . validator ( is_valid_pubkey )
1043
1043
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
1044
1044
. takes_value ( true )
1045
1045
. index ( 1 )
@@ -1052,7 +1052,7 @@ fn main() {
1052
1052
. about ( "Approve a delegate for a token account" )
1053
1053
. arg (
1054
1054
Arg :: with_name ( "account" )
1055
- . validator ( is_pubkey_or_keypair )
1055
+ . validator ( is_valid_pubkey )
1056
1056
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
1057
1057
. takes_value ( true )
1058
1058
. index ( 1 )
@@ -1070,7 +1070,7 @@ fn main() {
1070
1070
)
1071
1071
. arg (
1072
1072
Arg :: with_name ( "delegate" )
1073
- . validator ( is_pubkey_or_keypair )
1073
+ . validator ( is_valid_pubkey )
1074
1074
. value_name ( "DELEGATE_TOKEN_ACCOUNT_ADDRESS" )
1075
1075
. takes_value ( true )
1076
1076
. index ( 3 )
@@ -1083,7 +1083,7 @@ fn main() {
1083
1083
. about ( "Revoke a delegate's authority" )
1084
1084
. arg (
1085
1085
Arg :: with_name ( "account" )
1086
- . validator ( is_pubkey_or_keypair )
1086
+ . validator ( is_valid_pubkey )
1087
1087
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
1088
1088
. takes_value ( true )
1089
1089
. index ( 1 )
@@ -1096,7 +1096,7 @@ fn main() {
1096
1096
. about ( "Close a token account" )
1097
1097
. arg (
1098
1098
Arg :: with_name ( "account" )
1099
- . validator ( is_pubkey_or_keypair )
1099
+ . validator ( is_valid_pubkey )
1100
1100
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
1101
1101
. takes_value ( true )
1102
1102
. index ( 1 )
@@ -1105,7 +1105,7 @@ fn main() {
1105
1105
)
1106
1106
. arg (
1107
1107
Arg :: with_name ( "destination" )
1108
- . validator ( is_pubkey_or_keypair )
1108
+ . validator ( is_valid_pubkey )
1109
1109
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
1110
1110
. takes_value ( true )
1111
1111
. index ( 2 )
@@ -1191,7 +1191,9 @@ fn main() {
1191
1191
)
1192
1192
}
1193
1193
( "create-account" , Some ( arg_matches) ) => {
1194
- let token = pubkey_of ( arg_matches, "token" ) . unwrap ( ) ;
1194
+ let token = pubkey_of_signer ( arg_matches, "token" , & mut wallet_manager)
1195
+ . unwrap ( )
1196
+ . unwrap ( ) ;
1195
1197
let account = if arg_matches. is_present ( "account_keypair" ) {
1196
1198
signer_from_path (
1197
1199
& matches,
@@ -1210,7 +1212,9 @@ fn main() {
1210
1212
command_create_account ( & config, token, account)
1211
1213
}
1212
1214
( "authorize" , Some ( arg_matches) ) => {
1213
- let address = pubkey_of ( arg_matches, "address" ) . unwrap ( ) ;
1215
+ let address = pubkey_of_signer ( arg_matches, "address" , & mut wallet_manager)
1216
+ . unwrap ( )
1217
+ . unwrap ( ) ;
1214
1218
let authority_type = arg_matches. value_of ( "authority_type" ) . unwrap ( ) ;
1215
1219
let authority_type = match authority_type {
1216
1220
"mint" => AuthorityType :: MintTokens ,
@@ -1219,71 +1223,104 @@ fn main() {
1219
1223
"close" => AuthorityType :: CloseAccount ,
1220
1224
_ => unreachable ! ( ) ,
1221
1225
} ;
1222
- let new_authority = pubkey_of ( arg_matches, "new_authority" ) ;
1226
+ let new_authority =
1227
+ pubkey_of_signer ( arg_matches, "new_authority" , & mut wallet_manager) . unwrap ( ) ;
1223
1228
command_authorize ( & config, address, authority_type, new_authority)
1224
1229
}
1225
1230
( "transfer" , Some ( arg_matches) ) => {
1226
- let sender = pubkey_of ( arg_matches, "sender" ) . unwrap ( ) ;
1231
+ let sender = pubkey_of_signer ( arg_matches, "sender" , & mut wallet_manager)
1232
+ . unwrap ( )
1233
+ . unwrap ( ) ;
1227
1234
let amount = value_t_or_exit ! ( arg_matches, "amount" , f64 ) ;
1228
- let recipient = pubkey_of ( arg_matches, "recipient" ) . unwrap ( ) ;
1235
+ let recipient = pubkey_of_signer ( arg_matches, "recipient" , & mut wallet_manager)
1236
+ . unwrap ( )
1237
+ . unwrap ( ) ;
1229
1238
command_transfer ( & config, sender, amount, recipient)
1230
1239
}
1231
1240
( "burn" , Some ( arg_matches) ) => {
1232
- let source = pubkey_of ( arg_matches, "source" ) . unwrap ( ) ;
1241
+ let source = pubkey_of_signer ( arg_matches, "source" , & mut wallet_manager)
1242
+ . unwrap ( )
1243
+ . unwrap ( ) ;
1233
1244
let amount = value_t_or_exit ! ( arg_matches, "amount" , f64 ) ;
1234
1245
command_burn ( & config, source, amount)
1235
1246
}
1236
1247
( "mint" , Some ( arg_matches) ) => {
1237
- let token = pubkey_of ( arg_matches, "token" ) . unwrap ( ) ;
1248
+ let token = pubkey_of_signer ( arg_matches, "token" , & mut wallet_manager)
1249
+ . unwrap ( )
1250
+ . unwrap ( ) ;
1238
1251
let amount = value_t_or_exit ! ( arg_matches, "amount" , f64 ) ;
1239
- let recipient = pubkey_of ( arg_matches, "recipient" ) . unwrap ( ) ;
1252
+ let recipient = pubkey_of_signer ( arg_matches, "recipient" , & mut wallet_manager)
1253
+ . unwrap ( )
1254
+ . unwrap ( ) ;
1240
1255
command_mint ( & config, token, amount, recipient)
1241
1256
}
1242
1257
( "freeze" , Some ( arg_matches) ) => {
1243
- let account = pubkey_of ( arg_matches, "account" ) . unwrap ( ) ;
1258
+ let account = pubkey_of_signer ( arg_matches, "account" , & mut wallet_manager)
1259
+ . unwrap ( )
1260
+ . unwrap ( ) ;
1244
1261
command_freeze ( & config, account)
1245
1262
}
1246
1263
( "thaw" , Some ( arg_matches) ) => {
1247
- let account = pubkey_of ( arg_matches, "account" ) . unwrap ( ) ;
1264
+ let account = pubkey_of_signer ( arg_matches, "account" , & mut wallet_manager)
1265
+ . unwrap ( )
1266
+ . unwrap ( ) ;
1248
1267
command_thaw ( & config, account)
1249
1268
}
1250
1269
( "wrap" , Some ( arg_matches) ) => {
1251
1270
let amount = value_t_or_exit ! ( arg_matches, "amount" , f64 ) ;
1252
1271
command_wrap ( & config, amount)
1253
1272
}
1254
1273
( "unwrap" , Some ( arg_matches) ) => {
1255
- let address = pubkey_of ( arg_matches, "address" ) . unwrap ( ) ;
1274
+ let address = pubkey_of_signer ( arg_matches, "address" , & mut wallet_manager)
1275
+ . unwrap ( )
1276
+ . unwrap ( ) ;
1256
1277
command_unwrap ( & config, address)
1257
1278
}
1258
1279
( "approve" , Some ( arg_matches) ) => {
1259
- let account = pubkey_of ( arg_matches, "account" ) . unwrap ( ) ;
1280
+ let account = pubkey_of_signer ( arg_matches, "account" , & mut wallet_manager)
1281
+ . unwrap ( )
1282
+ . unwrap ( ) ;
1260
1283
let amount = value_t_or_exit ! ( arg_matches, "amount" , f64 ) ;
1261
- let delegate = pubkey_of ( arg_matches, "delegate" ) . unwrap ( ) ;
1284
+ let delegate = pubkey_of_signer ( arg_matches, "delegate" , & mut wallet_manager)
1285
+ . unwrap ( )
1286
+ . unwrap ( ) ;
1262
1287
command_approve ( & config, account, amount, delegate)
1263
1288
}
1264
1289
( "revoke" , Some ( arg_matches) ) => {
1265
- let account = pubkey_of ( arg_matches, "account" ) . unwrap ( ) ;
1290
+ let account = pubkey_of_signer ( arg_matches, "account" , & mut wallet_manager)
1291
+ . unwrap ( )
1292
+ . unwrap ( ) ;
1266
1293
command_revoke ( & config, account)
1267
1294
}
1268
1295
( "close" , Some ( arg_matches) ) => {
1269
- let account = pubkey_of ( arg_matches, "account" ) . unwrap ( ) ;
1270
- let destination = pubkey_of ( arg_matches, "destination" ) . unwrap ( ) ;
1296
+ let account = pubkey_of_signer ( arg_matches, "account" , & mut wallet_manager)
1297
+ . unwrap ( )
1298
+ . unwrap ( ) ;
1299
+ let destination = pubkey_of_signer ( arg_matches, "destination" , & mut wallet_manager)
1300
+ . unwrap ( )
1301
+ . unwrap ( ) ;
1271
1302
command_close ( & config, account, destination)
1272
1303
}
1273
1304
( "balance" , Some ( arg_matches) ) => {
1274
- let address = pubkey_of ( arg_matches, "address" ) . unwrap ( ) ;
1305
+ let address = pubkey_of_signer ( arg_matches, "address" , & mut wallet_manager)
1306
+ . unwrap ( )
1307
+ . unwrap ( ) ;
1275
1308
command_balance ( & config, address)
1276
1309
}
1277
1310
( "supply" , Some ( arg_matches) ) => {
1278
- let address = pubkey_of ( arg_matches, "address" ) . unwrap ( ) ;
1311
+ let address = pubkey_of_signer ( arg_matches, "address" , & mut wallet_manager)
1312
+ . unwrap ( )
1313
+ . unwrap ( ) ;
1279
1314
command_supply ( & config, address)
1280
1315
}
1281
1316
( "accounts" , Some ( arg_matches) ) => {
1282
- let token = pubkey_of ( arg_matches, "token" ) ;
1317
+ let token = pubkey_of_signer ( arg_matches, "token" , & mut wallet_manager ) . unwrap ( ) ;
1283
1318
command_accounts ( & config, token)
1284
1319
}
1285
1320
( "account-info" , Some ( arg_matches) ) => {
1286
- let address = pubkey_of ( arg_matches, "address" ) . unwrap ( ) ;
1321
+ let address = pubkey_of_signer ( arg_matches, "address" , & mut wallet_manager)
1322
+ . unwrap ( )
1323
+ . unwrap ( ) ;
1287
1324
command_account ( & config, address)
1288
1325
}
1289
1326
_ => unreachable ! ( ) ,
0 commit comments