diff --git a/packages/frontend/src/blockchain/hooks/useExplorerAddressLink.ts b/packages/frontend/src/blockchain/hooks/useExplorerAddressLink.ts new file mode 100644 index 00000000..cbde45e2 --- /dev/null +++ b/packages/frontend/src/blockchain/hooks/useExplorerAddressLink.ts @@ -0,0 +1,13 @@ +import { Hex } from 'viem' +import { useChainId, useChains } from 'wagmi' + +export const useExplorerAddressLink = (address: Hex): string | undefined => { + const chains = useChains() + const chainId = useChainId() + const currentChain = chains.find((chain) => chain.id === chainId) + + if (!currentChain || !currentChain.blockExplorers?.default) { + return undefined + } + return `${currentChain.blockExplorers.default.url}/address/${address}` +} diff --git a/packages/frontend/src/components/bids/BidsListEntry.tsx b/packages/frontend/src/components/bids/BidsListEntry.tsx index 5f65c4fc..8b0a5c6e 100644 --- a/packages/frontend/src/components/bids/BidsListEntry.tsx +++ b/packages/frontend/src/components/bids/BidsListEntry.tsx @@ -1,9 +1,9 @@ import { AddressColumn, BidColumn, PlaceColumn } from '@/components/bids/BidsColumns' import styled, { css } from 'styled-components' -import { useChainId, useChains } from 'wagmi' import { BidWithPlace } from '@/types/bid' import { Colors } from '@/styles/colors' import { formatEther, Hex } from 'viem' +import { useExplorerAddressLink } from '@/blockchain/hooks/useExplorerAddressLink' interface Props { bid: BidWithPlace @@ -29,17 +29,6 @@ export const BidsListEntry = ({ bid, isUser, view = 'full' }: Props) => { ) } -const useExplorerAddressLink = (address: Hex): string | undefined => { - const chains = useChains() - const chainId = useChainId() - const currentChain = chains.find((chain) => chain.id === chainId) - - if (!currentChain || !currentChain.blockExplorers?.default) { - return undefined - } - return `${currentChain.blockExplorers.default.url}/address/${address}` -} - const shortenEthAddress = (address: Hex) => `${address.substring(0, 6)}......${address.substring(address.length - 4)}` const BidsEntryRow = styled.div<{ isUser?: boolean }>`