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 1.2.0 to 1.3.0

4

dist/commands/storage/walletSources.d.ts
/// <reference types="node" />
import { Address, WalletV1R1Source, WalletV1R2Source, WalletV1R3Source, WalletV2R1Source, WalletV2R2Source, WalletV3R1Source, WalletV3R2Source } from "ton";
import { WhitelistedWalletSource } from "ton-contracts";
import { ValidatorControllerSource, WhitelistedWalletSource } from "ton-contracts";
export declare function createGenericWalletSource(kind: string, workChain: number, publicKey: Buffer): WalletV1R1Source | WalletV1R2Source | WalletV1R3Source | WalletV2R1Source | WalletV2R2Source | WalletV3R1Source | WalletV3R2Source;
export declare function restoreWalletSource(kind: string, address: Address, publicKey: Buffer, config: string): WalletV1R1Source | WalletV1R2Source | WalletV1R3Source | WalletV2R1Source | WalletV2R2Source | WalletV3R1Source | WalletV3R2Source | WhitelistedWalletSource;
export declare function restoreWalletSource(kind: string, address: Address, publicKey: Buffer, config: string): WalletV1R1Source | WalletV1R2Source | WalletV1R3Source | WalletV2R1Source | WalletV2R2Source | WalletV3R1Source | WalletV3R2Source | WhitelistedWalletSource | ValidatorControllerSource;

@@ -84,4 +84,7 @@ "use strict";

}
if (kind === 'org.ton.validator.controller') {
return ton_contracts_1.ValidatorControllerSource.restore(config);
}
throw Error('Unknown wallet kind: ' + kind);
}
exports.restoreWalletSource = restoreWalletSource;

@@ -33,3 +33,3 @@ "use strict";

var table = new cli_table_1.default({
head: ['Name', 'WC', 'Address', 'Kind'], colWidths: [24, 4, 56, 32]
head: ['Name', 'WC', 'Address', 'Kind'], colWidths: [36, 4, 56, 32]
});

@@ -171,3 +171,3 @@ for (let key of store.allKeys) {

var table = new cli_table_1.default({
head: ['Name', 'WC', 'Address', 'Balance', 'Kind', 'Status'], colWidths: [24, 4, 56, 16, 32, 24]
head: ['Name', 'WC', 'Address', 'Balance', 'Kind', 'Status'], colWidths: [36, 4, 56, 16, 32, 24]
});

@@ -179,3 +179,3 @@ const spinner = (0, ora_1.default)('Fetching balances...').start();

let state = (await config.client.getContractState(key.address)).state;
if (key.kind === 'org.ton.wallets.whitelisted' && state === 'active') {
if ((key.kind === 'org.ton.wallets.whitelisted' || key.kind === 'org.ton.validator.controller') && state === 'active') {
let cooldown = parseInt((await config.client.callGetMethod(key.address, 'restricted_cooldown')).stack[0][1], 16);

@@ -213,3 +213,4 @@ if (cooldown > 0) {

{ message: 'Wallet v1r3', name: 'org.ton.wallets.simple.r3', hint: 'for validator' },
{ message: 'Restricted (Whitelisted)', name: 'org.ton.wallets.whitelisted', hint: 'restricted wallet' }
{ message: 'Restricted (Whitelisted)', name: 'org.ton.wallets.whitelisted', hint: 'restricted wallet' },
{ message: 'Validator Controller', name: 'org.ton.validator.controller', hint: 'Secure wallet for validators' }
]

@@ -260,2 +261,42 @@ }]);

}
if (res.kind === 'org.ton.validator.controller') {
// Creaste keys
const spinner = (0, ora_1.default)('Creating keys').start();
const masterMnemonics = await (0, ton_crypto_1.mnemonicNew)();
const masterKey = await (0, ton_crypto_1.mnemonicToWalletKey)(masterMnemonics);
const restrictedMnemonics = await (0, ton_crypto_1.mnemonicNew)();
const restrictedKey = await (0, ton_crypto_1.mnemonicToWalletKey)(restrictedMnemonics);
spinner.stop();
// Ask for whitelisted address
const whitelistedAddress = await (0, askAddress_1.askAddress)({ message: 'Elector address' });
const source = ton_contracts_1.ValidatorControllerSource.create({
workchain,
masterKey: masterKey.publicKey,
restrictedKey: restrictedKey.publicKey,
whitelistedAddress: whitelistedAddress
});
const address = await (0, ContractSource_1.contractAddress)(source);
const sourceConfig = source.backup();
// Ask for name
const basicName = await (0, askKeyName_1.askKeyName)('Key Name', { store: store.store, suffixes: ['_restricted', '_master'] });
await store.store.addKey({
name: basicName + '_restricted',
address: address,
kind: source.type,
config: sourceConfig,
comment: '',
publicKey: restrictedKey.publicKey
}, Buffer.from(restrictedMnemonics.join(' ')));
await store.store.addKey({
name: basicName + '_master',
address: address,
kind: source.type,
config: sourceConfig,
comment: '',
publicKey: masterKey.publicKey
}, Buffer.from(masterMnemonics.join(' ')));
// Write to disk
fs_1.default.writeFileSync(store.name, await store.store.save());
return;
}
// Generic wallet

