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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! # Feature Objects
//! Feature objects are objects that store sufficient data to unlock a set of APIs.
//! These objects are mostly used internally to easy re-use application code without
//! requiring the usage of a base contract.  

use abstract_os::version_control::Core;
use cosmwasm_std::{Addr, Deps};

pub use abstract_os::objects::ans_host::AnsHost;

use crate::base::features::{Identification, RegisterAccess};

#[derive(Clone)]
/// Store the Version Control contract.
/// Implements [`RegisterAccess`]
pub struct VersionControlContract {
    pub address: Addr,
}

impl RegisterAccess for VersionControlContract {
    fn registry(&self, _deps: Deps) -> cosmwasm_std::StdResult<Addr> {
        Ok(self.address.clone())
    }
}

#[derive(Clone)]
/// Store a proxy contract address.
/// Implements [`Identification`].
pub struct ProxyContract {
    pub contract_address: Addr,
}

impl Identification for ProxyContract {
    fn proxy_address(&self, _deps: Deps) -> cosmwasm_std::StdResult<Addr> {
        Ok(self.contract_address.clone())
    }
}

impl Identification for Core {
    fn proxy_address(&self, _deps: Deps) -> cosmwasm_std::StdResult<Addr> {
        Ok(self.proxy.clone())
    }

    fn manager_address(&self, _deps: Deps) -> cosmwasm_std::StdResult<Addr> {
        Ok(self.manager.clone())
    }

    fn os_core(&self, _deps: Deps) -> cosmwasm_std::StdResult<Core> {
        Ok(self.clone())
    }
}

impl crate::base::features::AbstractNameService for AnsHost {
    fn ans_host(
        &self,
        _deps: Deps,
    ) -> cosmwasm_std::StdResult<abstract_os::objects::ans_host::AnsHost> {
        Ok(self.clone())
    }
}