diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-11-30 04:07:36 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-01 03:00:09 +0100 |
commit | b8ccc7c990a1542cf80578b41972f9a5b0870af9 (patch) | |
tree | 6f16319f9ce3133c4c4617129a516e692cfc3ac1 /src/webex/wxBackend.ts | |
parent | bc2c4aff8e657c7d5709433f137299491b98d257 (diff) | |
download | wallet-core-b8ccc7c990a1542cf80578b41972f9a5b0870af9.tar.xz |
partial implementation of tipping
Diffstat (limited to 'src/webex/wxBackend.ts')
-rw-r--r-- | src/webex/wxBackend.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts index 7393c8880..a17f516a8 100644 --- a/src/webex/wxBackend.ts +++ b/src/webex/wxBackend.ts @@ -31,12 +31,16 @@ import { Store, } from "../query"; import { + AcceptTipRequest, AmountJson, ConfirmReserveRequest, CreateReserveRequest, + GetTipPlanchetsRequest, Notifier, + ProcessTipResponseRequest, ProposalRecord, ReturnCoinsRequest, + TipStatusRequest, } from "../types"; import { Stores, @@ -44,6 +48,7 @@ import { Wallet, } from "../wallet"; + import { ChromeBadge } from "./chromeBadge"; import { MessageType } from "./messages"; import * as wxApi from "./wxApi"; @@ -316,6 +321,22 @@ function handleMessage(sender: MessageSender, } case "get-full-refund-fees": return needsWallet().getFullRefundFees(detail.refundPermissions); + case "get-tip-status": { + const req = TipStatusRequest.checked(detail); + return needsWallet().getTipStatus(req.merchantDomain, req.tipId); + } + case "accept-tip": { + const req = AcceptTipRequest.checked(detail); + return needsWallet().acceptTip(req.merchantDomain, req.tipId); + } + case "process-tip-response": { + const req = ProcessTipResponseRequest.checked(detail); + return needsWallet().processTipResponse(req.merchantDomain, req.tipId, req.tipResponse); + } + case "get-tip-planchets": { + const req = GetTipPlanchetsRequest.checked(detail); + return needsWallet().getTipPlanchets(req.merchantDomain, req.tipId, req.amount, req.deadline, req.exchangeUrl); + } default: // Exhaustiveness check. // See https://www.typescriptlang.org/docs/handbook/advanced-types.html @@ -409,6 +430,7 @@ function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[], url: stri contract_url: headers["x-taler-contract-url"], offer_url: headers["x-taler-offer-url"], refund_url: headers["x-taler-refund-url"], + tip: headers["x-taler-tip"], }; const talerHeaderFound = Object.keys(fields).filter((x: any) => (fields as any)[x]).length !== 0; @@ -424,6 +446,7 @@ function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[], url: stri contract_url: fields.contract_url, offer_url: fields.offer_url, refund_url: fields.refund_url, + tip: fields.tip, }; console.log("got pay detail", payDetail); @@ -728,7 +751,7 @@ function openTalerDb(): Promise<IDBDatabase> { for (const indexName in (si as any)) { if ((si as any)[indexName] instanceof Index) { const ii: Index<any, any> = (si as any)[indexName]; - s.createIndex(ii.indexName, ii.keyPath); + s.createIndex(ii.indexName, ii.keyPath, ii.options); } } } |