From 468f3a8679637190b1478e639eb0db2b6958ac00 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Mon, 25 Sep 2023 10:48:51 -0700 Subject: [PATCH] Fix bank decoding error handler. --- src/scripts/export/handlers/bank.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/scripts/export/handlers/bank.ts b/src/scripts/export/handlers/bank.ts index 408e96d8..305ccd0f 100644 --- a/src/scripts/export/handlers/bank.ts +++ b/src/scripts/export/handlers/bank.ts @@ -56,14 +56,21 @@ export const bank: HandlerMaker = async ({ // BalancesPrefix || len(addressBytes) || addressBytes || denomBytes const keyData = fromBase64(trace.key) - if (keyData[0] !== 0x02) { + if (keyData[0] !== 0x02 || keyData.length < 3) { return } const length = keyData[1] - const address = toBech32(config.bech32Prefix, keyData.slice(2, 2 + length)) - const denom = fromUtf8(keyData.slice(2 + length)) + let address + let denom + try { + address = toBech32(config.bech32Prefix, keyData.slice(2, 2 + length)) + denom = fromUtf8(keyData.slice(2 + length)) + } catch { + // Ignore decoding errors. + return + } // If we reached the first event of the next block, flush the previous // events to the DB. This ensures we batch all events from the same block