Skip to content

Commit a7b365e

Browse files
authored
Fix null tx.to crash on contract creation transactions (#154)
tx.to is null for contract creation transactions, causing "Cannot read properties of null (reading 'slice')" in the bundle detail page. Add null guards and display "Contract Creation" instead.
1 parent b5f1d24 commit a7b365e

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ function TransactionDetails({
183183
</div>
184184
<div className="text-xs text-gray-500 mt-0.5">
185185
{tx.signer.slice(0, 6)}...{tx.signer.slice(-4)}{" "}
186-
{tx.to.slice(0, 6)}...{tx.to.slice(-4)}
186+
{tx.to
187+
? `${tx.to.slice(0, 6)}...${tx.to.slice(-4)}`
188+
: "Contract Creation"}
187189
</div>
188190
</div>
189191
</div>
@@ -251,16 +253,22 @@ function TransactionDetails({
251253
<tr>
252254
<td className="text-gray-500 py-2">To</td>
253255
<td className="py-2 text-right">
254-
<span className="inline-flex items-center gap-1">
255-
<ExplorerLink
256-
type="address"
257-
value={tx.to}
258-
className="font-mono text-gray-900"
259-
>
260-
{tx.to}
261-
</ExplorerLink>
262-
<CopyButton text={tx.to} />
263-
</span>
256+
{tx.to ? (
257+
<span className="inline-flex items-center gap-1">
258+
<ExplorerLink
259+
type="address"
260+
value={tx.to}
261+
className="font-mono text-gray-900"
262+
>
263+
{tx.to}
264+
</ExplorerLink>
265+
<CopyButton text={tx.to} />
266+
</span>
267+
) : (
268+
<span className="font-mono text-gray-500">
269+
Contract Creation
270+
</span>
271+
)}
264272
</td>
265273
</tr>
266274
</tbody>

src/lib/s3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export interface BundleTransaction {
9393
gas: string;
9494
maxFeePerGas: string;
9595
maxPriorityFeePerGas: string;
96-
to: string;
96+
to: string | null;
9797
value: string;
9898
accessList: unknown[];
9999
input: string;

0 commit comments

Comments
 (0)