Move system_program out of src/

This commit is contained in:
Michael Vines
2018-12-03 13:32:31 -08:00
parent ae0be1e857
commit 9a4f8199d6
28 changed files with 332 additions and 571 deletions

View File

@@ -16,5 +16,5 @@ solana-sdk = { path = "../../../sdk", version = "0.11.0" }
[lib]
name = "solana_erc20"
crate-type = ["lib", "cdylib"]
crate-type = ["cdylib"]

View File

@@ -10,49 +10,26 @@ extern crate serde_derive;
#[macro_use]
extern crate solana_sdk;
use solana_sdk::account::{Account, KeyedAccount};
use solana_sdk::native_loader;
use solana_sdk::account::KeyedAccount;
use solana_sdk::native_program::ProgramError;
use solana_sdk::pubkey::Pubkey;
use std::sync::{Once, ONCE_INIT};
mod token_program;
const ERC20_NAME: &str = "solana_erc20";
const ERC20_PROGRAM_ID: [u8; 32] = [
131, 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(&ERC20_PROGRAM_ID)
}
pub fn account() -> Account {
Account {
tokens: 1,
owner: id(),
userdata: ERC20_NAME.as_bytes().to_vec(),
executable: true,
loader: native_loader::id(),
}
}
solana_entrypoint!(entrypoint);
fn entrypoint(
program_id: &Pubkey,
info: &mut [KeyedAccount],
input: &[u8],
_tick_height: u64,
) -> bool {
) -> Result<(), ProgramError> {
// env_logger can only be initialized once
static INIT: Once = ONCE_INIT;
INIT.call_once(env_logger::init);
match token_program::TokenProgram::process(program_id, info, input) {
Err(err) => {
error!("error: {:?}", err);
false
}
Ok(_) => true,
}
token_program::TokenProgram::process(program_id, info, input).map_err(|err| {
error!("error: {:?}", err);
ProgramError::GenericError
})
}