@@ -172,20 +172,35 @@ fn command_create_account(
172
172
Ok ( Some ( transaction) )
173
173
}
174
174
175
- fn command_assign ( config : & Config , account : Pubkey , new_owner : Pubkey ) -> CommandResult {
175
+ fn command_authorize (
176
+ config : & Config ,
177
+ account : Pubkey ,
178
+ authority_type : AuthorityType ,
179
+ new_owner : Option < Pubkey > ,
180
+ ) -> CommandResult {
181
+ let auth_str = match authority_type {
182
+ AuthorityType :: MintTokens => "mint authority" ,
183
+ AuthorityType :: FreezeAccount => "freeze authority" ,
184
+ AuthorityType :: AccountOwner => "owner" ,
185
+ AuthorityType :: CloseAccount => "close authority" ,
186
+ } ;
176
187
println ! (
177
- "Assigning {}\n Current owner : {}\n New owner : {}" ,
188
+ "Updating {}\n Current {} : {}\n New {} : {}" ,
178
189
account,
190
+ auth_str,
179
191
config. owner. pubkey( ) ,
192
+ auth_str,
180
193
new_owner
194
+ . map( |pubkey| pubkey. to_string( ) )
195
+ . unwrap_or_else( || "disabled" . to_string( ) )
181
196
) ;
182
197
183
198
let mut transaction = Transaction :: new_with_payer (
184
199
& [ set_authority (
185
200
& spl_token:: id ( ) ,
186
201
& account,
187
- Some ( & new_owner) ,
188
- AuthorityType :: AccountOwner ,
202
+ new_owner. as_ref ( ) ,
203
+ authority_type ,
189
204
& config. owner . pubkey ( ) ,
190
205
& [ ] ,
191
206
) ?] ,
@@ -731,8 +746,8 @@ fn main() {
731
746
) ,
732
747
)
733
748
. subcommand (
734
- SubCommand :: with_name ( "assign " )
735
- . about ( "Assign a token or token account to a new owner " )
749
+ SubCommand :: with_name ( "authorize " )
750
+ . about ( "Authorize a new signing keypair to a token or token account " )
736
751
. arg (
737
752
Arg :: with_name ( "address" )
738
753
. validator ( is_pubkey_or_keypair)
@@ -743,13 +758,31 @@ fn main() {
743
758
. help ( "The address of the token account" ) ,
744
759
)
745
760
. arg (
746
- Arg :: with_name ( "new_owner" )
747
- . validator ( is_pubkey_or_keypair)
748
- . value_name ( "OWNER_ADDRESS" )
761
+ Arg :: with_name ( "authority_type" )
762
+ . value_name ( "AUTHORITY_TYPE" )
749
763
. takes_value ( true )
764
+ . possible_values ( & [ "mint" , "freeze" , "owner" , "close" ] )
750
765
. index ( 2 )
751
766
. required ( true )
752
- . help ( "The address of the new owner" ) ,
767
+ . help ( "The new authority type. \
768
+ Token mints support `mint` and `freeze` authorities;\
769
+ Token accounts support `owner` and `close` authorities.") ,
770
+ )
771
+ . arg (
772
+ Arg :: with_name ( "new_authority" )
773
+ . validator ( is_pubkey_or_keypair)
774
+ . value_name ( "AUTHORITY_ADDRESS" )
775
+ . takes_value ( true )
776
+ . index ( 3 )
777
+ . required_unless ( "disable" )
778
+ . help ( "The address of the new authority" ) ,
779
+ )
780
+ . arg (
781
+ Arg :: with_name ( "disable" )
782
+ . long ( "disable" )
783
+ . takes_value ( false )
784
+ . conflicts_with ( "new_authority" )
785
+ . help ( "Disable mint, freeze, or close functionality by setting authority to None." )
753
786
) ,
754
787
)
755
788
. subcommand (
@@ -1035,10 +1068,18 @@ fn main() {
1035
1068
1036
1069
command_create_account ( & config, token, account)
1037
1070
}
1038
- ( "assign " , Some ( arg_matches) ) => {
1071
+ ( "authorize " , Some ( arg_matches) ) => {
1039
1072
let address = pubkey_of ( arg_matches, "address" ) . unwrap ( ) ;
1040
- let new_owner = pubkey_of ( arg_matches, "new_owner" ) . unwrap ( ) ;
1041
- command_assign ( & config, address, new_owner)
1073
+ let authority_type = arg_matches. value_of ( "authority_type" ) . unwrap ( ) ;
1074
+ let authority_type = match authority_type {
1075
+ "mint" => AuthorityType :: MintTokens ,
1076
+ "freeze" => AuthorityType :: FreezeAccount ,
1077
+ "owner" => AuthorityType :: AccountOwner ,
1078
+ "close" => AuthorityType :: CloseAccount ,
1079
+ _ => unreachable ! ( ) ,
1080
+ } ;
1081
+ let new_authority = pubkey_of ( arg_matches, "new_authority" ) ;
1082
+ command_authorize ( & config, address, authority_type, new_authority)
1042
1083
}
1043
1084
( "transfer" , Some ( arg_matches) ) => {
1044
1085
let sender = pubkey_of ( arg_matches, "sender" ) . unwrap ( ) ;
0 commit comments