sync api tests running, removed unused pieces of code
This commit is contained in:
81
lib/web3.js
81
lib/web3.js
@ -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);
|
||||
|
Reference in New Issue
Block a user