Skip to content

Commit

Permalink
Merge pull request #592 from ensdomains/dev
Browse files Browse the repository at this point in the history
Deploy to live
  • Loading branch information
makoto committed Feb 18, 2020
2 parents 49c6b80 + fc635ed commit 2eadace
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: 'Test'
install:
- yarn
- yarn global add cypress
- yarn global add cypress@3.5.0
- cypress install
- yarn global add ganache-cli@6.1.8
- yarn global add wait-on
Expand Down
23 changes: 0 additions & 23 deletions cypress/integration/nameDetail.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,29 +350,6 @@ describe('Name detail view', () => {
})
})

// it('can set old content', () => {
// const content =
// '0xd1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162'

// cy.visit(`${NAME_ROOT}/oldresolver.eth`)

// cy.getByTestId('name-details').within(container => {
// cy.getByTestId('edit-content', { exact: false }).click({ force: true })
// cy.getByPlaceholderText('Enter a content', {
// exact: false
// }).type(content, { force: true })
// waitUntilInputResolves('Save').then(() => {
// cy.getByText('Save').click({ force: true })

// //form closed
// waitUntilTestIdDoesNotExist('action')
// waitUntilTestIdDoesNotExist('cancel')
// //Value updated
// cy.queryByText(content, { exact: false }).should('exist')
// })
// })
// })

