Skip to content

Commit d3fca9a

Browse files
committed
fix: build error
1 parent 3845e5e commit d3fca9a

File tree

2 files changed

+109
-84
lines changed

2 files changed

+109
-84
lines changed

apps/dashboard/src/app/(dashboard)/(bridge)/routes/components/server/routelist-card.tsx

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Card, CardContent, CardHeader } from "@/components/ui/card";
22
import { getThirdwebClient } from "@/constants/thirdweb.server";
33
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
4-
import { defineChain } from "thirdweb";
4+
import { defineChain, getContract } from "thirdweb";
55
import { getChainMetadata } from "thirdweb/chains";
6-
import { TokenName, TokenProvider } from "thirdweb/react";
6+
import { name } from "thirdweb/extensions/common";
77

88
type RouteListCardProps = {
99
originChainId: number;
@@ -24,25 +24,45 @@ export async function RouteListCard({
2424
}: RouteListCardProps) {
2525
const [
2626
originChain,
27+
originTokenName,
2728
destinationChain,
29+
destinationTokenName,
2830
resolvedOriginTokenIconUri,
2931
resolvedDestinationTokenIconUri,
3032
] = await Promise.all([
3133
// eslint-disable-next-line no-restricted-syntax
3234
getChainMetadata(defineChain(originChainId)),
35+
originTokenAddress === "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
36+
? "ETH"
37+
: name({
38+
contract: getContract({
39+
address: originTokenAddress,
40+
chain: defineChain(originChainId),
41+
client: getThirdwebClient(),
42+
}),
43+
}).catch(() => undefined),
3344
// eslint-disable-next-line no-restricted-syntax
3445
getChainMetadata(defineChain(destinationChainId)),
46+
destinationTokenAddress === "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
47+
? "ETH"
48+
: name({
49+
contract: getContract({
50+
address: destinationTokenAddress,
51+
chain: defineChain(destinationChainId),
52+
client: getThirdwebClient(),
53+
}),
54+
}).catch(() => undefined),
3555
originTokenIconUri
3656
? resolveSchemeWithErrorHandler({
37-
uri: originTokenIconUri,
38-
client: getThirdwebClient(),
39-
})
57+
uri: originTokenIconUri,
58+
client: getThirdwebClient(),
59+
})
4060
: undefined,
4161
destinationTokenIconUri
4262
? resolveSchemeWithErrorHandler({
43-
uri: destinationTokenIconUri,
44-
client: getThirdwebClient(),
45-
})
63+
uri: destinationTokenIconUri,
64+
client: getThirdwebClient(),
65+
})
4666
: undefined,
4767
]);
4868

@@ -78,29 +98,19 @@ export async function RouteListCard({
7898
<tbody className="text-sm [&_td>*]:min-h-[25px]">
7999
<tr>
80100
<th className="text-left font-normal text-base">
81-
<TokenProvider
82-
address={originTokenAddress}
83-
// eslint-disable-next-line no-restricted-syntax
84-
chain={defineChain(originChainId)}
85-
client={getThirdwebClient()}
86-
>
87-
<TokenName />
88-
</TokenProvider>
101+
{originTokenName === "ETH"
102+
? originChain.nativeCurrency.name
103+
: originTokenName}
89104
</th>
90105
<td className="text-right text-base text-muted-foreground">
91106
{originChain.name}
92107
</td>
93108
</tr>
94109
<tr>
95110
<th className="text-left font-normal text-base">
96-
<TokenProvider
97-
address={destinationTokenAddress}
98-
// eslint-disable-next-line no-restricted-syntax
99-
chain={defineChain(destinationChainId)}
100-
client={getThirdwebClient()}
101-
>
102-
<TokenName />
103-
</TokenProvider>
111+
{destinationTokenName === "ETH"
112+
? destinationChain.nativeCurrency.name
113+
: destinationTokenName}
104114
</th>
105115
<td className="text-right text-base text-muted-foreground">
106116
{destinationChain.name}

apps/dashboard/src/app/(dashboard)/(bridge)/routes/components/server/routelist-row.tsx

Lines changed: 75 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { CopyTextButton } from "@/components/ui/CopyTextButton";
22
import { TableCell, TableRow } from "@/components/ui/table";
33
import { getThirdwebClient } from "@/constants/thirdweb.server";
44
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
5+
import { getContract } from "thirdweb";
56
import { defineChain, getChainMetadata } from "thirdweb/chains";
6-
import { TokenProvider, TokenSymbol } from "thirdweb/react";
7+
import { symbol } from "thirdweb/extensions/common";
78

89
type RouteListRowProps = {
910
originChainId: number;
@@ -24,95 +25,109 @@ export async function RouteListRow({
2425
}: RouteListRowProps) {
2526
const [
2627
originChain,
28+
originTokenSymbol,
2729
destinationChain,
30+
destinationTokenSymbol,
2831
resolvedOriginTokenIconUri,
2932
resolvedDestinationTokenIconUri,
3033
] = await Promise.all([
3134
// eslint-disable-next-line no-restricted-syntax
3235
getChainMetadata(defineChain(originChainId)),
36+
originTokenAddress === "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
37+
? "ETH"
38+
: symbol({
39+
contract: getContract({
40+
address: originTokenAddress,
41+
chain: defineChain(originChainId),
42+
client: getThirdwebClient(),
43+
}),
44+
}).catch(() => undefined),
3345
// eslint-disable-next-line no-restricted-syntax
3446
getChainMetadata(defineChain(destinationChainId)),
47+
destinationTokenAddress === "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
48+
? "ETH"
49+
: symbol({
50+
contract: getContract({
51+
address: destinationTokenAddress,
52+
chain: defineChain(destinationChainId),
53+
client: getThirdwebClient(),
54+
}),
55+
}).catch(() => undefined),
3556
originTokenIconUri
3657
? resolveSchemeWithErrorHandler({
37-
uri: originTokenIconUri,
38-
client: getThirdwebClient(),
39-
})
58+
uri: originTokenIconUri,
59+
client: getThirdwebClient(),
60+
})
4061
: undefined,
4162
destinationTokenIconUri
4263
? resolveSchemeWithErrorHandler({
43-
uri: destinationTokenIconUri,
44-
client: getThirdwebClient(),
45-
})
64+
uri: destinationTokenIconUri,
65+
client: getThirdwebClient(),
66+
})
4667
: undefined,
4768
]);
4869

