Browse Source

Merge pull request #1142 from debris/ethereumjs_timeout

ethereumjs master
cl-refactor
Gav Wood 10 years ago
parent
commit
8c9aefd39c
  1. 63
      libjsqrc/ethereumjs/.jshintrc
  2. 2
      libjsqrc/ethereumjs/README.md
  3. 5
      libjsqrc/ethereumjs/bower.json
  4. 29
      libjsqrc/ethereumjs/dist/ethereum.js
  5. 18
      libjsqrc/ethereumjs/dist/ethereum.js.map
  6. 2
      libjsqrc/ethereumjs/dist/ethereum.min.js
  7. 4
      libjsqrc/ethereumjs/gulpfile.js
  8. 2
      libjsqrc/ethereumjs/lib/abi.js
  9. 2
      libjsqrc/ethereumjs/lib/contract.js
  10. 4
      libjsqrc/ethereumjs/lib/event.js
  11. 2
      libjsqrc/ethereumjs/lib/filter.js
  12. 1
      libjsqrc/ethereumjs/lib/formatters.js
  13. 11
      libjsqrc/ethereumjs/lib/requestmanager.js
  14. 1
      libjsqrc/ethereumjs/lib/utils.js
  15. 4
      libjsqrc/ethereumjs/lib/web3.js
  16. 1
      libjsqrc/ethereumjs/package.json

63
libjsqrc/ethereumjs/.jshintrc

@ -1,50 +1,19 @@
{ {
"predef": [ "browserify": true,
"console", "bitwise": true,
"require", "camelcase": true,
"equal",
"test",
"testBoth",
"testWithDefault",
"raises",
"deepEqual",
"start",
"stop",
"ok",
"strictEqual",
"module",
"expect",
"reject",
"impl"
],
"esnext": true,
"proto": true,
"node" : true,
"browser" : true,
"browserify" : true,
"boss" : true,
"curly": false,
"debug": true,
"devel": true,
"eqeqeq": true, "eqeqeq": true,
"evil": true, "freeze": true,
"forin": false, "funcscope": false,
"immed": false, "maxcomplexity": 4, /* our target is 3! */
"laxbreak": false, "maxdepth": 3,
"newcap": true, "maxerr": 50,
"noarg": true, /*"maxlen": 80*/ /*this should be our goal*/
"noempty": false, "maxparams": 3,
"nonew": false, "nonew": true,
"nomen": false, "unused": true,
"onevar": false,
"plusplus": false,
"regexp": false,
"undef": true, "undef": true,
"sub": true, "predef": [
"strict": false, "console"
"white": false, ]
"shadow": true, }
"eqnull": true
}

2
libjsqrc/ethereumjs/README.md

@ -1,7 +1,7 @@
# Ethereum JavaScript API # Ethereum JavaScript API
This is the Ethereum compatible [JavaScript API](https://github.com/ethereum/wiki/wiki/JavaScript-API) This is the Ethereum compatible [JavaScript API](https://github.com/ethereum/wiki/wiki/JavaScript-API)
which implements the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC) spec. It's available on npm as a node module and also for bower and component as an embeddable js which implements the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) spec. It's available on npm as a node module and also for bower and component as an embeddable js
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url][![Coverage Status][coveralls-image]][coveralls-url] [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url][![Coverage Status][coveralls-image]][coveralls-url]

5
libjsqrc/ethereumjs/bower.json

@ -3,7 +3,10 @@
"namespace": "ethereum", "namespace": "ethereum",
"version": "0.0.15", "version": "0.0.15",
"description": "Ethereum Compatible JavaScript API", "description": "Ethereum Compatible JavaScript API",
"main": ["./dist/ethereum.js", "./dist/ethereum.min.js"], "main": [
"./dist/ethereum.js",
"./dist/ethereum.min.js"
],
"dependencies": { "dependencies": {
"bignumber.js": ">=2.0.0" "bignumber.js": ">=2.0.0"
}, },

