mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-06-07 10:46:49 +00:00
fix whitespace (lint errors) (#813)
This commit is contained in:
committed by
Elliot Lee
parent
f90617eac4
commit
7ece43e2e2
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -62,7 +62,7 @@ function getServerInfo(connection: Connection): Promise<GetServerInfoResponse> {
|
||||
}
|
||||
|
||||
function computeFeeFromServerInfo(cushion: number,
|
||||
serverInfo: GetServerInfoResponse
|
||||
serverInfo: GetServerInfoResponse
|
||||
): number {
|
||||
return (Number(serverInfo.validatedLedger.baseFeeXRP)
|
||||
* Number(serverInfo.loadFactor) * cushion).toString()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Object[]> {
|
||||
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<GetOrderbook> {
|
||||
validate.getOrderbook({address, orderbook, options})
|
||||
|
||||
|
||||
@@ -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))
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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<GetPaths> {
|
||||
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
|
||||
|
||||
@@ -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
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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<GetTransactionsResponse> {
|
||||
const getter = _.partial(getAccountTx, connection, address, options)
|
||||
const format = _.partial(formatResponse, connection, options)
|
||||
|
||||
@@ -19,7 +19,7 @@ type EscrowCreation = {
|
||||
}
|
||||
|
||||
function createEscrowCreationTransaction(account: string,
|
||||
payment: EscrowCreation
|
||||
payment: EscrowCreation
|
||||
): Object {
|
||||
const txJSON: Object = {
|
||||
TransactionType: 'EscrowCreate',
|
||||
|
||||
@@ -16,7 +16,7 @@ type EscrowExecution = {
|
||||
}
|
||||
|
||||
function createEscrowExecutionTransaction(account: string,
|
||||
payment: EscrowExecution
|
||||
payment: EscrowExecution
|
||||
): Object {
|
||||
const txJSON: Object = {
|
||||
TransactionType: 'EscrowFinish',
|
||||
|
||||
@@ -45,7 +45,7 @@ function createOrderTransaction(account: string, order: Order): Object {
|
||||
}
|
||||
|
||||
function prepareOrder(address: string, order: Order,
|
||||
instructions: Instructions = {}
|
||||
instructions: Instructions = {}
|
||||
): Promise<Prepare> {
|
||||
validate.prepareOrder({address, order, instructions})
|
||||
const txJSON = createOrderTransaction(address, order)
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -146,7 +146,7 @@ function createPaymentTransaction(address: string, paymentArgument: Payment
|
||||
}
|
||||
|
||||
function preparePayment(address: string, payment: Payment,
|
||||
instructions: Instructions = {}
|
||||
instructions: Instructions = {}
|
||||
): Promise<Prepare> {
|
||||
validate.preparePayment({address, payment, instructions})
|
||||
const txJSON = createPaymentTransaction(address, payment)
|
||||
|
||||
@@ -145,7 +145,7 @@ function createSettingsTransaction(account: string, settings: Settings
|
||||
}
|
||||
|
||||
function prepareSettings(address: string, settings: Settings,
|
||||
instructions: Instructions = {}
|
||||
instructions: Instructions = {}
|
||||
): Promise<Prepare> {
|
||||
validate.prepareSettings({address, settings, instructions})
|
||||
const txJSON = createSettingsTransaction(address, settings)
|
||||
|
||||
@@ -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<Prepare> {
|
||||
validate.prepareTrustline({address, trustline, instructions})
|
||||
const txJSON = createTrustlineTransaction(address, trustline)
|
||||
|
||||
@@ -32,7 +32,7 @@ function scaleValue(value, multiplier, extra = 0) {
|
||||
}
|
||||
|
||||
function prepareTransaction(txJSON: Object, api: Object,
|
||||
instructions: Instructions
|
||||
instructions: Instructions
|
||||
): Promise<Prepare> {
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user