WalletCanister

Struct WalletCanister 

Source
pub struct WalletCanister<'agent> { /* private fields */ }
Expand description

A wallet canister interface, for the standard wallet provided by DFINITY. This interface implements most methods conveniently for the user.

Implementations§

Source§

impl<'agent> WalletCanister<'agent>

Source

pub async fn create( agent: &'agent Agent, canister_id: Principal, ) -> Result<WalletCanister<'agent>, AgentError>

Create an instance of a WalletCanister interface pointing to the given Canister ID. Fails if it cannot learn the wallet’s version.

Source

pub async fn from_canister( canister: Canister<'agent>, ) -> Result<WalletCanister<'agent>, AgentError>

Create a WalletCanister interface from an existing canister object. Fails if it cannot learn the wallet’s version.

Source

pub fn from_canister_with_version( canister: Canister<'agent>, version: Version, ) -> Self

Create a WalletCanister interface from an existing canister object and a known wallet version.

This interface’s methods may raise errors if the provided version is newer than the wallet’s actual supported version.

Source§

impl<'agent> WalletCanister<'agent>

Source

pub fn fetch_wallet_api_version( &self, ) -> impl 'agent + SyncCall<Value = (Option<String>,)>

Re-fetch the API version string of the wallet.

Source

pub fn wallet_api_version(&self) -> &Version

Get the (cached) API version of the wallet.

Source

pub fn name(&self) -> impl 'agent + SyncCall<Value = (Option<String>,)>

Get the friendly name of the wallet (if one exists).

Source

pub fn set_name(&self, name: String) -> impl 'agent + AsyncCall<Value = ()>

Set the friendly name of the wallet.

Source

pub fn get_controllers( &self, ) -> impl 'agent + SyncCall<Value = (Vec<Principal>,)>

Get the current controller’s principal ID.

Source

pub fn add_controller( &self, principal: Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Transfer controller to another principal ID.

Source

pub fn remove_controller( &self, principal: Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Remove a user as a wallet controller.

Source

pub fn get_custodians( &self, ) -> impl 'agent + SyncCall<Value = (Vec<Principal>,)>

Get the list of custodians.

Source

pub fn authorize( &self, custodian: Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Authorize a new custodian.

Source

pub fn deauthorize( &self, custodian: Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Deauthorize a custodian.

Source

pub fn wallet_balance64( &self, ) -> impl 'agent + SyncCall<Value = (BalanceResult<u64>,)>

Get the balance with the 64-bit API.

Source

pub fn wallet_balance128( &self, ) -> impl 'agent + SyncCall<Value = (BalanceResult,)>

Get the balance with the 128-bit API.

Source

pub async fn wallet_balance(&self) -> Result<BalanceResult, AgentError>

Get the balance.

Source

pub fn wallet_send64( &self, destination: Principal, amount: u64, ) -> impl 'agent + AsyncCall<Value = (Result<(), String>,)>

Send cycles to another canister using the 64-bit API.

Source

pub fn wallet_send128<'canister: 'agent>( &'canister self, destination: Principal, amount: u128, ) -> impl 'agent + AsyncCall<Value = (Result<(), String>,)>

Send cycles to another canister using the 128-bit API.

Source

pub async fn wallet_send( &self, destination: Principal, amount: u128, ) -> Result<(), AgentError>

Send cycles to another canister.

Source

pub fn wallet_receive( &self, memo: Option<String>, ) -> impl 'agent + AsyncCall<Value = ((),)>

A function for sending cycles to, so that a memo can be passed along with them.

Source

pub fn wallet_create_canister64_v1( &self, cycles: u64, controller: Option<Principal>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> impl 'agent + AsyncCall<Value = (Result<CreateResult, String>,)>

Create a canister through the wallet, using the single-controller 64-bit API.

Source

pub fn wallet_create_canister64_v2( &self, cycles: u64, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> impl 'agent + AsyncCall<Value = (Result<CreateResult, String>,)>

Create a canister through the wallet, using the multi-controller 64-bit API.

Source

pub fn wallet_create_canister128( &self, cycles: u128, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> impl 'agent + AsyncCall<Value = (Result<CreateResult, String>,)>

Create a canister through the wallet, using the 128-bit API.

Source

pub async fn wallet_create_canister( &self, cycles: u128, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> Result<CreateResult, AgentError>

Create a canister through the wallet.

This method does not have a reserved_cycles_limit parameter, as the wallet does not support the setting. If you need to create a canister with a reserved_cycles_limit set, use the management canister.

This method does not have a wasm_memory_limit or log_visibility parameter, as the wallet does not support the setting. If you need to create a canister with a wasm_memory_limit or log_visibility set, use the management canister.

Source

pub fn wallet_create_wallet64_v1( &self, cycles: u64, controller: Option<Principal>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> impl 'agent + AsyncCall<Value = (Result<CreateResult, String>,)>

Create a wallet canister with the single-controller 64-bit API.

Source

pub fn wallet_create_wallet64_v2( &self, cycles: u64, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> impl 'agent + AsyncCall<Value = (Result<CreateResult, String>,)>

Create a wallet canister with the multi-controller 64-bit API.

Source

pub fn wallet_create_wallet128( &self, cycles: u128, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> impl 'agent + AsyncCall<Value = (Result<CreateResult, String>,)>

Create a wallet canister with the 128-bit API.

Source

pub async fn wallet_create_wallet( &self, cycles: u128, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold>, ) -> Result<CreateResult, AgentError>

Create a wallet canister.

Source

pub fn wallet_store_wallet_wasm( &self, wasm_module: Vec<u8>, ) -> impl 'agent + AsyncCall<Value = ()>

Store the wallet WASM inside the wallet canister. This is needed to enable wallet_create_wallet

Source

pub fn add_address( &self, address: AddressEntry, ) -> impl 'agent + AsyncCall<Value = ()>

Add a principal to the address book.

Source

pub fn list_addresses( &self, ) -> impl 'agent + SyncCall<Value = (Vec<AddressEntry>,)>

List the entries in the address book.

Source

pub fn remove_address( &self, principal: Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Remove a principal from the address book.

Source

pub fn get_events64( &self, from: Option<u32>, to: Option<u32>, ) -> impl 'agent + SyncCall<Value = (Vec<Event<u64>>,)>

Get a list of all transaction events this wallet remembers, using the 64-bit API. Fails if any events are 128-bit.

Source

pub fn get_events128( &self, from: Option<u32>, to: Option<u32>, ) -> impl 'agent + SyncCall<Value = (Vec<Event>,)>

Get a list of all transaction events this wallet remembers, using the 128-bit API.

Source

pub async fn get_events( &self, from: Option<u32>, to: Option<u32>, ) -> Result<Vec<Event>, AgentError>

Get a list of all transaction events this wallet remembers.

Source

pub fn call64<'canister, Out, M: Into<String>>( &'canister self, destination: Principal, method_name: M, arg: Argument, amount: u64, ) -> CallForwarder<'agent, 'canister, Out>
where Out: for<'de> ArgumentDecoder<'de> + Send + Sync,

Forward a call to another canister, including an amount of cycles from the wallet, using the 64-bit API.

Source

pub fn call128<'canister, Out, M: Into<String>>( &'canister self, destination: Principal, method_name: M, arg: Argument, amount: u128, ) -> CallForwarder<'agent, 'canister, Out>
where Out: for<'de> ArgumentDecoder<'de> + Send + Sync,

Forward a call to another canister, including an amount of cycles from the wallet, using the 128-bit API.

Source

pub fn call<'canister, Out, M: Into<String>>( &'canister self, destination: Principal, method_name: M, arg: Argument, amount: u128, ) -> CallForwarder<'agent, 'canister, Out>
where Out: for<'de> ArgumentDecoder<'de> + Send + Sync,

Forward a call to another canister, including an amount of cycles from the wallet.

Source

pub fn list_managed_canisters( &self, from: Option<u32>, to: Option<u32>, ) -> impl 'agent + SyncCall<Value = (Vec<ManagedCanisterInfo>, u32)>

Gets the managed canisters the wallet knows about.

Source

pub fn get_managed_canister_events64( &self, canister: Principal, from: Option<u32>, to: Option<u32>, ) -> impl 'agent + SyncCall<Value = (Option<Vec<ManagedCanisterEvent<u64>>>,)>

Gets the ManagedCanisterEvents for a particular canister, if the wallet knows about that canister, using the 64-bit API.

Source

pub fn get_managed_canister_events128( &self, canister: Principal, from: Option<u32>, to: Option<u32>, ) -> impl 'agent + SyncCall<Value = (Option<Vec<ManagedCanisterEvent>>,)>

Gets the ManagedCanisterEvents for a particular canister, if the wallet knows about that canister, using the 128-bit API.

Source

pub async fn get_managed_canister_events( &self, canister: Principal, from: Option<u32>, to: Option<u32>, ) -> Result<Option<Vec<ManagedCanisterEvent>>, AgentError>

Gets the ManagedCanisterEvents for a particular canister, if the wallet knows about that canister

Source

pub fn version_supports_multiple_controllers(&self) -> bool

Gets whether the wallet version supports initializing a canister with multiple controllers (introduced in 0.2.0).

Source

pub fn version_supports_u128_cycles(&self) -> bool

Gets whether the wallet version supports 128-bit cycle counts (introduced in 0.3.0).

Methods from Deref<Target = Canister<'agent>>§

Source

pub fn canister_id_(&self) -> &Principal

Get the canister ID of this canister. Prefer using canister_id instead.

Source

pub fn canister_id(&self) -> &Principal

Get the canister ID of this canister.

Source

pub fn update_<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>

Create an AsyncCallBuilder to do an update call. Prefer using update instead.

Source

pub fn update<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>

Create an AsyncCallBuilder to do an update call.

Source

pub fn query_<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>

Create a SyncCallBuilder to do a query call. Prefer using query instead.

Source

pub fn query<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>

Create a SyncCallBuilder to do a query call.

Source

pub async fn wait<'canister>( &'canister self, request_id: &RequestId, ) -> Result<Vec<u8>, AgentError>

Call request_status on the RequestId in a loop and return the response as a byte vector.

Source

pub fn clone_with_(&self, id: Principal) -> Self

Creates a copy of this canister, changing the canister ID to the provided principal. Prefer using clone_with instead.

Source

pub fn clone_with(&self, id: Principal) -> Self

Creates a copy of this canister, changing the canister ID to the provided principal.

Trait Implementations§

Source§

impl<'agent> Clone for WalletCanister<'agent>

Source§

fn clone(&self) -> WalletCanister<'agent>

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<'agent> Debug for WalletCanister<'agent>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'agent> Deref for WalletCanister<'agent>

Source§

type Target = Canister<'agent>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'agent> Freeze for WalletCanister<'agent>

§

impl<'agent> !RefUnwindSafe for WalletCanister<'agent>

§

impl<'agent> Send for WalletCanister<'agent>

§

impl<'agent> Sync for WalletCanister<'agent>

§

impl<'agent> Unpin for WalletCanister<'agent>

§

impl<'agent> !UnwindSafe for WalletCanister<'agent>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T