fix(@embark/ens): use namehash for resolver

This commit is contained in:
Ricardo Guilherme Schmidt 2019-05-20 11:05:52 -03:00 committed by Pascal Precht
parent 3df7f81732
commit 4d079de1f4
4 changed files with 9 additions and 9 deletions

View File

@ -95,7 +95,6 @@ response:
* embarkjs.utils
* secureSend
* embark utils
* soliditySha3
* ZERO_ADDRESS
* hashTo32ByteHexString
* joinPath

View File

@ -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")) {
address = address.slice(2);
}
let node = soliditySha3(address.toLowerCase() + reverseAddressSuffix);
let node = _namehash.hash(address.toLowerCase() + reverseAddressSuffix);
function cb(err, name) {
if (err === NoDecodeStringErr || err === NoDecodeAddrErr) {

View File

@ -235,7 +235,7 @@ __embarkENS.lookup = function (address, callback) {
address = address.slice(2);
}
let node = Web3.utils.soliditySha3(address.toLowerCase() + reverseAddrSuffix);
let node = namehash.hash(address.toLowerCase() + reverseAddrSuffix);
try {
const resolverAddress = await this.ens.methods.resolver(node).call();
@ -292,7 +292,7 @@ __embarkENS.registerSubDomain = function (name, address, callback) {
EmbarkJS.Blockchain.blockchainConnector.getDefaultAccount(),
name,
this.registration.rootDomain,
Web3.utils.soliditySha3(address.toLowerCase().substr(2) + reverseAddrSuffix),
namehash.hash(address.toLowerCase().substr(2) + reverseAddrSuffix),
address,
console,
EmbarkJS.Utils.secureSend,

View File

@ -1,5 +1,5 @@
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 async = require('async');
const ENSFunctions = require('./ENSFunctions');
@ -287,7 +287,7 @@ class ENS {
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);
});
}
@ -338,7 +338,7 @@ class ENS {
(req, res) => {
async.waterfall([
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) {
if (error) {
@ -498,7 +498,7 @@ class ENS {
const web3 = result[3];
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();
if (owner === web3.eth.defaultAccount) {