From e9ed3b18672af919efa12364b97fd2b7efe21cd9 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 13 Aug 2020 00:26:55 +0530 Subject: integration test for paywall flow --- .../taler-wallet-core/src/types/walletTypes.ts | 44 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'packages/taler-wallet-core') diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index 6f6340520..8521af3ff 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -221,6 +221,29 @@ export interface ConfirmPayResultPending { export type ConfirmPayResult = ConfirmPayResultDone | ConfirmPayResultPending; +export const codecForConfirmPayResultPending = (): Codec< + ConfirmPayResultPending +> => + buildCodecForObject() + .property("lastError", codecForAny()) + .property("type", codecForConstString(ConfirmPayResultType.Pending)) + .build("ConfirmPayResultPending"); + +export const codecForConfirmPayResultDone = (): Codec< + ConfirmPayResultDone +> => + buildCodecForObject() + .property("type", codecForConstString(ConfirmPayResultType.Done)) + .property("nextUrl", codecForString()) + .build("ConfirmPayResultDone"); + +export const codecForConfirmPayResult = (): Codec => + buildCodecForUnion() + .discriminateOn("type") + .alternative(ConfirmPayResultType.Pending, codecForConfirmPayResultPending()) + .alternative(ConfirmPayResultType.Done, codecForConfirmPayResultDone()) + .build("ConfirmPayResult"); + /** * Information about all sender wire details known to the wallet, * as well as exchanges that accept these wire types. @@ -400,13 +423,22 @@ export const codecForPreparePayResultAlreadyConfirmed = (): Codec< .property("contractTerms", codecForAny()) .build("PreparePayResultAlreadyConfirmed"); -export const codecForPreparePayResult = (): Codec => +export const codecForPreparePayResult = (): Codec => buildCodecForUnion() - .discriminateOn("status") - .alternative(PreparePayResultType.AlreadyConfirmed, codecForPreparePayResultAlreadyConfirmed()) - .alternative(PreparePayResultType.InsufficientBalance, codecForPreparePayResultInsufficientBalance()) - .alternative(PreparePayResultType.PaymentPossible, codecForPreparePayResultPaymentPossible()) - .build("PreparePayResult"); + .discriminateOn("status") + .alternative( + PreparePayResultType.AlreadyConfirmed, + codecForPreparePayResultAlreadyConfirmed(), + ) + .alternative( + PreparePayResultType.InsufficientBalance, + codecForPreparePayResultInsufficientBalance(), + ) + .alternative( + PreparePayResultType.PaymentPossible, + codecForPreparePayResultPaymentPossible(), + ) + .build("PreparePayResult"); export type PreparePayResult = | PreparePayResultInsufficientBalance -- cgit v1.2.3