aboutsummaryrefslogtreecommitdiff
path: root/src/webex
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-11-30 00:36:20 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-11-30 00:36:20 +0100
commitaaf7e1338d6cdb1b4e01ad318938b3eaea2f922b (patch)
tree594129ccdf20757aeb86d434dd62c0c1e8259ed5 /src/webex
parent809fa186448dbd924f258f89920b9336f1979bb0 (diff)
wallet robustness WIP
Diffstat (limited to 'src/webex')
-rw-r--r--src/webex/messages.ts6
-rw-r--r--src/webex/pages/payback.tsx2
-rw-r--r--src/webex/wxApi.ts10
-rw-r--r--src/webex/wxBackend.ts21
4 files changed, 24 insertions, 15 deletions
diff --git a/src/webex/messages.ts b/src/webex/messages.ts
index 034bf2849..e321e5ac1 100644
--- a/src/webex/messages.ts
+++ b/src/webex/messages.ts
@@ -66,7 +66,7 @@ export interface MessageMap {
response: void;
};
"confirm-pay": {
- request: { proposalId: number; sessionId?: string };
+ request: { proposalId: string; sessionId?: string };
response: walletTypes.ConfirmPayResult;
};
"exchange-info": {
@@ -113,9 +113,9 @@ export interface MessageMap {
request: { reservePub: string };
response: dbTypes.ReserveRecord[];
};
- "get-precoins": {
+ "get-planchets": {
request: { exchangeBaseUrl: string };
- response: dbTypes.PreCoinRecord[];
+ response: dbTypes.PlanchetRecord[];
};
"get-denoms": {
request: { exchangeBaseUrl: string };
diff --git a/src/webex/pages/payback.tsx b/src/webex/pages/payback.tsx
index af14b95d4..806bef17c 100644
--- a/src/webex/pages/payback.tsx
+++ b/src/webex/pages/payback.tsx
@@ -57,7 +57,7 @@ function Payback() {
<div>
{reserves.map(r => (
<div>
- <h2>Reserve for ${renderAmount(r.currentAmount!)}</h2>
+ <h2>Reserve for ${renderAmount(r.withdrawRemainingAmount)}</h2>
<ul>
<li>Exchange: ${r.exchangeBaseUrl}</li>
</ul>
diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts
index a50672131..a8b35ed34 100644
--- a/src/webex/wxApi.ts
+++ b/src/webex/wxApi.ts
@@ -28,7 +28,7 @@ import {
CurrencyRecord,
DenominationRecord,
ExchangeRecord,
- PreCoinRecord,
+ PlanchetRecord,
ReserveRecord,
} from "../dbTypes";
import {
@@ -174,10 +174,10 @@ export function getCoins(exchangeBaseUrl: string): Promise<CoinRecord[]> {
/**
- * Get all precoins withdrawn from the given exchange.
+ * Get all planchets withdrawn from the given exchange.
*/
-export function getPreCoins(exchangeBaseUrl: string): Promise<PreCoinRecord[]> {
- return callBackend("get-precoins", { exchangeBaseUrl });
+export function getPlanchets(exchangeBaseUrl: string): Promise<PlanchetRecord[]> {
+ return callBackend("get-planchets", { exchangeBaseUrl });
}
@@ -207,7 +207,7 @@ export function payback(coinPub: string): Promise<void> {
/**
* Pay for a proposal.
*/
-export function confirmPay(proposalId: number, sessionId: string | undefined): Promise<ConfirmPayResult> {
+export function confirmPay(proposalId: string, sessionId: string | undefined): Promise<ConfirmPayResult> {
return callBackend("confirm-pay", { proposalId, sessionId });
}
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 57c10d94a..78c86a976 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -117,8 +117,8 @@ async function handleMessage(
return needsWallet().confirmReserve(req);
}
case "confirm-pay": {
- if (typeof detail.proposalId !== "number") {
- throw Error("proposalId must be number");
+ if (typeof detail.proposalId !== "string") {
+ throw Error("proposalId must be string");
}
return needsWallet().confirmPay(detail.proposalId, detail.sessionId);
}
@@ -178,11 +178,11 @@ async function handleMessage(
}
return needsWallet().getCoinsForExchange(detail.exchangeBaseUrl);
}
- case "get-precoins": {
+ case "get-planchets": {
if (typeof detail.exchangeBaseUrl !== "string") {
return Promise.reject(Error("exchangBaseUrl missing"));
}
- return needsWallet().getPreCoins(detail.exchangeBaseUrl);
+ return needsWallet().getPlanchets(detail.exchangeBaseUrl);
}
case "get-denoms": {
if (typeof detail.exchangeBaseUrl !== "string") {
@@ -658,8 +658,8 @@ export async function wxMain() {
if (!wallet) {
console.warn("wallet not available while handling header");
}
- if (details.statusCode === 402) {
- console.log(`got 402 from ${details.url}`);
+ if (details.statusCode === 402 || details.statusCode === 202) {
+ console.log(`got 402/202 from ${details.url}`);
for (let header of details.responseHeaders || []) {
if (header.name.toLowerCase() === "taler") {
const talerUri = header.value || "";
@@ -705,6 +705,15 @@ export async function wxMain() {
talerRefundUri: talerUri,
},
);
+ } else if (talerUri.startsWith("taler://notify-reserve/")) {
+ Promise.resolve().then(() => {
+ const w = currentWallet;
+ if (!w) {
+ return;
+ }
+ w.handleNotifyReserve();
+ });
+
} else {
console.warn("Unknown action in taler:// URI, ignoring.");
}