Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit dfc5cc5

Browse files
t-nelsonmergify[bot]
authored andcommitted
token-cli: Fix ATA creation in offline mode
1 parent c149b0a commit dfc5cc5

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

token/cli/src/main.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ fn command_transfer(
576576
recipient_token_account
577577
);
578578

579-
if !config.sign_only {
580-
let needs_funding = if let Some(recipient_token_account_data) = config
579+
let needs_funding = if !config.sign_only {
580+
if let Some(recipient_token_account_data) = config
581581
.rpc_client
582582
.get_account_with_commitment(
583583
&recipient_token_account,
@@ -596,10 +596,14 @@ fn command_transfer(
596596
}
597597
} else {
598598
true
599-
};
599+
}
600+
} else {
601+
fund_recipient
602+
};
600603

601-
if needs_funding {
602-
if fund_recipient {
604+
if needs_funding {
605+
if fund_recipient {
606+
if !config.sign_only {
603607
minimum_balance_for_rent_exemption += config
604608
.rpc_client
605609
.get_minimum_balance_for_rent_exemption(Account::LEN)?;
@@ -608,18 +612,18 @@ fn command_transfer(
608612
recipient_token_account,
609613
lamports_to_sol(minimum_balance_for_rent_exemption)
610614
);
611-
instructions.push(create_associated_token_account(
612-
&config.fee_payer,
613-
&recipient,
614-
&mint_pubkey,
615-
));
616-
} else {
617-
return Err(
618-
"Error: Recipient's associated token account does not exist. \
619-
Add `--fund-recipient` to fund their account"
620-
.into(),
621-
);
622615
}
616+
instructions.push(create_associated_token_account(
617+
&config.fee_payer,
618+
&recipient,
619+
&mint_pubkey,
620+
));
621+
} else {
622+
return Err(
623+
"Error: Recipient's associated token account does not exist. \
624+
Add `--fund-recipient` to fund their account"
625+
.into(),
626+
);
623627
}
624628
}
625629
}

0 commit comments

Comments
 (0)