From 13b7c9bfbb58c2b410382d102b72bbd06d1a0fd0 Mon Sep 17 00:00:00 2001 From: wltsmrz Date: Wed, 26 Jun 2013 03:41:46 +0900 Subject: [PATCH] Revert "Wrap JSON.parse in try/catch" This reverts commit 67041201053b8ca5bfe90defa5318ee018d6c171. --- src/js/ripple/remote.js | 85 +++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/src/js/ripple/remote.js b/src/js/ripple/remote.js index ffa752a4..2c286ffa 100644 --- a/src/js/ripple/remote.js +++ b/src/js/ripple/remote.js @@ -45,8 +45,8 @@ var Request = function (remote, command) { this.remote = remote; this.requested = false; this.message = { - 'command': command, - 'id': void(0) + 'command' : command, + 'id' : void(0), }; }; @@ -108,7 +108,7 @@ Request.prototype.ledger_select = function (ledger_spec) { if (String(ledger_spec).length > 12) { this.message.ledger_hash = ledger_spec; } else { - this.message.ledger_index = ledger_spec; + this.message.ledger_index = ledger_spec; } } @@ -132,8 +132,8 @@ Request.prototype.index = function (hash) { // --> seq : sequence number of transaction creating offer (integer) Request.prototype.offer_id = function (account, seq) { this.message.offer = { - 'account': UInt160.json_rewrite(account), - 'seq': seq + 'account' : UInt160.json_rewrite(account), + 'seq' : seq }; return this; @@ -185,19 +185,20 @@ Request.prototype.ripple_state = function (account, issuer, currency) { }; Request.prototype.accounts = function (accounts, realtime) { - if (!Array.isArray(accounts)) { - accounts = [ accounts ]; + if (typeof accounts !== 'object') { + accounts = [accounts]; } // Process accounts parameters - var procAccounts = accounts.map(function(account) { - return UInt160.json_rewrite(account); - }); + var procAccounts = []; + for (var i = 0, l = accounts.length; i < l; i++) { + procAccounts.push(UInt160.json_rewrite(accounts[i])); + } if (realtime) { this.message.rt_accounts = procAccounts; } else { - this.message.accounts = procAccounts; + this.message.accounts = procAccounts; } return this; @@ -313,7 +314,7 @@ var Remote = function (opts, trace) { // Local signing implies local fees and sequences if (this.local_signing) { this.local_sequence = true; - this.local_fee = true; + this.local_fee = true; } this._servers = []; @@ -326,6 +327,7 @@ var Remote = function (opts, trace) { // Otherwise, clear it to have it automatically refreshed from the network. // account : { seq : __ } + }; // Hash map of Account objects by AccountId. @@ -349,31 +351,33 @@ var Remote = function (opts, trace) { } }; - // Support old API if (!('servers' in opts)) { - opts.servers = [ { - host: opts.websocket_ip, - port: opts.websocket_port, - secure: opts.websocket_ssl, - trusted: opts.trusted - } ] + opts.servers = [ + { + host: opts.websocket_ip, + port: opts.websocket_port, + secure: opts.websocket_ssl, + trusted: opts.trusted + } + ] } - // Initialize servers - opts.servers.forEach(function(server) { - self.add_server(server); - }); + for (var i=0; i