Commit 2081c83e authored by tom goriunov's avatar tom goriunov Committed by GitHub

ENS: add offchain support and fix bugs (#2156)

* ens: add offchain support and fix bugs

Fixes #2136

* fix ts
parent d5ed4f85
...@@ -63,6 +63,14 @@ export const ensDomainA: bens.DetailedDomain = { ...@@ -63,6 +63,14 @@ export const ensDomainA: bens.DetailedDomain = {
NEAR: 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near', NEAR: 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near',
}, },
protocol: protocolA, protocol: protocolA,
resolver_address: {
hash: '0xD578780f1dA7404d9CC0eEbC9D684c140CC4b638',
},
resolved_with_wildcard: true,
stored_offchain: true,
wrapped_owner: {
hash: '0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401',
},
}; };
export const ensDomainB: bens.DetailedDomain = { export const ensDomainB: bens.DetailedDomain = {
...@@ -81,6 +89,8 @@ export const ensDomainB: bens.DetailedDomain = { ...@@ -81,6 +89,8 @@ export const ensDomainB: bens.DetailedDomain = {
expiry_date: undefined, expiry_date: undefined,
other_addresses: {}, other_addresses: {},
protocol: undefined, protocol: undefined,
resolved_with_wildcard: false,
stored_offchain: false,
}; };
export const ensDomainC: bens.DetailedDomain = { export const ensDomainC: bens.DetailedDomain = {
...@@ -101,6 +111,8 @@ export const ensDomainC: bens.DetailedDomain = { ...@@ -101,6 +111,8 @@ export const ensDomainC: bens.DetailedDomain = {
expiry_date: '2022-11-01T13:10:36.000Z', expiry_date: '2022-11-01T13:10:36.000Z',
other_addresses: {}, other_addresses: {},
protocol: undefined, protocol: undefined,
resolved_with_wildcard: false,
stored_offchain: false,
}; };
export const ensDomainD: bens.DetailedDomain = { export const ensDomainD: bens.DetailedDomain = {
...@@ -119,4 +131,6 @@ export const ensDomainD: bens.DetailedDomain = { ...@@ -119,4 +131,6 @@ export const ensDomainD: bens.DetailedDomain = {
expiry_date: '2027-09-23T13:10:36.000Z', expiry_date: '2027-09-23T13:10:36.000Z',
other_addresses: {}, other_addresses: {},
protocol: undefined, protocol: undefined,
resolved_with_wildcard: false,
stored_offchain: false,
}; };
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
"monitoring:grafana:local": "docker run -d -p 4000:3000 --name=blockscout_grafana --user $(id -u) --volume $(pwd)/grafana:/var/lib/grafana grafana/grafana-enterprise" "monitoring:grafana:local": "docker run -d -p 4000:3000 --name=blockscout_grafana --user $(id -u) --volume $(pwd)/grafana:/var/lib/grafana grafana/grafana-enterprise"
}, },
"dependencies": { "dependencies": {
"@blockscout/bens-types": "1.3.4", "@blockscout/bens-types": "1.4.1",
"@blockscout/stats-types": "1.6.0", "@blockscout/stats-types": "1.6.0",
"@blockscout/visualizer-types": "0.2.0", "@blockscout/visualizer-types": "0.2.0",
"@chakra-ui/react": "2.7.1", "@chakra-ui/react": "2.7.1",
......
...@@ -22,6 +22,8 @@ export const ENS_DOMAIN: bens.DetailedDomain = { ...@@ -22,6 +22,8 @@ export const ENS_DOMAIN: bens.DetailedDomain = {
ETH: ADDRESS_HASH, ETH: ADDRESS_HASH,
}, },
protocol: undefined, protocol: undefined,
resolved_with_wildcard: false,
stored_offchain: false,
}; };
export const ENS_DOMAIN_EVENT: bens.DomainEvent = { export const ENS_DOMAIN_EVENT: bens.DomainEvent = {
......
...@@ -31,7 +31,7 @@ import PopoverTriggerTooltip from 'ui/shared/PopoverTriggerTooltip'; ...@@ -31,7 +31,7 @@ import PopoverTriggerTooltip from 'ui/shared/PopoverTriggerTooltip';
interface Props { interface Props {
query: UseQueryResult<bens.LookupAddressResponse, ResourceError<unknown>>; query: UseQueryResult<bens.LookupAddressResponse, ResourceError<unknown>>;
addressHash: string; addressHash: string;
mainDomainName: string | null; mainDomainName: string | null | undefined;
} }
const DomainsGrid = ({ data }: { data: Array<bens.Domain> }) => { const DomainsGrid = ({ data }: { data: Array<bens.Domain> }) => {
...@@ -64,9 +64,9 @@ const AddressEnsDomains = ({ query, addressHash, mainDomainName }: Props) => { ...@@ -64,9 +64,9 @@ const AddressEnsDomains = ({ query, addressHash, mainDomainName }: Props) => {
return null; return null;
} }
const mainDomain = data.items.find((domain) => domain.name === mainDomainName); const mainDomain = data.items.find((domain) => mainDomainName && domain.name === mainDomainName);
const ownedDomains = data.items.filter((domain) => { const ownedDomains = data.items.filter((domain) => {
if (domain.name === mainDomainName) { if (mainDomainName && domain.name === mainDomainName) {
return false; return false;
} }
......
...@@ -17,6 +17,7 @@ import IconSvg from 'ui/shared/IconSvg'; ...@@ -17,6 +17,7 @@ import IconSvg from 'ui/shared/IconSvg';
import LinkInternal from 'ui/shared/links/LinkInternal'; import LinkInternal from 'ui/shared/links/LinkInternal';
import TextSeparator from 'ui/shared/TextSeparator'; import TextSeparator from 'ui/shared/TextSeparator';
import NameDomainDetailsAlert from './details/NameDomainDetailsAlert';
import NameDomainExpiryStatus from './NameDomainExpiryStatus'; import NameDomainExpiryStatus from './NameDomainExpiryStatus';
interface Props { interface Props {
...@@ -30,6 +31,8 @@ const NameDomainDetails = ({ query }: Props) => { ...@@ -30,6 +31,8 @@ const NameDomainDetails = ({ query }: Props) => {
const hasExpired = query.data?.expiry_date && dayjs(query.data.expiry_date).isBefore(dayjs()); const hasExpired = query.data?.expiry_date && dayjs(query.data.expiry_date).isBefore(dayjs());
return ( return (
<>
<NameDomainDetailsAlert data={ query.data }/>
<Grid columnGap={ 8 } rowGap={ 3 } templateColumns={{ base: 'minmax(0, 1fr)', lg: 'max-content minmax(728px, auto)' }}> <Grid columnGap={ 8 } rowGap={ 3 } templateColumns={{ base: 'minmax(0, 1fr)', lg: 'max-content minmax(728px, auto)' }}>
{ query.data?.registration_date && ( { query.data?.registration_date && (
<> <>
...@@ -78,6 +81,24 @@ const NameDomainDetails = ({ query }: Props) => { ...@@ -78,6 +81,24 @@ const NameDomainDetails = ({ query }: Props) => {
</> </>
) } ) }
{ query.data?.resolver_address && (
<>
<DetailsInfoItem.Label
hint="The resolver contract provides information about a domain name"
isLoading={ isLoading }
>
Resolver
</DetailsInfoItem.Label>
<DetailsInfoItem.Value
>
<AddressEntity
address={ query.data.resolver_address }
isLoading={ isLoading }
/>
</DetailsInfoItem.Value>
</>
) }
{ query.data?.registrant && ( { query.data?.registrant && (
<> <>
<DetailsInfoItem.Label <DetailsInfoItem.Label
...@@ -220,6 +241,7 @@ const NameDomainDetails = ({ query }: Props) => { ...@@ -220,6 +241,7 @@ const NameDomainDetails = ({ query }: Props) => {
</> </>
) } ) }
</Grid> </Grid>
</>
); );
}; };
......
import { Alert } from '@chakra-ui/react';
import React from 'react';
import type * as bens from '@blockscout/bens-types';
import LinkExternal from 'ui/shared/links/LinkExternal';
interface Props {
data: bens.DetailedDomain | undefined;
}
const NameDomainDetailsAlert = ({ data }: Props) => {
if (!data?.stored_offchain || !data?.resolved_with_wildcard) {
return null;
}
return (
<Alert status="info" colorScheme="gray" display="inline-block" whiteSpace="pre-wrap" mb={ 6 }>
<span>The domain name is resolved offchain using </span>
{ data.stored_offchain && <LinkExternal href="https://eips.ethereum.org/EIPS/eip-3668">EIP-3668: CCIP Read</LinkExternal> }
{ data.stored_offchain && data.resolved_with_wildcard && <span> & </span> }
{ data.resolved_with_wildcard && <LinkExternal href="https://eips.ethereum.org/EIPS/eip-2544">EIP-2544: Wildcard Resolution</LinkExternal> }
</Alert>
);
};
export default React.memo(NameDomainDetailsAlert);
...@@ -327,8 +327,8 @@ const AddressPageContent = () => { ...@@ -327,8 +327,8 @@ const AddressPageContent = () => {
<HStack ml="auto" gap={ 2 }/> <HStack ml="auto" gap={ 2 }/>
{ !isLoading && addressQuery.data?.is_contract && addressQuery.data?.is_verified && config.UI.views.address.solidityscanEnabled && { !isLoading && addressQuery.data?.is_contract && addressQuery.data?.is_verified && config.UI.views.address.solidityscanEnabled &&
<SolidityscanReport hash={ hash }/> } <SolidityscanReport hash={ hash }/> }
{ !isLoading && addressQuery.data && config.features.nameService.isEnabled && { !isLoading && addressEnsDomainsQuery.data && config.features.nameService.isEnabled &&
<AddressEnsDomains query={ addressEnsDomainsQuery } addressHash={ hash } mainDomainName={ addressQuery.data.ens_domain_name }/> } <AddressEnsDomains query={ addressEnsDomainsQuery } addressHash={ hash } mainDomainName={ addressQuery.data?.ens_domain_name }/> }
<NetworkExplorers type="address" pathParam={ hash }/> <NetworkExplorers type="address" pathParam={ hash }/>
</Flex> </Flex>
); );
......
...@@ -1327,10 +1327,10 @@ ...@@ -1327,10 +1327,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@blockscout/bens-types@1.3.4": "@blockscout/bens-types@1.4.1":
version "1.3.4" version "1.4.1"
resolved "https://registry.yarnpkg.com/@blockscout/bens-types/-/bens-types-1.3.4.tgz#e75b863c6d065e7d6d5d01e1a1d64da8df261640" resolved "https://registry.yarnpkg.com/@blockscout/bens-types/-/bens-types-1.4.1.tgz#9182a79d9015b7fa2339edf0bfa3cd0c32045e66"
integrity sha512-kKRa8jKu/CBLR3QbWpRXmtwIXiIwIPDrFeEPIYUQp5bg9uY+ActOyQERixo/9FE+BHZShWUDm+75FoaAmIGIOw== integrity sha512-TlZ1HVdZ2Cswm/CcvNoxS+Ydiht/YGaLo//PJR/UmkmihlEFoY4HfVJvVcUnOQXi+Si7FwJ486DPii889nTJsQ==
"@blockscout/stats-types@1.6.0": "@blockscout/stats-types@1.6.0":
version "1.6.0" version "1.6.0"
...@@ -14899,16 +14899,7 @@ string-template@~0.2.1: ...@@ -14899,16 +14899,7 @@ string-template@~0.2.1:
resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add" resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add"
integrity sha512-Yptehjogou2xm4UJbxJ4CxgZx12HBfeystp0y3x7s4Dj32ltVVG1Gg8YhKjHZkHicuKpZX/ffilA8505VbUbpw== integrity sha512-Yptehjogou2xm4UJbxJ4CxgZx12HBfeystp0y3x7s4Dj32ltVVG1Gg8YhKjHZkHicuKpZX/ffilA8505VbUbpw==
"string-width-cjs@npm:string-width@^4.2.0": "string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3" version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
...@@ -15036,14 +15027,7 @@ string_decoder@~1.1.1: ...@@ -15036,14 +15027,7 @@ string_decoder@~1.1.1:
dependencies: dependencies:
safe-buffer "~5.1.0" safe-buffer "~5.1.0"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1": "strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1" version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
...@@ -16203,7 +16187,7 @@ word-wrap@^1.2.5, word-wrap@~1.2.3: ...@@ -16203,7 +16187,7 @@ word-wrap@^1.2.5, word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0" version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
...@@ -16221,15 +16205,6 @@ wrap-ansi@^6.2.0: ...@@ -16221,15 +16205,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0" string-width "^4.1.0"
strip-ansi "^6.0.0" strip-ansi "^6.0.0"
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@^8.1.0: wrap-ansi@^8.1.0:
version "8.1.0" version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment