diff --git a/package.json b/package.json index b729a04..f614b2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yerofey/cryptowallet-cli", - "version": "1.31.3", + "version": "1.31.4", "description": "Crypto wallet generator CLI tool", "type": "module", "homepage": "https://github.com/yerofey/cryptowallet-cli", diff --git a/src/Method.js b/src/Method.js index 655a0ec..ca91bf2 100644 --- a/src/Method.js +++ b/src/Method.js @@ -496,6 +496,15 @@ class Method { log(); } + // should be activated (only for specific chains) + if (cw.row.requiresActivation !== undefined && cw.row.requiresActivation) { + log( + blue( + `💎 ${cw.row.title} (${cw.row.network}) requires wallet activation in order to use it (just make a small value transaction to itself)` + ) + ); + } + // formats if ( cw.row.formats !== undefined && @@ -546,7 +555,8 @@ class Method { let appsString = appsArray.join(', '); if (cw.row.apps || false) { - appsString += ' and any other wallet app (either using mnemonic or private key)'; + appsString += + ' and any other wallet app (either using mnemonic or private key)'; } log(greenBright('ℹī¸ You can import this wallet into ' + appsString)); } diff --git a/src/Wallet.js b/src/Wallet.js index 1a8e4a3..8593d71 100644 --- a/src/Wallet.js +++ b/src/Wallet.js @@ -1,3 +1,4 @@ +/* eslint-disable no-case-declarations */ import { config } from 'dotenv'; import { log } from './utils.js'; import chalk from 'chalk'; @@ -501,27 +502,47 @@ class Wallet { const keyPair = await TonMnemonicToPrivateKey(mnemonics); let addresses = []; - - switch (format.toUpperCase()) { - case 'V4R2': + let walletFormat = format.toLowerCase(); + + switch (walletFormat) { + // old formats + case 'simpler1': + case 'simpler2': + case 'simpler3': + case 'v2r1': + case 'v2r2': + case 'v3r1': + case 'v3r2': + case 'v4r1': + case 'v4r2': const tonweb = new TonWeb(); - const WalletClass = tonweb.wallet.all.v4R2; + const _tonwebFormat = walletFormat.replace('r', 'R'); + const WalletClass = tonweb.wallet.all[_tonwebFormat]; const wallet = new WalletClass(tonweb.provider, keyPair); const address = await wallet.getAddress(); - const nonBounceableAddress = address.toString(true, true, false); - addresses.push({ - title: 'V4R2: UQ format: best for wallets, - non-bounceable', - address: nonBounceableAddress, - }); - const bouncableAddress = address.toString(true, true, true); - addresses.push({ - title: 'V4R2: EQ format: best for smart contracts, - bounceable', - address: bouncableAddress, - }); + + if (walletFormat == 'v4r2') { + // when UQ was implemented (non-bounceable addresses) + const nonBounceableAddress = address.toString(true, true, false); + addresses.push({ + title: 'V4R2 (UQ): best for wallets, - non-bounceable', + address: nonBounceableAddress, + }); + const bouncableAddress = address.toString(true, true, true); + addresses.push({ + title: 'V4R2 (EQ): best for smart contracts, - bounceable', + address: bouncableAddress, + }); + } else { + addresses.push({ + address: address.toString(true, true, true), + }); + } break; - case 'V5R1': - case 'W5': + // new format + case 'v5r1': + case 'w5': default: const workchain = 0; const walletV5 = WalletContractV5R1.create({ @@ -535,7 +556,7 @@ class Wallet { testOnly: false, }); addresses.push({ - title: 'W5 (V5R1): UQ format: best for wallets, - non-bounceable', + title: 'W5 (V5R1) [UQ]: best for wallets, - non-bounceable', address: nonBounceableV5Address, }); const bouncableAddressV5 = v5Address.toString({ @@ -544,8 +565,7 @@ class Wallet { testOnly: false, }); addresses.push({ - title: - 'W5 (V5R1): EQ format: best for smart contracts, - bounceable', + title: 'W5 (V5R1) [EQ]: best for smart contracts, - bounceable', address: bouncableAddressV5, }); break; diff --git a/src/chains/TON.json b/src/chains/TON.json index 719692e..5ddb9f0 100644 --- a/src/chains/TON.json +++ b/src/chains/TON.json @@ -3,6 +3,70 @@ "network": "TON", "defaultFormat": "W5", "formats": { + "simpleR1": { + "format": "simpleR1", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, + "simpleR2": { + "format": "simpleR2", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, + "simpleR3": { + "format": "simpleR3", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, + "V2R1": { + "format": "V2R1", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, + "V2R2": { + "format": "V2R2", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, + "V3R1": { + "format": "V3R1", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, + "V3R2": { + "format": "V3R2", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, + "V4R1": { + "format": "V4R1", + "startsWith": "EQ", + "prefixTest": "[0-9a-zA-Z-_]", + "rareSymbols": "[0-9]", + "apps": ["tonkeeper", "trustwallet"], + "flags": ["m", "p", "s"] + }, "V4R2": { "format": "V4R2", "startsWith": "EQ|UQ", @@ -28,5 +92,6 @@ "apps": ["tonkeeper", "trustwallet"], "flags": ["m", "p", "s"] } - } + }, + "requiresActivation": true }