use crate::*;
#[derive(Accounts)]
pub struct SetOwner<'info> {
#[account(mut)]
pub permalock: AccountLoader<'info, Permalock>,
pub owner_setter: Signer<'info>,
pub new_owner: UncheckedAccount<'info>,
}
impl<'info> SetOwner<'info> {
fn set_owner(&self) -> Result<()> {
let permalock = &mut self.permalock.load_mut()?;
assert_keys_eq!(
self.owner_setter,
permalock.owner_setter,
UnauthorizedNotOwnerSetter
);
permalock.owner = self.new_owner.key();
Ok(())
}
}
pub fn handler(ctx: Context<SetOwner>) -> Result<()> {
ctx.accounts.set_owner()
}
impl<'info> Validate<'info> for SetOwner<'info> {
fn validate(&self) -> Result<()> {
Ok(())
}
}