Skip to content

Commit

Permalink
Add missing query to dao-pre-propose-approver.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Nov 14, 2023
1 parent db42d45 commit f1b93e7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
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),
}
Expand Down
2 changes: 2 additions & 0 deletions contracts/pre-propose/dao-pre-propose-approver/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub struct InstantiateMsg {
pub enum QueryExt {
#[returns(cosmwasm_std::Addr)]
PreProposeApprovalContract {},
#[returns(u64)]
PendingProposalIdForApprovalProposalId { id: u64 },
}

pub type BaseInstantiateMsg = InstantiateBase<Empty>;
Expand Down
21 changes: 17 additions & 4 deletions contracts/pre-propose/dao-pre-propose-approver/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 {
Expand All @@ -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());

Expand Down

0 comments on commit f1b93e7

Please sign in to comment.