From 9bad83d9e226ac7a35a9b46f26d9af5ac1bcd1f4 Mon Sep 17 00:00:00 2001 From: Isacco Date: Thu, 26 Oct 2023 15:43:15 +0200 Subject: [PATCH 1/3] fix: updateActiveAccount --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index dd1cc5dea..7d6aec8c4 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -439,9 +439,14 @@ export class DAppClient extends Client { private async updateActiveAccountHandler(address?: string) { if (address && this._activeAccount.isResolved()) { - let account = await this._activeAccount.promise - account && (account.address = address) - account && (await this.setActiveAccount(account)) + const activeAccount = await this._activeAccount.promise + + const account = { + ...activeAccount, + address: address + } as AccountInfo + + await this.setActiveAccount(account) } } From e631ee0a2cdc4f7fe3e63d058a14fe021a824596 Mon Sep 17 00:00:00 2001 From: Isacco Date: Wed, 1 Nov 2023 11:22:46 +0100 Subject: [PATCH 2/3] fix: address --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 7d6aec8c4..624f91a57 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -443,7 +443,7 @@ export class DAppClient extends Client { const account = { ...activeAccount, - address: address + address } as AccountInfo await this.setActiveAccount(account) From b31ae94728473cb54d58fc69dd28e1da288221ef Mon Sep 17 00:00:00 2001 From: Isacco Date: Wed, 1 Nov 2023 17:06:11 +0100 Subject: [PATCH 3/3] fix: updateAccount --- .../src/transports/clients/ClientEvents.ts | 3 +-- .../beacon-dapp/src/dapp-client/DAppClient.ts | 17 ----------------- .../WalletConnectCommunicationClient.ts | 3 --- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/packages/beacon-core/src/transports/clients/ClientEvents.ts b/packages/beacon-core/src/transports/clients/ClientEvents.ts index 37a57a121..f050bec67 100644 --- a/packages/beacon-core/src/transports/clients/ClientEvents.ts +++ b/packages/beacon-core/src/transports/clients/ClientEvents.ts @@ -1,6 +1,5 @@ export const enum ClientEvents { CLOSE_ALERT = 'CLOSE_ALERT', RESET_STATE = 'RESET_STATE', - WC_ACK_NOTIFICATION = 'WC_ACK_NOTIFICATION', - UPDATE_ACCOUNT = 'UPDATE_ACCOUNT', + WC_ACK_NOTIFICATION = 'WC_ACK_NOTIFICATION' } diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 624f91a57..5ce34bfcb 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -431,23 +431,6 @@ export class DAppClient extends Client { ClientEvents.WC_ACK_NOTIFICATION, this.wcToastHandler.bind(this) ) - this.walletConnectTransport.setEventHandler( - ClientEvents.UPDATE_ACCOUNT, - this.updateActiveAccountHandler.bind(this) - ) - } - - private async updateActiveAccountHandler(address?: string) { - if (address && this._activeAccount.isResolved()) { - const activeAccount = await this._activeAccount.promise - - const account = { - ...activeAccount, - address - } as AccountInfo - - await this.setActiveAccount(account) - } } private async wcToastHandler() { diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index e97dbb7ee..def756574 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -527,9 +527,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient { throw new Error('Public key for the new account not provided') } - const fun = this.eventHandlers.get(ClientEvents.UPDATE_ACCOUNT) - fun && fun(this.activeAccount) - this.notifyListeners(session.pairingTopic, { id: await generateGUID(), type: BeaconMessageType.ChangeAccountRequest,