sync api tests running, removed unused pieces of code

This commit is contained in:
Marek Kotewicz 2015-01-21 20:43:20 +01:00
parent fc986a3fbe
commit ceb4357a8d
10 changed files with 9 additions and 173 deletions

84
dist/ethereum.js vendored

@ -731,7 +731,8 @@ ProviderManager.prototype.send = function(data) {
this.id++;
if (this.provider === undefined) {
console.error("provider is not set");
console.error('provider is not set');
return JSON.stringify({result: 'error, provider is not set'});
}
return this.provider.send(data);
@ -808,48 +809,6 @@ module.exports = ProviderManager;
* @date 2014
*/
/// Recursively resolves all promises in given object and replaces the resolved values with promises
/// @param any object/array/promise/anything else..
/// @returns (resolves) object with replaced promises with their result
function flattenPromise (obj) {
if (obj instanceof Promise) {
return Promise.resolve(obj);
}
if (obj instanceof Array) {
return new Promise(function (resolve) {
var promises = obj.map(function (o) {
return flattenPromise(o);
});
return Promise.all(promises).then(function (res) {
for (var i = 0; i < obj.length; i++) {
obj[i] = res[i];
}
resolve(obj);
});
});
}
if (obj instanceof Object) {
return new Promise(function (resolve) {
var keys = Object.keys(obj);
var promises = keys.map(function (key) {
return flattenPromise(obj[key]);
});
return Promise.all(promises).then(function (res) {
for (var i = 0; i < keys.length; i++) {
obj[keys[i]] = res[i];
}
resolve(obj);
});
});
}
return Promise.resolve(obj);
}
/// @returns an array of objects describing web3 api methods
var web3Methods = function () {
return [
@ -964,22 +923,6 @@ var setupMethods = function (obj, methods) {
result = JSON.parse(result);
return result.result;
//return flattenPromise(Array.prototype.slice.call(arguments)).then(function (args) {
//var call = typeof method.call === "function" ? method.call(args) : method.call;
//return {call: call, args: args};
//}).then(function (request) {
//return new Promise(function (resolve, reject) {
//web3.provider.send(request, function (err, result) {
//if (!err) {
//resolve(result);
//return;
//}
//reject(err);
//});
//});
//}).catch(function(err) {
//console.error(err);
//});
};
});
};
@ -997,16 +940,6 @@ var setupProperties = function (obj, properties) {
result = JSON.parse(result);
return result.result;
//return new Promise(function(resolve, reject) {
//web3.provider.send({call: property.getter}, function(err, result) {
//if (!err) {
//resolve(result);
//return;
//}
//reject(err);
//});
//});
};
if (property.setter) {
proto.set = function (val) {
@ -1018,19 +951,6 @@ var setupProperties = function (obj, properties) {
result = JSON.parse(result);
return result.result;
//return flattenPromise([val]).then(function (args) {
//return new Promise(function (resolve) {
//web3.provider.send({call: property.setter, args: args}, function (err, result) {
//if (!err) {
//resolve(result);
//return;
//}
//reject(err);
//});
//});
//}).catch(function (err) {
//console.error(err);
//});
};
}
Object.defineProperty(obj, property.name, proto);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -63,7 +63,8 @@ ProviderManager.prototype.send = function(data) {
this.id++;
if (this.provider === undefined) {
console.error("provider is not set");
console.error('provider is not set');
return JSON.stringify({result: 'error, provider is not set'});
}
return this.provider.send(data);

@ -23,48 +23,6 @@
* @date 2014
*/
/// Recursively resolves all promises in given object and replaces the resolved values with promises
/// @param any object/array/promise/anything else..
/// @returns (resolves) object with replaced promises with their result
function flattenPromise (obj) {
if (obj instanceof Promise) {
return Promise.resolve(obj);
}
if (obj instanceof Array) {
return new Promise(function (resolve) {
var promises = obj.map(function (o) {
return flattenPromise(o);
});
return Promise.all(promises).then(function (res) {
for (var i = 0; i < obj.length; i++) {
obj[i] = res[i];
}
resolve(obj);
});
});
}
if (obj instanceof Object) {
return new Promise(function (resolve) {
var keys = Object.keys(obj);
var promises = keys.map(function (key) {
return flattenPromise(obj[key]);
});
return Promise.all(promises).then(function (res) {
for (var i = 0; i < keys.length; i++) {
obj[keys[i]] = res[i];
}
resolve(obj);
});
});
}
return Promise.resolve(obj);
}
/// @returns an array of objects describing web3 api methods
var web3Methods = function () {
return [
@ -179,22 +137,6 @@ var setupMethods = function (obj, methods) {
result = JSON.parse(result);
return result.result;
//return flattenPromise(Array.prototype.slice.call(arguments)).then(function (args) {
//var call = typeof method.call === "function" ? method.call(args) : method.call;
//return {call: call, args: args};
//}).then(function (request) {
//return new Promise(function (resolve, reject) {
//web3.provider.send(request, function (err, result) {
//if (!err) {
//resolve(result);
//return;
//}
//reject(err);
//});
//});
//}).catch(function(err) {
//console.error(err);
//});
};
});
};
@ -212,16 +154,6 @@ var setupProperties = function (obj, properties) {
result = JSON.parse(result);
return result.result;
//return new Promise(function(resolve, reject) {
//web3.provider.send({call: property.getter}, function(err, result) {
//if (!err) {
//resolve(result);
//return;
//}
//reject(err);
//});
//});
};
if (property.setter) {
proto.set = function (val) {
@ -233,19 +165,6 @@ var setupProperties = function (obj, properties) {
result = JSON.parse(result);
return result.result;
//return flattenPromise([val]).then(function (args) {
//return new Promise(function (resolve) {
//web3.provider.send({call: property.setter, args: args}, function (err, result) {
//if (!err) {
//resolve(result);
//return;
//}
//reject(err);
//});
//});
//}).catch(function (err) {
//console.error(err);
//});
};
}
Object.defineProperty(obj, property.name, proto);

@ -3,7 +3,6 @@ require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
describe('db', function() {

@ -3,7 +3,6 @@ require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
describe('eth', function() {

@ -3,7 +3,6 @@ require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
describe('shh', function() {

@ -8,7 +8,7 @@ var methodExists = function (object, method) {
var propertyExists = function (object, property) {
it('should have property ' + property + ' implemented', function() {
assert.equal('object', typeof object[property], 'property ' + property + ' is not implemented');
assert.notEqual('undefined', typeof object[property], 'property ' + property + ' is not implemented');
});
};

@ -3,7 +3,6 @@ require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
u.methodExists(web3, 'sha3');