mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 03:35:49 +00:00
The following methods are available directly under the RippleAPI object, not under schemaValidator: isValidAddress, isValidSecret, deriveKeypair, deriveAddress
29 lines
782 B
TypeScript
29 lines
782 B
TypeScript
import {validate} from '../common'
|
|
import {FormattedLedger, parseLedger} from './parse/ledger'
|
|
import {RippleAPI} from '../api'
|
|
|
|
export type GetLedgerOptions = {
|
|
ledgerVersion?: number,
|
|
includeAllData?: boolean,
|
|
includeTransactions?: boolean,
|
|
includeState?: boolean
|
|
}
|
|
|
|
async function getLedger(
|
|
this: RippleAPI, options: GetLedgerOptions = {}
|
|
): Promise<FormattedLedger> {
|
|
// 1. Validate
|
|
validate.getLedger({options})
|
|
// 2. Make Request
|
|
const response = await this.request('ledger', {
|
|
ledger_index: options.ledgerVersion || 'validated',
|
|
expand: options.includeAllData,
|
|
transactions: options.includeTransactions,
|
|
accounts: options.includeState
|
|
})
|
|
// 3. Return Formatted Response
|
|
return parseLedger(response.ledger)
|
|
}
|
|
|
|
export default getLedger
|