From 5b6093e961fb4e20073ad1a648a8737e39aea3a3 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 1 Aug 2024 20:37:31 -0400 Subject: [PATCH 1/4] fix cargo errors --- .../external/cw-tokenfactory-issuer/tests/mod.rs | 4 ---- contracts/external/dao-migrator/README.md | 14 ++++++++------ .../dao-proposal-condorcet/src/testing/suite.rs | 2 +- .../src/tests/test_tube/mod.rs | 4 ---- packages/dao-testing/src/test_tube/mod.rs | 4 ---- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/contracts/external/cw-tokenfactory-issuer/tests/mod.rs b/contracts/external/cw-tokenfactory-issuer/tests/mod.rs index 73b60899d..8ad6cfb23 100644 --- a/contracts/external/cw-tokenfactory-issuer/tests/mod.rs +++ b/contracts/external/cw-tokenfactory-issuer/tests/mod.rs @@ -1,7 +1,3 @@ -// Ignore integration tests for code coverage since there will be problems with dynamic linking libosmosistesttube -// and also, tarpaulin will not be able read coverage out of wasm binary anyway -#![cfg(not(tarpaulin))] - #[cfg(feature = "test-tube")] mod cases; #[cfg(feature = "test-tube")] diff --git a/contracts/external/dao-migrator/README.md b/contracts/external/dao-migrator/README.md index f61a3bb52..ba51df374 100644 --- a/contracts/external/dao-migrator/README.md +++ b/contracts/external/dao-migrator/README.md @@ -5,7 +5,7 @@ Here is the [discussion](https://github.com/DA0-DA0/dao-contracts/discussions/607). -A migrator module for a DAO DAO DAO which handles migration for DAO modules +A migrator module for a DAO DAO DAO which handles migration for DAO modules and test it went successfully. DAO core migration is handled by a proposal, which adds this module and do @@ -14,6 +14,7 @@ If custom module is found, this TX fails and migration is cancelled, custom module requires a custom migration to be done by the DAO. # General idea + 1. Proposal is made to migrate DAO core to V2, which also adds this module to the DAO. 2. On init of this contract, a callback is fired to do the migration. 3. Then we check to make sure the DAO doesn't have custom modules. @@ -23,9 +24,10 @@ module requires a custom migration to be done by the DAO. 7. In any case where 1 migration fails, we fail the whole TX. # Important notes -* custom modules cannot reliably be migrated by this contract, -because of that we fail the process to avoid any unwanted results. -* If any module migration fails we fail the whole thing, -this is to make sure that we either have a fully working V2, -or we do nothing and make sure the DAO is operational at any time. \ No newline at end of file +- custom modules cannot reliably be migrated by this contract, + because of that we fail the process to avoid any unwanted results. + +- If any module migration fails we fail the whole thing, + this is to make sure that we either have a fully working V2, + or we do nothing and make sure the DAO is operational at any time. diff --git a/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs b/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs index 79d18154f..c268bc5c1 100644 --- a/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs +++ b/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs @@ -146,7 +146,7 @@ impl SuiteBuilder { if let Some(candidates) = self.with_proposal { suite .propose( - &suite.sender(), + suite.sender(), (0..candidates) .map(|_| vec![unimportant_message()]) .collect(), diff --git a/contracts/voting/dao-voting-token-staked/src/tests/test_tube/mod.rs b/contracts/voting/dao-voting-token-staked/src/tests/test_tube/mod.rs index fe51e9fb6..eb0b4f91b 100644 --- a/contracts/voting/dao-voting-token-staked/src/tests/test_tube/mod.rs +++ b/contracts/voting/dao-voting-token-staked/src/tests/test_tube/mod.rs @@ -1,6 +1,2 @@ -// Ignore integration tests for code coverage since there will be problems with dynamic linking libosmosistesttube -// and also, tarpaulin will not be able read coverage out of wasm binary anyway -#![cfg(not(tarpaulin))] - mod integration_tests; mod test_env; diff --git a/packages/dao-testing/src/test_tube/mod.rs b/packages/dao-testing/src/test_tube/mod.rs index c764df4d1..107ea403d 100644 --- a/packages/dao-testing/src/test_tube/mod.rs +++ b/packages/dao-testing/src/test_tube/mod.rs @@ -1,7 +1,3 @@ -// Ignore integration tests for code coverage since there will be problems with dynamic linking libosmosistesttube -// and also, tarpaulin will not be able read coverage out of wasm binary anyway -#![cfg(not(tarpaulin))] - // Integrationg tests using an actual chain binary, requires // the "test-tube" feature to be enabled // cargo test --features test-tube From 6dff386e02bcd765729dc11cfcb79f64ad1a538b Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 1 Aug 2024 21:04:53 -0400 Subject: [PATCH 2/4] replaced pre-propose submission policy's optional vectors of strings with vectors of addrs --- ci/bootstrap-env/src/main.rs | 4 +- ci/integration-tests/src/helpers/helper.rs | 4 +- .../src/tests.rs | 116 ++++++++--------- .../dao-pre-propose-approver/src/contract.rs | 4 +- .../dao-pre-propose-approver/src/tests.rs | 36 +++--- .../dao-pre-propose-multiple/src/tests.rs | 114 ++++++++--------- .../dao-pre-propose-single/src/tests.rs | 118 +++++++++--------- .../src/testing/instantiate.rs | 6 +- .../src/testing/tests.rs | 6 +- .../src/testing/instantiate.rs | 6 +- .../dao-proposal-single/src/testing/tests.rs | 8 +- packages/dao-pre-propose-base/src/execute.rs | 71 ++++------- packages/dao-pre-propose-base/src/tests.rs | 2 +- packages/dao-voting/src/pre_propose.rs | 9 +- 14 files changed, 239 insertions(+), 265 deletions(-) diff --git a/ci/bootstrap-env/src/main.rs b/ci/bootstrap-env/src/main.rs index e32e4f558..be218793f 100644 --- a/ci/bootstrap-env/src/main.rs +++ b/ci/bootstrap-env/src/main.rs @@ -102,8 +102,8 @@ fn main() -> Result<()> { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty::default(), }) diff --git a/ci/integration-tests/src/helpers/helper.rs b/ci/integration-tests/src/helpers/helper.rs index 95b0e55bb..13b627d4d 100644 --- a/ci/integration-tests/src/helpers/helper.rs +++ b/ci/integration-tests/src/helpers/helper.rs @@ -86,8 +86,8 @@ pub fn create_dao( }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty::default(), }) diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs index 8c9093997..2c74dc823 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs @@ -65,12 +65,12 @@ fn get_default_proposal_module_instantiate( let pre_propose_id = app.store_code(dao_pre_propose_approval_single_contract()); let submission_policy = if open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; @@ -1393,7 +1393,7 @@ fn test_anyone_denylist() { pre_propose.clone(), core_addr.as_str(), None, - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); let rando = "rando"; @@ -1408,7 +1408,7 @@ fn test_anyone_denylist() { core_addr.as_str(), None, PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec![rando.to_string()]), + denylist: vec![Addr::unchecked(rando)], }, ); @@ -1457,8 +1457,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -1499,8 +1499,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec![rando.to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![], }, ); @@ -1515,8 +1515,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec![rando.to_string()]), - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![Addr::unchecked("ekez")], }, ); @@ -1551,8 +1551,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec![rando.to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![], }, ); @@ -1616,8 +1616,8 @@ fn test_instantiate_with_zero_native_deposit() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: InstantiateExt { approver: "approver".to_string(), @@ -1685,8 +1685,8 @@ fn test_instantiate_with_zero_cw20_deposit() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: InstantiateExt { approver: "approver".to_string(), @@ -1737,8 +1737,8 @@ fn test_update_config() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] } } ); @@ -1759,7 +1759,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never, }), - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); let config = get_config(&app, pre_propose.clone()); @@ -1771,7 +1771,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never }), - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1826,7 +1826,7 @@ fn test_update_config() { pre_propose.clone(), proposal_single.as_str(), None, - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); assert_eq!(err, PreProposeError::NotDao {}); @@ -1838,8 +1838,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); assert_eq!( @@ -1855,8 +1855,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![Addr::unchecked("ekez")], }, ); assert_eq!( @@ -1881,7 +1881,7 @@ fn test_update_submission_policy() { config, Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1925,7 +1925,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec!["ekez".to_string()]), + denylist: vec![Addr::unchecked("ekez")], }, } ); @@ -1951,7 +1951,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec!["someone".to_string(), "else".to_string()]), + denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], }, } ); @@ -1976,7 +1976,7 @@ fn test_update_submission_policy() { config, Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -2056,8 +2056,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: Some(PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }), }, &[], @@ -2071,8 +2071,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, } ); @@ -2099,8 +2099,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![], + denylist: vec![Addr::unchecked("ekez")], }, } ); @@ -2127,8 +2127,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: Some(vec!["someone".to_string(), "else".to_string()]), + allowlist: vec![], + denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], }, } ); @@ -2155,8 +2155,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); @@ -2183,8 +2183,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec!["ekez".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![], }, } ); @@ -2211,8 +2211,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec!["someone".to_string(), "else".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![], }, } ); @@ -2239,8 +2239,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); @@ -2289,8 +2289,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: None + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![] }, } ); @@ -2363,8 +2363,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -2414,8 +2414,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -2792,8 +2792,8 @@ fn test_migrate_from_v241() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] } }, config @@ -3087,8 +3087,8 @@ fn test_migrate_from_v241_with_policy_update() { msg: to_json_binary(&MigrateMsg::FromUnderV250 { policy: Some(PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["noob".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("noob")], + denylist: vec![], }), }) .unwrap(), @@ -3155,8 +3155,8 @@ fn test_migrate_from_v241_with_policy_update() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["noob".to_string()]), - denylist: None + allowlist: vec![Addr::unchecked("noob")], + denylist: vec![] } }, config diff --git a/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs b/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs index 8a4a6f774..268d3bae8 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs @@ -41,8 +41,8 @@ pub fn instantiate( deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty {}, }; diff --git a/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs b/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs index 2e62af1da..c1475939a 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs @@ -82,12 +82,12 @@ fn get_proposal_module_approval_single_instantiate( let pre_propose_id = app.store_code(cw_pre_propose_base_proposal_single()); let submission_policy = if open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; @@ -1359,8 +1359,8 @@ fn test_update_config() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] } } ); @@ -1388,7 +1388,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never, }), - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); let config = get_config(&app, pre_propose.clone()); @@ -1400,7 +1400,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never }), - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1457,7 +1457,7 @@ fn test_update_config() { pre_propose.clone(), proposal_single.as_str(), None, - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); assert_eq!(err, PreProposeError::NotDao {}); @@ -1469,8 +1469,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); assert_eq!( @@ -1486,8 +1486,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![Addr::unchecked("ekez")], }, ); assert_eq!( @@ -1520,8 +1520,8 @@ fn test_approver_unsupported_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![], }, ); assert_eq!(err, PreProposeError::Unsupported {}); @@ -1636,8 +1636,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -1689,8 +1689,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); diff --git a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs index 9fab05407..32b4dfd71 100644 --- a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs @@ -68,12 +68,12 @@ fn get_default_proposal_module_instantiate( let pre_propose_id = app.store_code(dao_pre_propose_multiple_contract()); let submission_policy = if open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; @@ -1067,7 +1067,7 @@ fn test_anyone_denylist() { pre_propose.clone(), core_addr.as_str(), None, - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); let rando = "rando"; @@ -1088,7 +1088,7 @@ fn test_anyone_denylist() { core_addr.as_str(), None, PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec![rando.to_string()]), + denylist: vec![Addr::unchecked(rando)], }, ); @@ -1143,8 +1143,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -1197,8 +1197,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec![rando.to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![], }, ); @@ -1219,8 +1219,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec![rando.to_string()]), - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![Addr::unchecked("ekez")], }, ); @@ -1261,8 +1261,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec![rando.to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![], }, ); @@ -1370,8 +1370,8 @@ fn test_instantiate_with_zero_native_deposit() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty::default(), }) @@ -1437,8 +1437,8 @@ fn test_instantiate_with_zero_cw20_deposit() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty::default(), }) @@ -1487,8 +1487,8 @@ fn test_update_config() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] } } ); @@ -1512,7 +1512,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never, }), - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); let config = get_config(&app, pre_propose.clone()); @@ -1524,7 +1524,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never }), - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1587,7 +1587,7 @@ fn test_update_config() { pre_propose.clone(), proposal_single.as_str(), None, - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); assert_eq!(err, PreProposeError::NotDao {}); @@ -1599,8 +1599,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); assert_eq!( @@ -1616,8 +1616,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![Addr::unchecked("ekez")], }, ); assert_eq!( @@ -1642,7 +1642,7 @@ fn test_update_submission_policy() { config, Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1686,7 +1686,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec!["ekez".to_string()]), + denylist: vec![Addr::unchecked("ekez")], }, } ); @@ -1712,7 +1712,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec!["someone".to_string(), "else".to_string()]), + denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], }, } ); @@ -1737,7 +1737,7 @@ fn test_update_submission_policy() { config, Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1817,8 +1817,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: Some(PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }), }, &[], @@ -1832,8 +1832,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, } ); @@ -1860,8 +1860,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![], + denylist: vec![Addr::unchecked("ekez")], }, } ); @@ -1888,8 +1888,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: Some(vec!["someone".to_string(), "else".to_string()]), + allowlist: vec![], + denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], }, } ); @@ -1916,8 +1916,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); @@ -1944,8 +1944,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec!["ekez".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![], }, } ); @@ -1972,8 +1972,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec!["someone".to_string(), "else".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![], }, } ); @@ -2000,8 +2000,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); @@ -2050,8 +2050,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: None + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![] }, } ); @@ -2124,8 +2124,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -2172,8 +2172,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -2566,7 +2566,7 @@ fn test_migrate_from_v241() { assert_eq!( Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None } + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] } }, config ); @@ -2889,8 +2889,8 @@ fn test_migrate_from_v241_with_policy_update() { msg: to_json_binary(&MigrateMsg::FromUnderV250 { policy: Some(PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["noob".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("noob")], + denylist: vec![], }), }) .unwrap(), @@ -2956,8 +2956,8 @@ fn test_migrate_from_v241_with_policy_update() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["noob".to_string()]), - denylist: None + allowlist: vec![Addr::unchecked("noob")], + denylist: vec![] } }, config diff --git a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs index e7efc6615..5545ce9dc 100644 --- a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs @@ -65,12 +65,12 @@ fn get_default_proposal_module_instantiate( let pre_propose_id = app.store_code(dao_pre_propose_single_contract()); let submission_policy = if open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; @@ -1002,7 +1002,7 @@ fn test_anyone_denylist() { pre_propose.clone(), core_addr.as_str(), None, - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); let rando = "rando"; @@ -1023,7 +1023,7 @@ fn test_anyone_denylist() { core_addr.as_str(), None, PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec![rando.to_string()]), + denylist: vec![Addr::unchecked(rando)], }, ); @@ -1072,8 +1072,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -1120,8 +1120,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec![rando.to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![], }, ); @@ -1142,8 +1142,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec![rando.to_string()]), - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![Addr::unchecked("ekez")], }, ); @@ -1178,8 +1178,8 @@ fn test_specific_allowlist_denylist() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec![rando.to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked(rando)], + denylist: vec![], }, ); @@ -1281,8 +1281,8 @@ fn test_instantiate_with_zero_native_deposit() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty::default(), }) @@ -1348,8 +1348,8 @@ fn test_instantiate_with_zero_cw20_deposit() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty::default(), }) @@ -1398,8 +1398,8 @@ fn test_update_config() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); @@ -1423,7 +1423,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never, }), - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); let config = get_config(&app, pre_propose.clone()); @@ -1435,7 +1435,7 @@ fn test_update_config() { amount: Uint128::new(10), refund_policy: DepositRefundPolicy::Never }), - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1486,7 +1486,7 @@ fn test_update_config() { pre_propose.clone(), proposal_single.as_str(), None, - PreProposeSubmissionPolicy::Anyone { denylist: None }, + PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, ); assert_eq!(err, PreProposeError::NotDao {}); @@ -1498,8 +1498,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); assert_eq!( @@ -1515,8 +1515,8 @@ fn test_update_config() { None, PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![Addr::unchecked("ekez")], }, ); assert_eq!( @@ -1543,7 +1543,7 @@ fn test_update_config() { config, Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); } @@ -1562,7 +1562,7 @@ fn test_update_submission_policy() { config, Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1606,7 +1606,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec!["ekez".to_string()]), + denylist: vec![Addr::unchecked("ekez")], }, } ); @@ -1632,7 +1632,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: Some(vec!["someone".to_string(), "else".to_string()]), + denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], }, } ); @@ -1657,7 +1657,7 @@ fn test_update_submission_policy() { config, Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, } ); @@ -1737,8 +1737,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: Some(PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }), }, &[], @@ -1752,8 +1752,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, } ); @@ -1780,8 +1780,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: Some(vec!["ekez".to_string()]), + allowlist: vec![], + denylist: vec![Addr::unchecked("ekez")], }, } ); @@ -1808,8 +1808,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: Some(vec!["someone".to_string(), "else".to_string()]), + allowlist: vec![], + denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], }, } ); @@ -1836,8 +1836,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); @@ -1864,8 +1864,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec!["ekez".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![], }, } ); @@ -1892,8 +1892,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: Some(vec!["someone".to_string(), "else".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![], }, } ); @@ -1920,8 +1920,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); @@ -1970,8 +1970,8 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["ekez".to_string()]), - denylist: None + allowlist: vec![Addr::unchecked("ekez")], + denylist: vec![] }, } ); @@ -2044,8 +2044,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -2092,8 +2092,8 @@ fn test_withdraw() { }), PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, ); @@ -2466,8 +2466,8 @@ fn test_migrate_from_v241() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] } }, config @@ -2741,8 +2741,8 @@ fn test_migrate_from_v241_with_policy_update() { msg: to_json_binary(&MigrateMsg::FromUnderV250 { policy: Some(PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["noob".to_string()]), - denylist: None, + allowlist: vec![Addr::unchecked("noob")], + denylist: vec![], }), }) .unwrap(), @@ -2800,8 +2800,8 @@ fn test_migrate_from_v241_with_policy_update() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: false, - allowlist: Some(vec!["noob".to_string()]), - denylist: None + allowlist: vec![Addr::unchecked("noob")], + denylist: vec![] } }, config diff --git a/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs b/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs index 28fdc5847..693edfbb0 100644 --- a/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs +++ b/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs @@ -34,12 +34,12 @@ fn get_pre_propose_info( let pre_propose_contract = app.store_code(pre_propose_multiple_contract()); let submission_policy = if open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; diff --git a/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs b/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs index 55b43cc9f..2b82b7ce7 100644 --- a/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs +++ b/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs @@ -99,12 +99,12 @@ pub fn get_pre_propose_info( let pre_propose_contract = app.store_code(pre_propose_multiple_contract()); let submission_policy = if open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; diff --git a/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs b/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs index 42514753d..217ad740f 100644 --- a/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs +++ b/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs @@ -33,12 +33,12 @@ pub(crate) fn get_pre_propose_info( app.store_code(crate::testing::contracts::pre_propose_single_contract()); let submission_policy = if open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; diff --git a/contracts/proposal/dao-proposal-single/src/testing/tests.rs b/contracts/proposal/dao-proposal-single/src/testing/tests.rs index 34b591ea0..56bc68522 100644 --- a/contracts/proposal/dao-proposal-single/src/testing/tests.rs +++ b/contracts/proposal/dao-proposal-single/src/testing/tests.rs @@ -3957,8 +3957,8 @@ fn test_update_pre_propose_module() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], }, extension: Empty::default(), }) @@ -4012,8 +4012,8 @@ fn test_update_pre_propose_module() { }), submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None + allowlist: vec![], + denylist: vec![] }, } ); diff --git a/packages/dao-pre-propose-base/src/execute.rs b/packages/dao-pre-propose-base/src/execute.rs index bba2db9f1..778fa5de2 100644 --- a/packages/dao-pre-propose-base/src/execute.rs +++ b/packages/dao-pre-propose-base/src/execute.rs @@ -246,7 +246,7 @@ where let mut config = self.config.load(deps.storage)?; match config.submission_policy { - PreProposeSubmissionPolicy::Anyone { denylist } => { + PreProposeSubmissionPolicy::Anyone { mut denylist } => { // Error if other values that apply to Specific were set. if set_dao_members.is_some() || allowlist_add.is_some() @@ -257,43 +257,35 @@ where )); } - let mut denylist = denylist.unwrap_or_default(); - // Add to denylist. - if let Some(mut denylist_add) = denylist_add { + if let Some(denylist_add) = denylist_add { // Validate addresses. - denylist_add + let mut addrs = denylist_add .iter() .map(|addr| deps.api.addr_validate(addr)) .collect::>>()?; - denylist.append(&mut denylist_add); + denylist.append(&mut addrs); denylist.dedup(); } // Remove from denylist. if let Some(denylist_remove) = denylist_remove { // Validate addresses. - denylist_remove + let addrs = denylist_remove .iter() .map(|addr| deps.api.addr_validate(addr)) .collect::>>()?; - denylist.retain(|a| !denylist_remove.contains(a)); + denylist.retain(|a| !addrs.contains(a)); } - let denylist = if denylist.is_empty() { - None - } else { - Some(denylist) - }; - config.submission_policy = PreProposeSubmissionPolicy::Anyone { denylist }; } PreProposeSubmissionPolicy::Specific { dao_members, - allowlist, - denylist, + mut allowlist, + mut denylist, } => { let dao_members = if let Some(new_dao_members) = set_dao_members { new_dao_members @@ -301,67 +293,52 @@ where dao_members }; - let mut allowlist = allowlist.unwrap_or_default(); - let mut denylist = denylist.unwrap_or_default(); - // Add to allowlist. - if let Some(mut allowlist_add) = allowlist_add { + if let Some(allowlist_add) = allowlist_add { // Validate addresses. - allowlist_add + let mut addrs = allowlist_add .iter() .map(|addr| deps.api.addr_validate(addr)) .collect::>>()?; - allowlist.append(&mut allowlist_add); + allowlist.append(&mut addrs); allowlist.dedup(); } // Remove from allowlist. if let Some(allowlist_remove) = allowlist_remove { // Validate addresses. - allowlist_remove + let addrs = allowlist_remove .iter() .map(|addr| deps.api.addr_validate(addr)) .collect::>>()?; - allowlist.retain(|a| !allowlist_remove.contains(a)); + allowlist.retain(|a| !addrs.contains(a)); } // Add to denylist. - if let Some(mut denylist_add) = denylist_add { + if let Some(denylist_add) = denylist_add { // Validate addresses. - denylist_add + let mut addrs = denylist_add .iter() .map(|addr| deps.api.addr_validate(addr)) .collect::>>()?; - denylist.append(&mut denylist_add); + denylist.append(&mut addrs); denylist.dedup(); } // Remove from denylist. if let Some(denylist_remove) = denylist_remove { // Validate addresses. - denylist_remove + let addrs = denylist_remove .iter() .map(|addr| deps.api.addr_validate(addr)) .collect::>>()?; - denylist.retain(|a| !denylist_remove.contains(a)); + denylist.retain(|a| !addrs.contains(a)); } - // Replace empty vectors with None. - let allowlist = if allowlist.is_empty() { - None - } else { - Some(allowlist) - }; - let denylist = if denylist.is_empty() { - None - } else { - Some(denylist) - }; - config.submission_policy = PreProposeSubmissionPolicy::Specific { dao_members, allowlist, @@ -527,7 +504,7 @@ where match config.submission_policy { PreProposeSubmissionPolicy::Anyone { denylist } => { - if !denylist.unwrap_or_default().contains(&who.to_string()) { + if !denylist.contains(&who) { return Ok(()); } } @@ -537,9 +514,9 @@ where denylist, } => { // denylist overrides all other settings - if !denylist.unwrap_or_default().contains(&who.to_string()) { + if !denylist.contains(&who) { // if on the allowlist, return early - if allowlist.unwrap_or_default().contains(&who.to_string()) { + if allowlist.contains(&who) { return Ok(()); } @@ -640,12 +617,12 @@ where // otherwise convert old `open_proposal_submission` flag // into new policy enum } else if old_config.open_proposal_submission { - PreProposeSubmissionPolicy::Anyone { denylist: None } + PreProposeSubmissionPolicy::Anyone { denylist: vec![] } } else { PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: None, - denylist: None, + allowlist: vec![], + denylist: vec![], } }; diff --git a/packages/dao-pre-propose-base/src/tests.rs b/packages/dao-pre-propose-base/src/tests.rs index be7c4d189..c575ea677 100644 --- a/packages/dao-pre-propose-base/src/tests.rs +++ b/packages/dao-pre-propose-base/src/tests.rs @@ -87,7 +87,7 @@ fn test_proposal_submitted_hooks() { &mut deps.storage, &Config { deposit_info: None, - submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: None }, + submission_policy: PreProposeSubmissionPolicy::Anyone { denylist: vec![] }, }, ) .unwrap(); diff --git a/packages/dao-voting/src/pre_propose.rs b/packages/dao-voting/src/pre_propose.rs index 680d1f588..9384c971c 100644 --- a/packages/dao-voting/src/pre_propose.rs +++ b/packages/dao-voting/src/pre_propose.rs @@ -71,16 +71,16 @@ pub enum PreProposeSubmissionPolicy { /// Anyone may create proposals, except for those in the denylist. Anyone { /// Addresses that may not create proposals. - denylist: Option>, + denylist: Vec, }, /// Specific people may create proposals. Specific { /// Whether or not DAO members may create proposals. dao_members: bool, /// Addresses that may create proposals. - allowlist: Option>, + allowlist: Vec, /// Addresses that may not create proposals, overriding other settings. - denylist: Option>, + denylist: Vec, }, } @@ -108,9 +108,6 @@ impl PreProposeSubmissionPolicy { denylist, } = self { - let allowlist = allowlist.as_deref().unwrap_or_default(); - let denylist = denylist.as_deref().unwrap_or_default(); - // prevent allowlist and denylist from overlapping if denylist.iter().any(|a| allowlist.iter().any(|b| a == b)) { return Err(PreProposeSubmissionPolicyError::DenylistAllowlistOverlap {}); From a1e75d4bd093f19024d68754e1696db5855a457d Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 1 Aug 2024 23:57:03 -0400 Subject: [PATCH 3/4] de-dupe redundant code --- .../src/tests.rs | 6 +- .../dao-pre-propose-multiple/src/tests.rs | 6 +- .../dao-pre-propose-single/src/tests.rs | 6 +- packages/dao-pre-propose-base/src/execute.rs | 86 ++++--------------- packages/dao-pre-propose-base/src/helpers.rs | 32 +++++++ packages/dao-pre-propose-base/src/lib.rs | 1 + 6 files changed, 61 insertions(+), 76 deletions(-) create mode 100644 packages/dao-pre-propose-base/src/helpers.rs diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs index 2c74dc823..2e3f3e324 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs @@ -1951,7 +1951,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], }, } ); @@ -2128,7 +2128,7 @@ fn test_update_submission_policy() { submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, allowlist: vec![], - denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], }, } ); @@ -2211,7 +2211,7 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + allowlist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], denylist: vec![], }, } diff --git a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs index 32b4dfd71..f949702c2 100644 --- a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs @@ -1712,7 +1712,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], }, } ); @@ -1889,7 +1889,7 @@ fn test_update_submission_policy() { submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, allowlist: vec![], - denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], }, } ); @@ -1972,7 +1972,7 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + allowlist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], denylist: vec![], }, } diff --git a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs index 5545ce9dc..a8eef5e3e 100644 --- a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs @@ -1632,7 +1632,7 @@ fn test_update_submission_policy() { Config { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Anyone { - denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], }, } ); @@ -1809,7 +1809,7 @@ fn test_update_submission_policy() { submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, allowlist: vec![], - denylist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + denylist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], }, } ); @@ -1892,7 +1892,7 @@ fn test_update_submission_policy() { deposit_info: None, submission_policy: PreProposeSubmissionPolicy::Specific { dao_members: true, - allowlist: vec![Addr::unchecked("someone"), Addr::unchecked("else")], + allowlist: vec![Addr::unchecked("else"), Addr::unchecked("someone")], denylist: vec![], }, } diff --git a/packages/dao-pre-propose-base/src/execute.rs b/packages/dao-pre-propose-base/src/execute.rs index 778fa5de2..fea5238e6 100644 --- a/packages/dao-pre-propose-base/src/execute.rs +++ b/packages/dao-pre-propose-base/src/execute.rs @@ -19,6 +19,7 @@ use serde::Serialize; use crate::{ error::PreProposeError, + helpers::add_and_remove_addresses, msg::{DepositInfoResponse, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}, state::{Config, PreProposeContract}, }; @@ -257,28 +258,12 @@ where )); } - // Add to denylist. - if let Some(denylist_add) = denylist_add { - // Validate addresses. - let mut addrs = denylist_add - .iter() - .map(|addr| deps.api.addr_validate(addr)) - .collect::>>()?; - - denylist.append(&mut addrs); - denylist.dedup(); - } - - // Remove from denylist. - if let Some(denylist_remove) = denylist_remove { - // Validate addresses. - let addrs = denylist_remove - .iter() - .map(|addr| deps.api.addr_validate(addr)) - .collect::>>()?; - - denylist.retain(|a| !addrs.contains(a)); - } + add_and_remove_addresses( + deps.as_ref(), + &mut denylist, + denylist_add, + denylist_remove, + )?; config.submission_policy = PreProposeSubmissionPolicy::Anyone { denylist }; } @@ -293,51 +278,18 @@ where dao_members }; - // Add to allowlist. - if let Some(allowlist_add) = allowlist_add { - // Validate addresses. - let mut addrs = allowlist_add - .iter() - .map(|addr| deps.api.addr_validate(addr)) - .collect::>>()?; - - allowlist.append(&mut addrs); - allowlist.dedup(); - } - - // Remove from allowlist. - if let Some(allowlist_remove) = allowlist_remove { - // Validate addresses. - let addrs = allowlist_remove - .iter() - .map(|addr| deps.api.addr_validate(addr)) - .collect::>>()?; - - allowlist.retain(|a| !addrs.contains(a)); - } - - // Add to denylist. - if let Some(denylist_add) = denylist_add { - // Validate addresses. - let mut addrs = denylist_add - .iter() - .map(|addr| deps.api.addr_validate(addr)) - .collect::>>()?; - - denylist.append(&mut addrs); - denylist.dedup(); - } - - // Remove from denylist. - if let Some(denylist_remove) = denylist_remove { - // Validate addresses. - let addrs = denylist_remove - .iter() - .map(|addr| deps.api.addr_validate(addr)) - .collect::>>()?; - - denylist.retain(|a| !addrs.contains(a)); - } + add_and_remove_addresses( + deps.as_ref(), + &mut allowlist, + allowlist_add, + allowlist_remove, + )?; + add_and_remove_addresses( + deps.as_ref(), + &mut denylist, + denylist_add, + denylist_remove, + )?; config.submission_policy = PreProposeSubmissionPolicy::Specific { dao_members, diff --git a/packages/dao-pre-propose-base/src/helpers.rs b/packages/dao-pre-propose-base/src/helpers.rs new file mode 100644 index 000000000..cbc265da6 --- /dev/null +++ b/packages/dao-pre-propose-base/src/helpers.rs @@ -0,0 +1,32 @@ +use cosmwasm_std::{Addr, Deps, StdResult}; + +/// validate addresses and add to and/or remove from an existing list of +/// addresses, removing any duplicates. mutates the original list. +pub fn add_and_remove_addresses( + deps: Deps, + list: &mut Vec, + add: Option>, + remove: Option>, +) -> StdResult<()> { + if let Some(add) = add { + let mut addrs = add + .iter() + .map(|addr| deps.api.addr_validate(addr)) + .collect::>>()?; + + list.append(&mut addrs); + list.sort(); + list.dedup(); + } + + if let Some(remove) = remove { + let addrs = remove + .iter() + .map(|addr| deps.api.addr_validate(addr)) + .collect::>>()?; + + list.retain(|a| !addrs.contains(a)); + } + + Ok(()) +} diff --git a/packages/dao-pre-propose-base/src/lib.rs b/packages/dao-pre-propose-base/src/lib.rs index be0040039..707bf4681 100644 --- a/packages/dao-pre-propose-base/src/lib.rs +++ b/packages/dao-pre-propose-base/src/lib.rs @@ -2,6 +2,7 @@ pub mod error; pub mod execute; +pub mod helpers; pub mod msg; pub mod state; From 7874011b76e1db21678343dccf0f84b5643d575e Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Fri, 2 Aug 2024 00:01:21 -0400 Subject: [PATCH 4/4] updated schema --- .../dao-pre-propose-approval-single.json | 124 +++++++++--------- .../schema/dao-pre-propose-approver.json | 92 +++++++------ .../schema/dao-pre-propose-multiple.json | 124 +++++++++--------- .../schema/dao-pre-propose-single.json | 124 +++++++++--------- 4 files changed, 224 insertions(+), 240 deletions(-) diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json b/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json index 060a12f52..25303c6bd 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json +++ b/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json @@ -41,6 +41,10 @@ }, "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": [ { @@ -139,15 +143,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -166,17 +170,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -185,12 +188,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -531,6 +531,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": [ @@ -1204,15 +1208,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -1231,17 +1235,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -1250,12 +1253,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2328,6 +2328,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" + }, "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" @@ -2344,15 +2348,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2371,17 +2375,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -2390,12 +2393,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2553,15 +2553,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2580,17 +2580,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -2599,12 +2598,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, diff --git a/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json b/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json index 82f095399..8dc9a227c 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json +++ b/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json @@ -266,6 +266,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" + }, "ApproverProposeMessage": { "oneOf": [ { @@ -451,15 +455,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -478,17 +482,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -497,12 +500,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -942,6 +942,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" + }, "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" @@ -958,15 +962,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -985,17 +989,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -1004,12 +1007,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -1167,15 +1167,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -1194,17 +1194,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -1213,12 +1212,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, diff --git a/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json b/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json index a39977ce6..a23f2cc06 100644 --- a/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json +++ b/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json @@ -41,6 +41,10 @@ }, "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": [ { @@ -131,15 +135,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -158,17 +162,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -177,12 +180,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -523,6 +523,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": [ @@ -1201,15 +1205,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -1228,17 +1232,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -1247,12 +1250,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2013,6 +2013,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" + }, "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" @@ -2029,15 +2033,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2056,17 +2060,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -2075,12 +2078,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2238,15 +2238,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2265,17 +2265,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -2284,12 +2283,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, diff --git a/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json b/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json index 83c0fac71..d91d61190 100644 --- a/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json +++ b/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json @@ -41,6 +41,10 @@ }, "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": [ { @@ -131,15 +135,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -158,17 +162,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -177,12 +180,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -523,6 +523,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": [ @@ -1122,15 +1126,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -1149,17 +1153,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -1168,12 +1171,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -1987,6 +1987,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" + }, "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" @@ -2003,15 +2007,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2030,17 +2034,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -2049,12 +2052,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2212,15 +2212,15 @@ "properties": { "anyone": { "type": "object", + "required": [ + "denylist" + ], "properties": { "denylist": { "description": "Addresses that may not create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } }, @@ -2239,17 +2239,16 @@ "specific": { "type": "object", "required": [ - "dao_members" + "allowlist", + "dao_members", + "denylist" ], "properties": { "allowlist": { "description": "Addresses that may create proposals.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } }, "dao_members": { @@ -2258,12 +2257,9 @@ }, "denylist": { "description": "Addresses that may not create proposals, overriding other settings.", - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/Addr" } } },