mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-14 01:25:48 +00:00
9
custom_typings/node.d.ts
vendored
9
custom_typings/node.d.ts
vendored
@@ -1,9 +0,0 @@
|
|||||||
/**
|
|
||||||
* This is an extension of Node's `process` object to include the browser
|
|
||||||
* property, which is added by webpack.
|
|
||||||
*/
|
|
||||||
interface AmbiguousProcess extends NodeJS.Process {
|
|
||||||
browser?: true
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var process: AmbiguousProcess;
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
"ws": "^3.3.1"
|
"ws": "^3.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^8.0.53",
|
"@types/node": "11.13.0",
|
||||||
"assert-diff": "^1.0.1",
|
"assert-diff": "^1.0.1",
|
||||||
"doctoc": "^0.15.0",
|
"doctoc": "^0.15.0",
|
||||||
"ejs": "^2.3.4",
|
"ejs": "^2.3.4",
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"ts-node": "^3.3.0",
|
"ts-node": "^3.3.0",
|
||||||
"tslint": "^5.8.0",
|
"tslint": "^5.8.0",
|
||||||
"tslint-eslint-rules": "^4.1.1",
|
"tslint-eslint-rules": "^4.1.1",
|
||||||
"typescript": "2.9.2",
|
"typescript": "3.4.2",
|
||||||
"uglifyjs-webpack-plugin": "^1.1.4",
|
"uglifyjs-webpack-plugin": "^1.1.4",
|
||||||
"webpack": "3.12.0",
|
"webpack": "3.12.0",
|
||||||
"yargs": "^8.0.2"
|
"yargs": "^8.0.2"
|
||||||
|
|||||||
@@ -206,12 +206,6 @@ class Connection extends EventEmitter {
|
|||||||
|
|
||||||
this._retry = 0
|
this._retry = 0
|
||||||
this._ws.on('error', error => {
|
this._ws.on('error', error => {
|
||||||
// TODO: "type" does not exist on official error type, safe to remove?
|
|
||||||
if (process.browser && error && (<any>error).type === 'error') {
|
|
||||||
// we are in browser, ignore error - `close` event will be fired
|
|
||||||
// after error
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.emit('error', 'websocket', error.message, error)
|
this.emit('error', 'websocket', error.message, error)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -287,7 +281,7 @@ class Connection extends EventEmitter {
|
|||||||
return websocket
|
return websocket
|
||||||
}
|
}
|
||||||
|
|
||||||
connect() {
|
connect(): Promise<void> {
|
||||||
this._clearReconnectTimer()
|
this._clearReconnectTimer()
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!this._url) {
|
if (!this._url) {
|
||||||
@@ -322,11 +316,11 @@ class Connection extends EventEmitter {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect(): Promise<void> {
|
||||||
return this._disconnect(true)
|
return this._disconnect(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
_disconnect(calledByUser) {
|
_disconnect(calledByUser): Promise<void> {
|
||||||
if (calledByUser) {
|
if (calledByUser) {
|
||||||
this._clearReconnectTimer()
|
this._clearReconnectTimer()
|
||||||
this._retry = 0
|
this._retry = 0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as _ from 'lodash'
|
import * as _ from 'lodash'
|
||||||
import {convertKeysFromSnakeCaseToCamelCase} from './utils'
|
import {convertKeysFromSnakeCaseToCamelCase} from './utils'
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import {RippleAPI} from '../index'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type GetServerInfoResponse = {
|
export type GetServerInfoResponse = {
|
||||||
buildVersion: string,
|
buildVersion: string,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {validate, removeUndefined, dropsToXrp} from '../common'
|
import {validate, removeUndefined, dropsToXrp} from '../common'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
import {AccountInfoResponse} from '../common/types/commands/account_info'
|
import {AccountInfoResponse} from '../common/types/commands/account_info'
|
||||||
|
|
||||||
export type GetAccountInfoOptions = {
|
export type GetAccountInfoOptions = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {removeUndefined} from '../common'
|
import {removeUndefined} from '../common'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
import {
|
import {
|
||||||
GetAccountObjectsOptions,
|
GetAccountObjectsOptions,
|
||||||
AccountObjectsResponse
|
AccountObjectsResponse
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as _ from 'lodash'
|
|||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import {Amount} from '../common/types/objects'
|
import {Amount} from '../common/types/objects'
|
||||||
import {ensureLedgerVersion} from './utils'
|
import {ensureLedgerVersion} from './utils'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type BalanceSheetOptions = {
|
export type BalanceSheetOptions = {
|
||||||
excludeAddresses?: Array<string>,
|
excludeAddresses?: Array<string>,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {validate} from '../common'
|
|||||||
import {Connection} from '../common'
|
import {Connection} from '../common'
|
||||||
import {GetTrustlinesOptions} from './trustlines'
|
import {GetTrustlinesOptions} from './trustlines'
|
||||||
import {FormattedTrustline} from '../common/types/objects/trustlines'
|
import {FormattedTrustline} from '../common/types/objects/trustlines'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
|
|
||||||
export type Balance = {
|
export type Balance = {
|
||||||
@@ -47,7 +48,7 @@ function getLedgerVersionHelper(connection: Connection, optionValue?: number
|
|||||||
return connection.getLedgerVersion()
|
return connection.getLedgerVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBalances(address: string, options: GetTrustlinesOptions = {}
|
function getBalances(this: RippleAPI, address: string, options: GetTrustlinesOptions = {}
|
||||||
): Promise<GetBalances> {
|
): Promise<GetBalances> {
|
||||||
validate.getTrustlines({address, options})
|
validate.getTrustlines({address, options})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import {FormattedLedger, parseLedger} from './parse/ledger'
|
import {FormattedLedger, parseLedger} from './parse/ledger'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type GetLedgerOptions = {
|
export type GetLedgerOptions = {
|
||||||
ledgerHash?: string,
|
ledgerHash?: string,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import {Amount, Issue} from '../common/types/objects'
|
import {Amount, Issue} from '../common/types/objects'
|
||||||
import {BookOffer} from '../common/types/commands'
|
import {BookOffer} from '../common/types/commands'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
|
|
||||||
export type FormattedOrderbook = {
|
export type FormattedOrderbook = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as _ from 'lodash'
|
import * as _ from 'lodash'
|
||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import {FormattedAccountOrder, parseAccountOrder} from './parse/account-order'
|
import {FormattedAccountOrder, parseAccountOrder} from './parse/account-order'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
import {AccountOffersResponse} from '../common/types/commands'
|
import {AccountOffersResponse} from '../common/types/commands'
|
||||||
|
|
||||||
export type GetOrdersOptions = {
|
export type GetOrdersOptions = {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {RippledAmount, Amount} from '../common/types/objects'
|
|||||||
import {
|
import {
|
||||||
GetPaths, PathFind, RippledPathsResponse, PathFindRequest
|
GetPaths, PathFind, RippledPathsResponse, PathFindRequest
|
||||||
} from './pathfind-types'
|
} from './pathfind-types'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
const NotFoundError = errors.NotFoundError
|
const NotFoundError = errors.NotFoundError
|
||||||
const ValidationError = errors.ValidationError
|
const ValidationError = errors.ValidationError
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ function formatResponse(pathfind: PathFind, paths: RippledPathsResponse) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPaths(pathfind: PathFind): Promise<GetPaths> {
|
function getPaths(this: RippleAPI, pathfind: PathFind): Promise<GetPaths> {
|
||||||
validate.getPaths({pathfind})
|
validate.getPaths({pathfind})
|
||||||
|
|
||||||
const address = pathfind.source.address
|
const address = pathfind.source.address
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
FormattedPaymentChannel
|
FormattedPaymentChannel
|
||||||
} from './parse/payment-channel'
|
} from './parse/payment-channel'
|
||||||
import {validate, errors} from '../common'
|
import {validate, errors} from '../common'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
import {LedgerEntryResponse} from '../common/types/commands'
|
import {LedgerEntryResponse} from '../common/types/commands'
|
||||||
const NotFoundError = errors.NotFoundError
|
const NotFoundError = errors.NotFoundError
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import parseFields from './parse/fields'
|
|||||||
import {validate, constants} from '../common'
|
import {validate, constants} from '../common'
|
||||||
import {FormattedSettings} from '../common/types/objects'
|
import {FormattedSettings} from '../common/types/objects'
|
||||||
import {AccountInfoResponse} from '../common/types/commands'
|
import {AccountInfoResponse} from '../common/types/commands'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
const AccountFlags = constants.AccountFlags
|
const AccountFlags = constants.AccountFlags
|
||||||
|
|
||||||
export type SettingsOptions = {
|
export type SettingsOptions = {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {validate, errors} from '../common'
|
|||||||
import {Connection} from '../common'
|
import {Connection} from '../common'
|
||||||
import {FormattedTransactionType} from '../transaction/types'
|
import {FormattedTransactionType} from '../transaction/types'
|
||||||
import {RippledError} from '../common/errors'
|
import {RippledError} from '../common/errors'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type TransactionOptions = {
|
export type TransactionOptions = {
|
||||||
minLedgerVersion?: number,
|
minLedgerVersion?: number,
|
||||||
@@ -96,7 +97,7 @@ function formatResponse(options: TransactionOptions, tx: TransactionResponse
|
|||||||
return parseTransaction(tx, options.includeRawTransaction)
|
return parseTransaction(tx, options.includeRawTransaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTransaction(id: string, options: TransactionOptions = {}
|
async function getTransaction(this: RippleAPI, id: string, options: TransactionOptions = {}
|
||||||
): Promise<FormattedTransactionType> {
|
): Promise<FormattedTransactionType> {
|
||||||
validate.getTransaction({id, options})
|
validate.getTransaction({id, options})
|
||||||
const _options = await utils.ensureLedgerVersion.call(this, options)
|
const _options = await utils.ensureLedgerVersion.call(this, options)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import parseTransaction from './parse/transaction'
|
|||||||
import getTransaction from './transaction'
|
import getTransaction from './transaction'
|
||||||
import {validate, errors, Connection} from '../common'
|
import {validate, errors, Connection} from '../common'
|
||||||
import {FormattedTransactionType} from '../transaction/types'
|
import {FormattedTransactionType} from '../transaction/types'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
|
|
||||||
export type TransactionsOptions = {
|
export type TransactionsOptions = {
|
||||||
@@ -162,7 +163,7 @@ function getTransactionsInternal(connection: Connection, address: string,
|
|||||||
return utils.getRecursive(getter, options.limit).then(format)
|
return utils.getRecursive(getter, options.limit).then(format)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTransactions(address: string, options: TransactionsOptions = {}
|
function getTransactions(this: RippleAPI, address: string, options: TransactionsOptions = {}
|
||||||
): Promise<GetTransactionsResponse> {
|
): Promise<GetTransactionsResponse> {
|
||||||
validate.getTransactions({address, options})
|
validate.getTransactions({address, options})
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as _ from 'lodash'
|
import * as _ from 'lodash'
|
||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import parseAccountTrustline from './parse/account-trustline'
|
import parseAccountTrustline from './parse/account-trustline'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
import {FormattedTrustline} from '../common/types/objects/trustlines'
|
import {FormattedTrustline} from '../common/types/objects/trustlines'
|
||||||
|
|
||||||
export type GetTrustlinesOptions = {
|
export type GetTrustlinesOptions = {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import * as common from '../common'
|
|||||||
import {Connection} from '../common'
|
import {Connection} from '../common'
|
||||||
import {FormattedTransactionType} from '../transaction/types'
|
import {FormattedTransactionType} from '../transaction/types'
|
||||||
import {Issue} from '../common/types/objects'
|
import {Issue} from '../common/types/objects'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type RecursiveData = {
|
export type RecursiveData = {
|
||||||
marker: string,
|
marker: string,
|
||||||
@@ -105,7 +106,7 @@ function isPendingLedgerVersion(connection: Connection,
|
|||||||
ledgerVersion < (maxLedgerVersion || 0))
|
ledgerVersion < (maxLedgerVersion || 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureLedgerVersion(options: any
|
function ensureLedgerVersion(this: RippleAPI, options: any
|
||||||
): Promise<object> {
|
): Promise<object> {
|
||||||
if (Boolean(options) && options.ledgerVersion !== undefined &&
|
if (Boolean(options) && options.ledgerVersion !== undefined &&
|
||||||
options.ledgerVersion !== null
|
options.ledgerVersion !== null
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
import * as common from '../common'
|
import * as common from '../common'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
function isConnected(): boolean {
|
function isConnected(this: RippleAPI): boolean {
|
||||||
return this.connection.isConnected()
|
return this.connection.isConnected()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLedgerVersion(): Promise<number> {
|
function getLedgerVersion(this: RippleAPI): Promise<number> {
|
||||||
return this.connection.getLedgerVersion()
|
return this.connection.getLedgerVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect(): Promise<void> {
|
function connect(this: RippleAPI): Promise<void> {
|
||||||
return this.connection.connect()
|
return this.connection.connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
function disconnect(): Promise<void> {
|
function disconnect(this: RippleAPI): Promise<void> {
|
||||||
return this.connection.disconnect()
|
return this.connection.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {TransactionJSON, prepareTransaction} from './utils'
|
import {TransactionJSON, prepareTransaction} from './utils'
|
||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare} from './types'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type CheckCancelParameters = {
|
export type CheckCancelParameters = {
|
||||||
checkID: string
|
checkID: string
|
||||||
@@ -18,7 +19,7 @@ function createCheckCancelTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareCheckCancel(address: string,
|
function prepareCheckCancel(this: RippleAPI, address: string,
|
||||||
checkCancel: CheckCancelParameters,
|
checkCancel: CheckCancelParameters,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const toRippledAmount = utils.common.toRippledAmount
|
|||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import {Instructions, Prepare, TransactionJSON} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {Amount} from '../common/types/objects'
|
import {Amount} from '../common/types/objects'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type CheckCashParameters = {
|
export type CheckCashParameters = {
|
||||||
checkID: string,
|
checkID: string,
|
||||||
@@ -36,7 +37,7 @@ function createCheckCashTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareCheckCash(address: string,
|
function prepareCheckCash(this: RippleAPI, address: string,
|
||||||
checkCash: CheckCashParameters,
|
checkCash: CheckCashParameters,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const toRippledAmount = utils.common.toRippledAmount
|
|||||||
import {validate, iso8601ToRippleTime} from '../common'
|
import {validate, iso8601ToRippleTime} from '../common'
|
||||||
import {Instructions, Prepare, TransactionJSON} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {Amount} from '../common/types/objects'
|
import {Amount} from '../common/types/objects'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type CheckCreateParameters = {
|
export type CheckCreateParameters = {
|
||||||
destination: string,
|
destination: string,
|
||||||
@@ -37,7 +38,7 @@ function createCheckCreateTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareCheckCreate(address: string,
|
function prepareCheckCreate(this: RippleAPI, address: string,
|
||||||
checkCreate: CheckCreateParameters,
|
checkCreate: CheckCreateParameters,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as utils from './utils'
|
|||||||
const validate = utils.common.validate
|
const validate = utils.common.validate
|
||||||
import {Instructions, Prepare, TransactionJSON} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {Memo} from '../common/types/objects'
|
import {Memo} from '../common/types/objects'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type EscrowCancellation = {
|
export type EscrowCancellation = {
|
||||||
owner: string,
|
owner: string,
|
||||||
@@ -27,7 +28,7 @@ function createEscrowCancellationTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareEscrowCancellation(address: string,
|
function prepareEscrowCancellation(this: RippleAPI, address: string,
|
||||||
escrowCancellation: EscrowCancellation,
|
escrowCancellation: EscrowCancellation,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
|||||||
const ValidationError = utils.common.errors.ValidationError
|
const ValidationError = utils.common.errors.ValidationError
|
||||||
import {Instructions, Prepare, TransactionJSON} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {Memo} from '../common/types/objects'
|
import {Memo} from '../common/types/objects'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type EscrowCreation = {
|
export type EscrowCreation = {
|
||||||
amount: string,
|
amount: string,
|
||||||
@@ -51,7 +52,7 @@ function createEscrowCreationTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareEscrowCreation(address: string,
|
function prepareEscrowCreation(this: RippleAPI, address: string,
|
||||||
escrowCreation: EscrowCreation,
|
escrowCreation: EscrowCreation,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const validate = utils.common.validate
|
|||||||
const ValidationError = utils.common.errors.ValidationError
|
const ValidationError = utils.common.errors.ValidationError
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare} from './types'
|
||||||
import {Memo} from '../common/types/objects'
|
import {Memo} from '../common/types/objects'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type EscrowExecution = {
|
export type EscrowExecution = {
|
||||||
owner: string,
|
owner: string,
|
||||||
@@ -39,7 +40,7 @@ function createEscrowExecutionTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareEscrowExecution(address: string,
|
function prepareEscrowExecution(this: RippleAPI, address: string,
|
||||||
escrowExecution: EscrowExecution,
|
escrowExecution: EscrowExecution,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const offerFlags = utils.common.txFlags.OfferCreate
|
|||||||
import {validate, iso8601ToRippleTime} from '../common'
|
import {validate, iso8601ToRippleTime} from '../common'
|
||||||
import {Instructions, Prepare, OfferCreateTransaction} from './types'
|
import {Instructions, Prepare, OfferCreateTransaction} from './types'
|
||||||
import {FormattedOrderSpecification} from '../common/types/objects/index'
|
import {FormattedOrderSpecification} from '../common/types/objects/index'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
function createOrderTransaction(
|
function createOrderTransaction(
|
||||||
account: string, order: FormattedOrderSpecification
|
account: string, order: FormattedOrderSpecification
|
||||||
@@ -43,7 +44,7 @@ function createOrderTransaction(
|
|||||||
return txJSON as OfferCreateTransaction
|
return txJSON as OfferCreateTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareOrder(address: string, order: FormattedOrderSpecification,
|
function prepareOrder(this: RippleAPI, address: string, order: FormattedOrderSpecification,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
const validate = utils.common.validate
|
const validate = utils.common.validate
|
||||||
import {Instructions, Prepare, TransactionJSON} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
function createOrderCancellationTransaction(account: string,
|
function createOrderCancellationTransaction(account: string,
|
||||||
orderCancellation: any
|
orderCancellation: any
|
||||||
@@ -16,7 +17,7 @@ function createOrderCancellationTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareOrderCancellation(address: string, orderCancellation: object,
|
function prepareOrderCancellation(this: RippleAPI, address: string, orderCancellation: object,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const ValidationError = utils.common.errors.ValidationError
|
|||||||
const claimFlags = utils.common.txFlags.PaymentChannelClaim
|
const claimFlags = utils.common.txFlags.PaymentChannelClaim
|
||||||
import {validate, xrpToDrops} from '../common'
|
import {validate, xrpToDrops} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare} from './types'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type PaymentChannelClaim = {
|
export type PaymentChannelClaim = {
|
||||||
channel: string,
|
channel: string,
|
||||||
@@ -58,7 +59,7 @@ function createPaymentChannelClaimTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePaymentChannelClaim(address: string,
|
function preparePaymentChannelClaim(this: RippleAPI, address: string,
|
||||||
paymentChannelClaim: PaymentChannelClaim,
|
paymentChannelClaim: PaymentChannelClaim,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare} from './types'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type PaymentChannelCreate = {
|
export type PaymentChannelCreate = {
|
||||||
amount: string,
|
amount: string,
|
||||||
@@ -37,7 +38,7 @@ function createPaymentChannelCreateTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePaymentChannelCreate(address: string,
|
function preparePaymentChannelCreate(this: RippleAPI, address: string,
|
||||||
paymentChannelCreate: PaymentChannelCreate,
|
paymentChannelCreate: PaymentChannelCreate,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare} from './types'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type PaymentChannelFund = {
|
export type PaymentChannelFund = {
|
||||||
channel: string,
|
channel: string,
|
||||||
@@ -25,7 +26,7 @@ function createPaymentChannelFundTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePaymentChannelFund(address: string,
|
function preparePaymentChannelFund(this: RippleAPI, address: string,
|
||||||
paymentChannelFund: PaymentChannelFund,
|
paymentChannelFund: PaymentChannelFund,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {Instructions, Prepare, TransactionJSON} from './types'
|
|||||||
import {Amount, Adjustment, MaxAdjustment,
|
import {Amount, Adjustment, MaxAdjustment,
|
||||||
MinAdjustment, Memo} from '../common/types/objects'
|
MinAdjustment, Memo} from '../common/types/objects'
|
||||||
import {xrpToDrops} from '../common'
|
import {xrpToDrops} from '../common'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
|
|
||||||
export interface Payment {
|
export interface Payment {
|
||||||
@@ -167,7 +168,7 @@ function createPaymentTransaction(address: string, paymentArgument: Payment
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePayment(address: string, payment: Payment,
|
function preparePayment(this: RippleAPI, address: string, payment: Payment,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const AccountFlagIndices = utils.common.constants.AccountFlagIndices
|
|||||||
const AccountFields = utils.common.constants.AccountFields
|
const AccountFields = utils.common.constants.AccountFields
|
||||||
import {Instructions, Prepare, SettingsTransaction} from './types'
|
import {Instructions, Prepare, SettingsTransaction} from './types'
|
||||||
import {FormattedSettings, WeightedSigner} from '../common/types/objects'
|
import {FormattedSettings, WeightedSigner} from '../common/types/objects'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
function setTransactionFlags(txJSON: utils.TransactionJSON, values: FormattedSettings) {
|
function setTransactionFlags(txJSON: utils.TransactionJSON, values: FormattedSettings) {
|
||||||
const keys = Object.keys(values)
|
const keys = Object.keys(values)
|
||||||
@@ -121,7 +122,7 @@ function createSettingsTransaction(account: string, settings: FormattedSettings
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareSettings(address: string, settings: FormattedSettings,
|
function prepareSettings(this: RippleAPI, address: string, settings: FormattedSettings,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {computeBinaryTransactionHash} from 'ripple-hashes'
|
|||||||
import {SignOptions, KeyPair} from './types'
|
import {SignOptions, KeyPair} from './types'
|
||||||
import {BigNumber} from 'bignumber.js'
|
import {BigNumber} from 'bignumber.js'
|
||||||
import {xrpToDrops} from '../common'
|
import {xrpToDrops} from '../common'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
const validate = utils.common.validate
|
const validate = utils.common.validate
|
||||||
|
|
||||||
function computeSignature(tx: object, privateKey: string, signAs?: string) {
|
function computeSignature(tx: object, privateKey: string, signAs?: string) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {Instructions, Prepare, TransactionJSON} from './types'
|
|||||||
import {
|
import {
|
||||||
FormattedTrustlineSpecification
|
FormattedTrustlineSpecification
|
||||||
} from '../common/types/objects/trustlines'
|
} from '../common/types/objects/trustlines'
|
||||||
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
function convertQuality(quality) {
|
function convertQuality(quality) {
|
||||||
return (new BigNumber(quality)).shift(9).truncated().toNumber()
|
return (new BigNumber(quality)).shift(9).truncated().toNumber()
|
||||||
@@ -49,7 +50,7 @@ function createTrustlineTransaction(account: string,
|
|||||||
return txJSON
|
return txJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareTrustline(address: string,
|
function prepareTrustline(this: RippleAPI, address: string,
|
||||||
trustline: FormattedTrustlineSpecification, instructions: Instructions = {}
|
trustline: FormattedTrustlineSpecification, instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as common from '../common'
|
|||||||
import {Memo, RippledAmount} from '../common/types/objects'
|
import {Memo, RippledAmount} from '../common/types/objects'
|
||||||
const txFlags = common.txFlags
|
const txFlags = common.txFlags
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare} from './types'
|
||||||
import {RippleAPI} from '../api'
|
import {RippleAPI} from '..'
|
||||||
import {ValidationError} from '../common/errors'
|
import {ValidationError} from '../common/errors'
|
||||||
|
|
||||||
export type ApiMemo = {
|
export type ApiMemo = {
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ const utils = RippleAPI._PRIVATE.ledgerUtils;
|
|||||||
const ledgerClosed = require('./fixtures/rippled/ledger-close-newer');
|
const ledgerClosed = require('./fixtures/rippled/ledger-close-newer');
|
||||||
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
||||||
const binary = require('ripple-binary-codec');
|
const binary = require('ripple-binary-codec');
|
||||||
const BigNumber = require('bignumber.js')
|
const BigNumber = require('bignumber.js');
|
||||||
assert.options.strict = true;
|
assert.options.strict = true;
|
||||||
|
|
||||||
// how long before each test case times out
|
// how long before each test case times out
|
||||||
const TIMEOUT = process.browser ? 25000 : 10000;
|
const TIMEOUT = 20000;
|
||||||
|
|
||||||
function unused() {
|
function unused() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const ledgerClosed = require('./fixtures/rippled/ledger-close');
|
|||||||
const RippleAPI = require('ripple-api').RippleAPI;
|
const RippleAPI = require('ripple-api').RippleAPI;
|
||||||
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
||||||
|
|
||||||
const TIMEOUT = process.browser ? 25000 : 10000;
|
const TIMEOUT = 20000;
|
||||||
|
|
||||||
function checkResult(expected, schemaName, response) {
|
function checkResult(expected, schemaName, response) {
|
||||||
if (expected.txJSON) {
|
if (expected.txJSON) {
|
||||||
@@ -29,9 +29,7 @@ describe('RippleAPIBroadcast', function() {
|
|||||||
|
|
||||||
it('base', function() {
|
it('base', function() {
|
||||||
const expected = {request_server_info: 1};
|
const expected = {request_server_info: 1};
|
||||||
if (!process.browser) {
|
this.mocks.forEach(mock => mock.expect(_.assign({}, expected)));
|
||||||
this.mocks.forEach(mock => mock.expect(_.assign({}, expected)));
|
|
||||||
}
|
|
||||||
assert(this.api.isConnected());
|
assert(this.api.isConnected());
|
||||||
return this.api.getServerInfo().then(
|
return this.api.getServerInfo().then(
|
||||||
_.partial(checkResult, responses.getServerInfo, 'getServerInfo'));
|
_.partial(checkResult, responses.getServerInfo, 'getServerInfo'));
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const {payTo, ledgerAccept} = require('./utils');
|
|||||||
|
|
||||||
|
|
||||||
// how long before each test case times out
|
// how long before each test case times out
|
||||||
const TIMEOUT = process.browser ? 25000 : 10000;
|
const TIMEOUT = 20000;
|
||||||
const INTERVAL = 1000; // how long to wait between checks for validated ledger
|
const INTERVAL = 1000; // how long to wait between checks for validated ledger
|
||||||
|
|
||||||
const serverUrl = 'ws://127.0.0.1:6006';
|
const serverUrl = 'ws://127.0.0.1:6006';
|
||||||
|
|||||||
@@ -12,15 +12,14 @@
|
|||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"removeComments": false,
|
"removeComments": true,
|
||||||
|
"strict": true /* Enable all strict type-checking options. */,
|
||||||
"preserveConstEnums": false,
|
"preserveConstEnums": false,
|
||||||
"suppressImplicitAnyIndexErrors": false,
|
"suppressImplicitAnyIndexErrors": false,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true
|
||||||
"skipLibCheck": true
|
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"custom_typings/**/*.ts",
|
|
||||||
"src/**/*.ts"
|
"src/**/*.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
16
yarn.lock
16
yarn.lock
@@ -12,10 +12,10 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.1.tgz#e2d374ef15b315b48e7efc308fa1a7cd51faa06c"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.1.tgz#e2d374ef15b315b48e7efc308fa1a7cd51faa06c"
|
||||||
integrity sha512-xwlHq5DXQFRpe+u6hmmNkzYk/3oxxqDp71a/AJMupOQYmxyaBetqrVMqdNlSQfbg7XTJYD8vARjf3Op06OzdtQ==
|
integrity sha512-xwlHq5DXQFRpe+u6hmmNkzYk/3oxxqDp71a/AJMupOQYmxyaBetqrVMqdNlSQfbg7XTJYD8vARjf3Op06OzdtQ==
|
||||||
|
|
||||||
"@types/node@^8.0.53":
|
"@types/node@11.13.0":
|
||||||
version "8.10.1"
|
version "11.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.1.tgz#aac98b810c50568054486f2bb8c486d824713be8"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.0.tgz#b0df8d6ef9b5001b2be3a94d909ce3c29a80f9e1"
|
||||||
integrity sha512-X/pIUOcgpX7xxKsmdPCMKeDBefsGH/4D/IuJ1gIHbqgWI0qEy/yMKeqaN/sT+rzV9UpAXAfd0kLOVExRmZrXIg==
|
integrity sha512-rx29MMkRdVmzunmiA4lzBYJNnXsW/PhG4kMBy2ATsYaDjGGR75dCFEVVROKpNwlVdcUX3xxlghKQOeDPBJobng==
|
||||||
|
|
||||||
"@types/ws@^3.2.0":
|
"@types/ws@^3.2.0":
|
||||||
version "3.2.1"
|
version "3.2.1"
|
||||||
@@ -5223,10 +5223,10 @@ typedarray@^0.0.6:
|
|||||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||||
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
||||||
|
|
||||||
typescript@2.9.2:
|
typescript@3.4.2:
|
||||||
version "2.9.2"
|
version "3.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.2.tgz#9ed4e6475d906f589200193be056f5913caed481"
|
||||||
integrity sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==
|
integrity sha512-Og2Vn6Mk7JAuWA1hQdDQN/Ekm/SchX80VzLhjKN9ETYrIepBFAd8PkOdOTK2nKt0FCkmMZKBJvQ1dV1gIxPu/A==
|
||||||
|
|
||||||
uglify-es@^3.3.4:
|
uglify-es@^3.3.4:
|
||||||
version "3.3.9"
|
version "3.3.9"
|
||||||
|
|||||||
Reference in New Issue
Block a user