Disable search by ENS name if network does not support it
This commit is contained in:
parent
33839eb5ef
commit
488f267d48
|
@ -100,7 +100,10 @@ const Address: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<StandardFrame>
|
<StandardFrame>
|
||||||
{error ? (
|
{error ? (
|
||||||
<AddressOrENSNameNotFound addressOrENSName={addressOrName} />
|
<AddressOrENSNameNotFound
|
||||||
|
addressOrENSName={addressOrName}
|
||||||
|
supportsENS={provider?.network.ensAddress !== undefined}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
checksummedAddress && (
|
checksummedAddress && (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -4,16 +4,19 @@ import ContentFrame from "../ContentFrame";
|
||||||
|
|
||||||
type AddressOrENSNameNotFoundProps = {
|
type AddressOrENSNameNotFoundProps = {
|
||||||
addressOrENSName: string;
|
addressOrENSName: string;
|
||||||
|
supportsENS: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AddressOrENSNameNotFound: React.FC<AddressOrENSNameNotFoundProps> = ({
|
const AddressOrENSNameNotFound: React.FC<AddressOrENSNameNotFoundProps> = ({
|
||||||
addressOrENSName,
|
addressOrENSName,
|
||||||
|
supportsENS,
|
||||||
}) => (
|
}) => (
|
||||||
<>
|
<>
|
||||||
<StandardSubtitle>Transaction Details</StandardSubtitle>
|
<StandardSubtitle>Transaction Details</StandardSubtitle>
|
||||||
<ContentFrame>
|
<ContentFrame>
|
||||||
<div className="py-4 text-sm">
|
<div className="py-4 text-sm">
|
||||||
"{addressOrENSName}" is not an ETH address or ENS name.
|
"{addressOrENSName}" is not an ETH address
|
||||||
|
{supportsENS && " or ENS name"}.
|
||||||
</div>
|
</div>
|
||||||
</ContentFrame>
|
</ContentFrame>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -48,19 +48,25 @@ export const useAddressOrENS = (
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const resolveName = async () => {
|
if (provider.network.ensAddress) {
|
||||||
const resolvedAddress = await provider.resolveName(addressOrName);
|
const resolveName = async () => {
|
||||||
if (resolvedAddress !== null) {
|
const resolvedAddress = await provider.resolveName(addressOrName);
|
||||||
setENS(true);
|
if (resolvedAddress !== null) {
|
||||||
setError(false);
|
setENS(true);
|
||||||
setChecksummedAddress(resolvedAddress);
|
setError(false);
|
||||||
} else {
|
setChecksummedAddress(resolvedAddress);
|
||||||
setENS(false);
|
} else {
|
||||||
setError(true);
|
setENS(false);
|
||||||
setChecksummedAddress(undefined);
|
setError(true);
|
||||||
}
|
setChecksummedAddress(undefined);
|
||||||
};
|
}
|
||||||
resolveName();
|
};
|
||||||
|
resolveName();
|
||||||
|
} else {
|
||||||
|
setENS(false);
|
||||||
|
setError(true);
|
||||||
|
setChecksummedAddress(undefined);
|
||||||
|
}
|
||||||
}, [provider, addressOrName, urlFixer]);
|
}, [provider, addressOrName, urlFixer]);
|
||||||
|
|
||||||
return [checksummedAddress, isENS, error];
|
return [checksummedAddress, isENS, error];
|
||||||
|
|
Loading…
Reference in New Issue