Comparing version 0.2.0 to 0.3.0
@@ -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 @@ } |
{ | ||
"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" |
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
33666
32
764
12
+ Added@types/bn.js@^5.1.0
+ Added@types/bn.js@5.1.6(transitive)
+ Added@types/node@22.9.3(transitive)
+ Addedjssha@3.2.0(transitive)
+ Addedton@4.1.0(transitive)
+ Addedton-crypto@1.4.7(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removed@ledgerhq/devices@5.51.1(transitive)
- Removed@ledgerhq/errors@5.50.0(transitive)
- Removed@ledgerhq/hw-transport@5.51.1(transitive)
- Removed@ledgerhq/hw-transport-web-ble@5.51.1(transitive)
- Removed@ledgerhq/hw-transport-webhid@5.51.1(transitive)
- Removed@ledgerhq/hw-transport-webusb@5.53.1(transitive)
- Removed@ledgerhq/logs@5.50.0(transitive)
- Removedevents@3.3.0(transitive)
- Removedrxjs@6.6.7(transitive)
- Removedsemver@7.6.3(transitive)
- Removedton@2.6.0(transitive)
- Removedton-crypto@1.3.2(transitive)
- Removedtonweb@0.0.18(transitive)
- Removedtslib@1.14.1(transitive)
- Removedxmlhttprequest@1.8.0(transitive)
Updatedton@4.1.0