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

Commit 6aa096e

Browse files
[FIX] fix parsing incoming trust lines
JsonRewriter: correctly parse limit, limit_peer and noRipple properties of incoming trust line transaction Trust Tab: correctly show "Rippling" field for incoming trust lines
1 parent 96cb62a commit 6aa096e

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

src/js/entry/web.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var types = require('../util/types');
1+
var types = require('../util/types'),
2+
rewriter = require('../util/jsonrewriter');
23

34
// Load app modules
45
require('../controllers/app');
@@ -137,6 +138,8 @@ var app = angular
137138
var rippleclient = window.rippleclient = {};
138139
rippleclient.app = app;
139140
rippleclient.types = types;
141+
// for unit tests
142+
rippleclient.rewriter = rewriter;
140143

141144
// Install basic page template
142145
angular.element('body').prepend(require('../../jade/client/index.jade')());

src/js/tabs/trust.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,10 @@ TrustTab.prototype.angular = function (module)
332332
}
333333

334334
obj[line.currency].components.push(line);
335-
335+
// correctly show "Rippling" flag for incoming trust lines
336+
if (_.has(line, 'no_ripple_peer')) {
337+
line.no_ripple = line.no_ripple_peer;
338+
}
336339
});
337340

338341
$scope.accountLines = obj;

src/js/util/jsonrewriter.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,20 +386,17 @@ var JsonRewriter = module.exports = {
386386

387387
var high = node.fields.HighLimit;
388388
var low = node.fields.LowLimit;
389+
var viewHigh = high.issuer === account;
389390

390-
var which = high.issuer === account ? 'HighNoRipple' : 'LowNoRipple';
391+
var which = obj.transaction.type == 'trusting' ? (high.issuer === account ? 'HighNoRipple' : 'LowNoRipple') :
392+
(high.issuer === account ? 'LowNoRipple' : 'HighNoRipple');
391393

392394
// New trust line
393395
if (node.diffType === 'CreatedNode') {
394-
effect.limit = ripple.Amount.from_json(high.value > 0 ? high : low);
395-
effect.limit_peer = ripple.Amount.from_json(high.value > 0 ? low : high);
396-
397-
if ((high.value > 0 && high.issuer === account)
398-
|| (low.value > 0 && low.issuer === account)) {
399-
effect.type = 'trust_create_local';
400-
} else {
401-
effect.type = 'trust_create_remote';
402-
}
396+
effect.limit = ripple.Amount.from_json(viewHigh ? high : low);
397+
effect.limit_peer = ripple.Amount.from_json(viewHigh ? low : high);
398+
399+
effect.type = obj.transaction.type == 'trusting' ? 'trust_create_local' : 'trust_create_remote';
403400
}
404401

405402
// Modified trust line

test/unit/utilities/jsonRewriterSpec.js

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)