2018-12-04 15:18:35 -08:00
|
|
|
//! The `loader_transaction` module provides functionality for loading and calling a program
|
2018-10-16 09:43:49 -07:00
|
|
|
|
2018-12-14 20:39:10 -08:00
|
|
|
use crate::hash::Hash;
|
|
|
|
use crate::loader_instruction::LoaderInstruction;
|
|
|
|
use crate::pubkey::Pubkey;
|
|
|
|
use crate::signature::Keypair;
|
|
|
|
use crate::transaction::Transaction;
|
2018-10-16 09:43:49 -07:00
|
|
|
|
2019-02-01 08:36:35 -07:00
|
|
|
pub struct LoaderTransaction {}
|
2018-10-16 09:43:49 -07:00
|
|
|
|
2019-02-01 08:36:35 -07:00
|
|
|
impl LoaderTransaction {
|
|
|
|
pub fn new_write(
|
2018-10-16 09:43:49 -07:00
|
|
|
from_keypair: &Keypair,
|
|
|
|
loader: Pubkey,
|
|
|
|
offset: u32,
|
|
|
|
bytes: Vec<u8>,
|
|
|
|
last_id: Hash,
|
2018-11-05 09:36:22 -07:00
|
|
|
fee: u64,
|
2019-02-01 08:36:35 -07:00
|
|
|
) -> Transaction {
|
2018-10-16 09:43:49 -07:00
|
|
|
let instruction = LoaderInstruction::Write { offset, bytes };
|
2018-11-06 06:50:00 -07:00
|
|
|
Transaction::new(from_keypair, &[], loader, &instruction, last_id, fee)
|
2018-10-16 09:43:49 -07:00
|
|
|
}
|
|
|
|
|
2019-02-01 08:36:35 -07:00
|
|
|
pub fn new_finalize(
|
|
|
|
from_keypair: &Keypair,
|
|
|
|
loader: Pubkey,
|
|
|
|
last_id: Hash,
|
|
|
|
fee: u64,
|
|
|
|
) -> Transaction {
|
2018-10-16 09:43:49 -07:00
|
|
|
let instruction = LoaderInstruction::Finalize;
|
2018-11-06 06:50:00 -07:00
|
|
|
Transaction::new(from_keypair, &[], loader, &instruction, last_id, fee)
|
2018-10-16 09:43:49 -07:00
|
|
|
}
|
|
|
|
}
|