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..01b61fa5f 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": [ + "pre_propose_id_for_approval_proposal_id" + ], + "properties": { + "pre_propose_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..0cad0fe79 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::PreProposeIdForApprovalProposalId { 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..131d0e178 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,10 @@ pub struct InstantiateMsg { pub enum QueryExt { #[returns(cosmwasm_std::Addr)] PreProposeApprovalContract {}, + #[returns(u64)] + PreProposeIdForApprovalProposalId { + 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..b0a6659f7 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::PreProposeIdForApprovalProposalId { + 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());