diff options
author | Florian Dold <florian@dold.me> | 2023-09-06 18:43:37 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-09-06 18:43:37 +0200 |
commit | 1fcb55c84dc541e64ebbb2d16156bab275ff16c4 (patch) | |
tree | 2e0b3e3604cf70989b34c1b34f77ccf0e08d2060 /packages/taler-wallet-core/src/wallet.ts | |
parent | cd9c3a143bc1ad88ce77d53c212a90f60660069a (diff) | |
download | wallet-core-1fcb55c84dc541e64ebbb2d16156bab275ff16c4.tar.xz |
remove ToS storage
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 86 |
1 files changed, 10 insertions, 76 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 7a1bd5a4f..cb82a3a43 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -34,7 +34,6 @@ import { Duration, ExchangeDetailedResponse, ExchangeListItem, - ExchangeTosStatusDetails, ExchangesListResponse, FeeDescription, GetExchangeTosResult, @@ -202,7 +201,6 @@ import { provideExchangeRecordInTx, updateExchangeFromUrl, updateExchangeFromUrlHandler, - updateExchangeTermsOfService, } from "./operations/exchanges.js"; import { getMerchantInfo } from "./operations/merchants.js"; import { @@ -557,33 +555,6 @@ async function getExchangeTos( ): Promise<GetExchangeTosResult> { // FIXME: download ToS in acceptable format if passed! const { exchangeDetails } = await updateExchangeFromUrl(ws, exchangeBaseUrl); - const tosDetails = await ws.db - .mktx((x) => [x.exchangeTos]) - .runReadOnly(async (tx) => { - return await getExchangeTosStatusDetails(tx, exchangeDetails); - }); - const content = tosDetails.content; - const currentEtag = tosDetails.currentVersion; - const contentType = tosDetails.contentType; - if ( - content === undefined || - currentEtag === undefined || - contentType === undefined - ) { - throw Error("exchange is in invalid state"); - } - if ( - acceptedFormat && - acceptedFormat.findIndex((f) => f === contentType) !== -1 - ) { - return { - acceptedEtag: exchangeDetails.tosAccepted?.etag, - currentEtag, - content, - contentType, - tosStatus: getExchangeTosStatus(exchangeDetails), - }; - } const tosDownload = await downloadTosFromAcceptedFormat( ws, @@ -592,17 +563,15 @@ async function getExchangeTos( acceptedFormat, ); - if (tosDownload.tosContentType === contentType) { - return { - acceptedEtag: exchangeDetails.tosAccepted?.etag, - currentEtag, - content, - contentType, - tosStatus: getExchangeTosStatus(exchangeDetails), - }; - } - - await updateExchangeTermsOfService(ws, exchangeBaseUrl, tosDownload); + await ws.db + .mktx((x) => [x.exchanges, x.exchangeDetails]) + .runReadWrite(async (tx) => { + const d = await getExchangeDetails(tx, exchangeBaseUrl); + if (d) { + d.tosCurrentEtag = tosDownload.tosEtag; + await tx.exchangeDetails.put(d); + } + }); return { acceptedEtag: exchangeDetails.tosAccepted?.etag, @@ -683,32 +652,6 @@ async function forgetKnownBankAccounts( return; } -async function getExchangeTosStatusDetails( - tx: GetReadOnlyAccess<{ exchangeTos: typeof WalletStoresV1.exchangeTos }>, - exchangeDetails: ExchangeDetailsRecord, -): Promise<ExchangeTosStatusDetails> { - let exchangeTos = await tx.exchangeTos.get([ - exchangeDetails.exchangeBaseUrl, - exchangeDetails.tosCurrentEtag, - ]); - - if (!exchangeTos) { - exchangeTos = { - etag: "not-available", - termsOfServiceContentType: "text/plain", - termsOfServiceText: "terms of service unavailable", - exchangeBaseUrl: exchangeDetails.exchangeBaseUrl, - }; - } - - return { - acceptedVersion: exchangeDetails.tosAccepted?.etag, - content: exchangeTos.termsOfServiceText, - contentType: exchangeTos.termsOfServiceContentType, - currentVersion: exchangeTos.etag, - }; -} - async function getExchanges( ws: InternalWalletState, ): Promise<ExchangesListResponse> { @@ -717,7 +660,6 @@ async function getExchanges( .mktx((x) => [ x.exchanges, x.exchangeDetails, - x.exchangeTos, x.denominations, x.operationRetries, ]) @@ -742,12 +684,7 @@ async function getExchangeDetailedInfo( ): Promise<ExchangeDetailedResponse> { //TODO: should we use the forceUpdate parameter? const exchange = await ws.db - .mktx((x) => [ - x.exchanges, - x.exchangeTos, - x.exchangeDetails, - x.denominations, - ]) + .mktx((x) => [x.exchanges, x.exchangeDetails, x.denominations]) .runReadOnly(async (tx) => { const ex = await tx.exchanges.get(exchangeBaseurl); const dp = ex?.detailsPointer; @@ -769,8 +706,6 @@ async function getExchangeDetailedInfo( return; } - const tos = await getExchangeTosStatusDetails(tx, exchangeDetails); - const denominations: DenominationInfo[] = denominationRecords.map((x) => DenominationRecord.toDenomInfo(x), ); @@ -779,7 +714,6 @@ async function getExchangeDetailedInfo( info: { exchangeBaseUrl: ex.baseUrl, currency, - tos, paytoUris: exchangeDetails.wireInfo.accounts.map((x) => x.payto_uri), auditors: exchangeDetails.auditors, wireInfo: exchangeDetails.wireInfo, |