Struct ic_utils::interfaces::wallet::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>
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<'canister: 'agent>(
&'canister self
) -> impl 'agent + SyncCall<(Option<String>,)>
pub fn fetch_wallet_api_version<'canister: 'agent>( &'canister self ) -> impl 'agent + SyncCall<(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<'canister: 'agent>(
&'canister self
) -> impl 'agent + SyncCall<(Option<String>,)>
pub fn name<'canister: 'agent>( &'canister self ) -> impl 'agent + SyncCall<(Option<String>,)>
Get the friendly name of the wallet (if one exists).
sourcepub fn set_name<'canister: 'agent>(
&'canister self,
name: String
) -> impl 'agent + AsyncCall<()>
pub fn set_name<'canister: 'agent>( &'canister self, name: String ) -> impl 'agent + AsyncCall<()>
Set the friendly name of the wallet.
sourcepub fn get_controllers<'canister: 'agent>(
&'canister self
) -> impl 'agent + SyncCall<(Vec<Principal>,)>
pub fn get_controllers<'canister: 'agent>( &'canister self ) -> impl 'agent + SyncCall<(Vec<Principal>,)>
Get the current controller’s principal ID.
sourcepub fn add_controller<'canister: 'agent>(
&'canister self,
principal: Principal
) -> impl 'agent + AsyncCall<()>
pub fn add_controller<'canister: 'agent>( &'canister self, principal: Principal ) -> impl 'agent + AsyncCall<()>
Transfer controller to another principal ID.
sourcepub fn remove_controller<'canister: 'agent>(
&'canister self,
principal: Principal
) -> impl 'agent + AsyncCall<()>
pub fn remove_controller<'canister: 'agent>( &'canister self, principal: Principal ) -> impl 'agent + AsyncCall<()>
Remove a user as a wallet controller.
sourcepub fn get_custodians<'canister: 'agent>(
&'canister self
) -> impl 'agent + SyncCall<(Vec<Principal>,)>
pub fn get_custodians<'canister: 'agent>( &'canister self ) -> impl 'agent + SyncCall<(Vec<Principal>,)>
Get the list of custodians.
Authorize a new custodian.
Deauthorize a custodian.
sourcepub fn wallet_balance64<'canister: 'agent>(
&'canister self
) -> impl 'agent + SyncCall<(BalanceResult<u64>,)>
pub fn wallet_balance64<'canister: 'agent>( &'canister self ) -> impl 'agent + SyncCall<(BalanceResult<u64>,)>
Get the balance with the 64-bit API.
sourcepub fn wallet_balance128<'canister: 'agent>(
&'canister self
) -> impl 'agent + SyncCall<(BalanceResult,)>
pub fn wallet_balance128<'canister: 'agent>( &'canister self ) -> impl 'agent + SyncCall<(BalanceResult,)>
Get the balance with the 128-bit API.
sourcepub async fn wallet_balance<'canister: 'agent>(
&'canister self
) -> Result<BalanceResult, AgentError>
pub async fn wallet_balance<'canister: 'agent>( &'canister self ) -> Result<BalanceResult, AgentError>
Get the balance.
sourcepub fn wallet_send64<'canister: 'agent>(
&'canister self,
destination: Principal,
amount: u64
) -> impl 'agent + AsyncCall<(Result<(), String>,)>
pub fn wallet_send64<'canister: 'agent>( &'canister self, destination: Principal, amount: u64 ) -> impl 'agent + AsyncCall<(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<(Result<(), String>,)>
pub fn wallet_send128<'canister: 'agent>( &'canister self, destination: Principal, amount: u128 ) -> impl 'agent + AsyncCall<(Result<(), String>,)>
Send cycles to another canister using the 128-bit API.
sourcepub async fn wallet_send<'canister: 'agent>(
&'canister self,
destination: Principal,
amount: u128
) -> Result<(), AgentError>
pub async fn wallet_send<'canister: 'agent>( &'canister self, destination: Principal, amount: u128 ) -> Result<(), AgentError>
Send cycles to another canister.
sourcepub fn wallet_receive<'canister: 'agent>(
&'canister self,
memo: Option<String>
) -> impl 'agent + AsyncCall<((),)>
pub fn wallet_receive<'canister: 'agent>( &'canister self, memo: Option<String> ) -> impl 'agent + AsyncCall<((),)>
A function for sending cycles to, so that a memo can be passed along with them.
sourcepub fn wallet_create_canister64_v1<'canister: 'agent>(
&'canister self,
cycles: u64,
controller: Option<Principal>,
compute_allocation: Option<ComputeAllocation>,
memory_allocation: Option<MemoryAllocation>,
freezing_threshold: Option<FreezingThreshold>
) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
pub fn wallet_create_canister64_v1<'canister: 'agent>( &'canister self, cycles: u64, controller: Option<Principal>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold> ) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
Create a canister through the wallet, using the single-controller 64-bit API.
sourcepub fn wallet_create_canister64_v2<'canister: 'agent>(
&'canister self,
cycles: u64,
controllers: Option<Vec<Principal>>,
compute_allocation: Option<ComputeAllocation>,
memory_allocation: Option<MemoryAllocation>,
freezing_threshold: Option<FreezingThreshold>
) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
pub fn wallet_create_canister64_v2<'canister: 'agent>( &'canister self, cycles: u64, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold> ) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
Create a canister through the wallet, using the multi-controller 64-bit API.
sourcepub fn wallet_create_canister128<'canister: 'agent>(
&'canister self,
cycles: u128,
controllers: Option<Vec<Principal>>,
compute_allocation: Option<ComputeAllocation>,
memory_allocation: Option<MemoryAllocation>,
freezing_threshold: Option<FreezingThreshold>
) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
pub fn wallet_create_canister128<'canister: 'agent>( &'canister self, cycles: u128, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold> ) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
Create a canister through the wallet, using the 128-bit API.
sourcepub async fn wallet_create_canister<'canister: 'agent>(
&'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<'canister: 'agent>( &'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.
sourcepub fn wallet_create_wallet64_v1<'canister: 'agent>(
&'canister self,
cycles: u64,
controller: Option<Principal>,
compute_allocation: Option<ComputeAllocation>,
memory_allocation: Option<MemoryAllocation>,
freezing_threshold: Option<FreezingThreshold>
) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
pub fn wallet_create_wallet64_v1<'canister: 'agent>( &'canister self, cycles: u64, controller: Option<Principal>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold> ) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
Create a wallet canister with the single-controller 64-bit API.
sourcepub fn wallet_create_wallet64_v2<'canister: 'agent>(
&'canister self,
cycles: u64,
controllers: Option<Vec<Principal>>,
compute_allocation: Option<ComputeAllocation>,
memory_allocation: Option<MemoryAllocation>,
freezing_threshold: Option<FreezingThreshold>
) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
pub fn wallet_create_wallet64_v2<'canister: 'agent>( &'canister self, cycles: u64, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold> ) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
Create a wallet canister with the multi-controller 64-bit API.
sourcepub fn wallet_create_wallet128<'canister: 'agent>(
&'canister self,
cycles: u128,
controllers: Option<Vec<Principal>>,
compute_allocation: Option<ComputeAllocation>,
memory_allocation: Option<MemoryAllocation>,
freezing_threshold: Option<FreezingThreshold>
) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
pub fn wallet_create_wallet128<'canister: 'agent>( &'canister self, cycles: u128, controllers: Option<Vec<Principal>>, compute_allocation: Option<ComputeAllocation>, memory_allocation: Option<MemoryAllocation>, freezing_threshold: Option<FreezingThreshold> ) -> impl 'agent + AsyncCall<(Result<CreateResult, String>,)>
Create a wallet canister with the 128-bit API.
sourcepub async fn wallet_create_wallet<'canister: 'agent>(
&'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_wallet<'canister: 'agent>( &'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 wallet canister.
sourcepub fn wallet_store_wallet_wasm<'canister: 'agent>(
&'canister self,
wasm_module: Vec<u8>
) -> impl 'agent + AsyncCall<()>
pub fn wallet_store_wallet_wasm<'canister: 'agent>( &'canister self, wasm_module: Vec<u8> ) -> impl 'agent + AsyncCall<()>
Store the wallet WASM inside the wallet canister. This is needed to enable wallet_create_wallet
sourcepub fn add_address<'canister: 'agent>(
&'canister self,
address: AddressEntry
) -> impl 'agent + AsyncCall<()>
pub fn add_address<'canister: 'agent>( &'canister self, address: AddressEntry ) -> impl 'agent + AsyncCall<()>
Add a principal to the address book.
sourcepub fn list_addresses<'canister: 'agent>(
&'canister self
) -> impl 'agent + SyncCall<(Vec<AddressEntry>,)>
pub fn list_addresses<'canister: 'agent>( &'canister self ) -> impl 'agent + SyncCall<(Vec<AddressEntry>,)>
List the entries in the address book.
sourcepub fn remove_address<'canister: 'agent>(
&'canister self,
principal: Principal
) -> impl 'agent + AsyncCall<()>
pub fn remove_address<'canister: 'agent>( &'canister self, principal: Principal ) -> impl 'agent + AsyncCall<()>
Remove a principal from the address book.
sourcepub fn get_events64<'canister: 'agent>(
&'canister self,
from: Option<u32>,
to: Option<u32>
) -> impl 'agent + SyncCall<(Vec<Event<u64>>,)>
pub fn get_events64<'canister: 'agent>( &'canister self, from: Option<u32>, to: Option<u32> ) -> impl 'agent + SyncCall<(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<'canister: 'agent>(
&'canister self,
from: Option<u32>,
to: Option<u32>
) -> impl 'agent + SyncCall<(Vec<Event>,)>
pub fn get_events128<'canister: 'agent>( &'canister self, from: Option<u32>, to: Option<u32> ) -> impl 'agent + SyncCall<(Vec<Event>,)>
Get a list of all transaction events this wallet remembers, using the 128-bit API.
sourcepub async fn get_events<'canister: 'agent>(
&'canister self,
from: Option<u32>,
to: Option<u32>
) -> Result<Vec<Event>, AgentError>
pub async fn get_events<'canister: 'agent>( &'canister 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: 'agent, 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,
pub fn call64<'canister: 'agent, 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.
sourcepub fn call128<'canister: 'agent, 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,
pub fn call128<'canister: 'agent, 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.
sourcepub fn call<'canister: 'agent, 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,
pub fn call<'canister: 'agent, 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.
sourcepub fn list_managed_canisters<'canister: 'agent>(
&'canister self,
from: Option<u32>,
to: Option<u32>
) -> impl 'agent + SyncCall<(Vec<ManagedCanisterInfo>, u32)>
pub fn list_managed_canisters<'canister: 'agent>( &'canister self, from: Option<u32>, to: Option<u32> ) -> impl 'agent + SyncCall<(Vec<ManagedCanisterInfo>, u32)>
Gets the managed canisters the wallet knows about.
sourcepub fn get_managed_canister_events64<'canister: 'agent>(
&'canister self,
canister: Principal,
from: Option<u32>,
to: Option<u32>
) -> impl 'agent + SyncCall<(Option<Vec<ManagedCanisterEvent<u64>>>,)>
pub fn get_managed_canister_events64<'canister: 'agent>( &'canister self, canister: Principal, from: Option<u32>, to: Option<u32> ) -> impl 'agent + SyncCall<(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<'canister: 'agent>(
&'canister self,
canister: Principal,
from: Option<u32>,
to: Option<u32>
) -> impl 'agent + SyncCall<(Option<Vec<ManagedCanisterEvent>>,)>
pub fn get_managed_canister_events128<'canister: 'agent>( &'canister self, canister: Principal, from: Option<u32>, to: Option<u32> ) -> impl 'agent + SyncCall<(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<'canister: 'agent>(
&'canister self,
canister: Principal,
from: Option<u32>,
to: Option<u32>
) -> Result<Option<Vec<ManagedCanisterEvent>>, AgentError>
pub async fn get_managed_canister_events<'canister: 'agent>( &'canister 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_<'canister: 'agent>(&'canister self) -> &Principal
pub fn canister_id_<'canister: 'agent>(&'canister self) -> &Principal
Get the canister ID of this canister.
sourcepub fn update_<'canister: 'agent>(
&'canister self,
method_name: &str
) -> AsyncCallBuilder<'agent, 'canister>
pub fn update_<'canister: 'agent>( &'canister self, method_name: &str ) -> AsyncCallBuilder<'agent, 'canister>
Create an AsyncCallBuilder to do an update call.
sourcepub fn query_<'canister: 'agent>(
&'canister self,
method_name: &str
) -> SyncCallBuilder<'agent, 'canister>
pub fn query_<'canister: 'agent>( &'canister self, method_name: &str ) -> SyncCallBuilder<'agent, 'canister>
Create a SyncCallBuilder to do a query call.
sourcepub async fn wait<'canister: 'agent>(
&'canister self,
request_id: RequestId
) -> Result<Vec<u8>, AgentError>
pub async fn wait<'canister: 'agent>( &'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.
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