UNPKG

@slide-computer/signer-agent

Version:

Initiate transactions with signers on the Internet Computer

51 lines 3.12 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var _a, _StoicTransport_isInternalConstructing, _StoicTransport_connection, _StoicTransport_agent; import {} from "@slide-computer/signer"; import { StoicChannel } from "./stoicChannel"; import { StoicConnection, } from "./stoicConnection"; export class StoicTransportError extends Error { constructor(message) { super(message); Object.setPrototypeOf(this, StoicTransportError.prototype); } } export class StoicTransport { constructor(connection, agent) { _StoicTransport_connection.set(this, void 0); _StoicTransport_agent.set(this, void 0); const throwError = !__classPrivateFieldGet(_a, _a, "f", _StoicTransport_isInternalConstructing); __classPrivateFieldSet(_a, _a, false, "f", _StoicTransport_isInternalConstructing); if (throwError) { throw new StoicTransportError("StoicTransport is not constructable"); } __classPrivateFieldSet(this, _StoicTransport_connection, connection, "f"); __classPrivateFieldSet(this, _StoicTransport_agent, agent, "f"); } get connection() { return __classPrivateFieldGet(this, _StoicTransport_connection, "f"); } static async create(options) { const connection = await StoicConnection.create(options); __classPrivateFieldSet(_a, _a, true, "f", _StoicTransport_isInternalConstructing); return new _a(connection, options === null || options === void 0 ? void 0 : options.agent); } async establishChannel() { if (!__classPrivateFieldGet(this, _StoicTransport_connection, "f").connected) { throw new StoicTransportError("StoicTransport is not connected"); } return new StoicChannel(__classPrivateFieldGet(this, _StoicTransport_connection, "f"), __classPrivateFieldGet(this, _StoicTransport_agent, "f")); } } _a = StoicTransport, _StoicTransport_connection = new WeakMap(), _StoicTransport_agent = new WeakMap(); _StoicTransport_isInternalConstructing = { value: false }; //# sourceMappingURL=stoicTransport.js.map