refactor: move private PDA npk into proven ChainedCall and Claim

This commit is contained in:
Moudy
2026-04-16 16:53:54 +02:00
parent e08c8f93b4
commit bda21fb5c5
12 changed files with 147 additions and 106 deletions
@@ -41,6 +41,7 @@ fn main() {
instruction_data: instruction_data.clone(),
pre_states: vec![running_sender_pre.clone(), running_recipient_pre.clone()], /* <- Account order permutation here */
pda_seeds: pda_seed.iter().copied().collect(),
private_pda_seeds: vec![],
};
chained_calls.push(new_chained_call);
@@ -32,6 +32,7 @@ fn main() {
instruction_data: to_vec(&timestamp).unwrap(),
pre_states: pre_states.clone(),
pda_seeds: vec![],
private_pda_seeds: vec![],
};
ProgramOutput::new(
@@ -71,6 +71,7 @@ fn main() {
pre_states: vec![receiver_authorized, vault_pre.clone()],
instruction_data: transfer_instruction,
pda_seeds: vec![PdaSeed::new([1_u8; 32])],
private_pda_seeds: vec![],
});
}
// Malicious path (return_funds = false): emit no chained calls.
@@ -129,6 +129,7 @@ fn main() {
pre_states: vec![vault_authorized, receiver_pre.clone()],
instruction_data: transfer_instruction,
pda_seeds: vec![PdaSeed::new([0_u8; 32])],
private_pda_seeds: vec![],
};
// Chained call 2: User callback.
@@ -139,6 +140,7 @@ fn main() {
pre_states: vec![vault_after_transfer, receiver_after_transfer],
instruction_data: callback_instruction_data,
pda_seeds: vec![],
private_pda_seeds: vec![],
};
// Chained call 3: Self-call to enforce the invariant.
@@ -157,6 +159,7 @@ fn main() {
pre_states: vec![vault_after_callback],
instruction_data: invariant_instruction,
pda_seeds: vec![],
private_pda_seeds: vec![],
};
// The initiator itself makes no direct state changes.
@@ -39,6 +39,7 @@ fn main() {
instruction_data,
pre_states: vec![authorised_sender, receiver.clone()],
pda_seeds: vec![],
private_pda_seeds: vec![],
};
ProgramOutput::new(
@@ -37,6 +37,7 @@ fn main() {
instruction_data: chained_instruction,
pre_states,
pda_seeds: vec![],
private_pda_seeds: vec![],
};
ProgramOutput::new(