Abandon Builder pattern

This commit is contained in:
Greg Fitzgerald
2019-03-15 10:54:56 -06:00
parent aca739b800
commit 24d9138067
10 changed files with 108 additions and 114 deletions

View File

@@ -11,7 +11,6 @@ use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::transaction::Transaction;
use solana_sdk::transaction_builder::TransactionBuilder;
pub struct BudgetTransaction {}
@@ -31,7 +30,7 @@ impl BudgetTransaction {
let create_ix =
SystemInstruction::new_program_account(&from, contract, lamports, space, &id());
let init_ix = BudgetInstruction::new_initialize_account(contract, expr);
let mut tx = TransactionBuilder::new(vec![create_ix, init_ix]).compile();
let mut tx = Transaction::new(vec![create_ix, init_ix]);
tx.fee = fee;
tx.sign(&[from_keypair], recent_blockhash);
tx
@@ -67,7 +66,7 @@ impl BudgetTransaction {
) -> Transaction {
let from = from_keypair.pubkey();
let ix = BudgetInstruction::new_apply_timestamp(&from, contract, to, dt);
let mut tx = TransactionBuilder::new(vec![ix]).compile();
let mut tx = Transaction::new(vec![ix]);
tx.sign(&[from_keypair], recent_blockhash);
tx
}
@@ -81,7 +80,7 @@ impl BudgetTransaction {
) -> Transaction {
let from = from_keypair.pubkey();
let ix = BudgetInstruction::new_apply_signature(&from, contract, to);
let mut tx = TransactionBuilder::new(vec![ix]).compile();
let mut tx = Transaction::new(vec![ix]);
tx.sign(&[from_keypair], recent_blockhash);
tx
}

View File

@@ -9,7 +9,6 @@ use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction;
use solana_sdk::transaction_builder::TransactionBuilder;
use solana_vote_api::vote_instruction::VoteInstruction;
pub struct RewardsTransaction {}
@@ -42,7 +41,7 @@ impl RewardsTransaction {
let vote_id = vote_keypair.pubkey();
let redeem_ix = RewardsInstruction::new_redeem_vote_credits(&vote_id, rewards_id);
let clear_ix = VoteInstruction::new_clear_credits(&vote_id);
let mut tx = TransactionBuilder::new(vec![redeem_ix, clear_ix]).compile();
let mut tx = Transaction::new(vec![redeem_ix, clear_ix]);
tx.fee = fee;
tx.sign(&[vote_keypair], blockhash);
tx

View File

@@ -5,8 +5,7 @@ use solana_sdk::native_program::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::transaction::{Instruction, InstructionError, TransactionError};
use solana_sdk::transaction_builder::TransactionBuilder;
use solana_sdk::transaction::{Instruction, InstructionError, Transaction, TransactionError};
use solana_vote_api::vote_instruction::{Vote, VoteInstruction};
use solana_vote_api::vote_state::VoteState;
use solana_vote_api::vote_transaction::VoteTransaction;
@@ -120,10 +119,8 @@ fn test_vote_via_bank_with_no_signature() {
// Sneak in an instruction so that the transaction is signed but
// the 0th account in the second instruction is not! The program
// needs to check that it's signed.
let mut tx = TransactionBuilder::default()
.push(SystemInstruction::new_move(&mallory_id, &vote_id, 1))
.push(vote_ix)
.compile();
let move_ix = SystemInstruction::new_move(&mallory_id, &vote_id, 1);
let mut tx = Transaction::new(vec![move_ix, vote_ix]);
tx.sign(&[&mallory_keypair], blockhash);
let result = bank.process_transaction(&tx);

View File

@@ -9,7 +9,6 @@ use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::transaction::Transaction;
use solana_sdk::transaction_builder::TransactionBuilder;
pub struct VoteTransaction {}
@@ -23,7 +22,7 @@ impl VoteTransaction {
) -> Transaction {
let vote = Vote { slot };
let ix = VoteInstruction::new_vote(staking_account, vote);
let mut tx = TransactionBuilder::new(vec![ix]).compile();
let mut tx = Transaction::new(vec![ix]);
tx.fee = fee;
tx.sign(&[authorized_voter_keypair], recent_blockhash);
tx
@@ -42,7 +41,7 @@ impl VoteTransaction {
let create_ix =
SystemInstruction::new_program_account(&from_id, staker_id, lamports, space, &id());
let init_ix = VoteInstruction::new_initialize_account(staker_id);
let mut tx = TransactionBuilder::new(vec![create_ix, init_ix]).compile();
let mut tx = Transaction::new(vec![create_ix, init_ix]);
tx.fee = fee;
tx.sign(&[from_keypair], recent_blockhash);
tx
@@ -64,7 +63,7 @@ impl VoteTransaction {
SystemInstruction::new_program_account(&from_id, &voter_id, lamports, space, &id());
let init_ix = VoteInstruction::new_initialize_account(&voter_id);
let delegate_ix = VoteInstruction::new_delegate_stake(&voter_id, &delegate_id);
let mut tx = TransactionBuilder::new(vec![create_ix, init_ix, delegate_ix]).compile();
let mut tx = Transaction::new(vec![create_ix, init_ix, delegate_ix]);
tx.fee = fee;
tx.sign(&[from_keypair, voter_keypair], recent_blockhash);
tx
@@ -78,7 +77,7 @@ impl VoteTransaction {
fee: u64,
) -> Transaction {
let ix = VoteInstruction::new_authorize_voter(&vote_keypair.pubkey(), authorized_voter_id);
let mut tx = TransactionBuilder::new(vec![ix]).compile();
let mut tx = Transaction::new(vec![ix]);
tx.fee = fee;
tx.sign(&[vote_keypair], recent_blockhash);
tx
@@ -92,7 +91,7 @@ impl VoteTransaction {
fee: u64,
) -> Transaction {
let ix = VoteInstruction::new_delegate_stake(&vote_keypair.pubkey(), node_id);
let mut tx = TransactionBuilder::new(vec![ix]).compile();
let mut tx = Transaction::new(vec![ix]);
tx.fee = fee;
tx.sign(&[vote_keypair], recent_blockhash);
tx