Skip to content

Commit

Permalink
fix: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Jun 19, 2024
1 parent 641e58a commit 7aadc36
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/beacon-dapp/src/dapp-client/DAppClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ export class DAppClient extends Client {
} else if (typedMessage.type === BeaconMessageType.ChangeAccountRequest) {
await this.onNewAccount(typedMessage as ChangeAccountRequest, connectionInfo)
} else {
logger.error('handleResponse', 'no request found for id ', message.id, message)
// This needs to be a debug log because, due to the BC feature,
// IDs generated in another tab will also be handled here.
logger.debug('handleResponse', 'no request found for id ', message.id, message)
}
}

Expand Down Expand Up @@ -492,8 +494,7 @@ export class DAppClient extends Client {
case BeaconMessageType.PermissionRequest:
case BeaconMessageType.OperationRequest:
case BeaconMessageType.SignPayloadRequest:
this.openRequestsOtherTabs.add(message.id)
this.makeRequest(message.data, false, message.id)
this.prepareRequest(message)
break
case 'RESPONSE':
this.handleResponse(message.data.message, message.data.connectionInfo)
Expand All @@ -506,6 +507,15 @@ export class DAppClient extends Client {
}
}

private prepareRequest(message: any) {
if (!this.multiTabChannel.isLeader()) {
return
}

this.openRequestsOtherTabs.add(message.id)
this.makeRequest(message.data, false, message.id)
}

private async createStateSnapshot() {
if (!localStorage || !this.enableMetrics) {
return
Expand Down

0 comments on commit 7aadc36

Please sign in to comment.