add note why clawback is possible when someone is engaged in an active proposal (#39)

* add comment

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

* remove unused

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

* fix test

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-02-10 19:34:48 +01:00 committed by GitHub
parent 7ff4ad2e23
commit 69767b2323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 12 deletions

View File

@ -19,17 +19,6 @@ pub struct Clawback<'info> {
has_one = registrar)]
pub voter: AccountLoader<'info, Voter>,
/// The token_owner_record for the voter_authority. This is needed
/// to be able to forbid withdraws while the voter is engaged with
/// a vote or has an open proposal.
///
/// token_owner_record is validated in the instruction:
/// - owned by registrar.governance_program_id
/// - for the registrar.realm
/// - for the registrar.realm_governing_token_mint
/// - governing_token_owner is voter_authority
pub token_owner_record: UncheckedAccount<'info>,
#[account(
mut,
associated_token::authority = voter,
@ -68,6 +57,11 @@ pub fn clawback(ctx: Context<Clawback>, deposit_entry_index: u8) -> Result<()> {
// Load the accounts.
let registrar = &ctx.accounts.registrar.load()?;
let voter = &mut ctx.accounts.voter.load_mut()?;
// Note: don't assert if token_owner_record is engaged in active proposals
// since this way a grantee could block clawback
// Get the deposit being clawed back from.
let deposit_entry = voter.active_deposit_mut(deposit_entry_index)?;
require!(
deposit_entry.allow_clawback,

View File

@ -427,7 +427,6 @@ impl AddinCookie {
&voter_stake_registry::accounts::Clawback {
registrar: registrar.address,
voter: voter.address,
token_owner_record: voter.token_owner_record,
vault,
destination: token_address,
realm_authority: realm_authority.pubkey(),