2025-12-03 16:39:33 -03:00
|
|
|
use nssa_core::program::{AccountPostState, ProgramInput, read_nssa_inputs, write_nssa_outputs};
|
2025-08-10 11:02:59 -03:00
|
|
|
|
2025-08-10 18:59:29 -03:00
|
|
|
type Instruction = u128;
|
2025-08-10 18:51:55 -03:00
|
|
|
|
2025-08-10 11:02:59 -03:00
|
|
|
fn main() {
|
2025-11-18 01:38:47 -03:00
|
|
|
let (
|
|
|
|
|
ProgramInput {
|
|
|
|
|
pre_states,
|
|
|
|
|
instruction: balance,
|
|
|
|
|
},
|
|
|
|
|
instruction_words,
|
|
|
|
|
) = read_nssa_inputs::<Instruction>();
|
2025-08-10 11:02:59 -03:00
|
|
|
|
2026-03-03 23:21:08 +03:00
|
|
|
let Ok([sender_pre, receiver_pre]) = <[_; 2]>::try_from(pre_states) else {
|
|
|
|
|
return;
|
2025-08-10 11:02:59 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let mut sender_post = sender_pre.account.clone();
|
|
|
|
|
let mut receiver_post = receiver_pre.account.clone();
|
2026-03-04 18:42:33 +03:00
|
|
|
sender_post.balance = sender_post
|
|
|
|
|
.balance
|
|
|
|
|
.checked_sub(balance)
|
|
|
|
|
.expect("Not enough balance to transfer");
|
|
|
|
|
receiver_post.balance = receiver_post
|
|
|
|
|
.balance
|
|
|
|
|
.checked_add(balance)
|
|
|
|
|
.expect("Overflow when adding balance");
|
2025-08-10 11:02:59 -03:00
|
|
|
|
2025-08-14 14:09:04 -03:00
|
|
|
write_nssa_outputs(
|
2025-11-18 01:38:47 -03:00
|
|
|
instruction_words,
|
2025-08-14 14:09:04 -03:00
|
|
|
vec![sender_pre, receiver_pre],
|
2025-12-03 16:39:33 -03:00
|
|
|
vec![
|
|
|
|
|
AccountPostState::new(sender_post),
|
|
|
|
|
AccountPostState::new(receiver_post),
|
|
|
|
|
],
|
2025-08-14 14:09:04 -03:00
|
|
|
);
|
2025-08-10 11:02:59 -03:00
|
|
|
}
|