-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
55 lines (44 loc) · 1.33 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { apiUrl, checkAPIConnectivity } from "./src/api";
import {
getSlowList,
mapBalancesAccount,
mapCommunityBalance,
mapCommunityListToBalance,
mapPledgeAccount,
mapSlowListToBalance,
reduceBalances,
} from "./src/slow_wallets";
import { getSupply } from "./src/supply";
import fs from "fs";
const main = async () => {
if (!(await checkAPIConnectivity(apiUrl))) {
console.log("cannot connect to upstream");
process.exit(1);
} else {
console.log(`connected to ${apiUrl}`);
}
console.log(await getSupply());
const communityList = await mapCommunityListToBalance();
const comm_balance = await mapCommunityBalance(communityList);
const slowList = await mapSlowListToBalance();
let balances = await mapBalancesAccount(slowList);
balances = await mapPledgeAccount(balances);
let joined = balances.concat(comm_balance)
const summary = reduceBalances(joined);
// console.log(balances);
fs.writeFile("./data/balances.json", JSON.stringify(balances, null, 2), (err) => {
if (err) {
console.error("Error writing to file", err);
} else {
console.log("Output written to balances.json");
}
});
fs.writeFile("./data/summary.json", JSON.stringify(summary, null, 2), (err) => {
if (err) {
console.error("Error writing to file", err);
} else {
console.log("Output written to summary.json");
}
});
};
main();