diff options
author | Marian Oancea <contact@siteshop.ro> | 2014-11-10 19:57:49 +0800 |
---|---|---|
committer | Marian Oancea <contact@siteshop.ro> | 2014-11-10 19:57:49 +0800 |
commit | c91e4afe6c94b46bb717951bf96fd491ca817d9b (patch) | |
tree | 6ddad3fd0de440ee964dc31da3b46af7cb2c54e4 | |
parent | a2d8b8928949c589ad0282fbb1b9abf783f53c98 (diff) | |
parent | e3ad9be4c8053c18ed30775d62692f6fe91b1451 (diff) | |
download | go-tangerine-c91e4afe6c94b46bb717951bf96fd491ca817d9b.tar go-tangerine-c91e4afe6c94b46bb717951bf96fd491ca817d9b.tar.gz go-tangerine-c91e4afe6c94b46bb717951bf96fd491ca817d9b.tar.bz2 go-tangerine-c91e4afe6c94b46bb717951bf96fd491ca817d9b.tar.lz go-tangerine-c91e4afe6c94b46bb717951bf96fd491ca817d9b.tar.xz go-tangerine-c91e4afe6c94b46bb717951bf96fd491ca817d9b.tar.zst go-tangerine-c91e4afe6c94b46bb717951bf96fd491ca817d9b.zip |
fix merge conflicts
-rw-r--r-- | lib/httprpc.js | 5 | ||||
-rw-r--r-- | lib/main.js | 26 |
2 files changed, 18 insertions, 13 deletions
diff --git a/lib/httprpc.js b/lib/httprpc.js index c1ee0f02a..99f02b532 100644 --- a/lib/httprpc.js +++ b/lib/httprpc.js @@ -45,7 +45,8 @@ if(process.env.NODE_ENV !== "build") { return { _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; this.sendRequest(payload, function (request) { 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; } self.handlers.forEach(function (handler) { diff --git a/lib/main.js b/lib/main.js index 08eb722e2..95581c2be 100644 --- a/lib/main.js +++ b/lib/main.js @@ -155,15 +155,15 @@ return {call: call, args: args}; }).then(function (request) { return new Promise(function (resolve, reject) { - web3.provider.send(request, function (result) { - if (result || typeof result === "boolean") { + web3.provider.send(request, function (err, result) { + if (!err) { resolve(result); return; } - reject(result); + reject(err); }); }); - }).catch(function( err) { + }).catch(function(err) { console.error(err); }); }; @@ -175,8 +175,12 @@ var proto = {}; proto.get = function () { return new Promise(function(resolve, reject) { - web3.provider.send({call: property.getter}, function(result) { - resolve(result); + web3.provider.send({call: property.getter}, function(err, result) { + if (!err) { + resolve(result); + return; + } + reject(err); }); }); }; @@ -184,12 +188,12 @@ proto.set = function (val) { return flattenPromise([val]).then(function (args) { return new Promise(function (resolve) { - web3.provider.send({call: property.setter, args: args}, function (result) { - if (result) { + web3.provider.send({call: property.setter, args: args}, function (err, result) { + if (!err) { resolve(result); - } else { - reject(result); + return; } + reject(err); }); }); }).catch(function (err) { @@ -440,7 +444,7 @@ if(data._id) { var cb = web3._callbacks[data._id]; if (cb) { - cb.call(this, data.data); + cb.call(this, data.error, data.data) delete web3._callbacks[data._id]; } } |