Skip to content

Commit

Permalink
fix bug with timestamp in checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemka374 committed Aug 16, 2023
1 parent 5541265 commit 7863269
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/src/governance/utils/votes/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
Data,
VotesEvents,
},
governor::TimestampProvider,
traits::errors::{
CheckpointsError,
GovernanceError,
Expand All @@ -18,7 +19,7 @@ use openbrush::traits::{
Storage,
};

pub trait VotesInternal: Storage<Data> + VotesEvents {
pub trait VotesInternal: Storage<Data> + VotesEvents + TimestampProvider {
fn _get_total_supply(&self) -> Balance {
self.data::<Data>().total_checkpoints.get_or_default().latest()
}
Expand Down Expand Up @@ -128,7 +129,7 @@ pub trait VotesInternal: Storage<Data> + VotesEvents {
delta: Balance,
) -> Result<(u128, u128), GovernanceError> {
let (old_value, new_value) = store
.push(Self::env().block_timestamp(), op(store.latest(), delta)?)
.push(TimestampProvider::block_timestamp(self), op(store.latest(), delta)?)
.map_err(|err| <CheckpointsError as Into<GovernanceError>>::into(err))?;
Ok((old_value, new_value))
}
Expand Down

0 comments on commit 7863269

Please sign in to comment.