1- import { defineChain , getChainMetadata } from "thirdweb/chains" ;
2- import { CopyTextButton } from "@/components/ui/CopyTextButton" ;
1+ import { ExternalLinkIcon } from "lucide-react" ;
2+ import Link from "next/link" ;
3+ import { getAddress , NATIVE_TOKEN_ADDRESS } from "thirdweb" ;
4+ import {
5+ type ChainMetadata ,
6+ defineChain ,
7+ getChainMetadata ,
8+ } from "thirdweb/chains" ;
9+ import { shortenAddress } from "thirdweb/utils" ;
10+ import { Img } from "@/components/blocks/Img" ;
11+ import { Button } from "@/components/ui/button" ;
312import { TableCell , TableRow } from "@/components/ui/table" ;
413import { serverThirdwebClient } from "@/constants/thirdweb-client.server" ;
514import { resolveSchemeWithErrorHandler } from "@/utils/resolveSchemeWithErrorHandler" ;
@@ -52,72 +61,27 @@ export async function RouteListRow({
5261 ] ) ;
5362
5463 return (
55- < TableRow className = "group transition-colors hover:bg-accent/50" linkBox >
64+ < TableRow className = "group" >
5665 < TableCell >
57- < div className = "flex flex-row items-center gap-3" >
58- < div className = "flex items-center gap-2" >
59- { resolvedOriginTokenIconUri ? (
60- // For now we're using a normal img tag because the domain for these images is unknown
61- // eslint-disable-next-line @next/next/no-img-element
62- < img
63- alt = { originTokenAddress }
64- className = "size-7 rounded-full border border-border/50 shadow-sm transition-transform group-hover:scale-105"
65- src = { resolvedOriginTokenIconUri }
66- />
67- ) : (
68- < div className = "size-7 rounded-full bg-muted-foreground/20" />
69- ) }
70- { originTokenSymbol && (
71- < CopyTextButton
72- className = "relative z-10 font-medium text-base"
73- copyIconPosition = "right"
74- textToCopy = { originTokenAddress }
75- textToShow = {
76- originTokenSymbol === "ETH"
77- ? originChain . nativeCurrency . symbol
78- : originTokenSymbol
79- }
80- tooltip = "Copy Token Address"
81- variant = "ghost"
82- />
83- ) }
84- </ div >
85- </ div >
66+ < TokenInfo
67+ chainMetadata = { originChain }
68+ tokenAddress = { originTokenAddress }
69+ tokenIconUri = { resolvedOriginTokenIconUri }
70+ tokenSymbol = { originTokenSymbol }
71+ />
8672 </ TableCell >
8773
8874 < TableCell className = "text-muted-foreground/90" >
8975 < span className = "font-medium" > { originChain . name } </ span >
9076 </ TableCell >
9177
9278 < TableCell >
93- < div className = "flex flex-row items-center gap-3" >
94- < div className = "flex items-center gap-2" >
95- { resolvedDestinationTokenIconUri ? (
96- // eslint-disable-next-line @next/next/no-img-element
97- < img
98- alt = { destinationTokenAddress }
99- className = "size-7 rounded-full border border-border/50 shadow-sm transition-transform group-hover:scale-105"
100- src = { resolvedDestinationTokenIconUri }
101- />
102- ) : (
103- < div className = "size-7 rounded-full bg-muted-foreground/20" />
104- ) }
105- { destinationTokenSymbol && (
106- < CopyTextButton
107- className = "relative z-10 font-medium text-base"
108- copyIconPosition = "right"
109- textToCopy = { destinationTokenAddress }
110- textToShow = {
111- destinationTokenSymbol === "ETH"
112- ? destinationChain . nativeCurrency . symbol
113- : destinationTokenSymbol
114- }
115- tooltip = "Copy Token Address"
116- variant = "ghost"
117- />
118- ) }
119- </ div >
120- </ div >
79+ < TokenInfo
80+ chainMetadata = { destinationChain }
81+ tokenAddress = { destinationTokenAddress }
82+ tokenIconUri = { resolvedDestinationTokenIconUri }
83+ tokenSymbol = { destinationTokenSymbol }
84+ />
12185 </ TableCell >
12286
12387 < TableCell className = "text-muted-foreground/90" >
@@ -126,3 +90,47 @@ export async function RouteListRow({
12690 </ TableRow >
12791 ) ;
12892}
93+
94+ const nativeTokenAddress = getAddress ( NATIVE_TOKEN_ADDRESS ) ;
95+
96+ function TokenInfo ( props : {
97+ tokenAddress : string ;
98+ tokenSymbol : string | undefined ;
99+ chainMetadata : ChainMetadata ;
100+ tokenIconUri : string | undefined ;
101+ } ) {
102+ const isERC20 = getAddress ( props . tokenAddress ) !== nativeTokenAddress ;
103+
104+ return (
105+ < div className = "flex items-center gap-1.5" >
106+ { props . tokenIconUri ? (
107+ < Img
108+ alt = { props . tokenAddress }
109+ className = "size-7 rounded-full border border-border/50"
110+ src = { props . tokenIconUri }
111+ />
112+ ) : (
113+ < div className = "size-7 rounded-full bg-muted-foreground/20" />
114+ ) }
115+ { isERC20 ? (
116+ < Button
117+ asChild
118+ className = "h-auto w-auto py-1 px-1.5 gap-2"
119+ variant = "ghost"
120+ >
121+ < Link
122+ href = { `https://thirdweb.com/${ props . chainMetadata . slug } /${ props . tokenAddress } ` }
123+ target = "_blank"
124+ >
125+ { props . tokenSymbol || shortenAddress ( props . tokenAddress ) }
126+ < ExternalLinkIcon className = "size-3.5 text-muted-foreground" />
127+ </ Link >
128+ </ Button >
129+ ) : (
130+ < span className = "font-medium text-sm px-1.5 py-1" >
131+ { props . chainMetadata . nativeCurrency . symbol }
132+ </ span >
133+ ) }
134+ </ div >
135+ ) ;
136+ }
0 commit comments