From c522979abcbe38828b6c6088c8667ea34980057a Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Fri, 20 Sep 2024 19:27:14 +0200 Subject: [PATCH] fix: hide ui --- .../beacon-core/src/utils/multi-tab-channel.ts | 1 + .../beacon-dapp/src/dapp-client/DAppClient.ts | 16 ++++++++++++---- .../src/WalletConnectTransport.ts | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/beacon-core/src/utils/multi-tab-channel.ts b/packages/beacon-core/src/utils/multi-tab-channel.ts index ce5b0bfe0..c77c0b9fc 100644 --- a/packages/beacon-core/src/utils/multi-tab-channel.ts +++ b/packages/beacon-core/src/utils/multi-tab-channel.ts @@ -14,6 +14,7 @@ type BCMessageType = | 'DISCONNECT' | 'REQUEST_PAIRING' | 'RESPONSE_PAIRING' + | 'HIDE_UI' | BeaconMessageType type BCMessage = { diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 5bd63dd2c..5ef5fdce9 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -500,6 +500,9 @@ export class DAppClient extends Client { case 'RESPONSE_PAIRING': this.handlePairingResponse(message.data) break + case 'HIDE_UI': + this.hideUI(message.data) + break default: logger.error('onBCMessageHandler', 'message type not recognized', message) } @@ -535,15 +538,20 @@ export class DAppClient extends Client { const { message, connectionInfo } = await this.makeRequest< PermissionRequest, PermissionResponse - >(request).catch((err) => { - throw new Error(err.message) - }) + >(request) await this.hideUI(['toast']) const accountInfo = await this.onNewAccount(message, connectionInfo) await this.accountManager.addAccount(accountInfo) - // todo output + + this.walletConnectTransport?.connect() + + this.multiTabChannel.postMessage({ + type: 'HIDE_UI', + recipient, + data: ['alert', 'toast'] + }) }) .catch(console.error) diff --git a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts index ba11c3d19..20dcc8210 100644 --- a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts +++ b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts @@ -57,6 +57,7 @@ export class WalletConnectTransport< public async connect(): Promise { if ([TransportStatus.CONNECTED, TransportStatus.CONNECTING].includes(this._isConnected)) { + this.isReady.isPending() && this.isReady.resolve(true) return }