Skip to content

Commit

Permalink
chore: Update package.json version to 1.31.4 and fix address format i…
Browse files Browse the repository at this point in the history
…n Wallet.js

- Update the version in package.json to 1.31.4
- Fix the address format in Wallet.js to adhere to the specified wallet formats
  • Loading branch information
yerofey committed Sep 6, 2024
1 parent d8b13cc commit 1b94401
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 11 additions & 1 deletion src/Method.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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));
}
Expand Down
58 changes: 39 additions & 19 deletions src/Wallet.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-case-declarations */
import { config } from 'dotenv';
import { log } from './utils.js';
import chalk from 'chalk';
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -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;
Expand Down
67 changes: 66 additions & 1 deletion src/chains/TON.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -28,5 +92,6 @@
"apps": ["tonkeeper", "trustwallet"],
"flags": ["m", "p", "s"]
}
}
},
"requiresActivation": true
}

0 comments on commit 1b94401

Please sign in to comment.