Skip to content

Commit

Permalink
feat: throw error if frame is not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir committed Oct 4, 2024
1 parent 152aefe commit c4a9150
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/wallet/src/W3mFrameProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface W3mFrameProviderConfig {

// -- Provider --------------------------------------------------------
export class W3mFrameProvider {
private ready = false
public w3mLogger: W3mFrameLogger
private w3mFrame: W3mFrame
private openRpcRequests: Array<W3mFrameTypes.RPCRequest & { abortController: AbortController }> =
Expand All @@ -33,6 +34,20 @@ export class W3mFrameProvider {
this.w3mLogger = new W3mFrameLogger(projectId)
this.w3mFrame = new W3mFrame(projectId, true, chainId)
this.onTimeout = onTimeout

this.w3mFrame.events.onFrameEvent(event => {
if (event.type === W3mFrameConstants.FRAME_READY) {
this.ready = true
}
})

setTimeout(() => {
if (!this.ready) {
this.w3mLogger.logger.error(
'W3mFrame could not be mounted. Please review your configuration.'
)
}
}, 10_000)
}

// -- Extended Methods ------------------------------------------------
Expand Down

0 comments on commit c4a9150

Please sign in to comment.