Skip to content

Commit

Permalink
token-cli: Don't sign with owner when creating an associated token ac…
Browse files Browse the repository at this point in the history
…count (solana-labs#1449)
  • Loading branch information
jstarry authored Mar 16, 2021
1 parent 6db3b29 commit 5aa60dd
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions token/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,13 @@ fn main() {
path: default_signer_path,
arg_name: default_signer_arg_name,
};
// Owner doesn't sign when it's a multisig; and the `accounts` command is read-only
let owner = if matches.is_present(MULTISIG_SIGNER_ARG.name) || sub_command == "accounts" {

// Owner doesn't sign when using a mulitisig...
let owner = if matches.is_present(MULTISIG_SIGNER_ARG.name)
|| sub_command == "accounts" // when calling the `accounts` command...
|| (sub_command == "create-account" // or when creating an associated token account.
&& !matches.is_present("account_keypair"))
{
let owner_val = matches
.value_of("owner")
.unwrap_or(&cli_config.keypair_path);
Expand Down Expand Up @@ -1794,17 +1799,20 @@ fn main() {
.unwrap()
.unwrap();

let (signer, account) = if arg_matches.is_present("account_keypair") {
signer_of(&arg_matches, "account_keypair", &mut wallet_manager).unwrap_or_else(
|e| {
eprintln!("error: {}", e);
exit(1);
},
)
let account = if arg_matches.is_present("account_keypair") {
let (signer, account) =
signer_of(&arg_matches, "account_keypair", &mut wallet_manager).unwrap_or_else(
|e| {
eprintln!("error: {}", e);
exit(1);
},
);
bulk_signers.push(signer);
account
} else {
(None, None)
// No need to add a signer when creating an associated token account
None
};
bulk_signers.push(signer);

command_create_account(&config, token, account)
}
Expand Down

0 comments on commit 5aa60dd

Please sign in to comment.