pub struct DefaultSigner {
pub arg_name: String,
pub path: String,
/* private fields */
}agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Expand description
A command line argument that loads a default signer in absence of other signers.
This type manages a default signing source which may be overridden by other
signing sources via its generate_unique_signers method.
path is a signing source as documented by signer_from_path, and
arg_name is the name of its clap command line argument, which is passed
to signer_from_path as its keypair_name argument.
Fieldsยง
ยงarg_name: Stringagave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.The name of the signers command line argument.
path: Stringagave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.The signing source.
Implementationsยง
Sourceยงimpl DefaultSigner
impl DefaultSigner
Sourcepub fn new<AN: AsRef<str>, P: AsRef<str>>(arg_name: AN, path: P) -> Self
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn new<AN: AsRef<str>, P: AsRef<str>>(arg_name: AN, path: P) -> Self
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Create a new DefaultSigner.
path is a signing source as documented by signer_from_path, and
arg_name is the name of its clap command line argument, which is
passed to signer_from_path as its keypair_name argument.
ยงExamples
use clap::{App, Arg, value_t_or_exit};
use solana_clap_utils::keypair::DefaultSigner;
use solana_clap_utils::offline::OfflineArgs;
let clap_app = App::new("my-program")
// The argument we'll parse as a signer "path"
.arg(Arg::with_name("keypair")
.required(true)
.help("The default signer"))
.offline_args();
let clap_matches = clap_app.get_matches();
let keypair_str = value_t_or_exit!(clap_matches, "keypair", String);
let default_signer = DefaultSigner::new("keypair", &keypair_str);
assert_eq!(default_signer.path, keypair_str);Sourcepub fn generate_unique_signers(
&self,
bulk_signers: Vec<Option<Box<dyn Signer>>>,
matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<CliSignerInfo, Box<dyn Error>>
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn generate_unique_signers( &self, bulk_signers: Vec<Option<Box<dyn Signer>>>, matches: &ArgMatches<'_>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, ) -> Result<CliSignerInfo, Box<dyn Error>>
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Generate a unique set of signers, possibly excluding this default signer.
This function allows a command line application to have a default signer, perhaps representing a default wallet, but to override that signer and instead sign with one or more other signers.
bulk_signers is a vector of signers, all of which are optional. If any
of those signers is None, then the default signer will be loaded; if
all of those signers are Some, then the default signer will not be
loaded.
The returned value includes all of the bulk_signers that were not
None, and maybe the default signer, if it was loaded.
ยงExamples
use clap::{App, Arg, value_t_or_exit};
use solana_clap_utils::keypair::{DefaultSigner, signer_from_path};
use solana_clap_utils::offline::OfflineArgs;
use solana_signer::Signer;
let clap_app = App::new("my-program")
// The argument we'll parse as a signer "path"
.arg(Arg::with_name("keypair")
.required(true)
.help("The default signer"))
.arg(Arg::with_name("payer")
.long("payer")
.help("The account paying for the transaction"))
.offline_args();
let mut wallet_manager = None;
let clap_matches = clap_app.get_matches();
let keypair_str = value_t_or_exit!(clap_matches, "keypair", String);
let maybe_payer = clap_matches.value_of("payer");
let default_signer = DefaultSigner::new("keypair", &keypair_str);
let maybe_payer_signer = maybe_payer.map(|payer| {
signer_from_path(&clap_matches, payer, "payer", &mut wallet_manager)
}).transpose()?;
let bulk_signers = vec![maybe_payer_signer];
let unique_signers = default_signer.generate_unique_signers(
bulk_signers,
&clap_matches,
&mut wallet_manager,
)?;Sourcepub fn signer_from_path(
&self,
matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
) -> Result<Box<dyn Signer>, Box<dyn Error>>
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn signer_from_path( &self, matches: &ArgMatches<'_>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, ) -> Result<Box<dyn Signer>, Box<dyn Error>>
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Loads the default Signer from one of several possible sources.
The path is not strictly a file system path, but is interpreted as
various types of signing source, depending on its format, one of which
is a path to a keypair file. Some sources may require user interaction
in the course of calling this function.
This simply delegates to the signer_from_path free function, passing
it the DefaultSigners path and arg_name fields as the path and
keypair_name arguments.
See the signer_from_path free function for full documentation of how
this function interprets its arguments.
ยงExamples
use clap::{App, Arg, value_t_or_exit};
use solana_clap_utils::keypair::DefaultSigner;
use solana_clap_utils::offline::OfflineArgs;
let clap_app = App::new("my-program")
// The argument we'll parse as a signer "path"
.arg(Arg::with_name("keypair")
.required(true)
.help("The default signer"))
.offline_args();
let clap_matches = clap_app.get_matches();
let keypair_str = value_t_or_exit!(clap_matches, "keypair", String);
let default_signer = DefaultSigner::new("keypair", &keypair_str);
let mut wallet_manager = None;
let signer = default_signer.signer_from_path(
&clap_matches,
&mut wallet_manager,
)?;Sourcepub fn signer_from_path_with_config(
&self,
matches: &ArgMatches<'_>,
wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
config: &SignerFromPathConfig,
) -> Result<Box<dyn Signer>, Box<dyn Error>>
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn signer_from_path_with_config( &self, matches: &ArgMatches<'_>, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, config: &SignerFromPathConfig, ) -> Result<Box<dyn Signer>, Box<dyn Error>>
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Loads the default Signer from one of several possible sources.
The path is not strictly a file system path, but is interpreted as
various types of signing source, depending on its format, one of which
is a path to a keypair file. Some sources may require user interaction
in the course of calling this function.
This simply delegates to the signer_from_path_with_config free
function, passing it the DefaultSigners path and arg_name fields
as the path and keypair_name arguments.
See the signer_from_path free function for full documentation of how
this function interprets its arguments.
ยงExamples
use clap::{App, Arg, value_t_or_exit};
use solana_clap_utils::keypair::{SignerFromPathConfig, DefaultSigner};
use solana_clap_utils::offline::OfflineArgs;
let clap_app = App::new("my-program")
// The argument we'll parse as a signer "path"
.arg(Arg::with_name("keypair")
.required(true)
.help("The default signer"))
.offline_args();
let clap_matches = clap_app.get_matches();
let keypair_str = value_t_or_exit!(clap_matches, "keypair", String);
let default_signer = DefaultSigner::new("keypair", &keypair_str);
let mut wallet_manager = None;
// Allow pubkey signers without accompanying signatures
let config = SignerFromPathConfig {
allow_null_signer: true,
};
let signer = default_signer.signer_from_path_with_config(
&clap_matches,
&mut wallet_manager,
&config,
)?;Trait Implementationsยง
Sourceยงimpl Debug for DefaultSigner
impl Debug for DefaultSigner
Sourceยงimpl Default for DefaultSigner
impl Default for DefaultSigner
Sourceยงfn default() -> DefaultSigner
fn default() -> DefaultSigner
Auto Trait Implementationsยง
impl !Freeze for DefaultSigner
impl !RefUnwindSafe for DefaultSigner
impl Send for DefaultSigner
impl !Sync for DefaultSigner
impl Unpin for DefaultSigner
impl UnwindSafe for DefaultSigner
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> FmtForward for T
impl<T> FmtForward for T
Sourceยงfn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Sourceยงfn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Sourceยงfn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Sourceยงfn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Sourceยงfn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Sourceยงfn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Sourceยงfn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Sourceยงfn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Sourceยงimpl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Sourceยงfn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Sourceยงfn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSourceยงfn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSourceยงfn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Sourceยงfn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Sourceยงfn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Sourceยงfn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Sourceยงfn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Sourceยงimpl<T> Tap for T
impl<T> Tap for T
Sourceยงfn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSourceยงfn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSourceยงfn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSourceยงfn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSourceยงfn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSourceยงfn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSourceยงfn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Sourceยงfn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Sourceยงfn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Sourceยงfn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Sourceยงfn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Sourceยงfn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Sourceยงfn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.