From 4365cd6401713b2e207d8c032c0558487e860154 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 28 Jul 2020 14:22:35 +0530 Subject: towards the new withdrawal API (temporarily breaks WebExtension wallet) --- src/webex/wxBackend.ts | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'src/webex/wxBackend.ts') diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts index 793f4b5d3..39fcf899e 100644 --- a/src/webex/wxBackend.ts +++ b/src/webex/wxBackend.ts @@ -35,7 +35,6 @@ import { OpenedPromise, openPromise } from "../util/promiseUtils"; import { classifyTalerUri, TalerUriType } from "../util/taleruri"; import { Wallet } from "../wallet"; import { isFirefox, getPermissionsApi } from "./compat"; -import { MessageType } from "./messages"; import * as wxApi from "./wxApi"; import MessageSender = chrome.runtime.MessageSender; import { Database } from "../util/query"; @@ -62,19 +61,9 @@ const notificationPorts: chrome.runtime.Port[] = []; async function handleMessage( sender: MessageSender, - type: MessageType, + type: string, detail: any, ): Promise { - function assertNotFound(t: never): never { - console.error(`Request type ${t as string} unknown`); - console.error(`Request detail was ${detail}`); - return { - error: { - message: `request type ${t as string} unknown`, - requestType: type, - }, - } as never; - } function needsWallet(): Wallet { if (!currentWallet) { throw NeedsWallet; @@ -204,12 +193,6 @@ async function handleMessage( } return needsWallet().benchmarkCrypto(detail.repetitions); } - case "get-withdraw-details": { - return needsWallet().getWithdrawDetailsForUri( - detail.talerWithdrawUri, - detail.maybeSelectedExchange, - ); - } case "accept-withdrawal": { return needsWallet().acceptWithdrawal( detail.talerWithdrawUri, @@ -280,9 +263,14 @@ async function handleMessage( return { newValue: res }; } default: - // Exhaustiveness check. - // See https://www.typescriptlang.org/docs/handbook/advanced-types.html - return assertNotFound(type); + console.error(`Request type ${type} unknown`); + console.error(`Request detail was ${detail}`); + return { + error: { + message: `request type ${type} unknown`, + requestType: type, + }, + }; } } @@ -354,7 +342,7 @@ function makeSyncWalletRedirect( tabId: number, oldUrl: string, params?: { [name: string]: string | undefined }, -): object { +): Record { const innerUrl = new URL(chrome.extension.getURL("/" + url)); if (params) { for (const key in params) { -- cgit v1.2.3