solana/sdk/src/native_loader.rs

26 lines
704 B
Rust
Raw Normal View History

2019-02-13 19:43:56 -08:00
use crate::account::Account;
2018-12-14 20:39:10 -08:00
use crate::pubkey::Pubkey;
2018-12-03 13:31:11 -08:00
pub const NATIVE_LOADER_PROGRAM_ID: [u8; 32] = [
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
pub fn id() -> Pubkey {
Pubkey::new(&NATIVE_LOADER_PROGRAM_ID)
}
pub fn check_id(program_id: &Pubkey) -> bool {
program_id.as_ref() == NATIVE_LOADER_PROGRAM_ID
}
2019-02-13 19:43:56 -08:00
/// 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(),
}
}