propagate current account

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-04-08 17:48:07 -04:00
parent 18ea05db0a
commit 5917bc16fd
13 changed files with 120 additions and 20 deletions

View File

@@ -16,6 +16,20 @@ pub struct Keypair {
pub secret_key: Option<SecretKey>,
}
pub struct KeypairUnowned<'a> {
pub pubkey: &'a Pubkey,
pub secret_key: Option<&'a SecretKey>,
}
impl<'a> From<&'a Keypair> for KeypairUnowned<'a> {
fn from(value: &'a Keypair) -> Self {
Self {
pubkey: &value.pubkey,
secret_key: value.secret_key.as_ref(),
}
}
}
impl Keypair {
pub fn from_secret(secret_key: SecretKey) -> Self {
let cloned_secret_key = secret_key.clone();
@@ -70,6 +84,15 @@ impl<'a> FilledKeypair<'a> {
}
}
impl<'a> From<FilledKeypair<'a>> for KeypairUnowned<'a> {
fn from(value: FilledKeypair<'a>) -> Self {
Self {
pubkey: value.pubkey,
secret_key: Some(value.secret_key),
}
}
}
impl FullKeypair {
pub fn new(pubkey: Pubkey, secret_key: SecretKey) -> Self {
FullKeypair { pubkey, secret_key }