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

deps: Bump ethereumjs and metamask packages #453

Merged
merged 7 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const EventEmitter = require('events').EventEmitter
const inherits = require('util').inherits
const ethUtil = require('ethereumjs-util')
const ethUtil = require('@ethereumjs/util')
const { PollingBlockTracker } = require('eth-block-tracker')
const map = require('async/map')
const eachSeries = require('async/eachSeries')
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@
},
"dependencies": {
"@cypress/request": "^3.0.0",
"@ethereumjs/tx": "^3.3.0",
"@ethereumjs/statemanager": "^1.1.0",
"@ethereumjs/block": "^4.3.0",
"@ethereumjs/tx": "^4.2.0",
"@ethereumjs/vm": "^6.5.0",
"@ethereumjs/util": "^8.1.0",
"@metamask/eth-json-rpc-filters": "^7.0.0",
"@metamask/eth-json-rpc-infura": "^9.0.0",
"@metamask/eth-json-rpc-middleware": "^12.0.0",
"@metamask/eth-sig-util": "^7.0.0",
"@metamask/rpc-errors": "^6.0.0",
"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-block-tracker": "^8.0.0",
"json-stable-stringify": "^1.0.1",
"promise-to-callback": "^1.0.0",
"readable-stream": "^2.2.9",
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('@metamask/eth-json-rpc-middleware')

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('@metamask/eth-json-rpc-middleware')

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

class FiltersSubprovider extends ProviderSubprovider {
constructor() {
Expand Down
20 changes: 15 additions & 5 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 ethUtil = require('ethereumjs-util')
const sigUtil = require('eth-sig-util')
const ethUtil = require('@ethereumjs/util')
const sigUtil = require('@metamask/eth-sig-util')

module.exports = HookedWalletEthTxSubprovider

Expand Down Expand Up @@ -41,7 +41,10 @@ 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)
const data = typeof msgParams.data === 'string' && !ethUtil.isHexString(msgParams.data)
? Buffer.from(msgParams.data)
: msgParams.data;
var dataBuff = ethUtil.toBuffer(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 +55,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,
version: msgParams.version || 'V1',
data: msgParams.data,
})
cb(null, serialized)
})
}
Expand Down
18 changes: 9 additions & 9 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 ethUtil = require('ethereumjs-util')
const sigUtil = require('eth-sig-util')
const ethUtil = require('@ethereumjs/util')
const sigUtil = require('@metamask/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,
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('@metamask/eth-json-rpc-middleware')

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

class InfuraSubprovider extends ProviderSubprovider {
constructor(opts = {}) {
const provider = createInfuraProvider(opts)
const provider = createProvider(opts)
super(provider)
}
}
Expand Down
2 changes: 1 addition & 1 deletion subproviders/nonce-tracker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const inherits = require('util').inherits
const { TransactionFactory } = require('@ethereumjs/tx')
const ethUtil = require('ethereumjs-util')
const ethUtil = require('@ethereumjs/util')
const Subprovider = require('./subprovider.js')
const blockTagForPayload = require('../util/rpc-cache-utils').blockTagForPayload

Expand Down
6 changes: 3 additions & 3 deletions subproviders/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const xhr = process.browser ? require('xhr') : require('request')
const inherits = require('util').inherits
const createPayload = require('../util/create-payload.js')
const Subprovider = require('./subprovider.js')
const { ethErrors, serializeError } = require('eth-rpc-errors')
const { rpcErrors, serializeError } = require('@metamask/rpc-errors')


module.exports = RpcSource
Expand Down Expand Up @@ -38,7 +38,7 @@ RpcSource.prototype.handleRequest = function(payload, next, end){
// check for error code
switch (res.statusCode) {
case 405:
return end(ethErrors.rpc.methodNotFound())
return end(rpcErrors.methodNotFound())
case 504: // Gateway timeout
return (function(){
let msg = `Gateway timeout. The request took too long to process. `
Expand Down Expand Up @@ -81,4 +81,4 @@ function sanitizePayload (payload) {
method: payload.method,
params: payload.params,
}
}
}
2 changes: 1 addition & 1 deletion subproviders/sanitizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const inherits = require('util').inherits
const Subprovider = require('./subprovider.js')
const extend = require('xtend')
const ethUtil = require('ethereumjs-util')
const ethUtil = require('@ethereumjs/util')

module.exports = SanitizerSubprovider

Expand Down
2 changes: 1 addition & 1 deletion subproviders/subscriptions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ProviderSubprovider = require('./json-rpc-engine-middleware')
const createSubscriptionManager = require('eth-json-rpc-filters/subscriptionManager')
const createSubscriptionManager = require('@metamask/eth-json-rpc-filters/subscriptionManager')

class SubscriptionsSubprovider extends ProviderSubprovider {
constructor() {
Expand Down
14 changes: 9 additions & 5 deletions subproviders/vm.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const doWhilst = require('async/doWhilst')
const inherits = require('util').inherits
const Stoplight = require('../util/stoplight.js')
const createVm = require('ethereumjs-vm/dist/hooked').fromWeb3Provider
const Block = require('ethereumjs-block')
const { VM } = require('@ethereumjs/vm')
const Block = require('@ethereumjs/block')
const { EthersStateManager } = require('@ethereumjs/statemanager')
const { TransactionFactory } = require('@ethereumjs/tx')
const ethUtil = require('ethereumjs-util')
const ethUtil = require('@ethereumjs/util')
const rpcHexEncoding = require('../util/rpc-hex-encoding.js')
const Subprovider = require('./subprovider.js')

Expand Down Expand Up @@ -119,8 +120,11 @@ VmSubprovider.prototype.runVm = function(payload, cb){
var blockNumber = ethUtil.addHexPrefix(blockData.number.toString('hex'))

// create vm with state lookup intercepted
var vm = self.vm = createVm(self.engine, blockNumber, {
enableHomestead: true
const vm = self.vm = new VM({
stateManager: new EthersStateManager({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

provider: self.engine,
blockTag: blockNumber,
}),
})

if (self.opts.debug) {
Expand Down
2 changes: 1 addition & 1 deletion test/nonce.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('tape')
const { TransactionFactory } = require('@ethereumjs/tx')
const ethUtil = require('ethereumjs-util')
const ethUtil = require('@ethereumjs/util')
const ProviderEngine = require('../index.js')
const FixtureProvider = require('../subproviders/fixture.js')
const NonceTracker = require('../subproviders/nonce-tracker.js')
Expand Down
2 changes: 1 addition & 1 deletion test/wallet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('tape')
const { TransactionFactory } = require('@ethereumjs/tx')
const ethUtil = require('ethereumjs-util')
const ethUtil = require('@ethereumjs/util')
const ProviderEngine = require('../index.js')
const FixtureProvider = require('../subproviders/fixture.js')
const NonceTracker = require('../subproviders/nonce-tracker.js')
Expand Down
2 changes: 1 addition & 1 deletion util/rpc-hex-encoding.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ethUtil = require('ethereumjs-util')
const ethUtil = require('@ethereumjs/util')
const assert = require('./assert.js')

module.exports = {
Expand Down
Loading
Loading