diff options
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index bccdf721f..e5e179937 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -42,6 +42,7 @@ import { ExchangesShortListResponse, FeeDescription, GetCurrencySpecificationResponse, + GetExchangeEntryByUrlResponse, GetExchangeTosResult, InitResponse, KnownBankAccounts, @@ -89,6 +90,7 @@ import { codecForGetBalanceDetailRequest, codecForGetContractTermsDetails, codecForGetCurrencyInfoRequest, + codecForGetExchangeEntryByUrlRequest, codecForGetExchangeTosRequest, codecForGetWithdrawalDetailsForAmountRequest, codecForGetWithdrawalDetailsForUri, @@ -1148,6 +1150,38 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( case WalletApiOperation.ListExchanges: { return await getExchanges(ws); } + case WalletApiOperation.GetExchangeEntryByUrl: { + const req = codecForGetExchangeEntryByUrlRequest().decode(payload); + const exchangeEntry = await ws.db + .mktx((x) => [ + x.exchanges, + x.exchangeDetails, + x.denominations, + x.operationRetries, + ]) + .runReadOnly(async (tx) => { + const exchangeRec = await tx.exchanges.get(req.exchangeBaseUrl); + if (!exchangeRec) { + throw Error("exchange not found"); + } + const exchangeDetails = await getExchangeDetails( + tx, + exchangeRec.baseUrl, + ); + const opRetryRecord = await tx.operationRetries.get( + TaskIdentifiers.forExchangeUpdate(exchangeRec), + ); + return makeExchangeListItem( + exchangeRec, + exchangeDetails, + opRetryRecord?.lastError, + ); + }); + const result: GetExchangeEntryByUrlResponse = { + exchangeEntry, + }; + return result; + } case WalletApiOperation.ListExchangesForScopedCurrency: { const req = codecForListExchangesForScopedCurrencyRequest().decode(payload); |