diff options
author | Florian Dold <florian@dold.me> | 2021-05-20 13:14:47 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-05-20 13:15:11 +0200 |
commit | 851ac5602cea0beb7b3e29dc9a95c2093a0ed906 (patch) | |
tree | 294e00a40e752c52706b65c86807028ffc450938 /packages/taler-wallet-core/src/operations/reserves.ts | |
parent | 0299e719ce4c97748090fa238cb5f68303fb4abf (diff) | |
download | wallet-core-851ac5602cea0beb7b3e29dc9a95c2093a0ed906.tar.gz wallet-core-851ac5602cea0beb7b3e29dc9a95c2093a0ed906.tar.bz2 wallet-core-851ac5602cea0beb7b3e29dc9a95c2093a0ed906.zip |
add UIDs for deletion tombstones to auditor/exchange trust management
Diffstat (limited to 'packages/taler-wallet-core/src/operations/reserves.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/reserves.ts | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/packages/taler-wallet-core/src/operations/reserves.ts b/packages/taler-wallet-core/src/operations/reserves.ts index 9a479427e..9addca975 100644 --- a/packages/taler-wallet-core/src/operations/reserves.ts +++ b/packages/taler-wallet-core/src/operations/reserves.ts @@ -38,7 +38,6 @@ import { ReserveRecordStatus, ReserveBankInfo, ReserveRecord, - CurrencyRecord, WithdrawalGroupRecord, } from "../db.js"; import { @@ -158,31 +157,9 @@ export async function createReserve( throw Error("exchange not updated"); } const { isAudited, isTrusted } = await getExchangeTrust(ws, exchangeInfo); - let currencyRecord = await ws.db.get( - Stores.currencies, - exchangeDetails.currency, - ); - if (!currencyRecord) { - currencyRecord = { - auditors: [], - exchanges: [], - fractionalDigits: 2, - name: exchangeDetails.currency, - }; - } - - if (!isAudited && !isTrusted) { - currencyRecord.exchanges.push({ - exchangeBaseUrl: req.exchange, - exchangeMasterPub: exchangeDetails.masterPublicKey, - uids: [encodeCrock(getRandomBytes(32))], - }); - } - - const cr: CurrencyRecord = currencyRecord; const resp = await ws.db.runWithWriteTransaction( - [Stores.currencies, Stores.reserves, Stores.bankWithdrawUris], + [Stores.exchangeTrustStore, Stores.reserves, Stores.bankWithdrawUris], async (tx) => { // Check if we have already created a reserve for that bankWithdrawStatusUrl if (reserveRecord.bankInfo?.statusUrl) { @@ -207,7 +184,14 @@ export async function createReserve( talerWithdrawUri: reserveRecord.bankInfo.statusUrl, }); } - await tx.put(Stores.currencies, cr); + if (!isAudited && !isAudited) { + await tx.put(Stores.exchangeTrustStore, { + currency: reserveRecord.currency, + exchangeBaseUrl: reserveRecord.exchangeBaseUrl, + exchangeMasterPub: exchangeDetails.masterPublicKey, + uids: [encodeCrock(getRandomBytes(32))], + }); + } await tx.put(Stores.reserves, reserveRecord); const r: CreateReserveResponse = { exchange: canonExchange, |