Skip to content

Commit d4af5b5

Browse files
author
Micah Zoltu
committed
Removes ethereumjs-util and keccak dependencies.
Replaces both with `js-sha3`. `ethereumjs-util` and `keccak` NPM packages both have native bindings in their dependency tree which means they depend on node-gyp along the way. `js-sha3` on the other hand is a native implementation of the sha3 family of hashing functions, which relieves a number of `node-gyp` and native binding related issues.
1 parent b1a098a commit d4af5b5

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

downloadCurrentVersion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var pkg = require('./package.json');
77
var fs = require('fs');
88
var https = require('https');
99
var MemoryStream = require('memorystream');
10-
var ethJSUtil = require('ethereumjs-util');
10+
var keccak256 = require('js-sha3').keccak256;
1111

1212
function getVersionList (cb) {
1313
console.log('Retrieving available version list...');
@@ -48,7 +48,7 @@ function downloadBinary (outputName, version, expectedHash) {
4848
response.pipe(file);
4949
file.on('finish', function () {
5050
file.close(function () {
51-
var hash = '0x' + ethJSUtil.sha3(fs.readFileSync(outputName, { encoding: 'binary' })).toString('hex');
51+
var hash = '0x' + keccak256(fs.readFileSync(outputName, { encoding: 'binary' }));
5252
if (expectedHash !== hash) {
5353
console.log('Hash mismatch: ' + expectedHash + ' vs ' + hash);
5454
process.exit(1);

linker.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
var keccak = require('keccak');
2-
3-
function keccak256 (input) {
4-
return keccak('keccak256').update(input).digest();
5-
}
1+
var keccak256 = require('js-sha3').keccak256;
62

73
function libraryHashPlaceholder (input) {
8-
return '$' + keccak256(input).toString('hex').slice(0, 34) + '$';
4+
return '$' + keccak256(input).slice(0, 34) + '$';
95
}
106

117
var linkBytecode = function (bytecode, libraries) {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,15 @@
4343
"dependencies": {
4444
"command-exists": "^1.2.8",
4545
"fs-extra": "^0.30.0",
46-
"keccak": "^1.0.2",
4746
"memorystream": "^0.3.1",
4847
"require-from-string": "^2.0.0",
4948
"semver": "^5.5.0",
49+
"js-sha3": "0.8.0",
5050
"tmp": "0.0.33",
5151
"yargs": "^11.0.0"
5252
},
5353
"devDependencies": {
5454
"coveralls": "^3.0.0",
55-
"ethereumjs-util": "^5.2.0",
5655
"istanbul": "^0.4.5",
5756
"semistandard": "^12.0.0",
5857
"tape": "=4.9.2",

0 commit comments

Comments
 (0)