wative 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.js +1 -1
- package/lib/index.umd.js +1 -1
- package/package.json +2 -2
- package/src/account.ts +64 -36
- package/src/assets.ts +8 -6
- package/src/network.ts +26 -23
- package/src/tools.ts +26 -24
- package/src/utils.ts +1 -1
package/src/account.ts
CHANGED
|
@@ -107,9 +107,11 @@ const importPrivateKey = async (keystore_path: string, wative_core: typeof Wativ
|
|
|
107
107
|
|
|
108
108
|
const createAccount = async (keystore_path: string, wative_core: typeof WativeCore) => {
|
|
109
109
|
const create_account_options = [
|
|
110
|
+
'> Back',
|
|
111
|
+
new inquirer.Separator('----------------------------------'),
|
|
110
112
|
'> Import Passphrase',
|
|
111
113
|
'> Import Private Key',
|
|
112
|
-
|
|
114
|
+
|
|
113
115
|
];
|
|
114
116
|
|
|
115
117
|
let selected_create_account = await selectSomething(create_account_options);
|
|
@@ -151,16 +153,19 @@ export const loginIn = async (account_label: string, wative_core: typeof WativeC
|
|
|
151
153
|
if (is_login) {
|
|
152
154
|
return true;
|
|
153
155
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
|
|
157
|
+
for (let i = 0; i < 3; i++) {
|
|
158
|
+
const password = await inputPassword(`Please input the password for Account [${account_label}]`);
|
|
159
|
+
const login_result = await wative_core.account.login(account_label, password);
|
|
160
|
+
if (login_result.status) {
|
|
161
|
+
return true;
|
|
162
|
+
} else {
|
|
163
|
+
console.log(
|
|
164
|
+
chalk.red(login_result.output)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
163
167
|
}
|
|
168
|
+
return false;
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
const selectAccount = async (keystore_path: string, wative_core: typeof WativeCore) => {
|
|
@@ -168,7 +173,8 @@ const selectAccount = async (keystore_path: string, wative_core: typeof WativeCo
|
|
|
168
173
|
const account_label_list = networks.accounts;
|
|
169
174
|
|
|
170
175
|
let select_account_options = [
|
|
171
|
-
|
|
176
|
+
'> Back',
|
|
177
|
+
new inquirer.Separator('----------------------------------')
|
|
172
178
|
];
|
|
173
179
|
|
|
174
180
|
const account_label_len = account_label_list.length;
|
|
@@ -190,11 +196,11 @@ const selectAccount = async (keystore_path: string, wative_core: typeof WativeCo
|
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
const selected_account = await selectSomething(select_account_options, "Select an account");
|
|
193
|
-
if (selected_account ===
|
|
199
|
+
if (selected_account === '> Back') {
|
|
194
200
|
return;
|
|
195
201
|
}
|
|
196
202
|
|
|
197
|
-
const selected_account_label = account_label_list[select_account_options.indexOf(selected_account) -
|
|
203
|
+
const selected_account_label = account_label_list[select_account_options.indexOf(selected_account) - 2];
|
|
198
204
|
let login_result = await loginIn(selected_account_label, wative_core);
|
|
199
205
|
if (login_result) {
|
|
200
206
|
await accountManager(keystore_path, selected_account_label, wative_core);
|
|
@@ -207,7 +213,8 @@ const setDisableAddress = async (keystore_path: string, account_label: string, w
|
|
|
207
213
|
const account_info = await getAccountInfo(keystore_path, account_label);
|
|
208
214
|
|
|
209
215
|
let disable_address_options = [
|
|
210
|
-
|
|
216
|
+
'> Back',
|
|
217
|
+
new inquirer.Separator('----------------------------------'),
|
|
211
218
|
"1.Disabled Slots",
|
|
212
219
|
"2.Add Single",
|
|
213
220
|
"3.Add Range"
|
|
@@ -215,7 +222,7 @@ const setDisableAddress = async (keystore_path: string, account_label: string, w
|
|
|
215
222
|
|
|
216
223
|
const selected_disable_address = await selectSomething(disable_address_options);
|
|
217
224
|
switch (selected_disable_address) {
|
|
218
|
-
case
|
|
225
|
+
case '> Back': {
|
|
219
226
|
return;
|
|
220
227
|
}
|
|
221
228
|
case "1.Disabled Slots": {
|
|
@@ -230,7 +237,8 @@ const setDisableAddress = async (keystore_path: string, account_label: string, w
|
|
|
230
237
|
let account_data = account_info.data;
|
|
231
238
|
|
|
232
239
|
let disabled_slots_options = [
|
|
233
|
-
|
|
240
|
+
'> Back',
|
|
241
|
+
new inquirer.Separator('----------------------------------'),
|
|
234
242
|
];
|
|
235
243
|
|
|
236
244
|
let default_network = account_info.default_network;
|
|
@@ -284,7 +292,7 @@ const setDisableAddress = async (keystore_path: string, account_label: string, w
|
|
|
284
292
|
|
|
285
293
|
let selected_disabled_slots = await selectSomething(disabled_slots_options);
|
|
286
294
|
|
|
287
|
-
if (selected_disabled_slots ===
|
|
295
|
+
if (selected_disabled_slots === '> Back') {
|
|
288
296
|
break;
|
|
289
297
|
}
|
|
290
298
|
|
|
@@ -292,7 +300,7 @@ const setDisableAddress = async (keystore_path: string, account_label: string, w
|
|
|
292
300
|
if (!confirm) {
|
|
293
301
|
break;
|
|
294
302
|
}
|
|
295
|
-
let selected_disabled_slots_index = disabled_slots_options.indexOf(selected_disabled_slots) -
|
|
303
|
+
let selected_disabled_slots_index = disabled_slots_options.indexOf(selected_disabled_slots) - 2;
|
|
296
304
|
|
|
297
305
|
account_info.disabled_slots.splice(selected_disabled_slots_index, 1);
|
|
298
306
|
saveAccountInfo(keystore_path, account_label, account_info);
|
|
@@ -346,24 +354,27 @@ const setDisableAddress = async (keystore_path: string, account_label: string, w
|
|
|
346
354
|
const accountManager = async (keystore_path: string, account_label: string, wative_core: typeof WativeCore) => {
|
|
347
355
|
let account_info = await getAccountInfo(keystore_path, account_label);
|
|
348
356
|
|
|
349
|
-
let account_manager_options:
|
|
357
|
+
let account_manager_options: any[];
|
|
350
358
|
|
|
351
359
|
if (account_info.account_type === "PP") {
|
|
352
360
|
account_manager_options = [
|
|
361
|
+
'> Back',
|
|
362
|
+
new inquirer.Separator('----------------------------------'),
|
|
353
363
|
'1.Address List',
|
|
354
364
|
'2.Expand Address',
|
|
355
365
|
'3.Slice Address',
|
|
356
366
|
'4.Disable Address',
|
|
357
367
|
'5.Reset Account Password',
|
|
358
368
|
`6.Switch Networks [${account_info.default_network}]`,
|
|
359
|
-
|
|
369
|
+
|
|
360
370
|
];
|
|
361
371
|
} else {
|
|
362
372
|
account_manager_options = [
|
|
373
|
+
'> Back',
|
|
374
|
+
new inquirer.Separator('----------------------------------'),
|
|
363
375
|
'1.Address List',
|
|
364
376
|
'2.Reset Account Password',
|
|
365
377
|
`3.Switch Networks [${account_info.default_network}]`,
|
|
366
|
-
'> Back'
|
|
367
378
|
];
|
|
368
379
|
}
|
|
369
380
|
|
|
@@ -445,7 +456,8 @@ const accountManager = async (keystore_path: string, account_label: string, wati
|
|
|
445
456
|
const showPPAccounts = async (keystore_path: string, account_label: string, wative_core: typeof WativeCore) => {
|
|
446
457
|
const account_info = await getAccountInfo(keystore_path, account_label);
|
|
447
458
|
let option_accounts: any = [
|
|
448
|
-
'> Back'
|
|
459
|
+
'> Back',
|
|
460
|
+
new inquirer.Separator('----------------------------------'),
|
|
449
461
|
];
|
|
450
462
|
|
|
451
463
|
let disabled_slots = account_info.disabled_slots;
|
|
@@ -485,11 +497,11 @@ const showPPAccounts = async (keystore_path: string, account_label: string, wati
|
|
|
485
497
|
}
|
|
486
498
|
|
|
487
499
|
let selected_account = await selectSomething(option_accounts, "Select an account");
|
|
488
|
-
if (selected_account ===
|
|
500
|
+
if (selected_account === '> Back') {
|
|
489
501
|
return;
|
|
490
502
|
}
|
|
491
503
|
|
|
492
|
-
let selected_account_id = option_accounts.indexOf(selected_account) -
|
|
504
|
+
let selected_account_id = option_accounts.indexOf(selected_account) - 2;
|
|
493
505
|
|
|
494
506
|
await showPPAccountDetail(keystore_path, account_label, selected_account_id, wative_core);
|
|
495
507
|
await showPPAccounts(keystore_path, account_label, wative_core);
|
|
@@ -521,18 +533,19 @@ const showPPAccountDetail = async (keystore_path: string, account_label: string,
|
|
|
521
533
|
);
|
|
522
534
|
}
|
|
523
535
|
|
|
524
|
-
let tag =
|
|
536
|
+
let tag = '> Tag()';
|
|
525
537
|
if ("tag" in account_info.data[selected_account_id] && account_info.data[selected_account_id].tag !== "") {
|
|
526
538
|
tag = `> Tag(${account_info.data[selected_account_id].tag})`;
|
|
527
539
|
}
|
|
528
540
|
|
|
529
541
|
let options_account_detail = [
|
|
542
|
+
'> Back',
|
|
543
|
+
new inquirer.Separator('----------------------------------'),
|
|
530
544
|
tag,
|
|
531
545
|
'> Switch network',
|
|
532
546
|
'> Assets',
|
|
533
547
|
'> Tools',
|
|
534
|
-
'> Dump private key'
|
|
535
|
-
'> Back'
|
|
548
|
+
'> Dump private key'
|
|
536
549
|
];
|
|
537
550
|
|
|
538
551
|
let selected_account_detail = await selectSomething(options_account_detail);
|
|
@@ -577,7 +590,8 @@ const showPPAccountDetail = async (keystore_path: string, account_label: string,
|
|
|
577
590
|
const showPKAccounts = async (keystore_path: string, account_label: string, wative_core: typeof WativeCore) => {
|
|
578
591
|
const account_info = await getAccountInfo(keystore_path, account_label);
|
|
579
592
|
let option_accounts = [
|
|
580
|
-
'> Back'
|
|
593
|
+
'> Back',
|
|
594
|
+
new inquirer.Separator('----------------------------------')
|
|
581
595
|
];
|
|
582
596
|
|
|
583
597
|
let tag = "";
|
|
@@ -587,7 +601,7 @@ const showPKAccounts = async (keystore_path: string, account_label: string, wati
|
|
|
587
601
|
|
|
588
602
|
option_accounts.push(`#0 ${account_info.ciphertexts.address} ${tag} [${account_info.default_network}]`);
|
|
589
603
|
let selected_account = await selectSomething(option_accounts, "Select an account");
|
|
590
|
-
if (selected_account ===
|
|
604
|
+
if (selected_account === '> Back') {
|
|
591
605
|
return;
|
|
592
606
|
}
|
|
593
607
|
|
|
@@ -604,18 +618,19 @@ const showPKAccounts = async (keystore_path: string, account_label: string, wati
|
|
|
604
618
|
|
|
605
619
|
const showPKAccountDetail = async (keystore_path: string, account_label: string, wative_core: typeof WativeCore) => {
|
|
606
620
|
const account_info = await getAccountInfo(keystore_path, account_label);
|
|
607
|
-
let tag =
|
|
621
|
+
let tag = '> Tag()';
|
|
608
622
|
if ("tag" in account_info && account_info.tag !== "") {
|
|
609
623
|
tag = `> Tag(${account_info.tag})`;
|
|
610
624
|
}
|
|
611
625
|
|
|
612
626
|
let options_account_detail = [
|
|
627
|
+
'> Back',
|
|
628
|
+
new inquirer.Separator('----------------------------------'),
|
|
613
629
|
tag,
|
|
614
630
|
'> Switch network',
|
|
615
631
|
'> Assets',
|
|
616
632
|
'> Tools',
|
|
617
633
|
'> Dump private key',
|
|
618
|
-
'> Back'
|
|
619
634
|
];
|
|
620
635
|
|
|
621
636
|
let selected_account_detail = await selectSomething(options_account_detail);
|
|
@@ -696,11 +711,24 @@ export const accountSetting = async (keystore_path: string, wative_core: typeof
|
|
|
696
711
|
fs.mkdirSync(account_path);
|
|
697
712
|
}
|
|
698
713
|
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
714
|
+
const networks = getNetworkInfo(keystore_path);
|
|
715
|
+
const account_label_list = networks.accounts;
|
|
716
|
+
|
|
717
|
+
let account_setting_options: any[];
|
|
718
|
+
if (account_label_list.length === 0) {
|
|
719
|
+
account_setting_options = [
|
|
720
|
+
'> Back',
|
|
721
|
+
new inquirer.Separator('----------------------------------'),
|
|
722
|
+
'> Create a new account'
|
|
723
|
+
];
|
|
724
|
+
} else {
|
|
725
|
+
account_setting_options = [
|
|
726
|
+
'> Back',
|
|
727
|
+
new inquirer.Separator('----------------------------------'),
|
|
728
|
+
'> Select an account',
|
|
729
|
+
'> Create a new account'
|
|
730
|
+
];
|
|
731
|
+
}
|
|
704
732
|
|
|
705
733
|
let selected_account_setting = await selectSomething(account_setting_options);
|
|
706
734
|
|
package/src/assets.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { isEvmAddress, isSolanaAddress } from "./chain";
|
|
|
6
6
|
import { getNetworkInfoByName, getNetworkTypeByName } from "./network";
|
|
7
7
|
import { chainAddressValidator, checkFileExistence, inputSomething, selectSomething } from "./utils";
|
|
8
8
|
import { getTokenBalanceInEvm, getTokenBalanceInSolana, getTokenInfoInEvm, getTokenInfoInSolana } from './web3';
|
|
9
|
+
import inquirer from "inquirer";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
// symbol; name; address; decimals
|
|
@@ -157,22 +158,23 @@ export const showAssets = async (
|
|
|
157
158
|
default_network: string
|
|
158
159
|
) => {
|
|
159
160
|
const options_assets_list = [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
'> Back',
|
|
162
|
+
new inquirer.Separator('----------------------------------'),
|
|
163
|
+
'> Show Assets',
|
|
164
|
+
'> Add Asset'
|
|
163
165
|
];
|
|
164
166
|
|
|
165
167
|
const selected_option = await selectSomething(options_assets_list);
|
|
166
168
|
switch (selected_option) {
|
|
167
|
-
case
|
|
169
|
+
case '> Show Assets': {
|
|
168
170
|
await showAssetsDetail(keystore_path, default_network, account_address);
|
|
169
171
|
break;
|
|
170
172
|
}
|
|
171
|
-
case
|
|
173
|
+
case '> Add Asset': {
|
|
172
174
|
await addAsset(keystore_path, default_network);
|
|
173
175
|
break;
|
|
174
176
|
}
|
|
175
|
-
case
|
|
177
|
+
case '> Back': {
|
|
176
178
|
return;
|
|
177
179
|
}
|
|
178
180
|
}
|
package/src/network.ts
CHANGED
|
@@ -39,28 +39,28 @@ export const createNetwork = async (keystore_path: string) => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export const selectOrEditNetwork = async (keystore_path: string, selected_network: any) => {
|
|
42
|
-
let options:
|
|
43
|
-
|
|
42
|
+
let options: any[] = [
|
|
43
|
+
'> Back',
|
|
44
|
+
new inquirer.Separator('----------------------------------'),
|
|
45
|
+
'> Edit'
|
|
44
46
|
];
|
|
45
47
|
|
|
46
48
|
if (selected_network.name !== "Ethereum Mainnet" && selected_network.name !== "Solana Mainnet") {
|
|
47
|
-
options.push(
|
|
49
|
+
options.push('> Remove');
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
options.push("> Back");
|
|
51
|
-
|
|
52
52
|
const selected_network_info = await selectSomething(options);
|
|
53
53
|
|
|
54
54
|
switch (selected_network_info) {
|
|
55
|
-
case
|
|
55
|
+
case '> Edit': {
|
|
56
56
|
await updateNetwork(keystore_path, selected_network);
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
|
-
case
|
|
59
|
+
case '> Remove': {
|
|
60
60
|
await removeNetwork(keystore_path, selected_network);
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
|
-
case
|
|
63
|
+
case '> Back': {
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -229,7 +229,7 @@ export const showAvailableNetworks = async (keystore_path: string) => {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
let options: any = [
|
|
232
|
+
let options: any = ['> Back', new inquirer.Separator(`----Networks(evm)----`)];
|
|
233
233
|
|
|
234
234
|
for (let i = 0; i < evm_ids.length; i++) {
|
|
235
235
|
const evm_id = evm_ids[i];
|
|
@@ -257,7 +257,7 @@ export const showAvailableNetworks = async (keystore_path: string) => {
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
const selected_option = await selectSomething(options);
|
|
260
|
-
if (selected_option ===
|
|
260
|
+
if (selected_option === '> Back') {
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
263
|
|
|
@@ -275,23 +275,24 @@ export const showAvailableNetworks = async (keystore_path: string) => {
|
|
|
275
275
|
|
|
276
276
|
export const showNetwork = async (keystore_path: string) => {
|
|
277
277
|
let network_info_list = [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
'> Back',
|
|
279
|
+
new inquirer.Separator('----------------------------------'),
|
|
280
|
+
'> Available Networks',
|
|
281
|
+
'> Add Network'
|
|
281
282
|
];
|
|
282
283
|
|
|
283
284
|
const selected_network_info = await selectSomething(network_info_list);
|
|
284
285
|
|
|
285
286
|
switch (selected_network_info) {
|
|
286
|
-
case
|
|
287
|
+
case '> Available Networks': {
|
|
287
288
|
await showAvailableNetworks(keystore_path);
|
|
288
289
|
break;
|
|
289
290
|
}
|
|
290
|
-
case
|
|
291
|
+
case '> Add Network': {
|
|
291
292
|
await addNetwork(keystore_path);
|
|
292
293
|
break;
|
|
293
294
|
}
|
|
294
|
-
case
|
|
295
|
+
case '> Back': {
|
|
295
296
|
return;
|
|
296
297
|
}
|
|
297
298
|
}
|
|
@@ -368,7 +369,8 @@ export const switchPPNetwork = async (keystore_path: string, account_label: stri
|
|
|
368
369
|
|
|
369
370
|
let account_info = getAccountInfo(keystore_path, account_label);
|
|
370
371
|
let options_switch_network = [
|
|
371
|
-
|
|
372
|
+
'> Back',
|
|
373
|
+
new inquirer.Separator('----------------------------------')
|
|
372
374
|
];
|
|
373
375
|
|
|
374
376
|
let default_network = account_info.data[account_id].default_network;
|
|
@@ -396,15 +398,15 @@ export const switchPPNetwork = async (keystore_path: string, account_label: stri
|
|
|
396
398
|
|
|
397
399
|
const selected_network = await selectSomething(options_switch_network);
|
|
398
400
|
|
|
399
|
-
if (selected_network ===
|
|
401
|
+
if (selected_network === '> Back') {
|
|
400
402
|
return;
|
|
401
403
|
}
|
|
402
404
|
|
|
403
405
|
let selected_network_id = options_switch_network.indexOf(selected_network);
|
|
404
|
-
if (selected_network_id ===
|
|
406
|
+
if (selected_network_id === 2) {
|
|
405
407
|
delete account_info.data[account_id].default_network;
|
|
406
408
|
} else {
|
|
407
|
-
account_info.data[account_id].default_network = network_list[selected_network_id -
|
|
409
|
+
account_info.data[account_id].default_network = network_list[selected_network_id - 3].name;
|
|
408
410
|
}
|
|
409
411
|
|
|
410
412
|
saveAccountInfo(keystore_path, account_label, account_info);
|
|
@@ -428,7 +430,8 @@ export const switchNetworkByAccountLabel = async (keystore_path: string, account
|
|
|
428
430
|
|
|
429
431
|
let account_info = getAccountInfo(keystore_path, account_label);
|
|
430
432
|
let options_switch_network = [
|
|
431
|
-
|
|
433
|
+
'> Back',
|
|
434
|
+
new inquirer.Separator('----------------------------------'),
|
|
432
435
|
];
|
|
433
436
|
|
|
434
437
|
let default_network = account_info.default_network;
|
|
@@ -464,12 +467,12 @@ export const switchNetworkByAccountLabel = async (keystore_path: string, account
|
|
|
464
467
|
}
|
|
465
468
|
|
|
466
469
|
const selected_network = await selectSomething(options_switch_network);
|
|
467
|
-
if (selected_network ===
|
|
470
|
+
if (selected_network === '> Back') {
|
|
468
471
|
return;
|
|
469
472
|
}
|
|
470
473
|
|
|
471
474
|
let selected_network_id = options_switch_network.indexOf(selected_network);
|
|
472
|
-
account_info.default_network = option_network_name_list[selected_network_id -
|
|
475
|
+
account_info.default_network = option_network_name_list[selected_network_id - 2];
|
|
473
476
|
saveAccountInfo(keystore_path, account_label, account_info);
|
|
474
477
|
|
|
475
478
|
if (!is_account_label) {
|
package/src/tools.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
|
|
17
17
|
const { WativeCore } = require("wative-core");
|
|
18
18
|
|
|
19
|
-
const confirmEvmRawTransaction = async (tx_params: any) => {
|
|
19
|
+
const confirmEvmRawTransaction = async (tx_params: any): Promise<any> => {
|
|
20
20
|
let option_send_evm_raw_transaction_list: any = [
|
|
21
21
|
new inquirer.Separator("————Tx Detail—————-"),
|
|
22
22
|
`from: ${tx_params.from}`,
|
|
@@ -59,7 +59,7 @@ const confirmEvmRawTransaction = async (tx_params: any) => {
|
|
|
59
59
|
return tx_params;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
await confirmEvmRawTransaction(tx_params);
|
|
62
|
+
return await confirmEvmRawTransaction(tx_params);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
const sendEvmRawTransaction = async (chain_rpc_url: string, chain_symbols: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
@@ -99,7 +99,7 @@ const sendEvmRawTransaction = async (chain_rpc_url: string, chain_symbols: strin
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
let option_select_vaule_list: any = [
|
|
102
|
-
|
|
102
|
+
'> Input value',
|
|
103
103
|
`> Total Balance (${total_balance} ${chain_symbols})`
|
|
104
104
|
]
|
|
105
105
|
let selected_vaule = await selectSomething(option_select_vaule_list);
|
|
@@ -228,7 +228,7 @@ export const sendSolanaRawTransaction = async (chain_rpc_url: string, chain_symb
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
let option_select_vaule_list: any = [
|
|
231
|
-
|
|
231
|
+
'> Input value',
|
|
232
232
|
`> Total Balance (${total_balance} ${chain_symbols})`
|
|
233
233
|
]
|
|
234
234
|
let selected_vaule = await selectSomething(option_select_vaule_list);
|
|
@@ -283,15 +283,15 @@ export const sendSolanaRawTransaction = async (chain_rpc_url: string, chain_symb
|
|
|
283
283
|
|
|
284
284
|
const sendEvmTokenTransaction = async (keystore_path: string, chain_rpc_url: string, chain_id: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
285
285
|
const option_token_address_list = [
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
'> Input token ticker',
|
|
287
|
+
'> Input token contract address'
|
|
288
288
|
];
|
|
289
289
|
let selected_token_address = await selectSomething(option_token_address_list);
|
|
290
290
|
|
|
291
291
|
let token_address: any;
|
|
292
292
|
let token_decimals: any;
|
|
293
293
|
switch (selected_token_address) {
|
|
294
|
-
case
|
|
294
|
+
case '> Input token ticker':
|
|
295
295
|
let token_name = await inputSomething("token ticker");
|
|
296
296
|
|
|
297
297
|
let token_address_list = await getAssetListByTokenName(keystore_path, chain_id, token_name);
|
|
@@ -329,7 +329,7 @@ const sendEvmTokenTransaction = async (keystore_path: string, chain_rpc_url: str
|
|
|
329
329
|
token_address = token_ticker_info.address;
|
|
330
330
|
token_decimals = Number(token_ticker_info.decimals);
|
|
331
331
|
break;
|
|
332
|
-
case
|
|
332
|
+
case '> Input token contract address':
|
|
333
333
|
token_address = await inputSomething("token contract address", chainAddressValidator);
|
|
334
334
|
let token_info: any = await getTokenInfoInEvm(token_address, chain_rpc_url);
|
|
335
335
|
if (!token_info.status) {
|
|
@@ -404,15 +404,15 @@ const sendEvmTokenTransaction = async (keystore_path: string, chain_rpc_url: str
|
|
|
404
404
|
|
|
405
405
|
const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url: string, chain_id: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
406
406
|
const option_token_address_list = [
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
'> Input token ticker',
|
|
408
|
+
'> Input token contract address'
|
|
409
409
|
];
|
|
410
410
|
let selected_token_address = await selectSomething(option_token_address_list);
|
|
411
411
|
|
|
412
412
|
let token_address: any;
|
|
413
413
|
let token_decimals: any;
|
|
414
414
|
switch (selected_token_address) {
|
|
415
|
-
case
|
|
415
|
+
case '> Input token ticker':
|
|
416
416
|
let token_name = await inputSomething("token ticker");
|
|
417
417
|
|
|
418
418
|
let token_address_list = await getAssetListByTokenName(keystore_path, chain_id, token_name);
|
|
@@ -450,7 +450,7 @@ const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url:
|
|
|
450
450
|
token_address = token_ticker_info.address;
|
|
451
451
|
token_decimals = Number(token_ticker_info.decimals);
|
|
452
452
|
break;
|
|
453
|
-
case
|
|
453
|
+
case '> Input token contract address':
|
|
454
454
|
token_address = await inputSomething("token contract address", chainAddressValidator);
|
|
455
455
|
let token_info: any = await getTokenInfoInSolana(token_address, chain_rpc_url);
|
|
456
456
|
if (!token_info.status) {
|
|
@@ -638,15 +638,16 @@ const excuteTools = async (keystore_path: string, account_label: string, account
|
|
|
638
638
|
);
|
|
639
639
|
|
|
640
640
|
const option_send_tx = [
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
641
|
+
'> Back',
|
|
642
|
+
new inquirer.Separator('----------------------------------'),
|
|
643
|
+
'> Send Raw Tx',
|
|
644
|
+
'> Send Token'
|
|
644
645
|
];
|
|
645
646
|
|
|
646
647
|
const selected_send_tx = await selectSomething(option_send_tx);
|
|
647
648
|
|
|
648
649
|
switch (selected_send_tx) {
|
|
649
|
-
case
|
|
650
|
+
case '> Send Raw Tx': {
|
|
650
651
|
if (account_chain_type === "evm") {
|
|
651
652
|
await sendEvmRawTransaction(
|
|
652
653
|
network_info.rpcUrl,
|
|
@@ -666,7 +667,7 @@ const excuteTools = async (keystore_path: string, account_label: string, account
|
|
|
666
667
|
}
|
|
667
668
|
break;
|
|
668
669
|
}
|
|
669
|
-
case
|
|
670
|
+
case '> Send Token': {
|
|
670
671
|
if (account_chain_type === "evm") {
|
|
671
672
|
await sendEvmTokenTransaction(
|
|
672
673
|
keystore_path,
|
|
@@ -688,7 +689,7 @@ const excuteTools = async (keystore_path: string, account_label: string, account
|
|
|
688
689
|
}
|
|
689
690
|
break;
|
|
690
691
|
}
|
|
691
|
-
case
|
|
692
|
+
case '> Back': {
|
|
692
693
|
return;
|
|
693
694
|
}
|
|
694
695
|
}
|
|
@@ -696,18 +697,19 @@ const excuteTools = async (keystore_path: string, account_label: string, account
|
|
|
696
697
|
|
|
697
698
|
export const selectToolsOptions = async (keystore_path: string, account_label: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
698
699
|
const tools_options = [
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
700
|
+
'> Back',
|
|
701
|
+
new inquirer.Separator('----------------------------------'),
|
|
702
|
+
'> SendTx',
|
|
703
|
+
'> SignMessage'
|
|
702
704
|
];
|
|
703
705
|
|
|
704
706
|
const selected_tools_option = await selectSomething(tools_options);
|
|
705
707
|
switch (selected_tools_option) {
|
|
706
|
-
case
|
|
708
|
+
case '> SendTx': {
|
|
707
709
|
await excuteTools(keystore_path, account_label, account_address, wative_core);
|
|
708
710
|
break;
|
|
709
711
|
}
|
|
710
|
-
case
|
|
712
|
+
case '> SignMessage': {
|
|
711
713
|
const message = await editorSomething("Input the message to sign");
|
|
712
714
|
const signed_message = wative_core.account.signMessage(account_address, message);
|
|
713
715
|
if (!signed_message.status) {
|
|
@@ -719,7 +721,7 @@ export const selectToolsOptions = async (keystore_path: string, account_label: s
|
|
|
719
721
|
);
|
|
720
722
|
break;
|
|
721
723
|
}
|
|
722
|
-
case
|
|
724
|
+
case '> Back': {
|
|
723
725
|
return;
|
|
724
726
|
}
|
|
725
727
|
}
|
package/src/utils.ts
CHANGED
|
@@ -400,7 +400,7 @@ export const editorSomething = async (text: string, validate_func?: Function) =>
|
|
|
400
400
|
|
|
401
401
|
export const hexValidator = function (value: string) {
|
|
402
402
|
let reg = /^0x[0-9a-fA-F]*$/g;
|
|
403
|
-
if (reg.test(value)) {
|
|
403
|
+
if (reg.test(value.trim())) {
|
|
404
404
|
return true;
|
|
405
405
|
} else {
|
|
406
406
|
return false;
|