Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Governance #126

Merged
merged 142 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
5efdd0c
Add governance structure
Jul 31, 2023
b4cdd41
Add utils
Jul 31, 2023
4855bd1
Add governor traits
Jul 31, 2023
c3176ff
Add governor struct
Jul 31, 2023
9c396c4
Add traits for extansions
prxgr4mm3r Jul 31, 2023
2acf292
Merge remote-tracking branch 'origin/feature/governance' into feature…
prxgr4mm3r Jul 31, 2023
3812d2f
fix some bugs
Jul 31, 2023
a4cb223
Fix errors and warnings
prxgr4mm3r Jul 31, 2023
75341bb
Change inheritance
prxgr4mm3r Jul 31, 2023
ab34931
add checkpoint logic
Jul 31, 2023
f1969a7
Merge remote-tracking branch 'origin/feature/governance' into feature…
Jul 31, 2023
b6d97ac
fix bug with states
Jul 31, 2023
aec766e
Add impls for extensions
prxgr4mm3r Aug 1, 2023
4880951
add governor impl
varex83 Aug 1, 2023
2754492
add governor internal impl
varex83 Aug 1, 2023
77d0d61
Add internal for extensions
prxgr4mm3r Aug 1, 2023
8b89466
move timelock controller
varex83 Aug 1, 2023
db5191a
update features
varex83 Aug 1, 2023
f5673ee
fix features
varex83 Aug 1, 2023
accf4df
remove todo
varex83 Aug 1, 2023
01f2730
remove todo
varex83 Aug 1, 2023
e366693
update path
varex83 Aug 1, 2023
e93a160
my_governance contract
varex83 Aug 1, 2023
5f2352e
fix bugs wit imports
varex83 Aug 2, 2023
876b48b
update interfaces
varex83 Aug 2, 2023
0b39f3a
update interfaces
varex83 Aug 2, 2023
8fbbc34
add tests boilerplate
varex83 Aug 2, 2023
4d2964d
Add governance_settings
prxgr4mm3r Aug 2, 2023
edcda59
Add governance_votes_quorum_fraction
prxgr4mm3r Aug 2, 2023
4900f08
Revert "Add governance_votes_quorum_fraction"
varex83 Aug 2, 2023
7be42ad
Revert "Add governance_settings"
varex83 Aug 2, 2023
80782cc
add PSP22Votes extension
Artemka374 Aug 2, 2023
87fe97c
Merge remote-tracking branch 'origin/feature/governance' into feature…
Artemka374 Aug 2, 2023
5ab1a27
add governor quorum fraction impl
varex83 Aug 2, 2023
1b45483
move & rename GovernorVotes -> Votes, add VotesRef, implement Governo…
varex83 Aug 2, 2023
3a248e9
add quorum implementation
varex83 Aug 2, 2023
8da3a44
add governance settings
varex83 Aug 2, 2023
6c0230d
add logics, fix conflicts
Artemka374 Aug 3, 2023
d5b091e
fix bugs, wrap everything up
varex83 Aug 3, 2023
f96e48a
Merge remote-tracking branch 'origin/feature/governance' into feature…
varex83 Aug 3, 2023
aeea7e4
add only_governance modifier, relay method in governor
Artemka374 Aug 3, 2023
aa4e9bb
fix compilation
Artemka374 Aug 3, 2023
5964c08
use map_err instead of unwrap
Artemka374 Aug 3, 2023
564cce6
Add nonces e2e tests
prxgr4mm3r Aug 3, 2023
01a5078
Fix nonces e2e tests
prxgr4mm3r Aug 4, 2023
02e299c
improve test structure a little bit
varex83 Aug 4, 2023
1e19af7
add quorum tests
varex83 Aug 4, 2023
a21e204
add psp22 votes contract, fix governor example contract
varex83 Aug 4, 2023
8bfe2dc
fix _is_valid_description_for_proposer
Artemka374 Aug 10, 2023
58db008
fix _is_valid_description_for_proposer
Artemka374 Aug 10, 2023
74990fb
Add tests for governor
prxgr4mm3r Aug 10, 2023
76cee30
Add tests for governor
prxgr4mm3r Aug 10, 2023
49acd2a
create mock timestamp provider
Artemka374 Aug 11, 2023
7ab1e26
add only_governance to set_proposal_threshold
Artemka374 Aug 11, 2023
d3ab126
add GovernorHelper class
Artemka374 Aug 14, 2023
50ad406
add execute method
Artemka374 Aug 14, 2023
90680d9
add cancel method
Artemka374 Aug 14, 2023
521818e
Add tests for governor
prxgr4mm3r Aug 14, 2023
a8f40cf
add offset to wait methods
Artemka374 Aug 14, 2023
176af91
Merge remote-tracking branch 'origin/feature/governance' into feature…
Artemka374 Aug 14, 2023
4e24594
add tests
Artemka374 Aug 14, 2023
318fe09
Merge branch 'main' into feature/governance
Artemka374 Aug 14, 2023
88091f7
fix findSelectorByName
Artemka374 Aug 14, 2023
d4d46c7
Merge remote-tracking branch 'origin/feature/governance' into feature…
Artemka374 Aug 14, 2023
897d1f1
Rework tests with helper
prxgr4mm3r Aug 14, 2023
8a721a6
Change Canselled -> Canceled
prxgr4mm3r Aug 14, 2023
7cef6d7
Add tests for state
prxgr4mm3r Aug 14, 2023
6011d1e
add mock_receiver contract
Artemka374 Aug 14, 2023
fc65b02
fix encoding in description
Artemka374 Aug 14, 2023
9e895d4
Fixed Votes contract
prxgr4mm3r Aug 14, 2023
d0837d1
Fix Votes contract and tests
prxgr4mm3r Aug 15, 2023
8b92fad
small test fix
prxgr4mm3r Aug 15, 2023
a06db05
fix checkpoints, add check for hex in _is_valid_description
Artemka374 Aug 15, 2023
aaa0903
fix is_valid_description
Artemka374 Aug 15, 2023
85e52e9
save this.proposalId
Artemka374 Aug 15, 2023
019f7f3
fix proposal length test
Artemka374 Aug 15, 2023
a173716
fix snapshot and deadline getter
Artemka374 Aug 15, 2023
a9349ce
use unwrap_or_default in places where it is needed
Artemka374 Aug 15, 2023
f6effee
add some tests
prxgr4mm3r Aug 15, 2023
dfc4154
fix state method
Artemka374 Aug 15, 2023
6cbff64
Merge remote-tracking branch 'origin/feature/governance' into feature…
Artemka374 Aug 15, 2023
2eb294b
fix state
prxgr4mm3r Aug 15, 2023
5fc7b6c
fix cancel
prxgr4mm3r Aug 15, 2023
99a532d
fix some cancel tests
prxgr4mm3r Aug 15, 2023
078e378
set default voting delay
prxgr4mm3r Aug 15, 2023
247fd5c
use Option instead of zero address, fix some bugs
Artemka374 Aug 15, 2023
89fc6a5
add tests for PSP22Votes
prxgr4mm3r Aug 15, 2023
c1b06e8
add tests for Counting
prxgr4mm3r Aug 15, 2023
1035a1c
add get_votes and count_votes in contract
prxgr4mm3r Aug 16, 2023
a34a8bf
use Option in more places, use TimestampProvider in PSP22Votes
Artemka374 Aug 16, 2023
5541265
add check for votes in deployment check
Artemka374 Aug 16, 2023
7863269
fix bug with timestamp in checkpoints
Artemka374 Aug 16, 2023
1036b4b
make counting tests working
prxgr4mm3r Aug 16, 2023
087fe10
add licences
prxgr4mm3r Aug 16, 2023
2411de9
add inline docs to traits
prxgr4mm3r Aug 16, 2023
18754e1
fix execute call input
Artemka374 Aug 16, 2023
26f1092
Merge remote-tracking branch 'origin/feature/governance' into feature…
Artemka374 Aug 16, 2023
cc7d93d
add inline docs to governance contracts and utils
prxgr4mm3r Aug 16, 2023
e477d01
fix bugs
Artemka374 Aug 16, 2023
67836a4
use correct selector and data values
Artemka374 Aug 16, 2023
828e837
delete useless storage fields from example governance contract, chang…
prxgr4mm3r Aug 16, 2023
e0e80e9
add restriction for voting period, clean up tests
Artemka374 Aug 16, 2023
ac3b345
Merge remote-tracking branch 'origin/feature/governance' into feature…
Artemka374 Aug 16, 2023
51027f6
fix inline docs
prxgr4mm3r Aug 17, 2023
03c5f42
apply suggestions
Artemka374 Aug 17, 2023
01d4b97
Merge remote-tracking branch 'origin/feature/governance' into feature…
Artemka374 Aug 17, 2023
7b62bf2
fix conflicts
Artemka374 Aug 17, 2023
916116c
apply fmt
Artemka374 Aug 17, 2023
42ce434
add implementation macro to Governance
prxgr4mm3r Aug 17, 2023
6e647d9
Merge remote-tracking branch 'origin/feature/governance' into feature…
prxgr4mm3r Aug 17, 2023
c115a76
make governor contract compilable
prxgr4mm3r Aug 17, 2023
0db7102
split macro and do beautiful imports
prxgr4mm3r Aug 17, 2023
1cebeb5
add Nonces macro
prxgr4mm3r Aug 17, 2023
67ca713
add Nonces macro
prxgr4mm3r Aug 17, 2023
6e58872
fix governance and votes import system and add PSP22Votes macro
prxgr4mm3r Aug 18, 2023
33ce3e9
add feature flags on utils
Artemka374 Aug 18, 2023
ce3c950
fix config
Artemka374 Aug 21, 2023
be4cdd7
fix compilation, apply fmt
Artemka374 Aug 21, 2023
2d0cc46
delete strange folder
Artemka374 Aug 21, 2023
d4cc861
fix builds
Artemka374 Aug 22, 2023
0bfefc8
fix wrong symbol
Artemka374 Aug 22, 2023
be6a46b
fix build
Artemka374 Aug 22, 2023
6f4dd24
fix governance feature in psp22_votes
Artemka374 Aug 22, 2023
e9a7f3d
apply suggestions
Artemka374 Aug 25, 2023
76fba6b
fix build
Artemka374 Aug 26, 2023
dd84db2
fix unit tests
Artemka374 Aug 26, 2023
b42fdd9
remove unnecessary examples, update dockerfile
Artemka374 Aug 26, 2023
19833a3
update versions in ci
Artemka374 Aug 26, 2023
8da323e
add version in compile
Artemka374 Aug 26, 2023
7644e49
add version in compile
Artemka374 Aug 26, 2023
a415530
update package.json
Artemka374 Aug 26, 2023
af5e0fb
fix some tests
Artemka374 Aug 28, 2023
d85efd3
update typechain-compiler-config.json
Artemka374 Aug 28, 2023
16a0841
update wrapper test
Artemka374 Aug 28, 2023
01bacfa
add mock to compiler
Artemka374 Aug 28, 2023
fd776fc
apply eslint, delete counting mode
Artemka374 Aug 28, 2023
dafd2f8
fix some tests
Artemka374 Aug 28, 2023
8491a06
update quorum tests
Artemka374 Aug 28, 2023
5c158aa
Merge remote-tracking branch 'origin/develop' into feature/governance
Artemka374 Aug 28, 2023
de87bbc
fix some errors after merge
Artemka374 Aug 28, 2023
fd34f92
fix compilation in reentrancy_guard
Artemka374 Aug 28, 2023
30e560c
fix some warnings
Artemka374 Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
exclude = [
"examples",
"example_project_structure",
"mocks"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a contract just for receiving?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mock contract to test executing transactions in other contracts through governance

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be any contract though

]

