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 49a6916
Show file tree
Hide file tree
Showing 23 changed files with 228 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,7 +88,7 @@
"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"
Expand Down Expand Up @@ -609,7 +609,7 @@
"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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
"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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"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"
Expand Down Expand Up @@ -601,7 +601,7 @@
"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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"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"
Expand Down Expand Up @@ -601,7 +601,7 @@
"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"
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
49 changes: 37 additions & 12 deletions contracts/proposal/dao-proposal-multiple/src/testing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use dao_interface::state::ProposalModule;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_voting::veto::{VetoConfig, VetoError};
use dao_voting::{
deposit::{CheckedDepositInfo, DepositRefundPolicy, DepositToken, UncheckedDepositInfo},
deposit::{
CheckedDepositInfo, DepositRefundPolicy, DepositToken, UncheckedDepositInfo,
VotingModuleTokenType,
},
multiple_choice::{
CheckedMultipleChoiceOption, MultipleChoiceOption, MultipleChoiceOptionType,
MultipleChoiceOptions, MultipleChoiceVote, MultipleChoiceVotes, VotingStrategy,
Expand Down Expand Up @@ -715,7 +718,9 @@ fn test_voting_module_token_proposal_deposit_instantiate() {
pre_propose_info: get_pre_propose_info(
&mut app,
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down Expand Up @@ -884,7 +889,9 @@ fn test_take_proposal_deposit() {
pre_propose_info: get_pre_propose_info(
&mut app,
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down Expand Up @@ -1131,7 +1138,9 @@ fn test_deposit_return_on_execute() {
Status::Passed,
None,
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down Expand Up @@ -1416,7 +1425,9 @@ fn test_cant_propose_zero_power() {
pre_propose_info: get_pre_propose_info(
&mut app,
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::Always,
}),
Expand Down Expand Up @@ -1532,7 +1543,9 @@ fn test_cant_vote_not_registered() {
Status::Open,
Some(Uint128::new(100)),
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::Always,
}),
Expand Down Expand Up @@ -1887,7 +1900,9 @@ fn test_close_open_proposal() {
Status::Open,
Some(Uint128::new(100)),
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::Always,
}),
Expand Down Expand Up @@ -1955,7 +1970,9 @@ fn test_no_refund_failed_proposal() {
Status::Open,
Some(Uint128::new(100)),
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down Expand Up @@ -2033,7 +2050,9 @@ fn test_deposit_return_on_close() {
Status::Rejected,
None,
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::Always,
}),
Expand Down Expand Up @@ -2333,7 +2352,9 @@ fn test_no_return_if_no_refunds() {
Status::Rejected,
None,
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down Expand Up @@ -3529,7 +3550,9 @@ fn test_return_deposit_to_dao_on_proposal_failure() {
Status::Open,
Some(Uint128::new(100)),
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
Expand Down Expand Up @@ -3832,7 +3855,9 @@ fn test_no_double_refund_on_execute_fail_and_close() {
pre_propose_info: get_pre_propose_info(
&mut app,
Some(UncheckedDepositInfo {
denom: DepositToken::VotingModuleToken {},
denom: DepositToken::VotingModuleToken {
token_type: VotingModuleTokenType::Cw20,
},
amount: Uint128::new(1),
// Important to set to true here as we want to be sure
// that we don't get a second refund on close. Refunds on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use cw20::Cw20Coin;
use cw_multi_test::{next_block, App};
use cw_utils::Duration;
use dao_voting::{
deposit::{DepositRefundPolicy, UncheckedDepositInfo},
deposit::{DepositRefundPolicy, UncheckedDepositInfo, VotingModuleTokenType},
status::Status,
threshold::{PercentageThreshold, Threshold::AbsolutePercentage},
voting::Vote,
Expand Down Expand Up @@ -171,7 +171,9 @@ pub fn test_executed_prop_state_remains_after_vote_swing() {
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 Expand Up @@ -268,7 +270,9 @@ pub fn test_passed_prop_state_remains_after_vote_swing() {
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 @@ -7,7 +7,7 @@ use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_pre_propose_single as cppbps;

use dao_voting::{
deposit::{DepositRefundPolicy, UncheckedDepositInfo},
deposit::{DepositRefundPolicy, UncheckedDepositInfo, VotingModuleTokenType},
pre_propose::PreProposeInfo,
threshold::{ActiveThreshold, PercentageThreshold, Threshold::ThresholdQuorum},
};
Expand Down Expand Up @@ -61,7 +61,9 @@ pub(crate) fn get_default_token_dao_proposal_module_instantiate(app: &mut App) -
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 49a6916

Please sign in to comment.