Skip to content

Commit

Permalink
stake-pool-cli: Update input parser to work with ledgers (solana-labs…
Browse files Browse the repository at this point in the history
…#2613)

* stake-pool-cli: Update input parser to work with ledgers

* fmt
  • Loading branch information
joncinque authored Dec 3, 2021
1 parent 97285c6 commit c24bc96
Showing 1 changed file with 22 additions and 41 deletions.
63 changes: 22 additions & 41 deletions stake-pool/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use {
input_parsers::{keypair_of, pubkey_of},
input_validators::{
is_amount, is_keypair_or_ask_keyword, is_parsable, is_pubkey, is_url,
is_valid_percentage, is_valid_pubkey,
is_valid_percentage, is_valid_pubkey, is_valid_signer,
},
keypair::{signer_from_path_with_config, SignerFromPathConfig},
},
Expand Down Expand Up @@ -1624,60 +1624,41 @@ fn main() {
Arg::with_name("staker")
.long("staker")
.value_name("KEYPAIR")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.takes_value(true)
.help(
"Specify the stake pool staker. \
This may be a keypair file, the ASK keyword. \
Defaults to the client keypair.",
),
.help("Stake pool staker. [default: cli config keypair]"),
)
.arg(
Arg::with_name("manager")
.long("manager")
.value_name("KEYPAIR")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.takes_value(true)
.help(
"Specify the stake pool manager. \
This may be a keypair file, the ASK keyword. \
Defaults to the client keypair.",
),
.help("Stake pool manager. [default: cli config keypair]"),
)
.arg(
Arg::with_name("funding_authority")
.long("funding-authority")
.value_name("KEYPAIR")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.takes_value(true)
.help(
"Specify the stake pool funding authority, for deposits or withdrawals. \
This may be a keypair file, the ASK keyword.",
),
.help("Stake pool funding authority for deposits or withdrawals. [default: cli config keypair]"),
)
.arg(
Arg::with_name("token_owner")
.long("token-owner")
.value_name("KEYPAIR")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.takes_value(true)
.help(
"Specify the owner of the pool token account. \
This may be a keypair file, the ASK keyword. \
Defaults to the client keypair.",
),
.help("Owner of pool token account [default: cli config keypair]"),
)
.arg(
Arg::with_name("fee_payer")
.long("fee-payer")
.value_name("KEYPAIR")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.takes_value(true)
.help(
"Specify the fee-payer account. \
This may be a keypair file, the ASK keyword. \
Defaults to the client keypair.",
),
.help("Transaction fee payer account [default: cli config keypair]"),
)
.subcommand(SubCommand::with_name("create-pool")
.about("Create a new stake pool")
Expand Down Expand Up @@ -1757,7 +1738,7 @@ fn main() {
Arg::with_name("deposit_authority")
.long("deposit-authority")
.short("a")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.value_name("DEPOSIT_AUTHORITY_KEYPAIR")
.takes_value(true)
.help("Deposit authority required to sign all deposits into the stake pool"),
Expand Down Expand Up @@ -1976,11 +1957,10 @@ fn main() {
.arg(
Arg::with_name("withdraw_authority")
.long("withdraw-authority")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.value_name("KEYPAIR")
.takes_value(true)
.help("Withdraw authority for the stake account to be deposited. \
Defaults to the fee payer."),
.help("Withdraw authority for the stake account to be deposited. [default: cli config keypair]"),
)
.arg(
Arg::with_name("token_receiver")
Expand Down Expand Up @@ -2022,11 +2002,10 @@ fn main() {
.arg(
Arg::with_name("from")
.long("from")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.value_name("KEYPAIR")
.takes_value(true)
.help("Source account of funds. \
Defaults to the fee payer."),
.help("Source account of funds. [default: cli config keypair]"),
)
.arg(
Arg::with_name("token_receiver")
Expand Down Expand Up @@ -2192,7 +2171,7 @@ fn main() {
.arg(
Arg::with_name("new_manager")
.long("new-manager")
.validator(is_keypair_or_ask_keyword)
.validator(is_valid_signer)
.value_name("KEYPAIR")
.takes_value(true)
.help("Keypair for the new stake pool manager."),
Expand Down Expand Up @@ -2667,9 +2646,11 @@ fn main() {
("set-referral-fee", Some(arg_matches)) => {
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
let fee = value_t_or_exit!(arg_matches, "fee", u8);
if fee > 100u8 {
panic!("Invalid fee {}%. Fee needs to be in range [0-100]", fee);
}
assert!(
fee <= 100u8,
"Invalid fee {}%. Fee needs to be in range [0-100]",
fee
);
let fee_type = match arg_matches.value_of("fee_type").unwrap() {
"sol" => FeeType::SolReferral(fee),
"stake" => FeeType::StakeReferral(fee),
Expand Down

0 comments on commit c24bc96

Please sign in to comment.