From 11fa3397053c16cfcbf594c1389a75eaad94a40e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 12 Aug 2020 16:32:07 +0530 Subject: fix preparePay bug and add integration test for it --- packages/taler-wallet-core/src/types/walletTypes.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'packages/taler-wallet-core/src/types') diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index 7a648dd56..ec57e7d2a 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -48,6 +48,7 @@ import { codecForBoolean, codecForConstString, codecForAny, + buildCodecForUnion, } from "../util/codec"; import { AmountString, codecForContractTerms } from "./talerTypes"; import { TransactionError } from "./transactions"; @@ -399,6 +400,14 @@ export const codecForPreparePayResultAlreadyConfirmed = (): Codec< .property("contractTerms", codecForAny()) .build("PreparePayResultAlreadyConfirmed"); +export const codecForPreparePayResult = (): Codec => + buildCodecForUnion() + .discriminateOn("status") + .alternative(PreparePayResultType.AlreadyConfirmed, codecForPreparePayResultAlreadyConfirmed()) + .alternative(PreparePayResultType.InsufficientBalance, codecForPreparePayResultInsufficientBalance()) + .alternative(PreparePayResultType.PaymentPossible, codecForPreparePayResultPaymentPossible()) + .build("PreparePayResult"); + export type PreparePayResult = | PreparePayResultInsufficientBalance | PreparePayResultAlreadyConfirmed -- cgit v1.2.3