From bad8f607045a5e771aa88b7d967955bcef4db159 Mon Sep 17 00:00:00 2001 From: Freezy Gem Date: Thu, 7 Apr 2022 16:02:30 +0000 Subject: [PATCH] feat: add 4 years param --- programs/ve_honey/src/context.rs | 2 ++ programs/ve_honey/src/context/set_params.rs | 26 +++++++++++++++++++++ programs/ve_honey/src/lib.rs | 6 +++++ 3 files changed, 34 insertions(+) create mode 100644 programs/ve_honey/src/context/set_params.rs diff --git a/programs/ve_honey/src/context.rs b/programs/ve_honey/src/context.rs index 1a17242..579f21a 100644 --- a/programs/ve_honey/src/context.rs +++ b/programs/ve_honey/src/context.rs @@ -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::*; diff --git a/programs/ve_honey/src/context/set_params.rs b/programs/ve_honey/src/context/set_params.rs new file mode 100644 index 0000000..0a3d64d --- /dev/null +++ b/programs/ve_honey/src/context/set_params.rs @@ -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>, +} + +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(()) + } +} diff --git a/programs/ve_honey/src/lib.rs b/programs/ve_honey/src/lib.rs index 8a52820..bccd952 100644 --- a/programs/ve_honey/src/lib.rs +++ b/programs/ve_honey/src/lib.rs @@ -26,6 +26,12 @@ pub mod ve_honey { Ok(()) } + #[access_control(ctx.accounts.validate())] + pub fn set_locker_params(ctx: Context, params: LockerParams) -> Result<()> { + ctx.accounts.process(params)?; + Ok(()) + } + #[access_control(ctx.accounts.validate())] pub fn init_escrow(ctx: Context) -> Result<()> { ctx.accounts.process(unwrap_bump!(ctx, "escrow"))?;