[package]
Expand Down Expand Up @@ -67,6 +68,8 @@ timelock_controller = ["openbrush_contracts/timelock_controller"]
proxy = ["openbrush_contracts/proxy"]
diamond = ["openbrush_contracts/diamond"]
upgradeable = ["openbrush_contracts/upgradeable"]
governance = ["openbrush_contracts/governance"]
utils = ["openbrush_contracts/utils"]

test-all = [
"psp22",
Expand All @@ -81,14 +84,15 @@ test-all = [
"timelock_controller",
"proxy",
"diamond",
"governance",
"utils",
]

[profile.release]
panic = "abort"
lto = false

[profile.dev]

panic = "abort"
lto = false
overflow-checks = false
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ RUN npm install -g n && \
npm install -g yarn && \
n stable

RUN curl -sSf https://sh.rustup.rs/ | sh
RUN curl -sSf https://sh.rustup.rs/ -y | sh

RUN rustup component add rust-src
RUN rustup target add wasm32-unknown-unknown

RUN cargo install cargo-dylint dylint-link

RUN cargo install cargo-contract --version 3.2.0 --force && \
RUN cargo install cargo-contract --version 4.0.0-alpha --force && \
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force --locked
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (c) 2023 Brushfam
coreggon11 marked this conversation as resolved.
Show resolved Hide resolved
// Copyright (c) 2012-2022 Supercolony
//
// Permission is hereby granted, free of charge, to any person obtaining
Expand Down
8 changes: 8 additions & 0 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
ink = { version = "4.3.0", default-features = false}
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }

