Plumb GetTransactionCount through solana-wallet
This commit is contained in:
committed by
Tyera Eulberg
parent
9314eea7e9
commit
02cfa76916
@@ -163,8 +163,8 @@ fn main() -> Result<(), Box<error::Error>> {
|
||||
)
|
||||
// TODO: Add "loader" argument; current default is bpf_loader
|
||||
).subcommand(
|
||||
SubCommand::with_name("leader-ready")
|
||||
.about("Determine leader readiness")
|
||||
SubCommand::with_name("get-transaction-count")
|
||||
.about("Get current transaction count")
|
||||
).subcommand(
|
||||
SubCommand::with_name("pay")
|
||||
.about("Send a payment")
|
||||
|
@@ -42,7 +42,7 @@ pub enum WalletCommand {
|
||||
Cancel(Pubkey),
|
||||
Confirm(Signature),
|
||||
Deploy(String),
|
||||
GetLeaderReadiness,
|
||||
GetTransactionCount,
|
||||
// Pay(tokens, to, timestamp, timestamp_pubkey, witness(es), cancelable)
|
||||
Pay(
|
||||
i64,
|
||||
@@ -146,7 +146,7 @@ pub fn parse_command(
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
)),
|
||||
("leader-ready", Some(_matches)) => Ok(WalletCommand::GetLeaderReadiness),
|
||||
("get-transaction-count", Some(_matches)) => Ok(WalletCommand::GetTransactionCount),
|
||||
("pay", Some(pay_matches)) => {
|
||||
let tokens = pay_matches.value_of("tokens").unwrap().parse()?;
|
||||
let to = if pay_matches.is_present("to") {
|
||||
@@ -454,15 +454,12 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
||||
"programId": format!("{}", program.pubkey()),
|
||||
}).to_string())
|
||||
}
|
||||
WalletCommand::GetLeaderReadiness => {
|
||||
// TODO: This logic is currently only correct for initial network boot;
|
||||
// needs updating for leader rotation
|
||||
WalletCommand::GetTransactionCount => {
|
||||
let transaction_count = RpcRequest::GetTransactionCount
|
||||
.make_rpc_request(&config.rpc_addr, 1, None)?
|
||||
.as_u64();
|
||||
match transaction_count {
|
||||
Some(0) => Ok("Leader not ready".to_string()),
|
||||
Some(_) => Ok("Leader ready".to_string()),
|
||||
Some(count) => Ok(count.to_string()),
|
||||
None => Err(WalletError::RpcRequestError(
|
||||
"Received result of an unexpected type".to_string(),
|
||||
))?,
|
||||
|
Reference in New Issue
Block a user