From fc0611916ea738bc9c7e95e25780a6f7511a593e Mon Sep 17 00:00:00 2001 From: newcoin Date: Sun, 10 Feb 2013 23:52:42 -0800 Subject: [PATCH 1/8] JS: Fixes for load. --- src/js/remote.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/remote.js b/src/js/remote.js index 5bda588f5f..efe050bfa0 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -577,12 +577,12 @@ Remote.prototype._connect_message = function (ws, json) { if ('load_base' in message && 'load_factor' in message - && (message.load_base !== self._load_base || message.load_factor != self._load_factor)) + && (message.load_base !== this._load_base || message.load_factor != this._load_factor)) { - self._load_base = message.load_base; - self._load_factor = message.load_factor; + this._load_base = message.load_base; + this._load_factor = message.load_factor; - this.emit('load', { 'load_base' : self._load_base, 'load_factor' : self.load_factor }); + this.emit('load', { 'load_base' : this._load_base, 'load_factor' : this.load_factor }); } break; From fbc619c2e3de95b9e3aa34c382f57046df695652 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sun, 17 Feb 2013 21:07:09 -0800 Subject: [PATCH 2/8] Move gateways option to opts instead of config. --- src/js/uint.js | 4 ++-- src/js/uint160.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/uint.js b/src/js/uint.js index c02d8b27ca..d95ccb51fa 100644 --- a/src/js/uint.js +++ b/src/js/uint.js @@ -20,8 +20,8 @@ var UInt = function () { this._value = NaN; }; -UInt.json_rewrite = function (j) { - return this.from_json(j).to_json(); +UInt.json_rewrite = function (j, opts) { + return this.from_json(j).to_json(opts); }; // Return a new UInt from j. diff --git a/src/js/uint160.js b/src/js/uint160.js index ee17524dc6..12c7ff04c6 100644 --- a/src/js/uint160.js +++ b/src/js/uint160.js @@ -59,8 +59,8 @@ UInt160.prototype.to_json = function (opts) { var output = Base.encode_check(Base.VER_ACCOUNT_ID, this.to_bytes()); - if (config.gateways && output in config.gateways && !opts.no_gateway) - output = config.gateways[output]; + if (opts.gateways && output in opts.gateways) + output = opts.gateways[output]; return output; }; From 0d18274a695cf0c64e86dd51c7d76987b8ae5671 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sun, 17 Feb 2013 22:04:44 -0800 Subject: [PATCH 3/8] JS: Add is_positive() to Amount. --- src/js/amount.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/js/amount.js b/src/js/amount.js index bbaea1bbc5..a3f1ac70c3 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -418,6 +418,10 @@ Amount.prototype.is_negative = function () { : false; // NaN is not negative }; +Amount.prototype.is_positive = function () { + return !this.is_zero() && !this.is_negative(); +}; + // Only checks the value. Not the currency and issuer. Amount.prototype.is_valid = function () { return this._value instanceof BigInteger; From 2ad9ccdc10d6516c51d0d8bde816f91518a4149d Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sun, 17 Feb 2013 22:57:12 -0800 Subject: [PATCH 4/8] JS: Amount set_currency() nows sets _is_native. --- src/js/amount.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/amount.js b/src/js/amount.js index a3f1ac70c3..408f85818d 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -699,6 +699,7 @@ Amount.prototype.set_currency = function (c) { { c.copyTo(this._currency); } + this._is_native = this._currency.is_native(); return this; }; From 4c8d405cc144f387d5c454968c441a54c90c3bd1 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sun, 17 Feb 2013 23:19:31 -0800 Subject: [PATCH 5/8] JS: Fix add of zero for non-XRP. --- src/js/amount.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/js/amount.js b/src/js/amount.js index 408f85818d..39fab475ac 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -111,7 +111,17 @@ Amount.prototype.add = function (v) { result._is_negative = s.compareTo(BigInteger.ZERO) < 0; result._value = result._is_negative ? s.negate() : s; } - else { + else if (v.is_zero()) { + result = this; + } + else if (this.is_zero()) { + result = new Amount(); + result._is_native = false; + result._currency = this._currency.clone(); + result._issuer = this._issuer.clone(); + } + else + { var v1 = this._is_negative ? this._value.negate() : this._value; var o1 = this._offset; var v2 = v._is_negative ? v._value.negate() : v._value; From 68403ae1a2eb6fe777ae5a298651df9a0b84ae88 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Mon, 18 Feb 2013 00:41:57 -0800 Subject: [PATCH 6/8] JS: Fix Add for Amount. --- src/js/amount.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/amount.js b/src/js/amount.js index 39fab475ac..a242d82474 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -115,8 +115,8 @@ Amount.prototype.add = function (v) { result = this; } else if (this.is_zero()) { - result = new Amount(); - result._is_native = false; + result = v.clone(); + // YYY Why are these cloned? We never modify them. result._currency = this._currency.clone(); result._issuer = this._issuer.clone(); } From 594e3d7f3f48395166458ac1d3e7dd3d203c0080 Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Mon, 18 Feb 2013 14:59:22 +0100 Subject: [PATCH 7/8] JS: Correct object reference in Account. --- src/js/account.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/js/account.js b/src/js/account.js index 93347682a0..59eb95c911 100644 --- a/src/js/account.js +++ b/src/js/account.js @@ -29,22 +29,22 @@ var Account = function (remote, account) { this.on('newListener', function (type, listener) { if (Account.subscribe_events.indexOf(type) !== -1) { - if (!this._subs && 'open' === this._remote._online_state) { - this._remote.request_subscribe() - .accounts(this._account_id) + if (!self._subs && 'open' === self._remote._online_state) { + self._remote.request_subscribe() + .accounts(self._account_id) .request(); } - this._subs += 1; + self._subs += 1; } }); this.on('removeListener', function (type, listener) { if (Account.subscribe_events.indexOf(type) !== -1) { - this._subs -= 1; + self._subs -= 1; - if (!this._subs && 'open' === this._remote._online_state) { - this._remote.request_unsubscribe() - .accounts(this._account_id) + if (!self._subs && 'open' === self._remote._online_state) { + self._remote.request_unsubscribe() + .accounts(self._account_id) .request(); } } @@ -52,8 +52,8 @@ var Account = function (remote, account) { this._remote.on('connect', function () { if (self._subs) { - this._remote.request_subscribe() - .accounts(this._account_id) + self._remote.request_subscribe() + .accounts(self._account_id) .request(); } }); From d3b7a59b91149e6fdd07ef6e958d1ecb283e7be5 Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Mon, 18 Feb 2013 15:07:27 +0100 Subject: [PATCH 8/8] CLI: Add help for account_tx. --- src/cpp/ripple/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index 4faab81028..3b57ced1f9 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -68,6 +68,7 @@ void printHelp(const po::options_description& desc) cerr << "Commands: " << endl; cerr << " account_domain_set []" << endl; cerr << " account_email_set []" << endl; + cerr << " account_tx || |( )" << endl; cerr << " account_lines || []" << endl; cerr << " account_offers || []" << endl; cerr << " account_info |" << endl;