Skip to content

Commit 8bb2117

Browse files
authored
fix(ui): handle undefined values in BigInt formatting functions (#118)
Add null checks to formatHexValue() and formatGasPrice() to prevent "Cannot convert undefined to a BigInt" error when viewing bundles with missing meter fields.
1 parent c6ae6f5 commit 8bb2117

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ui/src/app/bundles/[uuid]/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function formatBigInt(value: bigint, decimals: number, scale: bigint): string {
1919
return `${whole}.${frac.toString().padStart(decimals, "0")}`;
2020
}
2121

22-
function formatHexValue(hex: string): string {
22+
function formatHexValue(hex: string | undefined): string {
23+
if (!hex) return "—";
2324
const value = BigInt(hex);
2425
if (value >= WEI_PER_ETH / 10000n) {
2526
return `${formatBigInt(value, 6, WEI_PER_ETH)} ETH`;
@@ -30,7 +31,8 @@ function formatHexValue(hex: string): string {
3031
return `${value.toString()} Wei`;
3132
}
3233

33-
function formatGasPrice(hex: string): string {
34+
function formatGasPrice(hex: string | undefined): string {
35+
if (!hex) return "—";
3436
const value = BigInt(hex);
3537
return `${formatBigInt(value, 2, WEI_PER_GWEI)} Gwei`;
3638
}

0 commit comments

Comments
 (0)