Add native program account constructor

This commit is contained in:
Greg Fitzgerald
2019-02-13 20:43:56 -07:00
committed by Grimes
parent 8790a92f07
commit 72b6ec4aa8
2 changed files with 25 additions and 56 deletions

View File

@ -1,3 +1,4 @@
use crate::account::Account;
use crate::pubkey::Pubkey;
pub const NATIVE_LOADER_PROGRAM_ID: [u8; 32] = [
@ -11,3 +12,14 @@ pub fn id() -> Pubkey {
pub fn check_id(program_id: &Pubkey) -> bool {
program_id.as_ref() == NATIVE_LOADER_PROGRAM_ID
}
/// Create an executable account owned by the given program_id and shared object name.
pub fn create_program_account(program_id: Pubkey, name: &str) -> Account {
Account {
tokens: 1,
owner: program_id,
userdata: name.as_bytes().to_vec(),
executable: true,
loader: id(),
}
}