Skip to content

Commit

Permalink
add events
Browse files Browse the repository at this point in the history
  • Loading branch information
vito-kovalione committed Dec 18, 2024
1 parent fdbed8f commit 2500321
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions programs/tokenized_vault/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ pub struct StrategyReportedEvent {
pub protocol_fees: u64,
pub total_fees: u64,
pub timestamp: i64,
}

#[event]
pub struct WhitelistUpdatedEvent {
pub user: Pubkey,
pub whitelisted: bool,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use access_control::{

use crate::constants::USER_DATA_SEED;
use crate::state::{Vault, UserData};
use crate::events::WhitelistUpdatedEvent;

#[derive(Accounts)]
#[instruction(user: Pubkey)]
Expand Down Expand Up @@ -46,5 +47,11 @@ pub struct RevokeWhitelisting<'info> {

pub fn handle_revoke_whitelisting(ctx: Context<RevokeWhitelisting>, _user: Pubkey) -> Result<()> {
ctx.accounts.user_data.whitelisted = false;

emit!(WhitelistUpdatedEvent {
user: _user,
whitelisted: false,
});

Ok(())
}
7 changes: 7 additions & 0 deletions programs/tokenized_vault/src/instructions/whitelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use access_control::{

use crate::constants::USER_DATA_SEED;
use crate::state::{UserData, Vault};
use crate::events::WhitelistUpdatedEvent;

#[derive(Accounts)]
#[instruction(user: Pubkey)]
Expand Down Expand Up @@ -49,5 +50,11 @@ pub struct Whitelist<'info> {

pub fn handle_whitelist(ctx: Context<Whitelist>, _user: Pubkey) -> Result<()> {
ctx.accounts.user_data.whitelisted = true;

emit!(WhitelistUpdatedEvent {
user: _user,
whitelisted: true,
});

Ok(())
}

0 comments on commit 2500321

Please sign in to comment.