Skip to content

Commit

Permalink
Merge pull request #32 from woonetwork/audit_issue_29
Browse files Browse the repository at this point in the history
store bump in seeds for rebate manager
  • Loading branch information
toprince authored Oct 9, 2024
2 parents e184043 + 871464b commit 4c91bef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ pub fn handler(ctx: Context<CreateRebateManager>) -> Result<()> {
let authority = ctx.accounts.authority.key();
let quote_token_mint = ctx.accounts.quote_token_mint.key();
let token_vault = ctx.accounts.token_vault.key();
let bump = ctx.bumps.rebate_manager;

let rebate_manager = &mut ctx.accounts.rebate_manager;

rebate_manager.initialize(authority, quote_token_mint, token_vault)
rebate_manager.initialize(authority, quote_token_mint, token_vault, bump)
}
7 changes: 6 additions & 1 deletion programs/rebate_manager/src/state/rebate_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub const ADMIN_AUTH_MAX_LEN: usize = 5;
pub struct RebateManager {
pub authority: Pubkey, // 32

pub rebate_manager_bump: [u8; 1], // 1

#[max_len(ADMIN_AUTH_MAX_LEN)]
pub admin_authority: Vec<Pubkey>,

Expand All @@ -51,10 +53,11 @@ pub struct RebateManager {
}

impl RebateManager {
pub fn seeds(&self) -> [&[u8]; 2] {
pub fn seeds(&self) -> [&[u8]; 3] {
[
REBATEMANAGER_SEED.as_bytes(),
self.quote_token_mint.as_ref(),
self.rebate_manager_bump.as_ref(),
]
}

Expand All @@ -63,10 +66,12 @@ impl RebateManager {
authority: Pubkey,
quote_token_mint: Pubkey,
token_vault: Pubkey,
bump: u8
) -> Result<()> {
self.authority = authority;
self.quote_token_mint = quote_token_mint;
self.token_vault = token_vault;
self.rebate_manager_bump = [bump];

Ok(())
}
Expand Down

0 comments on commit 4c91bef

Please sign in to comment.