UNPKG

@ic-wallet-kit/hpl

Version:
43 lines (42 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OwnersActorWrapper = void 0; const agent_1 = require("@dfinity/agent"); const owners_did_1 = require("../../candid/owners/owners.did"); const ownerActor_error_1 = require("../../errors/ownerActor.error"); class OwnersActorWrapper { actor; constructor(actor) { this.actor = actor; } static create(agent, canisterId) { const actor = OwnersActorWrapper.getOwnerActor(agent, canisterId); return new OwnersActorWrapper(actor); } async lookup(principal) { try { const ownerId = await this.actor.lookup(principal); return ownerId; } catch (e) { throw new ownerActor_error_1.OwnerActorError("lookup", e.message); } } async get(ownerId) { try { const principal = await this.actor.get(ownerId); return principal; } catch (e) { throw new ownerActor_error_1.OwnerActorError("get", e.message); } } static getOwnerActor(agent, canisterId) { const ownersActor = agent_1.Actor.createActor(owners_did_1.idlFactory, { agent: agent, canisterId: canisterId, }); return ownersActor; } } exports.OwnersActorWrapper = OwnersActorWrapper;