UNPKG

ic-websocket-js

Version:
21 lines 858 B
import { IDL } from "@dfinity/candid"; import { Principal } from "@dfinity/principal"; import { wsMessageIdl, wsOpenIdl } from "./idl"; const _callCanisterMethod = async (canisterId, agent, methodName, idlFunc, args) => { const cid = Principal.from(canisterId); const arg = IDL.encode(idlFunc.argTypes, args); return agent.call(cid, { methodName, arg, effectiveCanisterId: cid, }); }; /** * Calls the ws_open method on the canister. */ export const callCanisterWsOpen = async (canisterId, agent, args) => _callCanisterMethod(canisterId, agent, "ws_open", wsOpenIdl, [args]); /** * Calls the ws_message method on the canister. */ export const callCanisterWsMessage = async (canisterId, agent, args) => _callCanisterMethod(canisterId, agent, "ws_message", wsMessageIdl, [args, []]); //# sourceMappingURL=actor.js.map