abstract_client/
infrastructure.rs1use abstract_interface::{Abstract, AbstractInterfaceError};
11use cw_orch::prelude::*;
12
13use crate::{account::Account, AbstractClient};
14
15use cw_orch::environment::Environment as _;
16
17pub trait Environment<Chain: CwEnv> {
19 fn environment(&self) -> Chain;
21}
22
23pub(crate) trait Infrastructure<Chain: CwEnv>: Environment<Chain> {
24 fn infrastructure(&self) -> Result<Abstract<Chain>, AbstractInterfaceError> {
26 let chain = self.environment();
27 Abstract::load_from(chain)
28 }
29}
30
31impl<Chain: CwEnv, T> Infrastructure<Chain> for T where T: Environment<Chain> {}
32
33impl<Chain: CwEnv> Environment<Chain> for Account<Chain> {
34 fn environment(&self) -> Chain {
35 self.abstr_account.environment().clone()
36 }
37}
38
39impl<Chain: CwEnv> Environment<Chain> for AbstractClient<Chain> {
40 fn environment(&self) -> Chain {
41 self.abstr.registry.environment().clone()
42 }
43}