-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.js
81 lines (73 loc) · 2.55 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
69
70
71
72
73
74
75
76
77
78
79
80
81
import { account } from "./account.js";
import { Tucana } from "./src/module/tucana/tucana.js";
import { Civitia } from "./src/module/civitia/civitia.js";
import { Initia } from "./src/module/initia/initia.js";
import { Config } from "./config.js";
import { COIN } from "./src/utils/enum/coin.js";
import { InitAi } from "./src/module/init_ai/init_ai.js";
import { userConfig } from "./user_config.js";
async function doQuest(walletAddress, privateKey) {
return new Promise(async (resolve, reject) => {
try {
const initia = new Initia(walletAddress, privateKey);
const tucana = new Tucana(walletAddress, privateKey, initia);
const civitia = new Civitia(walletAddress, privateKey);
const initAi = new InitAi(walletAddress, privateKey);
await initia.checkGas().then(async (gasBalance) => {
if (gasBalance / 1000000 < 5) {
reject(
`Account ${walletAddress} GAS Token is not enough, min balance is 5 GAS`
);
} else {
console.log(`Account ${walletAddress} Information`);
await initia
.queryBalance(COIN.INIT)
.then(async (initBalance) => {
console.log();
console.log("Doing daily routine for Account " + walletAddress);
console.log();
if (initBalance / 1000000 < 10) {
reject(
`Balance < 20 Initia for account ${walletAddress}, Please request initia token from faucet `
);
} else {
const config = new Config(
initia,
civitia,
tucana,
initAi,
userConfig,
walletAddress
);
for (const number of config.config) {
await config.executeConfigCode(number);
}
initia.exception.resetRoutine();
tucana.exception.resetRoutine();
civitia.exception.resetRoutine();
initAi.exception.resetRoutine();
resolve(true);
}
})
.then((error) => reject(error));
}
});
} catch (error) {
reject(error);
}
});
}
(async () => {
try {
for (const acc of account) {
var walletAddress = acc[0];
var privateKey = acc[1];
await doQuest(walletAddress, privateKey).catch((error) =>
console.error(error)
);
}
} catch (error) {
console.error("Error During executing bot", error);
}
})();
export { doQuest };