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

ethers-providers

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethers-providers - npm Package Compare versions

Comparing version 2.1.14 to 2.1.15

40

etherscan-provider.js

@@ -221,2 +221,10 @@ 'use strict';

case 'getEtherPrice':
if (this.name !== 'homestead') { return Promise.resolve(0.0); }
url += '/api?module=stats&action=ethprice';
url += apiKey;
return Provider.fetchJSON(url, null, getResult).then(function(result) {
return parseFloat(result.ethusd);
});
default:

@@ -229,2 +237,34 @@ break;

utils.defineProperty(EtherscanProvider.prototype, 'getHistory', function(addressOrName, startBlock, endBlock) {
var url = this.baseUrl;
var apiKey = '';
if (this.apiKey) { apiKey += '&apikey=' + this.apiKey; }
if (startBlock == null) { startBlock = 0; }
if (endBlock == null) { endBlock = 99999999; }
return this.resolveName(addressOrName).then(function(address) {
url += '/api?module=account&action=txlist&address=' + address;
url += '&fromBlock=' + startBlock;
url += '&endBlock=' + endBlock;
url += '&sort=asc';
return Provider.fetchJSON(url, null, getResult).then(function(result) {
var output = [];
result.forEach(function(tx) {
['contractAddress', 'to'].forEach(function(key) {
if (tx[key] == '') { delete tx[key]; }
});
if (tx.creates == null && tx.contractAddress != null) {
tx.creates = tx.contractAddress;
}
output.push(Provider._formatters.checkTransactionResponse(tx));
});
return output;
});
});
});
module.exports = EtherscanProvider;;

@@ -45,2 +45,9 @@ 'use strict';

utils.defineProperty(InfuraProvider.prototype, '_startPending', function() {
console.log('WARNING: INFURA does not support pending filters');
});
utils.defineProperty(InfuraProvider.prototype, '_stopPending', function() {
});
module.exports = InfuraProvider;

@@ -17,2 +17,11 @@ 'use strict';

// @TODO: Move this to utils
function timer(timeout) {
return new Promise(function(resolve) {
setTimeout(function() {
resolve();
}, timeout);
});
}
function getResult(payload) {

@@ -161,2 +170,44 @@ if (payload.error) {

utils.defineProperty(JsonRpcProvider.prototype, '_startPending', function() {
if (this._pendingFilter != null) { return; }
var self = this;
var pendingFilter = this.send('eth_newPendingTransactionFilter', []);
this._pendingFilter = pendingFilter;
pendingFilter.then(function(filterId) {
function poll() {
self.send('eth_getFilterChanges', [ filterId ]).then(function(hashes) {
if (self._pendingFilter != pendingFilter) { return; }
var seq = Promise.resolve();
hashes.forEach(function(hash) {
seq = seq.then(function() {
return self.getTransaction(hash).then(function(tx) {
self.emit('pending', tx);
});
});
});
return seq.then(function() {
return timer(1000);
});
}).then(function() {
if (self._pendingFilter != pendingFilter) {
self.send('eth_uninstallFilter', [ filterIf ]);
return;
}
setTimeout(function() { poll(); }, 0);
});
}
poll();
return filterId;
});
});
utils.defineProperty(JsonRpcProvider.prototype, '_stopPending', function() {
this._pendingFilter = null;
});
module.exports = JsonRpcProvider;

2

package.json
{
"name": "ethers-providers",
"version": "2.1.14",
"version": "2.1.15",
"description": "Service provider for Ethereum wallet library.",

@@ -5,0 +5,0 @@ "bugs": {

@@ -218,3 +218,2 @@ 'use strict';

if (!transaction.raw) {
// Very loose providers (e.g. TestRPC) don't provide a signature or raw

@@ -722,3 +721,3 @@ if (transaction.v && transaction.r && transaction.s) {

var self = this;
return this._resolveNames(transaction, ['to', 'from']).then(function(transaction) {
return this._resolveNames(transaction, [ 'to', 'from' ]).then(function(transaction) {
var params = { transaction: checkTransactionRequest(transaction) };

@@ -733,3 +732,3 @@ return self.perform('call', params).then(function(result) {

var self = this;
return this._resolveNames(transaction, ['to', 'from']).then(function(transaction) {
return this._resolveNames(transaction, [ 'to', 'from' ]).then(function(transaction) {
var params = {transaction: checkTransactionRequest(transaction)};

@@ -940,2 +939,5 @@ return self.perform('estimateGas', params).then(function(result) {

} else if (object === 'pending') {
return 'pending';
} else if (utils.isHexString(object)) {

@@ -968,2 +970,5 @@ if (object.length === 66) {

} else if (string === 'pending') {
return {type: 'pending'};
} else if (string.substring(0, 8) === 'address:') {

@@ -988,2 +993,9 @@ return {type: 'address', address: string.substring(8)};

utils.defineProperty(Provider.prototype, '_startPending', function() {
console.log('WARNING: this provider does not support pending events');
});
utils.defineProperty(Provider.prototype, '_stopPending', function() {
});
utils.defineProperty(Provider.prototype, 'on', function(eventName, listener) {

@@ -993,2 +1005,3 @@ var key = getEventString(eventName);

this._events[key].push({eventName: eventName, listener: listener, type: 'on'});
if (key === 'pending') { this._startPending(); }
this.polling = true;

@@ -1001,2 +1014,3 @@ });

this._events[key].push({eventName: eventName, listener: listener, type: 'once'});
if (key === 'pending') { this._startPending(); }
this.polling = true;

@@ -1026,3 +1040,7 @@ });

if (listeners.length === 0) { delete this._events[key]; }
if (listeners.length === 0) {
delete this._events[key];
if (key === 'pending') { this._stopPending(); }
}
if (this.listenerCount() === 0) { this.polling = false; }

@@ -1072,2 +1090,6 @@ });

utils.defineProperty(Provider, '_formatters', {
checkTransactionResponse: checkTransaction
});
module.exports = Provider;
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