Skip to content

Commit 2d11dea

Browse files
committed
refactor(program): remove dead validate_pda_with_bump trait method
No concrete type called this — all override `validate_self` with `Address::derive_address` directly. Default `validate_self` now falls back to `validate_pda` (canonical bump enforcement).
1 parent 722e364 commit 2d11dea

1 file changed

Lines changed: 1 addition & 24 deletions

File tree

program/src/traits/pda.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,6 @@ pub trait PdaSeeds {
3737
Ok(())
3838
}
3939

40-
/// Validate that account matches PDA derived with the provided bump.
41-
///
42-
/// This does not enforce canonical bump selection. Use `validate_pda`
43-
/// when canonical bump invariants must be enforced (e.g., account creation).
44-
#[inline(always)]
45-
fn validate_pda_with_bump(
46-
&self,
47-
account: &AccountView,
48-
program_id: &Address,
49-
bump: u8,
50-
) -> Result<(), ProgramError> {
51-
let seeds = self.seeds();
52-
let bump_arr = [bump];
53-
let mut seeds_with_bump = seeds;
54-
seeds_with_bump.push(&bump_arr[..]);
55-
let derived =
56-
Address::create_program_address(&seeds_with_bump, program_id).map_err(|_| ProgramError::InvalidSeeds)?;
57-
if account.address() != &derived {
58-
return Err(ProgramError::InvalidSeeds);
59-
}
60-
Ok(())
61-
}
62-
6340
/// Validate that account address matches derived PDA and return the canonical bump.
6441
///
6542
/// Uses `find_program_address` — only call this when the bump is not already known.
@@ -83,7 +60,7 @@ pub trait PdaAccount: PdaSeeds {
8360
/// Validate that account matches derived PDA using stored bump
8461
#[inline(always)]
8562
fn validate_self(&self, account: &AccountView, program_id: &Address) -> Result<(), ProgramError> {
86-
self.validate_pda_with_bump(account, program_id, self.bump())
63+
self.validate_pda(account, program_id, self.bump())
8764
}
8865
}
8966

0 commit comments

Comments
 (0)