Move CLI fee payer arg into clap-utils
This commit is contained in:
parent
6cf74d1166
commit
89cab47011
|
@ -0,0 +1,19 @@
|
||||||
|
use crate::{input_validators, ArgConstant};
|
||||||
|
use clap::Arg;
|
||||||
|
|
||||||
|
pub const FEE_PAYER_ARG: ArgConstant<'static> = ArgConstant {
|
||||||
|
name: "fee_payer",
|
||||||
|
long: "fee-payer",
|
||||||
|
help: "Specify the fee-payer account. This may be a keypair file, the ASK keyword \n\
|
||||||
|
or the pubkey of an offline signer, provided an appropriate --signer argument \n\
|
||||||
|
is also passed. Defaults to the client keypair.",
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn fee_payer_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||||
|
Arg::with_name(FEE_PAYER_ARG.name)
|
||||||
|
.long(FEE_PAYER_ARG.long)
|
||||||
|
.takes_value(true)
|
||||||
|
.value_name("KEYPAIR")
|
||||||
|
.validator(input_validators::is_valid_signer)
|
||||||
|
.help(FEE_PAYER_ARG.help)
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ impl std::fmt::Debug for DisplayError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod commitment;
|
pub mod commitment;
|
||||||
|
pub mod fee_payer;
|
||||||
pub mod input_parsers;
|
pub mod input_parsers;
|
||||||
pub mod input_validators;
|
pub mod input_validators;
|
||||||
pub mod keypair;
|
pub mod keypair;
|
||||||
|
|
|
@ -16,8 +16,14 @@ use num_traits::FromPrimitive;
|
||||||
use serde_json::{self, json, Value};
|
use serde_json::{self, json, Value};
|
||||||
use solana_account_decoder::{UiAccount, UiAccountEncoding};
|
use solana_account_decoder::{UiAccount, UiAccountEncoding};
|
||||||
use solana_clap_utils::{
|
use solana_clap_utils::{
|
||||||
self, commitment::commitment_arg_with_default, input_parsers::*, input_validators::*,
|
self,
|
||||||
keypair::signer_from_path, nonce::*, offline::*, ArgConstant,
|
commitment::commitment_arg_with_default,
|
||||||
|
fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
|
||||||
|
input_parsers::*,
|
||||||
|
input_validators::*,
|
||||||
|
keypair::signer_from_path,
|
||||||
|
nonce::*,
|
||||||
|
offline::*,
|
||||||
};
|
};
|
||||||
use solana_client::{
|
use solana_client::{
|
||||||
client_error::{ClientError, ClientErrorKind, Result as ClientResult},
|
client_error::{ClientError, ClientErrorKind, Result as ClientResult},
|
||||||
|
@ -118,23 +124,6 @@ pub(crate) fn generate_unique_signers(
|
||||||
const DATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
|
const DATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
|
||||||
pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30";
|
pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30";
|
||||||
|
|
||||||
pub const FEE_PAYER_ARG: ArgConstant<'static> = ArgConstant {
|
|
||||||
name: "fee_payer",
|
|
||||||
long: "fee-payer",
|
|
||||||
help: "Specify the fee-payer account. This may be a keypair file, the ASK keyword \n\
|
|
||||||
or the pubkey of an offline signer, provided an appropriate --signer argument \n\
|
|
||||||
is also passed. Defaults to the client keypair.",
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn fee_payer_arg<'a, 'b>() -> Arg<'a, 'b> {
|
|
||||||
Arg::with_name(FEE_PAYER_ARG.name)
|
|
||||||
.long(FEE_PAYER_ARG.long)
|
|
||||||
.takes_value(true)
|
|
||||||
.value_name("KEYPAIR")
|
|
||||||
.validator(is_valid_signer)
|
|
||||||
.help(FEE_PAYER_ARG.help)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CliCommand {
|
pub enum CliCommand {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
|
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
|
||||||
cli::{
|
cli::{
|
||||||
fee_payer_arg, generate_unique_signers, log_instruction_custom_error, return_signers,
|
generate_unique_signers, log_instruction_custom_error, return_signers, CliCommand,
|
||||||
CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult, SignerIndex, FEE_PAYER_ARG,
|
CliCommandInfo, CliConfig, CliError, ProcessResult, SignerIndex,
|
||||||
},
|
},
|
||||||
cli_output::{CliStakeHistory, CliStakeHistoryEntry, CliStakeState, CliStakeType},
|
cli_output::{CliStakeHistory, CliStakeHistoryEntry, CliStakeState, CliStakeType},
|
||||||
nonce::check_nonce_account,
|
nonce::check_nonce_account,
|
||||||
|
@ -10,7 +10,14 @@ use crate::{
|
||||||
spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
|
spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
|
||||||
};
|
};
|
||||||
use clap::{App, Arg, ArgGroup, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgGroup, ArgMatches, SubCommand};
|
||||||
use solana_clap_utils::{input_parsers::*, input_validators::*, nonce::*, offline::*, ArgConstant};
|
use solana_clap_utils::{
|
||||||
|
fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
|
||||||
|
input_parsers::*,
|
||||||
|
input_validators::*,
|
||||||
|
nonce::*,
|
||||||
|
offline::*,
|
||||||
|
ArgConstant,
|
||||||
|
};
|
||||||
use solana_client::{
|
use solana_client::{
|
||||||
nonce_utils, rpc_client::RpcClient, rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
|
nonce_utils, rpc_client::RpcClient, rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,13 +13,7 @@ use std::ffi::OsString;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
fn fee_payer_arg<'a, 'b>() -> Arg<'a, 'b> {
|
fn fee_payer_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||||
Arg::with_name("fee_payer")
|
solana_clap_utils::fee_payer::fee_payer_arg().required(true)
|
||||||
.long("fee-payer")
|
|
||||||
.required(true)
|
|
||||||
.takes_value(true)
|
|
||||||
.value_name("KEYPAIR")
|
|
||||||
.validator(is_valid_signer)
|
|
||||||
.help("Fee payer")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn funding_keypair_arg<'a, 'b>() -> Arg<'a, 'b> {
|
fn funding_keypair_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||||
|
|
Loading…
Reference in New Issue