Skip to content

Commit

Permalink
add info query to pre-propose-base
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Jul 19, 2024
1 parent ebc7914 commit a4cf157
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor};
use cw_utils::Duration;
use dao_interface::state::ProposalModule;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_interface::proposal::InfoResponse;
use dao_pre_propose_base::{error::PreProposeError, msg::DepositInfoResponse, state::Config};
use dao_proposal_single::query::ProposalResponse;
use dao_testing::helpers::instantiate_with_cw4_groups_governance;
Expand Down Expand Up @@ -179,6 +180,15 @@ fn setup_default_test(
get_proposal_module(app, pre_propose.clone())
);
assert_eq!(core_addr, get_dao(app, pre_propose.clone()));
assert_eq!(
InfoResponse {
info: ContractVersion {
contract: "crates.io:dao-pre-propose-approval-single".to_string(),
version: env!("CARGO_PKG_VERSION").to_string()
}
},
get_info(app, pre_propose.clone())
);

DefaultTestSetup {
core_addr,
Expand Down Expand Up @@ -297,6 +307,12 @@ fn get_dao(app: &App, module: Addr) -> Addr {
.unwrap()
}

fn get_info(app: &App, module: Addr) -> InfoResponse {
app.wrap()
.query_wasm_smart(module, &QueryMsg::Info {})
.unwrap()
}

fn get_proposal_module(app: &App, module: Addr) -> Addr {
app.wrap()
.query_wasm_smart(module, &QueryMsg::ProposalModule {})
Expand Down
16 changes: 16 additions & 0 deletions contracts/pre-propose/dao-pre-propose-approver/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use cw2::ContractVersion;
use cw20::Cw20Coin;
use cw_denom::UncheckedDenom;
use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor};
use dao_interface::proposal::InfoResponse;
use dao_voting::pre_propose::{PreProposeSubmissionPolicy, PreProposeSubmissionPolicyError};
use dps::query::{ProposalListResponse, ProposalResponse};

Expand Down Expand Up @@ -300,6 +301,15 @@ fn setup_default_test(
approver_core_addr,
get_dao(app, pre_propose_approver.clone())
);
assert_eq!(
InfoResponse {
info: ContractVersion {
contract: "crates.io:dao-pre-propose-approver".to_string(),
version: env!("CARGO_PKG_VERSION").to_string()
}
},
get_info(app, pre_propose_approver.clone())
);

DefaultTestSetup {
core_addr,
Expand Down Expand Up @@ -418,6 +428,12 @@ fn get_dao(app: &App, module: Addr) -> Addr {
.unwrap()
}

fn get_info(app: &App, module: Addr) -> InfoResponse {
app.wrap()
.query_wasm_smart(module, &QueryMsg::Info {})
.unwrap()
}

fn get_proposal_module(app: &App, module: Addr) -> Addr {
app.wrap()
.query_wasm_smart(module, &QueryMsg::ProposalModule {})
Expand Down
16 changes: 16 additions & 0 deletions contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor};
use cw_utils::Duration;
use dao_interface::state::ProposalModule;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_interface::proposal::InfoResponse;
use dao_pre_propose_base::{error::PreProposeError, msg::DepositInfoResponse, state::Config};
use dao_proposal_multiple as cpm;
use dao_testing::helpers::instantiate_with_cw4_groups_governance;
Expand Down Expand Up @@ -178,6 +179,15 @@ fn setup_default_test(
get_proposal_module(app, pre_propose.clone())
);
assert_eq!(core_addr, get_dao(app, pre_propose.clone()));
assert_eq!(
InfoResponse {
info: ContractVersion {
contract: "crates.io:dao-pre-propose-multiple".to_string(),
version: env!("CARGO_PKG_VERSION").to_string()
}
},
get_info(app, pre_propose.clone())
);

DefaultTestSetup {
core_addr,
Expand Down Expand Up @@ -350,6 +360,12 @@ fn get_dao(app: &App, module: Addr) -> Addr {
.unwrap()
}

fn get_info(app: &App, module: Addr) -> InfoResponse {
app.wrap()
.query_wasm_smart(module, &QueryMsg::Info {})
.unwrap()
}

fn get_proposal_module(app: &App, module: Addr) -> Addr {
app.wrap()
.query_wasm_smart(module, &QueryMsg::ProposalModule {})
Expand Down
16 changes: 16 additions & 0 deletions contracts/pre-propose/dao-pre-propose-single/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor};
use cw_utils::Duration;
use dao_interface::state::ProposalModule;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_interface::proposal::InfoResponse;
use dao_pre_propose_base::{error::PreProposeError, msg::DepositInfoResponse, state::Config};
use dao_proposal_single as dps;
use dao_testing::helpers::instantiate_with_cw4_groups_governance;
Expand Down Expand Up @@ -176,6 +177,15 @@ fn setup_default_test(
get_proposal_module(app, pre_propose.clone())
);
assert_eq!(core_addr, get_dao(app, pre_propose.clone()));
assert_eq!(
InfoResponse {
info: ContractVersion {
contract: "crates.io:dao-pre-propose-single".to_string(),
version: env!("CARGO_PKG_VERSION").to_string()
}
},
get_info(app, pre_propose.clone())
);

DefaultTestSetup {
core_addr,
Expand Down Expand Up @@ -325,6 +335,12 @@ fn get_dao(app: &App, module: Addr) -> Addr {
.unwrap()
}

fn get_info(app: &App, module: Addr) -> InfoResponse {
app.wrap()
.query_wasm_smart(module, &QueryMsg::Info {})
.unwrap()
}

fn query_hooks(app: &App, module: Addr) -> cw_hooks::HooksResponse {
app.wrap()
.query_wasm_smart(module, &QueryMsg::ProposalSubmittedHooks {})
Expand Down
3 changes: 3 additions & 0 deletions packages/dao-pre-propose-base/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ where
to_json_binary(&self.proposal_module.load(deps.storage)?)
}
QueryMsg::Dao {} => to_json_binary(&self.dao.load(deps.storage)?),
QueryMsg::Info {} => to_json_binary(&dao_interface::proposal::InfoResponse {
info: cw2::get_contract_version(deps.storage)?,
}),
QueryMsg::Config {} => to_json_binary(&self.config.load(deps.storage)?),
QueryMsg::DepositInfo { proposal_id } => {
let (deposit_info, proposer) = self.deposits.load(deps.storage, proposal_id)?;
Expand Down
4 changes: 4 additions & 0 deletions packages/dao-pre-propose-base/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use cosmwasm_schema::{cw_serde, schemars::JsonSchema, QueryResponses};
use cw_denom::UncheckedDenom;
use dao_interface::proposal::InfoResponse;

Check warning on line 3 in packages/dao-pre-propose-base/src/msg.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `dao_interface::proposal::InfoResponse`

Check warning on line 3 in packages/dao-pre-propose-base/src/msg.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `dao_interface::proposal::InfoResponse`
use dao_voting::{
deposit::{CheckedDepositInfo, UncheckedDepositInfo},
pre_propose::PreProposeSubmissionPolicy,
Expand Down Expand Up @@ -118,6 +119,9 @@ where
/// with. Returns `Addr`.
#[returns(cosmwasm_std::Addr)]
Dao {},
/// Returns contract version info.
#[returns(InfoResponse)]
Info {},
/// Gets the module's configuration.
#[returns(crate::state::Config)]
Config {},
Expand Down

0 comments on commit a4cf157

Please sign in to comment.