@@ -2659,7 +2659,7 @@ fn app<'a, 'b>(
2659
2659
. arg (
2660
2660
Arg :: with_name ( "recipient" )
2661
2661
. validator ( is_valid_pubkey)
2662
- . value_name ( "RECIPIENT_ADDRESS or RECIPIENT_TOKEN_ACCOUNT_ADDRESS" )
2662
+ . value_name ( "RECIPIENT_WALLET_ADDRESS or RECIPIENT_TOKEN_ACCOUNT_ADDRESS" )
2663
2663
. takes_value ( true )
2664
2664
. index ( 3 )
2665
2665
. required ( true )
@@ -2794,10 +2794,20 @@ fn app<'a, 'b>(
2794
2794
. validator ( is_valid_pubkey)
2795
2795
. value_name ( "RECIPIENT_TOKEN_ACCOUNT_ADDRESS" )
2796
2796
. takes_value ( true )
2797
+ . conflicts_with ( "recipient_owner" )
2797
2798
. index ( 3 )
2798
2799
. help ( "The token account address of recipient \
2799
2800
[default: associated token account for --mint-authority]") ,
2800
2801
)
2802
+ . arg (
2803
+ Arg :: with_name ( "recipient_owner" )
2804
+ . long ( "recipient-owner" )
2805
+ . validator ( is_valid_pubkey)
2806
+ . value_name ( "RECIPIENT_WALLET_ADDRESS" )
2807
+ . takes_value ( true )
2808
+ . conflicts_with ( "recipient" )
2809
+ . help ( "The owner of the recipient associated token account" ) ,
2810
+ )
2801
2811
. arg (
2802
2812
Arg :: with_name ( "mint_authority" )
2803
2813
. long ( "mint-authority" )
@@ -3777,6 +3787,10 @@ async fn process_command<'a>(
3777
3787
pubkey_of_signer ( arg_matches, "recipient" , & mut wallet_manager) . unwrap ( )
3778
3788
{
3779
3789
address
3790
+ } else if let Some ( address) =
3791
+ pubkey_of_signer ( arg_matches, "recipient_owner" , & mut wallet_manager) . unwrap ( )
3792
+ {
3793
+ get_associated_token_address_with_program_id ( & address, & token, & config. program_id )
3780
3794
} else {
3781
3795
let owner = config. default_signer ( ) ?. pubkey ( ) ;
3782
3796
config. associated_token_address_for_token_and_program (
@@ -4718,21 +4732,74 @@ mod tests {
4718
4732
let config = test_config_with_default_signer ( & test_validator, & payer, program_id) ;
4719
4733
let token = create_token ( & config, & payer) . await ;
4720
4734
let account = create_associated_account ( & config, & payer, token) . await ;
4721
- let result = process_test_command (
4735
+ let mut amount = 0 ;
4736
+
4737
+ // mint via implicit owner
4738
+ process_test_command (
4722
4739
& config,
4723
4740
& payer,
4724
4741
& [
4725
4742
"spl-token" ,
4726
4743
CommandName :: Mint . into ( ) ,
4727
4744
& token. to_string ( ) ,
4728
- "100 " ,
4745
+ "1 " ,
4729
4746
] ,
4730
4747
)
4731
- . await ;
4732
- result. unwrap ( ) ;
4733
- let account = config. rpc_client . get_account ( & account) . await . unwrap ( ) ;
4734
- let token_account = StateWithExtensionsOwned :: < Account > :: unpack ( account. data ) . unwrap ( ) ;
4735
- assert_eq ! ( token_account. base. amount, 100 ) ;
4748
+ . await
4749
+ . unwrap ( ) ;
4750
+ amount += 1 ;
4751
+
4752
+ let account_data = config. rpc_client . get_account ( & account) . await . unwrap ( ) ;
4753
+ let token_account =
4754
+ StateWithExtensionsOwned :: < Account > :: unpack ( account_data. data ) . unwrap ( ) ;
4755
+ assert_eq ! ( token_account. base. amount, amount) ;
4756
+ assert_eq ! ( token_account. base. mint, token) ;
4757
+ assert_eq ! ( token_account. base. owner, payer. pubkey( ) ) ;
4758
+
4759
+ // mint via explicit recipient
4760
+ process_test_command (
4761
+ & config,
4762
+ & payer,
4763
+ & [
4764
+ "spl-token" ,
4765
+ CommandName :: Mint . into ( ) ,
4766
+ & token. to_string ( ) ,
4767
+ "1" ,
4768
+ & account. to_string ( ) ,
4769
+ ] ,
4770
+ )
4771
+ . await
4772
+ . unwrap ( ) ;
4773
+ amount += 1 ;
4774
+
4775
+ let account_data = config. rpc_client . get_account ( & account) . await . unwrap ( ) ;
4776
+ let token_account =
4777
+ StateWithExtensionsOwned :: < Account > :: unpack ( account_data. data ) . unwrap ( ) ;
4778
+ assert_eq ! ( token_account. base. amount, amount) ;
4779
+ assert_eq ! ( token_account. base. mint, token) ;
4780
+ assert_eq ! ( token_account. base. owner, payer. pubkey( ) ) ;
4781
+
4782
+ // mint via explicit owner
4783
+ process_test_command (
4784
+ & config,
4785
+ & payer,
4786
+ & [
4787
+ "spl-token" ,
4788
+ CommandName :: Mint . into ( ) ,
4789
+ & token. to_string ( ) ,
4790
+ "1" ,
4791
+ "--recipient-owner" ,
4792
+ & payer. pubkey ( ) . to_string ( ) ,
4793
+ ] ,
4794
+ )
4795
+ . await
4796
+ . unwrap ( ) ;
4797
+ amount += 1 ;
4798
+
4799
+ let account_data = config. rpc_client . get_account ( & account) . await . unwrap ( ) ;
4800
+ let token_account =
4801
+ StateWithExtensionsOwned :: < Account > :: unpack ( account_data. data ) . unwrap ( ) ;
4802
+ assert_eq ! ( token_account. base. amount, amount) ;
4736
4803
assert_eq ! ( token_account. base. mint, token) ;
4737
4804
assert_eq ! ( token_account. base. owner, payer. pubkey( ) ) ;
4738
4805
}
0 commit comments