Skip to content

Commit bb67159

Browse files
committed
more fix
1 parent f95992a commit bb67159

3 files changed

Lines changed: 32 additions & 25 deletions

File tree

src/app/bundles/[hash]/page.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ function SimulationCard({ meter }: { meter: MeterBundleResponse }) {
315315
(sum, r) => sum + r.executionTimeUs,
316316
0,
317317
);
318-
const totalTimeUs = executionTimeUs + meter.stateRootTimeUs;
318+
const stateRootTimeUs = meter.stateRootTimeUs ?? 0;
319+
const totalTimeUs = executionTimeUs + stateRootTimeUs;
319320

320321
return (
321322
<Card>
@@ -330,7 +331,7 @@ function SimulationCard({ meter }: { meter: MeterBundleResponse }) {
330331
<div>
331332
<div className="text-xs text-gray-500 mb-1">State Root</div>
332333
<div className="text-xl font-semibold text-gray-900">
333-
{meter.stateRootTimeUs.toLocaleString()}μs
334+
{stateRootTimeUs.toLocaleString()}μs
334335
</div>
335336
</div>
336337
<div>
@@ -340,23 +341,23 @@ function SimulationCard({ meter }: { meter: MeterBundleResponse }) {
340341
</div>
341342
</div>
342343
</div>
343-
{(meter.stateRootAccountNodeCount > 0 ||
344-
meter.stateRootStorageNodeCount > 0) && (
344+
{((meter.stateRootAccountLeafCount ?? 0) > 0 ||
345+
(meter.stateRootStorageLeafCount ?? 0) > 0) && (
345346
<div className="grid grid-cols-2 gap-6 mt-4 pt-4 border-t border-gray-100">
346347
<div>
347348
<div className="text-xs text-gray-500 mb-1">
348349
Account Trie Nodes
349350
</div>
350351
<div className="text-xl font-semibold text-gray-900">
351-
{meter.stateRootAccountNodeCount.toLocaleString()}
352+
{((meter.stateRootAccountLeafCount ?? 0) + (meter.stateRootAccountBranchCount ?? 0)).toLocaleString()}
352353
</div>
353354
</div>
354355
<div>
355356
<div className="text-xs text-gray-500 mb-1">
356357
Storage Trie Nodes
357358
</div>
358359
<div className="text-xl font-semibold text-gray-900">
359-
{meter.stateRootStorageNodeCount.toLocaleString()}
360+
{((meter.stateRootStorageLeafCount ?? 0) + (meter.stateRootStorageBranchCount ?? 0)).toLocaleString()}
360361
</div>
361362
</div>
362363
</div>
@@ -366,7 +367,7 @@ function SimulationCard({ meter }: { meter: MeterBundleResponse }) {
366367
<div>
367368
<span className="text-gray-500">Total Gas</span>
368369
<span className="ml-2 font-medium text-gray-900">
369-
{meter.totalGasUsed.toLocaleString()}
370+
{(meter.totalGasUsed ?? 0).toLocaleString()}
370371
</span>
371372
</div>
372373
<div>

src/app/page.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ function MeteringCard({ meter }: { meter: MeterBundleResponse }) {
188188
(sum, r) => sum + r.executionTimeUs,
189189
0,
190190
);
191-
const totalTimeUs = executionTimeUs + meter.stateRootTimeUs;
191+
const stateRootTimeUs = meter.stateRootTimeUs ?? 0;
192+
const totalTimeUs = executionTimeUs + stateRootTimeUs;
192193

193194
return (
194195
<Card>
@@ -203,7 +204,7 @@ function MeteringCard({ meter }: { meter: MeterBundleResponse }) {
203204
<div>
204205
<div className="text-xs text-gray-500 mb-1">State Root</div>
205206
<div className="text-xl font-semibold text-gray-900">
206-
{meter.stateRootTimeUs.toLocaleString()}μs
207+
{stateRootTimeUs.toLocaleString()}μs
207208
</div>
208209
</div>
209210
<div>
@@ -213,23 +214,23 @@ function MeteringCard({ meter }: { meter: MeterBundleResponse }) {
213214
</div>
214215
</div>
215216
</div>
216-
{(meter.stateRootAccountNodeCount > 0 ||
217-
meter.stateRootStorageNodeCount > 0) && (
217+
{((meter.stateRootAccountLeafCount ?? 0) > 0 ||
218+
(meter.stateRootStorageLeafCount ?? 0) > 0) && (
218219
<div className="grid grid-cols-2 gap-6 mt-4 pt-4 border-t border-gray-100">
219220
<div>
220221
<div className="text-xs text-gray-500 mb-1">
221222
Account Trie Nodes
222223
</div>
223224
<div className="text-xl font-semibold text-gray-900">
224-
{meter.stateRootAccountNodeCount.toLocaleString()}
225+
{((meter.stateRootAccountLeafCount ?? 0) + (meter.stateRootAccountBranchCount ?? 0)).toLocaleString()}
225226
</div>
226227
</div>
227228
<div>
228229
<div className="text-xs text-gray-500 mb-1">
229230
Storage Trie Nodes
230231
</div>
231232
<div className="text-xl font-semibold text-gray-900">
232-
{meter.stateRootStorageNodeCount.toLocaleString()}
233+
{((meter.stateRootStorageLeafCount ?? 0) + (meter.stateRootStorageBranchCount ?? 0)).toLocaleString()}
233234
</div>
234235
</div>
235236
</div>
@@ -239,7 +240,7 @@ function MeteringCard({ meter }: { meter: MeterBundleResponse }) {
239240
<div>
240241
<span className="text-gray-500">Total Gas</span>
241242
<span className="ml-2 font-medium text-gray-900">
242-
{meter.totalGasUsed.toLocaleString()}
243+
{(meter.totalGasUsed ?? 0).toLocaleString()}
243244
</span>
244245
</div>
245246
<div>
@@ -613,14 +614,16 @@ function RejectedTransactionsTab() {
613614
);
614615
}
615616

616-
function getInitialTab(): Tab {
617-
if (typeof window === "undefined") return "blocks";
618-
const hash = window.location.hash.replace("#", "");
619-
return hash === "rejected" ? "rejected" : "blocks";
620-
}
621-
622617
export default function Home() {
623-
const [activeTab, setActiveTab] = useState<Tab>(getInitialTab);
618+
const [activeTab, setActiveTab] = useState<Tab>("blocks");
619+
620+
// Read hash on client only after hydration
621+
useEffect(() => {
622+
const hash = window.location.hash.replace("#", "");
623+
if (hash === "rejected") {
624+
setActiveTab("rejected");
625+
}
626+
}, []);
624627
const [error, setError] = useState<string | null>(null);
625628
const [blocks, setBlocks] = useState<BlockSummary[]>([]);
626629
const [loading, setLoading] = useState(true);

src/lib/s3.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ export interface MeterBundleResponse {
129129
totalGasUsed: number;
130130
totalExecutionTimeUs: number;
131131
stateRootTimeUs: number;
132-
stateRootAccountNodeCount: number;
133-
stateRootStorageNodeCount: number;
132+
stateRootAccountLeafCount: number;
133+
stateRootAccountBranchCount: number;
134+
stateRootStorageLeafCount: number;
135+
stateRootStorageBranchCount: number;
134136
}
135137

136138
export interface BundleData {
@@ -262,8 +264,9 @@ export interface RejectedTransaction {
262264
metering: MeterBundleResponse;
263265
}
264266

265-
export function formatRejectionReason(reason: RejectionReason): string {
266-
if (reason.executionTimeExceeded) {
267+
export function formatRejectionReason(reason: RejectionReason | string): string {
268+
if (typeof reason === "string") return reason;
269+
if (reason?.executionTimeExceeded) {
267270
const { txTimeUs, limitUs } = reason.executionTimeExceeded;
268271
return `Execution time exceeded: ${txTimeUs.toLocaleString()}μs > ${limitUs.toLocaleString()}μs limit`;
269272
}

0 commit comments

Comments
 (0)