From a57fcb144d8de40fe50b825d34a27e415ef3fec3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 14 Oct 2022 22:10:03 +0200 Subject: wallet-core: pull out ToS into separate object store --- .../taler-wallet-core/src/operations/withdraw.ts | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts') diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 145a2d9c7..700c4620c 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -69,6 +69,7 @@ import { CoinStatus, DenominationRecord, DenominationVerificationStatus, + ExchangeTosRecord, PlanchetRecord, PlanchetStatus, WalletStoresV1, @@ -1278,12 +1279,8 @@ export async function getExchangeWithdrawalInfo( } let tosAccepted = false; - - if (exchangeDetails.termsOfServiceLastEtag) { - if ( - exchangeDetails.termsOfServiceAcceptedEtag === - exchangeDetails.termsOfServiceLastEtag - ) { + if (exchangeDetails.tosAccepted?.timestamp) { + if (exchangeDetails.tosAccepted.etag === exchangeDetails.tosCurrentEtag) { tosAccepted = true; } } @@ -1357,7 +1354,12 @@ export async function getWithdrawalDetailsForUri( const exchanges: ExchangeListItem[] = []; await ws.db - .mktx((x) => [x.exchanges, x.exchangeDetails, x.denominations]) + .mktx((x) => [ + x.exchanges, + x.exchangeDetails, + x.exchangeTos, + x.denominations, + ]) .runReadOnly(async (tx) => { const exchangeRecords = await tx.exchanges.iter().toArray(); for (const r of exchangeRecords) { @@ -1366,14 +1368,19 @@ export async function getWithdrawalDetailsForUri( .iter(r.baseUrl) .toArray(); if (details && denominations) { + const tosRecord = await tx.exchangeTos.get([ + details.exchangeBaseUrl, + details.tosCurrentEtag, + ]); exchanges.push({ exchangeBaseUrl: details.exchangeBaseUrl, currency: details.currency, + // FIXME: We probably don't want to include the full ToS here! tos: { - acceptedVersion: details.termsOfServiceAcceptedEtag, - currentVersion: details.termsOfServiceLastEtag, - contentType: details.termsOfServiceContentType, - content: details.termsOfServiceText, + acceptedVersion: details.tosAccepted?.etag, + currentVersion: details.tosCurrentEtag, + contentType: tosRecord?.termsOfServiceContentType ?? "", + content: tosRecord?.termsOfServiceText ?? "", }, paytoUris: details.wireInfo.accounts.map((x) => x.payto_uri), }); -- cgit v1.2.3