Skip to content

Commit

Permalink
Adding a new assert_derivation for when the bump is known.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Apr 6, 2024
1 parent 7dab5d1 commit c221c16
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/rust/utils/src/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ pub fn assert_derivation(
Ok(bump)
}

pub fn assert_derivation_with_bump(
program_id: &Pubkey,
account: &AccountInfo,
path: &[&[u8]],
error: impl Into<ProgramError>,
) -> Result<(), ProgramError> {
let key = Pubkey::create_program_address(path, program_id)?;
if key != *account.key {
return Err(error.into());
}
Ok(())
}

pub fn assert_rent_exempt(
rent: &Rent,
account_info: &AccountInfo,
Expand Down

0 comments on commit c221c16

Please sign in to comment.