Support transaction signing by heterogenous lists of keypairs (bp #8342) (#8362)

automerge
This commit is contained in:
mergify[bot]
2020-02-20 14:02:14 -08:00
committed by GitHub
parent b4eb81546e
commit 9dffc3abe4
16 changed files with 191 additions and 81 deletions

View File

@@ -730,7 +730,7 @@ mod tests {
let mut error_counters = ErrorCounters::default();
let instructions = vec![CompiledInstruction::new(0, &(), vec![0])];
let tx = Transaction::new_with_compiled_instructions::<Keypair>(
let tx = Transaction::new_with_compiled_instructions::<[&Keypair; 0]>(
&[],
&[],
Hash::default(),

View File

@@ -9,6 +9,7 @@ use solana_sdk::{
message::Message,
pubkey::Pubkey,
signature::{Keypair, KeypairUtil, Signature},
signers::Signers,
system_instruction,
transaction::{self, Transaction},
transport::{Result, TransportError},
@@ -42,13 +43,13 @@ impl AsyncClient for BankClient {
Ok(signature)
}
fn async_send_message(
fn async_send_message<T: Signers>(
&self,
keypairs: &[&Keypair],
keypairs: &T,
message: Message,
recent_blockhash: Hash,
) -> io::Result<Signature> {
let transaction = Transaction::new(&keypairs, message, recent_blockhash);
let transaction = Transaction::new(keypairs, message, recent_blockhash);
self.async_send_transaction(transaction)
}
@@ -77,9 +78,9 @@ impl AsyncClient for BankClient {
}
impl SyncClient for BankClient {
fn send_message(&self, keypairs: &[&Keypair], message: Message) -> Result<Signature> {
fn send_message<T: Signers>(&self, keypairs: &T, message: Message) -> Result<Signature> {
let blockhash = self.bank.last_blockhash();
let transaction = Transaction::new(&keypairs, message, blockhash);
let transaction = Transaction::new(keypairs, message, blockhash);
self.bank.process_transaction(&transaction)?;
Ok(transaction.signatures.get(0).cloned().unwrap_or_default())
}

View File

@@ -61,7 +61,7 @@ fn fill_epoch_with_votes(
Some(&mint_pubkey),
);
assert!(bank_client
.send_message(&[&mint_keypair, &vote_keypair], message)
.send_message(&[mint_keypair, vote_keypair], message)
.is_ok());
}
bank

View File

@@ -372,7 +372,7 @@ fn submit_proof(
);
assert_matches!(
bank_client.send_message(&[&mint_keypair, &storage_keypair], message),
bank_client.send_message(&[mint_keypair, storage_keypair], message),
Ok(_)
);
ProofStatus::Valid