smart_wallet/instructions/
unapprove.rs

1//! Instruction handler for [smart_wallet::unapprove].
2
3use crate::*;
4
5/// Instruction handler for [smart_wallet::unapprove].
6pub fn handler(ctx: Context<Approve>) -> Result<()> {
7    let owner_index = ctx
8        .accounts
9        .smart_wallet
10        .try_owner_index(ctx.accounts.owner.key())?;
11    ctx.accounts.transaction.signers[owner_index] = false;
12
13    emit!(TransactionUnapproveEvent {
14        smart_wallet: ctx.accounts.smart_wallet.key(),
15        transaction: ctx.accounts.transaction.key(),
16        owner: ctx.accounts.owner.key(),
17        timestamp: Clock::get()?.unix_timestamp
18    });
19    Ok(())
20}