Add new request interface, implement first few request typings (#843)

* Add request interface & typings

- src/api: add basic implementation of request/requestAll()
- src/ledgers/account_info: refactor to simplify with request()
- src/ledgers/balances: refactor to simplify with request()
- src/ledgers/orderbook: refactor to simplify with requestAll()
- src/ledgers/orders: refactor to simplify with requestAll()
- src/ledgers/trustlines: refactor to simplify with requestAll()

* standardize on Formatted prefix
This commit is contained in:
Fred K. Schott
2018-02-20 11:44:36 -08:00
committed by Elliot Lee
parent 4a21360e37
commit 365de6d18a
42 changed files with 605 additions and 307 deletions

View File

@@ -1,7 +1,8 @@
import * as utils from './utils'
import {validate} from '../common'
import {Connection} from '../common'
import {TrustlinesOptions, Trustline} from './trustlines-types'
import {GetTrustlinesOptions} from './trustlines'
import {FormattedTrustline} from '../common/types/objects/trustlines'
type Balance = {
@@ -12,7 +13,7 @@ type Balance = {
type GetBalances = Array<Balance>
function getTrustlineBalanceAmount(trustline: Trustline) {
function getTrustlineBalanceAmount(trustline: FormattedTrustline) {
return {
currency: trustline.specification.currency,
counterparty: trustline.specification.counterparty,
@@ -46,7 +47,7 @@ function getLedgerVersionHelper(connection: Connection, optionValue?: number
return connection.getLedgerVersion()
}
function getBalances(address: string, options: TrustlinesOptions = {}
function getBalances(address: string, options: GetTrustlinesOptions = {}
): Promise<GetBalances> {
validate.getTrustlines({address, options})