Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
constantindogaru committed Nov 24, 2021
1 parent a5c8c97 commit 8165282
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions sputnikdao2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,29 @@ impl Contract {
/// If active, do nothing.
/// If inactive, transfer the available amount of NEAR in this DAO to the dedicated account.
pub fn is_active(&mut self) -> bool {
let mut active = false;
let config = self
.get_config()
.self_destruct_config
.expect("ERR_NO_CONFIG");
let config = self.get_config().self_destruct_config;
if config.is_none() {
return true;
}
let config = config.unwrap();

// keep this in case we need to iterate through all of the proposals
// for id in (0..self.last_proposal_id).rev() {}

if self.last_proposal_id == 0 {
return true; // nothing to check since there are no proposals in this DAO
}

let last_proposal: Proposal = self
.proposals
.get(&(self.last_proposal_id - 1))
.expect("ERR_NO_PROPOSAL")
.into();

let allowed_inactivity_time =
1_000_000_000 * 60 * 60 * 24 * config.max_days_of_inactivity.0;

let mut active = false;
if last_proposal.submission_time.0 + allowed_inactivity_time >= env::block_timestamp() {
active = true; // it means this DAO is still active
}
Expand Down

0 comments on commit 8165282

Please sign in to comment.