Skip to content
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

Add unapprove instruction #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions programs/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ pub mod serum_multisig {
Ok(())
}

// Unapproves a transaction on behalf of an owner of the multisig.
pub fn unapprove(ctx: Context<Unapprove>) -> Result<()> {
let owner_index = ctx
.accounts
.multisig
.owners
.iter()
.position(|a| a == ctx.accounts.owner.key)
.ok_or(ErrorCode::InvalidOwner)?;

ctx.accounts.transaction.signers[owner_index] = false;

Ok(())
}

// Set owners and threshold at once.
pub fn set_owners_and_change_threshold<'info>(
ctx: Context<'_, '_, '_, 'info, Auth<'info>>,
Expand Down Expand Up @@ -215,6 +230,17 @@ pub struct Approve<'info> {
owner: AccountInfo<'info>,
}

#[derive(Accounts)]
pub struct Unapprove<'info> {
#[account(constraint = multisig.owner_set_seqno == transaction.owner_set_seqno)]
multisig: ProgramAccount<'info, Multisig>,
#[account(mut, has_one = multisig)]
transaction: ProgramAccount<'info, Transaction>,
// One of the multisig owners. Checked in the handler.
#[account(signer)]
owner: AccountInfo<'info>,
}

#[derive(Accounts)]
pub struct Auth<'info> {
#[account(mut)]
Expand Down