mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +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
@@ -1,28 +1,29 @@
|
||||
import {validate} from '../common'
|
||||
import parseLedger from './parse/ledger'
|
||||
import {GetLedger} from './types'
|
||||
import {FormattedLedger, parseLedger} from './parse/ledger'
|
||||
import {RippleAPI} from '../api'
|
||||
|
||||
export type LedgerOptions = {
|
||||
export type GetLedgerOptions = {
|
||||
ledgerVersion?: number,
|
||||
includeAllData?: boolean,
|
||||
includeTransactions?: boolean,
|
||||
includeState?: boolean
|
||||
}
|
||||
|
||||
|
||||
function getLedger(options: LedgerOptions = {}): Promise<GetLedger> {
|
||||
async function getLedger(
|
||||
this: RippleAPI, options: GetLedgerOptions = {}
|
||||
): Promise<FormattedLedger> {
|
||||
// 1. Validate
|
||||
validate.getLedger({options})
|
||||
|
||||
const request = {
|
||||
command: 'ledger',
|
||||
// 2. Make Request
|
||||
const response = await this._request('ledger', {
|
||||
ledger_index: options.ledgerVersion || 'validated',
|
||||
expand: options.includeAllData,
|
||||
transactions: options.includeTransactions,
|
||||
accounts: options.includeState
|
||||
}
|
||||
|
||||
return this.connection.request(request).then(response =>
|
||||
parseLedger(response.ledger))
|
||||
})
|
||||
// 3. Return Formatted Response
|
||||
return parseLedger(response.ledger)
|
||||
}
|
||||
|
||||
|
||||
export default getLedger
|
||||
|
||||
Reference in New Issue
Block a user