refactor: pass self_program_id to ProgramOutput in test and example guest programs

This commit is contained in:
moudyellaz
2026-04-02 20:30:16 +02:00
committed by Moudy
parent 58b72dd77c
commit 7def0c4664
21 changed files with 42 additions and 45 deletions
@@ -18,8 +18,7 @@ type Instruction = Vec<u8>;
fn main() {
// Read inputs
let (
ProgramInput {
self_program_id: _,
ProgramInput { self_program_id,
pre_states,
instruction: greeting,
},
@@ -51,5 +50,5 @@ fn main() {
// with the NSSA program rules.
// WARNING: constructing a `ProgramOutput` has no effect on its own. `.write()` must be
// called to commit the output.
ProgramOutput::new(instruction_data, vec![pre_state], vec![post_state]).write();
ProgramOutput::new(self_program_id, instruction_data, vec![pre_state], vec![post_state]).write();
}
@@ -18,8 +18,7 @@ type Instruction = Vec<u8>;
fn main() {
// Read inputs
let (
ProgramInput {
self_program_id: _,
ProgramInput { self_program_id,
pre_states,
instruction: greeting,
},
@@ -58,5 +57,5 @@ fn main() {
// with the NSSA program rules.
// WARNING: constructing a `ProgramOutput` has no effect on its own. `.write()` must be
// called to commit the output.
ProgramOutput::new(instruction_data, vec![pre_state], vec![post_state]).write();
ProgramOutput::new(self_program_id, instruction_data, vec![pre_state], vec![post_state]).write();
}
@@ -65,8 +65,7 @@ fn move_data(from_pre: AccountWithMetadata, to_pre: AccountWithMetadata) -> Vec<
fn main() {
// Read input accounts.
let (
ProgramInput {
self_program_id: _,
ProgramInput { self_program_id,
pre_states,
instruction: (function_id, data),
},
@@ -86,5 +85,5 @@ fn main() {
// WARNING: constructing a `ProgramOutput` has no effect on its own. `.write()` must be
// called to commit the output.
ProgramOutput::new(instruction_words, pre_states, post_states).write();
ProgramOutput::new(self_program_id, instruction_words, pre_states, post_states).write();
}
@@ -26,8 +26,7 @@ fn hello_world_program_id() -> ProgramId {
fn main() {
// Read inputs
let (
ProgramInput {
self_program_id: _,
ProgramInput { self_program_id,
pre_states,
instruction: (),
},
@@ -56,7 +55,7 @@ fn main() {
// Write the outputs.
// WARNING: constructing a `ProgramOutput` has no effect on its own. `.write()` must be
// called to commit the output.
ProgramOutput::new(instruction_data, vec![pre_state], vec![post_state])
ProgramOutput::new(self_program_id, instruction_data, vec![pre_state], vec![post_state])
.with_chained_calls(vec![chained_call])
.write();
}
@@ -32,8 +32,7 @@ fn hello_world_program_id() -> ProgramId {
fn main() {
// Read inputs
let (
ProgramInput {
self_program_id: _,
ProgramInput { self_program_id,
pre_states,
instruction: (),
},
@@ -69,7 +68,7 @@ fn main() {
// Write the outputs.
// WARNING: constructing a `ProgramOutput` has no effect on its own. `.write()` must be
// called to commit the output.
ProgramOutput::new(instruction_data, vec![pre_state], vec![post_state])
ProgramOutput::new(self_program_id, instruction_data, vec![pre_state], vec![post_state])
.with_chained_calls(vec![chained_call])
.write();
}