it('can delete records', () => {
cy.visit(`${NAME_ROOT}/notsoawesome.eth`)
cy.getByTestId('name-details').within(container => {
Expand Down
17 changes: 17 additions & 0 deletions cypress/integration/resolverMigration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DISABLED_COLOUR = 'rgb(223, 223, 223)'
describe('Migrate resolver and records', () => {
it('can visit a name with an old resolver and migrate it', () => {
cy.visit(`${ROOT}/name/abittooawesome2.eth`)
cy.wait(3000)
cy.getByText('Migrate').click({ force: true })
cy.queryByText('migrate', { timeout: 50 }).should('not.exist')
cy.wait(1000)
Expand All @@ -16,6 +17,22 @@ describe('Migrate resolver and records', () => {
)
})

it('can visit a name with an old content resolver and migrate it as swarm contenthash', () => {
cy.visit(`${ROOT}/name/oldresolver.eth`)
cy.wait(3000) // this one took a while to render Migrate
cy.getByText('Migrate').click({ force: true })
cy.queryByText('migrate', { timeout: 50 }).should('not.exist')
cy.wait(1000)
cy.queryByTestId('edit-resolver').should(
'have.css',
'background-color',
ENABLED_COLOUR
)
cy.queryByText('bzz://', {
exact: false
}).should('exist')
})

it('cannot migrate resolver if the parent domain is not migrateed', () => {
cy.visit(`${ROOT}/name/a1.sub2.testing.eth`)
cy.wait(1000)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@ensdomains/ethregistrar": "^2.0.0",
"@ensdomains/react-ens-address": "0.0.17",
"@ensdomains/resolver": "^0.2.4",
"@ensdomains/ui": "2.0.11",
"@ensdomains/ui": "2.0.12",
"apollo-cache-inmemory": "^1.2.9",
"apollo-client": "^2.4.5",
"apollo-link": "^1.2.2",
Expand Down Expand Up @@ -92,7 +92,7 @@
}
},
"devDependencies": {
"@ensdomains/mock": "2.0.6",
"@ensdomains/mock": "2.0.7",
"apollo-client-mock": "0.0.8",
"babel-plugin-macros": "^2.4.2",
"cypress": "^3.5.0",
Expand Down
7 changes: 3 additions & 4 deletions src/api/manager/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import {
encodeContenthash,
getResolverContract,
getOldResolverContract,
getNamehash,
getProvider
getNamehash
} from '@ensdomains/ui'
import { formatsByName } from '@ensdomains/address-encoder'
import isEqual from 'lodash/isEqual'
Expand Down Expand Up @@ -544,8 +543,8 @@ const resolvers = {
'0xbf80bc10d6ebfee11bea9a157d762110a0b73d95'
]
const localResolvers =
process.env.REACT_APP_DEPRECATED_RESOLVERS &&
process.env.REACT_APP_DEPRECATED_RESOLVERS.split(',')
process.env.REACT_APP_OLD_CONTENT_RESOLVERS &&
process.env.REACT_APP_OLD_CONTENT_RESOLVERS.split(',')

const oldResolvers = [...oldContentResolvers, ...localResolvers].map(
a => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchErrors/SearchErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const errorData = {
.split('.')
.splice(-1, 1)} is not currently a support tld.`,
long: searchTerm =>
`We currently only support .eth and .xyz domains. Support for future domains are planned in the future`
`We currently only support .eth, .xyz and .art domains. Support for future domains are planned in the future`
},
tooShort: {
short: searchTerm => (
Expand Down
131 changes: 131 additions & 0 deletions src/components/SingleName/ResolverAndRecords/ArtRecords.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import React from 'react'
import { Query } from 'react-apollo'
import styled from '@emotion/styled'

import Loader from '../../Loader'

import {
RecordsContent,
RecordsItem,
RecordsKey,
RecordsValue
} from './RecordsItem'

const Records = styled('div')`
border-radius: 6px;
border: 1px solid #ededed;
box-shadow: inset 0 0 10px 0 rgba(235, 235, 235, 0.5);
padding-bottom: 10px;
display: block;
margin-bottom: 20px;
`

const RecordsHeader = styled('div')`
background: #f0f6fa;
`

const RecordsTitle = styled('h3')`
font-family: Overpass;
font-weight: 700;
font-size: 12px;
color: #adbbcd;
letter-spacing: 0.5px;
text-transform: uppercase;
margin: 0;
padding: 10px 20px;
display: flex;
align-items: center;
justify-content: space-between;
`

function isArt(name) {
return !!name.match(/\.art$/)
}

function getArtRecordLabel(key) {
const recordLabels = {
title: 'Title',
maker: 'Maker',
type: 'Type of Object',
subject: 'Subject',
period: 'Period',
dimensions: 'Measurements',
materials: 'Materials & Techniques',
markings: 'Inscriptions & Markings',
features: 'Features',
reference: 'Reference'
}

return recordLabels[key]
}

function isEmpty(records) {
if (!records.length) {
return true
}

return records.filter(record => record.value).length === 0
}

function decodeRecords(values) {
let parsed = {}
try {
parsed = JSON.parse(values)
} catch (e) {}

return Object.keys(parsed).reduce(
(decoded, key) =>
decoded.concat({
label: getArtRecordLabel(key),
value: parsed[key]
}),
[]
)
}

function ArtRecordItem({ value, label }) {
if (!value) return null

return (
<RecordsItem>
<RecordsContent>
<RecordsKey>{label}</RecordsKey>
<RecordsValue>
<div>{value}</div>
</RecordsValue>
</RecordsContent>
</RecordsItem>
)
}

export default function ArtRecords({ domain, query }) {
if (!isArt(domain.name)) return null

return (
<Query query={query} variables={{ name: domain.name, key: 'artrecords' }}>
{({ loading, data }) => {
if (loading) return <Loader center />

const { getText: encodedArtRecords } = data

if (!encodedArtRecords) return null

const records = decodeRecords(encodedArtRecords)

if (isEmpty(records)) return null

return (
<Records>
<RecordsHeader>
<RecordsTitle>Art records</RecordsTitle>
</RecordsHeader>

{records.map((r, i) => (
<ArtRecordItem key={i} value={r.value} label={r.label} />
))}
</Records>
)
}}
</Query>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import RecordsItem from './RecordsItem'
import TextRecord from './TextRecord'
import Address from './Address'
import ResolverMigration from './ResolverMigration'
import ArtRecords from './ArtRecords'

const RecordsWrapper = styled('div')`
border-radius: 6px;
Expand Down Expand Up @@ -304,6 +305,8 @@ export default function ResolverAndRecords({
duringMigration={duringMigration}
/>
)}

{hasResolver && <ArtRecords domain={domain} query={GET_TEXT} />}
</>
)
}
3 changes: 3 additions & 0 deletions src/constants/tlds.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
},
"luxe": {
"supported": true
},
"art": {
"supported": true
}
}
7 changes: 5 additions & 2 deletions src/routes/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ export default props => (
<Announcement>
<h3>
<img src={warning} alt="warning" />
&nbsp; ENS Registry Migration: Bug Fix, New Features&nbsp;
<a href="https://medium.com/p/64379193a5a/edit">(Find out more)</a>
&nbsp; ENS Registry Migration Is Over… Now What? A Few Things to
Know&nbsp;
<a href="https://medium.com/the-ethereum-name-service/ens-registry-migration-is-over-now-what-a-few-things-to-know-fb05f921872a">
(Find out more)
</a>
</h3>
</Announcement>
<Explanation>
Expand Down
16 changes: 15 additions & 1 deletion src/testing-utils/preTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ async function init() {

const addresses = await deployTestEns({ web3, accounts, dnssec, migrate })
console.log(addresses)
const { ensAddress, oldResolverAddresses } = addresses
const {
ensAddress,
oldResolverAddresses,
oldContentResolverAddresses
} = addresses
const envLocalFile = './.env.local'
fs.writeFileSync('./cypress.env.json', JSON.stringify(addresses))
fs.writeFileSync(envLocalFile, `REACT_APP_ENS_ADDRESS=${ensAddress}`)
Expand All @@ -53,11 +57,21 @@ async function init() {
envLocalFile,
`REACT_APP_DEPRECATED_RESOLVERS=${oldResolverAddresses.join(',')}`
)
fs.appendFileSync(envLocalFile, '\n')
fs.appendFileSync(
envLocalFile,
`REACT_APP_OLD_CONTENT_RESOLVERS=${oldContentResolverAddresses.join(',')}`
)
console.log(
`Successfully wrote Old resolver address ${oldResolverAddresses.join(
','
)} to .env.local`
)
console.log(
`Successfully wrote Old content resolver address ${oldContentResolverAddresses.join(
','
)} to .env.local`
)
}

init()
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1337,10 +1337,10 @@
truffle "^5.0.5"
web3-utils "^1.0.0-beta.48"

"@ensdomains/mock@2.0.6":
version "2.0.6"
resolved "https://registry.yarnpkg.com/@ensdomains/mock/-/mock-2.0.6.tgz#af8bc795c6d313efe4d8145b29d9c185f833b4e9"
integrity sha512-a74vfJHCWsTmal2dOAEiS7Mb1gZvob/7EmdpZjWXk+8XwFVIHsz2rXf8d//p/FN1T/Tct8XdJQrd1vXl9GEyTw==
"@ensdomains/mock@2.0.7":
version "2.0.7"
resolved "https://registry.yarnpkg.com/@ensdomains/mock/-/mock-2.0.7.tgz#657b14635473bbb2c312d8edf781a327b7190aa8"
integrity sha512-f8GiV/iQTBgax/6kHsErhbTzs/TD9uFEDmVDHrqEjB1yP0zlaMzhH+SIlO2mz7zHoEMzoey+R+qYBXE+IEDYNg==
dependencies:
"@0xproject/utils" "^2.0.2"
"@babel/runtime" "^7.4.4"
Expand Down Expand Up @@ -1415,10 +1415,10 @@
truffle-default-builder "^2.0.0"
underscore "^1.8.3"

"@ensdomains/ui@2.0.11":
version "2.0.11"
resolved "https://registry.yarnpkg.com/@ensdomains/ui/-/ui-2.0.11.tgz#9c1b2e3a564e00be99f44cdff12d595dfa34d4c9"
integrity sha512-96o5uVU+R+2/LkOkNlrs07YVFsoTivXNJaf3S5O7i/GvESntnFibRsqG4BtGj8XwMWwafjES7UcMI1Aw9gWzYw==
"@ensdomains/ui@2.0.12":
version "2.0.12"
resolved "https://registry.yarnpkg.com/@ensdomains/ui/-/ui-2.0.12.tgz#3b63ef5642596aafc0b00eae3200dceacd4d476c"
integrity sha512-u6keOxldv/gU0w2/NHSTDWfeiBH7lMNBKTCCZq32bdLOgj11yvvXfvoaiPY85nxw+YJUYjUL7Nmpk+ZGdBiP+Q==
dependencies:
"@0xproject/utils" "^2.0.2"
"@babel/runtime" "^7.4.4"
Expand Down

0 comments on commit 2eadace

Please sign in to comment.