forked from dante4rt/mint-forest-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
95 lines (83 loc) · 2.95 KB
/
main.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
const { successLog, failedLog, infoLog } = require('./logger');
const {
fetchEnergy,
fetchUserInfo,
claimEnergy,
injectEnergy,
getTokenList,
} = require('./api');
const colors = require('colors');
const main = async () => {
try {
const runCode = async () => {
process.stdout.write('\x1Bc');
console.log(colors.cyan('========================================'));
console.log(colors.cyan('= MintChain Claimer and Injector ='));
console.log(colors.cyan('= Created by HappyCuanAirdrop ='));
console.log(colors.cyan('= https://t.me/HappyCuanAirdrop ='));
console.log(colors.cyan('========================================'));
console.log();
const tokenList = getTokenList();
for (let i = 0; i < tokenList.length; i++) {
console.log(
colors.yellow(`Processing ACCOUNT ${i + 1} of ${tokenList.length}`)
);
console.log();
const token = tokenList[i];
const userInfo = await fetchUserInfo(token);
const { id, address, treeId, status, energy } = userInfo.result;
successLog('Account information retrieved successfully');
infoLog(`ID : ${id}`);
infoLog(`Address : ${address}`);
infoLog(`Tree ID : ${treeId}`);
infoLog(`Status : ${status}`);
infoLog(`Energy : ${energy}`);
const energyList = await fetchEnergy(token);
let totalEnergy;
let energyClaimed;
successLog('Energy list retrieved successfully');
for (const energy of energyList.result) {
infoLog(`Amount : ${energy.amount}`);
infoLog(`Type : ${energy.type}`);
if (energy.freeze == true) {
infoLog('Skipping claiming energy because it is frozen');
} else {
await claimEnergy(
token,
energy.uid,
energy.amount,
energy.includes,
energy.type,
energy.id
);
energyClaimed = energy.amount;
successLog(
`* Claimed ${energy.amount} energy for wallet ${address} *`
);
}
}
totalEnergy = energy + energyClaimed;
if (totalEnergy > 0) {
const response = await injectEnergy(token, totalEnergy, address);
if (response.msg == 'ok') {
successLog(
`* Injected ${totalEnergy} energy into ${address}'s tree *`
);
}
} else {
infoLog(`Skipping injection for wallet ${address}`);
}
console.log(colors.cyan('========================================'));
console.log();
}
};
// Run the code immediately when the script starts
await runCode();
// Set up interval to run the code every 86400 seconds (1 day)
setInterval(runCode, 86401 * 1000);
console.log("Retrying in 24 hours......");
} catch (error) {
failedLog(error.message);
}
};
module.exports = main;