mirror of https://github.com/embarklabs/embark.git
refactor (@embark/embark-utils): move soliditySha3 to embark-utils
This commit is contained in:
parent
7511e3c113
commit
04f187cfb9
|
@ -47,7 +47,8 @@
|
|||
"dependencies": {
|
||||
"@babel/runtime-corejs2": "7.3.1",
|
||||
"follow-redirects": "1.5.7",
|
||||
"multihashes": "0.4.14"
|
||||
"multihashes": "0.4.14",
|
||||
"web3": "1.0.0-beta.37"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.2.3",
|
||||
|
|
|
@ -33,6 +33,11 @@ function hashTo32ByteHexString(hash) {
|
|||
return '0x' + multihash.toHexString(digest);
|
||||
}
|
||||
|
||||
function soliditySha3(arg) {
|
||||
const Web3 = require('web3');
|
||||
return Web3.utils.soliditySha3(arg);
|
||||
}
|
||||
|
||||
const Utils = {
|
||||
joinPath: function() {
|
||||
const path = require('path');
|
||||
|
@ -46,7 +51,8 @@ const Utils = {
|
|||
checkIsAvailable,
|
||||
findNextPort,
|
||||
hashTo32ByteHexString,
|
||||
isHex
|
||||
isHex,
|
||||
soliditySha3
|
||||
};
|
||||
|
||||
module.exports = Utils;
|
||||
|
|
|
@ -48,12 +48,12 @@ function registerSubDomain(web3, ens, registrar, resolver, defaultAccount, subdo
|
|||
});
|
||||
}
|
||||
|
||||
function lookupAddress(address, ens, utils, createResolverContract, callback) {
|
||||
function lookupAddress(address, ens, soliditySha3, createResolverContract, callback) {
|
||||
if (address.startsWith("0x")) {
|
||||
address = address.slice(2);
|
||||
}
|
||||
|
||||
let node = utils.soliditySha3(address.toLowerCase() + reverseAddressSuffix);
|
||||
let node = soliditySha3(address.toLowerCase() + reverseAddressSuffix);
|
||||
|
||||
function cb(err, name) {
|
||||
if (err === NoDecodeStringErr || err === NoDecodeAddrErr) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {joinPath, hashTo32ByteHexString} from 'embark-utils';
|
||||
import {joinPath, hashTo32ByteHexString, soliditySha3} from 'embark-utils';
|
||||
const utils = require('../../utils/utils.js');
|
||||
const namehash = require('eth-ens-namehash');
|
||||
const async = require('async');
|
||||
|
@ -287,7 +287,7 @@ class ENS {
|
|||
return callback(error);
|
||||
}
|
||||
|
||||
const reverseNode = utils.soliditySha3(address.toLowerCase().substr(2) + reverseAddrSuffix);
|
||||
const reverseNode = soliditySha3(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, utils, createInternalResolverContract.bind(self), callback);
|
||||
ENSFunctions.lookupAddress(req.query.address, self.ensContract, soliditySha3, 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 = web3.utils.soliditySha3(web3.eth.defaultAccount.toLowerCase().substr(2) + reverseAddrSuffix);
|
||||
var reverseNode = soliditySha3(web3.eth.defaultAccount.toLowerCase().substr(2) + reverseAddrSuffix);
|
||||
const owner = await self.ensContract.methods.owner(rootNode).call();
|
||||
|
||||
if (owner === web3.eth.defaultAccount) {
|
||||
|
|
|
@ -365,11 +365,6 @@ function sha512(arg) {
|
|||
return hash.update(arg).digest('hex');
|
||||
}
|
||||
|
||||
function soliditySha3(arg) {
|
||||
const Web3 = require('web3');
|
||||
return Web3.utils.soliditySha3(arg);
|
||||
}
|
||||
|
||||
function normalizeInput(input) {
|
||||
if(typeof input === 'string') return input;
|
||||
let args = Object.values(input);
|
||||
|
@ -635,7 +630,6 @@ module.exports = {
|
|||
toChecksumAddress,
|
||||
sha3,
|
||||
sha512,
|
||||
soliditySha3,
|
||||
normalizeInput,
|
||||
buildUrl,
|
||||
buildUrlFromConfig,
|
||||
|
|
Loading…
Reference in New Issue