Skip to content

Commit

Permalink
refactor: rename functions & add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidsowardx committed May 17, 2024
1 parent b5bdd7b commit fa706c3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ import { ConnectorExtensionOptions } from 'options'
import { SessionId, WalletPublicKey } from '../session-router'
import { Connections } from 'pairing/state/connections'

export const initialize = (messageClient: MessageClient) => {
/**
* This section of code handles the retrieval of important data from the background page
* in order to provide necessary information to the offscreen page.
*
* The offscreen page does not have direct access to chrome.storage, so it relies on sending messages
* to the background page to obtain the following data:
* - Connector Extension Options
* - Session Router Data
* - Wallet Connections
*
* Each function within this code block is responsible for retrieving one specific key from the chrome storage.
*/
export const OffscreenInitializationMessages = (
messageClient: MessageClient,
) => {
return {
options: () => {
messageClient
Expand Down
10 changes: 5 additions & 5 deletions src/chrome/offscreen/offscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Message } from 'chrome/messages/_types'
import { LogsClient } from './logs-client'
import { WalletConnectionClient } from './wallet-connection/wallet-connection-client'
import { walletConnectionClientFactory } from './wallet-connection/factory'
import { initialize } from './helpers/initialize'
import { OffscreenInitializationMessages } from './helpers/offscreen-initialization-messages'

const logsClient = LogsClient()

Expand All @@ -32,11 +32,11 @@ chrome.runtime.onMessage.addListener((message: Message, sender) => {
messageClient.onMessage(message, sender.tab?.id)
})

const init = initialize(messageClient)
const messages = OffscreenInitializationMessages(messageClient)

init.options()
init.sessionRouterData()
init.connections()
messages.options()
messages.sessionRouterData()
messages.connections()

declare global {
interface Window {
Expand Down
2 changes: 1 addition & 1 deletion src/queues/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Worker = <T>(
) => {
const run = (job: Job<T>): WorkerRunnerOutput =>
fn(job).mapErr((error) => {
logger?.error(error)
logger?.error({ error, jobId: job.id })
return error
})
return { run }
Expand Down

0 comments on commit fa706c3

Please sign in to comment.