taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 9381ac6d1031ac16882023c617dc82b53df7a961
parent f5ef863a77fa6366848b6c50126e49988ece99c1
Author: Sebastian <sebasjm@gmail.com>
Date:   Fri, 17 May 2024 17:07:18 -0300

base_url is optional

Diffstat:
Mpackages/taler-util/src/codec.ts | 13++++++++++++-
Mpackages/taler-util/src/http-client/types.ts | 5+++--
Mpackages/taler-util/src/wallet-types.ts | 16++++++++++------
3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/packages/taler-util/src/codec.ts b/packages/taler-util/src/codec.ts @@ -146,7 +146,7 @@ class UnionCodecBuilder< constructor( private discriminator: TagPropertyLabel, private baseCodec?: Codec<CommonBaseType>, - ) {} + ) { } /** * Define a property for the object. @@ -491,6 +491,17 @@ export function codecOptional<V>(innerCodec: Codec<V>): Codec<V | undefined> { }; } +export function codecOptionalDefault<V>(innerCodec: Codec<V>, def: V): Codec<V> { + return { + decode(x: any, c?: Context): V { + if (x === undefined || x === null) { + return def; + } + return innerCodec.decode(x, c); + }, + }; +} + export function codecForLazy<V>(innerCodec: () => Codec<V>): Codec<V> { let instance: Codec<V> | undefined = undefined return { diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts @@ -13,6 +13,7 @@ import { codecForNumber, codecForString, codecOptional, + codecOptionalDefault, } from "../codec.js"; import { PaytoString, codecForPaytoString } from "../payto.js"; import { @@ -340,7 +341,7 @@ export const codecForCoreBankConfig = (): Codec<TalerCorebankApi.Config> => .property("name", codecForConstString("libeufin-bank")) .property("version", codecForString()) .property("bank_name", codecForString()) - .property("base_url", codecForString()) + .property("base_url", codecOptional(codecForString())) .property("allow_conversion", codecForBoolean()) .property("allow_registrations", codecForBoolean()) .property("allow_deletions", codecForBoolean()) @@ -358,7 +359,7 @@ export const codecForCoreBankConfig = (): Codec<TalerCorebankApi.Config> => ), ), ) - .property("wire_type", codecForString()) + .property("wire_type", codecOptionalDefault(codecForString(), "iban")) .build("TalerCorebankApi.Config"); //FIXME: implement this codec diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts @@ -662,11 +662,11 @@ export interface CoinDumpJson { withdrawal_reserve_pub: string | undefined; coin_status: CoinStatus; spend_allocation: - | { - id: string; - amount: AmountString; - } - | undefined; + | { + id: string; + amount: AmountString; + } + | undefined; /** * Information about the age restriction */ @@ -800,7 +800,7 @@ export const codecForPreparePayResultPaymentPossible = ) .build("PreparePayResultPaymentPossible"); -export interface BalanceDetails {} +export interface BalanceDetails { } /** * Detailed reason for why the wallet's balance is insufficient. @@ -1855,6 +1855,7 @@ export const codecForPrepareBankIntegratedWithdrawalRequest = export interface PrepareBankIntegratedWithdrawalResponse { transactionId: string; + info: WithdrawUriInfoResponse; } export interface ConfirmWithdrawalRequest { @@ -1941,6 +1942,9 @@ export const codecForApplyRefundFromPurchaseIdRequest = export interface GetWithdrawalDetailsForUriRequest { talerWithdrawUri: string; + /** + * @deprecated not used + */ restrictAge?: number; }