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::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::system_instruction::SystemInstruction;
|
||||
use solana_sdk::system_program;
|
||||
use solana_sdk::system_transaction::SystemTransaction;
|
||||
|
||||
#[test]
|
||||
|
@ -1578,13 +1577,13 @@ mod tests {
|
|||
let bank = Arc::new(Bank::new(&genesis_block));
|
||||
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(
|
||||
&mint_keypair.pubkey(),
|
||||
&[key.pubkey()],
|
||||
&system_program::id(),
|
||||
&move_lamports,
|
||||
let mut tx = Transaction::new_signed_instructions(
|
||||
&Vec::<&Keypair>::new(),
|
||||
vec![move_instruction],
|
||||
bank.last_blockhash(),
|
||||
2,
|
||||
);
|
||||
|
|
|
@ -72,7 +72,7 @@ pub struct Transaction {
|
|||
}
|
||||
|
||||
impl Transaction {
|
||||
fn new_with_message(message: Message) -> Self {
|
||||
fn new_unsigned_message(message: Message) -> Self {
|
||||
Self {
|
||||
signatures: Vec::with_capacity(message.num_signatures as usize),
|
||||
account_keys: message.account_keys,
|
||||
|
@ -85,7 +85,7 @@ impl Transaction {
|
|||
|
||||
pub fn new(instructions: Vec<Instruction>) -> Self {
|
||||
let message = Message::new(instructions);
|
||||
Self::new_with_message(message)
|
||||
Self::new_unsigned_message(message)
|
||||
}
|
||||
|
||||
pub fn new_signed_instructions<T: KeypairUtil>(
|
||||
|
@ -100,25 +100,6 @@ impl Transaction {
|
|||
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>(
|
||||
from_keypair: &T,
|
||||
transaction_keys: &[Pubkey],
|
||||
|
@ -127,14 +108,14 @@ impl Transaction {
|
|||
recent_blockhash: Hash,
|
||||
fee: u64,
|
||||
) -> Self {
|
||||
let mut transaction = Self::new_with_blockhash_and_fee(
|
||||
&from_keypair.pubkey(),
|
||||
transaction_keys,
|
||||
program_id,
|
||||
data,
|
||||
Hash::default(),
|
||||
fee,
|
||||
);
|
||||
let mut account_metas = vec![AccountMeta::new(from_keypair.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.sign(&[from_keypair], recent_blockhash);
|
||||
transaction
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue