Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-provider-engine

Package Overview
Dependencies
Maintainers
1
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-provider-engine - npm Package Compare versions

Comparing version 6.0.4 to 6.1.0

subproviders/etherscan.js

2

package.json
{
"name": "web3-provider-engine",
"version": "6.0.4",
"version": "6.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,1 +1,9 @@

/*
* Emulate 'eth_accounts' / 'eth_sendTransaction' using 'eth_sendRawTransaction'
*
* The two callbacks a user needs to implement are:
* - getAccounts() -- array of addresses supported
* - signTransaction(tx) -- sign a raw transaction object
*/
const async = require('async')

@@ -93,16 +101,34 @@ const inherits = require('util').inherits

// console.log('fillInTxExtras - address:', address)
async.parallel({
nonce: self.emitPayload.bind(self, { method: 'eth_getTransactionCount', params: [address, 'pending'] }),
gas: self.emitPayload.bind(self, { method: 'eth_estimateGas', params: [txParams] }),
gasPrice: self.emitPayload.bind(self, { method: 'eth_gasPrice', params: [] }),
}, function(err, result){
var reqs = {}
if (txParams.gasPrice === undefined) {
// console.log("need to get gasprice")
reqs.gasPrice = self.emitPayload.bind(self, { method: 'eth_gasPrice', params: [] })
}
if (txParams.nonce === undefined) {
// console.log("need to get nonce")
reqs.nonce = self.emitPayload.bind(self, { method: 'eth_getTransactionCount', params: [address, 'pending'] })
}
if (txParams.gas === undefined) {
// console.log("need to get gas")
reqs.gas = self.emitPayload.bind(self, { method: 'eth_estimateGas', params: [ txParams, 'pending'] })
}
async.parallel(reqs, function(err, result) {
if (err) return cb(err)
// console.log('fillInTxExtras - result:', result)
var fullTxParams = extend({
nonce: result.nonce.result,
gas: result.gas.result,
gasPrice: result.gasPrice.result,
}, txParams)
cb(null, fullTxParams)
var res = { }
if (result.gasPrice)
res.gasPrice = result.gasPrice.result
if (result.nonce)
res.nonce = result.nonce.result
if (result.gas)
res.gas = result.gas.result
cb(null, extend(res, txParams))
})
}

@@ -45,2 +45,3 @@ const xhr = process.browser ? require('xhr') : require('request')

data = JSON.parse(body)
if (data.error) return end(data.error)
} catch (err) {

@@ -51,14 +52,7 @@ console.error(err.stack)

// // console.log('network:', payload.method, payload.params, '->', data.result)
//
// if (data.error) {
// resultObj.error = data.error
// // return cb(new Error(data.error.message))
// } else {
// resultObj.result = data.result
// }
// console.log('network:', payload.method, payload.params, '->', data.result)
end(data.error, data.result);
end(null, data.result)
})
}
const async = require('async')
const inherits = require('util').inherits
const Stoplight = require('../util/stoplight.js')
const VM = require('ethereumjs-vm')

@@ -25,4 +26,16 @@ const Block = require('ethereumjs-block')

self.methods = ['eth_call', 'eth_estimateGas']
// set initialization blocker
self._ready = new Stoplight()
}
// setup a block listener on 'setEngine'
VmSubprovider.prototype.setEngine = function(engine) {
const self = this
Subprovider.prototype.setEngine.call(self, engine)
// unblock initialization after first block
engine.once('block', function(block) {
self._ready.go()
})
}
VmSubprovider.prototype.handleRequest = function(payload, next, end) {

@@ -29,0 +42,0 @@ if (this.methods.indexOf(payload.method) < 0) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc