-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
83 lines (80 loc) · 2.01 KB
/
index.js
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
81
82
83
import inquirer from 'inquirer';
import Api from './api/api.js';
let api = new Api();
function init() {
inquirer.prompt(
{
type: 'list',
name: 'environment',
message: 'Which environment do you want to work with?',
choices: ['Development', 'Production', 'Custom'],
}
).then(async(answers) => {
switch(answers.environment) {
case 'Development':
api.initClient('testnet');
actions();
break;
case 'Production':
api.initClient('mainnet');
actions();
break;
case 'Custom':
api.initClient('custom');
actions();
break;
}
});
}
function actions() {
inquirer.prompt(
{
type: 'list',
name: 'actions',
message: 'Hedera Client is ready, what do you want to do next?',
choices: [
'Create a Token',
'Update a Token',
'Administrate a Token',
'Setup ICO for Token',
],
}
).then(async(answers) => {
switch(answers.actions) {
case 'Create a Token':
try {
let treasury = await api.account.create();
let token = await api.token.create(treasury);
console.log(`the token ${token.name} has been created!`);
} catch(error) {
console.error(error.message);
}
break;
case 'Update a Token':
try {
let response = await api.token.update();
console.log(response);
} catch(error) {
console.error(error.message);
}
break;
case 'Administrate a Token':
try {
let response = await api.token.administrate();
console.log(response);
} catch(error) {
console.error(error.message);
}
break;
case 'Setup ICO for Token':
try {
let response = await api.ico.setup();
console.log(response);
} catch(error) {
console.error(error.message);
}
break;
}
});
}
init();