Skip to content

Commit

Permalink
Add ComponentContracts query to the facade
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDeeKay committed Dec 12, 2023
1 parent ccaffb3 commit aad7ec4
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 54 deletions.
9 changes: 5 additions & 4 deletions contracts/enterprise-facade-v1/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::{env::current_dir, fs::create_dir_all};

use cosmwasm_schema::{export_schema, remove_schemas, schema_for};
use enterprise_facade_api::api::{
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, DaoInfoResponse, MemberInfoResponse,
MemberVoteResponse, MultisigMembersResponse, NftWhitelistResponse, ProposalResponse,
ProposalStatusResponse, ProposalVotesResponse, ProposalsResponse, StakedNftsResponse,
TotalStakedAmountResponse, UserStakeResponse,
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, ComponentContractsResponse,
DaoInfoResponse, MemberInfoResponse, MemberVoteResponse, MultisigMembersResponse,
NftWhitelistResponse, ProposalResponse, ProposalStatusResponse, ProposalVotesResponse,
ProposalsResponse, StakedNftsResponse, TotalStakedAmountResponse, UserStakeResponse,
};
use enterprise_facade_api::msg::{ExecuteMsg, QueryMsg};

Expand All @@ -21,6 +21,7 @@ fn main() {
export_schema(&schema_for!(StakedNftsResponse), &out_dir);
export_schema(&schema_for!(MultisigMembersResponse), &out_dir);
export_schema(&schema_for!(DaoInfoResponse), &out_dir);
export_schema(&schema_for!(ComponentContractsResponse), &out_dir);
export_schema(&schema_for!(AssetWhitelistResponse), &out_dir);
export_schema(&schema_for!(NftWhitelistResponse), &out_dir);
export_schema(&schema_for!(MemberInfoResponse), &out_dir);
Expand Down
4 changes: 4 additions & 0 deletions contracts/enterprise-facade-v1/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> EnterpriseFacadeResult<Bina
let facade = get_facade(contract)?;
to_json_binary(&facade.query_dao_info(qctx)?)?
}
QueryMsg::ComponentContracts { contract } => {
let facade = get_facade(contract)?;
to_json_binary(&facade.query_component_contracts(qctx)?)?
}
QueryMsg::MemberInfo { contract, msg } => {
let facade = get_facade(contract)?;
to_json_binary(&facade.query_member_info(qctx, msg)?)?
Expand Down
38 changes: 29 additions & 9 deletions contracts/enterprise-facade-v1/src/facade_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ use cw_utils::Expiration;
use enterprise_facade_api::api::{
adapter_response_single_execute_msg, AdaptedExecuteMsg, AdaptedMsg, AdapterResponse,
AssetWhitelistParams, AssetWhitelistResponse, CastVoteMsg, ClaimsParams, ClaimsResponse,
CreateProposalMsg, CreateProposalWithDenomDepositMsg, CreateProposalWithTokenDepositMsg,
DaoInfoResponse, DaoType, ExecuteProposalMsg, GovConfigFacade, ListMultisigMembersMsg,
MemberInfoResponse, MemberVoteParams, MemberVoteResponse, MultisigMembersResponse,
NftWhitelistParams, NftWhitelistResponse, Proposal, ProposalParams, ProposalResponse,
ProposalStatus, ProposalStatusParams, ProposalStatusResponse, ProposalType,
ProposalVotesParams, ProposalVotesResponse, ProposalsParams, ProposalsResponse,
QueryMemberInfoMsg, StakeMsg, StakedNftsParams, StakedNftsResponse, TotalStakedAmountResponse,
TreasuryAddressResponse, UnstakeMsg, UserStakeParams, UserStakeResponse, V2MigrationStage,
V2MigrationStageResponse,
ComponentContractsResponse, CreateProposalMsg, CreateProposalWithDenomDepositMsg,
CreateProposalWithTokenDepositMsg, DaoInfoResponse, DaoType, ExecuteProposalMsg,
GovConfigFacade, ListMultisigMembersMsg, MemberInfoResponse, MemberVoteParams,
MemberVoteResponse, MultisigMembersResponse, NftWhitelistParams, NftWhitelistResponse,
Proposal, ProposalParams, ProposalResponse, ProposalStatus, ProposalStatusParams,
ProposalStatusResponse, ProposalType, ProposalVotesParams, ProposalVotesResponse,
ProposalsParams, ProposalsResponse, QueryMemberInfoMsg, StakeMsg, StakedNftsParams,
StakedNftsResponse, TotalStakedAmountResponse, TreasuryAddressResponse, UnstakeMsg,
UserStakeParams, UserStakeResponse, V2MigrationStage, V2MigrationStageResponse,
};
use enterprise_facade_api::error::DaoError::UnsupportedOperationForDaoType;
use enterprise_facade_api::error::EnterpriseFacadeError::Dao;
Expand Down Expand Up @@ -106,6 +106,26 @@ impl EnterpriseFacade for EnterpriseFacadeV1 {
})
}

