-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
68 lines (63 loc) · 1.83 KB
/
index.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
import mongoose from "mongoose";
import { btcClaim } from "./models/index.js";
import { script } from "./script.js";
import dotenv from "dotenv";
dotenv.config();
import readline from "readline";
import commit from "./commit";
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
mongoose
// eslint-disable-next-line no-undef
.connect(process.env.mongodbURL, {
useNewUrlParser: true,
autoReconnect: true,
useFindAndModify: false,
})
.then(() => {
console.log("Connected to Database");
rl.question(
"Enter 1 for list or 2 for payout and 3 for confirming stacking ? ",
async function (name) {
switch (parseInt(name)) {
case 1:
const list = await btcClaim.find({}).populate().lean();
list.forEach((value) => {
console.log(value.username);
console.table(value.btcAddress);
});
break;
case 2:
rl.question("Enter username", function (username) {
rl.question("enter reward", function (reward) {
rl.question(
"enter payoutaddress",
async function (payoutBTCAddress) {
await script({ username, reward, payoutBTCAddress });
}
);
});
});
break;
case 3:
rl.question("Enter reward cycle id", async (id) => {
const tx = await commit(id);
console.log(tx);
});
default:
rl.close();
process.exit(0);
}
// process.exit(0);
}
);
rl.on("close", function () {
console.log("\nBYE BYE !!!");
process.exit(0);
});
})
.catch(() => {
console.log("Failed to connect to the database");
});