-
Notifications
You must be signed in to change notification settings - Fork 33
/
getAccountsInfo.ts
38 lines (36 loc) · 1.21 KB
/
getAccountsInfo.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
import ora from "ora";
import { getImplementation } from "./getImplementation";
import { getSigners } from "./getSigner";
import { getBalances } from "./getTokenBalance";
import { getVersion } from "./getVersion";
import { NetworkId } from "./types";
export const getAccountInfos = async (
addresses: string[],
networkId: NetworkId,
oraProgress?: ora.Ora
) => {
const progress = oraProgress ?? ora("Retrieving signers");
progress.start();
progress.text = "Retrieving signers";
const signer = await getSigners(addresses, networkId);
progress.text = "Retrieving versions";
const versions = await getVersion(addresses, networkId);
progress.text = "Retrieving implementations";
const implementations = await getImplementation(addresses, networkId);
progress.text = "Retrieving balances";
const balances = await getBalances(addresses, networkId);
progress.succeed();
return addresses.map((address, i) => ({
address,
signer: signer[i],
networkId,
implementation: implementations[i],
version: versions[i],
balances: balances.reduce((acc, x) => {
if (x.address === address) {
acc[x.token] = x.balance;
}
return acc;
}, {} as { [token: string]: string }),
}));
};