diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-27 16:36:39 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-27 16:36:39 +0800 |
commit | 1f5a6f13419415b4c05519e126eedcdf815aff7c (patch) | |
tree | de2d9551d3746ab3e4c8c38501ae0a1b6eac09d5 /lib | |
parent | d223ac0379c4c1f8c209e777ec9ed63384590157 (diff) | |
parent | da4c2d530d6f9b8ba54221c6812f77766a33fed6 (diff) | |
download | dexon-1f5a6f13419415b4c05519e126eedcdf815aff7c.tar.gz dexon-1f5a6f13419415b4c05519e126eedcdf815aff7c.tar.zst dexon-1f5a6f13419415b4c05519e126eedcdf815aff7c.zip |
Merge branch 'develop' into cpp
Conflicts:
dist/ethereum.js.map
dist/ethereum.min.js
Diffstat (limited to 'lib')
-rw-r--r-- | lib/abi.js | 4 | ||||
-rw-r--r-- | lib/contract.js | 6 | ||||
-rw-r--r-- | lib/filter.js | 6 | ||||
-rw-r--r-- | lib/httpsync.js | 4 | ||||
-rw-r--r-- | lib/local.js | 18 | ||||
-rw-r--r-- | lib/providermanager.js | 10 | ||||
-rw-r--r-- | lib/web3.js | 2 |
7 files changed, 37 insertions, 13 deletions
diff --git a/lib/abi.js b/lib/abi.js index 177a146b0..d81c2f0c3 100644 --- a/lib/abi.js +++ b/lib/abi.js @@ -128,7 +128,7 @@ var formatInputReal = function (value) { var dynamicTypeBytes = function (type, value) { // TODO: decide what to do with array of strings - if (arrayType(type) || type == 'string') // only string itself that is dynamic; stringX is static length. + if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length. return formatInputInt(value.length); return ""; }; @@ -251,7 +251,7 @@ var formatOutputAddress = function (value) { }; var dynamicBytesLength = function (type) { - if (arrayType(type) || type == 'string') // only string itself that is dynamic; stringX is static length. + if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length. return ETH_PADDING * 2; return 0; }; diff --git a/lib/contract.js b/lib/contract.js index 95cc7bbd6..efee00cd1 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -53,7 +53,7 @@ var contract = function (address, desc) { // prototype, so we make it so as a workaround. if (method.name.indexOf('(') === -1) { var displayName = method.name; - var typeName = method.inputs.map(function(i){return i.type}).join(); + var typeName = method.inputs.map(function(i){return i.type; }).join(); method.name = displayName + '(' + typeName + ')'; } }); @@ -120,9 +120,9 @@ var contract = function (address, desc) { var ret = outputParser[displayName][typeName](output); if (collapse) { - if (ret.length == 1) + if (ret.length === 1) ret = ret[0]; - else if (ret.length == 0) + else if (ret.length === 0) ret = null; } return ret; diff --git a/lib/filter.js b/lib/filter.js index 079c25049..8c7dc6e33 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -47,8 +47,10 @@ Filter.prototype.changed = function(callback) { /// trigger calling new message from people Filter.prototype.trigger = function(messages) { - for(var i = 0; i < this.callbacks.length; i++) { - this.callbacks[i].call(this, messages); + for (var i = 0; i < this.callbacks.length; i++) { + for (var j = 0; j < messages; j++) { + this.callbacks[i].call(this, messages[j]); + } } }; diff --git a/lib/httpsync.js b/lib/httpsync.js index 67a3988f9..a638cfe94 100644 --- a/lib/httpsync.js +++ b/lib/httpsync.js @@ -21,6 +21,10 @@ * @date 2014 */ +if (process.env.NODE_ENV !== 'build') { + var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line +} + var HttpSyncProvider = function (host) { this.handlers = []; this.host = host || 'http://localhost:8080'; diff --git a/lib/local.js b/lib/local.js new file mode 100644 index 000000000..30cd14df2 --- /dev/null +++ b/lib/local.js @@ -0,0 +1,18 @@ +var addressName = {"0x12378912345789": "Gav", "0x57835893478594739854": "Jeff"}; +var nameAddress = {}; + +for (var prop in addressName) { + if (addressName.hasOwnProperty(prop)) { + nameAddress[addressName[prop]] = prop; + } +} + +var local = { + addressBook:{ + byName: addressName, + byAddress: nameAddress + } +}; + +if (typeof(module) !== "undefined") + module.exports = local; diff --git a/lib/providermanager.js b/lib/providermanager.js index 83e11605b..1a550e5f4 100644 --- a/lib/providermanager.js +++ b/lib/providermanager.js @@ -49,15 +49,15 @@ var ProviderManager = function() { result = JSON.parse(result); - // dont call the callback if result is an error, empty array or false - if (result.error || (result.result instanceof Array ? result.result.length === 0 : !result.result)) { + // dont call the callback if result is not an array, or empty one + if (result.error || !(result.result instanceof Array) || result.result.length === 0) { return; } - data.callback(result); + data.callback(result.result); }); } - setTimeout(poll, 12000); + setTimeout(poll, 1000); }; poll(); }; @@ -70,7 +70,7 @@ ProviderManager.prototype.send = function(data) { if (this.provider === undefined) { console.error('provider is not set'); - return undefined; + return null; } //TODO: handle error here? diff --git a/lib/web3.js b/lib/web3.js index fde3cce75..7cf624c9c 100644 --- a/lib/web3.js +++ b/lib/web3.js @@ -145,7 +145,7 @@ var shhWatchMethods = function () { return [ { name: 'newFilter', call: 'shh_newFilter' }, { name: 'uninstallFilter', call: 'shh_uninstallFilter' }, - { name: 'getMessage', call: 'shh_getMessages' } + { name: 'getMessages', call: 'shh_getMessages' } ]; }; |