@fractional-company/common
Version:
Tessera constants
98 lines (97 loc) • 3.06 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VaultEventBuilder = exports.vaultParams = exports.VAULT_CLOSED = exports.VAULT_CREATED = exports.VAULT_TOKEN_SOLD = exports.VAULT_TOKEN_RECEIVED = void 0;
const cloneObject_1 = require("../../utils/cloneObject");
const optimistic_bid_events_1 = require("./optimistic-bid.events");
const InternalEventBuilder_1 = require("./InternalEventBuilder");
const feature = "vault";
exports.VAULT_TOKEN_RECEIVED = `${feature}.token_received`;
exports.VAULT_TOKEN_SOLD = `${feature}.token_sold`;
exports.VAULT_CREATED = `${feature}.created`;
exports.VAULT_CLOSED = `${feature}.closed`;
exports.vaultParams = [
"id",
"slug",
"name",
"supply",
"initialSupply",
"closedAtBlock",
"mintedAtBlock",
"contractAddress",
"curatorAddress",
"chainId",
"raeTokenAddress",
"raeTokenId",
"isVisible",
"isActiveFrom",
"protoform",
"tokenStandard",
"tokenKey",
"createdAt",
];
class VaultEventBuilder extends InternalEventBuilder_1.InternalEventBuilder {
constructor() {
super(...arguments);
this.vault = null;
this.token = null;
this.collectable = null;
this.reconstitution = null;
}
setVault(vault) {
this.vault = vault;
return this;
}
// @ts-ignore
setToken(tokenAddress, tokenId, chainId) {
this.token = tokenId ? { tokenAddress, tokenId, chainId } : { tokenAddress, chainId };
return this;
}
setCollectable(collectable) {
this.collectable = collectable;
return this;
}
setReconstitution(reconstitution) {
this.reconstitution = reconstitution;
return this;
}
getDefaultBody() {
this.validate(["vault"], true);
return {
vault: (0, cloneObject_1.cloneObject)(this.vault, exports.vaultParams),
context: this.getContext(),
};
}
getCreatedBody() {
return {
...this.getDefaultBody(),
};
}
getTokenReceivedBody() {
return {
...this.getDefaultBody(),
// @ts-ignore
token: this.token,
collectable: this.collectable,
};
}
getClosedBody() {
this.validate(["reconstitution"], true);
return {
...this.getDefaultBody(),
reconstitution: (0, cloneObject_1.cloneObject)(this.reconstitution, optimistic_bid_events_1.reconstitutionParams),
};
}
getEventBody(eventName) {
switch (eventName) {
case exports.VAULT_CREATED:
return this.getCreatedBody();
case exports.VAULT_TOKEN_RECEIVED:
return this.getTokenReceivedBody();
case exports.VAULT_CLOSED:
return this.getClosedBody();
default:
return {};
}
}
}
exports.VaultEventBuilder = VaultEventBuilder;