tso-data-models
Advanced tools
Comparing version 1.0.14 to 1.0.15
@@ -0,9 +1,10 @@ | ||
import { BigNumber } from "ethers"; | ||
import { PriceReveal } from "./PriceReveal"; | ||
import { PriceSubmission } from "./PriceSubmission"; | ||
export declare class ClosedEpoch { | ||
epochNumber: number; | ||
epochEnd: number; | ||
epochNumber: BigNumber; | ||
epochEnd: BigNumber; | ||
submission: PriceSubmission; | ||
reveal: PriceReveal; | ||
outputPrice?: number; | ||
outputPrice?: BigNumber; | ||
rewardsReceived?: boolean; | ||
@@ -10,0 +11,0 @@ constructor(epochNumber: number, epochStart: number); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClosedEpoch = void 0; | ||
var ethers_1 = require("ethers"); | ||
var ClosedEpoch = /** @class */ (function () { | ||
function ClosedEpoch(epochNumber, epochStart) { | ||
this.epochNumber = epochNumber; | ||
this.epochNumber = ethers_1.BigNumber.from(epochNumber); | ||
var tempEnd = new Date(epochStart * 1000); | ||
var timeToAdd = 120 * 1000; | ||
this.epochEnd = tempEnd.getMilliseconds() + timeToAdd; | ||
this.epochEnd = ethers_1.BigNumber.from(tempEnd.getMilliseconds() + timeToAdd); | ||
} | ||
@@ -11,0 +12,0 @@ return ClosedEpoch; |
@@ -0,8 +1,9 @@ | ||
import { BigNumber } from "ethers"; | ||
export declare class OpenEpoch { | ||
epochNumber: number; | ||
epochStart: number; | ||
epochEnd: number; | ||
epochNumber: BigNumber; | ||
epochStart: BigNumber; | ||
epochEnd: BigNumber; | ||
constructor(epochNumber: number, epochStart: number); | ||
updateEndTime(): void; | ||
calculateSubmitTime(secondsBeforeEpochEnd: number): number; | ||
calculateSubmitTime(secondsBeforeEpochEnd: number): BigNumber; | ||
getDataFromBlockChain(): Promise<void>; | ||
@@ -9,0 +10,0 @@ isOpen(): boolean; |
@@ -40,6 +40,7 @@ "use strict"; | ||
exports.OpenEpoch = void 0; | ||
var ethers_1 = require("ethers"); | ||
var OpenEpoch = /** @class */ (function () { | ||
function OpenEpoch(epochNumber, epochStart) { | ||
this.epochNumber = epochNumber; | ||
this.epochStart = epochStart; | ||
this.epochNumber = ethers_1.BigNumber.from(epochNumber); | ||
this.epochStart = ethers_1.BigNumber.from(epochStart); | ||
this.updateEndTime(); | ||
@@ -49,7 +50,7 @@ } | ||
var timeToAdd = 120 * 1000; | ||
this.epochEnd = this.epochStart + timeToAdd; | ||
this.epochEnd = ethers_1.BigNumber.from(this.epochStart.add(timeToAdd)); | ||
}; | ||
OpenEpoch.prototype.calculateSubmitTime = function (secondsBeforeEpochEnd) { | ||
var submitBuffer = secondsBeforeEpochEnd * 1000; | ||
return this.epochEnd - submitBuffer; | ||
return this.epochEnd.sub(submitBuffer); | ||
}; | ||
@@ -68,3 +69,3 @@ OpenEpoch.prototype.getDataFromBlockChain = function () { | ||
var now = Date.now(); | ||
return this.epochEnd - now; | ||
return this.epochEnd.sub(now).toNumber(); | ||
}; | ||
@@ -71,0 +72,0 @@ return OpenEpoch; |
@@ -9,5 +9,5 @@ import { BigNumber } from "ethers"; | ||
submitPrice: BigNumber; | ||
revealTime?: number; | ||
revealBlockNumber?: number; | ||
revealExpiration?: number; | ||
revealTime?: BigNumber; | ||
revealBlockNumber?: BigNumber; | ||
revealExpiration?: BigNumber; | ||
constructor(revealStartTime: number, submission: PriceSubmission); | ||
@@ -14,0 +14,0 @@ getSubmitPriceHash(): string; |
@@ -8,3 +8,3 @@ "use strict"; | ||
this.assetName = submission.assetName; | ||
this.revealExpiration = revealStartTime + (120 * 1000); | ||
this.revealExpiration = ethers_1.BigNumber.from(revealStartTime + (120 * 1000)); | ||
this.providerAddress = submission.providerAddress; | ||
@@ -11,0 +11,0 @@ this.assetAddress = submission.assetAddress; |
import { BigNumber } from "ethers"; | ||
import { OpenEpoch } from "./OpenEpoch"; | ||
export declare class PriceSubmission { | ||
epochNumber: number; | ||
epochNumber: BigNumber; | ||
assetName: string; | ||
@@ -9,4 +9,4 @@ assetAddress: string; | ||
providerAddress: string; | ||
targetSubmitTime?: number; | ||
actualSubmitTime?: number; | ||
targetSubmitTime?: BigNumber; | ||
actualSubmitTime?: BigNumber; | ||
randomNumber?: number; | ||
@@ -13,0 +13,0 @@ submitPrice?: BigNumber; |
@@ -18,3 +18,3 @@ "use strict"; | ||
this.submitPrice = submissionPrice; | ||
this.actualSubmitTime = Date.now(); | ||
this.actualSubmitTime = ethers_1.BigNumber.from(Date.now()); | ||
this.randomNumber = Math.floor(Math.random() * 100000); | ||
@@ -27,3 +27,3 @@ }; | ||
PriceSubmission.prototype.isTargetSubmitTime = function () { | ||
return this.targetSubmitTime >= Date.now(); | ||
return this.targetSubmitTime >= ethers_1.BigNumber.from(Date.now()); | ||
}; | ||
@@ -30,0 +30,0 @@ return PriceSubmission; |
{ | ||
"name": "tso-data-models", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -0,1 +1,2 @@ | ||
import { BigNumber } from "ethers"; | ||
import { PriceReveal } from "./PriceReveal"; | ||
@@ -5,14 +6,14 @@ import { PriceSubmission } from "./PriceSubmission"; | ||
export class ClosedEpoch { | ||
epochNumber: number; | ||
epochEnd: number; | ||
epochNumber: BigNumber; | ||
epochEnd: BigNumber; | ||
submission: PriceSubmission; | ||
reveal: PriceReveal; | ||
outputPrice?: number; | ||
outputPrice?: BigNumber; | ||
rewardsReceived?: boolean; | ||
constructor(epochNumber: number, epochStart: number) { | ||
this.epochNumber = epochNumber; | ||
this.epochNumber = BigNumber.from(epochNumber); | ||
const tempEnd: Date = new Date(epochStart * 1000); | ||
const timeToAdd = 120 * 1000; | ||
this.epochEnd = tempEnd.getMilliseconds() + timeToAdd; | ||
this.epochEnd = BigNumber.from(tempEnd.getMilliseconds() + timeToAdd); | ||
} | ||
@@ -19,0 +20,0 @@ |
@@ -0,11 +1,12 @@ | ||
import { BigNumber } from "ethers"; | ||
import { PriceSubmission } from "./PriceSubmission"; | ||
export class OpenEpoch { | ||
epochNumber: number; | ||
epochStart: number; | ||
epochEnd: number; | ||
epochNumber: BigNumber; | ||
epochStart: BigNumber; | ||
epochEnd: BigNumber; | ||
constructor(epochNumber: number, epochStart: number) { | ||
this.epochNumber = epochNumber; | ||
this.epochStart = epochStart; | ||
this.epochNumber = BigNumber.from(epochNumber); | ||
this.epochStart = BigNumber.from(epochStart); | ||
this.updateEndTime(); | ||
@@ -16,8 +17,8 @@ } | ||
const timeToAdd = 120 * 1000; | ||
this.epochEnd = this.epochStart + timeToAdd; | ||
this.epochEnd = BigNumber.from(this.epochStart.add(timeToAdd)); | ||
} | ||
calculateSubmitTime(secondsBeforeEpochEnd: number): number { | ||
calculateSubmitTime(secondsBeforeEpochEnd: number): BigNumber { | ||
const submitBuffer = secondsBeforeEpochEnd * 1000; | ||
return this.epochEnd - submitBuffer; | ||
return this.epochEnd.sub(submitBuffer); | ||
} | ||
@@ -35,5 +36,5 @@ | ||
const now = Date.now(); | ||
return this.epochEnd - now; | ||
return this.epochEnd.sub(now).toNumber(); | ||
} | ||
} |
@@ -10,9 +10,9 @@ import { BigNumber, ethers } from "ethers"; | ||
submitPrice: BigNumber; | ||
revealTime?: number; | ||
revealBlockNumber?: number; | ||
revealExpiration?: number; | ||
revealTime?: BigNumber; | ||
revealBlockNumber?: BigNumber; | ||
revealExpiration?: BigNumber; | ||
constructor(revealStartTime: number, submission: PriceSubmission) { | ||
this.assetName = submission.assetName; | ||
this.revealExpiration = revealStartTime + (120 * 1000); | ||
this.revealExpiration = BigNumber.from(revealStartTime + (120 * 1000)); | ||
this.providerAddress = submission.providerAddress; | ||
@@ -19,0 +19,0 @@ this.assetAddress = submission.assetAddress; |
@@ -5,3 +5,3 @@ import { BigNumber, ethers } from "ethers"; | ||
export class PriceSubmission { | ||
epochNumber: number; | ||
epochNumber: BigNumber; | ||
assetName: string; | ||
@@ -11,4 +11,4 @@ assetAddress: string; | ||
providerAddress: string; | ||
targetSubmitTime?: number; | ||
actualSubmitTime?: number; | ||
targetSubmitTime?: BigNumber; | ||
actualSubmitTime?: BigNumber; | ||
randomNumber?: number; | ||
@@ -30,3 +30,3 @@ submitPrice?: BigNumber; | ||
this.submitPrice = submissionPrice; | ||
this.actualSubmitTime = Date.now(); | ||
this.actualSubmitTime = BigNumber.from(Date.now()); | ||
this.randomNumber = Math.floor(Math.random() * 100000); | ||
@@ -39,5 +39,5 @@ } | ||
} | ||
isTargetSubmitTime() { | ||
return this.targetSubmitTime >= Date.now(); | ||
return this.targetSubmitTime >= BigNumber.from(Date.now()); | ||
} | ||
@@ -44,0 +44,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50103
726