Skip to content

Commit

Permalink
feat: add 4 years param
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrust committed Apr 7, 2022
1 parent 1fbb82d commit bad8f60
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions programs/ve_honey/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ pub mod exit;
pub mod init_escrow;
pub mod init_locker;
pub mod lock;
pub mod set_params;
pub mod whitelist;

pub use exit::*;
pub use init_escrow::*;
pub use init_locker::*;
pub use lock::*;
pub use set_params::*;
pub use whitelist::*;
26 changes: 26 additions & 0 deletions programs/ve_honey/src/context/set_params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use crate::state::*;
use anchor_lang::prelude::*;
use vipers::*;

#[derive(Accounts)]
pub struct SetLockerParams<'info> {
pub admin: Signer<'info>,
#[account(mut)]
pub locker: Box<Account<'info, Locker>>,
}

impl<'info> SetLockerParams<'info> {
pub fn process(&mut self, params: LockerParams) -> Result<()> {
self.locker.params = params;

Ok(())
}
}

impl<'info> Validate<'info> for SetLockerParams<'info> {
fn validate(&self) -> Result<()> {
assert_keys_eq!(self.admin, self.locker.admin);

Ok(())
}
}
6 changes: 6 additions & 0 deletions programs/ve_honey/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ pub mod ve_honey {
Ok(())
}

#[access_control(ctx.accounts.validate())]
pub fn set_locker_params(ctx: Context<SetLockerParams>, params: LockerParams) -> Result<()> {
ctx.accounts.process(params)?;
Ok(())
}

#[access_control(ctx.accounts.validate())]
pub fn init_escrow(ctx: Context<InitEscrow>) -> Result<()> {
ctx.accounts.process(unwrap_bump!(ctx, "escrow"))?;
Expand Down

0 comments on commit bad8f60

Please sign in to comment.