Skip to content

Commit aa2a0c8

Browse files
committed
feat: contributor acc verification
1 parent db85799 commit aa2a0c8

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

smartcontract/programs/doublezero-serviceability/src/processors/link/closeaccount.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ pub fn process_closeaccount_link(
8383
let mut side_a_dev = Device::try_from(side_a_account)?;
8484
let mut side_z_dev = Device::try_from(side_z_account)?;
8585
let link: Link = Link::try_from(link_account)?;
86+
if link.contributor_pk != *contributor_account.key {
87+
return Err(DoubleZeroError::NotAllowed.into());
88+
}
8689

8790
if link.owner != *owner_account.key {
8891
return Err(ProgramError::InvalidAccountData);

smartcontract/programs/doublezero-serviceability/src/processors/link/delete.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,18 @@ pub fn process_delete_link(
6565

6666
let contributor = Contributor::try_from(contributor_account)?;
6767

68-
if contributor.owner != *payer_account.key
69-
&& !globalstate.foundation_allowlist.contains(payer_account.key)
70-
{
68+
let payer_in_foundation = globalstate.foundation_allowlist.contains(payer_account.key);
69+
70+
if contributor.owner != *payer_account.key && !payer_in_foundation {
7171
return Err(DoubleZeroError::InvalidOwnerPubkey.into());
7272
}
7373

7474
// Any link can be deleted by its contributor or foundation allowlist on any status
7575
let mut link: Link = Link::try_from(link_account)?;
76+
if !payer_in_foundation && link.contributor_pk != *contributor_account.key {
77+
return Err(DoubleZeroError::NotAllowed.into());
78+
}
79+
7680
link.status = LinkStatus::Deleting;
7781

7882
account_write(link_account, &link, payer_account, system_program)?;

smartcontract/programs/doublezero-serviceability/src/processors/link/resume.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,18 @@ pub fn process_resume_link(
6363
let globalstate = globalstate_get(globalstate_account)?;
6464
let contributor = Contributor::try_from(contributor_account)?;
6565

66-
if contributor.owner != *payer_account.key
67-
&& !globalstate.foundation_allowlist.contains(payer_account.key)
68-
{
66+
let payer_in_foundation = globalstate.foundation_allowlist.contains(payer_account.key);
67+
68+
if contributor.owner != *payer_account.key && !payer_in_foundation {
6969
return Err(DoubleZeroError::InvalidOwnerPubkey.into());
7070
}
7171

7272
let mut link: Link = Link::try_from(link_account)?;
7373

74+
if !payer_in_foundation && link.contributor_pk != *contributor_account.key {
75+
return Err(DoubleZeroError::NotAllowed.into());
76+
}
77+
7478
if link.status != LinkStatus::Suspended {
7579
return Err(DoubleZeroError::InvalidStatus.into());
7680
}

smartcontract/programs/doublezero-serviceability/src/processors/link/suspend.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ pub fn process_suspend_link(
6363
let globalstate = globalstate_get(globalstate_account)?;
6464
let contributor = Contributor::try_from(contributor_account)?;
6565

66-
if contributor.owner != *payer_account.key
67-
&& !globalstate.foundation_allowlist.contains(payer_account.key)
68-
{
66+
let payer_in_foundation = globalstate.foundation_allowlist.contains(payer_account.key);
67+
68+
if contributor.owner != *payer_account.key && !payer_in_foundation {
6969
return Err(DoubleZeroError::InvalidOwnerPubkey.into());
7070
}
7171

7272
let mut link: Link = Link::try_from(link_account)?;
73+
if !payer_in_foundation && link.contributor_pk != *contributor_account.key {
74+
return Err(DoubleZeroError::NotAllowed.into());
75+
}
7376

7477
if link.status != LinkStatus::Activated {
7578
#[cfg(test)]

0 commit comments

Comments
 (0)