diff --git a/apps/extension/src/entry/popup-root.tsx b/apps/extension/src/entry/popup-root.tsx index 5aab9d1a..4f42f0d1 100644 --- a/apps/extension/src/entry/popup-root.tsx +++ b/apps/extension/src/entry/popup-root.tsx @@ -21,7 +21,6 @@ chrome.runtime.onMessage.addListener( if (isTxApprovalRequest(req)) { void txApprovalSelector(useStore.getState()).acceptRequest(req, responder); } else if (isOriginApprovalRequest(req)) { - req.request.origin; originApprovalSelector(useStore.getState()).acceptRequest(req, responder); } else { throw new Error('Unknown popup request'); diff --git a/apps/extension/src/message/popup.ts b/apps/extension/src/message/popup.ts index 973ad583..092cc61f 100644 --- a/apps/extension/src/message/popup.ts +++ b/apps/extension/src/message/popup.ts @@ -51,11 +51,19 @@ export const isPopupRequest = (req: unknown): req is PopupRequest => typeof req.type === 'string' && req.type in PopupType; +export const isPopupResponse = (res: unknown): res is PopupResponse => + res != null && + typeof res === 'object' && + ('data' in res || 'error' in res) && + 'type' in res && + typeof res.type === 'string' && + res.type in PopupType; + export const isOriginApprovalRequest = (req: unknown): req is InternalRequest => isPopupRequest(req) && req.type === PopupType.OriginApproval; export const isTxApprovalRequest = (req: unknown): req is InternalRequest => isPopupRequest(req) && req.type === PopupType.TxApproval; -export const isPopupReadyResponse = (req: unknown): req is InternalResponse => - isPopupRequest(req) && req.type === PopupType.Ready; +export const isPopupReadyResponse = (res: unknown): res is InternalResponse => + isPopupResponse(res) && res.type === PopupType.Ready;