ic-websocket-js
Version:
IC WebSocket on the Internet Computer
26 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.callCanisterWsMessage = exports.callCanisterWsOpen = void 0;
const candid_1 = require("@dfinity/candid");
const principal_1 = require("@dfinity/principal");
const idl_1 = require("./idl");
const _callCanisterMethod = async (canisterId, agent, methodName, idlFunc, args) => {
const cid = principal_1.Principal.from(canisterId);
const arg = candid_1.IDL.encode(idlFunc.argTypes, args);
return agent.call(cid, {
methodName,
arg,
effectiveCanisterId: cid,
});
};
/**
* Calls the ws_open method on the canister.
*/
const callCanisterWsOpen = async (canisterId, agent, args) => _callCanisterMethod(canisterId, agent, "ws_open", idl_1.wsOpenIdl, [args]);
exports.callCanisterWsOpen = callCanisterWsOpen;
/**
* Calls the ws_message method on the canister.
*/
const callCanisterWsMessage = async (canisterId, agent, args) => _callCanisterMethod(canisterId, agent, "ws_message", idl_1.wsMessageIdl, [args, []]);
exports.callCanisterWsMessage = callCanisterWsMessage;
//# sourceMappingURL=actor.js.map