abstract_testing/
abstract_mock_querier.rsuse abstract_std::{
account::state::{ACCOUNT_ID, CALLING_TO_AS_ADMIN},
ans_host::state::{ASSET_ADDRESSES, CHANNELS, CONTRACT_ADDRESSES},
objects::{
gov_type::GovernanceDetails, ownership::Ownership,
storage_namespaces::OWNERSHIP_STORAGE_KEY, AccountId, AssetEntry, ChannelEntry,
ContractEntry,
},
registry::{state::ACCOUNT_ADDRESSES, Account},
};
use cosmwasm_std::Addr;
use cw_asset::AssetInfo;
use cw_storage_plus::Item;
use crate::prelude::*;
pub trait AbstractMockQuerier {
fn account(self, account: &Account, account_id: AccountId) -> Self;
fn assets(self, assets: Vec<(&AssetEntry, AssetInfo)>) -> Self;
fn set_account_admin_call_to(self, account: &Account) -> Self;
fn contracts(self, contracts: Vec<(&ContractEntry, Addr)>) -> Self;
fn channels(self, channels: Vec<(&ChannelEntry, String)>) -> Self;
fn addrs(&self) -> AbstractMockAddrs;
}
impl AbstractMockQuerier for MockQuerierBuilder {
fn account(self, account: &Account, account_id: AccountId) -> Self {
let abstract_addrs = self.addrs();
self.with_contract_item(account.addr(), ACCOUNT_ID, &account_id)
.with_contract_item(
account.addr(),
Item::new(OWNERSHIP_STORAGE_KEY),
&Some(Ownership {
owner: GovernanceDetails::Monarchy {
monarch: abstract_addrs.owner.clone(),
},
pending_owner: None,
pending_expiry: None,
}),
)
.with_contract_map_entry(
&abstract_addrs.registry,
ACCOUNT_ADDRESSES,
(&account_id, account.clone()),
)
.with_contract_map_entry(
account.addr(),
abstract_std::account::state::ACCOUNT_MODULES,
(TEST_MODULE_ID, abstract_addrs.module_address),
)
}
fn assets(self, assets: Vec<(&AssetEntry, AssetInfo)>) -> Self {
let abstract_addrs = self.addrs();
self.with_contract_map_entries(&abstract_addrs.ans_host, ASSET_ADDRESSES, assets)
}
fn contracts(self, contracts: Vec<(&ContractEntry, Addr)>) -> Self {
let abstract_addrs = self.addrs();
self.with_contract_map_entries(&abstract_addrs.ans_host, CONTRACT_ADDRESSES, contracts)
}
fn channels(self, channels: Vec<(&ChannelEntry, String)>) -> Self {
let abstract_addrs = self.addrs();
self.with_contract_map_entries(&abstract_addrs.ans_host, CHANNELS, channels)
}
fn addrs(&self) -> AbstractMockAddrs {
AbstractMockAddrs::new(self.api)
}
fn set_account_admin_call_to(self, account: &Account) -> Self {
let env = mock_env_validated(self.api);
self.with_contract_item(account.addr(), CALLING_TO_AS_ADMIN, &env.contract.address)
}
}