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>
impl<'agent> WalletCanister<'agent>
Sourcepub async fn create(
agent: &'agent Agent,
canister_id: Principal,
) -> Result<WalletCanister<'agent>, AgentError>
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.
Sourcepub async fn from_canister(
canister: Canister<'agent>,
) -> Result<WalletCanister<'agent>, AgentError>
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.
Sourcepub fn from_canister_with_version(
canister: Canister<'agent>,
version: Version,
) -> Self
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>
impl<'agent> WalletCanister<'agent>
Sourcepub fn fetch_wallet_api_version(
&self,
) -> impl 'agent + SyncCall<Value = (Option<String>,)>
pub fn fetch_wallet_api_version( &self, ) -> impl 'agent + SyncCall<Value = (Option<String>,)>
Re-fetch the API version string of the wallet.
Sourcepub fn wallet_api_version(&self) -> &Version
pub fn wallet_api_version(&self) -> &Version
Get the (cached) API version of the wallet.
Sourcepub fn name(&self) -> impl 'agent + SyncCall<Value = (Option<String>,)>
pub fn name(&self) -> impl 'agent + SyncCall<Value = (Option<String>,)>
Get the friendly name of the wallet (if one exists).
Sourcepub fn set_name(&self, name: String) -> impl 'agent + AsyncCall<Value = ()>
pub fn set_name(&self, name: String) -> impl 'agent + AsyncCall<Value = ()>
Set the friendly name of the wallet.
Sourcepub fn get_controllers(
&self,
) -> impl 'agent + SyncCall<Value = (Vec<Principal>,)>
pub fn get_controllers( &self, ) -> impl 'agent + SyncCall<Value = (Vec<Principal>,)>
Get the current controller’s principal ID.
Sourcepub fn add_controller(
&self,
principal: Principal,
) -> impl 'agent + AsyncCall<Value = ()>
pub fn add_controller( &self, principal: Principal, ) -> impl 'agent + AsyncCall<Value = ()>
Transfer controller to another principal ID.
Sourcepub fn remove_controller(
&self,
principal: Principal,
) -> impl 'agent + AsyncCall<Value = ()>
pub fn remove_controller( &self, principal: Principal, ) -> impl 'agent + AsyncCall<Value = ()>
Remove a user as a wallet controller.
Sourcepub fn get_custodians(
&self,
) -> impl 'agent + SyncCall<Value = (Vec<Principal>,)>
pub fn get_custodians( &self, ) -> impl 'agent + SyncCall<Value = (Vec<Principal>,)>
Get the list of custodians.
Authorize a new custodian.
Deauthorize a custodian.
Sourcepub fn wallet_balance64(
&self,
) -> impl 'agent + SyncCall<Value = (BalanceResult<u64>,)>
pub fn wallet_balance64( &self, ) -> impl 'agent + SyncCall<Value = (BalanceResult<u64>,)>
Get the balance with the 64-bit API.
Sourcepub fn wallet_balance128(
&self,
) -> impl 'agent + SyncCall<Value = (BalanceResult,)>
pub fn wallet_balance128( &self, ) -> impl 'agent + SyncCall<Value = (BalanceResult,)>
Get the balance with the 128-bit API.
Sourcepub async fn wallet_balance(&self) -> Result<BalanceResult, AgentError>
pub async fn wallet_balance(&self) -> Result<BalanceResult, AgentError>
Get the balance.
Sourcepub fn wallet_send64(
&self,
destination: Principal,
amount: u64,
) -> impl 'agent + AsyncCall<Value = (Result<(), String>,)>
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.
Sourcepub fn wallet_send128<'canister: 'agent>(
&'canister self,
destination: Principal,
amount: u128,
) -> impl 'agent + AsyncCall<Value = (Result<(), String>,)>
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.
Sourcepub async fn wallet_send(
&self,
destination: Principal,
amount: u128,
) -> Result<(), AgentError>
pub async fn wallet_send( &self, destination: Principal, amount: u128, ) -> Result<(), AgentError>
Send cycles to another canister.
Sourcepub fn wallet_receive(
&self,
memo: Option<String>,
) -> impl 'agent + AsyncCall<Value = ((),)>
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.
Sourcepub 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>,)>
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.
Sourcepub 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>,)>
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.
Sourcepub 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>,)>
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.
Sourcepub 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>
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.
Sourcepub 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>,)>
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.
Sourcepub 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>,)>
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.
Sourcepub 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>,)>
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.
Sourcepub 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>
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.
Sourcepub fn wallet_store_wallet_wasm(
&self,
wasm_module: Vec<u8>,
) -> impl 'agent + AsyncCall<Value = ()>
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
Sourcepub fn add_address(
&self,
address: AddressEntry,
) -> impl 'agent + AsyncCall<Value = ()>
pub fn add_address( &self, address: AddressEntry, ) -> impl 'agent + AsyncCall<Value = ()>
Add a principal to the address book.
Sourcepub fn list_addresses(
&self,
) -> impl 'agent + SyncCall<Value = (Vec<AddressEntry>,)>
pub fn list_addresses( &self, ) -> impl 'agent + SyncCall<Value = (Vec<AddressEntry>,)>
List the entries in the address book.
Sourcepub fn remove_address(
&self,
principal: Principal,
) -> impl 'agent + AsyncCall<Value = ()>
pub fn remove_address( &self, principal: Principal, ) -> impl 'agent + AsyncCall<Value = ()>
Remove a principal from the address book.
Sourcepub fn get_events64(
&self,
from: Option<u32>,
to: Option<u32>,
) -> impl 'agent + SyncCall<Value = (Vec<Event<u64>>,)>
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.
Sourcepub fn get_events128(
&self,
from: Option<u32>,
to: Option<u32>,
) -> impl 'agent + SyncCall<Value = (Vec<Event>,)>
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.
Sourcepub async fn get_events(
&self,
from: Option<u32>,
to: Option<u32>,
) -> Result<Vec<Event>, AgentError>
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.
Sourcepub fn call64<'canister, Out, M: Into<String>>(
&'canister self,
destination: Principal,
method_name: M,
arg: Argument,
amount: u64,
) -> CallForwarder<'agent, 'canister, Out>
pub fn call64<'canister, Out, M: Into<String>>( &'canister self, destination: Principal, method_name: M, arg: Argument, amount: u64, ) -> CallForwarder<'agent, 'canister, Out>
Forward a call to another canister, including an amount of cycles from the wallet, using the 64-bit API.
Sourcepub fn call128<'canister, Out, M: Into<String>>(
&'canister self,
destination: Principal,
method_name: M,
arg: Argument,
amount: u128,
) -> CallForwarder<'agent, 'canister, Out>
pub fn call128<'canister, Out, M: Into<String>>( &'canister self, destination: Principal, method_name: M, arg: Argument, amount: u128, ) -> CallForwarder<'agent, 'canister, Out>
Forward a call to another canister, including an amount of cycles from the wallet, using the 128-bit API.
Sourcepub fn call<'canister, Out, M: Into<String>>(
&'canister self,
destination: Principal,
method_name: M,
arg: Argument,
amount: u128,
) -> CallForwarder<'agent, 'canister, Out>
pub fn call<'canister, Out, M: Into<String>>( &'canister self, destination: Principal, method_name: M, arg: Argument, amount: u128, ) -> CallForwarder<'agent, 'canister, Out>
Forward a call to another canister, including an amount of cycles from the wallet.
Sourcepub fn list_managed_canisters(
&self,
from: Option<u32>,
to: Option<u32>,
) -> impl 'agent + SyncCall<Value = (Vec<ManagedCanisterInfo>, u32)>
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.
Sourcepub fn get_managed_canister_events64(
&self,
canister: Principal,
from: Option<u32>,
to: Option<u32>,
) -> impl 'agent + SyncCall<Value = (Option<Vec<ManagedCanisterEvent<u64>>>,)>
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.
Sourcepub fn get_managed_canister_events128(
&self,
canister: Principal,
from: Option<u32>,
to: Option<u32>,
) -> impl 'agent + SyncCall<Value = (Option<Vec<ManagedCanisterEvent>>,)>
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.
Sourcepub async fn get_managed_canister_events(
&self,
canister: Principal,
from: Option<u32>,
to: Option<u32>,
) -> Result<Option<Vec<ManagedCanisterEvent>>, AgentError>
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
Sourcepub fn version_supports_multiple_controllers(&self) -> bool
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).
Sourcepub fn version_supports_u128_cycles(&self) -> bool
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>>§
Sourcepub fn canister_id_(&self) -> &Principal
pub fn canister_id_(&self) -> &Principal
Get the canister ID of this canister.
Prefer using canister_id instead.
Sourcepub fn canister_id(&self) -> &Principal
pub fn canister_id(&self) -> &Principal
Get the canister ID of this canister.
Sourcepub fn update_<'canister>(
&'canister self,
method_name: &str,
) -> AsyncCallBuilder<'agent, 'canister>
pub fn update_<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>
Create an AsyncCallBuilder to do an update call.
Prefer using update instead.
Sourcepub fn update<'canister>(
&'canister self,
method_name: &str,
) -> AsyncCallBuilder<'agent, 'canister>
pub fn update<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>
Create an AsyncCallBuilder to do an update call.
Sourcepub fn query_<'canister>(
&'canister self,
method_name: &str,
) -> SyncCallBuilder<'agent, 'canister>
pub fn query_<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>
Create a SyncCallBuilder to do a query call.
Prefer using query instead.
Sourcepub fn query<'canister>(
&'canister self,
method_name: &str,
) -> SyncCallBuilder<'agent, 'canister>
pub fn query<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>
Create a SyncCallBuilder to do a query call.
Sourcepub async fn wait<'canister>(
&'canister self,
request_id: &RequestId,
) -> Result<Vec<u8>, AgentError>
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.
Sourcepub fn clone_with_(&self, id: Principal) -> Self
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.
Sourcepub fn clone_with(&self, id: Principal) -> Self
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>
impl<'agent> Clone for WalletCanister<'agent>
Source§fn clone(&self) -> WalletCanister<'agent>
fn clone(&self) -> WalletCanister<'agent>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more