Skip to content

Commit

Permalink
token-cli: reverse logic for --recipient-is-ata-owner (#5053)
Browse files Browse the repository at this point in the history
* Reverse logic for --recepient-is-ata-owner

* Retaining the original recipient_is_ata_owner as a hidden flag and printing that it is now default behaviour

* Syntax issue - minor change

* Adding flag for recipient is ata owner and printing it as default without touching commandresult

* Clean up

---------

Co-authored-by: Sumeet <[email protected]>
  • Loading branch information
joncinque and SUMEETRM authored Aug 18, 2023
1 parent 6f30f86 commit 30d0e1b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions token/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ async fn command_transfer(
allow_unfunded_recipient: bool,
fund_recipient: bool,
mint_decimals: Option<u8>,
recipient_is_ata_owner: bool,
no_recipient_is_ata_owner: bool,
use_unchecked_instruction: bool,
ui_fee: Option<f64>,
memo: Option<String>,
Expand Down Expand Up @@ -1290,7 +1290,7 @@ async fn command_transfer(
}
} else {
// in offline mode we gotta trust them
!recipient_is_ata_owner
no_recipient_is_ata_owner
};

// now if its a token account, life is ez
Expand Down Expand Up @@ -3133,12 +3133,21 @@ fn app<'a, 'b>(
.takes_value(false)
.help("Send tokens to the recipient even if the recipient is not a wallet owned by System Program."),
)
.arg(
Arg::with_name("no_recipient_is_ata_owner")
.long("no-recipient-is-ata-owner")
.takes_value(false)
.requires("sign_only")
.help("In sign-only mode, specifies that the recipient is the owner of the associated token account rather than an actual token account"),
)
.arg(
Arg::with_name("recipient_is_ata_owner")
.long("recipient-is-ata-owner")
.takes_value(false)
.hidden(true)
.conflicts_with("no_recipient_is_ata_owner")
.requires("sign_only")
.help("In sign-only mode, specifies that the recipient is the owner of the associated token account rather than an actual token account"),
.help("recipient-is-ata-owner is now the default behavior. The option has been deprecated and will be removed in a future release."),
)
.arg(
Arg::with_name("expected_fee")
Expand Down Expand Up @@ -4244,6 +4253,11 @@ async fn process_command<'a>(
|| arg_matches.is_present("allow_unfunded_recipient");

let recipient_is_ata_owner = arg_matches.is_present("recipient_is_ata_owner");
let no_recipient_is_ata_owner =
arg_matches.is_present("no_recipient_is_ata_owner") || !recipient_is_ata_owner;
if recipient_is_ata_owner {
println_display(config, format!("recipient-is-ata-owner is now the default behavior. The option has been deprecated and will be removed in a future release."));
}
let use_unchecked_instruction = arg_matches.is_present("use_unchecked_instruction");
let expected_fee = value_of::<f64>(arg_matches, "expected_fee");
let memo = value_t!(arg_matches, "memo", String).ok();
Expand All @@ -4263,7 +4277,7 @@ async fn process_command<'a>(
allow_unfunded_recipient,
fund_recipient,
mint_decimals,
recipient_is_ata_owner,
no_recipient_is_ata_owner,
use_unchecked_instruction,
expected_fee,
memo,
Expand Down

0 comments on commit 30d0e1b

Please sign in to comment.