-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deposit limit #52
Deposit limit #52
Changes from all commits
2f531ad
e121c12
d7d1014
fdbed8f
2500321
9e6aebc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,24 +5,25 @@ use access_control::{ | |
state::{UserRole, Role} | ||
}; | ||
|
||
use crate::constants::WHITELISTED_SEED; | ||
use crate::state::{Vault, Whitelisted}; | ||
use crate::constants::USER_DATA_SEED; | ||
use crate::state::{UserData, Vault}; | ||
use crate::events::WhitelistUpdatedEvent; | ||
|
||
#[derive(Accounts)] | ||
#[instruction(user: Pubkey)] | ||
pub struct Whitelist<'info> { | ||
#[account( | ||
init, | ||
init_if_needed, | ||
seeds = [ | ||
WHITELISTED_SEED.as_bytes(), | ||
USER_DATA_SEED.as_bytes(), | ||
vault.key().as_ref(), | ||
user.as_ref() | ||
], | ||
bump, | ||
payer = signer, | ||
space = Whitelisted::LEN, | ||
space = UserData::LEN, | ||
)] | ||
pub whitelisted: Account<'info, Whitelisted>, | ||
pub user_data: Account<'info, UserData>, | ||
|
||
#[account(mut)] | ||
pub vault: AccountLoader<'info, Vault>, | ||
|
@@ -48,6 +49,12 @@ pub struct Whitelist<'info> { | |
|
||
|
||
pub fn handle_whitelist(ctx: Context<Whitelist>, _user: Pubkey) -> Result<()> { | ||
ctx.accounts.whitelisted.is_whitelisted = true; | ||
ctx.accounts.user_data.whitelisted = true; | ||
|
||
emit!(WhitelistUpdatedEvent { | ||
user: _user, | ||
whitelisted: true, | ||
}); | ||
|
||
Ok(()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be nice if a whitelist event gets emitted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Front-end engineers were asking how to check whether a user was whitelisted, I had to tell them a way to check whether a PDA initialized or not when there was whitelist PDa. Ideally it's good if the subgraph can provide such info. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. event was added, checking if PDA initialized won't work, cause now we have UserData PDA istead |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
pub mod config; | ||
pub mod strategy_data; | ||
pub mod vault; | ||
pub mod whitelist; | ||
pub mod user_data; | ||
|
||
pub use config::*; | ||
pub use strategy_data::*; | ||
pub use vault::*; | ||
pub use whitelist::*; | ||
pub use user_data::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice of revoke whitelist event gets emitted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event was added