summaryrefslogtreecommitdiff
path: root/src/operations/tip.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-19 20:42:49 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-19 20:42:49 +0100
commit0c9358c1b2bd80e25940022e86bd8daef8184ad7 (patch)
treea8c8ca0134bd886d8151633aff4c85e9513ad32c /src/operations/tip.ts
parent49e3b3e5b9bbf1ce356ef68f301d50c689ceecb9 (diff)
downloadwallet-core-0c9358c1b2bd80e25940022e86bd8daef8184ad7.tar.gz
wallet-core-0c9358c1b2bd80e25940022e86bd8daef8184ad7.tar.bz2
wallet-core-0c9358c1b2bd80e25940022e86bd8daef8184ad7.zip
new date format, replace checkable annotations with codecs
Diffstat (limited to 'src/operations/tip.ts')
-rw-r--r--src/operations/tip.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/operations/tip.ts b/src/operations/tip.ts
index 76d0df22d..fcdda0763 100644
--- a/src/operations/tip.ts
+++ b/src/operations/tip.ts
@@ -18,13 +18,14 @@ import { InternalWalletState } from "./state";
import { parseTipUri } from "../util/taleruri";
import {
TipStatus,
- getTimestampNow,
OperationError,
} from "../types/walletTypes";
import {
TipPickupGetResponse,
TipPlanchetDetail,
TipResponse,
+ codecForTipPickupGetResponse,
+ codecForTipResponse,
} from "../types/talerTypes";
import * as Amounts from "../util/amounts";
import {
@@ -39,11 +40,11 @@ import {
getVerifiedWithdrawDenomList,
processWithdrawSession,
} from "./withdraw";
-import { getTalerStampSec, extractTalerStampOrThrow } from "../util/helpers";
import { updateExchangeFromUrl } from "./exchanges";
import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto";
import { guardOperationException } from "./errors";
import { NotificationType } from "../types/notifications";
+import { getTimestampNow } from "../util/time";
export async function getTipStatus(
ws: InternalWalletState,
@@ -63,7 +64,7 @@ export async function getTipStatus(
}
const respJson = await merchantResp.json();
console.log("resp:", respJson);
- const tipPickupStatus = TipPickupGetResponse.checked(respJson);
+ const tipPickupStatus = codecForTipPickupGetResponse().decode(respJson);
console.log("status", tipPickupStatus);
@@ -88,7 +89,7 @@ export async function getTipStatus(
acceptedTimestamp: undefined,
rejectedTimestamp: undefined,
amount,
- deadline: extractTalerStampOrThrow(tipPickupStatus.stamp_expire),
+ deadline: tipPickupStatus.stamp_expire,
exchangeUrl: tipPickupStatus.exchange_url,
merchantBaseUrl: res.merchantBaseUrl,
nextUrl: undefined,
@@ -115,8 +116,8 @@ export async function getTipStatus(
nextUrl: tipPickupStatus.extra.next_url,
merchantOrigin: res.merchantOrigin,
merchantTipId: res.merchantTipId,
- expirationTimestamp: getTalerStampSec(tipPickupStatus.stamp_expire)!,
- timestamp: getTalerStampSec(tipPickupStatus.stamp_created)!,
+ expirationTimestamp: tipPickupStatus.stamp_expire,
+ timestamp: tipPickupStatus.stamp_created,
totalFees: tipRecord.totalFees,
tipId: tipRecord.tipId,
};
@@ -240,7 +241,7 @@ async function processTipImpl(
throw e;
}
- const response = TipResponse.checked(await merchantResp.json());
+ const response = codecForTipResponse().decode(await merchantResp.json());
if (response.reserve_sigs.length !== tipRecord.planchets.length) {
throw Error("number of tip responses does not match requested planchets");