@yerofey/cryptowallet-cli 1.43.0 → 1.43.2

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/cli.js CHANGED
@@ -60,9 +60,10 @@ if (options.list) {
60
60
  // generate mnemonic string (12/15/18/21/24 words)
61
61
  if (isMnemonicString) {
62
62
  (async () => {
63
- new Method('mnemonic').init({
63
+ await new Method('mnemonic').init({
64
64
  mnemonic: options.mnemonic,
65
65
  copy: options?.copy || false,
66
+ chain: options.chain,
66
67
  });
67
68
  exit(0);
68
69
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.43.0",
3
+ "version": "1.43.2",
4
4
  "description": "Crypto wallet generator CLI tool",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/yerofey/cryptowallet-cli",
@@ -116,13 +116,13 @@
116
116
  ],
117
117
  "dependencies": {
118
118
  "@binance-chain/javascript-sdk": "^4.2.2",
119
- "@emurgo/cardano-serialization-lib-nodejs": "^15.0.1",
119
+ "@emurgo/cardano-serialization-lib-nodejs": "^15.0.3",
120
120
  "@harmony-js/account": "^0.1.57",
121
- "@mysten/sui": "^1.18.0",
121
+ "@mysten/sui": "^2.3.1",
122
122
  "@solana/web3.js": "^1.98.4",
123
- "@ton/core": "^0.61.0",
123
+ "@ton/core": "^0.63.0",
124
124
  "@ton/crypto": "^3.3.0",
125
- "@ton/ton": "^15.3.1",
125
+ "@ton/ton": "^16.2.2",
126
126
  "@yerofey/dogecoin-bip84": "^0.0.5",
127
127
  "@yerofey/litecoin-bip84": "^0.0.5",
128
128
  "bigint-buffer": "^1.1.5",
@@ -133,13 +133,13 @@
133
133
  "bs58": "^6.0.0",
134
134
  "cardano-wallet-js": "^1.4.0",
135
135
  "chalk": "5.6.2",
136
- "clipboardy": "^4.0.0",
136
+ "clipboardy": "^5.2.1",
137
137
  "coininfo": "5.2.1",
138
138
  "coinkey": "3.0.0",
139
139
  "columnify": "1.6.0",
140
- "commander": "^14.0.1",
140
+ "commander": "^14.0.3",
141
141
  "csv-writer": "^1.6.0",
142
- "dotenv": "^17.2.2",
142
+ "dotenv": "^17.2.4",
143
143
  "ed25519-hd-key": "^1.3.0",
144
144
  "eth-lib": "0.1.29",
145
145
  "ethereum-bip84": "0.0.3",
@@ -152,11 +152,11 @@
152
152
  "tezos-sign": "1.4.1",
153
153
  "tiny-secp256k1": "^2.2.4",
154
154
  "tonweb": "^0.0.66",
155
- "tronweb": "^6.0.4",
156
- "xrpl": "^4.2.0"
155
+ "tronweb": "^6.2.0",
156
+ "xrpl": "^4.5.0"
157
157
  },
158
158
  "devDependencies": {
159
159
  "ava": "^6.4.1",
160
- "eslint": "^9.35.0"
160
+ "eslint": "^10.0.0"
161
161
  }
162
162
  }
package/src/Method.js CHANGED
@@ -6,6 +6,7 @@ import columnify from 'columnify';
6
6
  import CsvWriter from 'csv-writer';
7
7
  import qr from 'qrcode-terminal';
8
8
  import CW from './CW.js';
9
+ import { mnemonicNew as newTonMnemonic } from '@ton/crypto';
9
10
  import { generateMnemonicString } from './Wallet.js';
10
11
  import { log, supportedChains, loadJson } from './utils.js';
11
12
 
@@ -32,6 +33,19 @@ const pkg = await loadJson(
32
33
  const _version = pkg['version'] || 0;
33
34
 
34
35
  class Method {
36
+ static mnemonicGenerators = {
37
+ TON: {
38
+ defaultLength: 24,
39
+ resolveLength: () => 24,
40
+ generate: async () => (await newTonMnemonic()).join(' '),
41
+ },
42
+ DEFAULT: {
43
+ defaultLength: 12,
44
+ allowedLengths: ['12', '15', '18', '21', '24'],
45
+ generate: async (length) => generateMnemonicString(length),
46
+ },
47
+ };
48
+
35
49
  constructor(name, params = {}) {
36
50
  this.name = name;
37
51
  this.params = params;
@@ -50,6 +64,30 @@ class Method {
50
64
  };
51
65
  }
52
66
 
67
+ _getMnemonicGenerator(chain) {
68
+ return Method.mnemonicGenerators[chain] || Method.mnemonicGenerators.DEFAULT;
69
+ }
70
+
71
+ _resolveMnemonicLength(chain, mnemonicValue) {
72
+ const generator = this._getMnemonicGenerator(chain);
73
+ if (typeof generator.resolveLength === 'function') {
74
+ return generator.resolveLength(mnemonicValue);
75
+ }
76
+ const mnemonic = mnemonicValue || `${generator.defaultLength || 12}`;
77
+ const allowed =
78
+ generator.allowedLengths || ['12', '15', '18', '21', '24'];
79
+ return allowed.includes(mnemonic)
80
+ ? parseInt(mnemonic, 10)
81
+ : generator.defaultLength || 12;
82
+ }
83
+
84
+ async _generateMnemonic(chain, mnemonicValue) {
85
+ const generator = this._getMnemonicGenerator(chain);
86
+ const length = this._resolveMnemonicLength(chain, mnemonicValue);
87
+ const mnemonicString = await generator.generate(length);
88
+ return { length, mnemonicString };
89
+ }
90
+
53
91
  async _list() {
54
92
  log(`🔠 All supported chains & tickers:\n`);
55
93
  let cryptos = {};
@@ -77,12 +115,10 @@ class Method {
77
115
  log(`â„šī¸ Use flag "-c TICKER" to select specific chain or ticker`);
78
116
  }
79
117
 
80
- _mnemonic() {
81
- const mnemonic = this.inputOptions.mnemonic || '12';
82
- const mnemonicLength = ['12', '15', '18', '21', '24'].includes(mnemonic)
83
- ? parseInt(mnemonic, 10)
84
- : 12;
85
- const mnemonicString = generateMnemonicString(mnemonicLength);
118
+ async _mnemonic() {
119
+ const chain = (this.inputOptions.chain || '').toString().toUpperCase();
120
+ const { length: mnemonicLength, mnemonicString } =
121
+ await this._generateMnemonic(chain, this.inputOptions.mnemonic);
86
122
 
87
123
  log(
88
124
  `✨ ${green('Done!')} ${blueBright(
@@ -147,7 +183,11 @@ class Method {
147
183
  );
148
184
  }
149
185
 
150
- if (cw.options.mnemonic != '' && cw.wallet.mnemonic == undefined) {
186
+ if (
187
+ cw.options.mnemonic != '' &&
188
+ cw.wallet.mnemonic == undefined &&
189
+ cw.wallet.error === undefined
190
+ ) {
151
191
  log(
152
192
  `đŸ˜ĸ ${yellow(
153
193
  'Sorry, ' + chainFullName + ' does not support mnemonic yet...'
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "segwit": {
24
24
  "format": "segwit",
25
- "startsWith": "A",
25
+ "startsWith": "A|9",
26
26
  "prefixTest": "(?![0OI])[1-9a-zA-Z]",
27
27
  "rareSymbols": "[1-9]",
28
28
  "path": "m/49'/3",