From 0fb51da18c0309df5f7e82105dd214fe5a668246 Mon Sep 17 00:00:00 2001 From: Ryan Ghods Date: Tue, 9 Jun 2020 20:43:18 -0700 Subject: [PATCH] upgrade to ethereumjs-util v7.0.2 --- lib/rpc/modules/web3.js | 4 ++-- lib/util/parse.js | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rpc/modules/web3.js b/lib/rpc/modules/web3.js index 02e903d..c170525 100644 --- a/lib/rpc/modules/web3.js +++ b/lib/rpc/modules/web3.js @@ -1,7 +1,7 @@ 'use strict' const { middleware, validators } = require('../validation') -const { addHexPrefix, keccak256 } = require('ethereumjs-util') +const { addHexPrefix, keccak, toBuffer } = require('ethereumjs-util') const { platform } = require('os') /** @@ -45,7 +45,7 @@ class Web3 { */ sha3 (params, cb) { try { - const rawDigest = keccak256(params[0]) + const rawDigest = keccak(toBuffer(params[0])) const hexEncodedDigest = addHexPrefix(rawDigest.toString('hex')) cb(null, hexEncodedDigest) } catch (err) { diff --git a/lib/util/parse.js b/lib/util/parse.js index f28999f..0feef67 100644 --- a/lib/util/parse.js +++ b/lib/util/parse.js @@ -48,7 +48,7 @@ async function parseStorage (storage) { const promises = [] for (let [address, value] of Object.entries(storage)) { address = toBuffer(address) - value = util.rlp.encode(util.unpad(toBuffer(value))) + value = util.rlp.encode(util.unpadBuffer(toBuffer(value))) promises.push(new Promise((resolve, reject) => { trie.put(address, value, (err) => { if (err) return reject(err) @@ -70,7 +70,7 @@ async function parseGethState (alloc) { account.balance = new util.BN(value.balance.slice(2), 16) } if (value.code) { - account.codeHash = util.keccak(value.code) + account.codeHash = util.keccak(util.toBuffer(value.code)) } if (value.storage) { account.stateRoot = (await parseStorage(value.storage)).root diff --git a/package.json b/package.json index d29886d..b1f954c 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "ethereumjs-blockchain": "^3.4.0", "ethereumjs-common": "^1.5.1", "ethereumjs-devp2p": "^2.5.1", - "ethereumjs-util": "^6.1.0", + "ethereumjs-util": "^7.0.2", "fs-extra": "^7.0.1", "jayson": "^2.0.6", "level": "^6.0.1",