-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
68 lines (54 loc) · 2.34 KB
/
main.js
File metadata and controls
68 lines (54 loc) · 2.34 KB
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 banner from './utils/banner.js';
import log from './utils/logger.js';
import { readFile } from './utils/file.js';
import { processAccountLogin, processAccountRewards, getUserInfo } from './services/api.js';
import { WebSocketClient, setupAccountIntervals } from './services/websocket.js';
import { INTERVALS } from './config/api.js';
const main = async () => {
log.info(banner);
const wallets = readFile("wallets.txt")
if (wallets.length === 0) {
log.error('No wallets found in wallets.txt');
return;
}
const proxies = readFile("proxy.txt");
log.info(`Starting for all accounts:`, wallets.length);
const accountsProcessing = wallets.map(async (address, index) => {
const proxy = proxies[index % proxies.length];
let isConnected = false;
log.info(`Starting Account ${index + 1} with Proxy ${(index % proxies.length) + 1}`);
let claimDetailsInterval;
let userInfoInterval;
while (!isConnected) {
try {
const token = await processAccountLogin(address, proxy, index);
await processAccountRewards(token, proxy, index);
await getUserInfo(token, proxy, index + 1);
const socket = new WebSocketClient(token, address, proxy, index + 1);
socket.connect();
isConnected = true;
const intervals = setupAccountIntervals(token, proxy, index, socket);
userInfoInterval = intervals.userInfoInterval;
claimDetailsInterval = intervals.claimDetailsInterval;
} catch (error) {
log.error(`Account ${index + 1} start failed:`, error.message || 'unknown error');
isConnected = false;
await new Promise(resolve => setTimeout(resolve, INTERVALS.RECONNECT_DELAY));
}
}
process.on('SIGINT', () => {
log.warn(`Cleaning up and exiting...`);
clearInterval(claimDetailsInterval);
clearInterval(userInfoInterval);
process.exit(0);
});
process.on('SIGTERM', () => {
log.warn(`Cleaning up and exiting...`);
clearInterval(claimDetailsInterval);
clearInterval(userInfoInterval);
process.exit(0);
});
});
await Promise.all(accountsProcessing);
};
main();