Skip to content

Commit

Permalink
chore: move request account logic to new file
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Jun 6, 2022
1 parent f48bf9b commit bb2c367
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
inferLegacyMessage,
} from './legacy-external-message-handler';
import { popupCenter } from './popup-center';
import { requestAccounts } from './methods/request-accounts';

initSentry();
initContextMenuActions();
Expand Down Expand Up @@ -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;
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/background/methods/request-accounts.ts
Original file line number Diff line number Diff line change
@@ -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()}`,
});
}

0 comments on commit bb2c367

Please sign in to comment.