2025-12-03 16:39:33 -03:00
|
|
|
use nssa_core::program::{AccountPostState, ProgramInput, read_nssa_inputs, write_nssa_outputs};
|
2025-08-10 11:17:15 -03:00
|
|
|
|
2025-12-05 17:16:41 +03:00
|
|
|
type Instruction = Vec<u8>;
|
2025-08-10 18:51:55 -03:00
|
|
|
|
2025-12-05 17:16:41 +03:00
|
|
|
/// A program that modifies the account data by setting bytes sent in instruction.
|
2025-08-10 11:17:15 -03:00
|
|
|
fn main() {
|
2025-12-16 17:44:10 +03:00
|
|
|
let (
|
|
|
|
|
ProgramInput {
|
|
|
|
|
pre_states,
|
|
|
|
|
instruction: data,
|
|
|
|
|
},
|
|
|
|
|
instruction_words,
|
|
|
|
|
) = read_nssa_inputs::<Instruction>();
|
2025-08-10 11:17:15 -03:00
|
|
|
|
2025-08-14 14:30:04 -03:00
|
|
|
let [pre] = match pre_states.try_into() {
|
2025-08-10 11:17:15 -03:00
|
|
|
Ok(array) => array,
|
|
|
|
|
Err(_) => return,
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-14 14:09:04 -03:00
|
|
|
let account_pre = &pre.account;
|
2025-08-10 11:17:15 -03:00
|
|
|
let mut account_post = account_pre.clone();
|
2025-12-16 17:44:10 +03:00
|
|
|
account_post.data = data
|
|
|
|
|
.try_into()
|
|
|
|
|
.expect("provided data should fit into data limit");
|
2025-08-10 11:17:15 -03:00
|
|
|
|
2025-12-09 22:27:38 -03:00
|
|
|
write_nssa_outputs(
|
|
|
|
|
instruction_words,
|
|
|
|
|
vec![pre],
|
|
|
|
|
vec![AccountPostState::new_claimed(account_post)],
|
|
|
|
|
);
|
2025-08-10 11:17:15 -03:00
|
|
|
}
|