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

Improve pre-propose proposal creation permission granularity (and bump versions to v2.5.0) #843

Merged
merged 12 commits into from
Jul 7, 2024
7 changes: 6 additions & 1 deletion ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cosm_orc::{config::cfg::Config, orchestrator::cosm_orc::CosmOrc};
use cosmwasm_std::{to_json_binary, Decimal, Empty, Uint128};
use cw20::Cw20Coin;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_voting::pre_propose::PreProposeSubmissionPolicy;
use dao_voting::{
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo, VotingModuleTokenType},
pre_propose::PreProposeInfo,
Expand Down Expand Up @@ -99,7 +100,11 @@ fn main() -> Result<()> {
amount: Uint128::new(1000000000),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
open_proposal_submission: false,
submission_policy: PreProposeSubmissionPolicy::Specific {
dao_members: true,
allowlist: None,
denylist: None,
},
extension: Empty::default(),
})
.unwrap(),
Expand Down
8 changes: 6 additions & 2 deletions ci/integration-tests/src/helpers/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use dao_interface::query::DumpStateResponse;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_voting::{
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo, VotingModuleTokenType},
pre_propose::{PreProposeInfo, ProposalCreationPolicy},
pre_propose::{PreProposeInfo, PreProposeSubmissionPolicy, ProposalCreationPolicy},
threshold::PercentageThreshold,
threshold::Threshold,
voting::Vote,
Expand Down Expand Up @@ -84,7 +84,11 @@ pub fn create_dao(
amount: DEPOSIT_AMOUNT,
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
open_proposal_submission: false,
submission_policy: PreProposeSubmissionPolicy::Specific {
dao_members: true,
allowlist: None,
denylist: None,
},
extension: Empty::default(),
})
.unwrap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "object",
"required": [
"extension",
"open_proposal_submission"
"submission_policy"
],
"properties": {
"deposit_info": {
Expand All @@ -30,13 +30,21 @@
}
]
},
"open_proposal_submission": {
"description": "If false, only members (addresses with voting power) may create proposals in the DAO. Otherwise, any address may create a proposal so long as they pay the deposit.",
"type": "boolean"
"submission_policy": {
"description": "The policy dictating who is allowed to submit proposals.",
"allOf": [
{
"$ref": "#/definitions/PreProposeSubmissionPolicy"
}
]
}
},
"additionalProperties": false,
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"DepositRefundPolicy": {
"oneOf": [
{
Expand Down Expand Up @@ -123,6 +131,80 @@
},
"additionalProperties": false
},
"PreProposeSubmissionPolicy": {
"description": "The policy configured in a pre-propose module that determines who can submit proposals. This is the preferred way to restrict proposal creation (as opposed to the ProposalCreationPolicy above) since pre-propose modules support other features, such as proposal deposits.",
"oneOf": [
{
"description": "Anyone may create proposals, except for those in the denylist.",
"type": "object",
"required": [
"anyone"
],
"properties": {
"anyone": {
"type": "object",
"properties": {
"denylist": {
"description": "Addresses that may not create proposals.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Specific people may create proposals.",
"type": "object",
"required": [
"specific"
],
"properties": {
"specific": {
"type": "object",
"required": [
"dao_members"
],
"properties": {
"allowlist": {
"description": "Addresses that may create proposals.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
},
"dao_members": {
"description": "Whether or not DAO members may create proposals.",
"type": "boolean"
},
"denylist": {
"description": "Addresses that may not create proposals, overriding other settings.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
Expand Down Expand Up @@ -239,7 +321,7 @@
"update_config": {
"type": "object",
"required": [
"open_proposal_submission"
"submission_policy"
],
"properties": {
"deposit_info": {
Expand All @@ -252,8 +334,8 @@
}
]
},
"open_proposal_submission": {
"type": "boolean"
"submission_policy": {
"$ref": "#/definitions/PreProposeSubmissionPolicy"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -384,6 +466,10 @@
}
],
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"oneOf": [
Expand Down Expand Up @@ -1011,6 +1097,80 @@
}
}
},
"PreProposeSubmissionPolicy": {
"description": "The policy configured in a pre-propose module that determines who can submit proposals. This is the preferred way to restrict proposal creation (as opposed to the ProposalCreationPolicy above) since pre-propose modules support other features, such as proposal deposits.",
"oneOf": [
{
"description": "Anyone may create proposals, except for those in the denylist.",
"type": "object",
"required": [
"anyone"
],
"properties": {
"anyone": {
"type": "object",
"properties": {
"denylist": {
"description": "Addresses that may not create proposals.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Specific people may create proposals.",
"type": "object",
"required": [
"specific"
],
"properties": {
"specific": {
"type": "object",
"required": [
"dao_members"
],
"properties": {
"allowlist": {
"description": "Addresses that may create proposals.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
},
"dao_members": {
"description": "Whether or not DAO members may create proposals.",
"type": "boolean"
},
"denylist": {
"description": "Addresses that may not create proposals, overriding other settings.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"ProposeMessage": {
"oneOf": [
{
Expand Down Expand Up @@ -1923,7 +2083,7 @@
"title": "Config",
"type": "object",
"required": [
"open_proposal_submission"
"submission_policy"
],
"properties": {
"deposit_info": {
Expand All @@ -1937,9 +2097,13 @@
}
]
},
"open_proposal_submission": {
"description": "If false, only members (addresses with voting power) may create proposals in the DAO. Otherwise, any address may create a proposal so long as they pay the deposit.",
"type": "boolean"
"submission_policy": {
"description": "The policy dictating who is allowed to submit proposals.",
"allOf": [
{
"$ref": "#/definitions/PreProposeSubmissionPolicy"
}
]
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -2040,6 +2204,80 @@
}
]
},
"PreProposeSubmissionPolicy": {
"description": "The policy configured in a pre-propose module that determines who can submit proposals. This is the preferred way to restrict proposal creation (as opposed to the ProposalCreationPolicy above) since pre-propose modules support other features, such as proposal deposits.",
"oneOf": [
{
"description": "Anyone may create proposals, except for those in the denylist.",
"type": "object",
"required": [
"anyone"
],
"properties": {
"anyone": {
"type": "object",
"properties": {
"denylist": {
"description": "Addresses that may not create proposals.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Specific people may create proposals.",
"type": "object",
"required": [
"specific"
],
"properties": {
"specific": {
"type": "object",
"required": [
"dao_members"
],
"properties": {
"allowlist": {
"description": "Addresses that may create proposals.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
},
"dao_members": {
"description": "Whether or not DAO members may create proposals.",
"type": "boolean"
},
"denylist": {
"description": "Addresses that may not create proposals, overriding other settings.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Addr"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
Expand Down
Loading
Loading