Struct 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§

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

pub fn module_factory(&self) -> &ModuleFactory<Chain>

Abstract Module Factory contract API

Source

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

Source

pub fn service<M: RegisteredModule + From<Contract<Chain>>>( &self, ) -> Result<Service<Chain, M>, AbstractClientError>

Service contract API

Source

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

Return current block info see BlockInfo.

Source

pub fn fetch_publisher( &self, namespace: Namespace, ) -> Result<Publisher<Chain>, AbstractClientError>

Fetches an existing Abstract Publisher from chain

Source

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

Builder for creating a new Abstract Account.

Source

pub fn sub_account_builder<'a>( &'a self, account: &'a Account<Chain>, ) -> Result<AccountBuilder<'a, Chain>, AbstractClientError>

Builder for creating a new Abstract Account.

Source

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:

  • 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 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

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>

👎Deprecated since 0.24.2: use fetch_account instead

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 random_account_id(&self) -> Result<u32, AbstractClientError>

Get random local account id sequence(unclaimed) in 2147483648..u32::MAX range

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

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.

Source

pub fn call_as(&self, sender: &<Chain as TxHandler>::Sender) -> Self

Clones the Abstract Client with a different sender.

Trait Implementations§

Source§

impl<Chain: Clone + CwEnv> Clone for AbstractClient<Chain>

Source§

fn clone(&self) -> AbstractClient<Chain>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V