4970
return (
5071
<TableRow linkBox className="hover:bg-accent/50">
5172
<TableCell>
52-
<TokenProvider
53-
address={originTokenAddress}
54-
// eslint-disable-next-line no-restricted-syntax
55-
chain={defineChain(originChainId)}
56-
client={getThirdwebClient()}
57-
>
58-
<div className="flex flex-row items-center gap-4">
59-
<div className="flex items-center gap-1">
60-
{resolvedOriginTokenIconUri ? (
61-
// For now we're using a normal img tag because the domain for these images is unknown
62-
<img
63-
src={resolvedOriginTokenIconUri}
64-
alt={originTokenAddress}
65-
className="size-6 rounded-full bg-muted-foreground"
66-
/>
67-
) : (
68-
<div className="size-6 rounded-full bg-muted-foreground" />
69-
)}
70-
<CopyTextButton
71-
textToCopy={originTokenAddress}
72-
textToShow={<TokenSymbol />}
73-
tooltip="Copy Token Address"
74-
className="relative z-10 text-base"
75-
variant="ghost"
76-
copyIconPosition="right"
73+
<div className="flex flex-row items-center gap-4">
74+
<div className="flex items-center gap-1">
75+
{resolvedOriginTokenIconUri ? (
76+
// For now we're using a normal img tag because the domain for these images is unknown
77+
<img
78+
src={resolvedOriginTokenIconUri}
79+
alt={originTokenAddress}
80+
className="size-6 rounded-full bg-muted-foreground"
7781
/>
78-
</div>
82+
) : (
83+
<div className="size-6 rounded-full bg-muted-foreground" />
84+
)}
85+
<CopyTextButton
86+
textToCopy={originTokenAddress}
87+
textToShow={
88+
originTokenSymbol === "ETH"
89+
? originChain.nativeCurrency.symbol
90+
: originTokenSymbol
91+
}
92+
tooltip="Copy Token Address"
93+
className="relative z-10 text-base"
94+
variant="ghost"
95+
copyIconPosition="right"
96+
/>
7997
</div>
80-
</TokenProvider>
98+
</div>
8199
</TableCell>
82100

83101
<TableCell className="text-muted-foreground">
84102
{originChain.name}
85103
</TableCell>
86104

87105
<TableCell>
88-
<TokenProvider
89-
address={destinationTokenAddress}
90-
// eslint-disable-next-line no-restricted-syntax
91-
chain={defineChain(destinationChainId)}
92-
client={getThirdwebClient()}
93-
>
94-
<div className="flex flex-row items-center gap-4">
95-
<div className="flex items-center gap-1">
96-
{resolvedDestinationTokenIconUri ? (
97-
<img
98-
src={resolvedDestinationTokenIconUri}
99-
alt={destinationTokenAddress}
100-
className="size-6 rounded-full bg-muted-foreground"
101-
/>
102-
) : (
103-
<div className="size-6 rounded-full bg-muted-foreground" />
104-
)}
105-
<CopyTextButton
106-
textToCopy={destinationTokenAddress}
107-
textToShow={<TokenSymbol />}
108-
tooltip="Copy Token Address"
109-
className="relative z-10 text-base"
110-
variant="ghost"
111-
copyIconPosition="right"
106+
<div className="flex flex-row items-center gap-4">
107+
<div className="flex items-center gap-1">
108+
{resolvedDestinationTokenIconUri ? (
109+
<img
110+
src={resolvedDestinationTokenIconUri}
111+
alt={destinationTokenAddress}
112+
className="size-6 rounded-full bg-muted-foreground"
112113
/>
113-
</div>
114+
) : (
115+
<div className="size-6 rounded-full bg-muted-foreground" />
116+
)}
117+
<CopyTextButton
118+
textToCopy={destinationTokenAddress}
119+
textToShow={
120+
destinationTokenSymbol === "ETH"
121+
? destinationChain.nativeCurrency.symbol
122+
: destinationTokenSymbol
123+
}
124+
tooltip="Copy Token Address"
125+
className="relative z-10 text-base"
126+
variant="ghost"
127+
copyIconPosition="right"
128+
/>
114129
</div>
115-
</TokenProvider>
130+
</div>
116131
</TableCell>
117132

118133
<TableCell className="text-muted-foreground">

0 commit comments

Comments
 (0)