From bd88dcebbcf90414c790a86ee13740eaf20e3334 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 15 Oct 2022 12:59:26 +0200 Subject: wallet-core: simplify exchanges list response --- packages/taler-wallet-core/src/operations/common.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'packages/taler-wallet-core/src/operations/common.ts') diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts index 5e02f3d7b..ee7a1b46e 100644 --- a/packages/taler-wallet-core/src/operations/common.ts +++ b/packages/taler-wallet-core/src/operations/common.ts @@ -22,6 +22,7 @@ import { Amounts, CoinRefreshRequest, CoinStatus, + ExchangeTosStatus, j2s, Logger, RefreshReason, @@ -31,7 +32,7 @@ import { TransactionIdStr, TransactionType, } from "@gnu-taler/taler-util"; -import { WalletStoresV1, CoinRecord } from "../db.js"; +import { WalletStoresV1, CoinRecord, ExchangeDetailsRecord } from "../db.js"; import { makeErrorDetail, TalerError } from "../errors.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js"; @@ -307,3 +308,15 @@ export function makeTombstoneId( ): TombstoneIdStr { return `tmb:${type}:${args.map((x) => encodeURIComponent(x)).join(":")}`; } + +export function getExchangeTosStatus( + exchangeDetails: ExchangeDetailsRecord, +): ExchangeTosStatus { + if (!exchangeDetails.tosAccepted) { + return ExchangeTosStatus.New; + } + if (exchangeDetails.tosAccepted?.etag == exchangeDetails.tosCurrentEtag) { + return ExchangeTosStatus.Accepted; + } + return ExchangeTosStatus.Changed; +} -- cgit v1.2.3