fn query_component_contracts(
&self,
qctx: QueryContext,
) -> EnterpriseFacadeResult<ComponentContractsResponse> {
let dao_info = self.query_dao_info(qctx)?;

Ok(ComponentContractsResponse {
enterprise_factory_contract: dao_info.enterprise_factory_contract,
enterprise_contract: self.enterprise_address.clone(),
funds_distributor_contract: dao_info.funds_distributor_contract,
enterprise_governance_contract: None,
enterprise_governance_controller_contract: None,
enterprise_outposts_contract: None,
enterprise_treasury_contract: None,
membership_contract: None,
council_membership_contract: None,
attestation_contract: None,
})
}

fn query_member_info(
&self,
qctx: QueryContext,
Expand Down
9 changes: 5 additions & 4 deletions contracts/enterprise-facade-v2/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::{env::current_dir, fs::create_dir_all};

use cosmwasm_schema::{export_schema, remove_schemas, schema_for};
use enterprise_facade_api::api::{
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, DaoInfoResponse, MemberInfoResponse,
MemberVoteResponse, MultisigMembersResponse, NftWhitelistResponse, ProposalResponse,
ProposalStatusResponse, ProposalVotesResponse, ProposalsResponse, StakedNftsResponse,
TotalStakedAmountResponse, UserStakeResponse,
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, ComponentContractsResponse,
DaoInfoResponse, MemberInfoResponse, MemberVoteResponse, MultisigMembersResponse,
NftWhitelistResponse, ProposalResponse, ProposalStatusResponse, ProposalVotesResponse,
ProposalsResponse, StakedNftsResponse, TotalStakedAmountResponse, UserStakeResponse,
};
use enterprise_facade_api::msg::{ExecuteMsg, QueryMsg};

Expand All @@ -21,6 +21,7 @@ fn main() {
export_schema(&schema_for!(StakedNftsResponse), &out_dir);
export_schema(&schema_for!(MultisigMembersResponse), &out_dir);
export_schema(&schema_for!(DaoInfoResponse), &out_dir);
export_schema(&schema_for!(ComponentContractsResponse), &out_dir);
export_schema(&schema_for!(AssetWhitelistResponse), &out_dir);
export_schema(&schema_for!(NftWhitelistResponse), &out_dir);
export_schema(&schema_for!(MemberInfoResponse), &out_dir);
Expand Down
4 changes: 4 additions & 0 deletions contracts/enterprise-facade-v2/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> EnterpriseFacadeResult<Bina
let facade = get_facade(contract)?;
to_json_binary(&facade.query_dao_info(qctx)?)?
}
QueryMsg::ComponentContracts { contract } => {
let facade = get_facade(contract)?;
to_json_binary(&facade.query_component_contracts(qctx)?)?
}
QueryMsg::MemberInfo { contract, msg } => {
let facade = get_facade(contract)?;
to_json_binary(&facade.query_member_info(qctx, msg)?)?
Expand Down
24 changes: 24 additions & 0 deletions contracts/enterprise-facade-v2/src/facade_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,30 @@ impl EnterpriseFacade for EnterpriseFacadeV2 {
})
}

fn query_component_contracts(
&self,
qctx: QueryContext,
) -> EnterpriseFacadeResult<enterprise_facade_api::api::ComponentContractsResponse> {
let component_contracts = self.component_contracts(qctx.deps)?;

Ok(enterprise_facade_api::api::ComponentContractsResponse {
enterprise_factory_contract: component_contracts.enterprise_factory_contract,
enterprise_contract: self.enterprise_address.clone(),
funds_distributor_contract: component_contracts.funds_distributor_contract,
enterprise_governance_contract: Some(
component_contracts.enterprise_governance_contract,
),
enterprise_governance_controller_contract: Some(
component_contracts.enterprise_governance_controller_contract,
),
enterprise_outposts_contract: Some(component_contracts.enterprise_outposts_contract),
enterprise_treasury_contract: Some(component_contracts.enterprise_treasury_contract),
membership_contract: Some(component_contracts.membership_contract),
council_membership_contract: Some(component_contracts.council_membership_contract),
attestation_contract: component_contracts.attestation_contract,
})
}

