UNPKG

@fractional-company/common

Version:
107 lines (106 loc) 3.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OptimisticBidEventBuilder = exports.reconstitutionParams = exports.OPTIMISTIC_BID_CASHED_OUT = exports.OPTIMISTIC_BID_CLOSED = exports.OPTIMISTIC_BID_REDEEM = exports.OPTIMISTIC_BID_SUCCEED = exports.OPTIMISTIC_BID_FAILED = exports.OPTIMISTIC_BID_CREATED = exports.OPTIMISTIC_BID_CANCELLED = void 0; const cloneObject_1 = require("../../utils/cloneObject"); const vault_events_1 = require("./vault.events"); const InternalEventBuilder_1 = require("./InternalEventBuilder"); const feature = "optimistic_bid"; exports.OPTIMISTIC_BID_CANCELLED = `${feature}.cancelled`; exports.OPTIMISTIC_BID_CREATED = `${feature}.created`; exports.OPTIMISTIC_BID_FAILED = `${feature}.failed`; exports.OPTIMISTIC_BID_SUCCEED = `${feature}.succeed`; exports.OPTIMISTIC_BID_REDEEM = `${feature}.redeem`; exports.OPTIMISTIC_BID_CLOSED = `${feature}.closed`; exports.OPTIMISTIC_BID_CASHED_OUT = `${feature}.cashed_out`; exports.reconstitutionParams = [ "id", "uuid", "vaultId", "method", "state", "creatorAddress", "remoteId", "isActive", "proposedVaultPriceWei", "proposedRaePriceWei", "valueInPoolWei", "supplyInPool", ]; class OptimisticBidEventBuilder extends InternalEventBuilder_1.InternalEventBuilder { setVault(vault) { this.vault = vault; return this; } setReconstitution(reconstitution) { this.reconstitution = reconstitution; return this; } setDetails(details) { this.details = details; return this; } getDefaultBody() { this.validate(["vault", "reconstitution"], true); return { vault: (0, cloneObject_1.cloneObject)(this.vault, vault_events_1.vaultParams), reconstitution: (0, cloneObject_1.cloneObject)(this.reconstitution, exports.reconstitutionParams), context: this.getContext(), }; } getCreatedBody() { this.validate(["details"], true); return { ...this.getDefaultBody(), // @ts-ignore details: this.details, }; } getSucceedBody() { this.validate(["details"], true); return { ...this.getDefaultBody(), // @ts-ignore details: this.details, }; } getRedeemBody() { return { ...this.getDefaultBody(), // @ts-ignore details: this.details, }; } getFailedBody() { this.validate(["details"], true); return { ...this.getDefaultBody(), // @ts-ignore details: this.details, }; } getCashedOutBody() { this.validate(["details"], true); return { ...this.getDefaultBody(), // @ts-ignore details: this.details, }; } getEventBody(eventName) { switch (eventName) { case exports.OPTIMISTIC_BID_CREATED: return this.getCreatedBody(); case exports.OPTIMISTIC_BID_SUCCEED: return this.getSucceedBody(); case exports.OPTIMISTIC_BID_FAILED: return this.getFailedBody(); case exports.OPTIMISTIC_BID_REDEEM: return this.getRedeemBody(); case exports.OPTIMISTIC_BID_CASHED_OUT: return this.getCashedOutBody(); default: return {}; } } } exports.OptimisticBidEventBuilder = OptimisticBidEventBuilder;