@fractional-company/common
Version:
Tessera constants
102 lines (101 loc) • 3.16 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LPDAEventBuilder = exports.distributionParams = exports.LPDA_ETH_REFUND = exports.LPDA_FAILED = exports.LPDA_CLOSED = exports.LPDA_BID = exports.LPDA_CREATED = void 0;
const vault_events_1 = require("./vault.events");
const cloneObject_1 = require("../../utils/cloneObject");
const InternalEventBuilder_1 = require("./InternalEventBuilder");
const feature = "lpda";
exports.LPDA_CREATED = `${feature}.created`;
exports.LPDA_BID = `${feature}.bid`;
exports.LPDA_CLOSED = `${feature}.closed`;
exports.LPDA_FAILED = `${feature}.failed`;
exports.LPDA_ETH_REFUND = `${feature}.eth_refund`;
exports.distributionParams = [
"id",
"uuid",
"method",
"creatorAddress",
"isActive",
"startDate",
"endDate",
"supply",
"availableSupply",
"initialRaePriceWei",
"lastRaePriceWei",
];
class LPDAEventBuilder extends InternalEventBuilder_1.InternalEventBuilder {
setVault(vault) {
this.vault = vault;
return this;
}
setBid(bid) {
this.bid = bid;
return this;
}
setDetails(details) {
this.details = details;
return this;
}
setIsSuccessful(isSuccessful) {
this.isSuccessful = isSuccessful;
return this;
}
setDistribution(distribution) {
this.distribution = distribution;
return this;
}
getDefaultBody() {
this.validate(["vault", "distribution"], true);
return {
vault: (0, cloneObject_1.cloneObject)(this.vault, vault_events_1.vaultParams),
distribution: (0, cloneObject_1.cloneObject)(this.distribution, exports.distributionParams),
context: this.getContext(),
};
}
getCreatedBody() {
return this.getDefaultBody();
}
getClosedBody() {
this.validate(["isSuccessful"], true);
return {
...this.getDefaultBody(),
isSuccessful: this.isSuccessful || false,
};
}
getBidBody() {
this.validate(["bid"], true);
return {
...this.getDefaultBody(),
// @ts-ignore
bid: this.bid,
};
}
getEthRefundBody() {
this.validate(["details"], true);
return {
...this.getDefaultBody(),
// @ts-ignore
details: this.details,
};
}
getFailedBody() {
return this.getDefaultBody();
}
getEventBody(eventName) {
switch (eventName) {
case exports.LPDA_CREATED:
return this.getCreatedBody();
case exports.LPDA_BID:
return this.getBidBody();
case exports.LPDA_ETH_REFUND:
return this.getEthRefundBody();
case exports.LPDA_FAILED:
return this.getFailedBody();
case exports.LPDA_CLOSED:
return this.getClosedBody();
default:
return {};
}
}
}
exports.LPDAEventBuilder = LPDAEventBuilder;