wative 1.0.19 → 1.0.21

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/src/account.ts CHANGED
@@ -23,6 +23,7 @@ import { selectToolsOptions } from './tools';
23
23
  import inquirer from "inquirer";
24
24
  import { getChainType } from "./chain";
25
25
 
26
+ require("dotenv").config();
26
27
  const cliProgress = require('cli-progress');
27
28
  const { WativeCore } = require("wative-core");
28
29
 
@@ -240,7 +241,12 @@ export const loginIn = async (account_label: string, wative_core: typeof WativeC
240
241
  }
241
242
 
242
243
  for (let i = 0; i < 3; i++) {
243
- const password = await inputPassword(`Please input the password for Account [${account_label}]`);
244
+ let password: any;
245
+ if (process.env.WativePassword && process.env.WativePassword !== '') {
246
+ password = process.env.WativePassword;
247
+ } else {
248
+ password = await inputPassword(`Please input the password for Account [${account_label}]`);
249
+ }
244
250
  if (!password) {
245
251
  console.log(
246
252
  chalk.red("Password can't be empty")
@@ -552,6 +558,7 @@ const showAccounts = async (keystore_path: string, account_label: string, wative
552
558
  let network_info = getNetworkInfoByName(keystore_path, default_network);
553
559
  let network_type = getChainType(network_info.chainId.toString());
554
560
 
561
+ let pad_index = account_info.data.length.toString().length + 1;
555
562
  for (let i = 0; i < account_info.data.length; i++) {
556
563
  let tag = account_info.data[i].tag ? `(${account_info.data[i].tag})` : "";
557
564
  let is_disable_address = wative_core.account.checkIsDisableAddress(disabled_slots, i);
@@ -569,10 +576,10 @@ const showAccounts = async (keystore_path: string, account_label: string, wative
569
576
 
570
577
  if (is_disable_address) {
571
578
  option_accounts.push(
572
- new inquirer.Separator(chalk.yellow(`#${i} ${formatAddr(account_address, status.fullAddr)} ${tag}`))
579
+ new inquirer.Separator(chalk.yellow(`#${i.toString().padEnd(pad_index)} ${formatAddr(account_address, status.fullAddr)} ${tag}`))
573
580
  )
574
581
  } else {
575
- option_accounts.push(`#${i} ${formatAddr(account_address, status.fullAddr)} ${tag}`);
582
+ option_accounts.push(`#${i.toString().padEnd(pad_index)} ${formatAddr(account_address, status.fullAddr)} ${tag}`);
576
583
  }
577
584
  }
578
585
 
@@ -646,11 +653,11 @@ const showAccountDetail = async (keystore_path: string, account_label: string, s
646
653
 
647
654
  switch (selected_account_detail) {
648
655
  case tag: {
649
- let cureent_tag = 'Current tag';
656
+ let current_tag = 'Current tag';
650
657
  if ("tag" in account_info.data[selected_account_id] && account_info.data[selected_account_id].tag !== "") {
651
- cureent_tag = `Current tag (${account_info.data[selected_account_id].tag})`;
658
+ current_tag = `Current tag (${account_info.data[selected_account_id].tag})`;
652
659
  }
653
- let tag = await inputSomething(cureent_tag, tagValidator);
660
+ let tag = await inputSomething(current_tag, tagValidator);
654
661
  tag = tag.replace(/\s+/g, " ").trim();
655
662
  account_info.data[selected_account_id].tag = tag.toLocaleLowerCase();
656
663
  saveAccountInfo(keystore_path, account_label, account_info);
package/src/assets.ts CHANGED
@@ -3,7 +3,7 @@ import * as path from "path";
3
3
  import * as fs from 'fs';
4
4
  import { BigNumber } from 'bignumber.js';
5
5
  import { getChainType, isEvmAddress, isSolanaAddress } from "./chain";
6
- import { getNetworkInfoByName, getNetworkTypeByName } from "./network";
6
+ import { getNetworkInfoByName, getNetworkTypeByName, getShowTokenList } from "./network";
7
7
  import { chainAddressValidator, checkFileExistence, inputSomething, numberValidator, selectSomething } from "./utils";
8
8
  import { deleteTokenBalance, getTokenBalance, getTokenBalanceInEvm, getTokenBalanceInSolana, getTokenInfoInEvm, getTokenInfoInSolana, updateBalance } from './web3';
9
9
  import inquirer from "inquirer";
@@ -36,7 +36,7 @@ export const getAssetListByTokenName = async (
36
36
  const asset_list = await getAssetList(keystore_path, chain_id);
37
37
  let token_address_list: any = [];
38
38
  for (let i = 0; i < asset_list.length; i++) {
39
- if (asset_list[i].symbol === token_name) {
39
+ if (asset_list[i].symbol.toLocaleLowerCase() === token_name.toLocaleLowerCase()) {
40
40
  token_address_list.push(asset_list[i]);
41
41
  }
42
42
  }
@@ -102,7 +102,10 @@ export const saveAsset = async (
102
102
  }
103
103
 
104
104
  for (let i = 0; i < assets_mapping[chain_id].length; i++) {
105
- if (assets_mapping[chain_id][i].address === asset_address) {
105
+ if (
106
+ assets_mapping[chain_id][i].address.toLocaleLowerCase() === asset_address.toLocaleLowerCase() ||
107
+ assets_mapping[chain_id][i].symbol.toLocaleLowerCase() === symbol.toLocaleLowerCase()
108
+ ) {
106
109
  assets_mapping[chain_id][i] = {
107
110
  address: asset_address,
108
111
  symbol,
@@ -172,7 +175,7 @@ export const addToken = async (
172
175
  }
173
176
 
174
177
  console.log(
175
- chalk.green(`Token ${token_info_result.output.name} loaded successfully.`)
178
+ chalk.green(`Token ${token_info_result.output.symbol}(${token_info_result.output.name}) loaded successfully.`)
176
179
  );
177
180
 
178
181
  let display_decimals = await inputSomething("Enter decimals for display", numberValidator);
@@ -224,7 +227,7 @@ export const addAsset = async (
224
227
  }
225
228
 
226
229
  console.log(
227
- chalk.green(`Token ${token_info_result.output.name} loaded successfully.`)
230
+ chalk.green(`Token ${token_info_result.output.symbol}(${token_info_result.output.name}) loaded successfully.`)
228
231
  );
229
232
 
230
233
  let display_decimals = await inputSomething("Enter decimals for display", numberValidator);
@@ -355,9 +358,15 @@ export const getBatchAccountBalance = async (
355
358
  }
356
359
 
357
360
  if (show_extended_token) {
361
+ let showTokenList = getShowTokenList(keystore_path, network_name);
362
+
358
363
  for (let i = 0; i < asset_info_list_len; i++) {
359
364
  let asset_info = asset_info_list[i];
360
365
  let token_address = asset_info.address;
366
+ if (!showTokenList.includes(token_address)) {
367
+ continue;
368
+ }
369
+
361
370
  await updateBalance(
362
371
  account_address_list,
363
372
  token_address,
package/src/network.ts CHANGED
@@ -13,9 +13,9 @@ import {
13
13
  getSymbol,
14
14
  getColor,
15
15
  Result,
16
- getAccountChainType,
17
16
  formatAddr,
18
- checkFileExistence
17
+ checkFileExistence,
18
+ selectCheckboxSomething
19
19
  } from "./utils";
20
20
  import {
21
21
  getAccountInfo,
@@ -362,6 +362,18 @@ export const selectFlag = async () => {
362
362
  }
363
363
  }
364
364
 
365
+ export const getShowTokenList = (keystore_path: string, chain_name: string) => {
366
+ const network_path = path.resolve(keystore_path, 'network.json');
367
+ const networks = JSON.parse(fs.readFileSync(network_path, 'utf8'));
368
+
369
+ let showTokensMap = networks.showTokens;
370
+ if (chain_name in showTokensMap) {
371
+ return showTokensMap[chain_name];
372
+ }
373
+
374
+ return [];
375
+ }
376
+
365
377
  export const showTokenList = async (keystore_path: string) => {
366
378
  const network_path = path.resolve(keystore_path, 'network.json');
367
379
  const networks = JSON.parse(fs.readFileSync(network_path, 'utf8'));
@@ -381,16 +393,48 @@ export const showTokenList = async (keystore_path: string) => {
381
393
 
382
394
  const assets = JSON.parse(fs.readFileSync(assets_path, 'utf8'));
383
395
 
396
+ let options: any = [];
397
+ let default_options: any = [];
398
+ let option_info_map: any = {};
384
399
  for (let chain_id in assets) {
385
- console.log(`----- Networks (${network_settings_map[chain_id]}) -------`);
386
-
400
+ option_info_map[options.length] = {
401
+ name: network_settings_map[chain_id],
402
+ address: null
403
+ };
404
+ options.push(new inquirer.Separator(`----- Networks (${network_settings_map[chain_id]}) -------`));
405
+ let show_token_list: any = getShowTokenList(keystore_path, network_settings_map[chain_id]);
387
406
  let token_list_len = assets[chain_id].length;
388
407
  for (let i = 0; i < token_list_len; i++) {
389
408
  let token_info = assets[chain_id][i];
390
- console.log(`${i + 1}.${token_info.symbol} CA: ${chalk.green(`${formatAddr(token_info.address)}`)
409
+ if (show_token_list.includes(token_info.address)) {
410
+ default_options.push(`${i + 1}.${token_info.symbol.padEnd(6)} CA: ${chalk.green(`${formatAddr(token_info.address).padEnd(45)}`)
411
+ } Decimals: ${token_info.display_decimals ? token_info.display_decimals : "4"}`);
412
+ }
413
+
414
+ option_info_map[options.length] = {
415
+ name: network_settings_map[chain_id],
416
+ address: token_info.address
417
+ };
418
+ options.push(`${i + 1}.${token_info.symbol.padEnd(6)} CA: ${chalk.green(`${formatAddr(token_info.address).padEnd(45)}`)
391
419
  } Decimals: ${token_info.display_decimals ? token_info.display_decimals : "4"}`);
392
420
  }
393
421
  }
422
+
423
+ let selected_option = await selectCheckboxSomething(options, "Choose Tokens", default_options);
424
+ let show_token_list_map: any = {};
425
+ for (let i = 0; i < selected_option.length; i++) {
426
+ let _option = selected_option[i];
427
+ let option_index = options.indexOf(_option);
428
+ let option_info = option_info_map[option_index];
429
+ if (option_info.name in show_token_list_map) {
430
+ show_token_list_map[option_info.name].push(option_info.address);
431
+ } else {
432
+ show_token_list_map[option_info.name] = [option_info.address];
433
+ }
434
+ }
435
+
436
+ networks.showTokens = show_token_list_map;
437
+ fs.writeFileSync(network_path, JSON.stringify(networks, null, 2));
394
438
  }
395
439
 
396
440
  export const enhancedBalanceDisplay = async (keystore_path: string) => {
package/src/tools.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  const chalk = require('chalk');
2
2
  import { BigNumber } from 'bignumber.js';
3
3
  import inquirer from 'inquirer';
4
- import { addrValidator, chainAddressValidator, confirmSomething, editorSomething, getAccountChainType, hexValidator, inputSomething, numberValidator, selectSomething } from "./utils";
4
+ import { addrValidator, chainAddressValidator, confirmSomething, editorSomething, gasValidator, getAccountChainType, hexValidator, inputSomething, numberValidator, selectSomething } from "./utils";
5
5
  import { loginIn } from './account';
6
6
  import { getAccountBalance, getDefaultNetworkByAddress, getEvmNetworks, getNetworkInfoByName, getNetworkTypeByName } from './network';
7
7
  import { GasUtil } from './tx_gas_utils';
@@ -68,7 +68,7 @@ const sendEvmRawTransaction = async (chain_id: string, chain_rpc_url: string, ch
68
68
  const estimateGasPrice = await gasUtil.getGasPrice();
69
69
  const estimateGasPriceEthers = (new BigNumber(estimateGasPrice.toString())).dividedBy(1e9);
70
70
  const _estimateGasPrice = estimateGasPriceEthers.toFixed(4, BigNumber.ROUND_FLOOR);
71
- const inputGasPrice = await inputSomething(`Gas price (${_estimateGasPrice}), agree or enter`);
71
+ const inputGasPrice = await inputSomething(`Gas price (${_estimateGasPrice}), agree or enter`, gasValidator);
72
72
  let gasPrice = inputGasPrice ? inputGasPrice : _estimateGasPrice;
73
73
  gasPrice = (new BigNumber(gasPrice)).multipliedBy(1e9).toFixed(0);
74
74
 
@@ -104,24 +104,6 @@ const sendEvmRawTransaction = async (chain_id: string, chain_rpc_url: string, ch
104
104
  chain_symbols,
105
105
  18
106
106
  );
107
-
108
- // let option_select_value_list: any = [
109
- // '> Input value',
110
- // `> Total Balance (${total_balance} ${chain_symbols})`
111
- // ]
112
- // let selected_value = await selectSomething(option_select_value_list);
113
- // let value_id = option_select_value_list.indexOf(selected_value);
114
- // if (value_id === 0) {
115
- // let input_value = await inputSomething("value", numberValidator);
116
- // value = new BigNumber(input_value).multipliedBy(1e18).toFixed(0, BigNumber.ROUND_FLOOR);
117
- // } else if (value_id === 1) {
118
- // value = max_value;
119
- // }
120
-
121
- // if ((new BigNumber(value)).isGreaterThan(new BigNumber(max_value))) {
122
- // console.log(chalk.red("Not enough balance"));
123
- // return;
124
- // }
125
107
  } else {
126
108
  data = await editorSomething("data", hexValidator);
127
109
  value = await inputSomething("value", numberValidator);
@@ -202,16 +184,12 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
202
184
  );
203
185
 
204
186
  transaction.feePayer = new PublicKey(account_address);
205
- console.log(account_address);
206
- console.log(chain_rpc_url)
207
- console.log(transaction);
208
187
  const simulate_result = await wative_core.account.simulateTransaction(
209
188
  account_address,
210
189
  chain_rpc_url,
211
190
  transaction
212
191
  );
213
192
 
214
- console.log(simulate_result);
215
193
  if (!simulate_result.status) {
216
194
  console.log(chalk.red(simulate_result.output));
217
195
  return;
@@ -224,25 +202,23 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
224
202
 
225
203
  let baseUnitsConsumed = new BigNumber(simulate_result.output.value.unitsConsumed.toString()).multipliedBy(1.2).toFixed(0, BigNumber.ROUND_CEIL);
226
204
  let unitsConsumed = new BigNumber(baseUnitsConsumed);
227
- // const prioritization_fee_result = await getPrioritizationFee(chain_rpc_url);
228
- // if (!prioritization_fee_result.status) {
229
- // console.log(chalk.red(prioritization_fee_result.output));
230
- // return;
231
- // }
232
-
233
- // const prioritization_fee = new BigNumber(prioritization_fee_result.output.toString());
234
- const prioritization_fee = new BigNumber(1000);
205
+ const prioritization_fee_result = await getPrioritizationFee(chain_rpc_url);
206
+ if (!prioritization_fee_result.status) {
207
+ console.log(chalk.red(prioritization_fee_result.output));
208
+ return;
209
+ }
210
+
211
+ const prioritization_fee = new BigNumber(prioritization_fee_result.output.toString());
235
212
  const used_prioritization_fee = unitsConsumed.multipliedBy(prioritization_fee).dividedBy(1e6).toFixed(0, BigNumber.ROUND_CEIL);
236
213
 
237
214
  const account_balance_result = await getAccountBalanceInSolana(account_address, chain_rpc_url);
238
- console.log(account_balance_result);
239
215
  if (!account_balance_result.status) {
240
216
  console.log(chalk.red(account_balance_result.output));
241
217
  return;
242
218
  }
243
219
 
244
220
  const account_balance = new BigNumber(account_balance_result.output);
245
-
221
+
246
222
  const max_value = account_balance.minus(5000).minus(used_prioritization_fee);
247
223
  let total_balance = (new BigNumber(max_value)).dividedBy(1e9).toFixed(4, BigNumber.ROUND_FLOOR);
248
224
  if (new BigNumber(total_balance) < new BigNumber(0)) {
@@ -256,23 +232,6 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
256
232
  chain_symbols,
257
233
  9
258
234
  );
259
- // let option_select_value_list: any = [
260
- // '> Input value',
261
- // `> Total Balance (${total_balance} ${chain_symbols})`
262
- // ]
263
- // let selected_value = await selectSomething(option_select_value_list);
264
- // let value_id = option_select_value_list.indexOf(selected_value);
265
- // let transfer_amount: string = "0";
266
- // if (value_id === 0) {
267
- // let input_value = await inputSomething("value", numberValidator);
268
- // transfer_amount = new BigNumber(input_value).multipliedBy(1e9).toFixed(0, BigNumber.ROUND_FLOOR);
269
- // if ((new BigNumber(transfer_amount)).isGreaterThan(new BigNumber(max_value))) {
270
- // console.log(chalk.red("Not enough balance"));
271
- // return;
272
- // }
273
- // } else if (value_id === 1) {
274
- // transfer_amount = max_value.toString();
275
- // }
276
235
 
277
236
  let transactions = new Transaction();
278
237
  transactions.add(
@@ -406,12 +365,30 @@ const sendEvmTokenTransaction = async (keystore_path: string, chain_rpc_url: str
406
365
  }
407
366
 
408
367
  const receipt = await inputSomething("Receipt", chainAddressValidator);
409
- const amount = await inputSomething("Amount", numberValidator);
368
+ const token_balance_result = await getTokenBalanceInEvm(account_address, token_address, chain_rpc_url);
369
+ if (!token_balance_result.status) {
370
+ console.log(chalk.red(token_balance_result.output));
371
+ return;
372
+ }
373
+ let amount: any;
374
+ for (let i = 0; i < 5; i++) {
375
+ let input_amount = await inputSomething("Amount", numberValidator);
376
+ if ((new BigNumber(input_amount).multipliedBy(Math.pow(10, Number(token_decimals)))).isLessThanOrEqualTo(new BigNumber(token_balance_result.output))) {
377
+ amount = input_amount;
378
+ break;
379
+ }
380
+ console.log(chalk.red("Not enough balance"));
381
+ }
382
+
383
+ if (!amount) {
384
+ return;
385
+ }
386
+
410
387
  const gasUtil = new GasUtil(chain_rpc_url);
411
388
  const estimateGasPrice = await gasUtil.getGasPrice();
412
389
  const estimateGasPriceEthers = (new BigNumber(estimateGasPrice.toString())).dividedBy(1e9);
413
390
  const _estimateGasPrice = estimateGasPriceEthers.toFixed(4, BigNumber.ROUND_FLOOR);
414
- const inputGasPrice = await inputSomething(`Gas price (${_estimateGasPrice}), agree or enter`);
391
+ const inputGasPrice = await inputSomething(`Gas price (${_estimateGasPrice}), agree or enter`, gasValidator);
415
392
  let gasPrice = inputGasPrice ? inputGasPrice : _estimateGasPrice;
416
393
  gasPrice = (new BigNumber(gasPrice)).multipliedBy(1e9).toFixed(0);
417
394
 
@@ -535,7 +512,24 @@ const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url:
535
512
  }
536
513
 
537
514
  const receipt = await inputSomething("Receipt", chainAddressValidator);
538
- const amount = await inputSomething("Amount", numberValidator);
515
+ const token_balance_result = await getTokenBalanceInEvm(account_address, token_address, chain_rpc_url);
516
+ if (!token_balance_result.status) {
517
+ console.log(chalk.red(token_balance_result.output));
518
+ return;
519
+ }
520
+ let amount: any;
521
+ for (let i = 0; i < 5; i++) {
522
+ let input_amount = await inputSomething("Amount", numberValidator);
523
+ if ((new BigNumber(input_amount).multipliedBy(Math.pow(10, Number(token_decimals)))).isLessThanOrEqualTo(new BigNumber(token_balance_result.output))) {
524
+ amount = input_amount;
525
+ break;
526
+ }
527
+ console.log(chalk.red("Not enough balance"));
528
+ }
529
+
530
+ if (!amount) {
531
+ return;
532
+ }
539
533
 
540
534
  let transfer_amount = new BigNumber(amount).multipliedBy(Math.pow(10, token_decimals)).toFixed(0);
541
535
  let from_token_account = getAssociatedTokenAddressSync(
@@ -615,7 +609,6 @@ const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url:
615
609
  transaction
616
610
  );
617
611
 
618
- console.log(simulate_result);
619
612
  if (!simulate_result.status) {
620
613
  console.log(chalk.red(simulate_result.output));
621
614
  return;
@@ -628,15 +621,14 @@ const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url:
628
621
 
629
622
  let unitsConsumed = new BigNumber(simulate_result.output.value.unitsConsumed.toString());
630
623
  unitsConsumed = new BigNumber(Math.ceil(Number(unitsConsumed) * 1.2));
631
- // const prioritization_fee_result = await getPrioritizationFee(chain_rpc_url);
632
- // if (!prioritization_fee_result.status) {
633
- // console.log(chalk.red(prioritization_fee_result.output));
634
- // return;
635
- // }
636
-
637
- // const prioritization_fee = new BigNumber(prioritization_fee_result.output.toString());
638
- const prioritization_fee = new BigNumber(1000);
639
-
624
+ const prioritization_fee_result = await getPrioritizationFee(chain_rpc_url);
625
+ if (!prioritization_fee_result.status) {
626
+ console.log(chalk.red(prioritization_fee_result.output));
627
+ return;
628
+ }
629
+
630
+ const prioritization_fee = new BigNumber(prioritization_fee_result.output.toString());
631
+
640
632
  transactions.add(
641
633
  createTransferInstruction(
642
634
  from_token_account,
package/src/utils.ts CHANGED
@@ -91,7 +91,7 @@ export const tagValidator = (tag: string) => {
91
91
 
92
92
  tag = tag.replace(/\s+/g, " ").trim();
93
93
 
94
- if (tag.length > 10) {
94
+ if (tag.length > 40) {
95
95
  return "Tag length should be less than 10";
96
96
  }
97
97
 
@@ -116,6 +116,13 @@ export const numberValidator = (value: string) => {
116
116
  return true;
117
117
  }
118
118
 
119
+ export const gasValidator = (value: string) => {
120
+ if (isNaN(Number(value)) || Number(value) > 1000) {
121
+ return "Value should be a number";
122
+ }
123
+ return true;
124
+ }
125
+
119
126
  export const passphraseValidator = (passphrase: string) => {
120
127
  passphrase = passphrase.replace(/\s+/g, " ");
121
128
  const mnemonic_word_list = passphrase.split(/\s+/g);
@@ -188,6 +195,25 @@ export const selectSomething = async (options: any[], message?: string, _default
188
195
  return inputText.toString()
189
196
  }
190
197
 
198
+ export const selectCheckboxSomething = async (options: any[], message?: string, _default?: any) => {
199
+ const questions = [
200
+ {
201
+ type: 'checkbox',
202
+ name: 'inputText',
203
+ message: message || 'Choose an option',
204
+ default: _default,
205
+ choices: options,
206
+ pageSize: 30,
207
+ filter: (val: string) => {
208
+ return val;
209
+ },
210
+ },
211
+ ]
212
+
213
+ const { inputText } = await inquirer.prompt(questions)
214
+ return inputText
215
+ }
216
+
191
217
  export const showIntroduction = () => {
192
218
  console.log(
193
219
  chalk.green(
@@ -598,6 +624,20 @@ export const listWithLazyBalanceLoading = async (
598
624
  show_extended_token
599
625
  );
600
626
 
627
+ let pad_index_map: any = {};
628
+
629
+ for (let account_address in batchBalanceOf) {
630
+ for (let token_name in batchBalanceOf[account_address]) {
631
+ let balance = batchBalanceOf[account_address][token_name];
632
+ let new_pad_index = balance.length + 1;
633
+ if (!pad_index_map[token_name]) {
634
+ pad_index_map[token_name] = new_pad_index;
635
+ } else if (pad_index_map[token_name] < new_pad_index) {
636
+ pad_index_map[token_name] = new_pad_index;
637
+ }
638
+ }
639
+ }
640
+
601
641
  let gas_token_name = network_info.nativeCurrency.symbol;
602
642
  for (let i = fromIndex; i < toIndex; i++) {
603
643
  let _index = i >= accounts.length / 2 ? i - accounts.length / 2 : i;
@@ -622,7 +662,7 @@ export const listWithLazyBalanceLoading = async (
622
662
  continue;
623
663
  }
624
664
 
625
- token_message += `${token_name}: ${batchBalanceOf[account_address][token_name]} `;
665
+ token_message += `${token_name}:${batchBalanceOf[account_address][token_name].padEnd(pad_index_map[token_name])} `;
626
666
  }
627
667
 
628
668
  let nameList = name.split('(');
@@ -653,6 +693,10 @@ export const updateStorage = (keystore_path: string) => {
653
693
  }
654
694
  }
655
695
 
696
+ if (!networks.showTokens) {
697
+ networks.showTokens = {};
698
+ }
699
+
656
700
  let account_list_len = networks.accounts.length;
657
701
  for (let i = 0; i < account_list_len; i++) {
658
702
  let account_label = networks.accounts[account_list_len - 1 - i];