Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
[FIX] fix parsing incoming trust lines
Browse files Browse the repository at this point in the history
JsonRewriter: correctly parse limit, limit_peer and noRipple properties of
incoming trust line transaction
Trust Tab: correctly show "Rippling" field for incoming trust lines
  • Loading branch information
darkdarkdragon committed Feb 4, 2015
1 parent 70f67ba commit 7de0e1b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/js/entry/web.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var types = require('../util/types');
var types = require('../util/types'),
rewriter = require('../util/jsonrewriter');

// Load app modules
require('../controllers/app');
Expand Down Expand Up @@ -136,6 +137,8 @@ var app = angular
var rippleclient = window.rippleclient = {};
rippleclient.app = app;
rippleclient.types = types;
// for unit tests
rippleclient.rewriter = rewriter;

// Install basic page template
angular.element('body').prepend(require('../../jade/client/index.jade')());
Expand Down
5 changes: 4 additions & 1 deletion src/js/tabs/trust.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ TrustTab.prototype.angular = function (module)
}

obj[line.currency].components.push(line);

// correctly show "Rippling" flag for incoming trust lines
if (_.has(line, 'no_ripple_peer')) {
line.no_ripple = line.no_ripple_peer;
}
});

$scope.accountLines = obj;
Expand Down
17 changes: 7 additions & 10 deletions src/js/util/jsonrewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,20 +397,17 @@ var JsonRewriter = module.exports = {

var high = node.fields.HighLimit;
var low = node.fields.LowLimit;
var viewHigh = high.issuer === account;

var which = high.issuer === account ? 'HighNoRipple' : 'LowNoRipple';
var which = obj.transaction.type === 'trusting' ? (viewHigh ? 'HighNoRipple' : 'LowNoRipple') :
(viewHigh ? 'LowNoRipple' : 'HighNoRipple');

// New trust line
if (node.diffType === 'CreatedNode') {
effect.limit = ripple.Amount.from_json(high.value > 0 ? high : low);
effect.limit_peer = ripple.Amount.from_json(high.value > 0 ? low : high);

if ((high.value > 0 && high.issuer === account)
|| (low.value > 0 && low.issuer === account)) {
effect.type = 'trust_create_local';
} else {
effect.type = 'trust_create_remote';
}
effect.limit = ripple.Amount.from_json(viewHigh ? high : low);
effect.limit_peer = ripple.Amount.from_json(viewHigh ? low : high);

effect.type = obj.transaction.type === 'trusting' ? 'trust_create_local' : 'trust_create_remote';
}

// Modified trust line
Expand Down
25 changes: 25 additions & 0 deletions test/unit/utilities/jsonRewriterSpec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7de0e1b

Please sign in to comment.