Comparing version 4.5.0 to 4.6.0
@@ -10,3 +10,3 @@ /// <reference types="bn.js" /> | ||
import { Maybe } from '../types'; | ||
import { WalletContractType } from '..'; | ||
import { WalletContractType, WalletSource } from '..'; | ||
import { TonTransaction } from './TonTransaction'; | ||
@@ -112,2 +112,3 @@ export declare type TonClientParameters = { | ||
}): Promise<Wallet>; | ||
openWalletFromCustomContract(src: WalletSource): Promise<Wallet>; | ||
/** | ||
@@ -114,0 +115,0 @@ * Securely creates new wallet |
@@ -169,2 +169,5 @@ "use strict"; | ||
} | ||
async openWalletFromCustomContract(src) { | ||
return Wallet_1.Wallet.openFromSource(this, src); | ||
} | ||
/** | ||
@@ -171,0 +174,0 @@ * Securely creates new wallet |
/// <reference types="node" /> | ||
import BN from "bn.js"; | ||
import { Address, Cell, TonClient } from ".."; | ||
import { WalletSource } from "../contracts/sources/WalletSource"; | ||
export declare type WalletContractType = 'org.ton.wallets.simple' | 'org.ton.wallets.simple.r2' | 'org.ton.wallets.simple.r3' | 'org.ton.wallets.v2' | 'org.ton.wallets.v2.r2' | 'org.ton.wallets.v3' | 'org.ton.wallets.v3.r2'; | ||
@@ -11,2 +12,3 @@ export declare function validateWalletType(src: string): WalletContractType | null; | ||
static openByType(client: TonClient, workchain: number, secretKey: Buffer, type: WalletContractType): Promise<Wallet>; | ||
static openFromSource(client: TonClient, source: WalletSource): Promise<Wallet>; | ||
static findActiveBySecretKey(client: TonClient, workchain: number, secretKey: Buffer): Promise<{ | ||
@@ -24,2 +26,3 @@ address: Address; | ||
prepare(workchain: number, publicKey: Buffer, type?: WalletContractType): Promise<void>; | ||
prepareFromSource(source: WalletSource): Promise<void>; | ||
/** | ||
@@ -26,0 +29,0 @@ * Transfers value to specified address |
@@ -9,2 +9,3 @@ "use strict"; | ||
const ton_crypto_1 = require("ton-crypto"); | ||
const ContractSource_1 = require("../contracts/sources/ContractSource"); | ||
const WalletV1R2Source_1 = require("../contracts/sources/WalletV1R2Source"); | ||
@@ -85,2 +86,8 @@ const WalletV1R3Source_1 = require("../contracts/sources/WalletV1R3Source"); | ||
} | ||
static async openFromSource(client, source) { | ||
let address = await (0, ContractSource_1.contractAddress)(source); | ||
let w = new Wallet(client, address); | ||
await w.prepareFromSource(source); | ||
return w; | ||
} | ||
static async findActiveBySecretKey(client, workchain, secretKey) { | ||
@@ -156,2 +163,9 @@ const publicKey = (0, ton_crypto_1.keyPairFromSecretKey)(secretKey).publicKey; | ||
} | ||
async prepareFromSource(source) { | ||
let contra = await WalletContract_1.WalletContract.create(this.#client, source); | ||
if (!contra.address.equals(this.address)) { | ||
throw Error('Contract have different address'); | ||
} | ||
this.#contract = contra; | ||
} | ||
/** | ||
@@ -158,0 +172,0 @@ * Transfers value to specified address |
import { Address, Cell } from "../.."; | ||
export declare type ContractSource = { | ||
export interface ContractSource { | ||
initialCode: Cell; | ||
@@ -7,3 +7,3 @@ initialData: Cell; | ||
type: string; | ||
}; | ||
} | ||
export declare function contractAddress(source: ContractSource): Promise<Address>; |
@@ -14,3 +14,4 @@ /// <reference types="node" /> | ||
readonly type = "org.ton.wallets.simple"; | ||
readonly walletVersion = "v1"; | ||
private constructor(); | ||
} |
@@ -22,2 +22,3 @@ "use strict"; | ||
type = 'org.ton.wallets.simple'; | ||
walletVersion = 'v1'; | ||
constructor(opts) { | ||
@@ -24,0 +25,0 @@ this.publicKey = opts.publicKey; |
@@ -14,3 +14,4 @@ /// <reference types="node" /> | ||
readonly type = "org.ton.wallets.simple.r2"; | ||
readonly walletVersion = "v1"; | ||
private constructor(); | ||
} |
@@ -22,2 +22,3 @@ "use strict"; | ||
type = 'org.ton.wallets.simple.r2'; | ||
walletVersion = 'v1'; | ||
constructor(opts) { | ||
@@ -24,0 +25,0 @@ this.publicKey = opts.publicKey; |
@@ -14,3 +14,4 @@ /// <reference types="node" /> | ||
readonly type = "org.ton.wallets.simple.r3"; | ||
readonly walletVersion = "v1"; | ||
private constructor(); | ||
} |
@@ -22,2 +22,3 @@ "use strict"; | ||
type = 'org.ton.wallets.simple.r3'; | ||
walletVersion = 'v1'; | ||
constructor(opts) { | ||
@@ -24,0 +25,0 @@ this.publicKey = opts.publicKey; |
@@ -14,3 +14,4 @@ /// <reference types="node" /> | ||
readonly type = "org.ton.wallets.v2"; | ||
readonly walletVersion = "v2"; | ||
private constructor(); | ||
} |
@@ -22,2 +22,3 @@ "use strict"; | ||
type = 'org.ton.wallets.v2'; | ||
walletVersion = 'v2'; | ||
constructor(opts) { | ||
@@ -24,0 +25,0 @@ this.publicKey = opts.publicKey; |
@@ -14,3 +14,4 @@ /// <reference types="node" /> | ||
readonly type = "org.ton.wallets.v2.r2"; | ||
readonly walletVersion = "v2"; | ||
private constructor(); | ||
} |
@@ -22,2 +22,3 @@ "use strict"; | ||
type = 'org.ton.wallets.v2.r2'; | ||
walletVersion = 'v2'; | ||
constructor(opts) { | ||
@@ -24,0 +25,0 @@ this.publicKey = opts.publicKey; |
@@ -17,3 +17,4 @@ /// <reference types="node" /> | ||
readonly type = "org.ton.wallets.v3"; | ||
readonly walletVersion = "v3"; | ||
private constructor(); | ||
} |
@@ -38,2 +38,3 @@ "use strict"; | ||
type = 'org.ton.wallets.v3'; | ||
walletVersion = 'v3'; | ||
constructor(opts) { | ||
@@ -40,0 +41,0 @@ this.publicKey = opts.publicKey; |
@@ -17,3 +17,4 @@ /// <reference types="node" /> | ||
readonly type = "org.ton.wallets.v3.r2"; | ||
readonly walletVersion = "v3"; | ||
private constructor(); | ||
} |
@@ -38,2 +38,3 @@ "use strict"; | ||
type = 'org.ton.wallets.v3.r2'; | ||
walletVersion = 'v3'; | ||
constructor(opts) { | ||
@@ -40,0 +41,0 @@ this.publicKey = opts.publicKey; |
@@ -5,16 +5,9 @@ /// <reference types="node" /> | ||
import { Contract } from "./Contract"; | ||
import { WalletV1R1Source } from "./sources/WalletV1R1Source"; | ||
import { WalletV1R2Source } from "./sources/WalletV1R2Source"; | ||
import { WalletV1R3Source } from "./sources/WalletV1R3Source"; | ||
import { WalletV2R1Source } from "./sources/WalletV2R1Source"; | ||
import { WalletV2R2Source } from "./sources/WalletV2R2Source"; | ||
import { WalletV3R1Source } from "./sources/WalletV3R1Source"; | ||
import { WalletV3R2Source } from "./sources/WalletV3R2Source"; | ||
export declare type WalletContractSource = WalletV1R1Source | WalletV1R2Source | WalletV1R3Source | WalletV2R1Source | WalletV2R2Source | WalletV3R1Source | WalletV3R2Source; | ||
import { WalletSource } from "./sources/WalletSource"; | ||
export declare class WalletContract implements Contract { | ||
static create(client: TonClient, source: WalletContractSource): Promise<WalletContract>; | ||
static create(client: TonClient, source: WalletSource): Promise<WalletContract>; | ||
readonly client: TonClient; | ||
readonly address: Address; | ||
readonly source: WalletContractSource; | ||
constructor(client: TonClient, source: WalletContractSource, address: Address); | ||
readonly source: WalletSource; | ||
constructor(client: TonClient, source: WalletSource, address: Address); | ||
getSeqNo(): Promise<number>; | ||
@@ -21,0 +14,0 @@ createTransfer(args: { |
@@ -29,12 +29,8 @@ "use strict"; | ||
createTransfer(args) { | ||
switch (this.source.type) { | ||
case 'org.ton.wallets.simple': | ||
case 'org.ton.wallets.simple.r2': | ||
case 'org.ton.wallets.simple.r3': | ||
switch (this.source.walletVersion) { | ||
case 'v1': | ||
return (0, createWalletTransfer_1.createWalletTransferV1)({ seqno: args.seqno, sendMode: args.sendMode, secretKey: args.secretKey, order: args.order }); | ||
case 'org.ton.wallets.v2': | ||
case 'org.ton.wallets.v2.r2': | ||
case 'v2': | ||
return (0, createWalletTransfer_1.createWalletTransferV2)({ seqno: args.seqno, sendMode: args.sendMode, secretKey: args.secretKey, order: args.order }); | ||
case 'org.ton.wallets.v3': | ||
case 'org.ton.wallets.v3.r2': | ||
case 'v3': | ||
return (0, createWalletTransfer_1.createWalletTransferV3)({ seqno: args.seqno, sendMode: args.sendMode, secretKey: args.secretKey, order: args.order, walletId: this.source.walletId }); | ||
@@ -41,0 +37,0 @@ default: |
@@ -21,2 +21,3 @@ export { BitString } from './boc/BitString'; | ||
export { ContractSource } from './contracts/sources/ContractSource'; | ||
export { WalletSource } from './contracts/sources/WalletSource'; | ||
export { UnknownContractSource } from './contracts/sources/UnknownContractSource'; | ||
@@ -23,0 +24,0 @@ export { WalletV1R1Source } from './contracts/sources/WalletV1R1Source'; |
{ | ||
"name": "ton", | ||
"version": "4.5.0", | ||
"version": "4.6.0", | ||
"repository": "https://github.com/ex3ndr/ton.git", | ||
@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>", |
170537
135
4396