From 32a0206a8aa95e749cb456392f94f5711b124c6f Mon Sep 17 00:00:00 2001 From: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com> Date: Sun, 27 Aug 2023 23:12:30 +0900 Subject: [PATCH] fix: return a 400 error on invalid address --- src/api.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index 70b9369..263f751 100644 --- a/src/api.ts +++ b/src/api.ts @@ -72,10 +72,18 @@ router.post('/', async (req, res) => { }); } + let address; + try { + address = getAddress(req.body.address); + } catch (e: any) { + return res.status(400).json({ + error: 'Invalid address' + }); + } + try { const msg = req.body.data.message; const msgHash = snapshot.utils.getHash(req.body.data); - const address = getAddress(req.body.address); const env = 'livenet'; let network = env === 'livenet' ? '1' : '5'; if (!req.body.data.types.Space && !msg.settings)