Route program_id to program entrypoint
This commit is contained in:
@@ -11,17 +11,23 @@ extern crate serde_derive;
|
||||
extern crate solana_sdk;
|
||||
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
mod token_program;
|
||||
|
||||
solana_entrypoint!(entrypoint);
|
||||
fn entrypoint(info: &mut [KeyedAccount], input: &[u8], _tick_height: u64) -> bool {
|
||||
fn entrypoint(
|
||||
program_id: &Pubkey,
|
||||
info: &mut [KeyedAccount],
|
||||
input: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> bool {
|
||||
// env_logger can only be initialized once
|
||||
static INIT: Once = ONCE_INIT;
|
||||
INIT.call_once(env_logger::init);
|
||||
|
||||
match token_program::TokenProgram::process(info, input) {
|
||||
match token_program::TokenProgram::process(program_id, info, input) {
|
||||
Err(err) => {
|
||||
error!("error: {:?}", err);
|
||||
false
|
||||
|
@@ -402,7 +402,7 @@ impl TokenProgram {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn process(info: &mut [KeyedAccount], input: &[u8]) -> Result<()> {
|
||||
pub fn process(program_id: &Pubkey, info: &mut [KeyedAccount], input: &[u8]) -> Result<()> {
|
||||
let command = bincode::deserialize::<Command>(input).map_err(Self::map_to_invalid_args)?;
|
||||
info!("process_transaction: command={:?}", command);
|
||||
|
||||
@@ -410,13 +410,7 @@ impl TokenProgram {
|
||||
.iter()
|
||||
.map(|keyed_account| {
|
||||
let account = &keyed_account.account;
|
||||
|
||||
//
|
||||
// TODO: Restore the following commented out block to valid program ids
|
||||
// once https://github.com/solana-labs/solana/issues/1544 is fixed.
|
||||
|
||||
/*
|
||||
if account.program_id == info[0].account.program_id {
|
||||
if account.owner == *program_id {
|
||||
match Self::deserialize(&account.userdata) {
|
||||
Ok(token_program) => token_program,
|
||||
Err(err) => {
|
||||
@@ -427,14 +421,6 @@ impl TokenProgram {
|
||||
} else {
|
||||
TokenProgram::Invalid
|
||||
}
|
||||
*/
|
||||
match Self::deserialize(&account.userdata) {
|
||||
Ok(token_program) => token_program,
|
||||
Err(err) => {
|
||||
error!("deserialize failed: {:?}", err);
|
||||
TokenProgram::Invalid
|
||||
}
|
||||
}
|
||||
}).collect();
|
||||
|
||||
for program_account in &input_program_accounts {
|
||||
|
Reference in New Issue
Block a user