From cf850572feef8d9720aba062fd6b1d76037ceb93 Mon Sep 17 00:00:00 2001 From: thekiba Date: Sat, 2 Dec 2023 23:49:33 +0400 Subject: [PATCH] fix(sdk): added waiting for bridge response before calling onRequestSent --- .../sdk/src/provider/bridge/bridge-provider.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/sdk/src/provider/bridge/bridge-provider.ts b/packages/sdk/src/provider/bridge/bridge-provider.ts index 4242a926..b84462c1 100644 --- a/packages/sdk/src/provider/bridge/bridge-provider.ts +++ b/packages/sdk/src/provider/bridge/bridge-provider.ts @@ -161,11 +161,17 @@ export class BridgeProvider implements HTTPProvider { hexToByteArray(this.session.walletPublicKey) ); - this.gateway - .send(encodedRequest, this.session.walletPublicKey, request.method) - .catch(reject); - this.pendingRequests.set(id.toString(), resolve); - onRequestSent?.(); + try { + await this.gateway.send( + encodedRequest, + this.session.walletPublicKey, + request.method + ); + onRequestSent?.(); + this.pendingRequests.set(id.toString(), resolve); + } catch (e) { + reject(e); + } }); }