Add sdk native_loader.rs

This commit is contained in:
Michael Vines 2018-12-03 13:31:11 -08:00
parent bf2658cee0
commit 63a758508a
5 changed files with 13 additions and 10 deletions

View File

@ -1,6 +1,7 @@
pub mod account;
pub mod hash;
pub mod loader_instruction;
pub mod native_loader;
pub mod native_program;
pub mod packet;
pub mod pubkey;

9
sdk/src/native_loader.rs Normal file
View File

@ -0,0 +1,9 @@
use pubkey::Pubkey;
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)
}

View File

@ -1,6 +1,6 @@
//! BPF loader
use native_loader;
use solana_sdk::account::Account;
use solana_sdk::native_loader;
use solana_sdk::pubkey::Pubkey;
const BPF_LOADER_NAME: &str = "solana_bpf_loader";

View File

@ -7,6 +7,7 @@ use libloading::os::unix::*;
use libloading::os::windows::*;
use solana_sdk::account::KeyedAccount;
use solana_sdk::loader_instruction::LoaderInstruction;
pub use solana_sdk::native_loader::*;
use solana_sdk::native_program;
use solana_sdk::pubkey::Pubkey;
use std::env;
@ -41,18 +42,10 @@ fn create_path(name: &str) -> PathBuf {
)
}
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 check_id(program_id: &Pubkey) -> bool {
program_id.as_ref() == NATIVE_LOADER_PROGRAM_ID
}
pub fn id() -> Pubkey {
Pubkey::new(&NATIVE_LOADER_PROGRAM_ID)
}
pub fn process_instruction(
program_id: &Pubkey,
keyed_accounts: &mut [KeyedAccount],

View File

@ -1,6 +1,6 @@
//! ERC20-like Token program
use native_loader;
use solana_sdk::account::Account;
use solana_sdk::native_loader;
use solana_sdk::pubkey::Pubkey;
const ERC20_NAME: &str = "solana_erc20";