abstract_extension/
features.rs

1use abstract_sdk::{
2    base::features::{AbstractNameService, Identification, RegisterAccess},
3    feature_objects::AnsHost,
4};
5use cosmwasm_std::{Addr, Deps, StdError, StdResult};
6
7use crate::{ExtensionContract, ExtensionError};
8
9impl<
10        Error: From<cosmwasm_std::StdError> + From<ExtensionError>,
11        CustomExecMsg,
12        CustomInitMsg,
13        CustomQueryMsg,
14        ReceiveMsg,
15    > AbstractNameService
16    for ExtensionContract<Error, CustomExecMsg, CustomInitMsg, CustomQueryMsg, ReceiveMsg>
17{
18    fn ans_host(&self, deps: Deps) -> StdResult<AnsHost> {
19        Ok(self.base_state.load(deps.storage)?.ans_host)
20    }
21}
22
23/// Retrieve identifying information about the calling OS
24impl<
25        Error: From<cosmwasm_std::StdError> + From<ExtensionError>,
26        CustomExecMsg,
27        CustomInitMsg,
28        CustomQueryMsg,
29        ReceiveMsg,
30    > Identification
31    for ExtensionContract<Error, CustomExecMsg, CustomInitMsg, CustomQueryMsg, ReceiveMsg>
32{
33    fn proxy_address(&self, _deps: Deps) -> StdResult<Addr> {
34        if let Some(target) = &self.target_os {
35            Ok(target.proxy.clone())
36        } else {
37            Err(StdError::generic_err(
38                "No target OS specified to execute on.",
39            ))
40        }
41    }
42
43    fn manager_address(&self, _deps: Deps) -> StdResult<Addr> {
44        if let Some(target) = &self.target_os {
45            Ok(target.manager.clone())
46        } else {
47            Err(StdError::generic_err("No OS manager specified."))
48        }
49    }
50
51    fn os_core(&self, _deps: Deps) -> StdResult<abstract_sdk::os::version_control::Core> {
52        if let Some(target) = &self.target_os {
53            Ok(target.clone())
54        } else {
55            Err(StdError::generic_err("No OS core specified."))
56        }
57    }
58}
59
60/// Get the version control contract
61impl<
62        Error: From<cosmwasm_std::StdError> + From<ExtensionError>,
63        CustomExecMsg,
64        CustomInitMsg,
65        CustomQueryMsg,
66        ReceiveMsg,
67    > RegisterAccess
68    for ExtensionContract<Error, CustomExecMsg, CustomInitMsg, CustomQueryMsg, ReceiveMsg>
69{
70    fn registry(&self, deps: Deps) -> StdResult<Addr> {
71        Ok(self.state(deps.storage)?.version_control)
72    }
73}