mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-26 15:15:49 +00:00
Add getTrustlines and unit test
This commit is contained in:
30
src/api/ledger/parse/account-trustline.js
Normal file
30
src/api/ledger/parse/account-trustline.js
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
const utils = require('./utils');
|
||||
|
||||
// rippled 'account_lines' returns a different format for
|
||||
// trustlines than 'tx'
|
||||
function parseAccountTrustline(trustline) {
|
||||
const specification = utils.removeUndefined({
|
||||
limit: trustline.limit,
|
||||
currency: trustline.currency,
|
||||
counterparty: trustline.account,
|
||||
qualityIn: trustline.quality_in || undefined,
|
||||
qualityOut: trustline.quality_out || undefined,
|
||||
disableRippling: trustline.no_ripple,
|
||||
frozen: trustline.freeze,
|
||||
authorized: trustline.authorized
|
||||
});
|
||||
// rippled doesn't provide the counterparty's qualities
|
||||
const counterparty = utils.removeUndefined({
|
||||
limit: trustline.limit_peer,
|
||||
disableRippling: trustline.no_ripple_peer,
|
||||
frozen: trustline.freeze_peer,
|
||||
authorized: trustline.peer_authorized
|
||||
});
|
||||
const state = {
|
||||
balance: trustline.balance
|
||||
};
|
||||
return {specification, counterparty, state};
|
||||
}
|
||||
|
||||
module.exports = parseAccountTrustline;
|
||||
@@ -13,7 +13,7 @@ function parseTrustline(tx: Object): Object {
|
||||
counterparty: tx.LimitAmount.issuer,
|
||||
qualityIn: tx.QualityIn,
|
||||
qualityOut: tx.QualityOut,
|
||||
allowRippling: (tx.Flags & flags.NoRipple) === 0,
|
||||
disableRippling: (tx.Flags & flags.NoRipple) !== 0,
|
||||
frozen: (tx.Flags & flags.SetFreeze) !== 0,
|
||||
authorized: (tx.Flags & flags.SetAuth) !== 0
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user