From f1b93e7f1d23ab02f1f0ca71caecaaf875e6dd50 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Mon, 13 Nov 2023 19:59:51 -0800 Subject: [PATCH] Add missing query to dao-pre-propose-approver. --- .../schema/dao-pre-propose-approver.json | 23 +++++++++++++++++++ .../dao-pre-propose-approver/src/contract.rs | 3 +++ .../dao-pre-propose-approver/src/msg.rs | 2 ++ .../dao-pre-propose-approver/src/tests.rs | 21 +++++++++++++---- 4 files changed, 45 insertions(+), 4 deletions(-) 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 ea29a1792..d77050b43 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 @@ -543,6 +543,29 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "pending_proposal_id_for_approval_proposal_id" + ], + "properties": { + "pending_proposal_id_for_approval_proposal_id": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } ] } 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 c1e52ecd3..58133965b 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs @@ -188,6 +188,9 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { QueryExt::PreProposeApprovalContract {} => { to_binary(&PRE_PROPOSE_APPROVAL_CONTRACT.load(deps.storage)?) } + QueryExt::PendingProposalIdForApprovalProposalId { id } => { + to_binary(&PROPOSAL_IDS.load(deps.storage, id)?) + } }, _ => PrePropose::default().query(deps, env, msg), } diff --git a/contracts/pre-propose/dao-pre-propose-approver/src/msg.rs b/contracts/pre-propose/dao-pre-propose-approver/src/msg.rs index 249b45caa..7b66a1d46 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/msg.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/msg.rs @@ -15,6 +15,8 @@ pub struct InstantiateMsg { pub enum QueryExt { #[returns(cosmwasm_std::Addr)] PreProposeApprovalContract {}, + #[returns(u64)] + PendingProposalIdForApprovalProposalId { id: u64 }, } pub type BaseInstantiateMsg = InstantiateBase; 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 a52c91042..ca71fdcce 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs @@ -26,6 +26,7 @@ use dao_voting::{ use crate::contract::{CONTRACT_NAME, CONTRACT_VERSION}; use crate::msg::InstantiateMsg as ApproverInstantiateMsg; +use crate::msg::{QueryExt as ApproverQueryExt, QueryMsg as ApproverQueryMsg}; // The approver dao contract is the 6th contract instantiated const APPROVER: &str = "contract6"; @@ -1234,7 +1235,7 @@ fn test_propose_open_proposal_submission() { pre_propose, _approver_core_addr: _, proposal_single_approver, - pre_propose_approver: _, + pre_propose_approver, } = setup_default_test( &mut app, Some(UncheckedDepositInfo { @@ -1249,11 +1250,23 @@ fn test_propose_open_proposal_submission() { // Non-member proposes. mint_natives(&mut app, "nonmember", coins(10, "ujuno")); - let _pre_propose_id = - make_pre_proposal(&mut app, pre_propose, "nonmember", &coins(10, "ujuno")); + let pre_propose_id = make_pre_proposal(&mut app, pre_propose, "nonmember", &coins(10, "ujuno")); - // Approver DAO votes to approves let approver_prop_id = get_latest_proposal_id(&app, proposal_single_approver.clone()); + let pre_propose_id_from_proposal: u64 = app + .wrap() + .query_wasm_smart( + pre_propose_approver.clone(), + &ApproverQueryMsg::QueryExtension { + msg: ApproverQueryExt::PendingProposalIdForApprovalProposalId { + id: approver_prop_id, + }, + }, + ) + .unwrap(); + assert_eq!(pre_propose_id, pre_propose_id_from_proposal); + + // Approver DAO votes to approves approve_proposal(&mut app, proposal_single_approver, "ekez", approver_prop_id); let id = get_latest_proposal_id(&app, proposal_single.clone());