Actor
Defined in: pocket-ic-actor.ts:32
A typesafe class that implements the Candid interface of a canister. This is acquired by calling setupCanister or createActor.
T The type of the Actor. Must implement ActorInterface.
Type Parameters
Section titled “Type Parameters”T
extends ActorInterface
<T
> = ActorInterface
Methods
Section titled “Methods”setIdentity()
Section titled “setIdentity()”setIdentity(
identity
):void
Defined in: pocket-ic-actor.ts:87
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
Section titled “Parameters”identity
Section titled “identity”Identity
The identity to set.
Returns
Section titled “Returns”void
Example
Section titled “Example”import { PocketIc } from '@dfinity/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());
setPrincipal()
Section titled “setPrincipal()”setPrincipal(
principal
):void
Defined in: pocket-ic-actor.ts:60
Set a Principal to be used as sender for all calls to the canister.
Parameters
Section titled “Parameters”principal
Section titled “principal”Principal
The Principal to set.
Returns
Section titled “Returns”void
Example
Section titled “Example”import { PocketIc } from '@dfinity/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());