diff --git a/src/background/background.ts b/src/background/background.ts index e22acf35ff7..108e187f55b 100755 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -21,6 +21,7 @@ import { inferLegacyMessage, } from './legacy-external-message-handler'; import { popupCenter } from './popup-center'; +import { requestAccounts } from './methods/request-accounts'; initSentry(); initContextMenuActions(); @@ -59,13 +60,7 @@ chrome.runtime.onConnect.addListener(port => switch (message.method) { case RpcMethods[RpcMethods.stx_requestAccounts]: { - const params = new URLSearchParams(); - params.set('tabId', port.sender.tab.id.toString()); - params.set('id', message.id); - params.set('origin', port.sender.origin.toString()); - popupCenter({ - url: `/popup-center.html#${RouteUrls.AccountRequest}?${params.toString()}`, - }); + requestAccounts(port.sender.tab.id, port.sender.origin, message); break; } } diff --git a/src/background/methods/request-accounts.ts b/src/background/methods/request-accounts.ts new file mode 100644 index 00000000000..70933c2d642 --- /dev/null +++ b/src/background/methods/request-accounts.ts @@ -0,0 +1,15 @@ +import { popupCenter } from '@background/popup-center'; +import { SupportedRpcMessages } from '@shared/message-types'; +import { RouteUrls } from '@shared/route-urls'; + +export function requestAccounts(tabId: number, origin: string, message: SupportedRpcMessages) { + const params = new URLSearchParams(); + + params.set('tabId', tabId.toString()); + params.set('id', message.id); + params.set('origin', origin.toString()); + + popupCenter({ + url: `/popup-center.html#${RouteUrls.AccountRequest}?${params.toString()}`, + }); +}