Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Add getContent
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflau committed Sep 23, 2020
1 parent 6992798 commit 88a4d85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
4 changes: 0 additions & 4 deletions src/__tests__/__snapshots__/ens.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Blockchain tests Helper functions getDomainDetails gets rootdomain and resolver details 1`] = `"ipfs://QmTeW79w7QQ6Npa3b1d5tANreCDxF2iDaAPsDvW6KtLmfB"`;

exports[`Blockchain tests Resolver getContent returns a 32 byte hash 1`] = `"0x736f6d65436f6e74656e74000000000000000000000000000000000000000000"`;

exports[`Blockchain tests Resolver setContent sets 32 byte hash 1`] = `"0xd1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162"`;
26 changes: 5 additions & 21 deletions src/__tests__/ens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,11 @@ describe('Blockchain tests', () => {
expect(addr).toBe('0x0000000000000000000000000000000000012345')
})

// test('setAddr sets an eth address', async () => {
// //reverts if no addr is present
// const resolverAddr = await ens.getAddress('resolver.eth')
// const tx = await ens.setResolver('superawesome.eth', resolverAddr)
// await tx.wait()
// const tx2 = await ens.setAddr(
// 'superawesome.eth',
// 'ETH',
// '0x0000000000000000000000000000000000012345'
// )
// await tx2.wait()
// const addr = await ens.getAddr('superawesome.eth', 'ETH')
// expect(addr).toBe('0x0000000000000000000000000000000000012345')
// })

// test('getContent returns a 32 byte hash', async () => {
// const content = await ens.name('oldresolver.eth').getContent()
// expect(content.contentType).toBe('oldcontent')
// expect(content.value).toBeHex()
// expect(content.value).toMatchSnapshot()
// })
test('getContent returns a 32 byte hash', async () => {
const content = await ens.name('oldresolver.eth').getContent()
expect(content.value).toBeHex()
expect(content.value).toMatchSnapshot()
})

// // old content resolver isn't on new registrar

Expand Down
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { abi as ensContract } from '@ensdomains/ens/build/contracts/ENS.json'
import { abi as resolverContract } from '@ensdomains/resolver/build/contracts/Resolver.json'

import { emptyAddress, namehash, labelhash } from './utils'
import {
isValidContenthash,
encodeContenthash,
decodeContenthash,
} from './utils/contents'
const utils = ethers.utils

let registries = {
1: '0x314159265dd8dbb310642f98f50c066173c1259b',
Expand Down Expand Up @@ -91,10 +97,9 @@ class Name {
return emptyAddress
}
try {
const provider = await getProvider()
const Resolver = getResolverContract({
address: resolverAddr,
provider,
provider: this.provider,
})
const contentHashSignature = utils
.solidityKeccak256(['string'], ['contenthash(bytes32)'])
Expand All @@ -109,6 +114,7 @@ class Name {
await Resolver.contenthash(this.namehash)
)
if (error) {
console.log('error decoding', error)
return {
value: emptyAddress,
contentType: 'contenthash',
Expand Down

0 comments on commit 88a4d85

Please sign in to comment.