Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
[v16] bump ethereum-related dependencies (#477)
Browse files Browse the repository at this point in the history
* deps: eth-json-rpc-middleware@^6.0.0->^8.1.0
* deps: eth-rpc-errors@^3.0.0->^4.0.3
* deps: update ethereumjs packages
* deps: eth-json-rpc-filters@^4.2.1->~5.0.0
* deps: eth-json-rpc-infura@^5.1.0 -> @metamask/eth-json-rpc-infura@^6.0.0
* deps: eth-sig-util@^1.4.2 -> @metamask/eth-sig-util@^4.0.1
* fix ethereumjs-abi resolution from github to registry
    - the github.com version comes from devDependency ganache-core -
    resolution only relevant for build/dev
* devDeps: ganache-core@^2.7.0->^2.13.2 -> [email protected]
* chore: securitry-related package lockbumps
  • Loading branch information
legobeat authored Apr 22, 2024
1 parent 059471b commit 277e195
Show file tree
Hide file tree
Showing 11 changed files with 1,619 additions and 4,648 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
"license": "MIT",
"resolutions": {
"@cypress/request/qs": "6.10.4",
"ganache-core/**/elliptic": "^6.5.2"
"ethereumjs-abi": "npm:[email protected]"
},
"dependencies": {
"@cypress/request": "^3.0.0",
"@ethereumjs/tx": "^3.3.0",
"@metamask/eth-json-rpc-infura": "^6.0.0",
"@metamask/eth-sig-util": "^4.0.1",
"async": "^2.5.0",
"backoff": "^2.5.0",
"clone": "^2.0.0",
"eth-block-tracker": "^5.0.1",
"eth-json-rpc-filters": "^4.2.1",
"eth-json-rpc-infura": "^5.1.0",
"eth-json-rpc-middleware": "^6.0.0",
"eth-rpc-errors": "^3.0.0",
"eth-sig-util": "^1.4.2",
"ethereumjs-block": "^1.2.2",
"ethereumjs-util": "^5.1.5",
"ethereumjs-vm": "^2.3.4",
"eth-json-rpc-filters": "~5.0.0",
"eth-json-rpc-middleware": "^8.1.0",
"eth-rpc-errors": "^4.0.3",
"ethereumjs-block": "^2.2.2",
"ethereumjs-util": "^7.1.5",
"ethereumjs-vm": "^2.6.0",
"json-stable-stringify": "^1.0.1",
"promise-to-callback": "^1.0.0",
"readable-stream": "^2.2.9",
Expand All @@ -58,7 +58,7 @@
"browserify": "^16.5.0",
"eslint": "^6.2.0",
"ethjs": "^0.3.6",
"ganache-core": "^2.7.0",
"ganache-cli": "6.12.2",
"tape": "^4.4.0"
},
"browser": {
Expand Down
2 changes: 1 addition & 1 deletion subproviders/cache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ProviderSubprovider = require('./json-rpc-engine-middleware')
const createBlockCacheMiddleware = require('eth-json-rpc-middleware/block-cache')
const { createBlockCacheMiddleware } = require('eth-json-rpc-middleware/dist/block-cache')

class BlockCacheSubprovider extends ProviderSubprovider {
constructor(opts) {
Expand Down
2 changes: 1 addition & 1 deletion subproviders/fetch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ProviderSubprovider = require('./json-rpc-engine-middleware')
const createFetchMiddleware = require('eth-json-rpc-middleware/fetch')
const { createFetchMiddleware } = require('eth-json-rpc-middleware/dist/fetch')

class FetchSubprovider extends ProviderSubprovider {
constructor(opts) {
Expand Down
15 changes: 11 additions & 4 deletions subproviders/hooked-wallet-ethtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
const inherits = require('util').inherits
const HookedWalletProvider = require('./hooked-wallet.js')
const { TransactionFactory } = require('@ethereumjs/tx')
const sigUtil = require('@metamask/eth-sig-util')
const ethUtil = require('ethereumjs-util')
const sigUtil = require('eth-sig-util')

module.exports = HookedWalletEthTxSubprovider

Expand Down Expand Up @@ -41,7 +41,7 @@ function HookedWalletEthTxSubprovider(opts) {
self.signMessage = function(msgParams, cb) {
opts.getPrivateKey(msgParams.from, function(err, privateKey) {
if (err) return cb(err)
var dataBuff = ethUtil.toBuffer(msgParams.data)
var dataBuff = Buffer.from(msgParams.data)
var msgHash = ethUtil.hashPersonalMessage(dataBuff)
var sig = ethUtil.ecsign(msgHash, privateKey)
var serialized = ethUtil.bufferToHex(concatSig(sig.v, sig.r, sig.s))
Expand All @@ -52,15 +52,22 @@ function HookedWalletEthTxSubprovider(opts) {
self.signPersonalMessage = function(msgParams, cb) {
opts.getPrivateKey(msgParams.from, function(err, privateKey) {
if (err) return cb(err)
const serialized = sigUtil.personalSign(privateKey, msgParams)
const serialized = sigUtil.personalSign({
privateKey,
data: msgParams.data,
})
cb(null, serialized)
})
}

self.signTypedMessage = function (msgParams, cb) {
opts.getPrivateKey(msgParams.from, function(err, privateKey) {
if (err) return cb(err)
const serialized = sigUtil.signTypedData(privateKey, msgParams)
const serialized = sigUtil.signTypedData({
privateKey,
data: msgParams.data,
version: msgParams.version || 'V1',
})
cb(null, serialized)
})
}
Expand Down
16 changes: 8 additions & 8 deletions subproviders/hooked-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
const waterfall = require('async/waterfall')
const parallel = require('async/parallel')
const inherits = require('util').inherits
const sigUtil = require('@metamask/eth-sig-util')
const ethUtil = require('ethereumjs-util')
const sigUtil = require('eth-sig-util')
const extend = require('xtend')
const Semaphore = require('semaphore')
const Subprovider = require('./subprovider.js')
Expand Down Expand Up @@ -229,26 +229,26 @@ HookedWalletSubprovider.prototype.handleRequest = function(payload, next, end){
(cb) => self.processDecryptMessage(msgParams, cb),
], end)
})()

case 'encryption_public_key':
return (function(){
const address = payload.params[0]

waterfall([
(cb) => self.validateEncryptionPublicKey(address, cb),
(cb) => self.processEncryptionPublicKey(address, cb),
], end)
})()

case 'personal_ecRecover':
return (function(){
return (function(){
message = payload.params[0]
let signature = payload.params[1]
// non-standard "extraParams" to be appended to our "msgParams" obj
// good place for metadata
extraParams = payload.params[2] || {}
msgParams = extend(extraParams, {
sig: signature,
signature: signature,
data: message,
})
self.recoverPersonalSignature(msgParams, end)
Expand All @@ -257,9 +257,9 @@ HookedWalletSubprovider.prototype.handleRequest = function(payload, next, end){
case 'eth_signTypedData':
case 'eth_signTypedData_v3':
case 'eth_signTypedData_v4':
return (function(){
return (function(){
// process normally

const first = payload.params[0]
const second = payload.params[1]

Expand Down
2 changes: 1 addition & 1 deletion subproviders/inflight-cache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ProviderSubprovider = require('./json-rpc-engine-middleware')
const createInflightCacheMiddleware = require('eth-json-rpc-middleware/inflight-cache')
const { createInflightCacheMiddleware } = require('eth-json-rpc-middleware/dist/inflight-cache')

class InflightCacheSubprovider extends ProviderSubprovider {
constructor(opts) {
Expand Down
2 changes: 1 addition & 1 deletion subproviders/infura.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const createInfuraProvider = require('eth-json-rpc-infura/src/createProvider')
const { createProvider: createInfuraProvider } = require('@metamask/eth-json-rpc-infura')
const ProviderSubprovider = require('./provider.js')

class InfuraSubprovider extends ProviderSubprovider {
Expand Down
4 changes: 2 additions & 2 deletions test/cache.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('tape')
const series = require('async/series')
const createGanacheProvider = require('ganache-core').provider
const createGanacheProvider = require('ganache-cli').provider
const ProviderEngine = require('../index.js')
const FixtureProvider = require('../subproviders/fixture.js')
const CacheProvider = require('../subproviders/cache.js')
Expand Down Expand Up @@ -198,7 +198,7 @@ function cacheTest(label, payloads, shouldHitCacheOnSecondRequest){
},
eth_getStorageAt: '0x00000000000000000000000000000000000000000000000000000000deadbeef',
}))

// handle dummy block
const ganacheProvider = createGanacheProvider()
var blockProvider = injectMetrics(new ProviderSubprovider(ganacheProvider))
Expand Down
6 changes: 3 additions & 3 deletions test/inflight-cache.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const test = require('tape')
const asyncParallel = require('async/parallel')
const asyncSeries = require('async/series')
const createGanacheProvider = require('ganache-core').provider
const createGanacheProvider = require('ganache-cli').provider
const ProviderEngine = require('../index.js')
const FixtureProvider = require('../subproviders/fixture.js')
const InflightCacheProvider = require('../subproviders/inflight-cache.js')
Expand Down Expand Up @@ -102,7 +102,7 @@ function inflightTest(label, payloads, shouldHitCacheOnSecondRequest){

t.equal(handlingProvider.getWitnessed(method).length, 1, 'handlingProvider did see "'+method+'"')
t.equal(handlingProvider.getHandled(method).length, 1, 'handlingProvider did handle "'+method+'"')

} else {

t.equal(cacheProvider.getWitnessed(method).length, 2, 'cacheProvider did see "'+method+'"')
Expand Down Expand Up @@ -136,4 +136,4 @@ function inflightTest(label, payloads, shouldHitCacheOnSecondRequest){

}

function noop(){}
function noop(){}
4 changes: 2 additions & 2 deletions test/util/ganache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { provider } = require('ganache-core')
const { provider } = require('ganache-cli')
const ProviderSubprovider = require('../../subproviders/provider')


Expand All @@ -10,4 +10,4 @@ class GanacheProvider extends ProviderSubprovider {

}

module.exports = GanacheProvider
module.exports = GanacheProvider
Loading

0 comments on commit 277e195

Please sign in to comment.