feat(types): add LedgerClosedEvent and export more types (#1333)

- Export AccountInfoResponse and other types
This commit is contained in:
Elliot Lee
2020-11-23 18:58:05 -08:00
parent dd4c6a0353
commit 5db1f5668c
4 changed files with 50 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
import {
RippleAPI,
AccountInfoResponse,
AccountInfoResponse,
LedgerClosedEvent
} from '../../dist/npm'
import https = require('https')
@@ -22,14 +22,14 @@ import https = require('https')
* A) `tec`: The transaction was included in a ledger but only claimed the transaction fee
* B) `tesSUCCESS` but unexpected result: The transaction was successful but did not have the expected result. This generally does not occur for XRP-to-XRP payments
* C) The transaction was not, and never will be, included in a validated ledger [3C]
*
*
* References:
* - https://xrpl.org/reliable-transaction-submission.html
* - https://xrpl.org/send-xrp.html
* - https://xrpl.org/look-up-transaction-results.html
* - https://xrpl.org/get-started-with-rippleapi-for-javascript.html
* - https://xrpl.org/monitor-incoming-payments-with-websocket.html
*
*
* For the implementation in this example, we have made the following decisions:
* 1) The script will choose the account sequence and LastLedgerSequence numbers automatically. We allow ripple-lib to choose the fee.
* Payments are defined upfront, and idempotency is not needed. If the script is run a second time, duplicate payments will result.
@@ -43,13 +43,13 @@ reliableTransactionSubmissionExample()
async function reliableTransactionSubmissionExample() {
/**
* Array of payments to execute.
*
*
* For brevity, these are XRP-to-XRP payments, taking a source, destination, and an amount in drops.
*
*
* The script will attempt to make all of these payments as quickly as possible, and report the final status of each. Transactions that fail are NOT retried.
*/
const payments = []
const sourceAccount = (await generateTestnetAccount()).account
console.log(`Generated new Testnet account: ${sourceAccount.classicAddress}/${sourceAccount.secret}`)
// Send amounts from 1 drop to 10 drops

View File

@@ -453,4 +453,29 @@ class RippleAPI extends EventEmitter {
isValidSecret = schemaValidator.isValidSecret
}
export {RippleAPI}
export {
RippleAPI
}
export type {
AccountObjectsRequest,
AccountObjectsResponse,
AccountOffersRequest,
AccountOffersResponse,
AccountInfoRequest,
AccountInfoResponse,
AccountLinesRequest,
AccountLinesResponse,
BookOffersRequest,
BookOffersResponse,
GatewayBalancesRequest,
GatewayBalancesResponse,
LedgerRequest,
LedgerResponse,
LedgerDataRequest,
LedgerDataResponse,
LedgerEntryRequest,
LedgerEntryResponse,
ServerInfoRequest,
ServerInfoResponse
}

View File

@@ -21,3 +21,17 @@ export interface Ledger {
accountState?: any[]
validated?: boolean
}
// https://xrpl.org/subscribe.html#ledger-stream
export type LedgerClosedEvent = {
type: 'ledgerClosed'
fee_base: number
fee_ref: number
ledger_hash: string
ledger_index: number
ledger_time: number
reserve_base: number
reserve_inc: number
txn_count: number
validated_ledgers: string
}

View File

@@ -1,6 +1,8 @@
export {RippleAPI} from './api'
export * from './api'
export {FormattedTransactionType} from './transaction/types'
export * from './transaction/types'
export * from './common/types/objects/ledger'
// Broadcast api is experimental
export {RippleAPIBroadcast} from './broadcast'