diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-07-29 22:53:17 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-07-29 22:53:17 +0530 |
commit | dfe5e95bc8537e13c482fff42cfefeb090eb2e09 (patch) | |
tree | 028d307a9536fce64a4868aeddc8c11e1ed84e0c /src/android | |
parent | 9a4cbcd9549fee9865a537ed5236e2a2ebe52cf1 (diff) |
fix Android response, stronger typingv0.7.1-dev.12
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/index.ts | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/android/index.ts b/src/android/index.ts index b9131a6df..82d8309b8 100644 --- a/src/android/index.ts +++ b/src/android/index.ts @@ -20,7 +20,6 @@ import { Wallet } from "../wallet"; import { getDefaultNodeWallet, - withdrawTestBalance, DefaultNodeWalletArgs, } from "../headless/helpers"; import { openPromise, OpenedPromise } from "../util/promiseUtils"; @@ -37,8 +36,11 @@ import { WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_MERCHANT_PROTOCOL_VERSION, } from "../operations/versions"; -import { Amounts } from "../util/amounts"; -import { handleCoreApiRequest } from "../walletCoreApiHandler"; +import { + handleCoreApiRequest, + CoreApiResponseSuccess, + CoreApiResponse, +} from "../walletCoreApiHandler"; // @ts-ignore: special built-in module //import akono = require("akono"); @@ -144,7 +146,20 @@ class AndroidWalletMessageHandler { /** * Handle a request from the Android wallet. */ - async handleMessage(operation: string, id: string, args: any): Promise<any> { + async handleMessage( + operation: string, + id: string, + args: any, + ): Promise<CoreApiResponse> { + const wrapResponse = (result: unknown): CoreApiResponseSuccess => { + return { + type: "response", + isError: false, + id, + operation, + result, + }; + }; switch (operation) { case "init": { this.walletArgs = { @@ -162,15 +177,15 @@ class AndroidWalletMessageHandler { console.error("Error during wallet retry loop", e); }); this.wp.resolve(w); - return { + return wrapResponse({ supported_protocol_versions: { exchange: WALLET_EXCHANGE_PROTOCOL_VERSION, merchant: WALLET_MERCHANT_PROTOCOL_VERSION, }, - }; + }); } case "getHistory": { - return []; + return wrapResponse({ history: [] }); } case "startTunnel": { // this.httpLib.useNfcTunnel = true; @@ -206,13 +221,12 @@ class AndroidWalletMessageHandler { console.error("Error during wallet retry loop", e); }); this.wp.resolve(w); - return {}; + return wrapResponse({}); } default: { const wallet = await this.wp.promise; return await handleCoreApiRequest(wallet, operation, id, args); } - } } } |