@@ -497,14 +497,26 @@ async fn command_set_interest_rate(
497
497
} )
498
498
}
499
499
500
+ // XXX OK wtf do i need to do for this shit
501
+ // create account needs to go through the client
502
+ // create associated vs create aux with ext... pretty simple?
503
+ // then i want to impl --immutable, also simple
504
+ // error if the mint is tokenkeg, rebuke if the token is associated
505
+ // XXX umm then for default... i think its not possible to use this for ata?
506
+ // test it out quicky
507
+
508
+ // XXX NEXT UP impl this shit for wrap. maybe put wrap/unwrap in the client?
509
+ // and also reply to jon. i need to take a nap tho omg im dying
500
510
async fn command_create_account (
501
511
config : & Config < ' _ > ,
502
512
token_pubkey : Pubkey ,
503
513
owner : Pubkey ,
504
514
maybe_account : Option < Pubkey > ,
515
+ immutable_owner : bool ,
505
516
bulk_signers : Vec < Arc < dyn Signer > > ,
506
517
) -> CommandResult {
507
518
let token = token_client_from_config ( config, & token_pubkey) ;
519
+ let mut extensions = vec ! [ ] ;
508
520
509
521
let ( account, associated) = if let Some ( account) = maybe_account {
510
522
( account, false )
@@ -522,6 +534,23 @@ async fn command_create_account(
522
534
}
523
535
}
524
536
537
+ if immutable_owner {
538
+ if config. program_id == spl_token:: id ( ) {
539
+ return Err ( format ! (
540
+ "Specified --immutable, but token program {} does not support the extension" ,
541
+ config. program_id
542
+ )
543
+ . into ( ) ) ;
544
+ } else if associated {
545
+ println_display (
546
+ config,
547
+ "Note: --immutable specified, but Token-2022 ATAs are always immutable" . to_string ( ) ,
548
+ ) ;
549
+ } else {
550
+ extensions. push ( ExtensionType :: ImmutableOwner ) ;
551
+ }
552
+ }
553
+
525
554
let res = if associated {
526
555
token. create_associated_token_account ( & owner) . await
527
556
} else {
@@ -531,7 +560,7 @@ async fn command_create_account(
531
560
. unwrap_or_else ( || panic ! ( "No signer provided for account {}" , account) ) ;
532
561
533
562
token
534
- . create_auxiliary_token_account_with_extension_space ( & * * signer, & owner, vec ! [ ] )
563
+ . create_auxiliary_token_account_with_extension_space ( & * * signer, & owner, extensions )
535
564
. await
536
565
} ?;
537
566
@@ -2170,6 +2199,14 @@ fn app<'a, 'b>(
2170
2199
[default: associated token account for --owner]"
2171
2200
) ,
2172
2201
)
2202
+ . arg (
2203
+ Arg :: with_name ( "immutable" )
2204
+ . long ( "immutable" )
2205
+ . takes_value ( false )
2206
+ . help (
2207
+ "Lock the owner of this token account from ever being changed"
2208
+ ) ,
2209
+ )
2173
2210
. arg ( owner_address_arg ( ) )
2174
2211
. nonce_args ( true )
2175
2212
)
@@ -3029,7 +3066,15 @@ async fn process_command<'a>(
3029
3066
) ;
3030
3067
3031
3068
let owner = config. pubkey_or_default ( arg_matches, "owner" , & mut wallet_manager) ;
3032
- command_create_account ( config, token, owner, account, bulk_signers) . await
3069
+ command_create_account (
3070
+ config,
3071
+ token,
3072
+ owner,
3073
+ account,
3074
+ arg_matches. is_present ( "immutable" ) ,
3075
+ bulk_signers,
3076
+ )
3077
+ . await
3033
3078
}
3034
3079
( CommandName :: CreateMultisig , arg_matches) => {
3035
3080
let minimum_signers = value_of :: < u8 > ( arg_matches, "minimum_signers" ) . unwrap ( ) ;
0 commit comments