@@ -1210,6 +1210,7 @@ async fn command_wrap(
1210
1210
sol : f64 ,
1211
1211
wallet_address : Pubkey ,
1212
1212
wrapped_sol_account : Option < Pubkey > ,
1213
+ immutable_owner : bool ,
1213
1214
bulk_signers : BulkSigners ,
1214
1215
) -> CommandResult {
1215
1216
let lamports = sol_to_lamports ( sol) ;
@@ -1235,9 +1236,24 @@ async fn command_wrap(
1235
1236
check_wallet_balance ( config, & wallet_address, lamports) . await ?;
1236
1237
}
1237
1238
1238
- let res = token
1239
- . wrap_transferable ( & account, & wallet_address, lamports, & bulk_signers)
1240
- . await ?;
1239
+ let res = if immutable_owner {
1240
+ if config. program_id == spl_token:: id ( ) {
1241
+ return Err ( format ! (
1242
+ "Specified --immutable, but token program {} does not support the extension" ,
1243
+ config. program_id
1244
+ )
1245
+ . into ( ) ) ;
1246
+ }
1247
+
1248
+ token
1249
+ . wrap ( & account, & wallet_address, lamports, & bulk_signers)
1250
+ . await ?
1251
+ } else {
1252
+ // this case is hit for a token22 ata, which is always immutable. but it does the right thing anyway
1253
+ token
1254
+ . wrap_transferable ( & account, & wallet_address, lamports, & bulk_signers)
1255
+ . await ?
1256
+ } ;
1241
1257
1242
1258
let tx_return = finish_tx ( config, & res, false ) . await ?;
1243
1259
Ok ( match tx_return {
@@ -2530,6 +2546,14 @@ fn app<'a, 'b>(
2530
2546
. long ( "create-aux-account" )
2531
2547
. help ( "Wrap SOL in an auxiliary account instead of associated token account" ) ,
2532
2548
)
2549
+ . arg (
2550
+ Arg :: with_name ( "immutable" )
2551
+ . long ( "immutable" )
2552
+ . takes_value ( false )
2553
+ . help (
2554
+ "Lock the owner of this token account from ever being changed"
2555
+ ) ,
2556
+ )
2533
2557
. nonce_args ( true )
2534
2558
. offline_args ( ) ,
2535
2559
)
@@ -3276,7 +3300,15 @@ async fn process_command<'a>(
3276
3300
bulk_signers. push ( wallet_signer) ;
3277
3301
}
3278
3302
3279
- command_wrap ( config, amount, wallet_address, account, bulk_signers) . await
3303
+ command_wrap (
3304
+ config,
3305
+ amount,
3306
+ wallet_address,
3307
+ account,
3308
+ arg_matches. is_present ( "immutable" ) ,
3309
+ bulk_signers,
3310
+ )
3311
+ . await
3280
3312
}
3281
3313
( CommandName :: Unwrap , arg_matches) => {
3282
3314
let ( wallet_signer, wallet_address) =
@@ -4142,9 +4174,16 @@ mod tests {
4142
4174
do_create_native_mint ( & config, & program_id, & payer) . await ;
4143
4175
let ( signer, account) = new_throwaway_signer ( ) ;
4144
4176
let bulk_signers: Vec < Arc < dyn Signer > > = vec ! [ Arc :: new( clone_keypair( & payer) ) , signer] ;
4145
- command_wrap ( & config, 0.5 , payer. pubkey ( ) , Some ( account) , bulk_signers)
4146
- . await
4147
- . unwrap ( ) ;
4177
+ command_wrap (
4178
+ & config,
4179
+ 0.5 ,
4180
+ payer. pubkey ( ) ,
4181
+ Some ( account) ,
4182
+ false ,
4183
+ bulk_signers,
4184
+ )
4185
+ . await
4186
+ . unwrap ( ) ;
4148
4187
let result = process_test_command (
4149
4188
& config,
4150
4189
& payer,
@@ -4304,9 +4343,16 @@ mod tests {
4304
4343
let source = create_associated_account ( & config, & payer, token) . await ;
4305
4344
do_create_native_mint ( & config, & program_id, & payer) . await ;
4306
4345
let ui_amount = 10.0 ;
4307
- command_wrap ( & config, ui_amount, payer. pubkey ( ) , None , bulk_signers)
4308
- . await
4309
- . unwrap ( ) ;
4346
+ command_wrap (
4347
+ & config,
4348
+ ui_amount,
4349
+ payer. pubkey ( ) ,
4350
+ None ,
4351
+ false ,
4352
+ bulk_signers,
4353
+ )
4354
+ . await
4355
+ . unwrap ( ) ;
4310
4356
4311
4357
let recipient = get_associated_token_address_with_program_id (
4312
4358
& payer. pubkey ( ) ,
0 commit comments