/** * Copyright (c) Whales Corp. * All Rights Reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /// import { AxiosAdapter } from "axios"; import { Address, Cell, Contract, ContractProvider, Transaction, TupleItem, TupleReader } from "ton-core"; import { z } from 'zod'; export declare type TonClient4Parameters = { /** * API endpoint */ endpoint: string; /** * HTTP request timeout in milliseconds. */ timeout?: number; /** * HTTP Adapter for axios */ httpAdapter?: AxiosAdapter; }; export declare class TonClient4 { #private; constructor(args: TonClient4Parameters); /** * Get Last Block * @returns last block info */ getLastBlock(): Promise<{ last: { workchain: number; shard: string; seqno: number; fileHash: string; rootHash: string; }; init: { fileHash: string; rootHash: string; }; stateRootHash: string; now: number; }>; /** * Get block info * @param seqno block sequence number * @returns block info */ getBlock(seqno: number): Promise<{ shards: { workchain: number; shard: string; seqno: number; transactions: { lt: string; hash: string; account: string; }[]; fileHash: string; rootHash: string; }[]; }>; /** * Get block info by unix timestamp * @param ts unix timestamp * @returns block info */ getBlockByUtime(ts: number): Promise<{ shards: { workchain: number; shard: string; seqno: number; transactions: { lt: string; hash: string; account: string; }[]; fileHash: string; rootHash: string; }[]; }>; /** * Get block info by unix timestamp * @param seqno block sequence number * @param address account address * @returns account info */ getAccount(seqno: number, address: Address): Promise<{ account: { balance: { coins: string; }; state: { type: "uninit"; } | { data: string | null; code: string | null; type: "active"; } | { type: "frozen"; stateHash: string; }; last: { lt: string; hash: string; } | null; storageStat: { lastPaid: number; duePayment: string | null; used: { bits: number; cells: number; publicCells: number; }; } | null; }; block: { workchain: number; shard: string; seqno: number; fileHash: string; rootHash: string; }; }>; /** * Get account lite info (without code and data) * @param seqno block sequence number * @param address account address * @returns account lite info */ getAccountLite(seqno: number, address: Address): Promise<{ account: { balance: { coins: string; }; state: { type: "uninit"; } | { type: "active"; codeHash: string; dataHash: string; } | { type: "frozen"; stateHash: string; }; last: { lt: string; hash: string; } | null; storageStat: { lastPaid: number; duePayment: string | null; used: { bits: number; cells: number; publicCells: number; }; } | null; }; }>; /** * Check if contract is deployed * @param address addres to check * @returns true if contract is in active state */ isContractDeployed(seqno: number, address: Address): Promise; /** * Check if account was updated since * @param seqno block sequence number * @param address account address * @param lt account last transaction lt * @returns account change info */ isAccountChanged(seqno: number, address: Address, lt: bigint): Promise<{ block: { workchain: number; shard: string; seqno: number; fileHash: string; rootHash: string; }; changed: boolean; }>; /** * Load unparsed account transactions * @param address address * @param lt last transaction lt * @param hash last transaction hash * @returns unparsed transactions */ getAccountTransactions(address: Address, lt: bigint, hash: Buffer): Promise<{ block: { workchain: number; seqno: number; shard: string; rootHash: string; fileHash: string; }; tx: Transaction; }[]>; /** * Load parsed account transactions * @param address address * @param lt last transaction lt * @param hash last transaction hash * @param count number of transactions to load * @returns parsed transactions */ getAccountTransactionsParsed(address: Address, lt: bigint, hash: Buffer, count?: number): Promise; /** * Get network config * @param seqno block sequence number * @param ids optional config ids * @returns network config */ getConfig(seqno: number, ids?: number[]): Promise<{ config: { cell: string; address: string; globalBalance: { coins: string; }; }; }>; /** * Execute run method * @param seqno block sequence number * @param address account address * @param name method name * @param args method arguments * @returns method result */ runMethod(seqno: number, address: Address, name: string, args?: TupleItem[]): Promise<{ exitCode: number; result: TupleItem[]; resultRaw: string | null; block: { workchain: number; shard: string; seqno: number; fileHash: string; rootHash: string; }; shardBlock: { workchain: number; shard: string; seqno: number; fileHash: string; rootHash: string; }; reader: TupleReader; }>; /** * Send external message * @param message message boc * @returns message status */ sendMessage(message: Buffer): Promise<{ status: any; }>; /** * Open smart contract * @param contract contract * @returns opened contract */ open(contract: T): import("ton-core").OpenedContract; /** * Open smart contract * @param block block number * @param contract contract * @returns opened contract */ openAt(block: number, contract: T): import("ton-core").OpenedContract; /** * Create provider * @param address address * @param init optional init data * @returns provider */ provider(address: Address, init?: { code: Cell; data: Cell; } | null): ContractProvider; /** * Create provider at specified block number * @param block block number * @param address address * @param init optional init data * @returns provider */ providerAt(block: number, address: Address, init?: { code: Cell; data: Cell; } | null): ContractProvider; } declare const blocksCodec: z.ZodArray, "many">; declare const parsedTransactionCodec: z.ZodObject<{ address: z.ZodString; lt: z.ZodString; hash: z.ZodString; prevTransaction: z.ZodObject<{ lt: z.ZodString; hash: z.ZodString; }, "strip", z.ZodTypeAny, { lt: string; hash: string; }, { lt: string; hash: string; }>; time: z.ZodNumber; outMessagesCount: z.ZodNumber; oldStatus: z.ZodUnion<[z.ZodLiteral<"uninitialized">, z.ZodLiteral<"frozen">, z.ZodLiteral<"active">, z.ZodLiteral<"non-existing">]>; newStatus: z.ZodUnion<[z.ZodLiteral<"uninitialized">, z.ZodLiteral<"frozen">, z.ZodLiteral<"active">, z.ZodLiteral<"non-existing">]>; fees: z.ZodString; update: z.ZodObject<{ oldHash: z.ZodString; newHash: z.ZodString; }, "strip", z.ZodTypeAny, { oldHash: string; newHash: string; }, { oldHash: string; newHash: string; }>; inMessage: z.ZodUnion<[z.ZodObject<{ body: z.ZodString; info: z.ZodUnion<[z.ZodObject<{ type: z.ZodLiteral<"internal">; value: z.ZodString; dest: z.ZodString; src: z.ZodString; bounced: z.ZodBoolean; bounce: z.ZodBoolean; ihrDisabled: z.ZodBoolean; createdAt: z.ZodNumber; createdLt: z.ZodString; fwdFee: z.ZodString; ihrFee: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; }, { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; }>, z.ZodObject<{ type: z.ZodLiteral<"external-in">; dest: z.ZodString; src: z.ZodUnion<[z.ZodObject<{ bits: z.ZodNumber; data: z.ZodString; }, "strip", z.ZodTypeAny, { data: string; bits: number; }, { data: string; bits: number; }>, z.ZodNull]>; importFee: z.ZodString; }, "strip", z.ZodTypeAny, { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; }, { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; }>, z.ZodObject<{ type: z.ZodLiteral<"external-out">; dest: z.ZodUnion<[z.ZodObject<{ bits: z.ZodNumber; data: z.ZodString; }, "strip", z.ZodTypeAny, { data: string; bits: number; }, { data: string; bits: number; }>, z.ZodNull]>; }, "strip", z.ZodTypeAny, { type: "external-out"; dest: { data: string; bits: number; } | null; }, { type: "external-out"; dest: { data: string; bits: number; } | null; }>]>; init: z.ZodUnion<[z.ZodObject<{ splitDepth: z.ZodUnion<[z.ZodNumber, z.ZodNull]>; code: z.ZodUnion<[z.ZodString, z.ZodNull]>; data: z.ZodUnion<[z.ZodString, z.ZodNull]>; special: z.ZodUnion<[z.ZodObject<{ tick: z.ZodBoolean; tock: z.ZodBoolean; }, "strip", z.ZodTypeAny, { tick: boolean; tock: boolean; }, { tick: boolean; tock: boolean; }>, z.ZodNull]>; }, "strip", z.ZodTypeAny, { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; }, { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; }>, z.ZodNull]>; }, "strip", z.ZodTypeAny, { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; }, { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; }>, z.ZodNull]>; outMessages: z.ZodArray; value: z.ZodString; dest: z.ZodString; src: z.ZodString; bounced: z.ZodBoolean; bounce: z.ZodBoolean; ihrDisabled: z.ZodBoolean; createdAt: z.ZodNumber; createdLt: z.ZodString; fwdFee: z.ZodString; ihrFee: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; }, { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; }>, z.ZodObject<{ type: z.ZodLiteral<"external-in">; dest: z.ZodString; src: z.ZodUnion<[z.ZodObject<{ bits: z.ZodNumber; data: z.ZodString; }, "strip", z.ZodTypeAny, { data: string; bits: number; }, { data: string; bits: number; }>, z.ZodNull]>; importFee: z.ZodString; }, "strip", z.ZodTypeAny, { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; }, { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; }>, z.ZodObject<{ type: z.ZodLiteral<"external-out">; dest: z.ZodUnion<[z.ZodObject<{ bits: z.ZodNumber; data: z.ZodString; }, "strip", z.ZodTypeAny, { data: string; bits: number; }, { data: string; bits: number; }>, z.ZodNull]>; }, "strip", z.ZodTypeAny, { type: "external-out"; dest: { data: string; bits: number; } | null; }, { type: "external-out"; dest: { data: string; bits: number; } | null; }>]>; init: z.ZodUnion<[z.ZodObject<{ splitDepth: z.ZodUnion<[z.ZodNumber, z.ZodNull]>; code: z.ZodUnion<[z.ZodString, z.ZodNull]>; data: z.ZodUnion<[z.ZodString, z.ZodNull]>; special: z.ZodUnion<[z.ZodObject<{ tick: z.ZodBoolean; tock: z.ZodBoolean; }, "strip", z.ZodTypeAny, { tick: boolean; tock: boolean; }, { tick: boolean; tock: boolean; }>, z.ZodNull]>; }, "strip", z.ZodTypeAny, { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; }, { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; }>, z.ZodNull]>; }, "strip", z.ZodTypeAny, { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; }, { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; }>, "many">; parsed: z.ZodObject<{ seqno: z.ZodUnion<[z.ZodNumber, z.ZodNull]>; body: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{ type: z.ZodLiteral<"comment">; comment: z.ZodString; }, "strip", z.ZodTypeAny, { type: "comment"; comment: string; }, { type: "comment"; comment: string; }>, z.ZodObject<{ type: z.ZodLiteral<"payload">; cell: z.ZodString; }, "strip", z.ZodTypeAny, { type: "payload"; cell: string; }, { type: "payload"; cell: string; }>]>, z.ZodNull]>; status: z.ZodUnion<[z.ZodLiteral<"success">, z.ZodLiteral<"failed">, z.ZodLiteral<"pending">]>; dest: z.ZodUnion<[z.ZodString, z.ZodNull]>; kind: z.ZodUnion<[z.ZodLiteral<"out">, z.ZodLiteral<"in">]>; amount: z.ZodString; resolvedAddress: z.ZodString; bounced: z.ZodBoolean; mentioned: z.ZodArray; }, "strip", z.ZodTypeAny, { status: "success" | "failed" | "pending"; seqno: number | null; body: { type: "comment"; comment: string; } | { type: "payload"; cell: string; } | null; dest: string | null; bounced: boolean; kind: "out" | "in"; amount: string; resolvedAddress: string; mentioned: string[]; }, { status: "success" | "failed" | "pending"; seqno: number | null; body: { type: "comment"; comment: string; } | { type: "payload"; cell: string; } | null; dest: string | null; bounced: boolean; kind: "out" | "in"; amount: string; resolvedAddress: string; mentioned: string[]; }>; operation: z.ZodObject<{ address: z.ZodString; comment: z.ZodOptional; items: z.ZodArray; amount: z.ZodString; }, "strip", z.ZodTypeAny, { kind: "ton"; amount: string; }, { kind: "ton"; amount: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"token">; amount: z.ZodString; }, "strip", z.ZodTypeAny, { kind: "token"; amount: string; }, { kind: "token"; amount: string; }>]>, "many">; op: z.ZodOptional, z.ZodLiteral<"jetton::transfer">, z.ZodLiteral<"jetton::transfer_notification">, z.ZodLiteral<"deposit">, z.ZodLiteral<"deposit::ok">, z.ZodLiteral<"withdraw">, z.ZodLiteral<"withdraw::all">, z.ZodLiteral<"withdraw::delayed">, z.ZodLiteral<"withdraw::ok">, z.ZodLiteral<"airdrop">]>; options: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: "jetton::excesses" | "jetton::transfer" | "jetton::transfer_notification" | "deposit" | "deposit::ok" | "withdraw" | "withdraw::all" | "withdraw::delayed" | "withdraw::ok" | "airdrop"; options?: Record | undefined; }, { type: "jetton::excesses" | "jetton::transfer" | "jetton::transfer_notification" | "deposit" | "deposit::ok" | "withdraw" | "withdraw::all" | "withdraw::delayed" | "withdraw::ok" | "airdrop"; options?: Record | undefined; }>>; }, "strip", z.ZodTypeAny, { items: ({ kind: "ton"; amount: string; } | { kind: "token"; amount: string; })[]; address: string; comment?: string | undefined; op?: { type: "jetton::excesses" | "jetton::transfer" | "jetton::transfer_notification" | "deposit" | "deposit::ok" | "withdraw" | "withdraw::all" | "withdraw::delayed" | "withdraw::ok" | "airdrop"; options?: Record | undefined; } | undefined; }, { items: ({ kind: "ton"; amount: string; } | { kind: "token"; amount: string; })[]; address: string; comment?: string | undefined; op?: { type: "jetton::excesses" | "jetton::transfer" | "jetton::transfer_notification" | "deposit" | "deposit::ok" | "withdraw" | "withdraw::all" | "withdraw::delayed" | "withdraw::ok" | "airdrop"; options?: Record | undefined; } | undefined; }>; }, "strip", z.ZodTypeAny, { lt: string; hash: string; fees: string; address: string; prevTransaction: { lt: string; hash: string; }; time: number; outMessagesCount: number; oldStatus: "active" | "uninitialized" | "frozen" | "non-existing"; newStatus: "active" | "uninitialized" | "frozen" | "non-existing"; update: { oldHash: string; newHash: string; }; inMessage: { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; } | null; outMessages: { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; }[]; parsed: { status: "success" | "failed" | "pending"; seqno: number | null; body: { type: "comment"; comment: string; } | { type: "payload"; cell: string; } | null; dest: string | null; bounced: boolean; kind: "out" | "in"; amount: string; resolvedAddress: string; mentioned: string[]; }; operation: { items: ({ kind: "ton"; amount: string; } | { kind: "token"; amount: string; })[]; address: string; comment?: string | undefined; op?: { type: "jetton::excesses" | "jetton::transfer" | "jetton::transfer_notification" | "deposit" | "deposit::ok" | "withdraw" | "withdraw::all" | "withdraw::delayed" | "withdraw::ok" | "airdrop"; options?: Record | undefined; } | undefined; }; }, { lt: string; hash: string; fees: string; address: string; prevTransaction: { lt: string; hash: string; }; time: number; outMessagesCount: number; oldStatus: "active" | "uninitialized" | "frozen" | "non-existing"; newStatus: "active" | "uninitialized" | "frozen" | "non-existing"; update: { oldHash: string; newHash: string; }; inMessage: { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; } | null; outMessages: { body: string; init: { data: string | null; code: string | null; splitDepth: number | null; special: { tick: boolean; tock: boolean; } | null; } | null; info: { value: string; type: "internal"; dest: string; src: string; bounced: boolean; bounce: boolean; ihrDisabled: boolean; createdAt: number; createdLt: string; fwdFee: string; ihrFee: string; } | { type: "external-in"; dest: string; src: { data: string; bits: number; } | null; importFee: string; } | { type: "external-out"; dest: { data: string; bits: number; } | null; }; }[]; parsed: { status: "success" | "failed" | "pending"; seqno: number | null; body: { type: "comment"; comment: string; } | { type: "payload"; cell: string; } | null; dest: string | null; bounced: boolean; kind: "out" | "in"; amount: string; resolvedAddress: string; mentioned: string[]; }; operation: { items: ({ kind: "ton"; amount: string; } | { kind: "token"; amount: string; })[]; address: string; comment?: string | undefined; op?: { type: "jetton::excesses" | "jetton::transfer" | "jetton::transfer_notification" | "deposit" | "deposit::ok" | "withdraw" | "withdraw::all" | "withdraw::delayed" | "withdraw::ok" | "airdrop"; options?: Record | undefined; } | undefined; }; }>; export declare type ParsedTransaction = z.infer; export declare type ParsedTransactions = { blocks: z.infer; transactions: ParsedTransaction[]; }; export {};