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

Commit 3136a49

Browse files
authored
token-cli: Remove multisig owner as signer (#4017)
1 parent 4da4314 commit 3136a49

File tree

3 files changed

+360
-117
lines changed

3 files changed

+360
-117
lines changed

token/cli/src/config.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(crate) struct Config<'a> {
3838
pub(crate) output_format: OutputFormat,
3939
pub(crate) fee_payer: Option<Arc<dyn Signer>>,
4040
pub(crate) nonce_account: Option<Pubkey>,
41-
pub(crate) nonce_authority: Option<Pubkey>,
41+
pub(crate) nonce_authority: Option<Arc<dyn Signer>>,
4242
pub(crate) sign_only: bool,
4343
pub(crate) dump_transaction_message: bool,
4444
pub(crate) multisigner_pubkeys: Vec<&'a Pubkey>,
@@ -98,6 +98,26 @@ impl<'a> Config<'a> {
9898
.await
9999
}
100100

101+
fn extract_multisig_signers(
102+
matches: &ArgMatches<'_>,
103+
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
104+
bulk_signers: &mut Vec<Arc<dyn Signer>>,
105+
multisigner_ids: &'a mut Vec<Pubkey>,
106+
) -> Vec<&'a Pubkey> {
107+
let multisig_signers = signers_of(matches, MULTISIG_SIGNER_ARG.name, wallet_manager)
108+
.unwrap_or_else(|e| {
109+
eprintln!("error: {}", e);
110+
exit(1);
111+
});
112+
if let Some(mut multisig_signers) = multisig_signers {
113+
multisig_signers.sort_by(|(_, lp), (_, rp)| lp.cmp(rp));
114+
let (signers, pubkeys): (Vec<_>, Vec<_>) = multisig_signers.into_iter().unzip();
115+
bulk_signers.extend(signers);
116+
multisigner_ids.extend(pubkeys);
117+
}
118+
multisigner_ids.iter().collect::<Vec<_>>()
119+
}
120+
101121
pub(crate) async fn new_with_clients_and_ws_url(
102122
matches: &ArgMatches<'_>,
103123
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
@@ -117,18 +137,8 @@ impl<'a> Config<'a> {
117137
} else {
118138
solana_cli_config::Config::default()
119139
};
120-
let multisig_signers = signers_of(matches, MULTISIG_SIGNER_ARG.name, wallet_manager)
121-
.unwrap_or_else(|e| {
122-
eprintln!("error: {}", e);
123-
exit(1);
124-
});
125-
if let Some(mut multisig_signers) = multisig_signers {
126-
multisig_signers.sort_by(|(_, lp), (_, rp)| lp.cmp(rp));
127-
let (signers, pubkeys): (Vec<_>, Vec<_>) = multisig_signers.into_iter().unzip();
128-
bulk_signers.extend(signers);
129-
multisigner_ids.extend(pubkeys);
130-
}
131-
let multisigner_pubkeys = multisigner_ids.iter().collect::<Vec<_>>();
140+
let multisigner_pubkeys =
141+
Self::extract_multisig_signers(matches, wallet_manager, bulk_signers, multisigner_ids);
132142

133143
let config = SignerFromPathConfig {
134144
allow_null_signer: !multisigner_pubkeys.is_empty(),
@@ -195,7 +205,7 @@ impl<'a> Config<'a> {
195205
exit(1);
196206
});
197207
let nonce_authority = if nonce_account.is_some() {
198-
let (signer, nonce_authority) = signer_from_path(
208+
let (nonce_authority, _) = signer_from_path(
199209
matches,
200210
matches
201211
.value_of(NONCE_AUTHORITY_ARG.name)
@@ -212,9 +222,6 @@ impl<'a> Config<'a> {
212222
eprintln!("error: {}", e);
213223
exit(1);
214224
});
215-
if !bulk_signers.contains(&signer) {
216-
bulk_signers.push(signer);
217-
}
218225

219226
Some(nonce_authority)
220227
} else {

0 commit comments

Comments
 (0)