@@ -15,6 +15,7 @@ import type { Chain } from "../../../../chains/types.js";
1515import type { ThirdwebClient } from "../../../../client/client.js" ;
1616import { getContract } from "../../../../contract/contract.js" ;
1717import { getLastAuthProvider } from "../../../../react/core/utils/storage.js" ;
18+ import { shortenAddress } from "../../../../utils/address.js" ;
1819import { isContractDeployed } from "../../../../utils/bytecode/is-contract-deployed.js" ;
1920import { formatNumber } from "../../../../utils/formatNumber.js" ;
2021import { webLocalStorage } from "../../../../utils/storage/webStorage.js" ;
@@ -67,10 +68,7 @@ import type {
6768 SupportedTokens ,
6869} from "../../../core/utils/defaultTokens.js" ;
6970import { hasSmartAccount } from "../../../core/utils/isSmartWallet.js" ;
70- import {
71- useConnectedWalletDetails ,
72- useWalletInfo ,
73- } from "../../../core/utils/wallet.js" ;
71+ import { useWalletInfo } from "../../../core/utils/wallet.js" ;
7472import { WalletUIStatesProvider } from "../../providers/wallet-ui-states-provider.js" ;
7573import { ChainIcon } from "../components/ChainIcon.js" ;
7674import { CopyIcon } from "../components/CopyIcon.js" ;
@@ -86,8 +84,13 @@ import { Button, IconButton } from "../components/buttons.js";
8684import { Link , Text } from "../components/text.js" ;
8785import { fadeInAnimation } from "../design-system/animations.js" ;
8886import { StyledButton } from "../design-system/elements.js" ;
87+ import { AccountAddress } from "../prebuilt/Account/address.js" ;
88+ import { AccountAvatar } from "../prebuilt/Account/avatar.js" ;
89+ import { AccountBalance } from "../prebuilt/Account/balance.js" ;
90+ import { AccountBlobbie } from "../prebuilt/Account/blobbie.js" ;
91+ import { AccountName } from "../prebuilt/Account/name.js" ;
92+ import { AccountProvider } from "../prebuilt/Account/provider.js" ;
8993import type { LocaleId } from "../types.js" ;
90- import { Blobbie } from "./Blobbie.js" ;
9194import { MenuButton , MenuLink } from "./MenuButton.js" ;
9295import { ScreenSetupContext , useSetupScreen } from "./Modal/screen.js" ;
9396import {
@@ -140,18 +143,10 @@ export const ConnectedWalletDetails: React.FC<{
140143 connectOptions : DetailsModalConnectOptions | undefined ;
141144} > = ( props ) => {
142145 const { connectLocale : locale , client } = props ;
143-
144146 const setRootEl = useContext ( SetRootElementContext ) ;
145147 const activeAccount = useActiveAccount ( ) ;
146148 const walletChain = useActiveWalletChain ( ) ;
147149
148- const { pfp, name, balanceQuery } = useConnectedWalletDetails (
149- client ,
150- walletChain ,
151- activeAccount ,
152- props . detailsButton ?. displayBalanceToken ,
153- ) ;
154-
155150 function closeModal ( ) {
156151 setRootEl ( null ) ;
157152 }
@@ -199,8 +194,6 @@ export const ConnectedWalletDetails: React.FC<{
199194 ) ;
200195 }
201196
202- const avatarSrc = props . detailsButton ?. connectedAccountAvatarUrl || pfp ;
203-
204197 const combinedClassName = `${ TW_CONNECTED_WALLET } ${ props . detailsButton ?. className || "" } ` ;
205198
206199 return (
@@ -219,17 +212,26 @@ export const ConnectedWalletDetails: React.FC<{
219212 height : "35px" ,
220213 } }
221214 >
222- { avatarSrc ? (
215+ { props . detailsButton ?. connectedAccountAvatarUrl ? (
223216 < img
224217 alt = ""
225- src = { avatarSrc }
218+ src = { props . detailsButton . connectedAccountAvatarUrl }
226219 style = { {
227220 width : "100%" ,
228221 height : "100%" ,
229222 } }
230223 />
231224 ) : (
232- activeAccount && < Blobbie address = { activeAccount . address } size = { 35 } />
225+ activeAccount && (
226+ < AccountAvatar
227+ loadingComponent = { < AccountBlobbie size = { 35 } /> }
228+ fallbackComponent = { < AccountBlobbie size = { 35 } /> }
229+ queryOptions = { {
230+ refetchOnWindowFocus : false ,
231+ refetchOnMount : false ,
232+ } }
233+ />
234+ )
233235 ) }
234236 </ Container >
235237 < Container
@@ -242,29 +244,47 @@ export const ConnectedWalletDetails: React.FC<{
242244 } }
243245 >
244246 { /* Address */ }
245- < Text
246- size = "xs"
247- color = "primaryText"
248- weight = { 500 }
249- className = { `${ TW_CONNECTED_WALLET } __address` }
250- >
251- { props . detailsButton ?. connectedAccountName ?? name }
252- </ Text >
253-
254- { /* Balance */ }
255- { balanceQuery . data ? (
247+ { props . detailsButton ?. connectedAccountName ? (
256248 < Text
257- className = { `${ TW_CONNECTED_WALLET } __balance` }
258249 size = "xs"
259- color = "secondaryText"
260- weight = { 400 }
250+ color = "primaryText"
251+ weight = { 500 }
252+ className = { `${ TW_CONNECTED_WALLET } __address` }
261253 >
262- { formatBalanceOnButton ( Number ( balanceQuery . data . displayValue ) ) } { " " }
263- { balanceQuery . data . symbol }
254+ { props . detailsButton . connectedAccountName }
264255 </ Text >
265256 ) : (
266- < Skeleton height = { fontSize . xs } width = "70px" />
257+ < Text
258+ size = "xs"
259+ color = "primaryText"
260+ weight = { 500 }
261+ className = { `${ TW_CONNECTED_WALLET } __address` }
262+ >
263+ < AccountName
264+ loadingComponent = { < AccountAddress formatFn = { shortenAddress } /> }
265+ fallbackComponent = { < AccountAddress formatFn = { shortenAddress } /> }
266+ />
267+ </ Text >
267268 ) }
269+
270+ < Text
271+ className = { `${ TW_CONNECTED_WALLET } __balance` }
272+ size = "xs"
273+ color = "secondaryText"
274+ weight = { 400 }
275+ >
276+ < AccountBalance
277+ chain = { walletChain }
278+ loadingComponent = { < Skeleton height = { fontSize . xs } width = "70px" /> }
279+ fallbackComponent = { < Skeleton height = { fontSize . xs } width = "70px" /> }
280+ formatFn = { formatBalanceOnButton }
281+ tokenAddress = {
282+ props . detailsButton ?. displayBalanceToken ?. [
283+ Number ( walletChain ?. id )
284+ ]
285+ }
286+ />
287+ </ Text >
268288 </ Container >
269289 </ WalletInfoButton >
270290 ) ;
@@ -294,12 +314,6 @@ function DetailsModal(props: {
294314 const { client, locale } = props ;
295315 const walletChain = useActiveWalletChain ( ) ;
296316 const activeAccount = useActiveAccount ( ) ;
297- const { pfp, name, balanceQuery } = useConnectedWalletDetails (
298- client ,
299- walletChain ,
300- activeAccount ,
301- props . displayBalanceToken ,
302- ) ;
303317 const theme = parseTheme ( props . theme ) ;
304318
305319 const activeWallet = useActiveWallet ( ) ;
@@ -362,12 +376,15 @@ function DetailsModal(props: {
362376 < Text color = "primaryText" size = "md" multiline >
363377 { chainNameQuery . name || `Unknown chain #${ walletChain ?. id } ` }
364378 < Text color = "secondaryText" size = "xs" >
365- { balanceQuery . data ? (
366- formatNumber ( Number ( balanceQuery . data . displayValue ) , 9 )
367- ) : (
368- < Skeleton height = "1em" width = "100px" />
369- ) } { " " }
370- { balanceQuery . data ?. symbol }
379+ < AccountBalance
380+ fallbackComponent = { < Skeleton height = "1em" width = "100px" /> }
381+ loadingComponent = { < Skeleton height = "1em" width = "100px" /> }
382+ formatFn = { ( num : number ) => formatNumber ( num , 9 ) }
383+ chain = { walletChain }
384+ tokenAddress = {
385+ props . displayBalanceToken ?. [ Number ( walletChain ?. id ) ]
386+ }
387+ />
371388 </ Text >
372389 </ Text >
373390 ) }
@@ -383,8 +400,6 @@ function DetailsModal(props: {
383400 </ MenuButton >
384401 ) ;
385402
386- const avatarSrc = props . detailsModal ?. connectedAccountAvatarUrl ?? pfp ;
387-
388403 const { hideSendFunds, hideReceiveFunds, hideBuyFunds } =
389404 props . detailsModal || { } ;
390405
@@ -406,9 +421,9 @@ function DetailsModal(props: {
406421 overflow : "hidden" ,
407422 } }
408423 >
409- { avatarSrc ? (
424+ { props . detailsModal ?. connectedAccountAvatarUrl ? (
410425 < img
411- src = { avatarSrc }
426+ src = { props . detailsModal . connectedAccountAvatarUrl }
412427 style = { {
413428 width : iconSize . xxl ,
414429 height : iconSize . xxl ,
@@ -417,9 +432,9 @@ function DetailsModal(props: {
417432 />
418433 ) : (
419434 activeAccount && (
420- < Blobbie
421- address = { activeAccount . address }
422- size = { Number ( iconSize . xxl ) }
435+ < AccountAvatar
436+ loadingComponent = { < AccountBlobbie size = { Number ( iconSize . xxl ) } /> }
437+ fallbackComponent = { < AccountBlobbie size = { Number ( iconSize . xxl ) } /> }
423438 />
424439 )
425440 ) }
@@ -494,9 +509,22 @@ function DetailsModal(props: {
494509 alignItems : "center" ,
495510 } }
496511 >
497- < Text color = "primaryText" weight = { 500 } size = "md" >
498- { props . detailsModal ?. connectedAccountName ?? name }
499- </ Text >
512+ { props . detailsModal ?. connectedAccountName ? (
513+ < Text color = "primaryText" weight = { 500 } size = "md" >
514+ { props . detailsModal . connectedAccountName }
515+ </ Text >
516+ ) : (
517+ < Text color = "primaryText" weight = { 500 } size = "md" >
518+ < AccountName
519+ loadingComponent = {
520+ < AccountAddress formatFn = { shortenAddress } />
521+ }
522+ fallbackComponent = {
523+ < AccountAddress formatFn = { shortenAddress } />
524+ }
525+ />
526+ </ Text >
527+ ) }
500528 < IconButton >
501529 < CopyIcon
502530 text = { activeAccount ?. address || "" }
@@ -962,7 +990,12 @@ function DetailsModal(props: {
962990 }
963991 } }
964992 >
965- { content }
993+ < AccountProvider
994+ address = { activeAccount ?. address || "" }
995+ client = { client }
996+ >
997+ { content }
998+ </ AccountProvider >
966999 </ Modal >
9671000 </ ScreenSetupContext . Provider >
9681001 </ WalletUIStatesProvider >
0 commit comments