bvs_vault_base/
proxy.rs

1use cosmwasm_std::{Addr, StdResult, Storage};
2use cw_storage_plus::Map;
3
4type Owner = Addr;
5type Proxy = Addr;
6
7/// Mapping of the owner (of shares) and the proxy.  
8/// This will allow the proxy to queue and redeem withdrawals on behalf of the owner.
9const APPROVED_PROXY: Map<(&Owner, &Proxy), bool> = Map::new("approved_proxy");
10
11pub fn set_approved_proxy(
12    storage: &mut dyn Storage,
13    owner: &Addr,
14    proxy: &Addr,
15    is_approved: &bool,
16) -> StdResult<()> {
17    APPROVED_PROXY.save(storage, (owner, proxy), is_approved)?;
18    Ok(())
19}
20
21/// Return `true` if the proxy is approved by the owner, otherwise `false`.
22pub fn is_approved_proxy(storage: &dyn Storage, owner: &Addr, proxy: &Addr) -> StdResult<bool> {
23    let is_approved = APPROVED_PROXY.may_load(storage, (owner, proxy))?;
24    Ok(is_approved.unwrap_or(false))
25}