mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-27 07:35:52 +00:00
Types cleanup + more API methods onto new request method (#857)
* major types cleanup, more formatted api methods onto new request method - getPaymentChannel() now uses this.request() - getSettings() now uses this.request() - getLedger() now uses this.request() - transaction types cleaned up a bit, but still some work left to do
This commit is contained in:
committed by
Elliot Lee
parent
c175e3f58e
commit
187154a2b0
@@ -3,7 +3,16 @@ import parseAmount from './amount'
|
||||
import {parseTimestamp, adjustQualityForXRP} from './utils'
|
||||
import {removeUndefined} from '../../common'
|
||||
import {orderFlags} from './flags'
|
||||
import {Order} from '../types'
|
||||
import {FormattedOrderSpecification} from '../../common/types/objects'
|
||||
|
||||
export type FormattedAccountOrder = {
|
||||
specification: FormattedOrderSpecification,
|
||||
properties: {
|
||||
maker: string,
|
||||
sequence: number,
|
||||
makerExchangeRate: string
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove this function once rippled provides quality directly
|
||||
function computeQuality(takerGets, takerPays) {
|
||||
@@ -13,7 +22,9 @@ function computeQuality(takerGets, takerPays) {
|
||||
|
||||
// rippled 'account_offers' returns a different format for orders than 'tx'
|
||||
// the flags are also different
|
||||
function parseAccountOrder(address: string, order: any): Order {
|
||||
export function parseAccountOrder(
|
||||
address: string, order: any
|
||||
): FormattedAccountOrder {
|
||||
const direction = (order.flags & orderFlags.Sell) === 0 ? 'buy' : 'sell'
|
||||
const takerGetsAmount = parseAmount(order.taker_gets)
|
||||
const takerPaysAmount = parseAmount(order.taker_pays)
|
||||
@@ -43,5 +54,3 @@ function parseAccountOrder(address: string, order: any): Order {
|
||||
|
||||
return {specification, properties}
|
||||
}
|
||||
|
||||
export default parseAccountOrder
|
||||
|
||||
Reference in New Issue
Block a user