@@ -14,6 +14,7 @@ use solana_clap_utils::{
14
14
is_valid_signer, normalize_to_url_if_moniker,
15
15
} ,
16
16
keypair:: { signer_from_path, CliSignerInfo } ,
17
+ memo:: memo_arg,
17
18
nonce:: * ,
18
19
offline:: { self , * } ,
19
20
ArgConstant ,
@@ -555,6 +556,7 @@ fn command_transfer(
555
556
mint_decimals : Option < u8 > ,
556
557
recipient_is_ata_owner : bool ,
557
558
use_unchecked_instruction : bool ,
559
+ memo : Option < String > ,
558
560
) -> CommandResult {
559
561
let sender = if let Some ( sender) = sender {
560
562
sender
@@ -714,12 +716,16 @@ fn command_transfer(
714
716
decimals,
715
717
) ?) ;
716
718
}
719
+ if let Some ( text) = memo {
720
+ instructions. push ( spl_memo:: build_memo ( text. as_bytes ( ) , & [ & config. fee_payer ] ) ) ;
721
+ }
717
722
Ok ( Some ( (
718
723
minimum_balance_for_rent_exemption,
719
724
vec ! [ instructions] ,
720
725
) ) )
721
726
}
722
727
728
+ #[ allow( clippy:: too_many_arguments) ]
723
729
fn command_burn (
724
730
config : & Config ,
725
731
source : Pubkey ,
@@ -728,6 +734,7 @@ fn command_burn(
728
734
mint_address : Option < Pubkey > ,
729
735
mint_decimals : Option < u8 > ,
730
736
use_unchecked_instruction : bool ,
737
+ memo : Option < String > ,
731
738
) -> CommandResult {
732
739
println_display (
733
740
config,
@@ -737,7 +744,7 @@ fn command_burn(
737
744
let ( mint_pubkey, decimals) = resolve_mint_info ( config, & source, mint_address, mint_decimals) ?;
738
745
let amount = spl_token:: ui_amount_to_amount ( ui_amount, decimals) ;
739
746
740
- let instructions = if use_unchecked_instruction {
747
+ let mut instructions = if use_unchecked_instruction {
741
748
vec ! [ burn(
742
749
& spl_token:: id( ) ,
743
750
& source,
@@ -757,6 +764,9 @@ fn command_burn(
757
764
decimals,
758
765
) ?]
759
766
} ;
767
+ if let Some ( text) = memo {
768
+ instructions. push ( spl_memo:: build_memo ( text. as_bytes ( ) , & [ & config. fee_payer ] ) ) ;
769
+ }
760
770
Ok ( Some ( ( 0 , vec ! [ instructions] ) ) )
761
771
}
762
772
@@ -1458,13 +1468,8 @@ fn main() {
1458
1468
"Enable the mint authority to freeze associated token accounts."
1459
1469
) ,
1460
1470
)
1461
- . arg (
1462
- Arg :: with_name ( "memo" )
1463
- . long ( "memo" )
1464
- . takes_value ( true )
1465
- . help ( "Specify text that should be written as a memo when the token is created" ) ,
1466
- )
1467
1471
. nonce_args ( true )
1472
+ . arg ( memo_arg ( ) )
1468
1473
. offline_args ( ) ,
1469
1474
)
1470
1475
. subcommand (
@@ -1682,6 +1687,7 @@ fn main() {
1682
1687
. arg ( multisig_signer_arg ( ) )
1683
1688
. arg ( mint_decimals_arg ( ) )
1684
1689
. nonce_args ( true )
1690
+ . arg ( memo_arg ( ) )
1685
1691
. offline_args_config ( & SignOnlyNeedsMintDecimals { } ) ,
1686
1692
)
1687
1693
. subcommand (
@@ -1715,6 +1721,7 @@ fn main() {
1715
1721
. arg ( multisig_signer_arg ( ) )
1716
1722
. mint_args ( )
1717
1723
. nonce_args ( true )
1724
+ . arg ( memo_arg ( ) )
1718
1725
. offline_args_config ( & SignOnlyNeedsFullMintSpec { } ) ,
1719
1726
)
1720
1727
. subcommand (
@@ -2360,6 +2367,7 @@ fn main() {
2360
2367
no_wait = matches. is_present ( "no_wait" ) ;
2361
2368
let recipient_is_ata_owner = matches. is_present ( "recipient_is_ata_owner" ) ;
2362
2369
let use_unchecked_instruction = matches. is_present ( "use_unchecked_instruction" ) ;
2370
+ let memo = value_t ! ( arg_matches, "memo" , String ) . ok ( ) ;
2363
2371
2364
2372
command_transfer (
2365
2373
& config,
@@ -2373,6 +2381,7 @@ fn main() {
2373
2381
mint_decimals,
2374
2382
recipient_is_ata_owner,
2375
2383
use_unchecked_instruction,
2384
+ memo,
2376
2385
)
2377
2386
}
2378
2387
( "burn" , Some ( arg_matches) ) => {
@@ -2389,6 +2398,7 @@ fn main() {
2389
2398
pubkey_of_signer ( arg_matches, MINT_ADDRESS_ARG . name , & mut wallet_manager) . unwrap ( ) ;
2390
2399
let mint_decimals = value_of :: < u8 > ( arg_matches, MINT_DECIMALS_ARG . name ) ;
2391
2400
let use_unchecked_instruction = matches. is_present ( "use_unchecked_instruction" ) ;
2401
+ let memo = value_t ! ( arg_matches, "memo" , String ) . ok ( ) ;
2392
2402
command_burn (
2393
2403
& config,
2394
2404
source,
@@ -2397,6 +2407,7 @@ fn main() {
2397
2407
mint_address,
2398
2408
mint_decimals,
2399
2409
use_unchecked_instruction,
2410
+ memo,
2400
2411
)
2401
2412
}
2402
2413
( "mint" , Some ( arg_matches) ) => {
0 commit comments