2019-03-14 07:55:41 -07:00
|
|
|
use crate::id;
|
|
|
|
use crate::ConfigState;
|
2019-03-23 20:12:27 -07:00
|
|
|
use solana_sdk::instruction::{AccountMeta, Instruction};
|
2019-03-14 07:55:41 -07:00
|
|
|
use solana_sdk::pubkey::Pubkey;
|
2019-04-03 08:45:57 -07:00
|
|
|
use solana_sdk::system_instruction;
|
2019-03-14 07:55:41 -07:00
|
|
|
|
2019-04-03 08:45:57 -07:00
|
|
|
/// Create a new, empty configuration account
|
|
|
|
pub fn create_account<T: ConfigState>(
|
|
|
|
from_account_pubkey: &Pubkey,
|
|
|
|
config_account_pubkey: &Pubkey,
|
|
|
|
lamports: u64,
|
|
|
|
) -> Instruction {
|
|
|
|
system_instruction::create_account(
|
|
|
|
from_account_pubkey,
|
|
|
|
config_account_pubkey,
|
|
|
|
lamports,
|
|
|
|
T::max_space(),
|
|
|
|
&id(),
|
|
|
|
)
|
|
|
|
}
|
2019-03-14 07:55:41 -07:00
|
|
|
|
2019-04-03 08:45:57 -07:00
|
|
|
/// Store new data in a configuration account
|
2019-05-12 22:47:12 -07:00
|
|
|
pub fn store<T: ConfigState>(config_account_pubkey: &Pubkey, data: &T) -> Instruction {
|
|
|
|
let account_metas = vec![AccountMeta::new(*config_account_pubkey, true)];
|
2019-04-03 08:45:57 -07:00
|
|
|
Instruction::new(id(), data, account_metas)
|
2019-03-14 07:55:41 -07:00
|
|
|
}
|