-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-propose-approval support for multiple choice proposals, and f…
…reeze approver (#883) * moved common pre-propose-approval types to dao-voting package * added dao-pre-propose-approval-multiple contract * added multiple choice approver tests * lock approver in pending proposal on propose instead of using most recent approver * updated schema
- Loading branch information
Showing
27 changed files
with
8,643 additions
and
180 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
contracts/pre-propose/dao-pre-propose-approval-multiple/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[package] | ||
name = "dao-pre-propose-approval-multiple" | ||
authors = ["ekez <[email protected]>", "Jake Hartnell <[email protected]>", "noah <[email protected]>"] | ||
description = "A DAO DAO pre-propose module handling a proposal approval flow for for dao-proposal-multiple." | ||
edition = { workspace = true } | ||
license = { workspace = true } | ||
repository = { workspace = true } | ||
version = { workspace = true } | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
# for more explicit tests, cargo test --features=backtraces | ||
backtraces = ["cosmwasm-std/backtraces"] | ||
# use library feature to disable all instantiate/execute/query exports | ||
library = [] | ||
|
||
[dependencies] | ||
cosmwasm-std = { workspace = true } | ||
cosmwasm-schema = { workspace = true } | ||
cw-storage-plus = { workspace = true } | ||
cw2 = { workspace = true } | ||
cw-paginate-storage = { workspace = true } | ||
dao-pre-propose-base = { workspace = true } | ||
dao-voting = { workspace = true } | ||
thiserror = { workspace = true } | ||
dao-interface = { workspace = true } | ||
|
||
[dev-dependencies] | ||
cw-denom = { workspace = true } | ||
cw-multi-test = { workspace = true } | ||
cw-utils = { workspace = true } | ||
cw4 = { workspace = true } | ||
cw4-group = { workspace = true } | ||
cw20 = { workspace = true } | ||
cw20-base = { workspace = true } | ||
dao-dao-core = { workspace = true } | ||
dao-hooks = { workspace = true } | ||
dao-testing = { workspace = true } | ||
dao-voting = { workspace = true } | ||
dao-voting-cw4 = { workspace = true } | ||
dao-voting-cw20-staked = { workspace = true } | ||
dao-proposal-multiple = { workspace = true } |
78 changes: 78 additions & 0 deletions
78
contracts/pre-propose/dao-pre-propose-approval-multiple/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Multi choice proposal approval contract | ||
|
||
[![dao-pre-propose-approval-multiple on crates.io](https://img.shields.io/crates/v/dao-pre-propose-approval-multiple.svg?logo=rust)](https://crates.io/crates/dao-pre-propose-approval-multiple) | ||
[![docs.rs](https://img.shields.io/docsrs/dao-pre-propose-approval-multiple?logo=docsdotrs)](https://docs.rs/dao-pre-propose-approval-multiple/latest/dao_pre_propose_approval_multiple/) | ||
|
||
This contract implements an approval flow for proposals, it also handles deposit logic. It works with the `dao-proposal-multiple` proposal module. | ||
|
||
## Approval Logic | ||
|
||
This contract is instantatied with an `approver` address. This address is | ||
allowed to approve or reject the proposal. An approved proposal opens for voting | ||
immediately, whereas a rejected proposal is simply discarded. | ||
|
||
```text | ||
┌──────────┐ | ||
│ │ | ||
│ Account │ | ||
│ │ | ||
└─────┬────┘ | ||
│ | ||
│ Makes prop | ||
▼ | ||
┌────────────────────────┐ ┌────────────────────────┐ | ||
│ │ │ │ | ||
│ Pre-propose Approval │ ◄─────────────┤ Approver Address │ | ||
│ │ Approves │ │ | ||
└───────────┬────────────┘ or rejects └────────────────────────┘ | ||
│ | ||
│ Creates prop | ||
│ on approval | ||
▼ | ||
┌──────────────────────────┐ | ||
│ │ | ||
│ Proposal Multiple │ | ||
│ │ | ||
└───────────┬──────────────┘ | ||
│ | ||
│ Normal voting | ||
│ | ||
▼ | ||
┌────────────────────────┐ | ||
│ │ | ||
│ Main DAO │ | ||
│ │ | ||
└────────────────────────┘ | ||
``` | ||
|
||
The `approver` may also register a `ProposalSubmitHook`, which fires every time a proposal is submitted to the `dao-pre-propose-approval-multiple` contract. | ||
|
||
## Deposit Logic | ||
|
||
It may accept either native ([bank | ||
module](https://docs.cosmos.network/main/modules/bank/)), | ||
[cw20](https://github.com/CosmWasm/cw-plus/tree/bc339368b1ee33c97c55a19d4cff983c7708ce36/packages/cw20) | ||
tokens, or no tokens as a deposit. If a proposal deposit is enabled | ||
the following refund strategies are avaliable: | ||
|
||
1. Never refund deposits. All deposits are sent to the DAO on proposal | ||
completion. | ||
2. Always refund deposits. Deposits are returned to the proposer on | ||
proposal completion and even rejection by the `approver`. | ||
3. Only refund passed proposals. Deposits are only returned to the | ||
proposer if the proposal is approved and passes. Otherwise, they | ||
are sent to the DAO. | ||
|
||
This module may also be configured to only accept proposals from | ||
members (addresses with voting power) of the DAO. | ||
|
||
Here is a flowchart showing the proposal creation process using this | ||
module: | ||
|
||
![](https://bafkreig42cxswefi2ks7vhrwyvkcnumbnwdk7ov643yaafm7loi6vh2gja.ipfs.nftstorage.link) | ||
|
||
### Resources | ||
|
||
More about the [pre-propose design](https://github.com/DA0-DA0/dao-contracts/wiki/Pre-propose-module-design). | ||
|
||
More about [pre-propose modules](https://github.com/DA0-DA0/dao-contracts/wiki/DAO-DAO-Contracts-Design#pre-propose-modules). |
11 changes: 11 additions & 0 deletions
11
contracts/pre-propose/dao-pre-propose-approval-multiple/examples/schema.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use cosmwasm_schema::write_api; | ||
use dao_pre_propose_approval_multiple::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; | ||
|
||
fn main() { | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
query: QueryMsg, | ||
execute: ExecuteMsg, | ||
migrate: MigrateMsg, | ||
} | ||
} |
Oops, something went wrong.