Skip to content

Commit

Permalink
Support using newly created token factory denom as proposal deposit d…
Browse files Browse the repository at this point in the history
…uring instantiation.
  • Loading branch information
NoahSaso committed Dec 18, 2023
1 parent a3f15d7 commit 537c2c6
Show file tree
Hide file tree
Showing 23 changed files with 332 additions and 94 deletions.
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

0 comments on commit 537c2c6

Please sign in to comment.