Interface: Actor<T>
A typesafe class that implements the Candid interface of a canister. This is acquired by calling setupCanister or createActor.
Typeparam
T The type of the Actor. Must implement ActorInterface.
Type parameters
• T = ActorInterface
Methods
setPrincipal()
setPrincipal(
principal
):void
Set a Principal to be used as sender for all calls to the canister.
Parameters
• principal: Principal
The Principal to set.
Returns
void
See
Example
import { PocketIc } from '@hadronous/pic';
import { Principal } from '@dfinity/principal';
import { _SERVICE, idlFactory } from '../declarations';
const wasmPath = resolve('..', '..', 'canister.wasm');
const pic = await PocketIc.create();
const fixture = await pic.setupCanister<_SERVICE>(idlFactory, wasmPath);
const { actor } = fixture;
actor.setPrincipal(Principal.anonymous());
Source
setIdentity()
setIdentity(
identity
):void
Set a Principal to be used as sender for all calls to the canister. This is a convenience method over setPrincipal that accepts an Identity and internally extracts the Principal.
Parameters
• identity: Identity
The identity to set.
Returns
void
See
Example
import { PocketIc } from '@hadronous/pic';
import { AnonymousIdentity } from '@dfinity/agent';
import { _SERVICE, idlFactory } from '../declarations';
const wasmPath = resolve('..', '..', 'canister.wasm');
const pic = await PocketIc.create();
const fixture = await pic.setupCanister<_SERVICE>(idlFactory, wasmPath);
const { actor } = fixture;
actor.setIdentity(new AnonymousIdentity());