mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Don't show flags that are set to false
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"qualityIn": 500000000,
|
||||
"qualityOut": 500000000,
|
||||
"disableRippling": true,
|
||||
"frozen": false,
|
||||
"authorized": false
|
||||
"ripplingDisabled": true
|
||||
},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"limit": "5",
|
||||
"currency": "USD",
|
||||
"counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"disableRippling": true,
|
||||
"ripplingDisabled": true,
|
||||
"frozen": true
|
||||
},
|
||||
"counterparty": {
|
||||
@@ -45,7 +45,7 @@
|
||||
"limit": "1",
|
||||
"currency": "USD",
|
||||
"counterparty": "r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X",
|
||||
"disableRippling": true
|
||||
"ripplingDisabled": true
|
||||
},
|
||||
"counterparty": {
|
||||
"limit": "0"
|
||||
@@ -59,7 +59,7 @@
|
||||
"limit": "500",
|
||||
"currency": "USD",
|
||||
"counterparty": "rfF3PNkwkq1DygW2wum2HK3RGfgkJjdPVD",
|
||||
"disableRippling": true
|
||||
"ripplingDisabled": true
|
||||
},
|
||||
"counterparty": {
|
||||
"limit": "0"
|
||||
@@ -76,7 +76,7 @@
|
||||
},
|
||||
"counterparty": {
|
||||
"limit": "100",
|
||||
"disableRippling": true
|
||||
"ripplingDisabled": true
|
||||
},
|
||||
"state": {
|
||||
"balance": "0"
|
||||
|
||||
Reference in New Issue
Block a user