Skip to content

Commit

Permalink
started adding pre-propose migration to v2.5.0 (DA0-DA0#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso authored Jul 22, 2024
1 parent 7646730 commit 7e6f5ce
Show file tree
Hide file tree
Showing 24 changed files with 888 additions and 120 deletions.
239 changes: 165 additions & 74 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ prost-types = { version = "0.12.3", default-features = false }
quote = "1.0"
rand = "0.8"
schemars = "0.8"
semver = "1.0.20"
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde-cw-value = "0.7"
serde_json = "1.0"
Expand Down Expand Up @@ -135,3 +136,11 @@ cw20-staked-balance-voting-v1 = { package = "cw20-staked-balance-voting", versio
cw4-voting-v1 = { package = "cw4-voting", version = "0.1.0" }
stake-cw20-v03 = { package = "stake-cw20", version = "0.2.6" }
voting-v1 = { package = "dao-voting", version = "0.1.0" }

# v2.4.1 dependencies. used for state migrations.
cw-denom-v241 = { package = "cw-denom", version = "2.4.1" }
dao-dao-core-v241 = { package = "dao-dao-core", version = "2.4.1" }
dao-pre-propose-base-v241 = { package = "dao-pre-propose-base", version = "2.4.1" }
dao-pre-propose-single-v241 = { package = "dao-pre-propose-single", version = "2.4.1" }
dao-voting-cw4-v241 = { package = "dao-voting-cw4", version = "2.4.1" }
dao-voting-v241 = { package = "dao-voting", version = "2.4.1" }
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use cosmwasm_schema::write_api;
use dao_pre_propose_approval_single::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use dao_pre_propose_approval_single::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
migrate: MigrateMsg,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,139 @@
}
}
},
"migrate": null,
"migrate": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MigrateMsg",
"oneOf": [
{
"type": "object",
"required": [
"from_under_v250"
],
"properties": {
"from_under_v250": {
"type": "object",
"properties": {
"policy": {
"description": "Optionally set a new submission policy with more granular controls. If not set, the current policy will remain.",
"anyOf": [
{
"$ref": "#/definitions/PreProposeSubmissionPolicy"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"extension"
],
"properties": {
"extension": {
"type": "object",
"required": [
"msg"
],
"properties": {
"msg": {
"$ref": "#/definitions/Empty"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
"Empty": {
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
"type": "object"
},
"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": {
"type": "string"
}
}
},
"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": {
"type": "string"
}
},
"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": {
"type": "string"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
}
},
"sudo": null,
"responses": {
"can_propose": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use dao_voting::deposit::DepositRefundPolicy;
use dao_voting::proposal::SingleChoiceProposeMsg as ProposeMsg;

use crate::msg::{
ApproverProposeMessage, ExecuteExt, ExecuteMsg, InstantiateExt, InstantiateMsg, ProposeMessage,
ProposeMessageInternal, QueryExt, QueryMsg,
ApproverProposeMessage, ExecuteExt, ExecuteMsg, InstantiateExt, InstantiateMsg, MigrateMsg,
ProposeMessage, ProposeMessageInternal, QueryExt, QueryMsg,
};
use crate::state::{
advance_approval_id, Proposal, ProposalStatus, APPROVER, COMPLETED_PROPOSALS,
Expand All @@ -24,7 +24,7 @@ use crate::state::{
pub(crate) const CONTRACT_NAME: &str = "crates.io:dao-pre-propose-approval-single";
pub(crate) const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

type PrePropose = PreProposeContract<InstantiateExt, ExecuteExt, QueryExt, ProposeMessage>;
type PrePropose = PreProposeContract<InstantiateExt, ExecuteExt, QueryExt, Empty, ProposeMessage>;

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
Expand Down Expand Up @@ -403,3 +403,8 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
_ => PrePropose::default().query(deps, env, msg),
}
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, PreProposeError> {
PrePropose::default().migrate(deps, msg)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{CosmosMsg, Empty};
use dao_pre_propose_base::msg::{
ExecuteMsg as ExecuteBase, InstantiateMsg as InstantiateBase, QueryMsg as QueryBase,
ExecuteMsg as ExecuteBase, InstantiateMsg as InstantiateBase, MigrateMsg as MigrateBase,
QueryMsg as QueryBase,
};
use dao_voting::{proposal::SingleChoiceProposeMsg as ProposeMsg, voting::SingleChoiceAutoVote};

Expand Down Expand Up @@ -87,6 +88,7 @@ pub enum QueryExt {
pub type InstantiateMsg = InstantiateBase<InstantiateExt>;
pub type ExecuteMsg = ExecuteBase<ProposeMessage, ExecuteExt>;
pub type QueryMsg = QueryBase<QueryExt>;
pub type MigrateMsg = MigrateBase<Empty>;

/// Internal version of the propose message that includes the
/// `proposer` field. The module will fill this in based on the sender
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use cosmwasm_schema::write_api;
use dao_pre_propose_approver::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use dao_pre_propose_approver::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
migrate: MigrateMsg,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,139 @@
}
}
},
"migrate": null,
"migrate": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MigrateMsg",
"oneOf": [
{
"type": "object",
"required": [
"from_under_v250"
],
"properties": {
"from_under_v250": {
"type": "object",
"properties": {
"policy": {
"description": "Optionally set a new submission policy with more granular controls. If not set, the current policy will remain.",
"anyOf": [
{
"$ref": "#/definitions/PreProposeSubmissionPolicy"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"extension"
],
"properties": {
"extension": {
"type": "object",
"required": [
"msg"
],
"properties": {
"msg": {
"$ref": "#/definitions/Empty"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
"Empty": {
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
"type": "object"
},
"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": {
"type": "string"
}
}
},
"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": {
"type": "string"
}
},
"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": {
"type": "string"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
}
},
"sudo": null,
"responses": {
"can_propose": {
Expand Down
Loading

0 comments on commit 7e6f5ce

Please sign in to comment.