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

[FIX] incoming trust line fix (RT-3392) #2527

Merged
merged 1 commit into from
Jun 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.controller.js');
Expand Down Expand Up @@ -156,6 +157,8 @@ var app = angular
var rippleclient = window.rippleclient = {};
rippleclient.app = app;
rippleclient.types = types;
// for unit tests
rippleclient.rewriter = rewriter;

// for unit tests
rippleclient.tabs = {};
Expand Down
18 changes: 7 additions & 11 deletions src/js/util/jsonrewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,16 @@ 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/util/jsonRewriterSpec.js

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