aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-14 22:10:03 +0200
committerFlorian Dold <florian@dold.me>2022-10-14 22:10:10 +0200
commita57fcb144d8de40fe50b825d34a27e415ef3fec3 (patch)
tree1883a8eefb9f7914d661a854c0098154cb5cd215 /packages/taler-wallet-core/src/operations/withdraw.ts
parentf1cba79c656875af0c6a09fd8e03b2c94fb2ac44 (diff)
downloadwallet-core-a57fcb144d8de40fe50b825d34a27e415ef3fec3.tar.xz
wallet-core: pull out ToS into separate object store
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts29
1 files changed, 18 insertions, 11 deletions
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),
});