@@ -5,6 +5,7 @@ import { Badge } from "@/components/ui/badge";
55import { Button } from "@/components/ui/button" ;
66import { Checkbox , CheckboxWithLabel } from "@/components/ui/checkbox" ;
77import { FormItem } from "@/components/ui/form" ;
8+ import { Skeleton } from "@/components/ui/skeleton" ;
89import {
910 type BackendWallet ,
1011 useEngineBackendWalletBalance ,
@@ -34,11 +35,9 @@ import { type ColumnDef, createColumnHelper } from "@tanstack/react-table";
3435import { ChainIcon } from "components/icons/ChainIcon" ;
3536import { TWTable } from "components/shared/TWTable" ;
3637import { useTrack } from "hooks/analytics/useTrack" ;
38+ import { useAllChainsData } from "hooks/chains/allChains" ;
3739import { EngineBackendWalletOptions } from "lib/engine" ;
38- import {
39- useActiveChainAsDashboardChain ,
40- useV5DashboardChain ,
41- } from "lib/v5-adapter" ;
40+ import { useV5DashboardChain } from "lib/v5-adapter" ;
4241import {
4342 DownloadIcon ,
4443 PencilIcon ,
@@ -52,7 +51,6 @@ import { useForm } from "react-hook-form";
5251import { toast } from "sonner" ;
5352import { getAddress } from "thirdweb" ;
5453import { shortenAddress } from "thirdweb/utils" ;
55- import invariant from "tiny-invariant" ;
5654import { FormHelperText , FormLabel , LinkButton , Text } from "tw-components" ;
5755import { prettyPrintCurrency } from "./utils" ;
5856
@@ -89,21 +87,21 @@ const BackendWalletBalanceCell: React.FC<BackendWalletBalanceCellProps> = ({
8987 instanceUrl : instanceUrl ,
9088 address,
9189 authToken,
90+ chainId,
9291 } ) ;
9392 const chain = useV5DashboardChain ( chainId ) ;
94- if ( ! chain || ! backendWalletBalance ) {
95- return ;
93+
94+ if ( ! backendWalletBalance ) {
95+ return < Skeleton className = "h-5 w-32 rounded-lg" /> ;
9696 }
9797
9898 const balanceDisplay = prettyPrintCurrency ( {
9999 amount : backendWalletBalance . displayValue ,
100- symbol : backendWalletBalance . symbol ,
100+ symbol : backendWalletBalance . symbol || chain . nativeCurrency ?. symbol ,
101101 } ) ;
102102
103103 const balanceComponent = (
104- < Text fontWeight = { backendWalletBalance . value === "0" ? "light" : "bold" } >
105- { balanceDisplay }
106- </ Text >
104+ < div className = "text-muted-foreground" > { balanceDisplay } </ div >
107105 ) ;
108106
109107 const explorer = chain . blockExplorers ?. [ 0 ] ;
@@ -250,6 +248,7 @@ export const BackendWalletsTable: React.FC<BackendWalletsTableProps> = ({
250248 disclosure = { sendDisclosure }
251249 instanceUrl = { instanceUrl }
252250 authToken = { authToken }
251+ chainId = { chainId }
253252 />
254253 ) }
255254 { selectedBackendWallet && deleteDisclosure . isOpen && (
@@ -425,36 +424,38 @@ const SendFundsModal = ({
425424 disclosure,
426425 instanceUrl,
427426 authToken,
427+ chainId,
428428} : {
429429 fromWallet : BackendWallet ;
430430 backendWallets : BackendWallet [ ] ;
431431 disclosure : UseDisclosureReturn ;
432432 instanceUrl : string ;
433433 authToken : string ;
434+ chainId : number ;
434435} ) => {
435- const chain = useActiveChainAsDashboardChain ( ) ;
436436 const form = useForm < SendFundsInput > ( ) ;
437437 const sendTokens = useEngineSendTokens ( {
438438 instanceUrl,
439439 authToken,
440440 } ) ;
441+ const { idToChain } = useAllChainsData ( ) ;
441442 const { data : backendWalletBalance } = useEngineBackendWalletBalance ( {
442443 instanceUrl,
443444 address : fromWallet . address ,
444445 authToken,
446+ chainId : chainId ,
445447 } ) ;
448+ const chain = idToChain . get ( chainId ) ;
446449 const toWalletDisclosure = useDisclosure ( ) ;
447450
448451 if ( ! backendWalletBalance ) {
449452 return null ;
450453 }
451454
452455 const onSubmit = async ( data : SendFundsInput ) => {
453- invariant ( chain , "chain is required" ) ;
454-
455456 const promise = sendTokens . mutateAsync (
456457 {
457- chainId : chain . chainId ,
458+ chainId : chainId ,
458459 fromAddress : fromWallet . address ,
459460 toAddress : data . toAddress ,
460461 amount : data . amount ,
0 commit comments