fn query_member_info(
&self,
qctx: QueryContext,
Expand Down
9 changes: 5 additions & 4 deletions contracts/enterprise-facade/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::{env::current_dir, fs::create_dir_all};

use cosmwasm_schema::{export_schema, remove_schemas, schema_for};
use enterprise_facade_api::api::{
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, DaoInfoResponse, MemberInfoResponse,
MemberVoteResponse, MultisigMembersResponse, NftWhitelistResponse, ProposalResponse,
ProposalStatusResponse, ProposalVotesResponse, ProposalsResponse, StakedNftsResponse,
TotalStakedAmountResponse, UserStakeResponse,
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, ComponentContractsResponse,
DaoInfoResponse, MemberInfoResponse, MemberVoteResponse, MultisigMembersResponse,
NftWhitelistResponse, ProposalResponse, ProposalStatusResponse, ProposalVotesResponse,
ProposalsResponse, StakedNftsResponse, TotalStakedAmountResponse, UserStakeResponse,
};
use enterprise_facade_api::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

Expand All @@ -22,6 +22,7 @@ fn main() {
export_schema(&schema_for!(StakedNftsResponse), &out_dir);
export_schema(&schema_for!(MultisigMembersResponse), &out_dir);
export_schema(&schema_for!(DaoInfoResponse), &out_dir);
export_schema(&schema_for!(ComponentContractsResponse), &out_dir);
export_schema(&schema_for!(AssetWhitelistResponse), &out_dir);
export_schema(&schema_for!(NftWhitelistResponse), &out_dir);
export_schema(&schema_for!(MemberInfoResponse), &out_dir);
Expand Down
32 changes: 22 additions & 10 deletions contracts/enterprise-facade/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use cosmwasm_std::{
};
use cw2::set_contract_version;
use enterprise_facade_api::api::{
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, DaoInfoResponse, MemberInfoResponse,
MemberVoteResponse, MultisigMembersResponse, NftWhitelistResponse, ProposalResponse,
ProposalStatusResponse, ProposalVotesResponse, ProposalsResponse, StakedNftsResponse,
TotalStakedAmountResponse, TreasuryAddressResponse, UserStakeResponse,
V2MigrationStageResponse,
AdapterResponse, AssetWhitelistResponse, ClaimsResponse, ComponentContractsResponse,
DaoInfoResponse, MemberInfoResponse, MemberVoteResponse, MultisigMembersResponse,
NftWhitelistResponse, ProposalResponse, ProposalStatusResponse, ProposalVotesResponse,
ProposalsResponse, StakedNftsResponse, TotalStakedAmountResponse, TreasuryAddressResponse,
UserStakeResponse, V2MigrationStageResponse,
};
use enterprise_facade_api::error::EnterpriseFacadeResult;
use enterprise_facade_api::msg::QueryMsg::{
Expand All @@ -22,11 +22,12 @@ use enterprise_treasury_api::api::{
};
use QueryMsg::{
AssetWhitelist, CastCouncilVoteAdapted, CastVoteAdapted, ClaimAdapted, Claims,
CreateCouncilProposalAdapted, CreateProposalAdapted, CreateProposalWithDenomDepositAdapted,
CreateProposalWithNftDepositAdapted, CreateProposalWithTokenDepositAdapted,
CrossChainTreasuries, DaoInfo, HasUnmovedStakesOrClaims, ListMultisigMembers, MemberInfo,
MemberVote, NftWhitelist, Proposal, ProposalStatus, ProposalVotes, Proposals, ReleasableClaims,
StakeAdapted, StakedNfts, TotalStakedAmount, UnstakeAdapted, UserStake,
ComponentContracts, CreateCouncilProposalAdapted, CreateProposalAdapted,
CreateProposalWithDenomDepositAdapted, CreateProposalWithNftDepositAdapted,
CreateProposalWithTokenDepositAdapted, CrossChainTreasuries, DaoInfo, HasUnmovedStakesOrClaims,
ListMultisigMembers, MemberInfo, MemberVote, NftWhitelist, Proposal, ProposalStatus,
ProposalVotes, Proposals, ReleasableClaims, StakeAdapted, StakedNfts, TotalStakedAmount,
UnstakeAdapted, UserStake,
};

// version info for migration info
Expand Down Expand Up @@ -91,6 +92,17 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> EnterpriseFacadeResult<Bin
)?;
to_json_binary(&response)?
}
ComponentContracts { contract } => {
let facade = get_facade(deps, contract)?;

let response: ComponentContractsResponse = deps.querier.query_wasm_smart(
facade.facade_address.to_string(),
&ComponentContracts {
contract: facade.dao_address,
},
)?;
to_json_binary(&response)?
}
MemberInfo { contract, msg } => {
let facade = get_facade(deps, contract)?;

Expand Down
20 changes: 18 additions & 2 deletions packages/enterprise-facade-api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,20 @@ pub struct DaoInfoResponse {
pub dao_version: Version,
}

#[cw_serde]
pub struct ComponentContractsResponse {
pub enterprise_factory_contract: Addr,
pub enterprise_contract: Addr,
pub funds_distributor_contract: Addr,
pub enterprise_governance_contract: Option<Addr>,
pub enterprise_governance_controller_contract: Option<Addr>,
pub enterprise_outposts_contract: Option<Addr>,
pub enterprise_treasury_contract: Option<Addr>,
pub membership_contract: Option<Addr>,
pub council_membership_contract: Option<Addr>,
pub attestation_contract: Option<Addr>,
}

#[cw_serde]
pub struct GovConfigV1 {
/// Portion of total available votes cast in a proposal to consider it valid
Expand All @@ -245,7 +259,8 @@ pub struct GovConfigV1 {
/// If None, will default to the threshold set for all proposal options.
pub veto_threshold: Option<Decimal>,
/// Duration of proposals before they end, expressed in seconds
pub vote_duration: u64, // TODO: change from u64 to Duration
pub vote_duration: u64,
// TODO: change from u64 to Duration
/// Duration that has to pass for unstaked membership tokens to be claimable
pub unlocking_period: Duration,
/// Optional minimum amount of DAO's governance unit to be required to create a deposit.
Expand All @@ -270,7 +285,8 @@ pub struct GovConfigFacade {
/// Will default to the threshold set for all proposal options.
pub veto_threshold: Decimal,
/// Duration of proposals before they end, expressed in seconds
pub vote_duration: u64, // TODO: change from u64 to Duration
pub vote_duration: u64,
// TODO: change from u64 to Duration
/// Duration that has to pass for unstaked membership tokens to be claimable
pub unlocking_period: Duration,
/// Optional minimum amount of DAO's governance unit to be required to create a deposit.
Expand Down
19 changes: 11 additions & 8 deletions packages/enterprise-facade-api/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::api::{
AdapterResponse, AssetWhitelistParams, AssetWhitelistResponse, CastVoteMsg, ClaimsParams,
ClaimsResponse, CreateProposalMsg, CreateProposalWithDenomDepositMsg,
CreateProposalWithTokenDepositMsg, DaoInfoResponse, ExecuteProposalMsg, ListMultisigMembersMsg,
MemberInfoResponse, MemberVoteParams, MemberVoteResponse, MultisigMembersResponse,
NftWhitelistParams, NftWhitelistResponse, ProposalParams, ProposalResponse,
ProposalStatusParams, ProposalStatusResponse, ProposalVotesParams, ProposalVotesResponse,
ProposalsParams, ProposalsResponse, QueryMemberInfoMsg, StakeMsg, StakedNftsParams,
StakedNftsResponse, TotalStakedAmountResponse, TreasuryAddressResponse, UnstakeMsg,
UserStakeParams, UserStakeResponse, V2MigrationStageResponse,
ClaimsResponse, ComponentContractsResponse, CreateProposalMsg,
CreateProposalWithDenomDepositMsg, CreateProposalWithTokenDepositMsg, DaoInfoResponse,
ExecuteProposalMsg, ListMultisigMembersMsg, MemberInfoResponse, MemberVoteParams,
MemberVoteResponse, MultisigMembersResponse, NftWhitelistParams, NftWhitelistResponse,
ProposalParams, ProposalResponse, ProposalStatusParams, ProposalStatusResponse,
ProposalVotesParams, ProposalVotesResponse, ProposalsParams, ProposalsResponse,
QueryMemberInfoMsg, StakeMsg, StakedNftsParams, StakedNftsResponse, TotalStakedAmountResponse,
TreasuryAddressResponse, UnstakeMsg, UserStakeParams, UserStakeResponse,
V2MigrationStageResponse,
};
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::Addr;
Expand All @@ -33,6 +34,8 @@ pub enum QueryMsg {
TreasuryAddress { contract: Addr },
#[returns(DaoInfoResponse)]
DaoInfo { contract: Addr },
#[returns(ComponentContractsResponse)]
ComponentContracts { contract: Addr },
#[returns(MemberInfoResponse)]
MemberInfo {
contract: Addr,
Expand Down
22 changes: 14 additions & 8 deletions packages/enterprise-facade-common/src/facade.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use common::cw::QueryContext;
use enterprise_facade_api::api::{
AdapterResponse, AssetWhitelistParams, AssetWhitelistResponse, CastVoteMsg, ClaimsParams,
ClaimsResponse, CreateProposalMsg, CreateProposalWithDenomDepositMsg,
CreateProposalWithTokenDepositMsg, DaoInfoResponse, ExecuteProposalMsg, ListMultisigMembersMsg,
MemberInfoResponse, MemberVoteParams, MemberVoteResponse, MultisigMembersResponse,
NftWhitelistParams, NftWhitelistResponse, ProposalParams, ProposalResponse,
ProposalStatusParams, ProposalStatusResponse, ProposalVotesParams, ProposalVotesResponse,
ProposalsParams, ProposalsResponse, QueryMemberInfoMsg, StakeMsg, StakedNftsParams,
StakedNftsResponse, TotalStakedAmountResponse, TreasuryAddressResponse, UnstakeMsg,
UserStakeParams, UserStakeResponse, V2MigrationStageResponse,
ClaimsResponse, ComponentContractsResponse, CreateProposalMsg,
CreateProposalWithDenomDepositMsg, CreateProposalWithTokenDepositMsg, DaoInfoResponse,
ExecuteProposalMsg, ListMultisigMembersMsg, MemberInfoResponse, MemberVoteParams,
MemberVoteResponse, MultisigMembersResponse, NftWhitelistParams, NftWhitelistResponse,
ProposalParams, ProposalResponse, ProposalStatusParams, ProposalStatusResponse,
ProposalVotesParams, ProposalVotesResponse, ProposalsParams, ProposalsResponse,
QueryMemberInfoMsg, StakeMsg, StakedNftsParams, StakedNftsResponse, TotalStakedAmountResponse,
TreasuryAddressResponse, UnstakeMsg, UserStakeParams, UserStakeResponse,
V2MigrationStageResponse,
};
use enterprise_facade_api::error::EnterpriseFacadeResult;
use enterprise_governance_controller_api::api::CreateProposalWithNftDepositMsg;
Expand All @@ -25,6 +26,11 @@ pub trait EnterpriseFacade {

fn query_dao_info(&self, qctx: QueryContext) -> EnterpriseFacadeResult<DaoInfoResponse>;

fn query_component_contracts(
&self,
qctx: QueryContext,
) -> EnterpriseFacadeResult<ComponentContractsResponse>;

fn query_member_info(
&self,
qctx: QueryContext,
Expand Down
10 changes: 5 additions & 5 deletions refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"address": "terra1y2dwydnnnctdwwmvs23ct60fj626t66qk53cae2gc55k3ce92jmqldj0sf"
},
"enterprise-facade": {
"codeId": "2245",
"codeId": "2345",
"address": "terra136k05x7uzu0awwxgr8wtqunedjpnv4jzmc4ery40czx5338ht8vq0ja9xq"
},
"enterprise-versioning": {
Expand Down Expand Up @@ -143,12 +143,12 @@
"codeId": "2187"
},
"enterprise-facade-v1": {
"codeId": "2243",
"address": "terra14d9vkw33t3uex3f5jwgxa4pnh7vpzw8sje3py73tphjezt7jdeesfx2c75"
"codeId": "2343",
"address": "terra1ryr2nmj0jq580lq6rawzkmzmplx7hr8atqght6zycsr0afn0fdmqjc3eg2"
},
"enterprise-facade-v2": {
"codeId": "2244",
"address": "terra1zvvte69dj2ds59fed6g20ecvtd62j5h8jvl45kmj4st733hyg2dqxa9jau"
"codeId": "2344",
"address": "terra1t33hpdcmhmx67jef8zplpc9y9fyhlefssswy5vqcr3kvp7c2y3hs89hy2j"
},
"cw721_metadata_onchain": {
"codeId": "2111"
Expand Down

0 comments on commit aad7ec4

Please sign in to comment.