From ba353c2b1d9f2f72700fd957f30931cf589f0765 Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Tue, 22 Sep 2020 16:06:14 -0600 Subject: [PATCH] Move CLI blockhash_query module into client crate --- Cargo.lock | 1 + cli/src/cli.rs | 6 +++--- cli/src/offline/mod.rs | 4 ---- cli/src/stake.rs | 11 +++++----- cli/tests/nonce.rs | 11 +++++----- cli/tests/stake.rs | 11 +++++----- cli/tests/transfer.rs | 11 +++++----- cli/tests/vote.rs | 6 ++++-- client/Cargo.toml | 1 + .../offline => client/src}/blockhash_query.rs | 21 +++++++++---------- client/src/lib.rs | 1 + 11 files changed, 43 insertions(+), 41 deletions(-) rename {cli/src/offline => client/src}/blockhash_query.rs (97%) diff --git a/Cargo.lock b/Cargo.lock index 4208500e8..49a6d2f21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3585,6 +3585,7 @@ dependencies = [ "assert_matches", "bincode", "bs58", + "clap", "indicatif", "jsonrpc-core", "jsonrpc-http-server", diff --git a/cli/src/cli.rs b/cli/src/cli.rs index b36f59c60..00c6bae05 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -4,7 +4,7 @@ use crate::{ cluster_query::*, display::{new_spinner_progress_bar, println_name_value, println_transaction}, nonce::*, - offline::{blockhash_query::BlockhashQuery, return_signers}, + offline::return_signers, spend_utils::*, stake::*, validator_info::*, @@ -26,6 +26,7 @@ use solana_clap_utils::{ offline::*, }; use solana_client::{ + blockhash_query::BlockhashQuery, client_error::{ClientError, ClientErrorKind, Result as ClientResult}, nonce_utils, rpc_client::RpcClient, @@ -2224,9 +2225,8 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, ' #[cfg(test)] mod tests { use super::*; - use crate::offline::*; use serde_json::Value; - use solana_client::mock_sender::SIGNATURE; + use solana_client::{blockhash_query, mock_sender::SIGNATURE}; use solana_sdk::{ pubkey::Pubkey, signature::{keypair_from_seed, read_keypair_file, write_keypair_file, Presigner}, diff --git a/cli/src/offline/mod.rs b/cli/src/offline/mod.rs index 1e1d3a0bf..871d1d1bb 100644 --- a/cli/src/offline/mod.rs +++ b/cli/src/offline/mod.rs @@ -1,11 +1,7 @@ -pub mod blockhash_query; - use crate::cli_output::{CliSignOnlyData, OutputFormat}; use serde_json::Value; use solana_clap_utils::keypair::presigner_from_pubkey_sigs; -use solana_client::rpc_client::RpcClient; use solana_sdk::{ - fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey, signature::{Presigner, Signature}, diff --git a/cli/src/stake.rs b/cli/src/stake.rs index a01f50eb4..fbcb7cd89 100644 --- a/cli/src/stake.rs +++ b/cli/src/stake.rs @@ -6,7 +6,7 @@ use crate::{ }, cli_output::{CliStakeHistory, CliStakeHistoryEntry, CliStakeState, CliStakeType}, nonce::check_nonce_account, - offline::{blockhash_query::BlockhashQuery, return_signers}, + offline::return_signers, spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, }; use clap::{App, Arg, ArgGroup, ArgMatches, SubCommand}; @@ -20,7 +20,8 @@ use solana_clap_utils::{ ArgConstant, }; use solana_client::{ - nonce_utils, rpc_client::RpcClient, rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, + blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient, + rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, }; use solana_remote_wallet::remote_wallet::RemoteWalletManager; use solana_sdk::{ @@ -1770,10 +1771,8 @@ pub fn process_delegate_stake( #[cfg(test)] mod tests { use super::*; - use crate::{ - cli::{app, parse_command}, - offline::blockhash_query, - }; + use crate::cli::{app, parse_command}; + use solana_client::blockhash_query; use solana_sdk::{ hash::Hash, signature::{ diff --git a/cli/tests/nonce.rs b/cli/tests/nonce.rs index ffd3fd261..aafc297d3 100644 --- a/cli/tests/nonce.rs +++ b/cli/tests/nonce.rs @@ -1,14 +1,15 @@ use solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, cli_output::OutputFormat, - offline::{ - blockhash_query::{self, BlockhashQuery}, - parse_sign_only_reply_string, - }, + offline::parse_sign_only_reply_string, spend_utils::SpendAmount, test_utils::{check_ready, check_recent_balance}, }; -use solana_client::{nonce_utils, rpc_client::RpcClient}; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + nonce_utils, + rpc_client::RpcClient, +}; use solana_core::contact_info::ContactInfo; use solana_core::test_validator::{TestValidator, TestValidatorOptions}; use solana_faucet::faucet::run_local_faucet; diff --git a/cli/tests/stake.rs b/cli/tests/stake.rs index 5ce9c9c57..38f18ddf7 100644 --- a/cli/tests/stake.rs +++ b/cli/tests/stake.rs @@ -1,14 +1,15 @@ use solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, cli_output::OutputFormat, - offline::{ - blockhash_query::{self, BlockhashQuery}, - parse_sign_only_reply_string, - }, + offline::parse_sign_only_reply_string, spend_utils::SpendAmount, test_utils::{check_ready, check_recent_balance}, }; -use solana_client::{nonce_utils, rpc_client::RpcClient}; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + nonce_utils, + rpc_client::RpcClient, +}; use solana_core::test_validator::{TestValidator, TestValidatorOptions}; use solana_faucet::faucet::run_local_faucet; use solana_sdk::{ diff --git a/cli/tests/transfer.rs b/cli/tests/transfer.rs index 3b0e15bbf..f1347b1c1 100644 --- a/cli/tests/transfer.rs +++ b/cli/tests/transfer.rs @@ -1,14 +1,15 @@ use solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, cli_output::OutputFormat, - offline::{ - blockhash_query::{self, BlockhashQuery}, - parse_sign_only_reply_string, - }, + offline::parse_sign_only_reply_string, spend_utils::SpendAmount, test_utils::{check_ready, check_recent_balance}, }; -use solana_client::{nonce_utils, rpc_client::RpcClient}; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + nonce_utils, + rpc_client::RpcClient, +}; use solana_core::test_validator::{TestValidator, TestValidatorOptions}; use solana_faucet::faucet::run_local_faucet; use solana_sdk::{ diff --git a/cli/tests/vote.rs b/cli/tests/vote.rs index bb32dba82..8510ee163 100644 --- a/cli/tests/vote.rs +++ b/cli/tests/vote.rs @@ -1,10 +1,12 @@ use solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, - offline::{blockhash_query::BlockhashQuery, *}, spend_utils::SpendAmount, test_utils::check_recent_balance, }; -use solana_client::rpc_client::RpcClient; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + rpc_client::RpcClient, +}; use solana_core::test_validator::TestValidator; use solana_faucet::faucet::run_local_faucet; use solana_sdk::{ diff --git a/client/Cargo.toml b/client/Cargo.toml index 2978bc8be..d148bd818 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -11,6 +11,7 @@ edition = "2018" [dependencies] bincode = "1.3.1" bs58 = "0.3.1" +clap = "2.33.0" indicatif = "0.15.0" jsonrpc-core = "14.2.0" log = "0.4.8" diff --git a/cli/src/offline/blockhash_query.rs b/client/src/blockhash_query.rs similarity index 97% rename from cli/src/offline/blockhash_query.rs rename to client/src/blockhash_query.rs index 06cc0605d..dae1b79a6 100644 --- a/cli/src/offline/blockhash_query.rs +++ b/client/src/blockhash_query.rs @@ -1,12 +1,13 @@ -use super::*; +use crate::{nonce_utils, rpc_client::RpcClient}; use clap::ArgMatches; use solana_clap_utils::{ input_parsers::{pubkey_of, value_of}, nonce::*, offline::*, }; -use solana_client::nonce_utils; -use solana_sdk::commitment_config::CommitmentConfig; +use solana_sdk::{ + commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey, +}; #[derive(Debug, PartialEq)] pub enum Source { @@ -115,17 +116,15 @@ impl Default for BlockhashQuery { #[cfg(test)] mod tests { use super::*; - use crate::offline::blockhash_query::{self, BlockhashQuery}; - use clap::App; - use serde_json::{self, json, Value}; - use solana_account_decoder::{UiAccount, UiAccountEncoding}; - use solana_client::{ + use crate::{ + blockhash_query, rpc_request::RpcRequest, rpc_response::{Response, RpcFeeCalculator, RpcResponseContext}, }; - use solana_sdk::{ - account::Account, fee_calculator::FeeCalculator, hash::hash, nonce, system_program, - }; + use clap::App; + use serde_json::{self, json, Value}; + use solana_account_decoder::{UiAccount, UiAccountEncoding}; + use solana_sdk::{account::Account, hash::hash, nonce, system_program}; use std::collections::HashMap; #[test] diff --git a/client/src/lib.rs b/client/src/lib.rs index 22098eca6..3d70dd0a1 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,6 +1,7 @@ #[macro_use] extern crate serde_derive; +pub mod blockhash_query; pub mod client_error; pub mod http_sender; pub mod mock_sender;