@@ -332,3 +373,4 @@ let kind = (0, ton_1.validateWalletType)(res.kind);

{ message: 'Wallet v1r3', name: 'org.ton.wallets.simple.r3', hint: 'for validator' },
{ message: 'Restricted (Whitelisted)', name: 'org.ton.wallets.whitelisted', hint: 'restricted wallet' }
{ message: 'Restricted (Whitelisted)', name: 'org.ton.wallets.whitelisted', hint: 'restricted wallet' },
{ message: 'Validator Controller', name: 'org.ton.validator.controller', hint: 'Secure wallet for validators' }
]

@@ -377,2 +419,40 @@ }]);

}
if (res.kind === 'org.ton.validator.controller') {
// Key Parameters
const restrictedMnemonics = await (0, askMnemonics_1.askMnemonics)('Restricted Key mnemonics');
const masterMnemonics = await (0, askMnemonics_1.askMnemonics)('Main Key mnemonics');
const whitelistedAddress = await (0, askAddress_1.askAddress)({ message: 'Elector address' });
// Create contract
let restrictedKey = await (0, ton_crypto_1.mnemonicToWalletKey)(restrictedMnemonics);
let masterKey = await (0, ton_crypto_1.mnemonicToWalletKey)(masterMnemonics);
let source = ton_contracts_1.ValidatorControllerSource.create({
masterKey: masterKey.publicKey,
restrictedKey: restrictedKey.publicKey,
workchain,
whitelistedAddress: whitelistedAddress
});
let address = await (0, ContractSource_1.contractAddress)(source);
let sourceConfig = source.backup();
// Persist keys
const basicName = await (0, askKeyName_1.askKeyName)('Key Name', { store: store.store, suffixes: ['_restricted', '_master'] });
await store.store.addKey({
name: basicName + '_restricted',
address: address,
kind: source.type,
config: sourceConfig,
comment: '',
publicKey: restrictedKey.publicKey
}, Buffer.from(restrictedMnemonics.join(' ')));
await store.store.addKey({
name: basicName + '_master',
address: address,
kind: source.type,
config: sourceConfig,
comment: '',
publicKey: masterKey.publicKey
}, Buffer.from(masterMnemonics.join(' ')));
// Write to disk
fs_1.default.writeFileSync(store.name, await store.store.save());
return;
}
// Generic contract

@@ -379,0 +459,0 @@ const name = await (0, askKeyName_1.askKeyName)('Key name', { store: store.store });

{
"name": "ton-cli",
"version": "1.2.0",
"version": "1.3.0",
"repository": "https://github.com/ex3ndr/ton-cli.git",

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

"ton": "4.15.0",
"ton-contracts": "1.5.0",
"ton-contracts": "1.6.0",
"ton-crypto": "1.5.1",

@@ -48,0 +48,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