Merge branch 'main' into schouhy/add-block-context-system-accounts

This commit is contained in:
Sergio Chouhy
2026-04-02 19:48:55 -03:00
78 changed files with 1262 additions and 253 deletions
+31 -6
View File
@@ -14,6 +14,7 @@ use nssa_core::program::{ProgramInput, ProgramOutput, read_nssa_inputs};
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
instruction,
},
@@ -112,15 +113,15 @@ fn main() {
min_amount_to_remove_token_b,
)
}
Instruction::Swap {
Instruction::SwapExactInput {
swap_amount_in,
min_amount_out,
token_definition_id_in,
} => {
let [pool, vault_a, vault_b, user_holding_a, user_holding_b] = pre_states
.try_into()
.expect("Transfer instruction requires exactly five accounts");
amm_program::swap::swap(
.expect("SwapExactInput instruction requires exactly five accounts");
amm_program::swap::swap_exact_input(
pool,
vault_a,
vault_b,
@@ -131,9 +132,33 @@ fn main() {
token_definition_id_in,
)
}
Instruction::SwapExactOutput {
exact_amount_out,
max_amount_in,
token_definition_id_in,
} => {
let [pool, vault_a, vault_b, user_holding_a, user_holding_b] = pre_states
.try_into()
.expect("SwapExactOutput instruction requires exactly five accounts");
amm_program::swap::swap_exact_output(
pool,
vault_a,
vault_b,
user_holding_a,
user_holding_b,
exact_amount_out,
max_amount_in,
token_definition_id_in,
)
}
};
ProgramOutput::new(instruction_words, pre_states_clone, post_states)
.with_chained_calls(chained_calls)
.write();
ProgramOutput::new(
self_program_id,
instruction_words,
pre_states_clone,
post_states,
)
.with_chained_calls(chained_calls)
.write();
}
@@ -4,6 +4,7 @@ use nssa_core::program::{ProgramInput, ProgramOutput, read_nssa_inputs};
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
instruction,
},
@@ -56,7 +57,12 @@ fn main() {
}
};
ProgramOutput::new(instruction_words, pre_states_clone, post_states)
.with_chained_calls(chained_calls)
.write();
ProgramOutput::new(
self_program_id,
instruction_words,
pre_states_clone,
post_states,
)
.with_chained_calls(chained_calls)
.write();
}
@@ -67,6 +67,7 @@ fn main() {
// Read input accounts.
let (
ProgramInput {
self_program_id,
pre_states,
instruction: balance_to_move,
},
@@ -84,5 +85,5 @@ fn main() {
_ => panic!("invalid params"),
};
ProgramOutput::new(instruction_words, pre_states, post_states).write();
ProgramOutput::new(self_program_id, instruction_words, pre_states, post_states).write();
}
+2
View File
@@ -29,6 +29,7 @@ fn update_if_multiple(
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
instruction: timestamp,
},
@@ -68,6 +69,7 @@ fn main() {
let (pre_50, post_50) = update_if_multiple(pre_50, 50, current_block_id, updated_data);
ProgramOutput::new(
self_program_id,
instruction_words,
vec![pre_01, pre_10, pre_50],
vec![post_01, post_10, post_50],
+2
View File
@@ -46,6 +46,7 @@ fn main() {
// It is expected to receive only two accounts: [pinata_account, winner_account]
let (
ProgramInput {
self_program_id,
pre_states,
instruction: solution,
},
@@ -79,6 +80,7 @@ fn main() {
.expect("Overflow when adding prize to winner");
ProgramOutput::new(
self_program_id,
instruction_words,
vec![pinata, winner],
vec![
@@ -52,6 +52,7 @@ fn main() {
// winner_token_holding]
let (
ProgramInput {
self_program_id,
pre_states,
instruction: solution,
},
@@ -97,6 +98,7 @@ fn main() {
.with_pda_seeds(vec![PdaSeed::new([0; 32])]);
ProgramOutput::new(
self_program_id,
instruction_words,
vec![
pinata_definition,
@@ -107,6 +107,13 @@ impl ExecutionState {
|_: Infallible| unreachable!("Infallible error is never constructed"),
);
// Verify that the program output's self_program_id matches the expected program ID.
// This ensures the proof commits to which program produced the output.
assert_eq!(
program_output.self_program_id, chained_call.program_id,
"Program output self_program_id does not match chained call program_id"
);
// Check that the program is well behaved.
// See the # Programs section for the definition of the `validate_execution` method.
let execution_valid = validate_execution(
+8 -1
View File
@@ -12,6 +12,7 @@ use token_program::core::Instruction;
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
instruction,
},
@@ -81,5 +82,11 @@ fn main() {
}
};
ProgramOutput::new(instruction_words, pre_states_clone, post_states).write();
ProgramOutput::new(
self_program_id,
instruction_words,
pre_states_clone,
post_states,
)
.write();
}