e81e8a8f71
* Revert "Revert "Merge branch 'main' of https://github.com/Uniswap/interface" (#2912)" This reverts commit 7d343dcfbdf75a2f91d28cefce84e4b1bace7b87. * Revert "deleted files" This reverts commit 097b8361d4c09afd3cb681c4622145c555ced884.
19 lines
725 B
TypeScript
19 lines
725 B
TypeScript
import { useMemo } from 'react'
|
|
|
|
import contenthashToUri from '../utils/contenthashToUri'
|
|
import { parseENSAddress } from '../utils/parseENSAddress'
|
|
import uriToHttp from '../utils/uriToHttp'
|
|
import useENSContentHash from './useENSContentHash'
|
|
|
|
export default function useHttpLocations(uri: string | undefined): string[] {
|
|
const ens = useMemo(() => (uri ? parseENSAddress(uri) : undefined), [uri])
|
|
const resolvedContentHash = useENSContentHash(ens?.ensName)
|
|
return useMemo(() => {
|
|
if (ens) {
|
|
return resolvedContentHash.contenthash ? uriToHttp(contenthashToUri(resolvedContentHash.contenthash)) : []
|
|
} else {
|
|
return uri ? uriToHttp(uri) : []
|
|
}
|
|
}, [ens, resolvedContentHash.contenthash, uri])
|
|
}
|