Comparing version 1.2.0 to 1.3.0
/// <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" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73966
1797
+ Added@types/node@22.10.0(transitive)
+ Addedton-contracts@1.6.0(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@types/node@22.9.3(transitive)
- Removedton-contracts@1.5.0(transitive)
- Removedundici-types@6.19.8(transitive)
Updatedton-contracts@1.6.0