Merge pull request #6 from cubedro/develop

Changes from debris
poc8
Marian OANCΞA 10 years ago
commit 67e3eff806
  1. 5
      lib/httprpc.js
  2. 27
      lib/main.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) {

@ -155,12 +155,12 @@
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) {
@ -175,8 +175,12 @@
var proto = {};
proto.get = function () {
return new Promise(function(resolve, reject) {
web3.provider.send({call: property.getter}, function(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) {
@ -219,6 +223,8 @@
// Find termination
var str = "";
var i = 0, l = hex.length;
if (hex.substring(0, 2) == '0x')
i = 2;
for(; i < l; i+=2) {
var code = hex.charCodeAt(i);
if(code === 0) {
@ -240,7 +246,8 @@
var hex = this.toHex(str);
while(hex.length < pad*2)
hex += "00";
return hex;
return "0x" + hex;
},
eth: {
@ -440,7 +447,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];
}
}

Loading…
Cancel
Save