token-cli: Don't sign with owner when creating an associated token account (#1449)

This commit is contained in:
Justin Starry 2021-03-16 15:59:38 +08:00 committed by GitHub
parent 6db3b29066
commit 5aa60dd892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 11 deletions

View File

@ -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);
@ -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)
}