-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.ts
81 lines (67 loc) · 2.53 KB
/
models.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
78
79
80
81
import { Model, DataTypes } from './deps.ts'
export class Wallets extends Model {
static table = 'wallets'
static timestamps = true
static fields = {
id: { primaryKey: true, type: DataTypes.INTEGER, autoIncrement: true },
address: { type: DataTypes.STRING, unique: true },
chain: { type: DataTypes.INTEGER },
txnLength: { type: DataTypes.INTEGER, defaultValue: null },
isRevoke: { type: DataTypes.BOOLEAN, defaultValue: false },
lastBlock: { type: DataTypes.BIG_INTEGER },
}
}
export class Txns extends Model {
static table = 'txns'
static timestamps = true
static fields = {
id: { primaryKey: true, type: DataTypes.BIG_INTEGER, autoIncrement: true },
hash: { type: DataTypes.STRING, quote: true },
from: { type: DataTypes.STRING },
to: { type: DataTypes.STRING },
value: { type: DataTypes.BIG_INTEGER },
fee: { type: DataTypes.STRING },
method: { type: DataTypes.STRING },
type: { type: DataTypes.STRING },
blockNumber: { type: DataTypes.BIG_INTEGER },
blockHash: { type: DataTypes.STRING },
blockTimestamp: { type: DataTypes.BIG_INTEGER },
index: { type: DataTypes.INTEGER },
nonce: { type: DataTypes.INTEGER },
gas: { type: DataTypes.BIG_INTEGER },
gasPrice: { type: DataTypes.BIG_INTEGER },
input: { type: DataTypes.STRING },
chain: { type: DataTypes.INTEGER },
status: { type: DataTypes.BOOLEAN },
// TODO: need to be optimized when upgrading/migrating
details: { type: DataTypes.JSONB },
receipt: { type: DataTypes.JSONB },
isCompletion: { type: DataTypes.BOOLEAN, defaultValue: false },
}
}
export class WalletAchievements extends Model {
static table = 'achievements'
static timestamps = true
static fields = {
id: { primaryKey: true, type: DataTypes.INTEGER, autoIncrement: true },
address: { type: DataTypes.STRING, },
achievementId: { type: DataTypes.STRING, },
reasons: { type: DataTypes.JSONB },
}
}
export class Tasks extends Model {
static table = 'tasks'
static timestamps = true
static fields = {
id: { primaryKey: true, type: DataTypes.INTEGER, autoIncrement: true },
chain: { type: DataTypes.INTEGER },
address: { type: DataTypes.STRING },
details: { type: DataTypes.JSONB },
// status the task is in
status: { type: DataTypes.ENUM, values: ['ready', 'fetching', 'fetched'] },
// high permission task, Ignore last block to fetch
needToFetch: { type: DataTypes.BOOLEAN, defaultValue: false },
// last block fetched
lastBlock: { type: DataTypes.BIG_INTEGER },
}
}