fix: update example programs to use new sdk api
This commit is contained in:
parent
4a3a830789
commit
a4e7ce3133
|
@ -5,14 +5,14 @@
|
||||||
|
|
||||||
#include <solana_sdk.h>
|
#include <solana_sdk.h>
|
||||||
|
|
||||||
extern uint32_t entrypoint(const uint8_t *input) {
|
extern uint64_t entrypoint(const uint8_t *input) {
|
||||||
SolKeyedAccount ka[1];
|
SolKeyedAccount ka[1];
|
||||||
SolParameters params = (SolParameters) { .ka = ka };
|
SolParameters params = (SolParameters) { .ka = ka };
|
||||||
|
|
||||||
sol_log("Hello World");
|
sol_log("Hello World");
|
||||||
|
|
||||||
if (!sol_deserialize(input, ¶ms, SOL_ARRAY_SIZE(ka))) {
|
if (!sol_deserialize(input, ¶ms, SOL_ARRAY_SIZE(ka))) {
|
||||||
return 1;
|
return ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
sol_log_params(¶ms);
|
sol_log_params(¶ms);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
extern crate solana_sdk;
|
extern crate solana_sdk;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account_info::AccountInfo, entrypoint, entrypoint::SUCCESS, info, log::*, pubkey::Pubkey,
|
account_info::AccountInfo, entrypoint, info, log::*, program_error::ProgramError,
|
||||||
|
pubkey::Pubkey,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
@ -20,7 +21,11 @@ fn return_sstruct() -> SStruct {
|
||||||
}
|
}
|
||||||
|
|
||||||
entrypoint!(process_instruction);
|
entrypoint!(process_instruction);
|
||||||
fn process_instruction(program_id: &Pubkey, accounts: &mut [AccountInfo], data: &[u8]) -> u32 {
|
fn process_instruction(
|
||||||
|
program_id: &Pubkey,
|
||||||
|
accounts: &[AccountInfo],
|
||||||
|
ix_data: &[u8],
|
||||||
|
) -> Result<(), ProgramError> {
|
||||||
info!("Program identifier:");
|
info!("Program identifier:");
|
||||||
program_id.log();
|
program_id.log();
|
||||||
|
|
||||||
|
@ -28,7 +33,7 @@ fn process_instruction(program_id: &Pubkey, accounts: &mut [AccountInfo], data:
|
||||||
// the no-op program, no account keys or input data are expected but real
|
// the no-op program, no account keys or input data are expected but real
|
||||||
// programs will have specific requirements so they can do their work.
|
// programs will have specific requirements so they can do their work.
|
||||||
info!("Account keys and instruction input data:");
|
info!("Account keys and instruction input data:");
|
||||||
sol_log_params(accounts, data);
|
sol_log_params(accounts, ix_data);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Test - use std methods, unwrap
|
// Test - use std methods, unwrap
|
||||||
|
@ -54,7 +59,7 @@ fn process_instruction(program_id: &Pubkey, accounts: &mut [AccountInfo], data:
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
|
|
||||||
SUCCESS
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in New Issue