CLI: Encapsulate default signer attributes
This commit is contained in:
parent
eaf79152b3
commit
9a60353fa9
230
cli/src/cli.rs
230
cli/src/cli.rs
|
@ -78,7 +78,7 @@ use url::Url;
|
|||
|
||||
pub type CliSigners = Vec<Box<dyn Signer>>;
|
||||
pub type SignerIndex = usize;
|
||||
pub(crate) struct CliSignerInfo {
|
||||
pub struct CliSignerInfo {
|
||||
pub signers: CliSigners,
|
||||
}
|
||||
|
||||
|
@ -94,31 +94,45 @@ impl CliSignerInfo {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn generate_unique_signers(
|
||||
bulk_signers: Vec<Option<Box<dyn Signer>>>,
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliSignerInfo, Box<dyn error::Error>> {
|
||||
let mut unique_signers = vec![];
|
||||
pub struct DefaultSigner {
|
||||
pub arg_name: String,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
// Determine if the default signer is needed
|
||||
if bulk_signers.iter().any(|signer| signer.is_none()) {
|
||||
let default_signer =
|
||||
signer_from_path(matches, default_signer_path, "keypair", wallet_manager)?;
|
||||
unique_signers.push(default_signer);
|
||||
}
|
||||
impl DefaultSigner {
|
||||
pub fn generate_unique_signers(
|
||||
&self,
|
||||
bulk_signers: Vec<Option<Box<dyn Signer>>>,
|
||||
matches: &ArgMatches<'_>,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliSignerInfo, Box<dyn error::Error>> {
|
||||
let mut unique_signers = vec![];
|
||||
|
||||
for signer in bulk_signers.into_iter() {
|
||||
if let Some(signer) = signer {
|
||||
if !unique_signers.iter().any(|s| s == &signer) {
|
||||
unique_signers.push(signer);
|
||||
// Determine if the default signer is needed
|
||||
if bulk_signers.iter().any(|signer| signer.is_none()) {
|
||||
let default_signer = self.signer_from_path(matches, wallet_manager)?;
|
||||
unique_signers.push(default_signer);
|
||||
}
|
||||
|
||||
for signer in bulk_signers.into_iter() {
|
||||
if let Some(signer) = signer {
|
||||
if !unique_signers.iter().any(|s| s == &signer) {
|
||||
unique_signers.push(signer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(CliSignerInfo {
|
||||
signers: unique_signers,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn signer_from_path(
|
||||
&self,
|
||||
matches: &ArgMatches,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> {
|
||||
signer_from_path(matches, &self.path, &self.arg_name, wallet_manager)
|
||||
}
|
||||
Ok(CliSignerInfo {
|
||||
signers: unique_signers,
|
||||
})
|
||||
}
|
||||
|
||||
const DATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
|
||||
|
@ -566,7 +580,7 @@ impl Default for CliConfig<'_> {
|
|||
|
||||
pub fn parse_command(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, Box<dyn error::Error>> {
|
||||
let response = match matches.subcommand() {
|
||||
|
@ -581,7 +595,7 @@ pub fn parse_command(
|
|||
signers: vec![],
|
||||
}),
|
||||
("create-address-with-seed", Some(matches)) => {
|
||||
parse_create_address_with_seed(matches, default_signer_path, wallet_manager)
|
||||
parse_create_address_with_seed(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("fees", Some(_matches)) => Ok(CliCommandInfo {
|
||||
command: CliCommand::Fees,
|
||||
|
@ -609,7 +623,7 @@ pub fn parse_command(
|
|||
command: CliCommand::LeaderSchedule,
|
||||
signers: vec![],
|
||||
}),
|
||||
("ping", Some(matches)) => parse_cluster_ping(matches, default_signer_path, wallet_manager),
|
||||
("ping", Some(matches)) => parse_cluster_ping(matches, default_signer, wallet_manager),
|
||||
("live-slots", Some(_matches)) => Ok(CliCommandInfo {
|
||||
command: CliCommand::LiveSlots,
|
||||
signers: vec![],
|
||||
|
@ -626,28 +640,21 @@ pub fn parse_command(
|
|||
}
|
||||
// Nonce Commands
|
||||
("authorize-nonce-account", Some(matches)) => {
|
||||
parse_authorize_nonce_account(matches, default_signer_path, wallet_manager)
|
||||
parse_authorize_nonce_account(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("create-nonce-account", Some(matches)) => {
|
||||
parse_nonce_create_account(matches, default_signer_path, wallet_manager)
|
||||
parse_nonce_create_account(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("nonce", Some(matches)) => parse_get_nonce(matches, wallet_manager),
|
||||
("new-nonce", Some(matches)) => {
|
||||
parse_new_nonce(matches, default_signer_path, wallet_manager)
|
||||
}
|
||||
("new-nonce", Some(matches)) => parse_new_nonce(matches, default_signer, wallet_manager),
|
||||
("nonce-account", Some(matches)) => parse_show_nonce_account(matches, wallet_manager),
|
||||
("withdraw-from-nonce-account", Some(matches)) => {
|
||||
parse_withdraw_from_nonce_account(matches, default_signer_path, wallet_manager)
|
||||
parse_withdraw_from_nonce_account(matches, default_signer, wallet_manager)
|
||||
}
|
||||
// Program Deployment
|
||||
("deploy", Some(matches)) => {
|
||||
let (address_signer, _address) = signer_of(matches, "address_signer", wallet_manager)?;
|
||||
let mut signers = vec![signer_from_path(
|
||||
matches,
|
||||
default_signer_path,
|
||||
"keypair",
|
||||
wallet_manager,
|
||||
)?];
|
||||
let mut signers = vec![default_signer.signer_from_path(matches, wallet_manager)?];
|
||||
let address = address_signer.map(|signer| {
|
||||
signers.push(signer);
|
||||
1
|
||||
|
@ -665,74 +672,69 @@ pub fn parse_command(
|
|||
}
|
||||
// Stake Commands
|
||||
("create-stake-account", Some(matches)) => {
|
||||
parse_stake_create_account(matches, default_signer_path, wallet_manager)
|
||||
parse_stake_create_account(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("delegate-stake", Some(matches)) => {
|
||||
parse_stake_delegate_stake(matches, default_signer_path, wallet_manager)
|
||||
parse_stake_delegate_stake(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("withdraw-stake", Some(matches)) => {
|
||||
parse_stake_withdraw_stake(matches, default_signer_path, wallet_manager)
|
||||
parse_stake_withdraw_stake(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("deactivate-stake", Some(matches)) => {
|
||||
parse_stake_deactivate_stake(matches, default_signer_path, wallet_manager)
|
||||
parse_stake_deactivate_stake(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("split-stake", Some(matches)) => {
|
||||
parse_split_stake(matches, default_signer_path, wallet_manager)
|
||||
parse_split_stake(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("merge-stake", Some(matches)) => {
|
||||
parse_merge_stake(matches, default_signer_path, wallet_manager)
|
||||
parse_merge_stake(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("stake-authorize", Some(matches)) => {
|
||||
parse_stake_authorize(matches, default_signer_path, wallet_manager)
|
||||
parse_stake_authorize(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("stake-set-lockup", Some(matches)) => {
|
||||
parse_stake_set_lockup(matches, default_signer_path, wallet_manager)
|
||||
parse_stake_set_lockup(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("stake-account", Some(matches)) => parse_show_stake_account(matches, wallet_manager),
|
||||
("stake-history", Some(matches)) => parse_show_stake_history(matches),
|
||||
// Validator Info Commands
|
||||
("validator-info", Some(matches)) => match matches.subcommand() {
|
||||
("publish", Some(matches)) => {
|
||||
parse_validator_info_command(matches, default_signer_path, wallet_manager)
|
||||
parse_validator_info_command(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("get", Some(matches)) => parse_get_validator_info_command(matches),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
// Vote Commands
|
||||
("create-vote-account", Some(matches)) => {
|
||||
parse_create_vote_account(matches, default_signer_path, wallet_manager)
|
||||
parse_create_vote_account(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("vote-update-validator", Some(matches)) => {
|
||||
parse_vote_update_validator(matches, default_signer_path, wallet_manager)
|
||||
parse_vote_update_validator(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("vote-update-commission", Some(matches)) => {
|
||||
parse_vote_update_commission(matches, default_signer_path, wallet_manager)
|
||||
parse_vote_update_commission(matches, default_signer, wallet_manager)
|
||||
}
|
||||
("vote-authorize-voter", Some(matches)) => parse_vote_authorize(
|
||||
matches,
|
||||
default_signer_path,
|
||||
default_signer,
|
||||
wallet_manager,
|
||||
VoteAuthorize::Voter,
|
||||
),
|
||||
("vote-authorize-withdrawer", Some(matches)) => parse_vote_authorize(
|
||||
matches,
|
||||
default_signer_path,
|
||||
default_signer,
|
||||
wallet_manager,
|
||||
VoteAuthorize::Withdrawer,
|
||||
),
|
||||
("vote-account", Some(matches)) => parse_vote_get_account_command(matches, wallet_manager),
|
||||
("withdraw-from-vote-account", Some(matches)) => {
|
||||
parse_withdraw_from_vote_account(matches, default_signer_path, wallet_manager)
|
||||
parse_withdraw_from_vote_account(matches, default_signer, wallet_manager)
|
||||
}
|
||||
// Wallet Commands
|
||||
("address", Some(matches)) => Ok(CliCommandInfo {
|
||||
command: CliCommand::Address,
|
||||
signers: vec![signer_from_path(
|
||||
matches,
|
||||
default_signer_path,
|
||||
"keypair",
|
||||
wallet_manager,
|
||||
)?],
|
||||
signers: vec![default_signer.signer_from_path(matches, wallet_manager)?],
|
||||
}),
|
||||
("airdrop", Some(matches)) => {
|
||||
let faucet_port = matches
|
||||
|
@ -753,12 +755,7 @@ pub fn parse_command(
|
|||
let signers = if pubkey.is_some() {
|
||||
vec![]
|
||||
} else {
|
||||
vec![signer_from_path(
|
||||
matches,
|
||||
default_signer_path,
|
||||
"keypair",
|
||||
wallet_manager,
|
||||
)?]
|
||||
vec![default_signer.signer_from_path(matches, wallet_manager)?]
|
||||
};
|
||||
let lamports = lamports_of_sol(matches, "amount").unwrap();
|
||||
Ok(CliCommandInfo {
|
||||
|
@ -776,12 +773,7 @@ pub fn parse_command(
|
|||
let signers = if pubkey.is_some() {
|
||||
vec![]
|
||||
} else {
|
||||
vec![signer_from_path(
|
||||
matches,
|
||||
default_signer_path,
|
||||
"keypair",
|
||||
wallet_manager,
|
||||
)?]
|
||||
vec![default_signer.signer_from_path(matches, wallet_manager)?]
|
||||
};
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::Balance {
|
||||
|
@ -857,12 +849,8 @@ pub fn parse_command(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
|
||||
let signer_info = generate_unique_signers(
|
||||
bulk_signers,
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
let signer_info =
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
|
@ -911,19 +899,14 @@ pub fn get_blockhash_and_fee_calculator(
|
|||
|
||||
pub fn parse_create_address_with_seed(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let from_pubkey = pubkey_of_signer(matches, "from", wallet_manager)?;
|
||||
let signers = if from_pubkey.is_some() {
|
||||
vec![]
|
||||
} else {
|
||||
vec![signer_from_path(
|
||||
matches,
|
||||
default_signer_path,
|
||||
"keypair",
|
||||
wallet_manager,
|
||||
)?]
|
||||
vec![default_signer.signer_from_path(matches, wallet_manager)?]
|
||||
};
|
||||
|
||||
let program_id = match matches.value_of("program_id").unwrap() {
|
||||
|
@ -2349,13 +2332,19 @@ mod tests {
|
|||
let default_keypair_file = make_tmp_path("keypair_file");
|
||||
write_keypair_file(&default_keypair, &default_keypair_file).unwrap();
|
||||
|
||||
let signer_info =
|
||||
generate_unique_signers(vec![], &matches, &default_keypair_file, &mut None).unwrap();
|
||||
let default_signer = DefaultSigner {
|
||||
arg_name: "keypair".to_string(),
|
||||
path: default_keypair_file,
|
||||
};
|
||||
|
||||
let signer_info = default_signer
|
||||
.generate_unique_signers(vec![], &matches, &mut None)
|
||||
.unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 0);
|
||||
|
||||
let signer_info =
|
||||
generate_unique_signers(vec![None, None], &matches, &default_keypair_file, &mut None)
|
||||
.unwrap();
|
||||
let signer_info = default_signer
|
||||
.generate_unique_signers(vec![None, None], &matches, &mut None)
|
||||
.unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 1);
|
||||
assert_eq!(signer_info.index_of(None), Some(0));
|
||||
assert_eq!(signer_info.index_of(Some(Pubkey::new_rand())), None);
|
||||
|
@ -2365,8 +2354,9 @@ mod tests {
|
|||
let keypair0_clone = keypair_from_seed(&[1u8; 32]).unwrap();
|
||||
let keypair0_clone_pubkey = keypair0.pubkey();
|
||||
let signers = vec![None, Some(keypair0.into()), Some(keypair0_clone.into())];
|
||||
let signer_info =
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, &mut None).unwrap();
|
||||
let signer_info = default_signer
|
||||
.generate_unique_signers(signers, &matches, &mut None)
|
||||
.unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 2);
|
||||
assert_eq!(signer_info.index_of(None), Some(0));
|
||||
assert_eq!(signer_info.index_of(Some(keypair0_pubkey)), Some(1));
|
||||
|
@ -2376,8 +2366,9 @@ mod tests {
|
|||
let keypair0_pubkey = keypair0.pubkey();
|
||||
let keypair0_clone = keypair_from_seed(&[1u8; 32]).unwrap();
|
||||
let signers = vec![Some(keypair0.into()), Some(keypair0_clone.into())];
|
||||
let signer_info =
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, &mut None).unwrap();
|
||||
let signer_info = default_signer
|
||||
.generate_unique_signers(signers, &matches, &mut None)
|
||||
.unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 1);
|
||||
assert_eq!(signer_info.index_of(Some(keypair0_pubkey)), Some(0));
|
||||
|
||||
|
@ -2397,8 +2388,9 @@ mod tests {
|
|||
Some(presigner1.into()),
|
||||
Some(keypair1.into()),
|
||||
];
|
||||
let signer_info =
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, &mut None).unwrap();
|
||||
let signer_info = default_signer
|
||||
.generate_unique_signers(signers, &matches, &mut None)
|
||||
.unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 2);
|
||||
assert_eq!(signer_info.index_of(Some(keypair0_pubkey)), Some(0));
|
||||
assert_eq!(signer_info.index_of(Some(keypair1_pubkey)), Some(1));
|
||||
|
@ -2414,13 +2406,21 @@ mod tests {
|
|||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey_string = format!("{}", pubkey);
|
||||
|
||||
let default_keypair = Keypair::new();
|
||||
let keypair_file = make_tmp_path("keypair_file");
|
||||
write_keypair_file(&default_keypair, &keypair_file).unwrap();
|
||||
let keypair = read_keypair_file(&keypair_file).unwrap();
|
||||
let default_signer = DefaultSigner {
|
||||
path: keypair_file.clone(),
|
||||
arg_name: "".to_string(),
|
||||
};
|
||||
// Test Airdrop Subcommand
|
||||
let test_airdrop =
|
||||
test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "airdrop", "50", &pubkey_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_airdrop, "", &mut None).unwrap(),
|
||||
parse_command(&test_airdrop, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Airdrop {
|
||||
faucet_host: None,
|
||||
|
@ -2433,17 +2433,13 @@ mod tests {
|
|||
);
|
||||
|
||||
// Test Balance Subcommand, incl pubkey and keypair-file inputs
|
||||
let default_keypair = Keypair::new();
|
||||
let keypair_file = make_tmp_path("keypair_file");
|
||||
write_keypair_file(&default_keypair, &keypair_file).unwrap();
|
||||
let keypair = read_keypair_file(&keypair_file).unwrap();
|
||||
let test_balance = test_commands.clone().get_matches_from(vec![
|
||||
"test",
|
||||
"balance",
|
||||
&keypair.pubkey().to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_balance, "", &mut None).unwrap(),
|
||||
parse_command(&test_balance, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Balance {
|
||||
pubkey: Some(keypair.pubkey()),
|
||||
|
@ -2459,7 +2455,7 @@ mod tests {
|
|||
"--lamports",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_balance, "", &mut None).unwrap(),
|
||||
parse_command(&test_balance, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Balance {
|
||||
pubkey: Some(keypair.pubkey()),
|
||||
|
@ -2473,7 +2469,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "balance", "--lamports"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_balance, &keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_balance, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Balance {
|
||||
pubkey: None,
|
||||
|
@ -2491,7 +2487,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "confirm", &signature_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_confirm, "", &mut None).unwrap(),
|
||||
parse_command(&test_confirm, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Confirm(signature),
|
||||
signers: vec![],
|
||||
|
@ -2500,7 +2496,7 @@ mod tests {
|
|||
let test_bad_signature = test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "confirm", "deadbeef"]);
|
||||
assert!(parse_command(&test_bad_signature, "", &mut None).is_err());
|
||||
assert!(parse_command(&test_bad_signature, &default_signer, &mut None).is_err());
|
||||
|
||||
// Test CreateAddressWithSeed
|
||||
let from_pubkey = Some(Pubkey::new_rand());
|
||||
|
@ -2519,7 +2515,7 @@ mod tests {
|
|||
&from_str,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_address_with_seed, "", &mut None).unwrap(),
|
||||
parse_command(&test_create_address_with_seed, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateAddressWithSeed {
|
||||
from_pubkey,
|
||||
|
@ -2537,7 +2533,7 @@ mod tests {
|
|||
"STAKE",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_address_with_seed, &keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_address_with_seed, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateAddressWithSeed {
|
||||
from_pubkey: None,
|
||||
|
@ -2554,7 +2550,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "deploy", "/Users/test/program.o"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deploy, &keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deploy, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Deploy {
|
||||
program_location: "/Users/test/program.o".to_string(),
|
||||
|
@ -2575,7 +2571,7 @@ mod tests {
|
|||
&custom_address_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deploy, &keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deploy, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Deploy {
|
||||
program_location: "/Users/test/program.o".to_string(),
|
||||
|
@ -2595,7 +2591,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "resolve-signer", &keypair_file]);
|
||||
assert_eq!(
|
||||
parse_command(&test_resolve_signer, "", &mut None).unwrap(),
|
||||
parse_command(&test_resolve_signer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ResolveSigner(Some(keypair_file.clone())),
|
||||
signers: vec![],
|
||||
|
@ -2607,7 +2603,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "resolve-signer", &pubkey_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_resolve_signer, "", &mut None).unwrap(),
|
||||
parse_command(&test_resolve_signer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ResolveSigner(Some(pubkey.to_string())),
|
||||
signers: vec![],
|
||||
|
@ -2915,6 +2911,10 @@ mod tests {
|
|||
let default_keypair = Keypair::new();
|
||||
let default_keypair_file = make_tmp_path("keypair_file");
|
||||
write_keypair_file(&default_keypair, &default_keypair_file).unwrap();
|
||||
let default_signer = DefaultSigner {
|
||||
path: default_keypair_file.clone(),
|
||||
arg_name: "".to_string(),
|
||||
};
|
||||
|
||||
//Test Transfer Subcommand, SOL
|
||||
let from_keypair = keypair_from_seed(&[0u8; 32]).unwrap();
|
||||
|
@ -2927,7 +2927,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "transfer", &to_string, "42"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_transfer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
amount: SpendAmount::Some(42_000_000_000),
|
||||
|
@ -2949,7 +2949,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "transfer", &to_string, "ALL"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_transfer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
amount: SpendAmount::All,
|
||||
|
@ -2975,7 +2975,7 @@ mod tests {
|
|||
"42",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_transfer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
amount: SpendAmount::Some(42_000_000_000),
|
||||
|
@ -3005,7 +3005,7 @@ mod tests {
|
|||
"--sign-only",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_transfer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
amount: SpendAmount::Some(42_000_000_000),
|
||||
|
@ -3040,7 +3040,7 @@ mod tests {
|
|||
&blockhash_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_transfer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
amount: SpendAmount::Some(42_000_000_000),
|
||||
|
@ -3079,7 +3079,7 @@ mod tests {
|
|||
&nonce_authority_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_transfer, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
amount: SpendAmount::Some(42_000_000_000),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
|
||||
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, DefaultSigner, ProcessResult},
|
||||
cli_output::*,
|
||||
display::{
|
||||
format_labeled_address, new_spinner_progress_bar, println_name_value, println_transaction,
|
||||
|
@ -8,9 +8,7 @@ use crate::{
|
|||
};
|
||||
use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
|
||||
use console::{style, Emoji};
|
||||
use solana_clap_utils::{
|
||||
commitment::commitment_arg, input_parsers::*, input_validators::*, keypair::signer_from_path,
|
||||
};
|
||||
use solana_clap_utils::{commitment::commitment_arg, input_parsers::*, input_validators::*};
|
||||
use solana_client::{
|
||||
pubsub_client::PubsubClient,
|
||||
rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient},
|
||||
|
@ -332,7 +330,7 @@ pub fn parse_catchup(
|
|||
|
||||
pub fn parse_cluster_ping(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let lamports = value_t_or_exit!(matches, "lamports", u64);
|
||||
|
@ -350,12 +348,7 @@ pub fn parse_cluster_ping(
|
|||
count,
|
||||
timeout,
|
||||
},
|
||||
signers: vec![signer_from_path(
|
||||
matches,
|
||||
default_signer_path,
|
||||
"keypair",
|
||||
wallet_manager,
|
||||
)?],
|
||||
signers: vec![default_signer.signer_from_path(matches, wallet_manager)?],
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1480,12 +1473,16 @@ mod tests {
|
|||
let default_keypair = Keypair::new();
|
||||
let (default_keypair_file, mut tmp_file) = make_tmp_file();
|
||||
write_keypair(&default_keypair, tmp_file.as_file_mut()).unwrap();
|
||||
let default_signer = DefaultSigner {
|
||||
path: default_keypair_file,
|
||||
arg_name: String::new(),
|
||||
};
|
||||
|
||||
let test_cluster_version = test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "cluster-date"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_cluster_version, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_cluster_version, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ClusterDate,
|
||||
signers: vec![],
|
||||
|
@ -1496,7 +1493,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "cluster-version"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_cluster_version, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_cluster_version, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ClusterVersion,
|
||||
signers: vec![],
|
||||
|
@ -1505,7 +1502,7 @@ mod tests {
|
|||
|
||||
let test_fees = test_commands.clone().get_matches_from(vec!["test", "fees"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_fees, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_fees, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Fees,
|
||||
signers: vec![],
|
||||
|
@ -1518,7 +1515,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "block-time", &slot.to_string()]);
|
||||
assert_eq!(
|
||||
parse_command(&test_get_block_time, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_get_block_time, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::GetBlockTime { slot: Some(slot) },
|
||||
signers: vec![],
|
||||
|
@ -1529,7 +1526,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "epoch"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_get_epoch, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_get_epoch, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::GetEpoch,
|
||||
signers: vec![],
|
||||
|
@ -1540,7 +1537,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "epoch-info"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_get_epoch_info, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_get_epoch_info, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::GetEpochInfo,
|
||||
signers: vec![],
|
||||
|
@ -1551,7 +1548,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "genesis-hash"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_get_genesis_hash, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_get_genesis_hash, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::GetGenesisHash,
|
||||
signers: vec![],
|
||||
|
@ -1560,7 +1557,7 @@ mod tests {
|
|||
|
||||
let test_get_slot = test_commands.clone().get_matches_from(vec!["test", "slot"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_get_slot, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_get_slot, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::GetSlot,
|
||||
signers: vec![],
|
||||
|
@ -1571,7 +1568,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "total-supply"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_total_supply, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_total_supply, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::TotalSupply,
|
||||
signers: vec![],
|
||||
|
@ -1582,7 +1579,7 @@ mod tests {
|
|||
.clone()
|
||||
.get_matches_from(vec!["test", "transaction-count"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transaction_count, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_transaction_count, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::GetTransactionCount,
|
||||
signers: vec![],
|
||||
|
@ -1602,7 +1599,7 @@ mod tests {
|
|||
"max",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_ping, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_ping, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Ping {
|
||||
lamports: 1,
|
||||
|
|
|
@ -10,7 +10,7 @@ use solana_clap_utils::{
|
|||
};
|
||||
use solana_cli::{
|
||||
cli::{
|
||||
app, parse_command, process_command, CliCommandInfo, CliConfig, CliSigners,
|
||||
app, parse_command, process_command, CliCommandInfo, CliConfig, CliSigners, DefaultSigner,
|
||||
DEFAULT_RPC_TIMEOUT_SECONDS,
|
||||
},
|
||||
cli_output::OutputFormat,
|
||||
|
@ -139,13 +139,19 @@ pub fn parse_args<'a>(
|
|||
matches.value_of("json_rpc_url").unwrap_or(""),
|
||||
&config.json_rpc_url,
|
||||
);
|
||||
let default_signer_arg_name = "keypair".to_string();
|
||||
let (_, default_signer_path) = CliConfig::compute_keypair_path_setting(
|
||||
matches.value_of("keypair").unwrap_or(""),
|
||||
matches.value_of(&default_signer_arg_name).unwrap_or(""),
|
||||
&config.keypair_path,
|
||||
);
|
||||
|
||||
let default_signer = DefaultSigner {
|
||||
arg_name: default_signer_arg_name,
|
||||
path: default_signer_path.clone(),
|
||||
};
|
||||
|
||||
let CliCommandInfo { command, signers } =
|
||||
parse_command(&matches, &default_signer_path, &mut wallet_manager)?;
|
||||
parse_command(&matches, &default_signer, &mut wallet_manager)?;
|
||||
|
||||
let output_format = matches
|
||||
.value_of("output_format")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{
|
||||
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
|
||||
cli::{
|
||||
generate_unique_signers, log_instruction_custom_error, CliCommand, CliCommandInfo,
|
||||
CliConfig, CliError, ProcessResult, SignerIndex,
|
||||
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
|
||||
DefaultSigner, ProcessResult, SignerIndex,
|
||||
},
|
||||
cli_output::CliNonceAccount,
|
||||
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
|
||||
|
@ -161,7 +161,7 @@ impl NonceSubCommands for App<'_, '_> {
|
|||
|
||||
pub fn parse_authorize_nonce_account(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
|
||||
|
@ -170,10 +170,9 @@ pub fn parse_authorize_nonce_account(
|
|||
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, nonce_authority],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -189,7 +188,7 @@ pub fn parse_authorize_nonce_account(
|
|||
|
||||
pub fn parse_nonce_create_account(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let (nonce_account, nonce_account_pubkey) =
|
||||
|
@ -199,10 +198,9 @@ pub fn parse_nonce_create_account(
|
|||
let nonce_authority = pubkey_of_signer(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, nonce_account],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -232,7 +230,7 @@ pub fn parse_get_nonce(
|
|||
|
||||
pub fn parse_new_nonce(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
|
||||
|
@ -240,10 +238,9 @@ pub fn parse_new_nonce(
|
|||
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, nonce_authority],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -275,7 +272,7 @@ pub fn parse_show_nonce_account(
|
|||
|
||||
pub fn parse_withdraw_from_nonce_account(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let nonce_account = pubkey_of_signer(matches, "nonce_account_pubkey", wallet_manager)?.unwrap();
|
||||
|
@ -286,10 +283,9 @@ pub fn parse_withdraw_from_nonce_account(
|
|||
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, nonce_authority],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -595,6 +591,10 @@ mod tests {
|
|||
let default_keypair = Keypair::new();
|
||||
let (default_keypair_file, mut tmp_file) = make_tmp_file();
|
||||
write_keypair(&default_keypair, tmp_file.as_file_mut()).unwrap();
|
||||
let default_signer = DefaultSigner {
|
||||
path: default_keypair_file.clone(),
|
||||
arg_name: String::new(),
|
||||
};
|
||||
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||
let nonce_account_keypair = Keypair::new();
|
||||
write_keypair(&nonce_account_keypair, tmp_file.as_file_mut()).unwrap();
|
||||
|
@ -613,12 +613,7 @@ mod tests {
|
|||
&Pubkey::default().to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(
|
||||
&test_authorize_nonce_account,
|
||||
&default_keypair_file,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
parse_command(&test_authorize_nonce_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::AuthorizeNonceAccount {
|
||||
nonce_account: nonce_account_pubkey,
|
||||
|
@ -639,12 +634,7 @@ mod tests {
|
|||
&authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(
|
||||
&test_authorize_nonce_account,
|
||||
&default_keypair_file,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
parse_command(&test_authorize_nonce_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::AuthorizeNonceAccount {
|
||||
nonce_account: read_keypair_file(&keypair_file).unwrap().pubkey(),
|
||||
|
@ -666,7 +656,7 @@ mod tests {
|
|||
"50",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_nonce_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_nonce_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateNonceAccount {
|
||||
nonce_account: 1,
|
||||
|
@ -691,7 +681,7 @@ mod tests {
|
|||
&authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_nonce_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_nonce_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateNonceAccount {
|
||||
nonce_account: 1,
|
||||
|
@ -713,7 +703,7 @@ mod tests {
|
|||
&nonce_account_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_get_nonce, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_get_nonce, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::GetNonce(nonce_account_keypair.pubkey()),
|
||||
signers: vec![],
|
||||
|
@ -727,7 +717,7 @@ mod tests {
|
|||
.get_matches_from(vec!["test", "new-nonce", &keypair_file]);
|
||||
let nonce_account = read_keypair_file(&keypair_file).unwrap();
|
||||
assert_eq!(
|
||||
parse_command(&test_new_nonce, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_new_nonce, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::NewNonce {
|
||||
nonce_account: nonce_account.pubkey(),
|
||||
|
@ -747,7 +737,7 @@ mod tests {
|
|||
]);
|
||||
let nonce_account = read_keypair_file(&keypair_file).unwrap();
|
||||
assert_eq!(
|
||||
parse_command(&test_new_nonce, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_new_nonce, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::NewNonce {
|
||||
nonce_account: nonce_account.pubkey(),
|
||||
|
@ -767,7 +757,7 @@ mod tests {
|
|||
&nonce_account_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_show_nonce_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_show_nonce_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ShowNonceAccount {
|
||||
nonce_account_pubkey: nonce_account_keypair.pubkey(),
|
||||
|
@ -788,7 +778,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
parse_command(
|
||||
&test_withdraw_from_nonce_account,
|
||||
&default_keypair_file,
|
||||
&default_signer,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
|
@ -816,7 +806,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
parse_command(
|
||||
&test_withdraw_from_nonce_account,
|
||||
&default_keypair_file,
|
||||
&default_signer,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
|
|
130
cli/src/stake.rs
130
cli/src/stake.rs
|
@ -1,8 +1,8 @@
|
|||
use crate::{
|
||||
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
|
||||
cli::{
|
||||
generate_unique_signers, log_instruction_custom_error, CliCommand, CliCommandInfo,
|
||||
CliConfig, CliError, ProcessResult, SignerIndex,
|
||||
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
|
||||
DefaultSigner, ProcessResult, SignerIndex,
|
||||
},
|
||||
cli_output::{CliStakeHistory, CliStakeHistoryEntry, CliStakeState, CliStakeType},
|
||||
nonce::check_nonce_account,
|
||||
|
@ -411,7 +411,7 @@ impl StakeSubCommands for App<'_, '_> {
|
|||
|
||||
pub fn parse_stake_create_account(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let seed = matches.value_of("seed").map(|s| s.to_string());
|
||||
|
@ -436,7 +436,7 @@ pub fn parse_stake_create_account(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::CreateStakeAccount {
|
||||
|
@ -463,7 +463,7 @@ pub fn parse_stake_create_account(
|
|||
|
||||
pub fn parse_stake_delegate_stake(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let stake_account_pubkey =
|
||||
|
@ -485,7 +485,7 @@ pub fn parse_stake_delegate_stake(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
|
@ -505,7 +505,7 @@ pub fn parse_stake_delegate_stake(
|
|||
|
||||
pub fn parse_stake_authorize(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let stake_account_pubkey =
|
||||
|
@ -557,7 +557,7 @@ pub fn parse_stake_authorize(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
let new_authorizations = new_authorizations
|
||||
.into_iter()
|
||||
|
@ -588,7 +588,7 @@ pub fn parse_stake_authorize(
|
|||
|
||||
pub fn parse_split_stake(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let stake_account_pubkey =
|
||||
|
@ -612,7 +612,7 @@ pub fn parse_split_stake(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::SplitStake {
|
||||
|
@ -633,7 +633,7 @@ pub fn parse_split_stake(
|
|||
|
||||
pub fn parse_merge_stake(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let stake_account_pubkey =
|
||||
|
@ -655,7 +655,7 @@ pub fn parse_merge_stake(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::MergeStake {
|
||||
|
@ -674,7 +674,7 @@ pub fn parse_merge_stake(
|
|||
|
||||
pub fn parse_stake_deactivate_stake(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let stake_account_pubkey =
|
||||
|
@ -693,7 +693,7 @@ pub fn parse_stake_deactivate_stake(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
|
@ -711,7 +711,7 @@ pub fn parse_stake_deactivate_stake(
|
|||
|
||||
pub fn parse_stake_withdraw_stake(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let stake_account_pubkey =
|
||||
|
@ -737,7 +737,7 @@ pub fn parse_stake_withdraw_stake(
|
|||
bulk_signers.push(custodian);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::WithdrawStake {
|
||||
|
@ -758,7 +758,7 @@ pub fn parse_stake_withdraw_stake(
|
|||
|
||||
pub fn parse_stake_set_lockup(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let stake_account_pubkey =
|
||||
|
@ -781,7 +781,7 @@ pub fn parse_stake_set_lockup(
|
|||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
let signer_info =
|
||||
generate_unique_signers(bulk_signers, matches, default_signer_path, wallet_manager)?;
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::StakeSetLockup {
|
||||
|
@ -1793,6 +1793,10 @@ mod tests {
|
|||
let default_keypair = Keypair::new();
|
||||
let (default_keypair_file, mut tmp_file) = make_tmp_file();
|
||||
write_keypair(&default_keypair, tmp_file.as_file_mut()).unwrap();
|
||||
let default_signer = DefaultSigner {
|
||||
path: default_keypair_file.clone(),
|
||||
arg_name: String::new(),
|
||||
};
|
||||
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||
let stake_account_keypair = Keypair::new();
|
||||
write_keypair(&stake_account_keypair, tmp_file.as_file_mut()).unwrap();
|
||||
|
@ -1820,7 +1824,7 @@ mod tests {
|
|||
&new_withdraw_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -1854,7 +1858,7 @@ mod tests {
|
|||
&withdraw_authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -1892,7 +1896,7 @@ mod tests {
|
|||
&withdraw_authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -1922,7 +1926,7 @@ mod tests {
|
|||
&new_stake_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -1946,7 +1950,7 @@ mod tests {
|
|||
&stake_authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -1976,7 +1980,7 @@ mod tests {
|
|||
&withdraw_authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2003,7 +2007,7 @@ mod tests {
|
|||
&new_withdraw_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2031,7 +2035,7 @@ mod tests {
|
|||
&withdraw_authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_stake_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_stake_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2069,7 +2073,7 @@ mod tests {
|
|||
"--sign-only",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2102,7 +2106,7 @@ mod tests {
|
|||
&pubkey.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2148,7 +2152,7 @@ mod tests {
|
|||
&pubkey2.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2180,7 +2184,7 @@ mod tests {
|
|||
&blockhash_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2217,7 +2221,7 @@ mod tests {
|
|||
&nonce_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2253,7 +2257,7 @@ mod tests {
|
|||
&fee_payer_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2287,7 +2291,7 @@ mod tests {
|
|||
&signer,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::StakeAuthorize {
|
||||
stake_account_pubkey,
|
||||
|
@ -2328,7 +2332,7 @@ mod tests {
|
|||
"43",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_stake_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_stake_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateStakeAccount {
|
||||
stake_account: 1,
|
||||
|
@ -2369,12 +2373,7 @@ mod tests {
|
|||
]);
|
||||
|
||||
assert_eq!(
|
||||
parse_command(
|
||||
&test_create_stake_account2,
|
||||
&default_keypair_file,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
parse_command(&test_create_stake_account2, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateStakeAccount {
|
||||
stake_account: 1,
|
||||
|
@ -2427,12 +2426,7 @@ mod tests {
|
|||
]);
|
||||
|
||||
assert_eq!(
|
||||
parse_command(
|
||||
&test_create_stake_account2,
|
||||
&default_keypair_file,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
parse_command(&test_create_stake_account2, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateStakeAccount {
|
||||
stake_account: 1,
|
||||
|
@ -2468,7 +2462,7 @@ mod tests {
|
|||
&vote_account_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2497,7 +2491,7 @@ mod tests {
|
|||
&stake_authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2528,7 +2522,7 @@ mod tests {
|
|||
&vote_account_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2557,7 +2551,7 @@ mod tests {
|
|||
&blockhash_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2587,7 +2581,7 @@ mod tests {
|
|||
"--sign-only",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2621,7 +2615,7 @@ mod tests {
|
|||
&key1.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2667,7 +2661,7 @@ mod tests {
|
|||
&key2.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2704,7 +2698,7 @@ mod tests {
|
|||
&fee_payer_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_delegate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_delegate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DelegateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2734,7 +2728,7 @@ mod tests {
|
|||
]);
|
||||
|
||||
assert_eq!(
|
||||
parse_command(&test_withdraw_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_withdraw_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::WithdrawStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2764,7 +2758,7 @@ mod tests {
|
|||
]);
|
||||
|
||||
assert_eq!(
|
||||
parse_command(&test_withdraw_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_withdraw_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::WithdrawStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2799,7 +2793,7 @@ mod tests {
|
|||
]);
|
||||
|
||||
assert_eq!(
|
||||
parse_command(&test_withdraw_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_withdraw_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::WithdrawStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2842,7 +2836,7 @@ mod tests {
|
|||
]);
|
||||
|
||||
assert_eq!(
|
||||
parse_command(&test_withdraw_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_withdraw_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::WithdrawStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2875,7 +2869,7 @@ mod tests {
|
|||
&stake_account_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deactivate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deactivate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2899,7 +2893,7 @@ mod tests {
|
|||
&stake_authority_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deactivate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deactivate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2930,7 +2924,7 @@ mod tests {
|
|||
&blockhash_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deactivate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deactivate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2957,7 +2951,7 @@ mod tests {
|
|||
"--sign-only",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deactivate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deactivate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -2988,7 +2982,7 @@ mod tests {
|
|||
&key1.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deactivate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deactivate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -3031,7 +3025,7 @@ mod tests {
|
|||
&key2.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deactivate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deactivate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -3062,7 +3056,7 @@ mod tests {
|
|||
&fee_payer_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deactivate_stake, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_deactivate_stake, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::DeactivateStake {
|
||||
stake_account_pubkey,
|
||||
|
@ -3096,7 +3090,7 @@ mod tests {
|
|||
"50",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_split_stake_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_split_stake_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::SplitStake {
|
||||
stake_account_pubkey: stake_account_keypair.pubkey(),
|
||||
|
@ -3157,7 +3151,7 @@ mod tests {
|
|||
&stake_signer,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_split_stake_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_split_stake_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::SplitStake {
|
||||
stake_account_pubkey: stake_account_keypair.pubkey(),
|
||||
|
@ -3197,7 +3191,7 @@ mod tests {
|
|||
&source_stake_account_pubkey.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_merge_stake_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_merge_stake_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::MergeStake {
|
||||
stake_account_pubkey: stake_account_keypair.pubkey(),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
|
||||
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, DefaultSigner, ProcessResult},
|
||||
cli_output::{CliValidatorInfo, CliValidatorInfoVec},
|
||||
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
|
||||
};
|
||||
|
@ -13,7 +13,6 @@ use solana_account_decoder::validator_info::{
|
|||
use solana_clap_utils::{
|
||||
input_parsers::pubkey_of,
|
||||
input_validators::{is_pubkey, is_url},
|
||||
keypair::signer_from_path,
|
||||
};
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_config_program::{config_instruction, get_config_data, ConfigKeys, ConfigState};
|
||||
|
@ -212,7 +211,7 @@ impl ValidatorInfoSubCommands for App<'_, '_> {
|
|||
|
||||
pub fn parse_validator_info_command(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let info_pubkey = pubkey_of(matches, "info_pubkey");
|
||||
|
@ -224,12 +223,7 @@ pub fn parse_validator_info_command(
|
|||
force_keybase: matches.is_present("force"),
|
||||
info_pubkey,
|
||||
},
|
||||
signers: vec![signer_from_path(
|
||||
matches,
|
||||
default_signer_path,
|
||||
"keypair",
|
||||
wallet_manager,
|
||||
)?],
|
||||
signers: vec![default_signer.signer_from_path(matches, wallet_manager)?],
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{
|
||||
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
|
||||
cli::{
|
||||
generate_unique_signers, log_instruction_custom_error, CliCommand, CliCommandInfo,
|
||||
CliConfig, CliError, ProcessResult, SignerIndex,
|
||||
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
|
||||
DefaultSigner, ProcessResult, SignerIndex,
|
||||
},
|
||||
cli_output::{CliEpochVotingHistory, CliLockout, CliVoteAccount},
|
||||
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
|
||||
|
@ -246,7 +246,7 @@ impl VoteSubCommands for App<'_, '_> {
|
|||
|
||||
pub fn parse_create_vote_account(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let (vote_account, vote_account_pubkey) = signer_of(matches, "vote_account", wallet_manager)?;
|
||||
|
@ -258,10 +258,9 @@ pub fn parse_create_vote_account(
|
|||
let authorized_withdrawer = pubkey_of_signer(matches, "authorized_withdrawer", wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, vote_account, identity_account],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -280,7 +279,7 @@ pub fn parse_create_vote_account(
|
|||
|
||||
pub fn parse_vote_authorize(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
vote_authorize: VoteAuthorize,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
|
@ -291,10 +290,9 @@ pub fn parse_vote_authorize(
|
|||
let (authorized, _) = signer_of(matches, "authorized", wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, authorized],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -310,7 +308,7 @@ pub fn parse_vote_authorize(
|
|||
|
||||
pub fn parse_vote_update_validator(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let vote_account_pubkey =
|
||||
|
@ -321,10 +319,9 @@ pub fn parse_vote_update_validator(
|
|||
signer_of(matches, "authorized_withdrawer", wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, authorized_withdrawer, new_identity_account],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -340,7 +337,7 @@ pub fn parse_vote_update_validator(
|
|||
|
||||
pub fn parse_vote_update_commission(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let vote_account_pubkey =
|
||||
|
@ -350,10 +347,9 @@ pub fn parse_vote_update_commission(
|
|||
let commission = value_t_or_exit!(matches, "commission", u8);
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, authorized_withdrawer],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -385,7 +381,7 @@ pub fn parse_vote_get_account_command(
|
|||
|
||||
pub fn parse_withdraw_from_vote_account(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
default_signer: &DefaultSigner,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let vote_account_pubkey =
|
||||
|
@ -398,10 +394,9 @@ pub fn parse_withdraw_from_vote_account(
|
|||
signer_of(matches, "authorized_withdrawer", wallet_manager)?;
|
||||
|
||||
let payer_provided = None;
|
||||
let signer_info = generate_unique_signers(
|
||||
let signer_info = default_signer.generate_unique_signers(
|
||||
vec![payer_provided, withdraw_authority],
|
||||
matches,
|
||||
default_signer_path,
|
||||
wallet_manager,
|
||||
)?;
|
||||
|
||||
|
@ -794,6 +789,10 @@ mod tests {
|
|||
let default_keypair = Keypair::new();
|
||||
let (default_keypair_file, mut tmp_file) = make_tmp_file();
|
||||
write_keypair(&default_keypair, tmp_file.as_file_mut()).unwrap();
|
||||
let default_signer = DefaultSigner {
|
||||
path: default_keypair_file.clone(),
|
||||
arg_name: String::new(),
|
||||
};
|
||||
|
||||
let test_authorize_voter = test_commands.clone().get_matches_from(vec![
|
||||
"test",
|
||||
|
@ -803,7 +802,7 @@ mod tests {
|
|||
&pubkey2_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize_voter, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize_voter, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::VoteAuthorize {
|
||||
vote_account_pubkey: pubkey,
|
||||
|
@ -826,7 +825,7 @@ mod tests {
|
|||
&pubkey2_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_authorize_voter, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_authorize_voter, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::VoteAuthorize {
|
||||
vote_account_pubkey: pubkey,
|
||||
|
@ -856,7 +855,7 @@ mod tests {
|
|||
"10",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_vote_account, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_vote_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: 1,
|
||||
|
@ -885,7 +884,7 @@ mod tests {
|
|||
&identity_keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_vote_account2, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_vote_account2, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: 1,
|
||||
|
@ -918,7 +917,7 @@ mod tests {
|
|||
&authed.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_vote_account3, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_vote_account3, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: 1,
|
||||
|
@ -949,7 +948,7 @@ mod tests {
|
|||
&authed.to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_vote_account4, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_create_vote_account4, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: 1,
|
||||
|
@ -975,7 +974,7 @@ mod tests {
|
|||
&keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_update_validator, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_update_validator, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::VoteUpdateValidator {
|
||||
vote_account_pubkey: pubkey,
|
||||
|
@ -998,7 +997,7 @@ mod tests {
|
|||
&keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_update_commission, &default_keypair_file, &mut None).unwrap(),
|
||||
parse_command(&test_update_commission, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::VoteUpdateCommission {
|
||||
vote_account_pubkey: pubkey,
|
||||
|
@ -1021,12 +1020,7 @@ mod tests {
|
|||
"42",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(
|
||||
&test_withdraw_from_vote_account,
|
||||
&default_keypair_file,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
parse_command(&test_withdraw_from_vote_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::WithdrawFromVoteAccount {
|
||||
vote_account_pubkey: read_keypair_file(&keypair_file).unwrap().pubkey(),
|
||||
|
@ -1047,12 +1041,7 @@ mod tests {
|
|||
"ALL",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(
|
||||
&test_withdraw_from_vote_account,
|
||||
&default_keypair_file,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
parse_command(&test_withdraw_from_vote_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::WithdrawFromVoteAccount {
|
||||
vote_account_pubkey: read_keypair_file(&keypair_file).unwrap().pubkey(),
|
||||
|
@ -1078,12 +1067,7 @@ mod tests {
|
|||
&withdraw_authority_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(
|
||||
&test_withdraw_from_vote_account,
|
||||
&default_keypair_file,
|
||||
&mut None
|
||||
)
|
||||
.unwrap(),
|
||||
parse_command(&test_withdraw_from_vote_account, &default_signer, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::WithdrawFromVoteAccount {
|
||||
vote_account_pubkey: read_keypair_file(&keypair_file).unwrap().pubkey(),
|
||||
|
|
Loading…
Reference in New Issue