Files
explore/ui/shared/AppActionButton/useAppActionData.tsx
T
tom goriunovandGitHub e91b780802 Resolve BENS names from URL directly to address page (#2004)
* Resolve BENS names from URL directly to address page

Fixes #1965

* fix tests
2024-06-13 13:11:13 +02:00

15 lines
605 B
TypeScript

import { useMemo } from 'react';
import useAddressMetadataInfoQuery from 'lib/address/useAddressMetadataInfoQuery';
export default function useAppActionData(address: string | undefined = '', isEnabled = false) {
const memoizedArray = useMemo(() => address ? [ address ] : [], [ address ]);
const { data } = useAddressMetadataInfoQuery(memoizedArray, isEnabled);
const metadata = data?.addresses[address?.toLowerCase()];
const tag = metadata?.tags?.find(({ tagType }) => tagType === 'protocol');
if (tag?.meta?.appMarketplaceURL || tag?.meta?.appID) {
return tag.meta;
}
return null;
}