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

Fix voting module native token proposal deposit on instantiate #786

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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: 4 additions & 2 deletions ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cosmwasm_std::{to_json_binary, Decimal, Empty, Uint128};
use cw20::Cw20Coin;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_voting::{
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo},
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo, VotingModuleTokenType},
pre_propose::PreProposeInfo,
threshold::PercentageThreshold,
threshold::Threshold,
Expand Down Expand Up @@ -93,7 +93,9 @@ fn main() -> Result<()> {
code_id: orc.contract_map.code_id("dao_pre_propose_single")?,
msg: to_json_binary(&dao_pre_propose_single::InstantiateMsg {
deposit_info: Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1000000000),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down
6 changes: 4 additions & 2 deletions ci/integration-tests/src/helpers/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cw_utils::Duration;
use dao_interface::query::DumpStateResponse;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_voting::{
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo},
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo, VotingModuleTokenType},
pre_propose::{PreProposeInfo, ProposalCreationPolicy},
threshold::PercentageThreshold,
threshold::Threshold,
Expand Down Expand Up @@ -78,7 +78,9 @@ pub fn create_dao(
code_id: chain.orc.contract_map.code_id("dao_pre_propose_single")?,
msg: to_json_binary(&dao_pre_propose_single::InstantiateMsg {
deposit_info: Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: DEPOSIT_AMOUNT,
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,22 @@
"additionalProperties": false
},
{
"description": "Use the token address of the associated DAO's voting module. NOTE: in order to use the token address of the voting module the voting module must (1) use a cw20 token and (2) implement the `TokenContract {}` query type defined by `dao_dao_macros::token_query`. Failing to implement that and using this option will cause instantiation to fail.",
"description": "Use the token native denom or cw20 contract address of the associated DAO's voting module. NOTE: in order to retrieve the token automatically via this variant, the voting module must either (1) use a native token and implement the `Denom {}` query type defined by `dao_dao_macros::native_token_query` OR (2) use a cw20 token and implement the `TokenContract {}` query type defined by `dao_dao_macros::cw20_token_query`. Failing to implement correctly will cause this option to fail to instantiate.",
"type": "object",
"required": [
"voting_module_token"
],
"properties": {
"voting_module_token": {
"type": "object",
"required": [
"token_type"
],
"properties": {
"token_type": {
"$ref": "#/definitions/VotingModuleTokenType"
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -185,6 +193,13 @@
}
},
"additionalProperties": false
},
"VotingModuleTokenType": {
"type": "string",
"enum": [
"native",
"cw20"
]
}
}
},
Expand Down Expand Up @@ -609,14 +624,22 @@
"additionalProperties": false
},
{
"description": "Use the token address of the associated DAO's voting module. NOTE: in order to use the token address of the voting module the voting module must (1) use a cw20 token and (2) implement the `TokenContract {}` query type defined by `dao_dao_macros::token_query`. Failing to implement that and using this option will cause instantiation to fail.",
"description": "Use the token native denom or cw20 contract address of the associated DAO's voting module. NOTE: in order to retrieve the token automatically via this variant, the voting module must either (1) use a native token and implement the `Denom {}` query type defined by `dao_dao_macros::native_token_query` OR (2) use a cw20 token and implement the `TokenContract {}` query type defined by `dao_dao_macros::cw20_token_query`. Failing to implement correctly will cause this option to fail to instantiate.",
"type": "object",
"required": [
"voting_module_token"
],
"properties": {
"voting_module_token": {
"type": "object",
"required": [
"token_type"
],
"properties": {
"token_type": {
"$ref": "#/definitions/VotingModuleTokenType"
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -1275,6 +1298,13 @@
"no_with_veto"
]
},
"VotingModuleTokenType": {
"type": "string",
"enum": [
"native",
"cw20"
]
},
"WasmMsg": {
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
"oneOf": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,22 @@
"additionalProperties": false
},
{
"description": "Use the token address of the associated DAO's voting module. NOTE: in order to use the token address of the voting module the voting module must (1) use a cw20 token and (2) implement the `TokenContract {}` query type defined by `dao_dao_macros::token_query`. Failing to implement that and using this option will cause instantiation to fail.",
"description": "Use the token native denom or cw20 contract address of the associated DAO's voting module. NOTE: in order to retrieve the token automatically via this variant, the voting module must either (1) use a native token and implement the `Denom {}` query type defined by `dao_dao_macros::native_token_query` OR (2) use a cw20 token and implement the `TokenContract {}` query type defined by `dao_dao_macros::cw20_token_query`. Failing to implement correctly will cause this option to fail to instantiate.",
"type": "object",
"required": [
"voting_module_token"
],
"properties": {
"voting_module_token": {
"type": "object",
"required": [
"token_type"
],
"properties": {
"token_type": {
"$ref": "#/definitions/VotingModuleTokenType"
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -519,6 +527,13 @@
}
},
"additionalProperties": false
},
"VotingModuleTokenType": {
"type": "string",
"enum": [
"native",
"cw20"
]
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,22 @@
"additionalProperties": false
},
{
"description": "Use the token address of the associated DAO's voting module. NOTE: in order to use the token address of the voting module the voting module must (1) use a cw20 token and (2) implement the `TokenContract {}` query type defined by `dao_dao_macros::token_query`. Failing to implement that and using this option will cause instantiation to fail.",
"description": "Use the token native denom or cw20 contract address of the associated DAO's voting module. NOTE: in order to retrieve the token automatically via this variant, the voting module must either (1) use a native token and implement the `Denom {}` query type defined by `dao_dao_macros::native_token_query` OR (2) use a cw20 token and implement the `TokenContract {}` query type defined by `dao_dao_macros::cw20_token_query`. Failing to implement correctly will cause this option to fail to instantiate.",
"type": "object",
"required": [
"voting_module_token"
],
"properties": {
"voting_module_token": {
"type": "object",
"required": [
"token_type"
],
"properties": {
"token_type": {
"$ref": "#/definitions/VotingModuleTokenType"
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -177,6 +185,13 @@
}
},
"additionalProperties": false
},
"VotingModuleTokenType": {
"type": "string",
"enum": [
"native",
"cw20"
]
}
}
},
Expand Down Expand Up @@ -601,14 +616,22 @@
"additionalProperties": false
},
{
"description": "Use the token address of the associated DAO's voting module. NOTE: in order to use the token address of the voting module the voting module must (1) use a cw20 token and (2) implement the `TokenContract {}` query type defined by `dao_dao_macros::token_query`. Failing to implement that and using this option will cause instantiation to fail.",
"description": "Use the token native denom or cw20 contract address of the associated DAO's voting module. NOTE: in order to retrieve the token automatically via this variant, the voting module must either (1) use a native token and implement the `Denom {}` query type defined by `dao_dao_macros::native_token_query` OR (2) use a cw20 token and implement the `TokenContract {}` query type defined by `dao_dao_macros::cw20_token_query`. Failing to implement correctly will cause this option to fail to instantiate.",
"type": "object",
"required": [
"voting_module_token"
],
"properties": {
"voting_module_token": {
"type": "object",
"required": [
"token_type"
],
"properties": {
"token_type": {
"$ref": "#/definitions/VotingModuleTokenType"
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -1230,6 +1253,13 @@
"no_with_veto"
]
},
"VotingModuleTokenType": {
"type": "string",
"enum": [
"native",
"cw20"
]
},
"WasmMsg": {
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
"oneOf": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,22 @@
"additionalProperties": false
},
{
"description": "Use the token address of the associated DAO's voting module. NOTE: in order to use the token address of the voting module the voting module must (1) use a cw20 token and (2) implement the `TokenContract {}` query type defined by `dao_dao_macros::token_query`. Failing to implement that and using this option will cause instantiation to fail.",
"description": "Use the token native denom or cw20 contract address of the associated DAO's voting module. NOTE: in order to retrieve the token automatically via this variant, the voting module must either (1) use a native token and implement the `Denom {}` query type defined by `dao_dao_macros::native_token_query` OR (2) use a cw20 token and implement the `TokenContract {}` query type defined by `dao_dao_macros::cw20_token_query`. Failing to implement correctly will cause this option to fail to instantiate.",
"type": "object",
"required": [
"voting_module_token"
],
"properties": {
"voting_module_token": {
"type": "object",
"required": [
"token_type"
],
"properties": {
"token_type": {
"$ref": "#/definitions/VotingModuleTokenType"
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -177,6 +185,13 @@
}
},
"additionalProperties": false
},
"VotingModuleTokenType": {
"type": "string",
"enum": [
"native",
"cw20"
]
}
}
},
Expand Down Expand Up @@ -601,14 +616,22 @@
"additionalProperties": false
},
{
"description": "Use the token address of the associated DAO's voting module. NOTE: in order to use the token address of the voting module the voting module must (1) use a cw20 token and (2) implement the `TokenContract {}` query type defined by `dao_dao_macros::token_query`. Failing to implement that and using this option will cause instantiation to fail.",
"description": "Use the token native denom or cw20 contract address of the associated DAO's voting module. NOTE: in order to retrieve the token automatically via this variant, the voting module must either (1) use a native token and implement the `Denom {}` query type defined by `dao_dao_macros::native_token_query` OR (2) use a cw20 token and implement the `TokenContract {}` query type defined by `dao_dao_macros::cw20_token_query`. Failing to implement correctly will cause this option to fail to instantiate.",
"type": "object",
"required": [
"voting_module_token"
],
"properties": {
"voting_module_token": {
"type": "object",
"required": [
"token_type"
],
"properties": {
"token_type": {
"$ref": "#/definitions/VotingModuleTokenType"
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -1194,6 +1217,13 @@
"no_with_veto"
]
},
"VotingModuleTokenType": {
"type": "string",
"enum": [
"native",
"cw20"
]
},
"WasmMsg": {
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
"oneOf": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use cw20::Cw20Coin;
use cw_multi_test::{next_block, App, Executor};
use cw_utils::Duration;
use dao_voting::{
deposit::{DepositRefundPolicy, UncheckedDepositInfo},
deposit::{DepositRefundPolicy, UncheckedDepositInfo, VotingModuleTokenType},
multiple_choice::{
MultipleChoiceOption, MultipleChoiceOptions, MultipleChoiceVote, VotingStrategy,
},
Expand Down Expand Up @@ -273,7 +273,9 @@ pub fn test_allow_voting_after_proposal_execution_pre_expiration_cw20() {
pre_propose_info: get_pre_propose_info(
&mut app,
Some(UncheckedDepositInfo {
denom: dao_voting::deposit::DepositToken::VotingModuleToken {},
denom: dao_voting::deposit::DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(10_000_000),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use dao_testing::contracts::{
dao_dao_contract, native_staked_balances_voting_contract, pre_propose_multiple_contract,
};
use dao_voting::{
deposit::{DepositRefundPolicy, UncheckedDepositInfo},
deposit::{DepositRefundPolicy, UncheckedDepositInfo, VotingModuleTokenType},
multiple_choice::VotingStrategy,
pre_propose::PreProposeInfo,
threshold::{ActiveThreshold, ActiveThreshold::AbsoluteCount, PercentageThreshold},
Expand Down Expand Up @@ -58,7 +58,9 @@ pub fn _get_default_token_dao_proposal_module_instantiate(app: &mut App) -> Inst
pre_propose_info: get_pre_propose_info(
app,
Some(UncheckedDepositInfo {
denom: dao_voting::deposit::DepositToken::VotingModuleToken {},
denom: dao_voting::deposit::DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(10_000_000),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down
Loading