openbrush = { version = "~4.0.0-beta.1", package = "openbrush_lang", path = "../lang", default-features = false }

Expand Down Expand Up @@ -57,6 +58,11 @@ proxy = [
diamond = [
"ownable",
]
governance = [
"timelock_controller",
"utils"
]
utils = []
upgradeable = ["ownable"]
test-all = [
"psp22",
Expand All @@ -69,5 +75,7 @@ test-all = [
"pausable",
"timelock_controller",
"proxy",
"utils",
"diamond",
"governance",
]
41 changes: 41 additions & 0 deletions contracts/src/governance/extensions/governor_counting/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2023 Brushfam
// Copyright (c) 2012-2022 Supercolony
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the"Software"),
// to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pub use crate::traits::governance::{
ProposalId,
ProposalVote,
};
pub use openbrush::{
storage::Mapping,
traits::AccountId,
};

#[derive(Default, Debug)]
#[openbrush::storage_item]
pub struct Data {
/// Stores the ammounts of the votes of the proposals
/// The key is the proposal id and the value is the vote, which contains the ammount of votes
pub proposal_votes: Mapping<ProposalId, ProposalVote>,

/// Stores if the account has voted for the proposal
pub has_votes: Mapping<(ProposalId, AccountId), ()>,
}
49 changes: 49 additions & 0 deletions contracts/src/governance/extensions/governor_counting/impls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2023 Brushfam
// Copyright (c) 2012-2022 Supercolony
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the"Software"),
// to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

