diff options
| author | Florian Dold <florian@dold.me> | 2022-09-14 21:27:03 +0200 | 
|---|---|---|
| committer | Florian Dold <florian@dold.me> | 2022-09-14 21:27:03 +0200 | 
| commit | a66b636dee2ed531bb5119feced80d6569d99176 (patch) | |
| tree | d19b83739531220051ab850bfe3dd9478f7fca6b /packages/taler-wallet-core/src/wallet.ts | |
| parent | c021876b41bff11ad28c3a43808795fa0d02ce99 (diff) | |
wallet-core: restructure denomination record for easier querying
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
| -rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 49 | 
1 files changed, 41 insertions, 8 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index afbee4e64..02ed8a61b 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -102,6 +102,7 @@ import {    CoinRecord,    CoinSourceType,    CoinStatus, +  DenominationRecord,    exportDb,    importDb,    OperationAttemptResult, @@ -731,14 +732,29 @@ async function getExchangeDetailedInfo(          return;        } -      const denominations = await tx.denominations.indexes.byExchangeBaseUrl -        .iter(ex.baseUrl) -        .toArray(); +      const denominationRecords = +        await tx.denominations.indexes.byExchangeBaseUrl +          .iter(ex.baseUrl) +          .toArray(); -      if (!denominations) { +      if (!denominationRecords) {          return;        } +      const denominations: DenomInfo[] = denominationRecords.map((x) => ({ +        denomPub: x.denomPub, +        denomPubHash: x.denomPubHash, +        feeDeposit: x.fees.feeDeposit, +        feeRefresh: x.fees.feeRefresh, +        feeRefund: x.fees.feeRefund, +        feeWithdraw: x.fees.feeWithdraw, +        stampExpireDeposit: x.stampExpireDeposit, +        stampExpireLegal: x.stampExpireLegal, +        stampExpireWithdraw: x.stampExpireWithdraw, +        stampStart: x.stampStart, +        value: DenominationRecord.getValue(x), +      })); +        return {          info: {            exchangeBaseUrl: ex.baseUrl, @@ -753,7 +769,7 @@ async function getExchangeDetailedInfo(            auditors: exchangeDetails.auditors,            wireInfo: exchangeDetails.wireInfo,          }, -        denominations: denominations, +        denominations,        };      }); @@ -969,7 +985,11 @@ async function dumpCoins(ws: InternalWalletState): Promise<CoinDumpJson> {            coin_pub: c.coinPub,            denom_pub: denomInfo.denomPub,            denom_pub_hash: c.denomPubHash, -          denom_value: Amounts.stringify(denom.value), +          denom_value: Amounts.stringify({ +            value: denom.amountVal, +            currency: denom.currency, +            fraction: denom.amountFrac, +          }),            exchange_base_url: c.exchangeBaseUrl,            refresh_parent_coin_pub: refreshParentCoinPub,            remaining_value: Amounts.stringify(c.currentAmount), @@ -1566,9 +1586,22 @@ class InternalWalletStateImpl implements InternalWalletState {      }      const d = await tx.denominations.get([exchangeBaseUrl, denomPubHash]);      if (d) { -      this.denomCache[key] = d; +      const denomInfo = { +        denomPub: d.denomPub, +        denomPubHash: d.denomPubHash, +        feeDeposit: d.fees.feeDeposit, +        feeRefresh: d.fees.feeRefresh, +        feeRefund: d.fees.feeRefund, +        feeWithdraw: d.fees.feeWithdraw, +        stampExpireDeposit: d.stampExpireDeposit, +        stampExpireLegal: d.stampExpireLegal, +        stampExpireWithdraw: d.stampExpireWithdraw, +        stampStart: d.stampStart, +        value: DenominationRecord.getValue(d), +      }; +      return denomInfo;      } -    return d; +    return undefined;    }    notify(n: WalletNotification): void {  | 
