Skip to content

Commit

Permalink
handle bad usage of getTransactions, & formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelAJay committed Sep 12, 2024
1 parent 6ebba89 commit b0e1eb5
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/xrp/XrpClientAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,30 @@ class XrpClientAdapter extends xrpl.Client {
excludeFailures
}) {
/**
* Behavior defaults to 'true', but this error is to document that 'includeRawTransactions: false' is NOT supported
* Truthiness is not sufficient for this check - it must explicitly be an equality check, & strict equality is prefered
*/
* Behavior defaults to 'true', but this error is to document that 'includeRawTransactions: false' is NOT supported
* Truthiness is not sufficient for this check - it must explicitly be an equality check, & strict equality is prefered
*/
if (includeRawTransactions === false) {
throw new Error('"includeRawTransactions: false" not supported');
}

/**
* Filtering constants with defaults
*/
const TYPES = Array.isArray(types) && types.length > 0 ?
types.reduce(( acc, cur ) => {
* Filtering constants with defaults
*/
let TYPES = SUPPORTED_TRANSACTION_TYPES;
if (Array.isArray(types)) {
if (types.length === 0) {
throw new Error('If types is included, it should include at least one supported type');
}
TYPES = types.reduce(( acc, cur ) => {
const type = cur.toLowerCase();
if (SUPPORTED_TRANSACTION_TYPES.has(type)) {
acc.add(type);
}
return acc;
}, new Set())
: SUPPORTED_TRANSACTION_TYPES;
}, new Set());
}

// Boolean option checks must be checked against type for existence instead of using fallback assignment
const INITIATED = typeof initiated === 'boolean' ? initiated : false;
const EXCLUDE_FAILURES = typeof excludeFailures === 'boolean' ? excludeFailures : true;
Expand Down

0 comments on commit b0e1eb5

Please sign in to comment.