Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ton-cli

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ton-cli - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

dist/commands/utils/exportKey.d.ts

8

dist/commands/restoreKeystore.js

@@ -78,3 +78,9 @@ "use strict";

let key = await (0, ton_crypto_1.mnemonicToWalletKey)(b.mnemonics);
let wallet = await client.openWalletDefaultFromSecretKey({ workchain: address.workChain, secretKey: key.secretKey });
let kind = (0, ton_1.validateWalletType)(b.kind);
if (!kind) {
spinner.fail('Invalid backup file');
return;
}
let wallet = await client.openWalletFromAddress({ source: address });
await wallet.prepare(address.workChain, key.publicKey, kind);
await keystore.addKey({

@@ -81,0 +87,0 @@ name: b.name,

@@ -19,2 +19,3 @@ "use strict";

const askText_1 = require("./utils/askText");
const exportKey_1 = require("./utils/exportKey");
async function listKeys(store) {

@@ -79,2 +80,15 @@ var table = new cli_table_1.default({

type: 'select',
name: 'kind',
message: 'Wallet Type',
choices: [
{ message: 'Wallet v3', name: 'org.ton.wallets.v3', hint: 'default' },
{ message: 'Wallet v3r2', name: 'org.ton.wallets.v3.r2' },
{ message: 'Wallet v2', name: 'org.ton.wallets.v2' },
{ message: 'Wallet v2r2', name: 'org.ton.wallets.v2.r2' },
{ message: 'Wallet v1', name: 'org.ton.wallets.simple', hint: 'unsupported' },
{ message: 'Wallet v1r2', name: 'org.ton.wallets.simple.r2' },
{ message: 'Wallet v1r3', name: 'org.ton.wallets.simple.r3', hint: 'for validator' }
]
}, {
type: 'select',
name: 'count',

@@ -100,2 +114,6 @@ message: 'How many keys you want to create?',

}]);
let kind = (0, ton_1.validateWalletType)(res.kind);
if (!kind) {
throw Error('Invalid kind');
}
// Create keys

@@ -112,7 +130,7 @@ const spinner = (0, ora_1.default)('Creating keys').start();

spinner.text = 'Creating key ' + keyname;
let wallet = await client.createNewWallet({ workchain: workchain });
let wallet = await client.createNewWallet({ workchain: workchain, type: kind });
await store.store.addKey({
name: keyname,
address: wallet.wallet.address,
kind: 'org.ton.wallets.v3',
kind: kind,
config: '',

@@ -136,2 +154,15 @@ comment: '',

}, {
type: 'select',
name: 'kind',
message: 'Wallet Type',
choices: [
{ message: 'Wallet v3', name: 'org.ton.wallets.v3', hint: 'default' },
{ message: 'Wallet v3r2', name: 'org.ton.wallets.v3.r2' },
{ message: 'Wallet v2', name: 'org.ton.wallets.v2' },
{ message: 'Wallet v2r2', name: 'org.ton.wallets.v2.r2' },
{ message: 'Wallet v1', name: 'org.ton.wallets.simple', hint: 'unsupported' },
{ message: 'Wallet v1r2', name: 'org.ton.wallets.simple.r2' },
{ message: 'Wallet v1r3', name: 'org.ton.wallets.simple.r3', hint: 'for validator' }
]
}, {
type: 'input',

@@ -155,7 +186,11 @@ name: 'name',

let key = await (0, ton_crypto_1.mnemonicToWalletKey)(res.mnemonics.split(' '));
let wallet = await client.openWalletDefaultFromSecretKey({ workchain, secretKey: key.secretKey });
let kind = (0, ton_1.validateWalletType)(res.kind);
if (!kind) {
throw Error('Invalid kind');
}
let wallet = await client.openWalletFromSecretKey({ workchain, secretKey: key.secretKey, type: kind });
await store.store.addKey({
name: res.name,
address: wallet.address,
kind: 'org.ton.wallets.v3',
kind: kind,
config: '',

@@ -205,3 +240,4 @@ comment: '',

let target = contacts.find((v) => v.name === res.send_to).address;
let source = store.store.allKeys.find((v) => v.name === res.send_from).address;
let source = store.store.allKeys.find((v) => v.name === res.send_from);
let sourceAddress = source.address;
let mnemonics = (await store.store.getSecret(res.send_from, password)).toString().split(' ');

@@ -212,3 +248,8 @@ if (!(await (0, ton_crypto_1.mnemonicValidate)(mnemonics))) {

let key = await (0, ton_crypto_1.mnemonicToWalletKey)(mnemonics);
let wallet = await client.openWalletDefaultFromSecretKey({ workchain: source.workChain, secretKey: key.secretKey });
let wallet = await client.openWalletFromAddress({ source: sourceAddress });
let kind = (0, ton_1.validateWalletType)(source.kind);
if (!kind) {
throw Error('Invalid wallet kind');
}
await wallet.prepare(sourceAddress.workChain, key.publicKey, kind);
spinner.text = 'Preparing transfer';

@@ -279,3 +320,3 @@ let seqno = await (0, patterns_1.backoff)(() => wallet.getSeqNo());

fs_1.default.writeFileSync(res.name + '.addr', wallet.address.toBuffer());
fs_1.default.writeFileSync(res.name + '.pk', key.secretKey.slice(0, 32));
fs_1.default.writeFileSync(res.name + '.pk', (0, exportKey_1.exportKey)(key.secretKey));
spinner.succeed('Written files ' + res.name + '.addr' + ' and ' + res.name + '.pk');

@@ -282,0 +323,0 @@ }

5

package.json
{
"name": "ton-cli",
"version": "0.2.0",
"version": "0.3.0",
"repository": "https://github.com/ex3ndr/ton-cli.git",

@@ -34,2 +34,3 @@ "author": "Steve Korshakov <steve@korshakov.com>",

"@openland/patterns": "^0.0.2",
"@types/bn.js": "^5.1.0",
"@types/cli-table": "^0.3.0",

@@ -42,3 +43,3 @@ "cli-table": "^0.3.6",

"prompt": "^1.2.0",
"ton": "2.6.0",
"ton": "4.1.0",
"ton-crypto": "1.3.0",

@@ -45,0 +46,0 @@ "yargs": "^17.1.1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc