diff options
author | Florian Dold <florian@dold.me> | 2024-01-08 22:13:48 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-01-08 22:13:48 +0100 |
commit | de39d432374a3ecd1bddd788b1ac1585461af8c1 (patch) | |
tree | bcd55d18fa5b05ef8bee6e348ac69c9ce65fe237 /packages/taler-wallet-core | |
parent | 2490393924aa44e6e3c2c072110a6175aaf41a82 (diff) | |
download | wallet-core-de39d432374a3ecd1bddd788b1ac1585461af8c1.tar.xz |
wallet-core: return exchange scope info if we already know the currency
Fixes bugs.taler.net/n/8034
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/operations/common.ts | 36 |
1 files 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 index abba3f7a7..d8fb82be1 100644 --- 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), }; } |