From fbb7dd9e7e7fe4cf0611f5827f0bd250634dc29f Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 15 Oct 2022 21:26:36 +0200 Subject: wallet-core, wallet-cli: add status to exchange list, add detail query to CLI --- .../taler-wallet-core/src/operations/common.ts | 35 +++++++++++++++++++++- .../taler-wallet-core/src/operations/exchanges.ts | 2 -- .../taler-wallet-core/src/operations/withdraw.ts | 14 ++------- 3 files changed, 36 insertions(+), 15 deletions(-) (limited to 'packages/taler-wallet-core/src/operations') diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts index ee7a1b46e..95441be2b 100644 --- a/packages/taler-wallet-core/src/operations/common.ts +++ b/packages/taler-wallet-core/src/operations/common.ts @@ -22,6 +22,8 @@ import { Amounts, CoinRefreshRequest, CoinStatus, + ExchangeEntryStatus, + ExchangeListItem, ExchangeTosStatus, j2s, Logger, @@ -32,7 +34,12 @@ import { TransactionIdStr, TransactionType, } from "@gnu-taler/taler-util"; -import { WalletStoresV1, CoinRecord, ExchangeDetailsRecord } from "../db.js"; +import { + WalletStoresV1, + CoinRecord, + ExchangeDetailsRecord, + ExchangeRecord, +} from "../db.js"; import { makeErrorDetail, TalerError } from "../errors.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js"; @@ -320,3 +327,29 @@ export function getExchangeTosStatus( } return ExchangeTosStatus.Changed; } + +export function makeExchangeListItem( + r: ExchangeRecord, + exchangeDetails: ExchangeDetailsRecord | undefined, +): ExchangeListItem { + if (!exchangeDetails) { + return { + exchangeBaseUrl: r.baseUrl, + currency: undefined, + tosStatus: ExchangeTosStatus.Unknown, + paytoUris: [], + exchangeStatus: ExchangeEntryStatus.Unknown, + permanent: r.permanent, + }; + } + let exchangeStatus; + exchangeStatus = ExchangeEntryStatus.Ok; + return { + exchangeBaseUrl: r.baseUrl, + currency: exchangeDetails.currency, + tosStatus: getExchangeTosStatus(exchangeDetails), + paytoUris: exchangeDetails.wireInfo.accounts.map((x) => x.payto_uri), + exchangeStatus, + permanent: r.permanent, + }; +} diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index e89364ad1..142bedd83 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -705,8 +705,6 @@ export async function updateExchangeFromUrlHandler( }; } await tx.exchanges.put(r); - logger.info(`existing details ${j2s(existingDetails)}`); - logger.info(`inserting new details ${j2s(newDetails)}`); const drRowId = await tx.exchangeDetails.put(newDetails); checkDbInvariant(typeof drRowId.key === "number"); diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 1113fb87a..59863101a 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -85,6 +85,7 @@ import { InternalWalletState } from "../internal-wallet-state.js"; import { getExchangeTosStatus, makeCoinAvailable, + makeExchangeListItem, runOperationWithErrorReporting, } from "../operations/common.js"; import { walletCoreDebugFlags } from "../util/debugFlags.js"; @@ -1367,18 +1368,7 @@ export async function getWithdrawalDetailsForUri( .iter(r.baseUrl) .toArray(); if (exchangeDetails && denominations) { - const tosRecord = await tx.exchangeTos.get([ - exchangeDetails.exchangeBaseUrl, - exchangeDetails.tosCurrentEtag, - ]); - exchanges.push({ - exchangeBaseUrl: exchangeDetails.exchangeBaseUrl, - currency: exchangeDetails.currency, - paytoUris: exchangeDetails.wireInfo.accounts.map( - (x) => x.payto_uri, - ), - tosStatus: getExchangeTosStatus(exchangeDetails), - }); + exchanges.push(makeExchangeListItem(r, exchangeDetails)); } } }); -- cgit v1.2.3