CLI: dynamic signing reboot (#8384)
* Add keypair_util_from_path helper * Cli: impl config.keypair as a trait object * SDK: Add Debug and PartialEq for dyn Signer * ClapUtils: Arg parsing from pubkey+signers to Presigner * Impl Signers for &dyn Signer collections * CLI: Add helper for getting signers from args * CLI: Replace SigningAuthority with Signer trait-objs * CLI: Drop disused signers command field * CLI: Drop redundant tests * Add clap validator that handles all current signer types * clap_utils: Factor Presigner resolution to helper * SDK: `From` for boxing Signer implementors to trait objects * SDK: Derive `Clone` for `Presigner` * Remove panic * Cli: dedup signers in transfer for remote-wallet ergonomics * Update docs vis-a-vis ASK changes * Cli: update transaction types to use new dynamic-signer methods * CLI: Fix tests No. 1 what to do about write_keypair outstanding * Work around `CliConfig`'s signer not necessarily being a `Keypair` * CLI: Fix tests No. 2 * Remove unused arg * Remove unused methods * Move offline arg constants upstream * Make cli signing fallible Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
This commit is contained in:
@@ -48,6 +48,34 @@ impl Signers for [Box<dyn Signer>] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl Signers for Vec<&dyn Signer> {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl Signers for [&dyn Signer] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl Signers for [&dyn Signer; 0] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl Signers for [&dyn Signer; 1] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl Signers for [&dyn Signer; 2] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl Signers for [&dyn Signer; 3] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl Signers for [&dyn Signer; 4] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
|
||||
impl<T: Signer> Signers for [&T; 0] {
|
||||
default_keypairs_impl!();
|
||||
}
|
||||
@@ -111,4 +139,22 @@ mod tests {
|
||||
vec![Signature::default(), Signature::default()],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dyn_keypairs_by_ref_compile() {
|
||||
let foo = Foo {};
|
||||
let bar = Bar {};
|
||||
let xs: Vec<&dyn Signer> = vec![&foo, &bar];
|
||||
assert_eq!(
|
||||
xs.sign_message(b""),
|
||||
vec![Signature::default(), Signature::default()],
|
||||
);
|
||||
|
||||
// Same as above, but less compiler magic.
|
||||
let xs_ref: &[&dyn Signer] = &xs;
|
||||
assert_eq!(
|
||||
Signers::sign_message(xs_ref, b""),
|
||||
vec![Signature::default(), Signature::default()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user