2020-12-14 15:35:10 -08:00
|
|
|
//! @brief Example Rust-based BPF upgraded program
|
|
|
|
|
|
|
|
extern crate solana_program;
|
|
|
|
use solana_program::{
|
2021-01-04 13:45:05 -08:00
|
|
|
account_info::AccountInfo,
|
|
|
|
entrypoint,
|
|
|
|
entrypoint::ProgramResult,
|
|
|
|
msg,
|
|
|
|
pubkey::Pubkey,
|
|
|
|
sysvar::{clock, fees},
|
2020-12-14 15:35:10 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
entrypoint!(process_instruction);
|
|
|
|
fn process_instruction(
|
2021-01-04 13:45:05 -08:00
|
|
|
program_id: &Pubkey,
|
2020-12-17 01:02:31 -08:00
|
|
|
accounts: &[AccountInfo],
|
2020-12-14 15:35:10 -08:00
|
|
|
_instruction_data: &[u8],
|
|
|
|
) -> ProgramResult {
|
|
|
|
msg!("Upgraded program");
|
2021-01-04 13:45:05 -08:00
|
|
|
assert_eq!(accounts.len(), 3);
|
|
|
|
assert_eq!(accounts[0].key, program_id);
|
|
|
|
assert_eq!(*accounts[1].key, clock::id());
|
|
|
|
assert_eq!(*accounts[2].key, fees::id());
|
2020-12-14 15:35:10 -08:00
|
|
|
Err(43.into())
|
|
|
|
}
|