diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-08-12 15:48:02 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-08-12 15:48:02 +0530 |
commit | 56f5a1e3abe2679b4913ac87ff82860bb9675823 (patch) | |
tree | 5780413d148ac9cd84ac05cbca51018ae87248fd /packages/taler-wallet-core/src/types/walletTypes.ts | |
parent | 6d2d65bf630e82ec99b187b7572463db7bba3f7f (diff) | |
download | wallet-core-56f5a1e3abe2679b4913ac87ff82860bb9675823.tar.xz |
codec
Diffstat (limited to 'packages/taler-wallet-core/src/types/walletTypes.ts')
-rw-r--r-- | packages/taler-wallet-core/src/types/walletTypes.ts | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index 8faace033..d79ade971 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -27,7 +27,11 @@ /** * Imports. */ -import { AmountJson, codecForAmountJson } from "../util/amounts"; +import { + AmountJson, + codecForAmountJson, + codecForAmountString, +} from "../util/amounts"; import * as LibtoolVersion from "../util/libtoolVersion"; import { ExchangeRecord, @@ -42,8 +46,10 @@ import { Codec, makeCodecForList, codecForBoolean, + makeCodecForConstString, + codecForAny, } from "../util/codec"; -import { AmountString } from "./talerTypes"; +import { AmountString, codecForContractTerms } from "./talerTypes"; import { TransactionError } from "./transactions"; /** @@ -351,6 +357,48 @@ export const enum PreparePayResultType { AlreadyConfirmed = "already-confirmed", } +export const codecForPreparePayResultPaymentPossible = (): Codec< + PreparePayResultPaymentPossible +> => + makeCodecForObject<PreparePayResultPaymentPossible>() + .property("amountEffective", codecForAmountString()) + .property("amountRaw", codecForAmountString()) + .property("contractTerms", codecForAny) + .property("proposalId", codecForString) + .property( + "status", + makeCodecForConstString(PreparePayResultType.PaymentPossible), + ) + .build("PreparePayResultPaymentPossible"); + +export const codecForPreparePayResultInsufficientBalance = (): Codec< + PreparePayResultInsufficientBalance +> => + makeCodecForObject<PreparePayResultInsufficientBalance>() + .property("amountRaw", codecForAmountString()) + .property("contractTerms", codecForAny) + .property("proposalId", codecForString) + .property( + "status", + makeCodecForConstString(PreparePayResultType.InsufficientBalance), + ) + .build("PreparePayResultInsufficientBalance"); + +export const codecForPreparePayResultAlreadyConfirmed = (): Codec< + PreparePayResultAlreadyConfirmed +> => + makeCodecForObject<PreparePayResultAlreadyConfirmed>() + .property( + "status", + makeCodecForConstString(PreparePayResultType.AlreadyConfirmed), + ) + .property("amountEffective", codecForAmountString()) + .property("amountRaw", codecForAmountString()) + .property("nextUrl", codecForString) + .property("paid", codecForBoolean) + .property("contractTerms", codecForAny) + .build("PreparePayResultAlreadyConfirmed"); + export type PreparePayResult = | PreparePayResultInsufficientBalance | PreparePayResultAlreadyConfirmed |