This commit is contained in:
cavemanloverboy 2024-04-14 22:35:07 +02:00 committed by GitHub
commit 1d65b1a30d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 35 deletions

View File

@ -8,7 +8,7 @@ use solana_sdk::{
commitment_config::CommitmentConfig, signature::Signature, signer::Signer,
transaction::Transaction,
};
use std::{marker::PhantomData, ops::Deref, sync::Arc};
use std::{marker::PhantomData, sync::Arc};
use tokio::{
runtime::{Builder, Handle},
sync::RwLock,
@ -21,7 +21,7 @@ impl<'a> EventUnsubscriber<'a> {
}
}
impl<C: Deref<Target = impl Signer> + Clone> Program<C> {
impl<C: Signer + Clone> Program<C> {
pub fn new(program_id: Pubkey, cfg: Config<C>) -> Result<Self, ClientError> {
let rt: tokio::runtime::Runtime = Builder::new_multi_thread().enable_all().build()?;
@ -70,7 +70,7 @@ impl<C: Deref<Target = impl Signer> + Clone> Program<C> {
}
}
impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C> {
impl<'a, C: Signer + Clone> RequestBuilder<'a, C> {
pub fn from(
program_id: Pubkey,
cluster: &str,

View File

@ -88,7 +88,6 @@ use solana_sdk::signature::{Signature, Signer};
use solana_sdk::transaction::Transaction;
use std::iter::Map;
use std::marker::PhantomData;
use std::ops::Deref;
use std::pin::Pin;
use std::sync::Arc;
use std::vec::IntoIter;
@ -125,7 +124,7 @@ pub struct Client<C> {
cfg: Config<C>,
}
impl<C: Clone + Deref<Target = impl Signer>> Client<C> {
impl<C: Clone + Signer> Client<C> {
pub fn new(cluster: Cluster, payer: C) -> Self {
Self {
cfg: Config {
@ -157,35 +156,35 @@ impl<C: Clone + Deref<Target = impl Signer>> Client<C> {
}
}
/// Auxiliary data structure to align the types of the Solana CLI utils with Anchor client.
/// Client<C> implementation requires <C: Clone + Deref<Target = impl Signer>> which does not comply with Box<dyn Signer>
/// that's used when loaded Signer from keypair file. This struct is used to wrap the usage.
pub struct DynSigner(pub Arc<dyn Signer>);
// /// Auxiliary data structure to align the types of the Solana CLI utils with Anchor client.
// /// Client<C> implementation requires <C: Clone + impl Signer> which does not comply with Box<dyn Signer>
// /// that's used when loaded Signer from keypair file. This struct is used to wrap the usage.
// pub struct DynSigner(pub Arc<dyn Signer>);
impl Signer for DynSigner {
fn pubkey(&self) -> Pubkey {
self.0.pubkey()
}
// impl Signer for DynSigner {
// fn pubkey(&self) -> Pubkey {
// self.0.pubkey()
// }
fn try_pubkey(&self) -> Result<Pubkey, solana_sdk::signer::SignerError> {
self.0.try_pubkey()
}
// fn try_pubkey(&self) -> Result<Pubkey, solana_sdk::signer::SignerError> {
// self.0.try_pubkey()
// }
fn sign_message(&self, message: &[u8]) -> solana_sdk::signature::Signature {
self.0.sign_message(message)
}
// fn sign_message(&self, message: &[u8]) -> solana_sdk::signature::Signature {
// self.0.sign_message(message)
// }
fn try_sign_message(
&self,
message: &[u8],
) -> Result<solana_sdk::signature::Signature, solana_sdk::signer::SignerError> {
self.0.try_sign_message(message)
}
// fn try_sign_message(
// &self,
// message: &[u8],
// ) -> Result<solana_sdk::signature::Signature, solana_sdk::signer::SignerError> {
// self.0.try_sign_message(message)
// }
fn is_interactive(&self) -> bool {
self.0.is_interactive()
}
}
// fn is_interactive(&self) -> bool {
// self.0.is_interactive()
// }
// }
// Internal configuration for a client.
#[derive(Debug)]
@ -222,7 +221,7 @@ pub struct Program<C> {
rt: tokio::runtime::Runtime,
}
impl<C: Deref<Target = impl Signer> + Clone> Program<C> {
impl<C: Signer + Clone> Program<C> {
pub fn payer(&self) -> Pubkey {
self.cfg.payer.pubkey()
}
@ -519,7 +518,7 @@ pub struct RequestBuilder<'a, C> {
handle: &'a Handle,
}
impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C> {
impl<'a, C: Signer + Clone> RequestBuilder<'a, C> {
#[must_use]
pub fn payer(mut self, payer: C) -> Self {
self.payer = payer;
@ -618,7 +617,7 @@ impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C> {
) -> Result<Transaction, ClientError> {
let instructions = self.instructions()?;
let mut signers = self.signers.clone();
signers.push(&*self.payer);
signers.push(&self.payer);
let tx = Transaction::new_signed_with_payer(
&instructions,

View File

@ -8,7 +8,7 @@ use solana_sdk::{
commitment_config::CommitmentConfig, signature::Signature, signer::Signer,
transaction::Transaction,
};
use std::{marker::PhantomData, ops::Deref, sync::Arc};
use std::{marker::PhantomData, sync::Arc};
use tokio::sync::RwLock;
impl<'a> EventUnsubscriber<'a> {
@ -18,7 +18,7 @@ impl<'a> EventUnsubscriber<'a> {
}
}
impl<C: Deref<Target = impl Signer> + Clone> Program<C> {
impl<C: Signer + Clone> Program<C> {
pub fn new(program_id: Pubkey, cfg: Config<C>) -> Result<Self, ClientError> {
Ok(Self {
program_id,
@ -66,7 +66,7 @@ impl<C: Deref<Target = impl Signer> + Clone> Program<C> {
}
}
impl<'a, C: Deref<Target = impl Signer> + Clone> RequestBuilder<'a, C> {
impl<'a, C: Signer + Clone> RequestBuilder<'a, C> {
pub fn from(
program_id: Pubkey,
cluster: &str,