pub struct AbstractClient<Chain: CwEnv> { /* private fields */ }
Expand description
Client to interact with Abstract accounts and modules
Implementations§
Source§impl<Chain: CwEnv> AbstractClient<Chain>
impl<Chain: CwEnv> AbstractClient<Chain>
Sourcepub fn builder(chain: Chain) -> AbstractClientBuilder<Chain>
pub fn builder(chain: Chain) -> AbstractClientBuilder<Chain>
Abstract client builder
Source§impl<Chain: CwEnv> AbstractClient<Chain>
impl<Chain: CwEnv> AbstractClient<Chain>
Sourcepub fn new(chain: Chain) -> Result<Self, AbstractClientError>
pub fn new(chain: Chain) -> Result<Self, AbstractClientError>
Get AbstractClient
from a chosen environment. Abstract
should
already be deployed to this environment.
use abstract_client::AbstractClient;
let client = AbstractClient::new(chain)?;
Sourcepub fn registry(&self) -> &Registry<Chain>
pub fn registry(&self) -> &Registry<Chain>
Registry contract API
The Registry contract is a database contract that stores all module-related information.
use abstract_std::objects::{module_reference::ModuleReference, module::ModuleInfo};
// For getting registry address
use cw_orch::prelude::*;
let registry = client.registry();
let vc_module = registry.module(ModuleInfo::from_id_latest("abstract:registry")?)?;
assert_eq!(vc_module.reference, ModuleReference::Native(registry.address()?));
Sourcepub fn name_service(&self) -> &AnsHost<Chain>
pub fn name_service(&self) -> &AnsHost<Chain>
Abstract Name Service contract API
The Abstract Name Service contract is a database contract that stores all asset-related information.
use abstract_client::{AbstractClient, ClientResolve};
use cw_asset::AssetInfo;
use abstract_app::objects::AssetEntry;
// For getting registry address
use cw_orch::prelude::*;
let denom = "test_denom";
let entry = "denom";
let name_service = client.name_service();
let asset_entry = AssetEntry::new(entry);
let asset = asset_entry.resolve(name_service)?;
assert_eq!(asset, AssetInfo::Native(denom.to_owned()));
Sourcepub fn module_factory(&self) -> &ModuleFactory<Chain>
pub fn module_factory(&self) -> &ModuleFactory<Chain>
Abstract Module Factory contract API
Sourcepub fn ibc_client(&self) -> &IbcClient<Chain>
pub fn ibc_client(&self) -> &IbcClient<Chain>
Abstract Ibc Client contract API
The Abstract Ibc Client contract allows users to create and use Interchain Abstract Accounts
Sourcepub fn service<M: RegisteredModule + From<Contract<Chain>>>(
&self,
) -> Result<Service<Chain, M>, AbstractClientError>
pub fn service<M: RegisteredModule + From<Contract<Chain>>>( &self, ) -> Result<Service<Chain, M>, AbstractClientError>
Service contract API
Sourcepub fn block_info(&self) -> Result<BlockInfo, AbstractClientError>
pub fn block_info(&self) -> Result<BlockInfo, AbstractClientError>
Return current block info see BlockInfo
.
Sourcepub fn fetch_publisher(
&self,
namespace: Namespace,
) -> Result<Publisher<Chain>, AbstractClientError>
pub fn fetch_publisher( &self, namespace: Namespace, ) -> Result<Publisher<Chain>, AbstractClientError>
Fetches an existing Abstract Publisher
from chain
Sourcepub fn account_builder(&self) -> AccountBuilder<'_, Chain>
pub fn account_builder(&self) -> AccountBuilder<'_, Chain>
Builder for creating a new Abstract Account
.
Sourcepub fn sub_account_builder<'a>(
&'a self,
account: &'a Account<Chain>,
) -> Result<AccountBuilder<'a, Chain>, AbstractClientError>
pub fn sub_account_builder<'a>( &'a self, account: &'a Account<Chain>, ) -> Result<AccountBuilder<'a, Chain>, AbstractClientError>
Builder for creating a new Abstract Account
.
Sourcepub fn fetch_account<T: Into<AccountSource>>(
&self,
source: T,
) -> Result<Account<Chain>, AbstractClientError>
pub fn fetch_account<T: Into<AccountSource>>( &self, source: T, ) -> Result<Account<Chain>, AbstractClientError>
Fetch an Account
from a given source.
This method is used to retrieve an account from a given source. It will not create a new account if the source is invalid.
Sources that can be used are:
Sourcepub fn fetch_or_build_account<T: Into<AccountSource>, F>(
&self,
source: T,
build_fn: F,
) -> Result<Account<Chain>, AbstractClientError>where
F: for<'a, 'b> FnOnce(&'a mut AccountBuilder<'b, Chain>) -> &'a mut AccountBuilder<'b, Chain>,
pub fn fetch_or_build_account<T: Into<AccountSource>, F>(
&self,
source: T,
build_fn: F,
) -> Result<Account<Chain>, AbstractClientError>where
F: for<'a, 'b> FnOnce(&'a mut AccountBuilder<'b, Chain>) -> &'a mut AccountBuilder<'b, Chain>,
Fetches an existing Abstract Account
from chain
If the Namespace is not claimed, creates an account with the provided account builder
Sourcepub fn account_from<T: Into<AccountSource>>(
&self,
source: T,
) -> Result<Account<Chain>, AbstractClientError>
👎Deprecated since 0.24.2: use fetch_account instead
pub fn account_from<T: Into<AccountSource>>( &self, source: T, ) -> Result<Account<Chain>, AbstractClientError>
Fetch an Account
from a given source.
This method is used to retrieve an account from a given source. It will not create a new account if the source is invalid.
Sources that can be used are:
Sourcepub fn query_balance(
&self,
address: &Addr,
denom: impl Into<String>,
) -> Result<Uint128, AbstractClientError>
pub fn query_balance( &self, address: &Addr, denom: impl Into<String>, ) -> Result<Uint128, AbstractClientError>
Retrieve denom balance for provided address
Sourcepub fn query_balances(
&self,
address: &Addr,
) -> Result<Vec<Coin>, AbstractClientError>
pub fn query_balances( &self, address: &Addr, ) -> Result<Vec<Coin>, AbstractClientError>
Retrieve balances of all denoms for provided address
Sourcepub fn wait_blocks(&self, amount: u64) -> Result<(), AbstractClientError>
pub fn wait_blocks(&self, amount: u64) -> Result<(), AbstractClientError>
Waits for a specified number of blocks.
Sourcepub fn wait_seconds(&self, secs: u64) -> Result<(), AbstractClientError>
pub fn wait_seconds(&self, secs: u64) -> Result<(), AbstractClientError>
Waits for a specified number of blocks.
Sourcepub fn next_block(&self) -> Result<(), AbstractClientError>
pub fn next_block(&self) -> Result<(), AbstractClientError>
Waits for next block.
Sourcepub fn random_account_id(&self) -> Result<u32, AbstractClientError>
pub fn random_account_id(&self) -> Result<u32, AbstractClientError>
Get random local account id sequence(unclaimed) in 2147483648..u32::MAX range
Sourcepub fn module_instantiate2_address<M: RegisteredModule>(
&self,
account_id: &AccountId,
) -> Result<Addr, AbstractClientError>
pub fn module_instantiate2_address<M: RegisteredModule>( &self, account_id: &AccountId, ) -> Result<Addr, AbstractClientError>
Get address of instantiate2 module
If used for upcoming account this supposed to be used in pair with [AbstractClient::next_local_account_id
]
Sourcepub fn module_instantiate2_address_raw(
&self,
account_id: &AccountId,
module_info: ModuleInfo,
) -> Result<Addr, AbstractClientError>
pub fn module_instantiate2_address_raw( &self, account_id: &AccountId, module_info: ModuleInfo, ) -> Result<Addr, AbstractClientError>
Get address of instantiate2 module
Raw version of AbstractClient::module_instantiate2_address
If used for upcoming account this supposed to be used in pair with [AbstractClient::next_local_account_id
]
Sourcepub fn module_status(
&self,
module: ModuleInfo,
) -> Result<Option<ModuleStatus>, AbstractClientError>
pub fn module_status( &self, module: ModuleInfo, ) -> Result<Option<ModuleStatus>, AbstractClientError>
Retrieves the status of a specified module.
This function checks the status of a module within the registry contract.
and returns appropriate Some(ModuleStatus)
. If the module is not deployed, it returns None
.
Trait Implementations§
Source§impl<Chain: Clone + CwEnv> Clone for AbstractClient<Chain>
impl<Chain: Clone + CwEnv> Clone for AbstractClient<Chain>
Source§fn clone(&self) -> AbstractClient<Chain>
fn clone(&self) -> AbstractClient<Chain>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<Chain: CwEnv> Environment<Chain> for AbstractClient<Chain>
impl<Chain: CwEnv> Environment<Chain> for AbstractClient<Chain>
Source§fn environment(&self) -> Chain
fn environment(&self) -> Chain
Auto Trait Implementations§
impl<Chain> Freeze for AbstractClient<Chain>where
Chain: Freeze,
impl<Chain> RefUnwindSafe for AbstractClient<Chain>where
Chain: RefUnwindSafe,
impl<Chain> Send for AbstractClient<Chain>where
Chain: Send,
impl<Chain> Sync for AbstractClient<Chain>where
Chain: Sync,
impl<Chain> Unpin for AbstractClient<Chain>where
Chain: Unpin,
impl<Chain> UnwindSafe for AbstractClient<Chain>where
Chain: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more