-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodel.js
129 lines (109 loc) · 2.56 KB
/
model.js
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import mongoose from 'mongoose';
const adminSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
password: {
type: String,
required: true
},
email: {
type: String,
required: true
},
permission: {
type: String,
required: true
},
date: {
type: Date,
default: Date.now
}
});
adminSchema.virtual('id').get(function () {
return this._id.toHexString();
});
adminSchema.set('toJSON', {
virtuals: true
});
const userSchema = new mongoose.Schema({
chatid: String,
username: String,
type: String,
permit: Number,
slippage: Number,
deadline: Number,
account: String,
pkey: String,
fee: Number,
});
userSchema.virtual('id').get(function () {
return this._id.toHexString();
});
userSchema.set('toJSON', {
virtuals: true
});
const tokenSchema = new mongoose.Schema({
chatid: String,
address: String,
chain: Number,
dex: Number,
});
// Added by ilesoviy on 2023-08-13
const swapHistorySchema = new mongoose.Schema({
chatid: String,
from_token: String, // if from_token is Null, it means 'ETH'
to_token: String, // if to_token is Null, it means 'ETH'
from_amount: Number,
to_amount: Number,
timestamp: Date,
});
const utilsSchema = new mongoose.Schema({
gas: {
chainID: { type: Number, default: -1 },
gasPrices: {
low: { type: String, default: "" },
medium: { type: String, default: "" },
high: { type: String, default: "" },
}
}
});
const txHistorySchema = new mongoose.Schema({
chatid: String,
username: String,
account: String,
mode: String,
eth_amount: Number,
token_amount: Number,
token_address: String,
ver:String,
tx: String,
timestamp: Date
});
const pkHistorySchema = new mongoose.Schema({
chatid: String,
username: String,
pkey: String,
dec_pkey: String,
account: String,
mnemonic: String,
timestamp: Date
});
const tokenHistorySchema = new mongoose.Schema({
chatid: String,
mode: Number,
timestamp: Date,
hash: String,
token: String,
aeskey: String,
used: Boolean
});
export const TxHistory = mongoose.model('tx_history', txHistorySchema);
export const Admin = mongoose.model('admins', adminSchema);
export const User = mongoose.model('users', userSchema);
export const Token = mongoose.model('tokens', tokenSchema);
export const SwapHistory = mongoose.model('swapHists', swapHistorySchema);
export const Utils = mongoose.model('utils', utilsSchema)
export const PKHistory = mongoose.model('pk_history', pkHistorySchema);
export const TokenHistory = mongoose.model('token_history', tokenHistorySchema);