29
libjsqrc/ethereumjs/dist/ethereum.js

@ -53,7 +53,6 @@ var inputTypes = types.inputTypes();
/// @returns bytes representation of input params /// @returns bytes representation of input params
var formatInput = function (inputs, params) { var formatInput = function (inputs, params) {
var bytes = ""; var bytes = "";
var padding = c.ETH_PADDING * 2;
/// first we iterate in search for dynamic /// first we iterate in search for dynamic
inputs.forEach(function (input, index) { inputs.forEach(function (input, index) {
@ -110,6 +109,7 @@ var formatOutput = function (outs, output) {
output = output.slice(dynamicPartLength); output = output.slice(dynamicPartLength);
outs.forEach(function (out, i) { outs.forEach(function (out, i) {
/*jshint maxcomplexity:6 */
var typeMatch = false; var typeMatch = false;
for (var j = 0; j < outputTypes.length && !typeMatch; j++) { for (var j = 0; j < outputTypes.length && !typeMatch; j++) {
typeMatch = outputTypes[j].type(outs[i].type); typeMatch = outputTypes[j].type(outs[i].type);
@ -296,7 +296,6 @@ var web3 = require('./web3');
var abi = require('./abi'); var abi = require('./abi');
var utils = require('./utils'); var utils = require('./utils');
var eventImpl = require('./event'); var eventImpl = require('./event');
var filter = require('./filter');
var exportNatspecGlobals = function (vars) { var exportNatspecGlobals = function (vars) {
// it's used byt natspec.js // it's used byt natspec.js
@ -342,6 +341,7 @@ var addFunctionsToContract = function (contract, desc, address) {
var typeName = utils.extractTypeName(method.name); var typeName = utils.extractTypeName(method.name);
var impl = function () { var impl = function () {
/*jshint maxcomplexity:7 */
var params = Array.prototype.slice.call(arguments); var params = Array.prototype.slice.call(arguments);
var signature = abi.signatureFromAscii(method.name); var signature = abi.signatureFromAscii(method.name);
var parsed = inputParser[displayName][typeName].apply(null, params); var parsed = inputParser[displayName][typeName].apply(null, params);
@ -489,7 +489,7 @@ var contract = function (address, desc) {
module.exports = contract; module.exports = contract;
},{"./abi":1,"./event":6,"./filter":7,"./utils":15,"./web3":17}],4:[function(require,module,exports){ },{"./abi":1,"./event":6,"./utils":15,"./web3":17}],4:[function(require,module,exports){
/* /*
This file is part of ethereum.js. This file is part of ethereum.js.
@ -697,9 +697,9 @@ var getArgumentsObject = function (inputs, indexed, notIndexed) {
return inputs.reduce(function (acc, current) { return inputs.reduce(function (acc, current) {
var value; var value;
if (current.indexed) if (current.indexed)
value = indexed.splice(0, 1)[0]; value = indexedCopy.splice(0, 1)[0];
else else
value = notIndexed.splice(0, 1)[0]; value = notIndexedCopy.splice(0, 1)[0];
acc[current.name] = value; acc[current.name] = value;
return acc; return acc;
@ -847,7 +847,7 @@ var filter = function(options, implementation, formatter) {
return implementation.getMessages(filterId); return implementation.getMessages(filterId);
}; };
var uninstall = function (callback) { var uninstall = function () {
implementation.stopPolling(filterId); implementation.stopPolling(filterId);
implementation.uninstallFilter(filterId); implementation.uninstallFilter(filterId);
callbacks = []; callbacks = [];
@ -909,6 +909,7 @@ var padLeft = function (string, chars, sign) {
/// If the value is floating point, round it down /// If the value is floating point, round it down
/// @returns right-aligned byte representation of int /// @returns right-aligned byte representation of int
var formatInputInt = function (value) { var formatInputInt = function (value) {
/*jshint maxcomplexity:7 */
var padding = c.ETH_PADDING * 2; var padding = c.ETH_PADDING * 2;
if (value instanceof BigNumber || typeof value === 'number') { if (value instanceof BigNumber || typeof value === 'number') {
if (typeof value === 'number') if (typeof value === 'number')
@ -1210,6 +1211,7 @@ var c = require('./const');
*/ */
var requestManager = function() { var requestManager = function() {
var polls = []; var polls = [];
var timeout = null;
var provider; var provider;
var send = function (data) { var send = function (data) {
@ -1234,9 +1236,11 @@ var requestManager = function() {
provider = p; provider = p;
}; };
/*jshint maxparams:4 */
var startPolling = function (data, pollId, callback, uninstall) { var startPolling = function (data, pollId, callback, uninstall) {
polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall}); polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
}; };
/*jshint maxparams:3 */
var stopPolling = function (pollId) { var stopPolling = function (pollId) {
for (var i = polls.length; i--;) { for (var i = polls.length; i--;) {
@ -1252,6 +1256,12 @@ var requestManager = function() {
poll.uninstall(poll.id); poll.uninstall(poll.id);
}); });
polls = []; polls = [];
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
poll();
}; };
var poll = function () { var poll = function () {
@ -1262,7 +1272,7 @@ var requestManager = function() {
} }
data.callback(result); data.callback(result);
}); });
setTimeout(poll, c.ETH_POLLING_TIMEOUT); timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT);
}; };
poll(); poll();
@ -1509,6 +1519,7 @@ var filterEvents = function (json) {
/// TODO: use BigNumber.js to parse int /// TODO: use BigNumber.js to parse int
/// TODO: add tests for it! /// TODO: add tests for it!
var toEth = function (str) { var toEth = function (str) {
/*jshint maxcomplexity:7 */
var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str; var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
var unit = 0; var unit = 0;
var units = c.ETH_UNITS; var units = c.ETH_UNITS;
@ -1677,12 +1688,14 @@ var setupProperties = function (obj, properties) {
}); });
}; };
/*jshint maxparams:4 */
var startPolling = function (method, id, callback, uninstall) { var startPolling = function (method, id, callback, uninstall) {
web3.manager.startPolling({ web3.manager.startPolling({
method: method, method: method,
params: [id] params: [id]
}, id, callback, uninstall); }, id, callback, uninstall);
}; };
/*jshint maxparams:3 */
var stopPolling = function (id) { var stopPolling = function (id) {
web3.manager.stopPolling(id); web3.manager.stopPolling(id);
@ -1740,12 +1753,14 @@ var web3 = {
/// @param indexed is optional, this is an object with optional event indexed params /// @param indexed is optional, this is an object with optional event indexed params
/// @param options is optional, this is an object with optional event options ('max'...) /// @param options is optional, this is an object with optional event options ('max'...)
/// TODO: fix it, 4 params? no way /// TODO: fix it, 4 params? no way
/*jshint maxparams:4 */
watch: function (fil, indexed, options, formatter) { watch: function (fil, indexed, options, formatter) {
if (fil._isEvent) { if (fil._isEvent) {
return fil(indexed, options); return fil(indexed, options);
} }
return filter(fil, ethWatch, formatter); return filter(fil, ethWatch, formatter);
} }
/*jshint maxparams:3 */
}, },
/// db object prototype /// db object prototype

18
libjsqrc/ethereumjs/dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
libjsqrc/ethereumjs/dist/ethereum.min.js

File diff suppressed because one or more lines are too long

4
libjsqrc/ethereumjs/gulpfile.js

@ -10,8 +10,6 @@ var browserify = require('browserify');
var jshint = require('gulp-jshint'); var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify'); var uglify = require('gulp-uglify');
var rename = require('gulp-rename'); var rename = require('gulp-rename');
var envify = require('envify/custom');
var unreach = require('unreachable-branch-transform');
var source = require('vinyl-source-stream'); var source = require('vinyl-source-stream');
var exorcist = require('exorcist'); var exorcist = require('exorcist');
var bower = require('bower'); var bower = require('bower');
@ -23,7 +21,7 @@ var dst = 'ethereum';
var browserifyOptions = { var browserifyOptions = {
debug: true, debug: true,
insert_global_vars: false, insert_global_vars: false, // jshint ignore:line
detectGlobals: false, detectGlobals: false,
bundleExternal: false bundleExternal: false
}; };

2
libjsqrc/ethereumjs/lib/abi.js

@ -52,7 +52,6 @@ var inputTypes = types.inputTypes();
/// @returns bytes representation of input params /// @returns bytes representation of input params
var formatInput = function (inputs, params) { var formatInput = function (inputs, params) {
var bytes = ""; var bytes = "";
var padding = c.ETH_PADDING * 2;
/// first we iterate in search for dynamic /// first we iterate in search for dynamic
inputs.forEach(function (input, index) { inputs.forEach(function (input, index) {
@ -109,6 +108,7 @@ var formatOutput = function (outs, output) {
output = output.slice(dynamicPartLength); output = output.slice(dynamicPartLength);
outs.forEach(function (out, i) { outs.forEach(function (out, i) {
/*jshint maxcomplexity:6 */
var typeMatch = false; var typeMatch = false;
for (var j = 0; j < outputTypes.length && !typeMatch; j++) { for (var j = 0; j < outputTypes.length && !typeMatch; j++) {
typeMatch = outputTypes[j].type(outs[i].type); typeMatch = outputTypes[j].type(outs[i].type);

2
libjsqrc/ethereumjs/lib/contract.js

@ -24,7 +24,6 @@ var web3 = require('./web3');
var abi = require('./abi'); var abi = require('./abi');
var utils = require('./utils'); var utils = require('./utils');
var eventImpl = require('./event'); var eventImpl = require('./event');
var filter = require('./filter');
var exportNatspecGlobals = function (vars) { var exportNatspecGlobals = function (vars) {
// it's used byt natspec.js // it's used byt natspec.js
@ -70,6 +69,7 @@ var addFunctionsToContract = function (contract, desc, address) {
var typeName = utils.extractTypeName(method.name); var typeName = utils.extractTypeName(method.name);
var impl = function () { var impl = function () {
/*jshint maxcomplexity:7 */
var params = Array.prototype.slice.call(arguments); var params = Array.prototype.slice.call(arguments);
var signature = abi.signatureFromAscii(method.name); var signature = abi.signatureFromAscii(method.name);
var parsed = inputParser[displayName][typeName].apply(null, params); var parsed = inputParser[displayName][typeName].apply(null, params);

4
libjsqrc/ethereumjs/lib/event.js

@ -81,9 +81,9 @@ var getArgumentsObject = function (inputs, indexed, notIndexed) {
return inputs.reduce(function (acc, current) { return inputs.reduce(function (acc, current) {
var value; var value;
if (current.indexed) if (current.indexed)
value = indexed.splice(0, 1)[0]; value = indexedCopy.splice(0, 1)[0];
else else
value = notIndexed.splice(0, 1)[0]; value = notIndexedCopy.splice(0, 1)[0];
acc[current.name] = value; acc[current.name] = value;
return acc; return acc;

2
libjsqrc/ethereumjs/lib/filter.js

@ -93,7 +93,7 @@ var filter = function(options, implementation, formatter) {
return implementation.getMessages(filterId); return implementation.getMessages(filterId);
}; };
var uninstall = function (callback) { var uninstall = function () {
implementation.stopPolling(filterId); implementation.stopPolling(filterId);
implementation.uninstallFilter(filterId); implementation.uninstallFilter(filterId);
callbacks = []; callbacks = [];

1
libjsqrc/ethereumjs/lib/formatters.js

@ -40,6 +40,7 @@ var padLeft = function (string, chars, sign) {
/// If the value is floating point, round it down /// If the value is floating point, round it down
/// @returns right-aligned byte representation of int /// @returns right-aligned byte representation of int
var formatInputInt = function (value) { var formatInputInt = function (value) {
/*jshint maxcomplexity:7 */
var padding = c.ETH_PADDING * 2; var padding = c.ETH_PADDING * 2;
if (value instanceof BigNumber || typeof value === 'number') { if (value instanceof BigNumber || typeof value === 'number') {
if (typeof value === 'number') if (typeof value === 'number')

11
libjsqrc/ethereumjs/lib/requestmanager.js

@ -33,6 +33,7 @@ var c = require('./const');
*/ */
var requestManager = function() { var requestManager = function() {
var polls = []; var polls = [];
var timeout = null;
var provider; var provider;
var send = function (data) { var send = function (data) {
@ -57,9 +58,11 @@ var requestManager = function() {
provider = p; provider = p;
}; };
/*jshint maxparams:4 */
var startPolling = function (data, pollId, callback, uninstall) { var startPolling = function (data, pollId, callback, uninstall) {
polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall}); polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
}; };
/*jshint maxparams:3 */
var stopPolling = function (pollId) { var stopPolling = function (pollId) {
for (var i = polls.length; i--;) { for (var i = polls.length; i--;) {
@ -75,6 +78,12 @@ var requestManager = function() {
poll.uninstall(poll.id); poll.uninstall(poll.id);
}); });
polls = []; polls = [];
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
poll();
}; };
var poll = function () { var poll = function () {
@ -85,7 +94,7 @@ var requestManager = function() {
} }
data.callback(result); data.callback(result);
}); });
setTimeout(poll, c.ETH_POLLING_TIMEOUT); timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT);
}; };
poll(); poll();

1
libjsqrc/ethereumjs/lib/utils.js

@ -107,6 +107,7 @@ var filterEvents = function (json) {
/// TODO: use BigNumber.js to parse int /// TODO: use BigNumber.js to parse int
/// TODO: add tests for it! /// TODO: add tests for it!
var toEth = function (str) { var toEth = function (str) {
/*jshint maxcomplexity:7 */
var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str; var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
var unit = 0; var unit = 0;
var units = c.ETH_UNITS; var units = c.ETH_UNITS;

4
libjsqrc/ethereumjs/lib/web3.js

@ -80,12 +80,14 @@ var setupProperties = function (obj, properties) {
}); });
}; };
/*jshint maxparams:4 */
var startPolling = function (method, id, callback, uninstall) { var startPolling = function (method, id, callback, uninstall) {
web3.manager.startPolling({ web3.manager.startPolling({
method: method, method: method,
params: [id] params: [id]
}, id, callback, uninstall); }, id, callback, uninstall);
}; };
/*jshint maxparams:3 */
var stopPolling = function (id) { var stopPolling = function (id) {
web3.manager.stopPolling(id); web3.manager.stopPolling(id);
@ -143,12 +145,14 @@ var web3 = {
/// @param indexed is optional, this is an object with optional event indexed params /// @param indexed is optional, this is an object with optional event indexed params
/// @param options is optional, this is an object with optional event options ('max'...) /// @param options is optional, this is an object with optional event options ('max'...)
/// TODO: fix it, 4 params? no way /// TODO: fix it, 4 params? no way
/*jshint maxparams:4 */
watch: function (fil, indexed, options, formatter) { watch: function (fil, indexed, options, formatter) {
if (fil._isEvent) { if (fil._isEvent) {
return fil(indexed, options); return fil(indexed, options);
} }
return filter(fil, ethWatch, formatter); return filter(fil, ethWatch, formatter);
} }
/*jshint maxparams:3 */
}, },
/// db object prototype /// db object prototype

1
libjsqrc/ethereumjs/package.json

@ -9,7 +9,6 @@
}, },
"dependencies": { "dependencies": {
"bignumber.js": ">=2.0.0", "bignumber.js": ">=2.0.0",
"ws": "*",
"xmlhttprequest": "*" "xmlhttprequest": "*"
}, },
"devDependencies": { "devDependencies": {

Loading…
Cancel
Save