Skip to content

Commit

Permalink
Fix bank balance bigint decoding failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 30, 2023
1 parent d8228c2 commit 3bd9710
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/scripts/export/handlers/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ export const bank: HandlerMaker = async ({
// Ignore decoding errors.
}

// Try to decode as legacy Coin protobuf.
// Try to decode as legacy Coin protobuf, and ensure amount can be parsed
// as a bigint. Otherwise, ignore. The protobuf will decode (and not
// error) if the value is another protobuf, but `amount` will likely
// contain other data instead of a number. There's no way to ensure it's
// actually a coin protobuf, so this is the best we can do.
try {
balance = Coin.decode(valueData).amount
balance = BigInt(Coin.decode(valueData).amount).toString()
} catch {
// Ignore decoding errors.
}
Expand Down

0 comments on commit 3bd9710

Please sign in to comment.