1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

renaming registrar into registry

This commit is contained in:
pldespaigne 2019-04-04 14:07:24 +02:00
parent cf4eac3f2c
commit b26a59dbbe
2 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@ const namehash = require('eth-ens-namehash')
const multihash = require('multihashes') const multihash = require('multihashes')
const Eth = require('ethjs-query') const Eth = require('ethjs-query')
const EthContract = require('ethjs-contract') const EthContract = require('ethjs-contract')
const registrarAbi = require('./contracts/registrar') const registryAbi = require('./contracts/registry')
const resolverAbi = require('./contracts/resolver') const resolverAbi = require('./contracts/resolver')
module.exports = resolveEnsToIpfsContentId module.exports = resolveEnsToIpfsContentId
@ -12,15 +12,15 @@ async function resolveEnsToIpfsContentId ({ provider, name }) {
const eth = new Eth(provider) const eth = new Eth(provider)
const hash = namehash.hash(name) const hash = namehash.hash(name)
const contract = new EthContract(eth) const contract = new EthContract(eth)
// lookup registrar // lookup registry
const chainId = Number.parseInt(await eth.net_version(), 10) const chainId = Number.parseInt(await eth.net_version(), 10)
const registrarAddress = getRegistrarForChainId(chainId) const registryAddress = getRegistryForChainId(chainId)
if (!registrarAddress) { if (!registryAddress) {
throw new Error(`EnsIpfsResolver - no known ens-ipfs registrar for chainId "${chainId}"`) throw new Error(`EnsIpfsResolver - no known ens-ipfs registry for chainId "${chainId}"`)
} }
const Registrar = contract(registrarAbi).at(registrarAddress) const Registry = contract(registryAbi).at(registryAddress)
// lookup resolver // lookup resolver
const resolverLookupResult = await Registrar.resolver(hash) const resolverLookupResult = await Registry.resolver(hash)
const resolverAddress = resolverLookupResult[0] const resolverAddress = resolverLookupResult[0]
if (hexValueIsEmpty(resolverAddress)) { if (hexValueIsEmpty(resolverAddress)) {
throw new Error(`EnsIpfsResolver - no resolver found for name "${name}"`) throw new Error(`EnsIpfsResolver - no resolver found for name "${name}"`)
@ -42,7 +42,7 @@ function hexValueIsEmpty (value) {
return [undefined, null, '0x', '0x0', '0x0000000000000000000000000000000000000000000000000000000000000000'].includes(value) return [undefined, null, '0x', '0x0', '0x0000000000000000000000000000000000000000000000000000000000000000'].includes(value)
} }
function getRegistrarForChainId (chainId) { function getRegistryForChainId (chainId) {
switch (chainId) { switch (chainId) {
// mainnet // mainnet
case 1: case 1: