-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rs
38 lines (34 loc) · 1.17 KB
/
app.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{ensure, Addr, DepsMut, MessageInfo, Response, Storage};
use crate::ado_contract::ADOContract;
use crate::amp::addresses::AndrAddr;
use crate::error::ContractError;
#[cw_serde]
enum AppQueryMsg {
ComponentExists { name: String },
GetAddress { name: String },
}
impl<'a> ADOContract<'a> {
#[inline]
pub fn get_app_contract(&self, storage: &dyn Storage) -> Result<Option<Addr>, ContractError> {
Ok(self.app_contract.may_load(storage)?)
}
pub fn execute_update_app_contract(
&self,
deps: DepsMut,
info: MessageInfo,
address: String,
addresses: Option<Vec<AndrAddr>>,
) -> Result<Response, ContractError> {
ensure!(
self.is_contract_owner(deps.storage, info.sender.as_str())?,
ContractError::Unauthorized {}
);
self.app_contract
.save(deps.storage, &deps.api.addr_validate(&address)?)?;
self.validate_andr_addresses(&deps.as_ref(), addresses.unwrap_or_default())?;
Ok(Response::new()
.add_attribute("action", "update_app_contract")
.add_attribute("address", address))
}
}