feat: add caller_program_id to ProgramInput

This commit is contained in:
moudyellaz
2026-04-03 00:58:11 +02:00
committed by Moudy
parent d105a51c04
commit 087baebcca
31 changed files with 60 additions and 163 deletions
+1 -2
View File
@@ -4,8 +4,7 @@ type Instruction = u128;
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: balance_to_burn,
},
@@ -12,8 +12,7 @@ type Instruction = (u128, ProgramId, u32, Option<PdaSeed>);
/// program.
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: (balance, auth_transfer_id, num_chain_calls, pda_seed),
},
@@ -5,8 +5,7 @@ type Instruction = (Option<Vec<u8>>, bool);
/// A program that optionally modifies the account data and optionally claims it.
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: (data_opt, should_claim),
},
@@ -34,11 +33,5 @@ fn main() {
AccountPostState::new(account_post)
};
ProgramOutput::new(
self_program_id,
instruction_words,
vec![pre],
vec![post_state],
)
.write();
ProgramOutput::new(self_program_id, instruction_words, vec![pre], vec![post_state]).write();
}
@@ -4,8 +4,7 @@ type Instruction = ();
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: (),
},
@@ -18,11 +17,5 @@ fn main() {
let account_post = AccountPostState::new_claimed(pre.account.clone(), Claim::Authorized);
ProgramOutput::new(
self_program_id,
instruction_words,
vec![pre],
vec![account_post],
)
.write();
ProgramOutput::new(self_program_id, instruction_words, vec![pre], vec![account_post]).write();
}
@@ -5,8 +5,7 @@ type Instruction = Vec<u8>;
/// A program that modifies the account data by setting bytes sent in instruction.
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: data,
},
@@ -6,14 +6,7 @@ use nssa_core::{
type Instruction = ();
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let (ProgramInput { self_program_id, caller_program_id: _, pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -13,8 +13,7 @@ type Instruction = (u128, ProgramId);
/// but sets the `is_authorized` field of the first account to true.
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: (balance, transfer_program_id),
},
+1 -8
View File
@@ -3,14 +3,7 @@ use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nss
type Instruction = ();
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let (ProgramInput { self_program_id, caller_program_id: _, pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -3,14 +3,7 @@ use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nss
type Instruction = ();
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let (ProgramInput { self_program_id, caller_program_id: _, pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let Ok([pre1, pre2]) = <[_; 2]>::try_from(pre_states) else {
return;
@@ -63,8 +63,7 @@ fn transfer(
fn main() {
// Read input accounts.
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: balance_to_move,
},
@@ -3,14 +3,7 @@ use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nss
type Instruction = ();
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let (ProgramInput { self_program_id, caller_program_id: _, pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
+1 -8
View File
@@ -3,14 +3,7 @@ use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nss
type Instruction = ();
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let (ProgramInput { self_program_id, caller_program_id: _, pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let post_states = pre_states
.iter()
@@ -3,14 +3,7 @@ use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nss
type Instruction = ();
fn main() {
let (
ProgramInput {
self_program_id,
pre_states,
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let (ProgramInput { self_program_id, caller_program_id: _, pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -4,8 +4,7 @@ type Instruction = u128;
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: balance,
},
@@ -7,8 +7,7 @@ type Instruction = (BlockValidityWindow, TimestampValidityWindow);
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: (block_validity_window, timestamp_validity_window),
},
@@ -15,8 +15,7 @@ type Instruction = (BlockValidityWindow, ProgramId, BlockValidityWindow);
fn main() {
let (
ProgramInput {
self_program_id,
ProgramInput { self_program_id, caller_program_id: _,
pre_states,
instruction: (block_validity_window, chained_program_id, chained_block_validity_window),
},