diff --git a/src/common/connection.js b/src/common/connection.js index a344280ae2..867667fab7 100644 --- a/src/common/connection.js +++ b/src/common/connection.js @@ -77,7 +77,7 @@ class Connection extends EventEmitter { } return [data.type, data] } else if (data.type === undefined && data.error) { - return ['error', data.error, data.error_message, data] // e.g. slowDown + return ['error', data.error, data.error_message, data] // e.g. slowDown } throw new ResponseFormatError('unrecognized message type: ' + data.type) } diff --git a/src/common/constants.js b/src/common/constants.js index fbc9587efd..961967879f 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -6,7 +6,7 @@ const accountRootFlags = { RequireDestTag: 0x00020000, // require a DestinationTag for payments RequireAuth: 0x00040000, // require a authorization to hold IOUs DisallowXRP: 0x00080000, // disallow sending XRP - DisableMaster: 0x00100000, // force regular key + DisableMaster: 0x00100000, // force regular key NoFreeze: 0x00200000, // permanently disallowed freezing trustlines GlobalFreeze: 0x00400000, // trustlines globally frozen DefaultRipple: 0x00800000 @@ -36,7 +36,7 @@ const AccountFlagIndices = { const AccountFields = { EmailHash: {name: 'emailHash', encoding: 'hex', - length: 32, defaults: '0'}, + length: 32, defaults: '0'}, MessageKey: {name: 'messageKey'}, Domain: {name: 'domain', encoding: 'hex'}, TransferRate: {name: 'transferRate', defaults: 0, shift: 9} diff --git a/src/common/serverinfo.js b/src/common/serverinfo.js index 1960a4ce9b..6e2fb20aee 100644 --- a/src/common/serverinfo.js +++ b/src/common/serverinfo.js @@ -62,7 +62,7 @@ function getServerInfo(connection: Connection): Promise { } function computeFeeFromServerInfo(cushion: number, - serverInfo: GetServerInfoResponse + serverInfo: GetServerInfoResponse ): number { return (Number(serverInfo.validatedLedger.baseFeeXRP) * Number(serverInfo.loadFactor) * cushion).toString() diff --git a/src/ledger/balance-sheet.js b/src/ledger/balance-sheet.js index 140ca43a1d..54c02190a7 100644 --- a/src/ledger/balance-sheet.js +++ b/src/ledger/balance-sheet.js @@ -41,7 +41,7 @@ function formatBalanceSheet(balanceSheet): GetBalanceSheet { } if (!_.isUndefined(balanceSheet.obligations)) { result.obligations = _.map(balanceSheet.obligations, (value, currency) => - ({currency, value})) + ({currency, value})) } return result diff --git a/src/ledger/orderbook.js b/src/ledger/orderbook.js index 2644a4dc05..21509f9000 100644 --- a/src/ledger/orderbook.js +++ b/src/ledger/orderbook.js @@ -36,8 +36,8 @@ type GetOrderbook = { // account is to specify a "perspective", which affects which unfunded offers // are returned function getBookOffers(connection: Connection, account: string, - ledgerVersion?: number, limit?: number, takerGets: Issue, - takerPays: Issue + ledgerVersion?: number, limit?: number, takerGets: Issue, + takerPays: Issue ): Promise { return connection.request(utils.renameCounterpartyToIssuerInOrder({ command: 'book_offers', @@ -92,7 +92,7 @@ function formatBidsAndAsks(orderbook: Orderbook, offers) { } function getOrderbook(address: string, orderbook: Orderbook, - options: OrdersOptions = {} + options: OrdersOptions = {} ): Promise { validate.getOrderbook({address, orderbook, options}) diff --git a/src/ledger/orders.js b/src/ledger/orders.js index 4aee126971..98b4561ac5 100644 --- a/src/ledger/orders.js +++ b/src/ledger/orders.js @@ -32,7 +32,7 @@ function getOrders(address: string, options: OrdersOptions = {} return utils.ensureLedgerVersion.call(this, options).then(_options => { const getter = _.partial(requestAccountOffers, this.connection, address, - _options.ledgerVersion) + _options.ledgerVersion) return utils.getRecursive(getter, _options.limit).then(orders => _.sortBy(orders, order => order.properties.sequence)) }) diff --git a/src/ledger/parse/account-order.js b/src/ledger/parse/account-order.js index 2e0e0ed0c9..5e9cf03864 100644 --- a/src/ledger/parse/account-order.js +++ b/src/ledger/parse/account-order.js @@ -32,9 +32,9 @@ function parseAccountOrder(address: string, order: Object): Object { }) const makerExchangeRate = order.quality ? - utils.adjustQualityForXRP(order.quality.toString(), - takerGetsAmount.currency, takerPaysAmount.currency) : - computeQuality(takerGetsAmount, takerPaysAmount) + utils.adjustQualityForXRP(order.quality.toString(), + takerGetsAmount.currency, takerPaysAmount.currency) : + computeQuality(takerGetsAmount, takerPaysAmount) const properties = { maker: address, sequence: order.seq, diff --git a/src/ledger/parse/fields.js b/src/ledger/parse/fields.js index ff17276ab0..68ea37497c 100644 --- a/src/ledger/parse/fields.js +++ b/src/ledger/parse/fields.js @@ -5,7 +5,7 @@ const BigNumber = require('bignumber.js') const AccountFields = require('./utils').constants.AccountFields function parseField(info, value) { - if (info.encoding === 'hex' && !info.length) { // e.g. "domain" + if (info.encoding === 'hex' && !info.length) { // e.g. "domain" return new Buffer(value, 'hex').toString('ascii') } if (info.shift) { diff --git a/src/ledger/parse/flags.js b/src/ledger/parse/flags.js index 26e652d6db..af5c2a82f0 100644 --- a/src/ledger/parse/flags.js +++ b/src/ledger/parse/flags.js @@ -2,7 +2,7 @@ const orderFlags = { Passive: 0x00010000, - Sell: 0x00020000 // offer was placed as a sell + Sell: 0x00020000 // offer was placed as a sell } const trustlineFlags = { diff --git a/src/ledger/parse/orderbook-order.js b/src/ledger/parse/orderbook-order.js index 218be1c454..2aeae7d57f 100644 --- a/src/ledger/parse/orderbook-order.js +++ b/src/ledger/parse/orderbook-order.js @@ -30,9 +30,9 @@ function parseOrderbookOrder(order: Object): Object { } const takerGetsFunded = order.taker_gets_funded ? - parseAmount(order.taker_gets_funded) : undefined + parseAmount(order.taker_gets_funded) : undefined const takerPaysFunded = order.taker_pays_funded ? - parseAmount(order.taker_pays_funded) : undefined + parseAmount(order.taker_pays_funded) : undefined const available = utils.removeUndefined({ fundedAmount: takerGetsFunded, priceOfFundedAmount: takerPaysFunded diff --git a/src/ledger/parse/pathfind.js b/src/ledger/parse/pathfind.js index 56d3854722..5f3c209197 100644 --- a/src/ledger/parse/pathfind.js +++ b/src/ledger/parse/pathfind.js @@ -19,7 +19,7 @@ function createAdjustment(address: string, adjustmentWithoutAddress: Object) { const amountKey = _.keys(adjustmentWithoutAddress)[0] const amount = adjustmentWithoutAddress[amountKey] return _.set({address: address}, amountKey, - removeAnyCounterpartyEncoding(address, amount)) + removeAnyCounterpartyEncoding(address, amount)) } function parseAlternative(sourceAddress: string, destinationAddress: string, @@ -29,9 +29,9 @@ function parseAlternative(sourceAddress: string, destinationAddress: string, // directly to preparePayment const amounts = (alternative.destination_amount !== undefined) ? {source: {amount: parseAmount(alternative.source_amount)}, - destination: {minAmount: parseAmount(alternative.destination_amount)}} : + destination: {minAmount: parseAmount(alternative.destination_amount)}} : {source: {maxAmount: parseAmount(alternative.source_amount)}, - destination: {amount: parseAmount(destinationAmount)}} + destination: {amount: parseAmount(destinationAmount)}} return { source: createAdjustment(sourceAddress, amounts.source), diff --git a/src/ledger/parse/transaction.js b/src/ledger/parse/transaction.js index 8539f9b38e..527ac68aa5 100644 --- a/src/ledger/parse/transaction.js +++ b/src/ledger/parse/transaction.js @@ -31,8 +31,8 @@ function parseTransactionType(type) { PaymentChannelFund: 'paymentChannelFund', PaymentChannelClaim: 'paymentChannelClaim', SignerListSet: 'settings', - SetFee: 'feeUpdate', // pseudo-transaction - EnableAmendment: 'amendment' // pseudo-transaction + SetFee: 'feeUpdate', // pseudo-transaction + EnableAmendment: 'amendment' // pseudo-transaction } return mapping[type] || null } diff --git a/src/ledger/pathfind.js b/src/ledger/pathfind.js index 09285fcd56..c0ddb53b7f 100644 --- a/src/ledger/pathfind.js +++ b/src/ledger/pathfind.js @@ -88,7 +88,7 @@ function conditionallyAddDirectXRPPath(connection: Connection, address: string, } function filterSourceFundsLowPaths(pathfind: PathFind, - paths: RippledPathsResponse + paths: RippledPathsResponse ): RippledPathsResponse { if (pathfind.source.amount && pathfind.destination.amount.value === undefined && paths.alternatives) { @@ -107,7 +107,7 @@ function formatResponse(pathfind: PathFind, paths: RippledPathsResponse) { } if (paths.destination_currencies !== undefined && !_.includes(paths.destination_currencies, - pathfind.destination.amount.currency)) { + pathfind.destination.amount.currency)) { throw new NotFoundError('No paths found. ' + 'The destination_account does not accept ' + pathfind.destination.amount.currency + ', they only accept: ' + @@ -133,8 +133,8 @@ function getPaths(pathfind: PathFind): Promise { return requestPathFind(this.connection, pathfind).then(paths => conditionallyAddDirectXRPPath(this.connection, address, paths) ) - .then(paths => filterSourceFundsLowPaths(pathfind, paths)) - .then(paths => formatResponse(pathfind, paths)) + .then(paths => filterSourceFundsLowPaths(pathfind, paths)) + .then(paths => formatResponse(pathfind, paths)) } module.exports = getPaths diff --git a/src/ledger/transaction.js b/src/ledger/transaction.js index a4345dd937..94c58db6fe 100644 --- a/src/ledger/transaction.js +++ b/src/ledger/transaction.js @@ -55,17 +55,17 @@ function convertError(connection: Connection, options: TransactionOptions, if (_error instanceof errors.NotFoundError) { return utils.hasCompleteLedgerRange(connection, options.minLedgerVersion, options.maxLedgerVersion).then(hasCompleteLedgerRange => { - if (!hasCompleteLedgerRange) { - return utils.isPendingLedgerVersion( - connection, options.maxLedgerVersion) - .then(isPendingLedgerVersion => { - return isPendingLedgerVersion ? - new errors.PendingLedgerVersionError() : - new errors.MissingLedgerHistoryError() - }) - } - return _error - }) + if (!hasCompleteLedgerRange) { + return utils.isPendingLedgerVersion( + connection, options.maxLedgerVersion) + .then(isPendingLedgerVersion => { + return isPendingLedgerVersion ? + new errors.PendingLedgerVersionError() : + new errors.MissingLedgerHistoryError() + }) + } + return _error + }) } return Promise.resolve(_error) } @@ -92,11 +92,11 @@ function getTransaction(id: string, options: TransactionOptions = {} return this.connection.request(request).then(tx => attachTransactionDate(this.connection, tx) ).then(_.partial(formatResponse, _options)) - .catch(error => { - return convertError(this.connection, _options, error).then(_error => { - throw _error + .catch(error => { + return convertError(this.connection, _options, error).then(_error => { + throw _error + }) }) - }) }) } diff --git a/src/ledger/transactions.js b/src/ledger/transactions.js index d586b5b3c7..af7691f32e 100644 --- a/src/ledger/transactions.js +++ b/src/ledger/transactions.js @@ -59,7 +59,7 @@ function counterpartyFilter(filters, tx: TransactionType) { } function transactionFilter(address: string, filters: TransactionsOptions, - tx: TransactionType + tx: TransactionType ) { if (filters.excludeFailures && tx.outcome.result !== 'tesSUCCESS') { return false @@ -136,14 +136,14 @@ function checkForLedgerGaps(connection: Connection, return utils.hasCompleteLedgerRange(connection, minLedgerVersion, maxLedgerVersion).then(hasCompleteLedgerRange => { - if (!hasCompleteLedgerRange) { - throw new utils.common.errors.MissingLedgerHistoryError() - } - }) + if (!hasCompleteLedgerRange) { + throw new utils.common.errors.MissingLedgerHistoryError() + } + }) } function formatResponse(connection: Connection, options: TransactionsOptions, - transactions: GetTransactionsResponse + transactions: GetTransactionsResponse ) { const compare = options.earliestFirst ? utils.compareTransactions : _.rearg(utils.compareTransactions, 1, 0) @@ -153,7 +153,7 @@ function formatResponse(connection: Connection, options: TransactionsOptions, } function getTransactionsInternal(connection: Connection, address: string, - options: TransactionsOptions + options: TransactionsOptions ): Promise { const getter = _.partial(getAccountTx, connection, address, options) const format = _.partial(formatResponse, connection, options) diff --git a/src/transaction/escrow-creation.js b/src/transaction/escrow-creation.js index e3d7f5598c..71f36e5257 100644 --- a/src/transaction/escrow-creation.js +++ b/src/transaction/escrow-creation.js @@ -19,7 +19,7 @@ type EscrowCreation = { } function createEscrowCreationTransaction(account: string, - payment: EscrowCreation + payment: EscrowCreation ): Object { const txJSON: Object = { TransactionType: 'EscrowCreate', diff --git a/src/transaction/escrow-execution.js b/src/transaction/escrow-execution.js index 4e817b181a..93daa3dfcd 100644 --- a/src/transaction/escrow-execution.js +++ b/src/transaction/escrow-execution.js @@ -16,7 +16,7 @@ type EscrowExecution = { } function createEscrowExecutionTransaction(account: string, - payment: EscrowExecution + payment: EscrowExecution ): Object { const txJSON: Object = { TransactionType: 'EscrowFinish', diff --git a/src/transaction/order.js b/src/transaction/order.js index 387942af24..a7ba78c11f 100644 --- a/src/transaction/order.js +++ b/src/transaction/order.js @@ -45,7 +45,7 @@ function createOrderTransaction(account: string, order: Order): Object { } function prepareOrder(address: string, order: Order, - instructions: Instructions = {} + instructions: Instructions = {} ): Promise { validate.prepareOrder({address, order, instructions}) const txJSON = createOrderTransaction(address, order) diff --git a/src/transaction/ordercancellation.js b/src/transaction/ordercancellation.js index eac02c6fa7..aafc4923bb 100644 --- a/src/transaction/ordercancellation.js +++ b/src/transaction/ordercancellation.js @@ -6,7 +6,7 @@ const validate = utils.common.validate import type {Instructions, Prepare} from './types.js' function createOrderCancellationTransaction(account: string, - orderCancellation: Object + orderCancellation: Object ): Object { const txJSON: Object = { TransactionType: 'OfferCancel', diff --git a/src/transaction/payment.js b/src/transaction/payment.js index 53c48f9184..b070cad468 100644 --- a/src/transaction/payment.js +++ b/src/transaction/payment.js @@ -146,7 +146,7 @@ function createPaymentTransaction(address: string, paymentArgument: Payment } function preparePayment(address: string, payment: Payment, - instructions: Instructions = {} + instructions: Instructions = {} ): Promise { validate.preparePayment({address, payment, instructions}) const txJSON = createPaymentTransaction(address, payment) diff --git a/src/transaction/settings.js b/src/transaction/settings.js index 4aa927ec60..419f1881be 100644 --- a/src/transaction/settings.js +++ b/src/transaction/settings.js @@ -145,7 +145,7 @@ function createSettingsTransaction(account: string, settings: Settings } function prepareSettings(address: string, settings: Settings, - instructions: Instructions = {} + instructions: Instructions = {} ): Promise { validate.prepareSettings({address, settings, instructions}) const txJSON = createSettingsTransaction(address, settings) diff --git a/src/transaction/trustline.js b/src/transaction/trustline.js index 9299e5c9d7..d0642c6ff4 100644 --- a/src/transaction/trustline.js +++ b/src/transaction/trustline.js @@ -13,7 +13,7 @@ function convertQuality(quality) { } function createTrustlineTransaction(account: string, - trustline: TrustLineSpecification + trustline: TrustLineSpecification ): Object { const limit = { currency: trustline.currency, @@ -51,7 +51,7 @@ function createTrustlineTransaction(account: string, } function prepareTrustline(address: string, - trustline: TrustLineSpecification, instructions: Instructions = {} + trustline: TrustLineSpecification, instructions: Instructions = {} ): Promise { validate.prepareTrustline({address, trustline, instructions}) const txJSON = createTrustlineTransaction(address, trustline) diff --git a/src/transaction/utils.js b/src/transaction/utils.js index c3d0bc8433..8ef4550b71 100644 --- a/src/transaction/utils.js +++ b/src/transaction/utils.js @@ -32,7 +32,7 @@ function scaleValue(value, multiplier, extra = 0) { } function prepareTransaction(txJSON: Object, api: Object, - instructions: Instructions + instructions: Instructions ): Promise { common.validate.instructions(instructions) @@ -67,8 +67,8 @@ function prepareTransaction(txJSON: Object, api: Object, const extraFee = (txJSON.TransactionType !== 'EscrowFinish' || txJSON.Fulfillment === undefined) ? 0 : - (cushion * feeRef * (32 + Math.floor( - new Buffer(txJSON.Fulfillment, 'hex').length / 16))) + (cushion * feeRef * (32 + Math.floor( + new Buffer(txJSON.Fulfillment, 'hex').length / 16))) const feeDrops = common.xrpToDrops(fee) if (instructions.maxFee !== undefined) { const maxFeeDrops = common.xrpToDrops(instructions.maxFee)