diff --git a/cypress/integration/nameDetail.spec.js b/cypress/integration/nameDetail.spec.js index 0b947ab13..b83833e9f 100644 --- a/cypress/integration/nameDetail.spec.js +++ b/cypress/integration/nameDetail.spec.js @@ -358,6 +358,19 @@ describe('Name detail view', () => { ]) }) + it('cannot change deprecated ipns contenthash', () => { + const url = `${NAME_ROOT}/abittooawesome4.eth` + cy.visit(url) + const DEPRECATED_CONTENT_HASH = 'ipns://app.uniswap.org' + cy.queryByText(DEPRECATED_CONTENT_HASH, { timeout: 10000 }).should('exist') + + cy.getByTestId('name-details', { timeout: 10000 }).within(container => { + cy.getByText('Add/Edit Record').click({ force: true }) + cy.wait(2000) + cy.queryByTestId('content-record-input-invalid') + }) + }) + it('can delete records', () => { cy.visit(`${NAME_ROOT}/notsoawesome.eth`) cy.getByTestId('name-details').within(container => { diff --git a/package.json b/package.json index 792bbe049..0b797220a 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,9 @@ "@toruslabs/torus-embed": "^1.8.6", "@walletconnect/web3-provider": "^1.3.1", "@ensdomains/address-encoder": "^0.2.6", - "@ensdomains/mock": "^2.0.34", + "@ensdomains/mock": "^2.0.36", "@ensdomains/react-ens-address": "^0.0.27", - "@ensdomains/ui": "^3.0.58", + "@ensdomains/ui": "^3.0.61", "apollo-cache-inmemory": "^1.2.9", "apollo-client": "^2.4.5", "apollo-link": "^1.2.2", diff --git a/src/api/manager/resolvers.js b/src/api/manager/resolvers.js index 5a2e159af..7e837ca7d 100644 --- a/src/api/manager/resolvers.js +++ b/src/api/manager/resolvers.js @@ -654,7 +654,7 @@ const resolvers = { records.content === '' ? emptyAddress : records.content - ? encodeContenthash(records.content) + ? encodeContenthash(records.content)?.encoded : undefined, records.textRecords, records.coins @@ -807,7 +807,8 @@ const resolvers = { provider }) const content = await resolverInstanceWithoutSigner.content(namehash) - return encodeContenthash('bzz://' + content) + const { encoded } = encodeContenthash('bzz://' + content) + return encoded } async function getContenthash(name) { diff --git a/src/components/Links/ContentHashLink.js b/src/components/Links/ContentHashLink.js index 638891df1..aedff8696 100644 --- a/src/components/Links/ContentHashLink.js +++ b/src/components/Links/ContentHashLink.js @@ -1,7 +1,7 @@ import React from 'react' import styled from '@emotion/styled/macro' import { ReactComponent as ExternalLinkIcon } from '../Icons/externalLink.svg' -import { decodeContenthash, encodeContenthash } from '@ensdomains/ui' +import { getProtocolType } from '@ensdomains/ui' const ContentHashLinkContainer = styled('a')` display: inline-block; @@ -22,22 +22,12 @@ const ContentHashLinkContainer = styled('a')` } ` -const DecodedError = styled('div')` - white-space: normal; - overflow: scroll; -` - const ContentHashLink = ({ value, contentType, domain }) => { - if (contentType === 'oldcontent') { + if (contentType === 'oldcontent' || !value) { return
{value}
} - - const encoded = encodeContenthash(value) - const { protocolType, decoded, error } = decodeContenthash(encoded) + const { protocolType, decoded } = getProtocolType(value) let externalLink, url - if (error) { - return {error} - } if (protocolType === 'ipfs') { externalLink = `https://dweb.link/ipfs/${decoded}` // using ipfs's secured origin gateway url = `ipfs://${decoded}` diff --git a/src/components/SingleName/ResolverAndRecords/ContentHash.js b/src/components/SingleName/ResolverAndRecords/ContentHash.js index 5e440b103..c34ccbe6e 100644 --- a/src/components/SingleName/ResolverAndRecords/ContentHash.js +++ b/src/components/SingleName/ResolverAndRecords/ContentHash.js @@ -239,7 +239,7 @@ const ContentHashEditable = ({ <> { const value = event.target.value setUpdatedRecords(records => ({ diff --git a/src/utils/records.js b/src/utils/records.js index 342759bd5..e267c5bd9 100644 --- a/src/utils/records.js +++ b/src/utils/records.js @@ -15,8 +15,8 @@ export function validateRecord({ type, value, contentType, selectedKey }) { return isAddress case 'content': if (value === EMPTY_ADDRESS) return true // delete record - const encoded = encodeContenthash(value) - if (encoded) { + const { encoded, error: encodeError } = encodeContenthash(value) + if (!encodeError && encoded) { return isValidContenthash(encoded) } else { return false diff --git a/yarn.lock b/yarn.lock index 9d7525180..3acbf721d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1385,6 +1385,15 @@ multicodec "^1.0.4" multihashes "^2.0.0" +"@ensdomains/content-hash@^2.5.5": + version "2.5.5" + resolved "https://registry.yarnpkg.com/@ensdomains/content-hash/-/content-hash-2.5.5.tgz#3efb64ced7bc8c76d883648519fdcaa312ad6ae9" + integrity sha512-g97tsnHku7fC+uyWAPj71TlLmgI2TsMtDEsiXAGvK73eC67aTVCsEagk6sPIZbB7+iKV3DY2wTQQos2VGBLMTw== + dependencies: + cids "^0.8.3" + multicodec "^1.0.4" + multihashes "^2.0.0" + "@ensdomains/contracts@0.0.1", "@ensdomains/contracts@^0.0.1": version "0.0.1" resolved "https://registry.yarnpkg.com/@ensdomains/contracts/-/contracts-0.0.1.tgz#edb841955adbd6f86bddaf9d05f6d239d25d5ab7" @@ -1429,6 +1438,24 @@ table "^5.4.6" web3 "^1.3.0" +"@ensdomains/mock@^2.0.36": + version "2.0.36" + resolved "https://registry.yarnpkg.com/@ensdomains/mock/-/mock-2.0.36.tgz#308eb17b86b58a68990a89a872d1ba249cac5d55" + integrity sha512-JNtXo4m9wfDL0SHFHbAPQbWVNEagLbNKq+UzHlUTx+OWa9wZK6wNwJFi63o2p0IQiTpQJs1zc5MC/HQATH76Vg== + dependencies: + "@0xproject/utils" "^2.0.2" + "@babel/runtime" "^7.4.4" + "@ensdomains/contracts" "^0.0.1" + "@ensdomains/dnssec-oracle-anchors" "^0.0.1" + chalk "^3.0.0" + cross-fetch "^3.0.2" + dns-packet "^5.2.1" + eth-ens-namehash "^2.0.8" + lodash "^4.17.11" + moment "^2.26.0" + table "^5.4.6" + web3 "^1.3.0" + "@ensdomains/react-ens-address@^0.0.27": version "0.0.27" resolved "https://registry.yarnpkg.com/@ensdomains/react-ens-address/-/react-ens-address-0.0.27.tgz#42ba9a4563ad60b146bdb2b0c260b2a1f86baa8b" @@ -1465,16 +1492,16 @@ lodash "^4.17.11" web3 "^1.3.0" -"@ensdomains/ui@^3.0.58": - version "3.0.58" - resolved "https://registry.yarnpkg.com/@ensdomains/ui/-/ui-3.0.58.tgz#b028b190f036c4151e771e2c74e91b8e279af006" - integrity sha512-EUWB2QtZQ/q8WFvk/MaxPiVB7EWaQktqTICmLYAI7MtTPSgOoxxAV/v0j2b5J+yeXzylYLavJSv9c6eHaw+JSw== +"@ensdomains/ui@^3.0.61": + version "3.0.61" + resolved "https://registry.yarnpkg.com/@ensdomains/ui/-/ui-3.0.61.tgz#8263cce026eb4496b44618de843fac42ab0fbdaa" + integrity sha512-QrweOs7dfjX0h0DG1kybm+lMEBEt2da6R9JnPxvaYLSVesN0ikT3CWwum0WopJw8p7d7D/1T4+gkHGD/o7vxkA== dependencies: "@0xproject/utils" "^2.0.2" "@babel/plugin-proposal-class-properties" "^7.8.3" "@babel/runtime" "^7.4.4" "@ensdomains/address-encoder" "^0.2.5" - "@ensdomains/content-hash" "^2.5.3" + "@ensdomains/content-hash" "^2.5.5" "@ensdomains/contracts" "^0.0.1" "@ensdomains/dnsprovejs" "^0.2.0" "@ensdomains/mock" "^2.0.34"