From e840d5392b045c6d4163469631c6b50702839e0c Mon Sep 17 00:00:00 2001 From: Danyal Prout Date: Mon, 22 Dec 2025 11:06:33 -0600 Subject: [PATCH] fix(ui): handle undefined values in BigInt formatting functions Add null checks to formatHexValue() and formatGasPrice() to prevent "Cannot convert undefined to a BigInt" error when viewing bundles with missing meter fields. --- ui/src/app/bundles/[uuid]/page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/src/app/bundles/[uuid]/page.tsx b/ui/src/app/bundles/[uuid]/page.tsx index 95187f3..07c6973 100644 --- a/ui/src/app/bundles/[uuid]/page.tsx +++ b/ui/src/app/bundles/[uuid]/page.tsx @@ -19,7 +19,8 @@ function formatBigInt(value: bigint, decimals: number, scale: bigint): string { return `${whole}.${frac.toString().padStart(decimals, "0")}`; } -function formatHexValue(hex: string): string { +function formatHexValue(hex: string | undefined): string { + if (!hex) return "—"; const value = BigInt(hex); if (value >= WEI_PER_ETH / 10000n) { return `${formatBigInt(value, 6, WEI_PER_ETH)} ETH`; @@ -30,7 +31,8 @@ function formatHexValue(hex: string): string { return `${value.toString()} Wei`; } -function formatGasPrice(hex: string): string { +function formatGasPrice(hex: string | undefined): string { + if (!hex) return "—"; const value = BigInt(hex); return `${formatBigInt(value, 2, WEI_PER_GWEI)} Gwei`; }