@tonclient/core
Version:
TON Client for Java Script
48 lines • 2.18 kB
TypeScript
import { ClientConfig } from "./modules";
export declare type ResponseHandler = (params: any, responseType: number) => void;
export interface BinaryLibraryBase {
createContext(configJson: string): Promise<string>;
destroyContext(context: number): void;
}
export interface BinaryLibrary extends BinaryLibraryBase {
setResponseHandler(handler?: (requestId: number, paramsJson: string, responseType: number, finished: boolean) => void): void;
sendRequest(context: number, requestId: number, functionName: string, functionParamsJson: string): void;
}
export interface BinaryLibraryWithParams extends BinaryLibraryBase {
setResponseParamsHandler(handler?: (requestId: number, params: any, responseType: number, finished: boolean) => void): void;
sendRequestParams(context: number, requestId: number, functionName: string, functionParams: any): void;
}
export declare enum ResponseType {
Success = 0,
Error = 1,
Nop = 2,
AppRequest = 3,
AppNotify = 4,
Custom = 100
}
export interface BinaryBridge {
createContext(config: ClientConfig): Promise<number>;
destroyContext(context: number): void;
request<P, R>(context: number, functionName: string, functionParams: P, responseHandler?: ResponseHandler): Promise<R>;
}
export declare function getBridge(): BinaryBridge;
export declare function useLibrary(loader: (() => Promise<BinaryLibrary | BinaryLibraryWithParams>) | BinaryBridge): void;
export declare class CommonBinaryBridge implements BinaryBridge {
private loading;
private loadError;
private library;
private requests;
private nextRequestId;
private contextCount;
private responseHandlerAssigned;
constructor(loader: () => Promise<BinaryLibrary | BinaryLibraryWithParams>);
private checkResponseHandler;
createContext(config: ClientConfig): Promise<number>;
destroyContext(context: number): void;
request<P, R>(context: number, functionName: string, functionParams: P, responseHandler?: ResponseHandler): Promise<R>;
private loadRequired;
private generateRequestId;
private handleLibraryResponse;
private static parseResult;
}
//# sourceMappingURL=bin.d.ts.map