Skip to content

Commit a87e91b

Browse files
committed
[MNY-305] Dashboard: Checksum addresses in tx page (#8380)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing address handling in the `GeneericTxDetails` and `TokenInfo` components by introducing the `getAddress` function from `thirdweb`, ensuring that addresses are consistently formatted. ### Detailed summary - Added `getAddress` import in `page.tsx` and `bridge-status.tsx`. - Replaced direct usage of `transaction.from` and `transaction.to` with `fromAddress` and `toAddress` in `GeneericTxDetails`. - Updated `textToCopy` and `textToShow` in `CopyTextButton` components to use `fromAddress` and `toAddress`. - Updated `TokenInfo` to use `getAddress` for `props.token.address` and `props.walletAddress`. - Changed `textToCopy` and `textToShow` in `TokenInfo` to use `tokenAddress`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved address normalization in transaction and bridge status displays to ensure consistent formatting across the dashboard, preventing potential issues with address validation and comparison. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 0e630c4 commit a87e91b

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/tx/[txHash]/bridge-status.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import {
1010
CircleXIcon,
1111
} from "lucide-react";
1212
import Link from "next/link";
13-
import { NATIVE_TOKEN_ADDRESS, type ThirdwebClient } from "thirdweb";
13+
import {
14+
getAddress,
15+
NATIVE_TOKEN_ADDRESS,
16+
type ThirdwebClient,
17+
} from "thirdweb";
1418
import type { Status, Token } from "thirdweb/bridge";
1519
import { status } from "thirdweb/bridge";
1620
import { toTokens } from "thirdweb/utils";
@@ -123,6 +127,8 @@ function TokenInfo(props: {
123127
const isNativeToken =
124128
props.token.address.toLowerCase() === NATIVE_TOKEN_ADDRESS.toLowerCase();
125129

130+
const tokenAddress = getAddress(props.token.address);
131+
126132
return (
127133
<div className="flex-1 pt-10 pb-9 px-6 lg:px-8">
128134
<div className="flex justify-between items-center">
@@ -206,7 +212,7 @@ function TokenInfo(props: {
206212
<div className="space-y-1">
207213
<p className="text-sm text-foreground ">{props.addressLabel}</p>
208214
<WalletAddress
209-
address={props.walletAddress}
215+
address={getAddress(props.walletAddress)}
210216
client={props.client}
211217
className="py-0.5 h-auto text-sm [&>*]:!font-sans tabular-nums [&>*]:font-normal text-muted-foreground hover:text-foreground"
212218
iconClassName="size-3"
@@ -222,8 +228,8 @@ function TokenInfo(props: {
222228
? `/${chainQuery.data?.slug || props.token.chainId}`
223229
: `/${chainQuery.data?.slug || props.token.chainId}/${props.token.address}`
224230
}
225-
textToShow={props.token.address}
226-
textToCopy={props.token.address}
231+
textToShow={tokenAddress}
232+
textToCopy={tokenAddress}
227233
copyTooltip="Copy Token Address"
228234
className="-translate-x-1"
229235
/>

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/tx/[txHash]/page.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Clock4Icon,
99
InfoIcon,
1010
} from "lucide-react";
11-
import { toTokens } from "thirdweb";
11+
import { getAddress, toTokens } from "thirdweb";
1212
import { status } from "thirdweb/bridge";
1313
import type { ChainMetadata } from "thirdweb/chains";
1414
import {
@@ -153,6 +153,9 @@ function GeneericTxDetails(props: {
153153

154154
const timestamp = getDatefromTimestamp(block.timestamp);
155155

156+
const fromAddress = getAddress(transaction.from);
157+
const toAddress = transaction.to ? getAddress(transaction.to) : undefined;
158+
156159
return (
157160
<div className="border rounded-xl p-4 lg:p-6 bg-card">
158161
{/* section 1 */}
@@ -216,23 +219,23 @@ function GeneericTxDetails(props: {
216219
<section className="border-b py-6 space-y-5 lg:space-y-3">
217220
<GridItem label="From" tooltip="The sending party of the transaction.">
218221
<CopyTextButton
219-
textToCopy={transaction.from}
220-
textToShow={transaction.from}
222+
textToCopy={fromAddress}
223+
textToShow={fromAddress}
221224
tooltip="Copy from address"
222225
variant="ghost"
223226
copyIconPosition="right"
224227
className="truncate -translate-x-1.5 max-w-full"
225228
/>
226229
</GridItem>
227230

228-
{transaction.to && (
231+
{toAddress && (
229232
<GridItem
230233
label="Interacted with (To)"
231234
tooltip="The receiving party of the transaction (could be a contract address)."
232235
>
233236
<CopyTextButton
234-
textToCopy={transaction.to}
235-
textToShow={transaction.to}
237+
textToCopy={toAddress}
238+
textToShow={toAddress}
236239
tooltip="Copy to address"
237240
variant="ghost"
238241
copyIconPosition="right"

0 commit comments

Comments
 (0)