UNPKG

@test-org122/hypernet-core

Version:

Hypernet Core. Represents the SDK for running the Hypernet Protocol.

28 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContextProvider = void 0; const objects_1 = require("@interfaces/objects"); const errors_1 = require("@interfaces/objects/errors"); const neverthrow_1 = require("neverthrow"); class ContextProvider { constructor(onControlClaimed, onControlYielded, onPushPaymentProposed, onPullPaymentProposed, onPushPaymentReceived, onPullPaymentApproved, onPushPaymentUpdated, onPullPaymentUpdated, onBalancesChanged, onMerchantAuthorized, onAuthorizedMerchantUpdated, onAuthorizedMerchantActivationFailed) { this.context = new objects_1.HypernetContext(null, null, false, onControlClaimed, onControlYielded, onPushPaymentProposed, onPullPaymentProposed, onPushPaymentReceived, onPullPaymentApproved, onPushPaymentUpdated, onPullPaymentUpdated, onBalancesChanged, onMerchantAuthorized, onAuthorizedMerchantUpdated, onAuthorizedMerchantActivationFailed); } getContext() { return neverthrow_1.okAsync(this.context); } getInitializedContext() { if (this.context.account == null || this.context.publicIdentifier == null) { return neverthrow_1.errAsync(new errors_1.CoreUninitializedError()); } return neverthrow_1.okAsync(new objects_1.InitializedHypernetContext(this.context.account, this.context.publicIdentifier, this.context.inControl, this.context.onControlClaimed, this.context.onControlYielded, this.context.onPushPaymentProposed, this.context.onPullPaymentProposed, this.context.onPushPaymentReceived, this.context.onPullPaymentApproved, this.context.onPushPaymentUpdated, this.context.onPullPaymentUpdated, this.context.onBalancesChanged, this.context.onMerchantAuthorized, this.context.onAuthorizedMerchantUpdated, this.context.onAuthorizedMerchantActivationFailed, new Map())); } setContext(context) { this.context = context; return neverthrow_1.okAsync(null).map(() => { return; }); } } exports.ContextProvider = ContextProvider; //# sourceMappingURL=ContextProvider.js.map