Remove a mostly unused Transaction constructor
This commit is contained in:
parent
c09e0eb536
commit
ca2ac1e5ea
|
@ -930,7 +930,6 @@ mod tests {
|
||||||
use solana_sdk::instruction::InstructionError;
|
use solana_sdk::instruction::InstructionError;
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::system_instruction::SystemInstruction;
|
use solana_sdk::system_instruction::SystemInstruction;
|
||||||
use solana_sdk::system_program;
|
|
||||||
use solana_sdk::system_transaction::SystemTransaction;
|
use solana_sdk::system_transaction::SystemTransaction;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1578,13 +1577,13 @@ mod tests {
|
||||||
let bank = Arc::new(Bank::new(&genesis_block));
|
let bank = Arc::new(Bank::new(&genesis_block));
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
|
|
||||||
let move_lamports = SystemInstruction::Move { lamports: 1 };
|
let mut move_instruction =
|
||||||
|
SystemInstruction::new_move(&mint_keypair.pubkey(), &key.pubkey(), 1);
|
||||||
|
move_instruction.accounts[0].is_signer = false;
|
||||||
|
|
||||||
let mut tx = Transaction::new_with_blockhash_and_fee(
|
let mut tx = Transaction::new_signed_instructions(
|
||||||
&mint_keypair.pubkey(),
|
&Vec::<&Keypair>::new(),
|
||||||
&[key.pubkey()],
|
vec![move_instruction],
|
||||||
&system_program::id(),
|
|
||||||
&move_lamports,
|
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
2,
|
2,
|
||||||
);
|
);
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub struct Transaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Transaction {
|
impl Transaction {
|
||||||
fn new_with_message(message: Message) -> Self {
|
fn new_unsigned_message(message: Message) -> Self {
|
||||||
Self {
|
Self {
|
||||||
signatures: Vec::with_capacity(message.num_signatures as usize),
|
signatures: Vec::with_capacity(message.num_signatures as usize),
|
||||||
account_keys: message.account_keys,
|
account_keys: message.account_keys,
|
||||||
|
@ -85,7 +85,7 @@ impl Transaction {
|
||||||
|
|
||||||
pub fn new(instructions: Vec<Instruction>) -> Self {
|
pub fn new(instructions: Vec<Instruction>) -> Self {
|
||||||
let message = Message::new(instructions);
|
let message = Message::new(instructions);
|
||||||
Self::new_with_message(message)
|
Self::new_unsigned_message(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_signed_instructions<T: KeypairUtil>(
|
pub fn new_signed_instructions<T: KeypairUtil>(
|
||||||
|
@ -100,25 +100,6 @@ impl Transaction {
|
||||||
tx
|
tx
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_blockhash_and_fee<T: Serialize>(
|
|
||||||
from_pubkey: &Pubkey,
|
|
||||||
transaction_keys: &[Pubkey],
|
|
||||||
program_id: &Pubkey,
|
|
||||||
data: &T,
|
|
||||||
recent_blockhash: Hash,
|
|
||||||
fee: u64,
|
|
||||||
) -> Self {
|
|
||||||
let mut account_metas = vec![AccountMeta::new(*from_pubkey, true)];
|
|
||||||
for pubkey in transaction_keys {
|
|
||||||
account_metas.push(AccountMeta::new(*pubkey, false));
|
|
||||||
}
|
|
||||||
let instruction = Instruction::new(*program_id, data, account_metas);
|
|
||||||
let mut transaction = Self::new(vec![instruction]);
|
|
||||||
transaction.fee = fee;
|
|
||||||
transaction.recent_blockhash = recent_blockhash;
|
|
||||||
transaction
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_signed<S: Serialize, T: KeypairUtil>(
|
pub fn new_signed<S: Serialize, T: KeypairUtil>(
|
||||||
from_keypair: &T,
|
from_keypair: &T,
|
||||||
transaction_keys: &[Pubkey],
|
transaction_keys: &[Pubkey],
|
||||||
|
@ -127,14 +108,14 @@ impl Transaction {
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
fee: u64,
|
fee: u64,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut transaction = Self::new_with_blockhash_and_fee(
|
let mut account_metas = vec![AccountMeta::new(from_keypair.pubkey(), true)];
|
||||||
&from_keypair.pubkey(),
|
for pubkey in transaction_keys {
|
||||||
transaction_keys,
|
account_metas.push(AccountMeta::new(*pubkey, false));
|
||||||
program_id,
|
}
|
||||||
data,
|
let instruction = Instruction::new(*program_id, data, account_metas);
|
||||||
Hash::default(),
|
let mut transaction = Self::new(vec![instruction]);
|
||||||
fee,
|
transaction.fee = fee;
|
||||||
);
|
transaction.recent_blockhash = recent_blockhash;
|
||||||
transaction.sign(&[from_keypair], recent_blockhash);
|
transaction.sign(&[from_keypair], recent_blockhash);
|
||||||
transaction
|
transaction
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue