summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/types/walletTypes.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-08-12 16:32:07 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-08-12 16:32:07 +0530
commit11fa3397053c16cfcbf594c1389a75eaad94a40e (patch)
tree2a464ac389576b8a81021d92ee4ec3d2d6e8f56b /packages/taler-wallet-core/src/types/walletTypes.ts
parent8d7b171d02e0ab4d5da7dc81eaea6c27106dbc57 (diff)
downloadwallet-core-11fa3397053c16cfcbf594c1389a75eaad94a40e.tar.gz
wallet-core-11fa3397053c16cfcbf594c1389a75eaad94a40e.tar.bz2
wallet-core-11fa3397053c16cfcbf594c1389a75eaad94a40e.zip
fix preparePay bug and add integration test for it
Diffstat (limited to 'packages/taler-wallet-core/src/types/walletTypes.ts')
-rw-r--r--packages/taler-wallet-core/src/types/walletTypes.ts9
1 files changed, 9 insertions, 0 deletions
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<PreparePayResult> =>
+ buildCodecForUnion<PreparePayResult>()
+ .discriminateOn("status")
+ .alternative(PreparePayResultType.AlreadyConfirmed, codecForPreparePayResultAlreadyConfirmed())
+ .alternative(PreparePayResultType.InsufficientBalance, codecForPreparePayResultInsufficientBalance())
+ .alternative(PreparePayResultType.PaymentPossible, codecForPreparePayResultPaymentPossible())
+ .build("PreparePayResult");
+
export type PreparePayResult =
| PreparePayResultInsufficientBalance
| PreparePayResultAlreadyConfirmed