diff --git a/sdk/src/signature.rs b/sdk/src/signature.rs index 22c21764a7ac74..725e6ffd886316 100644 --- a/sdk/src/signature.rs +++ b/sdk/src/signature.rs @@ -12,7 +12,7 @@ use std::{ use thiserror::Error; // legacy module paths -pub use crate::signer::{keypair::*, presigner::*, *}; +pub use crate::signer::{keypair::*, null_signer::*, presigner::*, *}; /// Number of bytes in a signature pub const SIGNATURE_BYTES: usize = 64; @@ -113,39 +113,6 @@ impl FromStr for Signature { } } -/// NullSigner - A `Signer` implementation that always produces `Signature::default()`. -/// Used as a placeholder for absentee signers whose 'Pubkey` is required to construct -/// the transaction -#[derive(Clone, Debug, Default)] -pub struct NullSigner { - pubkey: Pubkey, -} - -impl NullSigner { - pub fn new(pubkey: &Pubkey) -> Self { - Self { pubkey: *pubkey } - } -} - -impl Signer for NullSigner { - fn try_pubkey(&self) -> Result { - Ok(self.pubkey) - } - - fn try_sign_message(&self, _message: &[u8]) -> Result { - Ok(Signature::default()) - } -} - -impl PartialEq for NullSigner -where - T: Signer, -{ - fn eq(&self, other: &T) -> bool { - self.pubkey == other.pubkey() - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/sdk/src/signer/mod.rs b/sdk/src/signer/mod.rs index 82948dfa77a143..5f97fa56a5a2a1 100644 --- a/sdk/src/signer/mod.rs +++ b/sdk/src/signer/mod.rs @@ -9,6 +9,7 @@ use { }; pub mod keypair; +pub mod null_signer; pub mod presigner; #[derive(Debug, Error, PartialEq)] diff --git a/sdk/src/signer/null_signer.rs b/sdk/src/signer/null_signer.rs new file mode 100644 index 00000000000000..d03f81b33d0972 --- /dev/null +++ b/sdk/src/signer/null_signer.rs @@ -0,0 +1,38 @@ +use crate::{ + pubkey::Pubkey, + signature::Signature, + signer::{Signer, SignerError}, +}; + +/// NullSigner - A `Signer` implementation that always produces `Signature::default()`. +/// Used as a placeholder for absentee signers whose 'Pubkey` is required to construct +/// the transaction +#[derive(Clone, Debug, Default)] +pub struct NullSigner { + pubkey: Pubkey, +} + +impl NullSigner { + pub fn new(pubkey: &Pubkey) -> Self { + Self { pubkey: *pubkey } + } +} + +impl Signer for NullSigner { + fn try_pubkey(&self) -> Result { + Ok(self.pubkey) + } + + fn try_sign_message(&self, _message: &[u8]) -> Result { + Ok(Signature::default()) + } +} + +impl PartialEq for NullSigner +where + T: Signer, +{ + fn eq(&self, other: &T) -> bool { + self.pubkey == other.pubkey() + } +}