CLI: Fix explicitly plumb vote_account through create-vote-account
(cherry picked from commit 14ac233d01
)
This commit is contained in:
committed by
Trent Nelson
parent
006a5c5c88
commit
00916b2ca6
@ -382,6 +382,7 @@ pub enum CliCommand {
|
|||||||
},
|
},
|
||||||
// Vote Commands
|
// Vote Commands
|
||||||
CreateVoteAccount {
|
CreateVoteAccount {
|
||||||
|
vote_account: SignerIndex,
|
||||||
seed: Option<String>,
|
seed: Option<String>,
|
||||||
identity_account: SignerIndex,
|
identity_account: SignerIndex,
|
||||||
authorized_voter: Option<Pubkey>,
|
authorized_voter: Option<Pubkey>,
|
||||||
@ -2168,6 +2169,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
|
|
||||||
// Create vote account
|
// Create vote account
|
||||||
CliCommand::CreateVoteAccount {
|
CliCommand::CreateVoteAccount {
|
||||||
|
vote_account,
|
||||||
seed,
|
seed,
|
||||||
identity_account,
|
identity_account,
|
||||||
authorized_voter,
|
authorized_voter,
|
||||||
@ -2176,6 +2178,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
} => process_create_vote_account(
|
} => process_create_vote_account(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
config,
|
config,
|
||||||
|
*vote_account,
|
||||||
seed,
|
seed,
|
||||||
*identity_account,
|
*identity_account,
|
||||||
authorized_voter,
|
authorized_voter,
|
||||||
@ -3483,6 +3486,7 @@ mod tests {
|
|||||||
let bob_pubkey = bob_keypair.pubkey();
|
let bob_pubkey = bob_keypair.pubkey();
|
||||||
let identity_keypair = Keypair::new();
|
let identity_keypair = Keypair::new();
|
||||||
config.command = CliCommand::CreateVoteAccount {
|
config.command = CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 2,
|
identity_account: 2,
|
||||||
authorized_voter: Some(bob_pubkey),
|
authorized_voter: Some(bob_pubkey),
|
||||||
@ -3709,6 +3713,7 @@ mod tests {
|
|||||||
let bob_keypair = Keypair::new();
|
let bob_keypair = Keypair::new();
|
||||||
let identity_keypair = Keypair::new();
|
let identity_keypair = Keypair::new();
|
||||||
config.command = CliCommand::CreateVoteAccount {
|
config.command = CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 2,
|
identity_account: 2,
|
||||||
authorized_voter: Some(bob_pubkey),
|
authorized_voter: Some(bob_pubkey),
|
||||||
|
@ -273,7 +273,7 @@ pub fn parse_create_vote_account(
|
|||||||
default_signer_path: &str,
|
default_signer_path: &str,
|
||||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
) -> Result<CliCommandInfo, CliError> {
|
||||||
let (vote_account, _) = signer_of(matches, "vote_account", wallet_manager)?;
|
let (vote_account, vote_account_pubkey) = signer_of(matches, "vote_account", wallet_manager)?;
|
||||||
let seed = matches.value_of("seed").map(|s| s.to_string());
|
let seed = matches.value_of("seed").map(|s| s.to_string());
|
||||||
let (identity_account, identity_pubkey) =
|
let (identity_account, identity_pubkey) =
|
||||||
signer_of(matches, "identity_account", wallet_manager)?;
|
signer_of(matches, "identity_account", wallet_manager)?;
|
||||||
@ -291,6 +291,7 @@ pub fn parse_create_vote_account(
|
|||||||
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: signer_info.index_of(vote_account_pubkey).unwrap(),
|
||||||
seed,
|
seed,
|
||||||
identity_account: signer_info.index_of(identity_pubkey).unwrap(),
|
identity_account: signer_info.index_of(identity_pubkey).unwrap(),
|
||||||
authorized_voter,
|
authorized_voter,
|
||||||
@ -443,13 +444,14 @@ pub fn parse_withdraw_from_vote_account(
|
|||||||
pub fn process_create_vote_account(
|
pub fn process_create_vote_account(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &CliConfig,
|
config: &CliConfig,
|
||||||
|
vote_account: SignerIndex,
|
||||||
seed: &Option<String>,
|
seed: &Option<String>,
|
||||||
identity_account: SignerIndex,
|
identity_account: SignerIndex,
|
||||||
authorized_voter: &Option<Pubkey>,
|
authorized_voter: &Option<Pubkey>,
|
||||||
authorized_withdrawer: &Option<Pubkey>,
|
authorized_withdrawer: &Option<Pubkey>,
|
||||||
commission: u8,
|
commission: u8,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let vote_account = config.signers[1];
|
let vote_account = config.signers[vote_account];
|
||||||
let vote_account_pubkey = vote_account.pubkey();
|
let vote_account_pubkey = vote_account.pubkey();
|
||||||
let vote_account_address = if let Some(seed) = seed {
|
let vote_account_address = if let Some(seed) = seed {
|
||||||
Pubkey::create_with_seed(&vote_account_pubkey, &seed, &solana_vote_program::id())?
|
Pubkey::create_with_seed(&vote_account_pubkey, &seed, &solana_vote_program::id())?
|
||||||
@ -820,6 +822,7 @@ mod tests {
|
|||||||
parse_command(&test_create_vote_account, &default_keypair_file, &mut None).unwrap(),
|
parse_command(&test_create_vote_account, &default_keypair_file, &mut None).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 2,
|
identity_account: 2,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
@ -848,6 +851,7 @@ mod tests {
|
|||||||
parse_command(&test_create_vote_account2, &default_keypair_file, &mut None).unwrap(),
|
parse_command(&test_create_vote_account2, &default_keypair_file, &mut None).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 2,
|
identity_account: 2,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
@ -880,6 +884,7 @@ mod tests {
|
|||||||
parse_command(&test_create_vote_account3, &default_keypair_file, &mut None).unwrap(),
|
parse_command(&test_create_vote_account3, &default_keypair_file, &mut None).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 2,
|
identity_account: 2,
|
||||||
authorized_voter: Some(authed),
|
authorized_voter: Some(authed),
|
||||||
@ -910,6 +915,7 @@ mod tests {
|
|||||||
parse_command(&test_create_vote_account4, &default_keypair_file, &mut None).unwrap(),
|
parse_command(&test_create_vote_account4, &default_keypair_file, &mut None).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 2,
|
identity_account: 2,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
|
@ -68,6 +68,7 @@ fn test_stake_delegation_force() {
|
|||||||
let vote_keypair = Keypair::new();
|
let vote_keypair = Keypair::new();
|
||||||
config.signers = vec![&default_signer, &vote_keypair];
|
config.signers = vec![&default_signer, &vote_keypair];
|
||||||
config.command = CliCommand::CreateVoteAccount {
|
config.command = CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 0,
|
identity_account: 0,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
|
@ -57,6 +57,7 @@ fn test_vote_authorize_and_withdraw() {
|
|||||||
let vote_account_pubkey = vote_account_keypair.pubkey();
|
let vote_account_pubkey = vote_account_keypair.pubkey();
|
||||||
config.signers = vec![&default_signer, &vote_account_keypair];
|
config.signers = vec![&default_signer, &vote_account_keypair];
|
||||||
config.command = CliCommand::CreateVoteAccount {
|
config.command = CliCommand::CreateVoteAccount {
|
||||||
|
vote_account: 1,
|
||||||
seed: None,
|
seed: None,
|
||||||
identity_account: 0,
|
identity_account: 0,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
|
Reference in New Issue
Block a user