summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-24 16:33:10 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-24 16:33:10 +0200
commit39cca9f8f6050d6e35c88f8cd3c6e825eae9cb9f (patch)
treef97ab3222874e99e2644412b0e17c3f6e4b00547
parent0fb77c2519a41a1f63447bc1aa84e1bf82a74758 (diff)
downloadwallet-core-39cca9f8f6050d6e35c88f8cd3c6e825eae9cb9f.tar.gz
wallet-core-39cca9f8f6050d6e35c88f8cd3c6e825eae9cb9f.tar.bz2
wallet-core-39cca9f8f6050d6e35c88f8cd3c6e825eae9cb9f.zip
imports and comments; expose wallet for debugging
-rw-r--r--src/wxBackend.ts63
1 files changed, 34 insertions, 29 deletions
diff --git a/src/wxBackend.ts b/src/wxBackend.ts
index 089526a43..a5b8c667f 100644
--- a/src/wxBackend.ts
+++ b/src/wxBackend.ts
@@ -14,41 +14,48 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+/**
+ * Messaging for the WebExtensions wallet. Should contain
+ * parts that are specific for WebExtensions, but as little business
+ * logic as possible.
+ */
+
+/**
+ * Imports.
+ */
import {
- Wallet,
- OfferRecord,
Badge,
ConfirmReserveRequest,
- CreateReserveRequest
+ CreateReserveRequest,
+ OfferRecord,
+ Stores,
+ Wallet,
} from "./wallet";
-import { BrowserHttpLib } from "./http";
-import { Checkable } from "./checkable";
-import { AmountJson } from "./types";
-import Port = chrome.runtime.Port;
-import { Notifier } from "./types";
-import { Contract } from "./types";
+import {
+ AmountJson,
+ Contract,
+ Notifier,
+} from "./types";
import MessageSender = chrome.runtime.MessageSender;
import { ChromeBadge } from "./chromeBadge";
import * as logging from "./logging";
+import { Store, Index } from "./query";
+import { BrowserHttpLib } from "./http";
+import { Checkable } from "./checkable";
+import Port = chrome.runtime.Port;
import URI = require("urijs");
-"use strict";
const DB_NAME = "taler";
-const DB_VERSION = 17;
-
-import {Stores} from "./wallet";
-import {Store, Index} from "./query";
/**
- * Messaging for the WebExtensions wallet. Should contain
- * parts that are specific for WebExtensions, but as little business
- * logic as possible.
- *
- * @author Florian Dold
+ * Current database version, should be incremented
+ * each time we do incompatible schema changes on the database.
+ * In the future we might consider adding migration functions for
+ * each version increment.
*/
-
+const DB_VERSION = 17;
type Handler = (detail: any, sender: MessageSender) => Promise<any>;
@@ -466,10 +473,6 @@ function handleBankRequest(wallet: Wallet, headerList: chrome.webRequest.HttpHea
// no known headers found, not a taler request ...
}
-// Useful for debugging ...
-export let wallet: Wallet | undefined = undefined;
-export let badge: ChromeBadge | undefined = undefined;
-export let log = logging.log;
// Rate limit cache for executePayment operations, to break redirect loops
let rateLimitCache: { [n: number]: number } = {};
@@ -484,7 +487,7 @@ export async function wxMain() {
}
chrome.browserAction.setBadgeText({ text: "" });
- badge = new ChromeBadge();
+ const badge = new ChromeBadge();
chrome.tabs.query({}, function (tabs) {
for (let tab of tabs) {
@@ -566,14 +569,16 @@ export async function wxMain() {
console.error("could not open database", e);
return;
}
- let http = new BrowserHttpLib();
- let notifier = new ChromeNotifier();
+ const http = new BrowserHttpLib();
+ const notifier = new ChromeNotifier();
console.log("setting wallet");
- wallet = new Wallet(db, http, badge!, notifier);
+ const wallet = new Wallet(db, http, badge!, notifier);
+ // Useful for debugging in the background page.
+ (window as any).talerWallet = wallet;
// Handlers for messages coming directly from the content
// script on the page
- let handlers = makeHandlers(db, wallet!);
+ const handlers = makeHandlers(db, wallet!);
chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
dispatch(handlers, req, sender, sendResponse);
return true;