Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Refactor SignerSource to expose DerivationPath to other kinds of signers #16933

Merged
merged 9 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions clap-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ uriparse = "0.6.3"
url = "2.1.0"
chrono = "0.4"

[dev-dependencies]
tempfile = "3.1.0"

[lib]
name = "solana_clap_utils"

Expand Down
6 changes: 4 additions & 2 deletions clap-utils/src/fee_payer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{input_validators, ArgConstant};
use clap::Arg;
use {
crate::{input_validators, ArgConstant},
clap::Arg,
};

pub const FEE_PAYER_ARG: ArgConstant<'static> = ArgConstant {
name: "fee_payer",
Expand Down
32 changes: 17 additions & 15 deletions clap-utils/src/input_parsers.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
use crate::keypair::{
keypair_from_seed_phrase, pubkey_from_path, resolve_signer_from_path, signer_from_path,
ASK_KEYWORD, SKIP_SEED_PHRASE_VALIDATION_ARG,
use {
crate::keypair::{
keypair_from_seed_phrase, pubkey_from_path, resolve_signer_from_path, signer_from_path,
ASK_KEYWORD, SKIP_SEED_PHRASE_VALIDATION_ARG,
},
chrono::DateTime,
clap::ArgMatches,
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
clock::UnixTimestamp,
commitment_config::CommitmentConfig,
genesis_config::ClusterType,
native_token::sol_to_lamports,
pubkey::Pubkey,
signature::{read_keypair_file, Keypair, Signature, Signer},
},
std::{str::FromStr, sync::Arc},
};
use chrono::DateTime;
use clap::ArgMatches;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
clock::UnixTimestamp,
commitment_config::CommitmentConfig,
genesis_config::ClusterType,
native_token::sol_to_lamports,
pubkey::Pubkey,
signature::{read_keypair_file, Keypair, Signature, Signer},
};
use std::{str::FromStr, sync::Arc};

// Return parsed values from matches at `name`
pub fn values_of<T>(matches: &ArgMatches<'_>, name: &str) -> Option<Vec<T>>
Expand Down
27 changes: 16 additions & 11 deletions clap-utils/src/input_validators.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::keypair::{parse_signer_source, SignerSource, ASK_KEYWORD};
use chrono::DateTime;
use solana_sdk::{
clock::{Epoch, Slot},
hash::Hash,
pubkey::{Pubkey, MAX_SEED_LEN},
signature::{read_keypair_file, Signature},
use {
crate::keypair::{parse_signer_source, SignerSourceKind, ASK_KEYWORD},
chrono::DateTime,
solana_sdk::{
clock::{Epoch, Slot},
hash::Hash,
pubkey::{Pubkey, MAX_SEED_LEN},
signature::{read_keypair_file, Signature},
},
std::fmt::Display,
std::str::FromStr,
};
use std::fmt::Display;
use std::str::FromStr;

fn is_parsable_generic<U, T>(string: T) -> Result<(), String>
where
Expand Down Expand Up @@ -108,8 +110,11 @@ pub fn is_valid_pubkey<T>(string: T) -> Result<(), String>
where
T: AsRef<str> + Display,
{
match parse_signer_source(string.as_ref()) {
SignerSource::Filepath(path) => is_keypair(path),
match parse_signer_source(string.as_ref())
.map_err(|err| format!("{}", err))?
.kind
{
SignerSourceKind::Filepath(path) => is_keypair(path),
_ => Ok(()),
}
}
Expand Down
Loading