Rename TransactionCompiler to Script and use it to replace the type alias

This commit is contained in:
Greg Fitzgerald
2019-03-17 09:55:42 -06:00
committed by Grimes
parent 99671472d1
commit 122c7bc2ef
9 changed files with 60 additions and 47 deletions

View File

@ -5,9 +5,10 @@ use bincode::serialized_size;
use chrono::prelude::{DateTime, Utc};
use serde_derive::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::script::Script;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::transaction::{Instruction, Script};
use solana_sdk::transaction::Instruction;
/// A smart contract.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
@ -48,10 +49,10 @@ impl BudgetInstruction {
expr: BudgetExpr,
) -> Script {
let space = serialized_size(&BudgetState::new(expr.clone())).unwrap();
vec![
Script::new(vec![
SystemInstruction::new_program_account(&from, contract, lamports, space, &id()),
Self::new_initialize_account(contract, expr),
]
])
}
/// Create a new payment script.

View File

@ -5,9 +5,10 @@ use bincode::deserialize;
use chrono::prelude::*;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::script::Script;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::transaction::{Script, Transaction};
use solana_sdk::transaction::Transaction;
pub struct BudgetTransaction {}
@ -18,7 +19,7 @@ impl BudgetTransaction {
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let mut tx = Transaction::new(script);
let mut tx = script.compile();
tx.fee = fee;
tx.sign(&[from_keypair], recent_blockhash);
tx