fix: fix operation invoke

main
Steve Korshakov 2022-06-16 14:17:24 +04:00
parent 7e592196ff
commit fa2a26c05f
1 changed files with 6 additions and 2 deletions

View File

@ -73,7 +73,7 @@ export class TonhubLocalConnector {
readonly network: 'mainnet' | 'sandbox';
readonly config: TonhubLocalConfig;
#provider: (name: string, args: any) => Promise<any>
#provider: (name: string, args: any, callback: (res: any) => void) => void;
constructor(network: 'mainnet' | 'sandbox') {
if (typeof window === 'undefined') {
@ -117,7 +117,7 @@ export class TonhubLocalConnector {
}
async requestTransaction(request: TonhubLocalTransactionRequest): Promise<TonhubLocalTransactionResponse> {
let res = await this.#provider('tx', {
let res = await this.#doRequest('tx', {
network: this.network,
to: request.to,
value: request.value,
@ -137,4 +137,8 @@ export class TonhubLocalConnector {
}
throw Error(res.message);
}
async #doRequest(name: string, args: any) {
return await new Promise<any>((resolve) => this.#provider(name, args, resolve));
}
}