@yerofey/cryptowallet-cli 1.18.1 → 1.18.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.18.1",
3
+ "version": "1.18.3",
4
4
  "description": "Crypto wallet generator CLI tool",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/yerofey/cryptowallet-cli",
@@ -119,6 +119,7 @@
119
119
  "columnify": "1.6.0",
120
120
  "commander": "11.1.0",
121
121
  "csv-writer": "^1.6.0",
122
+ "dotenv": "^16.4.1",
122
123
  "eth-lib": "0.1.29",
123
124
  "ethereum-bip84": "0.0.3",
124
125
  "ethereum-mnemonic-privatekey-utils": "1.0.5",
package/src/Method.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { config } from 'dotenv';
1
2
  import path from 'node:path';
2
3
  import chalk from 'chalk';
3
4
  import columnify from 'columnify';
@@ -6,9 +7,10 @@ import { log, supportedChains, loadJson } from './utils.js';
6
7
  import { generateMnemonicString } from './Wallet.js';
7
8
  import CW from './CW.js';
8
9
 
10
+ config();
9
11
  const { blue, green, blueBright, greenBright, yellow, red, magenta, white } =
10
12
  chalk;
11
-
13
+ const IS_DEV = process.env.NODE_ENV === 'development' || false;
12
14
  const pkg = await loadJson(
13
15
  `${path.dirname(import.meta.url)}/../package.json`.replace('file://', '')
14
16
  );
