Skip to content

Commit

Permalink
added dao-pre-propose-approval-multiple contract
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 17, 2024
1 parent 45e2ecb commit 3ab425c
Show file tree
Hide file tree
Showing 14 changed files with 6,185 additions and 79 deletions.
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions contracts/pre-propose/dao-pre-propose-approval-multiple/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "dao-pre-propose-approval-multiple"
authors = ["ekez <ekez@withoutdoing.com>", "Jake Hartnell <no-reply@no-reply.com>", "noah <noah@daodao.zone>"]
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 contracts/pre-propose/dao-pre-propose-approval-multiple/README.md
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).
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,
}
}
Loading

0 comments on commit 3ab425c

Please sign in to comment.