Struct abstract_client::AbstractClient
source · 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
sourcepub fn cw20_builder(
&self,
name: impl Into<String>,
symbol: impl Into<String>,
decimals: u8,
) -> Cw20Builder<Chain>
pub fn cw20_builder( &self, name: impl Into<String>, symbol: impl Into<String>, decimals: u8, ) -> Cw20Builder<Chain>
Cw20 contract 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 version_control(&self) -> &VersionControl<Chain>
pub fn version_control(&self) -> &VersionControl<Chain>
Version Control contract API
The Version Control contract is a database contract that stores all module-related information.
use abstract_std::objects::{module_reference::ModuleReference, module::ModuleInfo};
// For getting version control address
use cw_orch::prelude::*;
let version_control = client.version_control();
let vc_module = version_control.module(ModuleInfo::from_id_latest("abstract:version-control")?)?;
assert_eq!(vc_module.reference, ModuleReference::Native(version_control.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 version control 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 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 block_info(&self) -> Result<BlockInfo, AbstractClientError>
pub fn block_info(&self) -> Result<BlockInfo, AbstractClientError>
Return current block info see BlockInfo
.
sourcepub fn publisher_builder(
&self,
namespace: Namespace,
) -> PublisherBuilder<'_, Chain>
pub fn publisher_builder( &self, namespace: Namespace, ) -> PublisherBuilder<'_, Chain>
Publisher builder for creating new Publisher
Abstract Account
To publish any modules your account requires to have claimed a namespace.
sourcepub fn account_builder(&self) -> AccountBuilder<'_, Chain>
pub fn account_builder(&self) -> AccountBuilder<'_, Chain>
Builder for creating a new Abstract Account
.
sourcepub fn account_from<T: Into<AccountSource>>(
&self,
source: T,
) -> Result<Account<Chain>, AbstractClientError>
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 get_last_account(
&self,
) -> Result<Option<Account<Chain>>, AbstractClientError>
pub fn get_last_account( &self, ) -> Result<Option<Account<Chain>>, AbstractClientError>
Returns None
if no account has been created yet.
Note: This only returns accounts that were created with the Client. Any accounts created through the web-app will not be returned.
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
]
source§impl<Chain: MutCwEnv> AbstractClient<Chain>
impl<Chain: MutCwEnv> AbstractClient<Chain>
sourcepub fn set_balance(
&self,
address: impl Into<String>,
amount: &[Coin],
) -> Result<(), AbstractClientError>
pub fn set_balance( &self, address: impl Into<String>, amount: &[Coin], ) -> Result<(), AbstractClientError>
Set balance for an address
sourcepub fn set_balances<'a>(
&self,
balances: impl IntoIterator<Item = (impl Into<String>, &'a [Coin])>,
) -> Result<(), AbstractClientError>
pub fn set_balances<'a>( &self, balances: impl IntoIterator<Item = (impl Into<String>, &'a [Coin])>, ) -> Result<(), AbstractClientError>
Set on chain balance of addresses
sourcepub fn add_balance(
&self,
address: impl Into<String>,
amount: &[Coin],
) -> Result<(), AbstractClientError>
pub fn add_balance( &self, address: impl Into<String>, amount: &[Coin], ) -> Result<(), AbstractClientError>
Add balance for the address
sourcepub fn add_balances<'a>(
&self,
balances: impl IntoIterator<Item = (impl Into<String>, &'a [Coin])>,
) -> Result<(), AbstractClientError>
pub fn add_balances<'a>( &self, balances: impl IntoIterator<Item = (impl Into<String>, &'a [Coin])>, ) -> Result<(), AbstractClientError>
Add balance for the addresses
Trait Implementations§
source§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> 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