From 77569a2531c57bbdfcd63e65b0b259d978dfc598 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Mon, 31 Mar 2025 07:39:34 +0000 Subject: [PATCH] fix 404 response for missing wallet --- backend/src/api/services/services-routes.ts | 6 +++++- backend/src/api/services/wallets.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/src/api/services/services-routes.ts b/backend/src/api/services/services-routes.ts index 520496249..281bb1602 100644 --- a/backend/src/api/services/services-routes.ts +++ b/backend/src/api/services/services-routes.ts @@ -17,7 +17,11 @@ class ServicesRoutes { res.setHeader('Expires', new Date(Date.now() + 1000 * 5).toUTCString()); const walletId = req.params.walletId; const wallet = await WalletApi.getWallet(walletId); - res.status(200).send(wallet); + if (wallet === null) { + res.status(404).send('No such wallet'); + } else { + res.status(200).send(wallet); + } } catch (e) { handleError(req, res, 500, 'Failed to get wallet'); } diff --git a/backend/src/api/services/wallets.ts b/backend/src/api/services/wallets.ts index 540c093fe..b68a2e3c4 100644 --- a/backend/src/api/services/wallets.ts +++ b/backend/src/api/services/wallets.ts @@ -118,8 +118,12 @@ class WalletApi { } } - public getWallet(wallet: string): Record { - return this.wallets?.[wallet]?.addresses || {}; + public getWallet(wallet: string): Record | null { + if (wallet in this.wallets) { + return this.wallets?.[wallet]?.addresses || {}; + } else { + return null; + } } // resync wallet addresses from the services backend