use crate::governance::extensions::governor_counting::{
CountingInternal,
Data,
};
pub use crate::{
governance::extensions::governor_counting,
traits::governance::extensions::governor_counting::*,
};
use openbrush::traits::{
AccountId,
Storage,
};

/// Extension of `Governor` for simple, 3 options, vote counting.
pub trait GovernorCountingImpl: Storage<Data> + CountingInternal {
/// Returns `true` if the account has voted for the proposal, `false` otherwise
fn has_voted(&self, proposal_id: ProposalId, account: AccountId) -> bool {
self.data::<Data>().has_votes.get(&(proposal_id, account)).is_some()
}
/// Returns the tuple (for, against, abstain) votes for a proposal, where `for` is the total
/// number of votes for the proposal, `against` is the total number of votes against the
/// proposal, and `abstain` is the total number of abstained votes.
fn proposal_votes(&self, proposal_id: ProposalId) -> Result<ProposalVote, GovernanceError> {
let proposal_vote = self.data::<Data>().proposal_votes.get(&proposal_id).unwrap_or_default();
Ok(ProposalVote { ..proposal_vote })
}
}
108 changes: 108 additions & 0 deletions contracts/src/governance/extensions/governor_counting/internal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright (c) 2023 Brushfam
// Copyright (c) 2012-2022 Supercolony
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the"Software"),
// to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

