File tree Expand file tree Collapse file tree 2 files changed +26
-15
lines changed
packages/ui/src/components
widgets/TokenWidget/widget Expand file tree Collapse file tree 2 files changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -101,12 +101,20 @@ export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
101101
102102 const showDropdown = context !== 'origin' || filteredWallets . length > 0
103103
104+ const isEnsCapableVmType =
105+ chain ?. vmType === 'evm' ||
106+ chain ?. vmType === 'hypevm' ||
107+ selectedWallet ?. vmType === 'evm' ||
108+ selectedWallet ?. vmType === 'hypevm'
109+
110+ const shouldResolveEns = isEnsCapableVmType && isSupportedSelectedWallet
111+
104112 const { displayName } = useENSResolver ( selectedWalletAddress , {
105- enabled :
106- ( chain ?. vmType === 'evm' || chain ?. vmType === 'hypevm' ) &&
107- isSupportedSelectedWallet
113+ enabled : shouldResolveEns
108114 } )
109115
116+ const shouldShowEns = isEnsCapableVmType && Boolean ( displayName )
117+
110118 return (
111119 < Dropdown
112120 open = { showDropdown ? open : false }
@@ -174,8 +182,7 @@ export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
174182 { isSupportedSelectedWallet &&
175183 selectedWalletAddress &&
176184 selectedWalletAddress != ''
177- ? displayName &&
178- ( chain ?. vmType === 'evm' || chain ?. vmType === 'hypevm' )
185+ ? shouldShowEns
179186 ? displayName
180187 : truncateAddress ( selectedWalletAddress )
181188 : 'Select wallet' }
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import type { DebouncedState } from 'usehooks-ts'
3535import type { AdaptedWallet } from '@relayprotocol/relay-sdk'
3636import type { LinkedWallet } from '../../../../types/index.js'
3737import {
38+ addressesEqual ,
3839 addressWithFallback ,
3940 isValidAddress
4041} from '../../../../utils/address.js'
@@ -293,22 +294,25 @@ const TokenWidgetRenderer: FC<TokenWidgetRendererProps> = ({
293294 return defaultAddress
294295 }
295296
296- // Find the first wallet that supports the target chain's VM type
297- const compatibleWallet = linkedWallets . find ( ( wallet ) => {
298- // Check if wallet VM matches chain VM
299- if ( wallet . vmType !== targetChain . vmType ) {
300- return false
301- }
302-
303- // Additional validation for specific chains
304- return isValidAddress (
297+ const isCompatibleWallet = ( wallet : LinkedWallet ) =>
298+ wallet . vmType === targetChain . vmType &&
299+ isValidAddress (
305300 targetChain . vmType ,
306301 wallet . address ,
307302 targetChain . id ,
308303 wallet . connector ,
309304 connectorKeyOverrides
310305 )
311- } )
306+
307+ const activeLinkedWallet = linkedWallets . find ( ( wallet ) =>
308+ addressesEqual ( wallet . vmType , wallet . address , defaultAddress )
309+ )
310+
311+ if ( activeLinkedWallet && isCompatibleWallet ( activeLinkedWallet ) ) {
312+ return activeLinkedWallet . address
313+ }
314+
315+ const compatibleWallet = linkedWallets . find ( isCompatibleWallet )
312316
313317 return compatibleWallet ?. address || defaultAddress
314318 } , [
You can’t perform that action at this time.
0 commit comments