diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-08-13 00:26:55 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-08-13 00:26:55 +0530 |
commit | e9ed3b18672af919efa12364b97fd2b7efe21cd9 (patch) | |
tree | 42cd7e7bdf4686f463080e0ad879d06ff624a85b /packages/taler-wallet-core/src | |
parent | 4891c4c7ceec46781fa2d7b7b5a3347616587681 (diff) | |
download | wallet-core-e9ed3b18672af919efa12364b97fd2b7efe21cd9.tar.xz |
integration test for paywall flow
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/types/walletTypes.ts | 44 |
1 files changed, 38 insertions, 6 deletions
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<ConfirmPayResultPending>() + .property("lastError", codecForAny()) + .property("type", codecForConstString(ConfirmPayResultType.Pending)) + .build("ConfirmPayResultPending"); + +export const codecForConfirmPayResultDone = (): Codec< + ConfirmPayResultDone +> => + buildCodecForObject<ConfirmPayResultDone>() + .property("type", codecForConstString(ConfirmPayResultType.Done)) + .property("nextUrl", codecForString()) + .build("ConfirmPayResultDone"); + +export const codecForConfirmPayResult = (): Codec<ConfirmPayResult> => + buildCodecForUnion<ConfirmPayResult>() + .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<PreparePayResult> => +export const codecForPreparePayResult = (): Codec<PreparePayResult> => buildCodecForUnion<PreparePayResult>() - .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 |