taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit de39d432374a3ecd1bddd788b1ac1585461af8c1
parent 2490393924aa44e6e3c2c072110a6175aaf41a82
Author: Florian Dold <florian@dold.me>
Date:   Mon,  8 Jan 2024 22:13:48 +0100

wallet-core: return exchange scope info if we already know the currency

Fixes bugs.taler.net/n/8034

Diffstat:
Mpackages/taler-wallet-core/src/operations/common.ts | 36++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts @@ -101,9 +101,8 @@ export async function makeCoinsVisible( }>, transactionId: string, ): Promise<void> { - const coins = await tx.coins.indexes.bySourceTransactionId.getAll( - transactionId, - ); + const coins = + await tx.coins.indexes.bySourceTransactionId.getAll(transactionId); for (const coinRecord of coins) { if (!coinRecord.visible) { coinRecord.visible = 1; @@ -657,6 +656,24 @@ export function getExchangeState(r: ExchangeEntryRecord): ExchangeEntryState { }; } +/** + * Mock scope info for an exchange by always returning a regional currency scope. + */ +function mockExchangeScopeInfo( + r: ExchangeEntryRecord, + exchangeDetails: ExchangeDetailsRecord | undefined, +): ScopeInfo | undefined { + const currency = r.presetCurrencyHint ?? exchangeDetails?.currency; + if (currency) { + return { + currency, + type: ScopeType.Exchange, + url: r.baseUrl, + }; + } + return undefined; +} + export function makeExchangeListItem( r: ExchangeEntryRecord, exchangeDetails: ExchangeDetailsRecord | undefined, @@ -668,16 +685,6 @@ export function makeExchangeListItem( } : undefined; - let scopeInfo: ScopeInfo | undefined = undefined; - if (exchangeDetails) { - // FIXME: Look up actual scope info. - scopeInfo = { - currency: exchangeDetails.currency, - type: ScopeType.Exchange, - url: r.baseUrl, - }; - } - return { exchangeBaseUrl: r.baseUrl, currency: exchangeDetails?.currency ?? r.presetCurrencyHint, @@ -689,7 +696,8 @@ export function makeExchangeListItem( : [], paytoUris: exchangeDetails?.wireInfo.accounts.map((x) => x.payto_uri) ?? [], lastUpdateErrorInfo, - scopeInfo, + // FIXME: Return real scope info in the future! + scopeInfo: mockExchangeScopeInfo(r, exchangeDetails), }; }