-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.ts
80 lines (71 loc) · 2.17 KB
/
index.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
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
import { input } from "@inquirer/prompts";
import { SEEDS_COUNT_DEFAULT } from "./constants";
import {
getArgentVersion,
getBlockchain,
getBraavosVersion,
getCosmosChain,
getStarkNetWallet,
getTopLevel,
} from "./modules/menu";
import privatesToAddresses from "./modules/privates-to-addresses";
import { generateSeeds } from "./modules/seeds";
import seedsToAddresses from "./modules/seeds-to-addresses";
import seedsToPrivates from "./modules/seeds-to-privates";
import { Blockchain, StarknetWallet, TopLevel } from "./types";
async function getInputsForPrivates() {
const blockchain = await getBlockchain();
const cosmosChain = (blockchain === Blockchain.cosmos)
? await getCosmosChain()
: undefined;
const starknetWallet = (blockchain === Blockchain.starknet)
? await getStarkNetWallet()
: undefined;
return {
blockchain,
cosmosChain,
starknetWallet,
};
}
async function getInputsForAddresses() {
const result = await getInputsForPrivates();
const argentVersion = (result.starknetWallet === StarknetWallet.argent)
? await getArgentVersion()
: undefined;
const braavosVersion = (result.starknetWallet === StarknetWallet.braavos)
? await getBraavosVersion()
: undefined;
return {
...result,
argentVersion,
braavosVersion,
};
}
const topLevel = await getTopLevel();
switch (topLevel) {
case TopLevel.generateSeeds:
const seedsCountAnswer = await input({
message: "Введите количество?",
default: SEEDS_COUNT_DEFAULT.toString(),
});
const seedsCount = parseInt(seedsCountAnswer) || SEEDS_COUNT_DEFAULT;
generateSeeds(seedsCount);
break;
case TopLevel.seedsToPrivates: {
const { blockchain, ...options } = await getInputsForPrivates();
await seedsToPrivates(blockchain, options);
break;
}
case TopLevel.seedsToAddresses: {
const { blockchain, ...options } = await getInputsForAddresses();
await seedsToAddresses(blockchain, options);
break;
}
case TopLevel.privatesToAddresses: {
const { blockchain, ...options } = await getInputsForAddresses();
await privatesToAddresses(blockchain, options);
break;
}
default:
break;
}