Skip to content

Commit

Permalink
Fix bank decoding error handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 25, 2023
1 parent 968b42f commit 468f3a8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/scripts/export/handlers/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 468f3a8

Please sign in to comment.