From c5ec34136874be87210711fd65eea1c1a6feec50 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 12 Aug 2020 19:45:34 +0530 Subject: add exchange management test case --- packages/taler-wallet-core/src/index.ts | 2 ++ packages/taler-wallet-core/src/operations/exchanges.ts | 2 +- packages/taler-wallet-core/src/types/talerTypes.ts | 9 ++++++++- packages/taler-wallet-core/src/types/walletTypes.ts | 12 ++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-wallet-core/src/index.ts b/packages/taler-wallet-core/src/index.ts index 954798e46..784c9d63b 100644 --- a/packages/taler-wallet-core/src/index.ts +++ b/packages/taler-wallet-core/src/index.ts @@ -75,3 +75,5 @@ export * from "./crypto/workers/nodeThreadWorker"; export * from "./types/notifications"; export { Configuration } from "./util/talerconfig"; + +export { URL } from "./util/url"; \ No newline at end of file diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index 8967173ca..a7771f6d2 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -88,7 +88,7 @@ async function setExchangeError( baseUrl: string, err: OperationErrorDetails, ): Promise { - console.log(`last error for exchange ${baseUrl}:`, err); + logger.warn(`last error for exchange ${baseUrl}:`, err); const mut = (exchange: ExchangeRecord): ExchangeRecord => { exchange.lastError = err; return exchange; diff --git a/packages/taler-wallet-core/src/types/talerTypes.ts b/packages/taler-wallet-core/src/types/talerTypes.ts index bb0118a78..99f44ea25 100644 --- a/packages/taler-wallet-core/src/types/talerTypes.ts +++ b/packages/taler-wallet-core/src/types/talerTypes.ts @@ -47,7 +47,7 @@ import { Duration, codecForDuration, } from "../util/time"; -import { ExchangeListItem } from "./walletTypes"; +import { ExchangeListItem, codecForExchangeListItem } from "./walletTypes"; import { codecForAmountString } from "../util/amounts"; /** @@ -940,6 +940,13 @@ export interface WithdrawUriInfoResponse { possibleExchanges: ExchangeListItem[]; } +export const codecForWithdrawUriInfoResponse = (): Codec => + buildCodecForObject() + .property("amount", codecForAmountString()) + .property("defaultExchangeBaseUrl", codecOptional(codecForString())) + .property("possibleExchanges", codecForList(codecForExchangeListItem())) + .build("WithdrawUriInfoResponse"); + /** * Response body for the following endpoint: * diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index ec57e7d2a..6f6340520 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -554,6 +554,18 @@ export interface ExchangeListItem { paytoUris: string[]; } +export const codecForExchangeListItem = (): Codec => + buildCodecForObject() + .property("currency", codecForString()) + .property("exchangeBaseUrl", codecForString()) + .property("paytoUris", codecForList(codecForString())) + .build("ExchangeListItem"); + +export const codecForExchangesListResponse = (): Codec => + buildCodecForObject() + .property("exchanges", codecForList(codecForExchangeListItem())) + .build("ExchangesListRespose"); + export interface AcceptManualWithdrawalResult { /** * Payto URIs that can be used to fund the withdrawal. -- cgit v1.2.3