From e1e531b7bb3241d0b1bdf78cd5e40a09503c8972 Mon Sep 17 00:00:00 2001 From: ANISH-SR Date: Thu, 1 Jan 2026 15:05:35 +0530 Subject: [PATCH] feat: contributor acc verification --- .../src/processors/link/closeaccount.rs | 3 +++ .../src/processors/link/delete.rs | 10 +++++++--- .../src/processors/link/resume.rs | 10 +++++++--- .../src/processors/link/suspend.rs | 9 ++++++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/smartcontract/programs/doublezero-serviceability/src/processors/link/closeaccount.rs b/smartcontract/programs/doublezero-serviceability/src/processors/link/closeaccount.rs index 1792792bb..06e3336e2 100644 --- a/smartcontract/programs/doublezero-serviceability/src/processors/link/closeaccount.rs +++ b/smartcontract/programs/doublezero-serviceability/src/processors/link/closeaccount.rs @@ -85,6 +85,9 @@ pub fn process_closeaccount_link( let mut side_a_dev = Device::try_from(side_a_account)?; let mut side_z_dev = Device::try_from(side_z_account)?; let link: Link = Link::try_from(link_account)?; + if link.contributor_pk != *contributor_account.key { + return Err(DoubleZeroError::NotAllowed.into()); + } if link.owner != *owner_account.key { return Err(ProgramError::InvalidAccountData); diff --git a/smartcontract/programs/doublezero-serviceability/src/processors/link/delete.rs b/smartcontract/programs/doublezero-serviceability/src/processors/link/delete.rs index 881dbc45e..19a763b06 100644 --- a/smartcontract/programs/doublezero-serviceability/src/processors/link/delete.rs +++ b/smartcontract/programs/doublezero-serviceability/src/processors/link/delete.rs @@ -66,14 +66,18 @@ pub fn process_delete_link( let contributor = Contributor::try_from(contributor_account)?; - if contributor.owner != *payer_account.key - && !globalstate.foundation_allowlist.contains(payer_account.key) - { + let payer_in_foundation = globalstate.foundation_allowlist.contains(payer_account.key); + + if contributor.owner != *payer_account.key && !payer_in_foundation { return Err(DoubleZeroError::InvalidOwnerPubkey.into()); } // Any link can be deleted by its contributor or foundation allowlist on any status let mut link: Link = Link::try_from(link_account)?; + if !payer_in_foundation && link.contributor_pk != *contributor_account.key { + return Err(DoubleZeroError::NotAllowed.into()); + } + link.status = LinkStatus::Deleting; try_acc_write(&link, link_account, payer_account, accounts)?; diff --git a/smartcontract/programs/doublezero-serviceability/src/processors/link/resume.rs b/smartcontract/programs/doublezero-serviceability/src/processors/link/resume.rs index 51f161579..d3ccebd76 100644 --- a/smartcontract/programs/doublezero-serviceability/src/processors/link/resume.rs +++ b/smartcontract/programs/doublezero-serviceability/src/processors/link/resume.rs @@ -62,14 +62,18 @@ pub fn process_resume_link( let globalstate = GlobalState::try_from(globalstate_account)?; let contributor = Contributor::try_from(contributor_account)?; - if contributor.owner != *payer_account.key - && !globalstate.foundation_allowlist.contains(payer_account.key) - { + let payer_in_foundation = globalstate.foundation_allowlist.contains(payer_account.key); + + if contributor.owner != *payer_account.key && !payer_in_foundation { return Err(DoubleZeroError::InvalidOwnerPubkey.into()); } let mut link: Link = Link::try_from(link_account)?; + if !payer_in_foundation && link.contributor_pk != *contributor_account.key { + return Err(DoubleZeroError::NotAllowed.into()); + } + if link.status != LinkStatus::Suspended { return Err(DoubleZeroError::InvalidStatus.into()); } diff --git a/smartcontract/programs/doublezero-serviceability/src/processors/link/suspend.rs b/smartcontract/programs/doublezero-serviceability/src/processors/link/suspend.rs index 72e2f45e1..4f69de278 100644 --- a/smartcontract/programs/doublezero-serviceability/src/processors/link/suspend.rs +++ b/smartcontract/programs/doublezero-serviceability/src/processors/link/suspend.rs @@ -62,13 +62,16 @@ pub fn process_suspend_link( let globalstate = GlobalState::try_from(globalstate_account)?; let contributor = Contributor::try_from(contributor_account)?; - if contributor.owner != *payer_account.key - && !globalstate.foundation_allowlist.contains(payer_account.key) - { + let payer_in_foundation = globalstate.foundation_allowlist.contains(payer_account.key); + + if contributor.owner != *payer_account.key && !payer_in_foundation { return Err(DoubleZeroError::InvalidOwnerPubkey.into()); } let mut link: Link = Link::try_from(link_account)?; + if !payer_in_foundation && link.contributor_pk != *contributor_account.key { + return Err(DoubleZeroError::NotAllowed.into()); + } if link.status != LinkStatus::Activated { #[cfg(test)]