Comparing version 3.2.0 to 4.0.0
@@ -10,2 +10,3 @@ /// <reference types="bn.js" /> | ||
import { Maybe } from '../types'; | ||
import { WalletContractType } from '..'; | ||
export declare type TonClientParameters = { | ||
@@ -77,3 +78,3 @@ endpoint: string; | ||
*/ | ||
openWalletFromSecretKey(args: { | ||
findWalletFromSecretKey(args: { | ||
workchain: number; | ||
@@ -92,2 +93,12 @@ secretKey: Buffer; | ||
/** | ||
* Open wallet with default contract | ||
* @param args workchain and secret key | ||
* @returns wallet | ||
*/ | ||
openWalletFromSecretKey(args: { | ||
workchain: number; | ||
secretKey: Buffer; | ||
type: WalletContractType; | ||
}): Promise<Wallet>; | ||
/** | ||
* Securely creates new wallet | ||
@@ -94,0 +105,0 @@ * @param password optional password |
@@ -117,3 +117,3 @@ "use strict"; | ||
*/ | ||
async openWalletFromSecretKey(args) { | ||
async findWalletFromSecretKey(args) { | ||
return Wallet_1.Wallet.findBestBySecretKey(this, args.workchain, args.secretKey); | ||
@@ -130,2 +130,10 @@ } | ||
/** | ||
* Open wallet with default contract | ||
* @param args workchain and secret key | ||
* @returns wallet | ||
*/ | ||
async openWalletFromSecretKey(args) { | ||
return Wallet_1.Wallet.openByType(this, args.workchain, args.secretKey, args.type); | ||
} | ||
/** | ||
* Securely creates new wallet | ||
@@ -132,0 +140,0 @@ * @param password optional password |
@@ -31,3 +31,3 @@ "use strict"; | ||
const key = await (0, ton_crypto_1.mnemonicToWalletKey)(mnemonics); | ||
let wallet = await client.openWalletFromSecretKey({ workchain: 0, secretKey: key.secretKey }); | ||
let wallet = await client.findWalletFromSecretKey({ workchain: 0, secretKey: key.secretKey }); | ||
expect(wallet.address.workChain).toBe(0); | ||
@@ -34,0 +34,0 @@ expect(wallet.address.hash).toEqual(Buffer.from('d1e27790cea91f133d2847785705c26987ae1de4d75d3fc1fcc1f374b6140802', 'hex')); |
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
static openDefault(client: TonClient, workchain: number, secretKey: Buffer): Promise<Wallet>; | ||
static openByType(client: TonClient, workchain: number, secretKey: Buffer, type: WalletContractType): Promise<Wallet>; | ||
static findActiveBySecretKey(client: TonClient, workchain: number, secretKey: Buffer): Promise<{ | ||
@@ -12,0 +13,0 @@ address: Address; |
@@ -77,2 +77,9 @@ "use strict"; | ||
} | ||
static async openByType(client, workchain, secretKey, type) { | ||
const publicKey = (0, ton_crypto_1.keyPairFromSecretKey)(secretKey).publicKey; | ||
let c = await createContract(client, type, publicKey, workchain); | ||
let w = new Wallet(client, c.address); | ||
await w.prepare(workchain, publicKey, type); | ||
return w; | ||
} | ||
static async findActiveBySecretKey(client, workchain, secretKey) { | ||
@@ -79,0 +86,0 @@ const publicKey = (0, ton_crypto_1.keyPairFromSecretKey)(secretKey).publicKey; |
@@ -22,5 +22,5 @@ "use strict"; | ||
publicKey: key.publicKey, | ||
wallet: await client.openWalletFromSecretKey({ workchain: 0, secretKey: key.secretKey }) | ||
wallet: await client.findWalletFromSecretKey({ workchain: 0, secretKey: key.secretKey }) | ||
}; | ||
} | ||
exports.openTestTreasure = openTestTreasure; |
{ | ||
"name": "ton", | ||
"version": "3.2.0", | ||
"version": "4.0.0", | ||
"repository": "https://github.com/ex3ndr/ton.git", | ||
@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>", |
157528
4120