/
_marketPeriod.ts
77 lines (66 loc) · 2.15 KB
/
_marketPeriod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import assert from "assert"
import * as marshal from "./marshal"
/**
* Time period of the market
*/
export class MarketPeriod {
private _block!: (bigint | undefined | null)[] | undefined | null
private _end!: bigint
private _start!: bigint
private _timestamp!: (bigint | undefined | null)[] | undefined | null
constructor(props?: Partial<Omit<MarketPeriod, 'toJSON'>>, json?: any) {
Object.assign(this, props)
if (json != null) {
this._block = json.block == null ? undefined : marshal.fromList(json.block, val => val == null ? undefined : marshal.bigint.fromJSON(val))
this._end = marshal.bigint.fromJSON(json.end)
this._start = marshal.bigint.fromJSON(json.start)
this._timestamp = json.timestamp == null ? undefined : marshal.fromList(json.timestamp, val => val == null ? undefined : marshal.bigint.fromJSON(val))
}
}
/**
* start & end block numbers
*/
get block(): (bigint | undefined | null)[] | undefined | null {
return this._block
}
set block(value: (bigint | undefined | null)[] | undefined | null) {
this._block = value
}
/**
* Timestamp at which market should end
*/
get end(): bigint {
assert(this._end != null, 'uninitialized access')
return this._end
}
set end(value: bigint) {
this._end = value
}
/**
* Timestamp at which market should start
*/
get start(): bigint {
assert(this._start != null, 'uninitialized access')
return this._start
}
set start(value: bigint) {
this._start = value
}
/**
* start & end timestamps
*/
get timestamp(): (bigint | undefined | null)[] | undefined | null {
return this._timestamp
}
set timestamp(value: (bigint | undefined | null)[] | undefined | null) {
this._timestamp = value
}
toJSON(): object {
return {
block: this.block == null ? undefined : this.block.map((val: any) => val == null ? undefined : marshal.bigint.toJSON(val)),
end: marshal.bigint.toJSON(this.end),
start: marshal.bigint.toJSON(this.start),
timestamp: this.timestamp == null ? undefined : this.timestamp.map((val: any) => val == null ? undefined : marshal.bigint.toJSON(val)),
}
}
}