web3
Advanced tools
Comparing version 0.12.2 to 0.13.0
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.12.2", | ||
"version": "0.13.0", | ||
"description": "Ethereum Compatible JavaScript API", | ||
@@ -6,0 +6,0 @@ "main": [ |
@@ -383,3 +383,3 @@ /* | ||
var isStrictAddress = function (address) { | ||
return /^0x[0-9a-f]{40}$/.test(address); | ||
return /^0x[0-9a-f]{40}$/i.test(address); | ||
}; | ||
@@ -395,3 +395,3 @@ | ||
var isAddress = function (address) { | ||
return /^(0x)?[0-9a-f]{40}$/.test(address); | ||
return /^(0x)?[0-9a-f]{40}$/i.test(address); | ||
}; | ||
@@ -398,0 +398,0 @@ |
{ | ||
"version": "0.12.2" | ||
"version": "0.13.0" | ||
} |
@@ -34,2 +34,3 @@ /* | ||
var Filter = require('./web3/filter'); | ||
var IsSyncing = require('./web3/syncing'); | ||
var utils = require('./utils/utils'); | ||
@@ -89,2 +90,6 @@ var formatters = require('./web3/formatters'); | ||
web3.eth.isSyncing = function (callback) { | ||
return new IsSyncing(callback); | ||
}; | ||
/*jshint maxparams:4 */ | ||
@@ -109,4 +114,4 @@ web3.eth.filter = function (fil, callback) { | ||
}; | ||
web3.reset = function () { | ||
RequestManager.getInstance().reset(); | ||
web3.reset = function (keepIsSyncing) { | ||
RequestManager.getInstance().reset(keepIsSyncing); | ||
c.defaultBlock = 'latest'; | ||
@@ -113,0 +118,0 @@ c.defaultAccount = undefined; |
@@ -31,3 +31,3 @@ /* | ||
InvalidProvider: function () { | ||
return new Error('Providor not set or invalid'); | ||
return new Error('Provider not set or invalid'); | ||
}, | ||
@@ -34,0 +34,0 @@ InvalidResponse: function (result){ |
@@ -117,8 +117,10 @@ /* | ||
messages.forEach(function (message) { | ||
message = self.formatter ? self.formatter(message) : message; | ||
self.callbacks.forEach(function (callback) { | ||
callback(null, message); | ||
if(utils.isArray(messages)) { | ||
messages.forEach(function (message) { | ||
message = self.formatter ? self.formatter(message) : message; | ||
self.callbacks.forEach(function (callback) { | ||
callback(null, message); | ||
}); | ||
}); | ||
}); | ||
} | ||
}; | ||
@@ -143,2 +145,3 @@ | ||
this.callbacks = []; | ||
this.getLogsCallbacks = []; | ||
this.pollFilters = []; | ||
@@ -154,2 +157,9 @@ this.formatter = formatter; | ||
// check if there are get pending callbacks as a consequence | ||
// of calling get() with filterId unassigned. | ||
self.getLogsCallbacks.forEach(function (cb){ | ||
self.get(cb); | ||
}); | ||
self.getLogsCallbacks = []; | ||
// get filter logs for the already existing watch calls | ||
@@ -193,12 +203,21 @@ self.callbacks.forEach(function(cb){ | ||
if (utils.isFunction(callback)) { | ||
this.implementation.getLogs(this.filterId, function(err, res){ | ||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, res.map(function (log) { | ||
return self.formatter ? self.formatter(log) : log; | ||
})); | ||
} | ||
}); | ||
if (this.filterId === null) { | ||
// If filterId is not set yet, call it back | ||
// when newFilter() assigns it. | ||
this.getLogsCallbacks.push(callback); | ||
} else { | ||
this.implementation.getLogs(this.filterId, function(err, res){ | ||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, res.map(function (log) { | ||
return self.formatter ? self.formatter(log) : log; | ||
})); | ||
} | ||
}); | ||
} | ||
} else { | ||
if (this.filterId === null) { | ||
throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.'); | ||
} | ||
var logs = this.implementation.getLogs(this.filterId); | ||
@@ -205,0 +224,0 @@ return logs.map(function (log) { |
@@ -273,2 +273,12 @@ /* | ||
var outputSyncingFormatter = function(result) { | ||
result.startingBlock = utils.toDecimal(result.startingBlock); | ||
result.currentBlock = utils.toDecimal(result.currentBlock); | ||
result.highestBlock = utils.toDecimal(result.highestBlock); | ||
return result; | ||
}; | ||
module.exports = { | ||
@@ -286,4 +296,5 @@ inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter, | ||
outputLogFormatter: outputLogFormatter, | ||
outputPostFormatter: outputPostFormatter | ||
outputPostFormatter: outputPostFormatter, | ||
outputSyncingFormatter: outputSyncingFormatter | ||
}; | ||
@@ -272,2 +272,7 @@ /* | ||
new Property({ | ||
name: 'syncing', | ||
getter: 'eth_syncing', | ||
outputFormatter: formatters.outputSyncingFormatter | ||
}), | ||
new Property({ | ||
name: 'gasPrice', | ||
@@ -274,0 +279,0 @@ getter: 'eth_gasPrice', |
@@ -180,7 +180,11 @@ /* | ||
*/ | ||
RequestManager.prototype.reset = function () { | ||
RequestManager.prototype.reset = function (keepIsSyncing) { | ||
for (var key in this.polls) { | ||
this.polls[key].uninstall(); | ||
// remove all polls, except sync polls, | ||
// they need to be removed manually by calling syncing.stopWatching() | ||
if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) { | ||
this.polls[key].uninstall(); | ||
delete this.polls[key]; | ||
} | ||
} | ||
this.polls = {}; | ||
@@ -213,6 +217,6 @@ if (this.timeout) { | ||
var pollsData = []; | ||
var pollsKeys = []; | ||
var pollsIds = []; | ||
for (var key in this.polls) { | ||
pollsData.push(this.polls[key].data); | ||
pollsKeys.push(key); | ||
pollsIds.push(key); | ||
} | ||
@@ -225,5 +229,14 @@ | ||
var payload = Jsonrpc.getInstance().toBatchPayload(pollsData); | ||
// map the request id to they poll id | ||
var pollsIdMap = {}; | ||
payload.forEach(function(load, index){ | ||
pollsIdMap[load.id] = pollsIds[index]; | ||
}); | ||
var self = this; | ||
this.provider.sendAsync(payload, function (error, results) { | ||
// TODO: console log? | ||
@@ -237,8 +250,8 @@ if (error) { | ||
} | ||
results.map(function (result) { | ||
var id = pollsIdMap[result.id]; | ||
results.map(function (result, index) { | ||
var key = pollsKeys[index]; | ||
// make sure the filter is still installed after arrival of the request | ||
if (self.polls[key]) { | ||
result.callback = self.polls[key].callback; | ||
if (self.polls[id]) { | ||
result.callback = self.polls[id].callback; | ||
return result; | ||
@@ -255,4 +268,2 @@ } else | ||
return valid; | ||
}).filter(function (result) { | ||
return utils.isArray(result.result) && result.result.length > 0; | ||
}).forEach(function (result) { | ||
@@ -259,0 +270,0 @@ result.callback(null, result.result); |
/* jshint ignore:start */ | ||
Package.describe({ | ||
name: 'ethereum:web3', | ||
version: '0.12.2', | ||
version: '0.13.0', | ||
summary: 'Ethereum JavaScript API, middleware to talk to a ethreum node over RPC', | ||
@@ -6,0 +6,0 @@ git: 'https://github.com/ethereum/ethereum.js', |
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.12.2", | ||
"version": "0.13.0", | ||
"description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
spdx disjunction for an artifact's license information
Licensespdx disjunction for an artifact's license information
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
spdx disjunction for an artifact's license information
Licensespdx disjunction for an artifact's license information
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license
Found 1 instance in 1 package
5
3
1296568
70
21586