CLI changes required for to
account signing (#6678)
* CLI changes draft * use tempfile * remove un-necessary error handling * use keypair instead of pubkey
This commit is contained in:
@@ -43,6 +43,7 @@ url = "2.1.0"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
solana-core = { path = "../core", version = "0.21.0" }
|
solana-core = { path = "../core", version = "0.21.0" }
|
||||||
solana-budget-program = { path = "../programs/budget_program", version = "0.21.0" }
|
solana-budget-program = { path = "../programs/budget_program", version = "0.21.0" }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "solana"
|
name = "solana"
|
||||||
|
@@ -64,7 +64,7 @@ pub enum CliCommand {
|
|||||||
Deploy(String),
|
Deploy(String),
|
||||||
// Stake Commands
|
// Stake Commands
|
||||||
CreateStakeAccount {
|
CreateStakeAccount {
|
||||||
stake_account_pubkey: Pubkey,
|
stake_account: Keypair,
|
||||||
staker: Option<Pubkey>,
|
staker: Option<Pubkey>,
|
||||||
withdrawer: Option<Pubkey>,
|
withdrawer: Option<Pubkey>,
|
||||||
lockup: Lockup,
|
lockup: Lockup,
|
||||||
@@ -85,7 +85,7 @@ pub enum CliCommand {
|
|||||||
// Storage Commands
|
// Storage Commands
|
||||||
CreateStorageAccount {
|
CreateStorageAccount {
|
||||||
account_owner: Pubkey,
|
account_owner: Pubkey,
|
||||||
storage_account_pubkey: Pubkey,
|
storage_account: Keypair,
|
||||||
account_type: StorageAccountType,
|
account_type: StorageAccountType,
|
||||||
},
|
},
|
||||||
ClaimStorageReward {
|
ClaimStorageReward {
|
||||||
@@ -102,7 +102,7 @@ pub enum CliCommand {
|
|||||||
},
|
},
|
||||||
// Vote Commands
|
// Vote Commands
|
||||||
CreateVoteAccount {
|
CreateVoteAccount {
|
||||||
vote_account_pubkey: Pubkey,
|
vote_account: Keypair,
|
||||||
node_pubkey: Pubkey,
|
node_pubkey: Pubkey,
|
||||||
authorized_voter: Option<Pubkey>,
|
authorized_voter: Option<Pubkey>,
|
||||||
authorized_withdrawer: Option<Pubkey>,
|
authorized_withdrawer: Option<Pubkey>,
|
||||||
@@ -840,7 +840,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
|
|
||||||
// Create stake account
|
// Create stake account
|
||||||
CliCommand::CreateStakeAccount {
|
CliCommand::CreateStakeAccount {
|
||||||
stake_account_pubkey,
|
stake_account,
|
||||||
staker,
|
staker,
|
||||||
withdrawer,
|
withdrawer,
|
||||||
lockup,
|
lockup,
|
||||||
@@ -848,7 +848,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
} => process_create_stake_account(
|
} => process_create_stake_account(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
config,
|
config,
|
||||||
&stake_account_pubkey,
|
stake_account,
|
||||||
staker,
|
staker,
|
||||||
withdrawer,
|
withdrawer,
|
||||||
lockup,
|
lockup,
|
||||||
@@ -914,13 +914,13 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
// Create storage account
|
// Create storage account
|
||||||
CliCommand::CreateStorageAccount {
|
CliCommand::CreateStorageAccount {
|
||||||
account_owner,
|
account_owner,
|
||||||
storage_account_pubkey,
|
storage_account,
|
||||||
account_type,
|
account_type,
|
||||||
} => process_create_storage_account(
|
} => process_create_storage_account(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
config,
|
config,
|
||||||
&account_owner,
|
&account_owner,
|
||||||
&storage_account_pubkey,
|
storage_account,
|
||||||
*account_type,
|
*account_type,
|
||||||
),
|
),
|
||||||
CliCommand::ClaimStorageReward {
|
CliCommand::ClaimStorageReward {
|
||||||
@@ -959,7 +959,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
|
|
||||||
// Create vote account
|
// Create vote account
|
||||||
CliCommand::CreateVoteAccount {
|
CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey,
|
vote_account,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter,
|
authorized_voter,
|
||||||
authorized_withdrawer,
|
authorized_withdrawer,
|
||||||
@@ -967,7 +967,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
} => process_create_vote_account(
|
} => process_create_vote_account(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
config,
|
config,
|
||||||
&vote_account_pubkey,
|
vote_account,
|
||||||
&node_pubkey,
|
&node_pubkey,
|
||||||
authorized_voter,
|
authorized_voter,
|
||||||
authorized_withdrawer,
|
authorized_withdrawer,
|
||||||
@@ -1782,10 +1782,11 @@ mod tests {
|
|||||||
config.command = CliCommand::Confirm(good_signature);
|
config.command = CliCommand::Confirm(good_signature);
|
||||||
assert_eq!(process_command(&config).unwrap(), "Confirmed");
|
assert_eq!(process_command(&config).unwrap(), "Confirmed");
|
||||||
|
|
||||||
let bob_pubkey = Pubkey::new_rand();
|
let bob_keypair = Keypair::new();
|
||||||
|
let bob_pubkey = bob_keypair.pubkey();
|
||||||
let node_pubkey = Pubkey::new_rand();
|
let node_pubkey = Pubkey::new_rand();
|
||||||
config.command = CliCommand::CreateVoteAccount {
|
config.command = CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey: bob_pubkey,
|
vote_account: bob_keypair,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter: Some(bob_pubkey),
|
authorized_voter: Some(bob_pubkey),
|
||||||
authorized_withdrawer: Some(bob_pubkey),
|
authorized_withdrawer: Some(bob_pubkey),
|
||||||
@@ -1800,10 +1801,11 @@ mod tests {
|
|||||||
let signature = process_command(&config);
|
let signature = process_command(&config);
|
||||||
assert_eq!(signature.unwrap(), SIGNATURE.to_string());
|
assert_eq!(signature.unwrap(), SIGNATURE.to_string());
|
||||||
|
|
||||||
let bob_pubkey = Pubkey::new_rand();
|
let bob_keypair = Keypair::new();
|
||||||
|
let bob_pubkey = bob_keypair.pubkey();
|
||||||
let custodian = Pubkey::new_rand();
|
let custodian = Pubkey::new_rand();
|
||||||
config.command = CliCommand::CreateStakeAccount {
|
config.command = CliCommand::CreateStakeAccount {
|
||||||
stake_account_pubkey: bob_pubkey,
|
stake_account: bob_keypair,
|
||||||
staker: None,
|
staker: None,
|
||||||
withdrawer: None,
|
withdrawer: None,
|
||||||
lockup: Lockup { slot: 0, custodian },
|
lockup: Lockup { slot: 0, custodian },
|
||||||
@@ -1947,8 +1949,9 @@ mod tests {
|
|||||||
};
|
};
|
||||||
assert!(process_command(&config).is_err());
|
assert!(process_command(&config).is_err());
|
||||||
|
|
||||||
|
let bob_keypair = Keypair::new();
|
||||||
config.command = CliCommand::CreateVoteAccount {
|
config.command = CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey: bob_pubkey,
|
vote_account: bob_keypair,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter: Some(bob_pubkey),
|
authorized_voter: Some(bob_pubkey),
|
||||||
authorized_withdrawer: Some(bob_pubkey),
|
authorized_withdrawer: Some(bob_pubkey),
|
||||||
|
@@ -10,6 +10,7 @@ use crate::{
|
|||||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
use console::style;
|
use console::style;
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
|
use solana_sdk::signature::Keypair;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account_utils::State,
|
account_utils::State,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
@@ -21,9 +22,10 @@ use solana_sdk::{
|
|||||||
},
|
},
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
|
use solana_stake_api::stake_state::Meta;
|
||||||
use solana_stake_api::{
|
use solana_stake_api::{
|
||||||
stake_instruction::{self, StakeError},
|
stake_instruction::{self, StakeError},
|
||||||
stake_state::{Authorized, Lockup, Meta, StakeAuthorize, StakeState},
|
stake_state::{Authorized, Lockup, StakeAuthorize, StakeState},
|
||||||
};
|
};
|
||||||
use solana_vote_api::vote_state::VoteState;
|
use solana_vote_api::vote_state::VoteState;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
@@ -38,13 +40,13 @@ impl StakeSubCommands for App<'_, '_> {
|
|||||||
SubCommand::with_name("create-stake-account")
|
SubCommand::with_name("create-stake-account")
|
||||||
.about("Create a stake account")
|
.about("Create a stake account")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("stake_account_pubkey")
|
Arg::with_name("stake_account")
|
||||||
.index(1)
|
.index(1)
|
||||||
.value_name("STAKE ACCOUNT")
|
.value_name("STAKE ACCOUNT")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.validator(is_pubkey_or_keypair)
|
.validator(is_keypair)
|
||||||
.help("Address of the stake account to fund (pubkey or keypair)")
|
.help("Keypair of the stake account to fund")
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("amount")
|
Arg::with_name("amount")
|
||||||
@@ -272,7 +274,7 @@ impl StakeSubCommands for App<'_, '_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_stake_create_account(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_stake_create_account(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let stake_account_pubkey = pubkey_of(matches, "stake_account_pubkey").unwrap();
|
let stake_account = keypair_of(matches, "stake_account").unwrap();
|
||||||
let slot = value_of(&matches, "lockup").unwrap_or(0);
|
let slot = value_of(&matches, "lockup").unwrap_or(0);
|
||||||
let custodian = pubkey_of(matches, "custodian").unwrap_or_default();
|
let custodian = pubkey_of(matches, "custodian").unwrap_or_default();
|
||||||
let staker = pubkey_of(matches, "authorized_staker");
|
let staker = pubkey_of(matches, "authorized_staker");
|
||||||
@@ -281,7 +283,7 @@ pub fn parse_stake_create_account(matches: &ArgMatches<'_>) -> Result<CliCommand
|
|||||||
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::CreateStakeAccount {
|
command: CliCommand::CreateStakeAccount {
|
||||||
stake_account_pubkey,
|
stake_account,
|
||||||
staker,
|
staker,
|
||||||
withdrawer,
|
withdrawer,
|
||||||
lockup: Lockup { custodian, slot },
|
lockup: Lockup { custodian, slot },
|
||||||
@@ -374,15 +376,16 @@ pub fn parse_show_stake_history(matches: &ArgMatches<'_>) -> Result<CliCommandIn
|
|||||||
pub fn process_create_stake_account(
|
pub fn process_create_stake_account(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &CliConfig,
|
config: &CliConfig,
|
||||||
stake_account_pubkey: &Pubkey,
|
stake_account: &Keypair,
|
||||||
staker: &Option<Pubkey>,
|
staker: &Option<Pubkey>,
|
||||||
withdrawer: &Option<Pubkey>,
|
withdrawer: &Option<Pubkey>,
|
||||||
lockup: &Lockup,
|
lockup: &Lockup,
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
|
let stake_account_pubkey = stake_account.pubkey();
|
||||||
check_unique_pubkeys(
|
check_unique_pubkeys(
|
||||||
(&config.keypair.pubkey(), "cli keypair".to_string()),
|
(&config.keypair.pubkey(), "cli keypair".to_string()),
|
||||||
(stake_account_pubkey, "stake_account_pubkey".to_string()),
|
(&stake_account_pubkey, "stake_account_pubkey".to_string()),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if rpc_client.get_account(&stake_account_pubkey).is_ok() {
|
if rpc_client.get_account(&stake_account_pubkey).is_ok() {
|
||||||
@@ -412,7 +415,7 @@ pub fn process_create_stake_account(
|
|||||||
|
|
||||||
let ixs = stake_instruction::create_stake_account_with_lockup(
|
let ixs = stake_instruction::create_stake_account_with_lockup(
|
||||||
&config.keypair.pubkey(),
|
&config.keypair.pubkey(),
|
||||||
stake_account_pubkey,
|
&stake_account_pubkey,
|
||||||
&authorized,
|
&authorized,
|
||||||
lockup,
|
lockup,
|
||||||
lamports,
|
lamports,
|
||||||
@@ -709,36 +712,54 @@ pub fn process_delegate_stake(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::cli::{app, parse_command};
|
use crate::cli::{app, parse_command};
|
||||||
|
use solana_sdk::signature::write_keypair;
|
||||||
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
|
fn make_tmp_file() -> (String, NamedTempFile) {
|
||||||
|
let tmp_file = NamedTempFile::new().unwrap();
|
||||||
|
(String::from(tmp_file.path().to_str().unwrap()), tmp_file)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_command() {
|
fn test_parse_command() {
|
||||||
let test_commands = app("test", "desc", "version");
|
let test_commands = app("test", "desc", "version");
|
||||||
let pubkey = Pubkey::new_rand();
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||||
let pubkey_string = format!("{}", pubkey);
|
let stake_account_keypair = Keypair::new();
|
||||||
|
write_keypair(&stake_account_keypair, tmp_file.as_file_mut()).unwrap();
|
||||||
|
let stake_account_pubkey = stake_account_keypair.pubkey();
|
||||||
|
let stake_account_string = stake_account_pubkey.to_string();
|
||||||
|
|
||||||
let test_authorize_staker = test_commands.clone().get_matches_from(vec![
|
let test_authorize_staker = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"stake-authorize-staker",
|
"stake-authorize-staker",
|
||||||
&pubkey_string,
|
&stake_account_string,
|
||||||
&pubkey_string,
|
&stake_account_string,
|
||||||
]);
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_authorize_staker).unwrap(),
|
parse_command(&test_authorize_staker).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::StakeAuthorize(pubkey, pubkey, StakeAuthorize::Staker),
|
command: CliCommand::StakeAuthorize(
|
||||||
|
stake_account_pubkey,
|
||||||
|
stake_account_pubkey,
|
||||||
|
StakeAuthorize::Staker
|
||||||
|
),
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let test_authorize_withdrawer = test_commands.clone().get_matches_from(vec![
|
let test_authorize_withdrawer = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"stake-authorize-withdrawer",
|
"stake-authorize-withdrawer",
|
||||||
&pubkey_string,
|
&stake_account_string,
|
||||||
&pubkey_string,
|
&stake_account_string,
|
||||||
]);
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_authorize_withdrawer).unwrap(),
|
parse_command(&test_authorize_withdrawer).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::StakeAuthorize(pubkey, pubkey, StakeAuthorize::Withdrawer),
|
command: CliCommand::StakeAuthorize(
|
||||||
|
stake_account_pubkey,
|
||||||
|
stake_account_pubkey,
|
||||||
|
StakeAuthorize::Withdrawer
|
||||||
|
),
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -751,7 +772,7 @@ mod tests {
|
|||||||
let test_create_stake_account = test_commands.clone().get_matches_from(vec![
|
let test_create_stake_account = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-stake-account",
|
"create-stake-account",
|
||||||
&pubkey_string,
|
&keypair_file,
|
||||||
"50",
|
"50",
|
||||||
"--authorized-staker",
|
"--authorized-staker",
|
||||||
&authorized_string,
|
&authorized_string,
|
||||||
@@ -767,7 +788,7 @@ mod tests {
|
|||||||
parse_command(&test_create_stake_account).unwrap(),
|
parse_command(&test_create_stake_account).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateStakeAccount {
|
command: CliCommand::CreateStakeAccount {
|
||||||
stake_account_pubkey: pubkey,
|
stake_account: stake_account_keypair,
|
||||||
staker: Some(authorized),
|
staker: Some(authorized),
|
||||||
withdrawer: Some(authorized),
|
withdrawer: Some(authorized),
|
||||||
lockup: Lockup {
|
lockup: Lockup {
|
||||||
@@ -779,18 +800,26 @@ mod tests {
|
|||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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();
|
||||||
|
let stake_account_pubkey = stake_account_keypair.pubkey();
|
||||||
|
let stake_account_string = stake_account_pubkey.to_string();
|
||||||
|
|
||||||
let test_create_stake_account2 = test_commands.clone().get_matches_from(vec![
|
let test_create_stake_account2 = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-stake-account",
|
"create-stake-account",
|
||||||
&pubkey_string,
|
&keypair_file,
|
||||||
"50",
|
"50",
|
||||||
"lamports",
|
"lamports",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_create_stake_account2).unwrap(),
|
parse_command(&test_create_stake_account2).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateStakeAccount {
|
command: CliCommand::CreateStakeAccount {
|
||||||
stake_account_pubkey: pubkey,
|
stake_account: stake_account_keypair,
|
||||||
staker: None,
|
staker: None,
|
||||||
withdrawer: None,
|
withdrawer: None,
|
||||||
lockup: Lockup {
|
lockup: Lockup {
|
||||||
@@ -810,12 +839,12 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
"delegate-stake",
|
"delegate-stake",
|
||||||
&stake_pubkey_string,
|
&stake_pubkey_string,
|
||||||
&pubkey_string,
|
&stake_account_string,
|
||||||
]);
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_delegate_stake).unwrap(),
|
parse_command(&test_delegate_stake).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::DelegateStake(stake_pubkey, pubkey, false),
|
command: CliCommand::DelegateStake(stake_pubkey, stake_account_pubkey, false),
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -825,12 +854,12 @@ mod tests {
|
|||||||
"delegate-stake",
|
"delegate-stake",
|
||||||
"--force",
|
"--force",
|
||||||
&stake_pubkey_string,
|
&stake_pubkey_string,
|
||||||
&pubkey_string,
|
&stake_account_string,
|
||||||
]);
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_delegate_stake).unwrap(),
|
parse_command(&test_delegate_stake).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::DelegateStake(stake_pubkey, pubkey, true),
|
command: CliCommand::DelegateStake(stake_pubkey, stake_account_pubkey, true),
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -840,7 +869,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
"withdraw-stake",
|
"withdraw-stake",
|
||||||
&stake_pubkey_string,
|
&stake_pubkey_string,
|
||||||
&pubkey_string,
|
&stake_account_string,
|
||||||
"42",
|
"42",
|
||||||
"lamports",
|
"lamports",
|
||||||
]);
|
]);
|
||||||
@@ -848,7 +877,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_withdraw_stake).unwrap(),
|
parse_command(&test_withdraw_stake).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::WithdrawStake(stake_pubkey, pubkey, 42),
|
command: CliCommand::WithdrawStake(stake_pubkey, stake_account_pubkey, 42),
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -8,6 +8,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
|
use solana_sdk::signature::Keypair;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account_utils::State, message::Message, pubkey::Pubkey, signature::KeypairUtil,
|
account_utils::State, message::Message, pubkey::Pubkey, signature::KeypairUtil,
|
||||||
system_instruction::SystemError, transaction::Transaction,
|
system_instruction::SystemError, transaction::Transaction,
|
||||||
@@ -32,12 +33,12 @@ impl StorageSubCommands for App<'_, '_> {
|
|||||||
.validator(is_pubkey_or_keypair),
|
.validator(is_pubkey_or_keypair),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("storage_account_pubkey")
|
Arg::with_name("storage_account")
|
||||||
.index(2)
|
.index(2)
|
||||||
.value_name("STORAGE ACCOUNT PUBKEY")
|
.value_name("STORAGE ACCOUNT")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.validator(is_pubkey_or_keypair),
|
.validator(is_keypair),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
@@ -52,12 +53,12 @@ impl StorageSubCommands for App<'_, '_> {
|
|||||||
.validator(is_pubkey_or_keypair),
|
.validator(is_pubkey_or_keypair),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("storage_account_pubkey")
|
Arg::with_name("storage_account")
|
||||||
.index(2)
|
.index(2)
|
||||||
.value_name("STORAGE ACCOUNT PUBKEY")
|
.value_name("STORAGE ACCOUNT")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.validator(is_pubkey_or_keypair),
|
.validator(is_keypair),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
@@ -102,11 +103,11 @@ pub fn parse_storage_create_archiver_account(
|
|||||||
matches: &ArgMatches<'_>,
|
matches: &ArgMatches<'_>,
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
) -> Result<CliCommandInfo, CliError> {
|
||||||
let account_owner = pubkey_of(matches, "storage_account_owner").unwrap();
|
let account_owner = pubkey_of(matches, "storage_account_owner").unwrap();
|
||||||
let storage_account_pubkey = pubkey_of(matches, "storage_account_pubkey").unwrap();
|
let storage_account = keypair_of(matches, "storage_account").unwrap();
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::CreateStorageAccount {
|
command: CliCommand::CreateStorageAccount {
|
||||||
account_owner,
|
account_owner,
|
||||||
storage_account_pubkey,
|
storage_account,
|
||||||
account_type: StorageAccountType::Archiver,
|
account_type: StorageAccountType::Archiver,
|
||||||
},
|
},
|
||||||
require_keypair: true,
|
require_keypair: true,
|
||||||
@@ -117,11 +118,11 @@ pub fn parse_storage_create_validator_account(
|
|||||||
matches: &ArgMatches<'_>,
|
matches: &ArgMatches<'_>,
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
) -> Result<CliCommandInfo, CliError> {
|
||||||
let account_owner = pubkey_of(matches, "storage_account_owner").unwrap();
|
let account_owner = pubkey_of(matches, "storage_account_owner").unwrap();
|
||||||
let storage_account_pubkey = pubkey_of(matches, "storage_account_pubkey").unwrap();
|
let storage_account = keypair_of(matches, "storage_account").unwrap();
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::CreateStorageAccount {
|
command: CliCommand::CreateStorageAccount {
|
||||||
account_owner,
|
account_owner,
|
||||||
storage_account_pubkey,
|
storage_account,
|
||||||
account_type: StorageAccountType::Validator,
|
account_type: StorageAccountType::Validator,
|
||||||
},
|
},
|
||||||
require_keypair: true,
|
require_keypair: true,
|
||||||
@@ -154,9 +155,10 @@ pub fn process_create_storage_account(
|
|||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &CliConfig,
|
config: &CliConfig,
|
||||||
account_owner: &Pubkey,
|
account_owner: &Pubkey,
|
||||||
storage_account_pubkey: &Pubkey,
|
storage_account: &Keypair,
|
||||||
account_type: StorageAccountType,
|
account_type: StorageAccountType,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
|
let storage_account_pubkey = storage_account.pubkey();
|
||||||
check_unique_pubkeys(
|
check_unique_pubkeys(
|
||||||
(&config.keypair.pubkey(), "cli keypair".to_string()),
|
(&config.keypair.pubkey(), "cli keypair".to_string()),
|
||||||
(
|
(
|
||||||
@@ -168,7 +170,7 @@ pub fn process_create_storage_account(
|
|||||||
let ixs = storage_instruction::create_storage_account(
|
let ixs = storage_instruction::create_storage_account(
|
||||||
&config.keypair.pubkey(),
|
&config.keypair.pubkey(),
|
||||||
&account_owner,
|
&account_owner,
|
||||||
storage_account_pubkey,
|
&storage_account_pubkey,
|
||||||
1,
|
1,
|
||||||
account_type,
|
account_type,
|
||||||
);
|
);
|
||||||
@@ -226,45 +228,60 @@ pub fn process_show_storage_account(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::cli::{app, parse_command};
|
use crate::cli::{app, parse_command};
|
||||||
|
use solana_sdk::signature::write_keypair;
|
||||||
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
|
fn make_tmp_file() -> (String, NamedTempFile) {
|
||||||
|
let tmp_file = NamedTempFile::new().unwrap();
|
||||||
|
(String::from(tmp_file.path().to_str().unwrap()), tmp_file)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_command() {
|
fn test_parse_command() {
|
||||||
let test_commands = app("test", "desc", "version");
|
let test_commands = app("test", "desc", "version");
|
||||||
let pubkey = Pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
let pubkey_string = pubkey.to_string();
|
let pubkey_string = pubkey.to_string();
|
||||||
let storage_account_pubkey = Pubkey::new_rand();
|
|
||||||
let storage_account_string = storage_account_pubkey.to_string();
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||||
|
let storage_account_keypair = Keypair::new();
|
||||||
|
write_keypair(&storage_account_keypair, tmp_file.as_file_mut()).unwrap();
|
||||||
|
|
||||||
let test_create_archiver_storage_account = test_commands.clone().get_matches_from(vec![
|
let test_create_archiver_storage_account = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-archiver-storage-account",
|
"create-archiver-storage-account",
|
||||||
&pubkey_string,
|
&pubkey_string,
|
||||||
&storage_account_string,
|
&keypair_file,
|
||||||
]);
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_create_archiver_storage_account).unwrap(),
|
parse_command(&test_create_archiver_storage_account).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateStorageAccount {
|
command: CliCommand::CreateStorageAccount {
|
||||||
account_owner: pubkey,
|
account_owner: pubkey,
|
||||||
storage_account_pubkey,
|
storage_account: storage_account_keypair,
|
||||||
account_type: StorageAccountType::Archiver,
|
account_type: StorageAccountType::Archiver,
|
||||||
},
|
},
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||||
|
let storage_account_keypair = Keypair::new();
|
||||||
|
write_keypair(&storage_account_keypair, tmp_file.as_file_mut()).unwrap();
|
||||||
|
let storage_account_pubkey = storage_account_keypair.pubkey();
|
||||||
|
let storage_account_string = storage_account_pubkey.to_string();
|
||||||
|
|
||||||
let test_create_validator_storage_account = test_commands.clone().get_matches_from(vec![
|
let test_create_validator_storage_account = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-validator-storage-account",
|
"create-validator-storage-account",
|
||||||
&pubkey_string,
|
&pubkey_string,
|
||||||
&storage_account_string,
|
&keypair_file,
|
||||||
]);
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_create_validator_storage_account).unwrap(),
|
parse_command(&test_create_validator_storage_account).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateStorageAccount {
|
command: CliCommand::CreateStorageAccount {
|
||||||
account_owner: pubkey,
|
account_owner: pubkey,
|
||||||
storage_account_pubkey,
|
storage_account: storage_account_keypair,
|
||||||
account_type: StorageAccountType::Validator,
|
account_type: StorageAccountType::Validator,
|
||||||
},
|
},
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
|
@@ -9,6 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand};
|
use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand};
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
|
use solana_sdk::signature::Keypair;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::Account, pubkey::Pubkey, signature::KeypairUtil, system_instruction::SystemError,
|
account::Account, pubkey::Pubkey, signature::KeypairUtil, system_instruction::SystemError,
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
@@ -28,13 +29,13 @@ impl VoteSubCommands for App<'_, '_> {
|
|||||||
SubCommand::with_name("create-vote-account")
|
SubCommand::with_name("create-vote-account")
|
||||||
.about("Create a vote account")
|
.about("Create a vote account")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("vote_account_pubkey")
|
Arg::with_name("vote_account")
|
||||||
.index(1)
|
.index(1)
|
||||||
.value_name("VOTE ACCOUNT PUBKEY")
|
.value_name("VOTE ACCOUNT KEYPAIR")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.validator(is_pubkey_or_keypair)
|
.validator(is_keypair)
|
||||||
.help("Vote account address to fund"),
|
.help("Vote account keypair to fund"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("node_pubkey")
|
Arg::with_name("node_pubkey")
|
||||||
@@ -161,7 +162,7 @@ impl VoteSubCommands for App<'_, '_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_vote_create_account(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_vote_create_account(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let vote_account_pubkey = pubkey_of(matches, "vote_account_pubkey").unwrap();
|
let vote_account = keypair_of(matches, "vote_account").unwrap();
|
||||||
let node_pubkey = pubkey_of(matches, "node_pubkey").unwrap();
|
let node_pubkey = pubkey_of(matches, "node_pubkey").unwrap();
|
||||||
let commission = value_of(&matches, "commission").unwrap_or(0);
|
let commission = value_of(&matches, "commission").unwrap_or(0);
|
||||||
let authorized_voter = pubkey_of(matches, "authorized_voter");
|
let authorized_voter = pubkey_of(matches, "authorized_voter");
|
||||||
@@ -169,7 +170,7 @@ pub fn parse_vote_create_account(matches: &ArgMatches<'_>) -> Result<CliCommandI
|
|||||||
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey,
|
vote_account,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter,
|
authorized_voter,
|
||||||
authorized_withdrawer,
|
authorized_withdrawer,
|
||||||
@@ -231,19 +232,20 @@ pub fn parse_vote_uptime_command(matches: &ArgMatches<'_>) -> Result<CliCommandI
|
|||||||
pub fn process_create_vote_account(
|
pub fn process_create_vote_account(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &CliConfig,
|
config: &CliConfig,
|
||||||
vote_account_pubkey: &Pubkey,
|
vote_account: &Keypair,
|
||||||
node_pubkey: &Pubkey,
|
node_pubkey: &Pubkey,
|
||||||
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_pubkey = vote_account.pubkey();
|
||||||
check_unique_pubkeys(
|
check_unique_pubkeys(
|
||||||
(vote_account_pubkey, "vote_account_pubkey".to_string()),
|
(&vote_account_pubkey, "vote_account_pubkey".to_string()),
|
||||||
(&node_pubkey, "node_pubkey".to_string()),
|
(&node_pubkey, "node_pubkey".to_string()),
|
||||||
)?;
|
)?;
|
||||||
check_unique_pubkeys(
|
check_unique_pubkeys(
|
||||||
(&config.keypair.pubkey(), "cli keypair".to_string()),
|
(&config.keypair.pubkey(), "cli keypair".to_string()),
|
||||||
(vote_account_pubkey, "vote_account_pubkey".to_string()),
|
(&vote_account_pubkey, "vote_account_pubkey".to_string()),
|
||||||
)?;
|
)?;
|
||||||
let required_balance =
|
let required_balance =
|
||||||
rpc_client.get_minimum_balance_for_rent_exemption(VoteState::size_of())?;
|
rpc_client.get_minimum_balance_for_rent_exemption(VoteState::size_of())?;
|
||||||
@@ -254,13 +256,13 @@ pub fn process_create_vote_account(
|
|||||||
};
|
};
|
||||||
let vote_init = VoteInit {
|
let vote_init = VoteInit {
|
||||||
node_pubkey: *node_pubkey,
|
node_pubkey: *node_pubkey,
|
||||||
authorized_voter: authorized_voter.unwrap_or(*vote_account_pubkey),
|
authorized_voter: authorized_voter.unwrap_or(vote_account_pubkey),
|
||||||
authorized_withdrawer: authorized_withdrawer.unwrap_or(config.keypair.pubkey()),
|
authorized_withdrawer: authorized_withdrawer.unwrap_or(config.keypair.pubkey()),
|
||||||
commission,
|
commission,
|
||||||
};
|
};
|
||||||
let ixs = vote_instruction::create_account(
|
let ixs = vote_instruction::create_account(
|
||||||
&config.keypair.pubkey(),
|
&config.keypair.pubkey(),
|
||||||
vote_account_pubkey,
|
&vote_account_pubkey,
|
||||||
&vote_init,
|
&vote_init,
|
||||||
lamports,
|
lamports,
|
||||||
);
|
);
|
||||||
@@ -430,11 +432,19 @@ pub fn process_uptime(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::cli::{app, parse_command};
|
use crate::cli::{app, parse_command};
|
||||||
|
use solana_sdk::signature::write_keypair;
|
||||||
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
|
fn make_tmp_file() -> (String, NamedTempFile) {
|
||||||
|
let tmp_file = NamedTempFile::new().unwrap();
|
||||||
|
(String::from(tmp_file.path().to_str().unwrap()), tmp_file)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_command() {
|
fn test_parse_command() {
|
||||||
let test_commands = app("test", "desc", "version");
|
let test_commands = app("test", "desc", "version");
|
||||||
let pubkey = Pubkey::new_rand();
|
let keypair = Keypair::new();
|
||||||
|
let pubkey = keypair.pubkey();
|
||||||
let pubkey_string = pubkey.to_string();
|
let pubkey_string = pubkey.to_string();
|
||||||
|
|
||||||
let test_authorize_voter = test_commands.clone().get_matches_from(vec![
|
let test_authorize_voter = test_commands.clone().get_matches_from(vec![
|
||||||
@@ -451,13 +461,16 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||||
|
let keypair = Keypair::new();
|
||||||
|
write_keypair(&keypair, tmp_file.as_file_mut()).unwrap();
|
||||||
// Test CreateVoteAccount SubCommand
|
// Test CreateVoteAccount SubCommand
|
||||||
let node_pubkey = Pubkey::new_rand();
|
let node_pubkey = Pubkey::new_rand();
|
||||||
let node_pubkey_string = format!("{}", node_pubkey);
|
let node_pubkey_string = format!("{}", node_pubkey);
|
||||||
let test_create_vote_account = test_commands.clone().get_matches_from(vec![
|
let test_create_vote_account = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-vote-account",
|
"create-vote-account",
|
||||||
&pubkey_string,
|
&keypair_file,
|
||||||
&node_pubkey_string,
|
&node_pubkey_string,
|
||||||
"--commission",
|
"--commission",
|
||||||
"10",
|
"10",
|
||||||
@@ -466,7 +479,7 @@ mod tests {
|
|||||||
parse_command(&test_create_vote_account).unwrap(),
|
parse_command(&test_create_vote_account).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey: pubkey,
|
vote_account: keypair,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
authorized_withdrawer: None,
|
authorized_withdrawer: None,
|
||||||
@@ -475,17 +488,22 @@ mod tests {
|
|||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||||
|
let keypair = Keypair::new();
|
||||||
|
write_keypair(&keypair, tmp_file.as_file_mut()).unwrap();
|
||||||
|
|
||||||
let test_create_vote_account2 = test_commands.clone().get_matches_from(vec![
|
let test_create_vote_account2 = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-vote-account",
|
"create-vote-account",
|
||||||
&pubkey_string,
|
&keypair_file,
|
||||||
&node_pubkey_string,
|
&node_pubkey_string,
|
||||||
]);
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_create_vote_account2).unwrap(),
|
parse_command(&test_create_vote_account2).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey: pubkey,
|
vote_account: keypair,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
authorized_withdrawer: None,
|
authorized_withdrawer: None,
|
||||||
@@ -494,12 +512,17 @@ mod tests {
|
|||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// test init with an authed voter
|
// test init with an authed voter
|
||||||
let authed = Pubkey::new_rand();
|
let authed = Pubkey::new_rand();
|
||||||
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||||
|
let keypair = Keypair::new();
|
||||||
|
write_keypair(&keypair, tmp_file.as_file_mut()).unwrap();
|
||||||
|
|
||||||
let test_create_vote_account3 = test_commands.clone().get_matches_from(vec![
|
let test_create_vote_account3 = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-vote-account",
|
"create-vote-account",
|
||||||
&pubkey_string,
|
&keypair_file,
|
||||||
&node_pubkey_string,
|
&node_pubkey_string,
|
||||||
"--authorized-voter",
|
"--authorized-voter",
|
||||||
&authed.to_string(),
|
&authed.to_string(),
|
||||||
@@ -508,7 +531,7 @@ mod tests {
|
|||||||
parse_command(&test_create_vote_account3).unwrap(),
|
parse_command(&test_create_vote_account3).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey: pubkey,
|
vote_account: keypair,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter: Some(authed),
|
authorized_voter: Some(authed),
|
||||||
authorized_withdrawer: None,
|
authorized_withdrawer: None,
|
||||||
@@ -517,11 +540,15 @@ mod tests {
|
|||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
||||||
|
let keypair = Keypair::new();
|
||||||
|
write_keypair(&keypair, tmp_file.as_file_mut()).unwrap();
|
||||||
// test init with an authed withdrawer
|
// test init with an authed withdrawer
|
||||||
let test_create_vote_account4 = test_commands.clone().get_matches_from(vec![
|
let test_create_vote_account4 = test_commands.clone().get_matches_from(vec![
|
||||||
"test",
|
"test",
|
||||||
"create-vote-account",
|
"create-vote-account",
|
||||||
&pubkey_string,
|
&keypair_file,
|
||||||
&node_pubkey_string,
|
&node_pubkey_string,
|
||||||
"--authorized-withdrawer",
|
"--authorized-withdrawer",
|
||||||
&authed.to_string(),
|
&authed.to_string(),
|
||||||
@@ -530,7 +557,7 @@ mod tests {
|
|||||||
parse_command(&test_create_vote_account4).unwrap(),
|
parse_command(&test_create_vote_account4).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::CreateVoteAccount {
|
command: CliCommand::CreateVoteAccount {
|
||||||
vote_account_pubkey: pubkey,
|
vote_account: keypair,
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
authorized_voter: None,
|
authorized_voter: None,
|
||||||
authorized_withdrawer: Some(authed),
|
authorized_withdrawer: Some(authed),
|
||||||
|
@@ -68,10 +68,9 @@ identity_pubkey=$($solana_keygen pubkey "$identity_keypair")
|
|||||||
|
|
||||||
if [[ ! -r $storage_keypair ]]; then
|
if [[ ! -r $storage_keypair ]]; then
|
||||||
$solana_keygen new -o "$storage_keypair"
|
$solana_keygen new -o "$storage_keypair"
|
||||||
storage_pubkey=$($solana_keygen pubkey "$storage_keypair")
|
|
||||||
|
|
||||||
$solana_cli --keypair "$identity_keypair" --url "$rpc_url" \
|
$solana_cli --keypair "$identity_keypair" --url "$rpc_url" \
|
||||||
create-archiver-storage-account "$identity_pubkey" "$storage_pubkey"
|
create-archiver-storage-account "$identity_pubkey" "$storage_keypair"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
default_arg --entrypoint "$entrypoint"
|
default_arg --entrypoint "$entrypoint"
|
||||||
|
Reference in New Issue
Block a user