use crate::{
governance::{
extensions::{
governor_counting::Data,
governor_quorum::QuorumImpl,
},
governor::GovernorStorageGetters,
},
traits::{
errors::GovernanceError,
governance::{
ProposalId,
VoteType,
},
},
};
use openbrush::traits::{
AccountId,
Balance,
Storage,
};

pub trait CountingInternal: Storage<Data> + QuorumImpl + GovernorStorageGetters {
/// Returns true if the quorum is reached for the given proposal, false otherwise
fn _quorum_reached(&self, proposal_id: ProposalId) -> Result<bool, GovernanceError> {
let proposal_vote = self.data::<Data>().proposal_votes.get(&proposal_id).unwrap_or_default();
let num_votes = proposal_vote
.for_votes
.checked_add(proposal_vote.abstain_votes)
.ok_or(GovernanceError::Overflow)?;

Ok(self.quorum(self._proposal_snapshot(proposal_id)?)? <= num_votes)
}

/// Returns true if the proposal has succeeded, false otherwise
fn _vote_succeeded(&self, proposal_id: ProposalId) -> bool {
self.data::<Data>()
.proposal_votes
.get(&proposal_id)
.map(|proposal_vote| proposal_vote.for_votes > proposal_vote.against_votes)
.unwrap_or_default()
}

/// Adds a `account`'s vote to `proposal_id` with `weight` votes, to the `support` side.
fn _count_vote(
&mut self,
proposal_id: ProposalId,
account: AccountId,
support: VoteType,
weight: Balance,
// params: Vec<u8>,
) -> Result<(), GovernanceError> {
let mut proposal_vote = self.data::<Data>().proposal_votes.get(&proposal_id).unwrap_or_default();

if self.data::<Data>().has_votes.get(&(proposal_id, account)).is_some() {
return Err(GovernanceError::AlreadyCastVote(account))?
}

self.data::<Data>().has_votes.insert(&(proposal_id, account), &());

match support {
VoteType::Against => {
proposal_vote.against_votes = proposal_vote
.against_votes
.checked_add(weight)
.ok_or(GovernanceError::Overflow)?;
}
VoteType::For => {
proposal_vote.for_votes = proposal_vote
.for_votes
.checked_add(weight)
.ok_or(GovernanceError::Overflow)?;
}
VoteType::Abstain => {
proposal_vote.abstain_votes = proposal_vote
.abstain_votes
.checked_add(weight)
.ok_or(GovernanceError::Overflow)?;
}
}

self.data::<Data>().proposal_votes.insert(&proposal_id, &proposal_vote);

Ok(())
}
}
29 changes: 29 additions & 0 deletions contracts/src/governance/extensions/governor_counting/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2023 Brushfam
// Copyright (c) 2012-2022 Supercolony
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the"Software"),
// to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mod data;
mod impls;
mod internal;

pub use data::*;
pub use impls::*;
pub use internal::*;
31 changes: 31 additions & 0 deletions contracts/src/governance/extensions/governor_quorum/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2023 Brushfam
// Copyright (c) 2012-2022 Supercolony
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the"Software"),
// to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pub use crate::utils::checkpoint::Checkpoints;

#[derive(Debug, Default)]
#[openbrush::storage_item]
pub struct Data {
/// Stores the quorum numerator history of the governor
#[lazy]
pub quorum_numerator_history: Checkpoints,
}
29 changes: 29 additions & 0 deletions contracts/src/governance/extensions/governor_quorum/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2023 Brushfam
// Copyright (c) 2012-2022 Supercolony
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the"Software"),
// to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pub trait QuorumEvents {
/// Emitted when the quorum denominator is updated
fn emit_quorum_numerator_updated(&self, _old_quorum_numerator: u128, _new_quorum_numerator: u128) {}

/// Emitted when the governor quorum is invalid
fn emit_governor_invalid_quorum_fraction(&self, _quorum_numerator: u128, _quorum_denominator: u128) {}
}
Loading
Loading