Skip to content

Commit

Permalink
Adding bump
Browse files Browse the repository at this point in the history
  • Loading branch information
nalnir committed Nov 27, 2023
1 parent f1aa1c0 commit 36f184f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dao/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,10 @@ use crate::proposal::{
VotesCount,
};
use crate::storage::core::CoreState;
use crate::storage::core::{
PERSISTENT_BUMP_AMOUNT_HIGH_WATERMARK, PERSISTENT_BUMP_AMOUNT_LOW_WATERMARK,
};
use crate::storage::proposal_storage::ProposalStorageKey;

use crate::utils::core::{can_init_contract, get_core_state, set_core_state};

Expand Down Expand Up @@ -122,6 126,7 @@ impl DaoContractTrait for DaoContract {
}

fn vote(env: Env, from: Address, prop_id: u32, power: u32, vote: u32) {
let key = ProposalStorageKey::Proposal(prop_id);
// 1. Check if DAO member
let core_state = get_core_state(&env);
if !core_state.shareholders.contains(from.clone()) {
Expand Down Expand Up @@ -151,6 156,11 @@ impl DaoContractTrait for DaoContract {
} else {
panic_with_error!(env, VoteError::WrongVoteParam)
}
env.storage().persistent().bump(
&key,
PERSISTENT_BUMP_AMOUNT_LOW_WATERMARK,
PERSISTENT_BUMP_AMOUNT_HIGH_WATERMARK,
);
}

fn execute(env: Env, prop_id: u32) -> Vec<Val> {
Expand Down
3 changes: 3 additions & 0 deletions dao/src/storage/core.rs
Original file line number Diff line number Diff line change
@@ -1,5 1,8 @@
use soroban_sdk::{contracttype, Address, Vec};

pub(crate) const PERSISTENT_BUMP_AMOUNT_HIGH_WATERMARK: u32 = 34560; // 2 days
pub(crate) const PERSISTENT_BUMP_AMOUNT_LOW_WATERMARK: u32 = 17280; // 1 day

#[contracttype]
pub struct CoreState {
pub governance_token: Address,
Expand Down

0 comments on commit 36f184f

Please sign in to comment.