Merge pull request #435 from clark800/consistency

Don't show flags that are set to false
This commit is contained in:
sublimator
2015-07-21 09:06:05 +07:00
7 changed files with 38 additions and 20 deletions

View File

@@ -27,7 +27,8 @@
"noDirectRipple": {
"description": "A boolean that can be set to true if paths are specified and the sender would like the Ripple Network to disregard any direct paths from the source_account to the destination_account. This may be used to take advantage of an arbitrage opportunity or by gateways wishing to issue balances from a hot wallet to a user who has mistakenly set a trustline directly to the hot wallet",
"type": "boolean"
}
},
"limitQuality": {"type": "boolean"}
},
"required": ["source", "destination"],
"additionalProperties": false

View File

@@ -10,16 +10,16 @@ function parseAccountTrustline(trustline) {
counterparty: trustline.account,
qualityIn: trustline.quality_in || undefined,
qualityOut: trustline.quality_out || undefined,
disableRippling: trustline.no_ripple,
frozen: trustline.freeze,
authorized: trustline.authorized
ripplingDisabled: trustline.no_ripple || undefined,
frozen: trustline.freeze || undefined,
authorized: trustline.authorized || undefined
});
// 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
ripplingDisabled: trustline.no_ripple_peer || undefined,
frozen: trustline.freeze_peer || undefined,
authorized: trustline.peer_authorized || undefined
});
const state = {
balance: trustline.balance

View File

@@ -13,6 +13,10 @@ function isNoDirectRipple(tx) {
return (tx.Flags & Transaction.flags.Payment.NoRippleDirect) !== 0;
}
function isQualityLimited(tx) {
return (tx.Flags & Transaction.flags.Payment.LimitQuality) !== 0;
}
function parsePaymentMemos(tx) {
if (!Array.isArray(tx.Memos) || tx.Memos.length === 0) {
return undefined;
@@ -48,7 +52,8 @@ function parsePayment(tx: Object): Object {
invoiceID: tx.InvoiceID,
paths: tx.Paths ? JSON.stringify(tx.Paths) : undefined,
allowPartialPayment: isPartialPayment(tx) || undefined,
noDirectRipple: isNoDirectRipple(tx) || undefined
noDirectRipple: isNoDirectRipple(tx) || undefined,
limitQuality: isQualityLimited(tx) || undefined
});
}

View File

@@ -4,19 +4,30 @@ const assert = require('assert');
const utils = require('./utils');
const flags = utils.core.Transaction.flags.TrustSet;
function parseFlag(flagsValue, trueValue, falseValue) {
if (flagsValue & trueValue) {
return true;
}
if (flagsValue & falseValue) {
return false;
}
return undefined;
}
function parseTrustline(tx: Object): Object {
assert(tx.TransactionType === 'TrustSet');
return {
return utils.removeUndefined({
limit: tx.LimitAmount.value,
currency: tx.LimitAmount.currency,
counterparty: tx.LimitAmount.issuer,
qualityIn: tx.QualityIn,
qualityOut: tx.QualityOut,
disableRippling: (tx.Flags & flags.NoRipple) !== 0,
frozen: (tx.Flags & flags.SetFreeze) !== 0,
authorized: (tx.Flags & flags.SetAuth) !== 0
};
ripplingDisabled: parseFlag(
tx.Flags, flags.SetNoRipple, flags.ClearNoRipple),
frozen: parseFlag(tx.Flags, flags.SetFreeze, flags.ClearFreeze),
authorized: parseFlag(tx.Flags, flags.SetAuth, 0)
});
}
module.exports = parseTrustline;

View File

@@ -71,6 +71,9 @@ function createPaymentTransaction(account, payment) {
if (payment.noDirectRipple) {
transaction.setFlags(['NoRippleDirect']);
}
if (payment.limitQuality) {
transaction.setFlags(['LimitQuality']);
}
if (isSendMaxAllowed(payment)) {
const maxValue = new BigNumber(payment.source.amount.value)
.plus(payment.source.slippage || 0).toString();