Ensure the behavior of the bump ix arguments is unchanged

This commit is contained in:
Christian Kamm 2022-04-25 20:57:26 +02:00
parent 233e5414f4
commit 8eee11a86a
3 changed files with 13 additions and 0 deletions

View File

@ -48,6 +48,7 @@ pub struct CreateRegistrar<'info> {
/// used for voting.
pub fn create_registrar(ctx: Context<CreateRegistrar>, registrar_bump: u8) -> Result<()> {
let registrar = &mut ctx.accounts.registrar.load_init()?;
require_eq!(registrar_bump, *ctx.bumps.get("registrar").unwrap());
registrar.bump = registrar_bump;
registrar.governance_program_id = ctx.accounts.governance_program_id.key();
registrar.realm = ctx.accounts.realm.key();

View File

@ -67,6 +67,12 @@ pub fn create_voter(
);
}
require_eq!(voter_bump, *ctx.bumps.get("voter").unwrap());
require_eq!(
voter_weight_record_bump,
*ctx.bumps.get("voter_weight_record").unwrap()
);
// Load accounts.
let registrar = &ctx.accounts.registrar.load()?;
let voter_authority = ctx.accounts.voter_authority.key();

View File

@ -105,6 +105,12 @@ pub fn grant(
allow_clawback: bool,
amount: u64,
) -> Result<()> {
require_eq!(voter_bump, *ctx.bumps.get("voter").unwrap());
require_eq!(
voter_weight_record_bump,
*ctx.bumps.get("voter_weight_record").unwrap()
);
// Load accounts.
let registrar = &ctx.accounts.registrar.load()?;
let voter_authority = ctx.accounts.voter_authority.key();