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>

source

pub fn builder(chain: Chain) -> AbstractClientBuilder<Chain>

Abstract client builder

source

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>

source

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)?;
source

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()?));
source

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()));
source

pub fn block_info(&self) -> Result<BlockInfo, AbstractClientError>

Return current block info see BlockInfo.

source

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.

source

pub fn account_builder(&self) -> AccountBuilder<'_, Chain>

Builder for creating a new Abstract Account.

source

pub fn sender(&self) -> Addr

Address of the sender

source

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:

  • Namespace: Will retrieve the account from the namespace if it is already claimed.
  • AccountId: Will retrieve the account from the account id.
  • App Addr: Will retrieve the account from an app that is installed on it.
source

pub fn query_balance( &self, address: &Addr, denom: impl Into<String> ) -> Result<Uint128, AbstractClientError>

Retrieve denom balance for provided address

source

pub fn query_balances( &self, address: &Addr ) -> Result<Vec<Coin>, AbstractClientError>

Retrieve balances of all denoms for provided address

source

pub fn wait_blocks(&self, amount: u64) -> Result<(), AbstractClientError>

Waits for a specified number of blocks.

source

pub fn wait_seconds(&self, secs: u64) -> Result<(), AbstractClientError>

Waits for a specified number of blocks.

source

pub fn next_block(&self) -> Result<(), AbstractClientError>

Waits for next block.

source

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.

source

pub fn next_local_account_id(&self) -> Result<u32, AbstractClientError>

Get next local account id sequence

source

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

source

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>

source

pub fn set_balance( &self, address: impl Into<String>, amount: &[Coin] ) -> Result<(), AbstractClientError>

Set balance for an address

source

pub fn set_balances<'a>( &self, balances: impl IntoIterator<Item = (impl Into<String>, &'a [Coin])> ) -> Result<(), AbstractClientError>

Set on chain balance of addresses

source

pub fn add_balance( &self, address: impl Into<String>, amount: &[Coin] ) -> Result<(), AbstractClientError>

Add balance for the address

source

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>

source§

fn environment(&self) -> Chain

Get the execution environment

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<U> As for U

source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.