-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.ts
40 lines (37 loc) · 1.1 KB
/
main.ts
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
import * as dotenv from 'dotenv';
dotenv.config({ path: '..' });
import * as transports from './lib/transports';
import { Cache } from './lib/cache';
import { Chain } from './lib/chain';
const transport = (process.env.TRANSPORT || '')
?.split(',')
.map((v) => v.trim());
if (!transport?.length) {
throw new Error('TRANSPORT is not set');
}
console.log(transport);
class Main {
async init() {
console.log('Starting...');
const cache = new Cache();
console.log('Cache initialized');
const chain = new Chain();
console.log('Chain start');
if (!process.env.DROP_AMOUNT) {
throw new Error('DROP_AMOUNT is not set');
}
const amount = process.env.DROP_AMOUNT;
await chain.init();
console.log('Chain stuff has been initialized');
const timeout = parseInt(process.env.TX_TIMEOUT || '2s');
await Promise.all(
Object.values(transports).map((t) => {
const x = new t();
if (!transport.includes(x.name)) return;
x.init(cache);
x.onRequest(async (address) => chain.fundAccount(address, amount));
}),
);
}
}
new Main().init();