From 851ac5602cea0beb7b3e29dc9a95c2093a0ed906 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 May 2021 13:14:47 +0200 Subject: add UIDs for deletion tombstones to auditor/exchange trust management --- packages/taler-wallet-core/src/wallet.ts | 54 ++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'packages/taler-wallet-core/src/wallet.ts') diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index f69d26e84..192b54926 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -26,6 +26,7 @@ import { BackupRecovery, codecForAny, TalerErrorCode, + WalletCurrencyInfo, } from "@gnu-taler/taler-util"; import { CryptoWorkerFactory } from "./crypto/workers/cryptoApi"; import { @@ -56,7 +57,6 @@ import { import { acceptExchangeTermsOfService, getExchangePaytoUri, - getExchangeTrust, updateExchangeFromUrl, } from "./operations/exchanges"; import { @@ -99,9 +99,9 @@ import { processWithdrawGroup, } from "./operations/withdraw"; import { + AuditorTrustRecord, CoinRecord, CoinSourceType, - CurrencyRecord, DenominationRecord, ExchangeRecord, PurchaseRecord, @@ -179,19 +179,14 @@ import { AsyncCondition } from "./util/promiseUtils"; import { Database } from "./util/query"; import { Duration, durationMin } from "@gnu-taler/taler-util"; import { TimerGroup } from "./util/timer"; +import { getExchangeTrust } from "./operations/currencies.js"; -const builtinCurrencies: CurrencyRecord[] = [ +const builtinAuditors: AuditorTrustRecord[] = [ { - auditors: [ - { - auditorPub: "BW9DC48PHQY4NH011SHHX36DZZ3Q22Y6X7FZ1VD1CMZ2PTFZ6PN0", - auditorBaseUrl: "https://auditor.demo.taler.net/", - uids: ["5P25XF8TVQP9AW6VYGY2KV47WT5Y3ZXFSJAA570GJPX5SVJXKBVG"], - }, - ], - exchanges: [], - fractionalDigits: 2, - name: "KUDOS", + currency: "KUDOS", + auditorPub: "BW9DC48PHQY4NH011SHHX36DZZ3Q22Y6X7FZ1VD1CMZ2PTFZ6PN0", + auditorBaseUrl: "https://auditor.demo.taler.net/", + uids: ["5P25XF8TVQP9AW6VYGY2KV47WT5Y3ZXFSJAA570GJPX5SVJXKBVG"], }, ]; @@ -484,7 +479,7 @@ export class Wallet { */ async fillDefaults(): Promise { await this.db.runWithWriteTransaction( - [Stores.config, Stores.currencies], + [Stores.config, Stores.auditorTrustStore], async (tx) => { let applied = false; await tx.iter(Stores.config).forEach((x) => { @@ -493,8 +488,8 @@ export class Wallet { } }); if (!applied) { - for (const c of builtinCurrencies) { - await tx.put(Stores.currencies, c); + for (const c of builtinAuditors) { + await tx.put(Stores.auditorTrustStore, c); } } }, @@ -676,7 +671,6 @@ export class Wallet { return await this.db.iter(Stores.exchanges).toArray(); } - async getExchanges(): Promise { const exchanges: (ExchangeListItem | undefined)[] = await this.db .iter(Stores.exchanges) @@ -702,13 +696,25 @@ export class Wallet { }; } - async getCurrencies(): Promise { - return await this.db.iter(Stores.currencies).toArray(); - } - - async updateCurrency(currencyRecord: CurrencyRecord): Promise { - logger.trace("updating currency to", currencyRecord); - await this.db.put(Stores.currencies, currencyRecord); + async getCurrencies(): Promise { + const trustedAuditors = await this.db + .iter(Stores.auditorTrustStore) + .toArray(); + const trustedExchanges = await this.db + .iter(Stores.exchangeTrustStore) + .toArray(); + return { + trustedAuditors: trustedAuditors.map((x) => ({ + currency: x.currency, + auditorBaseUrl: x.auditorBaseUrl, + auditorPub: x.auditorPub, + })), + trustedExchanges: trustedExchanges.map((x) => ({ + currency: x.currency, + exchangeBaseUrl: x.exchangeBaseUrl, + exchangeMasterPub: x.exchangeMasterPub, + })), + }; } async getReserves(exchangeBaseUrl?: string): Promise { -- cgit v1.2.3