mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 02:21:14 +00:00
CLI API refactoring and improvement (#4692)
It changes the way we extended the CLI functionalities of substrate to allow more flexibility. (If this was not clear, here is another version: it changes the `sc_cli` API to allow more flexibility).
This touches a few important things:
- the startup of the async task with tokei:
This was in node and node-template and I moved it to substrate. The idea is to have 1 time the code that handles unix signals (SIGTERM and SIGINT) properly. It is however possible to make this more generic to wait for a future instead and provide only a helper for the basic handling of SIGTERM and SIGINT.
- increased the version of structopt and tokei
- no more use of structopt internal's API
- less use of generics
Related to #4643 and https://github.com/paritytech/cumulus/pull/42: the implementation of "into_configuration" and "get_config" are similar but with better flexibility so it is now possible in cumulus to have the command-line arguments only of the run command for polkadot if we want
Related to https://github.com/paritytech/cumulus/issues/24 and https://github.com/paritytech/cumulus/issues/34 : it will now be possible to make a configuration struct for polkadot with some overrides of the default parameters much more easily.
This commit is contained in:
@@ -113,6 +113,33 @@ impl From<Keyring> for sp_runtime::MultiSigner {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ParseKeyringError;
|
||||
|
||||
impl std::fmt::Display for ParseKeyringError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "ParseKeyringError")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Keyring {
|
||||
type Err = ParseKeyringError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, <Self as std::str::FromStr>::Err> {
|
||||
match s {
|
||||
"alice" => Ok(Keyring::Alice),
|
||||
"bob" => Ok(Keyring::Bob),
|
||||
"charlie" => Ok(Keyring::Charlie),
|
||||
"dave" => Ok(Keyring::Dave),
|
||||
"eve" => Ok(Keyring::Eve),
|
||||
"ferdie" => Ok(Keyring::Ferdie),
|
||||
"one" => Ok(Keyring::One),
|
||||
"two" => Ok(Keyring::Two),
|
||||
_ => Err(ParseKeyringError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref PRIVATE_KEYS: HashMap<Keyring, Pair> = {
|
||||
Keyring::iter().map(|i| (i, i.pair())).collect()
|
||||
|
||||
Reference in New Issue
Block a user