diff --git a/src/chrome/offscreen/helpers/initialize.ts b/src/chrome/offscreen/helpers/offscreen-initialization-messages.ts similarity index 69% rename from src/chrome/offscreen/helpers/initialize.ts rename to src/chrome/offscreen/helpers/offscreen-initialization-messages.ts index 47e1c57d..c5949997 100644 --- a/src/chrome/offscreen/helpers/initialize.ts +++ b/src/chrome/offscreen/helpers/offscreen-initialization-messages.ts @@ -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 diff --git a/src/chrome/offscreen/offscreen.ts b/src/chrome/offscreen/offscreen.ts index 342444e3..2377a641 100644 --- a/src/chrome/offscreen/offscreen.ts +++ b/src/chrome/offscreen/offscreen.ts @@ -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() @@ -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 { diff --git a/src/queues/worker.ts b/src/queues/worker.ts index 4141f6a3..23c72023 100644 --- a/src/queues/worker.ts +++ b/src/queues/worker.ts @@ -19,7 +19,7 @@ export const Worker = ( ) => { const run = (job: Job): WorkerRunnerOutput => fn(job).mapErr((error) => { - logger?.error(error) + logger?.error({ error, jobId: job.id }) return error }) return { run }