Skip to content

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.

T extends ActorInterface<T> = ActorInterface

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.

Identity

The identity to set.

void

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(principal): void

Defined in: pocket-ic-actor.ts:60

Set a Principal to be used as sender for all calls to the canister.

Principal

The Principal to set.

void

Principal

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());