Skip to content

Commit

Permalink
Merge pull request #784 from helium/bugfix/audit2
Browse files Browse the repository at this point in the history
Fix audit findings
  • Loading branch information
ChewingGlass authored Jan 29, 2025
2 parents 7c6c01f + a3e160e commit 3ef1508
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion programs/helium-sub-daos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "helium-sub-daos"
version = "0.2.0"
version = "0.2.1"
description = "Created with Anchor"
edition = "2021"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use crate::error::ErrorCode;
use crate::state::*;
use anchor_lang::prelude::*;
use anchor_spl::token::Mint;
use anchor_spl::token::TokenAccount;
use voter_stake_registry::state::LockupKind as VsrLockupKind;
use anchor_spl::token::{Mint, TokenAccount};
use voter_stake_registry::{
cpi::{accounts::ResetLockupV0 as VsrResetLockupV0, reset_lockup_v0},
state::{PositionV0, Registrar},
state::{LockupKind as VsrLockupKind, PositionV0, Registrar},
ResetLockupArgsV0 as VsrResetLockupArgsV0, VoterStakeRegistry,
};

use crate::{error::ErrorCode, state::*};

#[derive(Accounts)]
pub struct ResetLockupV0<'info> {
pub registrar: Box<Account<'info, Registrar>>,
Expand All @@ -30,7 +28,7 @@ pub struct ResetLockupV0<'info> {
#[account(
seeds = ["delegated_position".as_bytes(), position.key().as_ref()],
bump,
constraint = delegated_position.data_is_empty() && delegated_position.lamports() == 0 @ ErrorCode::PositionChangeWhileDelegated
constraint = delegated_position.data_is_empty() @ ErrorCode::PositionChangeWhileDelegated
)]
pub delegated_position: UncheckedAccount<'info>,
pub mint: Box<Account<'info, Mint>>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use crate::error::ErrorCode;
use crate::state::*;
use anchor_lang::prelude::*;
use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token::Mint;
use anchor_spl::token::Token;
use anchor_spl::token::TokenAccount;
use anchor_spl::{
associated_token::AssociatedToken,
token::{Mint, Token, TokenAccount},
};
use voter_stake_registry::{
cpi::{accounts::TransferV0 as VsrTransferV0, transfer_v0},
state::{PositionV0, Registrar},
TransferArgsV0 as VsrTransferArgsV0, VoterStakeRegistry,
};

use crate::{error::ErrorCode, state::*};

#[derive(Accounts)]
pub struct TransferV0<'info> {
pub registrar: Box<Account<'info, Registrar>>,
Expand All @@ -33,7 +33,7 @@ pub struct TransferV0<'info> {
#[account(
seeds = ["delegated_position".as_bytes(), source_position.key().as_ref()],
bump,
constraint = source_delegated_position.data_is_empty() && source_delegated_position.lamports() == 0 @ ErrorCode::PositionChangeWhileDelegated
constraint = source_delegated_position.data_is_empty() @ ErrorCode::PositionChangeWhileDelegated
)]
pub source_delegated_position: UncheckedAccount<'info>,
pub mint: Box<Account<'info, Mint>>,
Expand All @@ -53,7 +53,7 @@ pub struct TransferV0<'info> {
#[account(
seeds = ["delegated_position".as_bytes(), target_position.key().as_ref()],
bump,
constraint = target_delegated_position.data_is_empty() && target_delegated_position.lamports() == 0 @ ErrorCode::PositionChangeWhileDelegated
constraint = target_delegated_position.data_is_empty() @ ErrorCode::PositionChangeWhileDelegated
)]
pub target_delegated_position: UncheckedAccount<'info>,
pub deposit_mint: Box<Account<'info, Mint>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub fn handler(ctx: Context<IssueRewardsV0>, args: IssueRewardsArgsV0) -> Result
ctx.accounts.sub_dao_epoch_info.hnt_rewards_issued = escrow_amount;
ctx.accounts.dao_epoch_info.num_rewards_issued += 1;
ctx.accounts.sub_dao_epoch_info.rewards_issued_at = Some(Clock::get()?.unix_timestamp);
ctx.accounts.dao_epoch_info.delegation_rewards_issued = delegation_rewards_amount;
ctx.accounts.dao_epoch_info.delegation_rewards_issued += delegation_rewards_amount;
ctx.accounts.sub_dao_epoch_info.delegation_rewards_issued = 0;
ctx.accounts.dao_epoch_info.done_issuing_rewards =
ctx.accounts.dao.num_sub_daos == ctx.accounts.dao_epoch_info.num_rewards_issued;
Expand Down

0 comments on commit 3ef1508

Please sign in to comment.