mirror of https://github.com/embarklabs/embark.git
fix(@embark/ens): use namehash for resolver
This commit is contained in:
parent
3df7f81732
commit
4d079de1f4
|
@ -95,7 +95,6 @@ response:
|
||||||
* embarkjs.utils
|
* embarkjs.utils
|
||||||
* secureSend
|
* secureSend
|
||||||
* embark utils
|
* embark utils
|
||||||
* soliditySha3
|
|
||||||
* ZERO_ADDRESS
|
* ZERO_ADDRESS
|
||||||
* hashTo32ByteHexString
|
* hashTo32ByteHexString
|
||||||
* joinPath
|
* joinPath
|
||||||
|
|
|
@ -48,12 +48,13 @@ function registerSubDomain(web3, ens, registrar, resolver, defaultAccount, subdo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function lookupAddress(address, ens, soliditySha3, createResolverContract, callback) {
|
function lookupAddress(address, ens, _namehash, createResolverContract, callback) {
|
||||||
|
_namehash = _namehash || namehash;
|
||||||
if (address.startsWith("0x")) {
|
if (address.startsWith("0x")) {
|
||||||
address = address.slice(2);
|
address = address.slice(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
let node = soliditySha3(address.toLowerCase() + reverseAddressSuffix);
|
let node = _namehash.hash(address.toLowerCase() + reverseAddressSuffix);
|
||||||
|
|
||||||
function cb(err, name) {
|
function cb(err, name) {
|
||||||
if (err === NoDecodeStringErr || err === NoDecodeAddrErr) {
|
if (err === NoDecodeStringErr || err === NoDecodeAddrErr) {
|
||||||
|
|
|
@ -235,7 +235,7 @@ __embarkENS.lookup = function (address, callback) {
|
||||||
address = address.slice(2);
|
address = address.slice(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
let node = Web3.utils.soliditySha3(address.toLowerCase() + reverseAddrSuffix);
|
let node = namehash.hash(address.toLowerCase() + reverseAddrSuffix);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resolverAddress = await this.ens.methods.resolver(node).call();
|
const resolverAddress = await this.ens.methods.resolver(node).call();
|
||||||
|
@ -292,7 +292,7 @@ __embarkENS.registerSubDomain = function (name, address, callback) {
|
||||||
EmbarkJS.Blockchain.blockchainConnector.getDefaultAccount(),
|
EmbarkJS.Blockchain.blockchainConnector.getDefaultAccount(),
|
||||||
name,
|
name,
|
||||||
this.registration.rootDomain,
|
this.registration.rootDomain,
|
||||||
Web3.utils.soliditySha3(address.toLowerCase().substr(2) + reverseAddrSuffix),
|
namehash.hash(address.toLowerCase().substr(2) + reverseAddrSuffix),
|
||||||
address,
|
address,
|
||||||
console,
|
console,
|
||||||
EmbarkJS.Utils.secureSend,
|
EmbarkJS.Utils.secureSend,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { __ } from 'embark-i18n';
|
import { __ } from 'embark-i18n';
|
||||||
import {joinPath, hashTo32ByteHexString, soliditySha3, recursiveMerge, AddressUtils} from 'embark-utils';
|
import {joinPath, hashTo32ByteHexString, recursiveMerge, AddressUtils} from 'embark-utils';
|
||||||
const namehash = require('eth-ens-namehash');
|
const namehash = require('eth-ens-namehash');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const ENSFunctions = require('./ENSFunctions');
|
const ENSFunctions = require('./ENSFunctions');
|
||||||
|
@ -287,7 +287,7 @@ class ENS {
|
||||||
return callback(error);
|
return callback(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const reverseNode = soliditySha3(address.toLowerCase().substr(2) + reverseAddrSuffix);
|
const reverseNode = namehash.hash(address.toLowerCase().substr(2) + reverseAddrSuffix);
|
||||||
this.registerSubDomain(defaultAccount, subDomainName, reverseNode, address, secureSend, callback);
|
this.registerSubDomain(defaultAccount, subDomainName, reverseNode, address, secureSend, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ class ENS {
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (callback) {
|
function (callback) {
|
||||||
ENSFunctions.lookupAddress(req.query.address, self.ensContract, soliditySha3, createInternalResolverContract.bind(self), callback);
|
ENSFunctions.lookupAddress(req.query.address, self.ensContract, namehash, createInternalResolverContract.bind(self), callback);
|
||||||
}
|
}
|
||||||
], function (error, name) {
|
], function (error, name) {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -498,7 +498,7 @@ class ENS {
|
||||||
const web3 = result[3];
|
const web3 = result[3];
|
||||||
|
|
||||||
const rootNode = namehash.hash(self.registration.rootDomain);
|
const rootNode = namehash.hash(self.registration.rootDomain);
|
||||||
var reverseNode = soliditySha3(web3.eth.defaultAccount.toLowerCase().substr(2) + reverseAddrSuffix);
|
var reverseNode = namehash.hash(web3.eth.defaultAccount.toLowerCase().substr(2) + reverseAddrSuffix);
|
||||||
const owner = await self.ensContract.methods.owner(rootNode).call();
|
const owner = await self.ensContract.methods.owner(rootNode).call();
|
||||||
|
|
||||||
if (owner === web3.eth.defaultAccount) {
|
if (owner === web3.eth.defaultAccount) {
|
||||||
|
|
Loading…
Reference in New Issue