Merge branch 'debris-error_handling_fix' into develop
This commit is contained in:
commit
512d4ca6a4
16
README.md
16
README.md
@ -3,7 +3,7 @@
|
|||||||
This is the Ethereum compatible JavaScript API using `Promise`s
|
This is the Ethereum compatible JavaScript API using `Promise`s
|
||||||
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/Generic-JSON-RPC) spec. It's available on npm as a node module and also for bower and component as an embeddable js
|
||||||
|
|
||||||
[![Build Status][1]][2] [![dependency status][3]][4] [![dev dependency status][5]][6]
|
[![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]
|
||||||
|
|
||||||
[![browser support](https://ci.testling.com/cubedro/ethereum.js.png)](https://ci.testling.com/cubedro/ethereum.js)
|
[![browser support](https://ci.testling.com/cubedro/ethereum.js.png)](https://ci.testling.com/cubedro/ethereum.js)
|
||||||
|
|
||||||
@ -69,9 +69,11 @@ go get github.com/ethereum/go-ethereum/ethereum
|
|||||||
ethereum -ws -loglevel=4
|
ethereum -ws -loglevel=4
|
||||||
```
|
```
|
||||||
|
|
||||||
[1]: https://travis-ci.org/cubedro/ethereum.js.svg
|
[npm-image]: https://badge.fury.io/js/ethereum.js.png
|
||||||
[2]: https://travis-ci.org/cubedro/ethereum.js
|
[npm-url]: https://npmjs.org/package/ethereum.js
|
||||||
[3]: https://david-dm.org/cubedro/ethereum.js.svg
|
[travis-image]: https://travis-ci.org/cubedro/ethereum.js.svg
|
||||||
[4]: https://david-dm.org/cubedro/ethereum.js
|
[travis-url]: https://travis-ci.org/cubedro/ethereum.js
|
||||||
[5]: https://david-dm.org/cubedro/ethereum.js/dev-status.svg
|
[dep-image]: https://david-dm.org/cubedro/ethereum.js.svg
|
||||||
[6]: https://david-dm.org/cubedro/ethereum.js#info=devDependencies
|
[dep-url]: https://david-dm.org/cubedro/ethereum.js
|
||||||
|
[dep-dev-image]: https://david-dm.org/cubedro/ethereum.js/dev-status.svg
|
||||||
|
[dep-dev-url]: https://david-dm.org/cubedro/ethereum.js#info=devDependencies
|
@ -45,7 +45,8 @@ if(process.env.NODE_ENV !== "build") {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
_id: object.id,
|
_id: object.id,
|
||||||
data: object.result
|
data: object.result,
|
||||||
|
error: object.error
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ if(process.env.NODE_ENV !== "build") {
|
|||||||
var self = this;
|
var self = this;
|
||||||
this.sendRequest(payload, function (request) {
|
this.sendRequest(payload, function (request) {
|
||||||
var parsed = JSON.parse(request.responseText);
|
var parsed = JSON.parse(request.responseText);
|
||||||
if (parsed.result instanceof Array ? parsed.result.length === 0 : !parsed.result) {
|
if (parsed.error || (parsed.result instanceof Array ? parsed.result.length === 0 : !parsed.result)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.handlers.forEach(function (handler) {
|
self.handlers.forEach(function (handler) {
|
||||||
|
26
lib/main.js
26
lib/main.js
@ -155,15 +155,15 @@
|
|||||||
return {call: call, args: args};
|
return {call: call, args: args};
|
||||||
}).then(function (request) {
|
}).then(function (request) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
web3.provider.send(request, function (result) {
|
web3.provider.send(request, function (err, result) {
|
||||||
if (result || typeof result === "boolean") {
|
if (!err) {
|
||||||
resolve(result);
|
resolve(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reject(result);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(function( err) {
|
}).catch(function(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -175,8 +175,12 @@
|
|||||||
var proto = {};
|
var proto = {};
|
||||||
proto.get = function () {
|
proto.get = function () {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
web3.provider.send({call: property.getter}, function(result) {
|
web3.provider.send({call: property.getter}, function(err, result) {
|
||||||
resolve(result);
|
if (!err) {
|
||||||
|
resolve(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -184,12 +188,12 @@
|
|||||||
proto.set = function (val) {
|
proto.set = function (val) {
|
||||||
return flattenPromise([val]).then(function (args) {
|
return flattenPromise([val]).then(function (args) {
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
web3.provider.send({call: property.setter, args: args}, function (result) {
|
web3.provider.send({call: property.setter, args: args}, function (err, result) {
|
||||||
if (result) {
|
if (!err) {
|
||||||
resolve(result);
|
resolve(result);
|
||||||
} else {
|
return;
|
||||||
reject(result);
|
|
||||||
}
|
}
|
||||||
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
@ -440,7 +444,7 @@
|
|||||||
if(data._id) {
|
if(data._id) {
|
||||||
var cb = web3._callbacks[data._id];
|
var cb = web3._callbacks[data._id];
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb.call(this, data.data);
|
cb.call(this, data.error, data.data)
|
||||||
delete web3._callbacks[data._id];
|
delete web3._callbacks[data._id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user