@@ -218,14 +220,28 @@ class Method {
218
220
  cw.suffixFoundInWallets.includes(item.address)
219
221
  ) {
220
222
  // highlight found prefix and suffix
221
- const addressStartingSymbol = startsWithSymbols.filter((symbol) =>
222
- item.address.startsWith(symbol)
223
- )[0];
224
- const addressCutPrefixLength = addressStartingSymbol.length;
225
- const addressHighlightedPart = item.address.substring(
226
- addressCutPrefixLength + cw.options.prefix.length,
227
- cw.options.prefix.length
228
- );
223
+ let addressStartingSymbol;
224
+ if (startsWithSymbols.length > 1) {
225
+ addressStartingSymbol =
226
+ startsWithSymbols.filter((symbol) =>
227
+ item.address.startsWith(symbol)
228
+ )[0] || '';
229
+ } else {
230
+ addressStartingSymbol = startsWithSymbols[0] || '';
231
+ }
232
+ const addressCutPrefixLength = addressStartingSymbol.length || 0;
233
+ let addressHighlightedPart;
234
+ if (addressCutPrefixLength > 0) {
235
+ addressHighlightedPart = item.address.substring(
236
+ addressCutPrefixLength,
237
+ addressCutPrefixLength + cw.options.prefix.length
238
+ );
239
+ } else {
240
+ addressHighlightedPart = item.address.substring(
241
+ 0,
242
+ cw.options.prefix.length
243
+ );
244
+ }
229
245
  const addressLastPart = item.address.slice(
230
246
  cw.options.prefix.length + addressCutPrefixLength,
231
247
  item.address.length - cw.options.suffix.length
@@ -233,45 +249,100 @@ class Method {
233
249
  const addressHighlightedSuffix = item.address.slice(
234
250
  item.address.length - cw.options.suffix.length
235
251
  );
236
- log(
237
- `👛 ${addressStartingSymbol}${magenta(
238
- addressHighlightedPart
239
- )}${addressLastPart}${magenta(addressHighlightedSuffix)}`
240
- );
252
+ const fullAddressLength =
253
+ addressStartingSymbol.length +
254
+ addressHighlightedPart.length +
255
+ addressLastPart.length +
256
+ addressHighlightedSuffix.length;
257
+ // show hightlighted address (only if it's length is the same as the original address length)
258
+ if (fullAddressLength == item.address.length || IS_DEV) {
259
+ log(
260
+ `👛 ${addressStartingSymbol}${magenta(
261
+ addressHighlightedPart
262
+ )}${addressLastPart}${magenta(addressHighlightedSuffix)}`
263
+ );
264
+ // DEBUG
265
+ if (IS_DEV) {
266
+ log(`___ ${item.address}`);
267
+ }
268
+ } else {
269
+ log(`👛 ${item.address}`);
270
+ }
241
271
  } else if (
242
272
  cw.prefixFound &&
243
273
  cw.prefixFoundInWallets.includes(item.address)
244
274
  ) {
245
275
  // highlight found prefix
246
- const addressStartingSymbol = startsWithSymbols.filter((symbol) =>
247
- item.address.startsWith(symbol)
248
- )[0];
276
+ // startsWithSymbols could be 3 different types (empty, few symbols, or few symbols with "|" - separator for multiple symbols), adjust the address cut prefix length
277
+ let addressStartingSymbol;
278
+ if (startsWithSymbols.length > 1) {
279
+ addressStartingSymbol =
280
+ startsWithSymbols.filter((symbol) =>
281
+ item.address.startsWith(symbol)
282
+ )[0] || '';
283
+ } else {
284
+ addressStartingSymbol = startsWithSymbols[0] || '';
285
+ }
249
286
  const addressCutPrefixLength = addressStartingSymbol.length || 0;
250
- const addressHighlightedPart = item.address.substring(
251
- addressCutPrefixLength + cw.options.prefix.length,
252
- cw.options.prefix.length
253
- );
287
+ let addressHighlightedPart;
288
+ if (addressCutPrefixLength > 0) {
289
+ addressHighlightedPart = item.address.substring(
290
+ addressCutPrefixLength,
291
+ addressCutPrefixLength + cw.options.prefix.length
292
+ );
293
+ } else {
294
+ addressHighlightedPart = item.address.substring(
295
+ 0,
296
+ cw.options.prefix.length
297
+ );
298
+ }
254
299
  const addressLastPart = item.address.slice(
255
300
  cw.options.prefix.length + addressCutPrefixLength
256
301
  );
257
- log(
258
- `👛 ${addressStartingSymbol}${magenta(
259
- addressHighlightedPart
260
- )}${addressLastPart}`
261
- );
302
+ const fullAddressLength =
303
+ addressStartingSymbol.length +
304
+ addressHighlightedPart.length +
305
+ addressLastPart.length;
306
+ // show hightlighted address (only if it's length is the same as the original address length)
307
+ if (fullAddressLength == item.address.length || IS_DEV) {
308
+ log(
309
+ `👛 ${addressStartingSymbol}${magenta(
310
+ addressHighlightedPart
311
+ )}${addressLastPart}`
312
+ );
313
+ // DEBUG
314
+ if (IS_DEV) {
315
+ log(`___ ${item.address}`);
316
+ }
317
+ } else {
318
+ log(`👛 ${item.address}`);
319
+ }
262
320
  } else if (
263
321
  cw.suffixFound &&
264
322
  cw.suffixFoundInWallets.includes(item.address)
265
323
  ) {
266
324
  // highlight found suffix
267
- const addressLastPart = item.address.slice(
325
+ const addressFirstPart = item.address.slice(
268
326
  0,
269
327
  item.address.length - cw.options.suffix.length
270
328
  );
271
329
  const addressHighlightedSuffix = item.address.slice(
272
330
  item.address.length - cw.options.suffix.length
273
331
  );
274
- log(`👛 ${addressLastPart}${magenta(addressHighlightedSuffix)}`);
332
+ const fullAddressLength =
333
+ addressFirstPart.length + addressHighlightedSuffix.length;
334
+ // show hightlighted address (only if it's length is the same as the original address length)
335
+ if (fullAddressLength == item.address.length || IS_DEV) {
336
+ log(
337
+ `👛 ${addressFirstPart}${magenta(addressHighlightedSuffix)}`
338
+ );
339
+ // DEBUG
340
+ if (IS_DEV) {
341
+ log(`___ ${item.address}`);
342
+ }
343
+ } else {
344
+ log(`👛 ${item.address}`);
345
+ }
275
346
  } else {
276
347
  log(`👛 ${item.address}`);
277
348
  }
@@ -4,6 +4,5 @@
4
4
  "startsWith": "",
5
5
  "prefixTest": "[1-9a-zA-Z]",
6
6
  "apps": ["phantom", "trustwallet"],
7
- "flags": ["p", "s"],
8
- "tested": false
7
+ "flags": ["p", "s"]
9
8
  }