From bbff7403fbf46f9ad92240ac213df8d30ef31b64 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Sep 2018 02:56:13 +0200 Subject: update packages --- src/webex/messages.ts | 4 ++++ src/webex/pages/confirm-contract.tsx | 6 ++++-- src/webex/pages/popup.tsx | 5 ++++- src/webex/wxApi.ts | 9 +++++++++ src/webex/wxBackend.ts | 8 +++++++- 5 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src/webex') diff --git a/src/webex/messages.ts b/src/webex/messages.ts index 45cac6a9f..8bb9cafe5 100644 --- a/src/webex/messages.ts +++ b/src/webex/messages.ts @@ -205,6 +205,10 @@ export interface MessageMap { request: { contractTermsHash: string } response: void; }; + "benchmark-crypto": { + request: { repetitions: number } + response: walletTypes.BenchmarkResult; + }; } /** diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx index 41eebda8e..d24613794 100644 --- a/src/webex/pages/confirm-contract.tsx +++ b/src/webex/pages/confirm-contract.tsx @@ -25,6 +25,8 @@ */ import * as i18n from "../../i18n"; +import { runOnceWhenReady } from "./common"; + import { ExchangeRecord, ProposalDownloadRecord, @@ -372,7 +374,7 @@ class ContractPrompt extends React.Component The merchant{" "}{merchantName} offers you to purchase: -
+
{c.summary}
@@ -395,7 +397,7 @@ class ContractPrompt extends React.Component { +runOnceWhenReady(() => { const url = new URI(document.location.href); const query: any = URI.parseQuery(url.query()); diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx index 6d0134b84..2224a662f 100644 --- a/src/webex/pages/popup.tsx +++ b/src/webex/pages/popup.tsx @@ -27,6 +27,8 @@ */ import * as i18n from "../../i18n"; +import { runOnceWhenReady } from "./common"; + import { AmountJson } from "../../amounts"; import * as Amounts from "../../amounts"; @@ -41,6 +43,7 @@ import * as wxApi from "../wxApi"; import * as React from "react"; import * as ReactDOM from "react-dom"; + import URI = require("urijs"); function onUpdateNotification(f: () => void): () => void { @@ -571,7 +574,7 @@ const el = (
); -document.addEventListener("DOMContentLoaded", () => { +runOnceWhenReady(() => { ReactDOM.render(el, document.getElementById("content")!); // Will be used by the backend to detect when the popup gets closed, // so we can clear notifications diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts index e5da642f1..fde7b8c35 100644 --- a/src/webex/wxApi.ts +++ b/src/webex/wxApi.ts @@ -34,6 +34,7 @@ import { ReserveRecord, } from "../dbTypes"; import { + BenchmarkResult, CheckPayResult, ConfirmPayResult, ReserveCreationInfo, @@ -392,3 +393,11 @@ export function acceptRefund(refundUrl: string): Promise { export function abortFailedPayment(contractTermsHash: string) { return callBackend("abort-failed-payment", { contractTermsHash }); } + + +/** + * Abort a failed payment and try to get a refund. + */ +export function benchmarkCrypto(repetitions: number): Promise { + return callBackend("benchmark-crypto", { repetitions }); +} diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts index b1aecbbdd..f2dbd68be 100644 --- a/src/webex/wxBackend.ts +++ b/src/webex/wxBackend.ts @@ -335,6 +335,12 @@ function handleMessage(sender: MessageSender, talerPay(detail, senderUrl, tabId); return; } + case "benchmark-crypto": { + if (!detail.repetitions) { + throw Error("repetitions not given"); + } + return needsWallet().benchmarkCrypto(detail.repetitions); + } default: // Exhaustiveness check. // See https://www.typescriptlang.org/docs/handbook/advanced-types.html @@ -739,7 +745,7 @@ export async function wxMain() { }); window.onerror = (m, source, lineno, colno, error) => { - logging.record("error", m + error, undefined, source || "(unknown)", lineno || 0, colno || 0); + logging.record("error", "".concat(m as any, error as any), undefined, source || "(unknown)", lineno || 0, colno || 0); }; chrome.tabs.query({}, (tabs) => { -- cgit v1.2.3