You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

subscribe.d.ts 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import type { Amount, Currency, Path, StreamType, ResponseOnlyTxInfo } from '../common';
  2. import { Offer } from '../ledger';
  3. import { OfferCreate, Transaction } from '../transactions';
  4. import { TransactionMetadata } from '../transactions/metadata';
  5. import type { BaseRequest, BaseResponse } from './baseMethod';
  6. interface Book {
  7. taker_gets: Currency;
  8. taker_pays: Currency;
  9. taker: string;
  10. snapshot?: boolean;
  11. both?: boolean;
  12. }
  13. export interface SubscribeRequest extends BaseRequest {
  14. command: 'subscribe';
  15. streams?: StreamType[];
  16. accounts?: string[];
  17. accounts_proposed?: string[];
  18. books?: Book[];
  19. url?: string;
  20. url_username?: string;
  21. url_password?: string;
  22. }
  23. type BooksSnapshot = Offer[];
  24. export interface SubscribeResponse extends BaseResponse {
  25. result: Record<string, never> | LedgerStreamResponse | BooksSnapshot;
  26. }
  27. interface BaseStream {
  28. type: string;
  29. }
  30. export interface LedgerStream extends BaseStream {
  31. type: 'ledgerClosed';
  32. fee_base: number;
  33. fee_ref: number;
  34. ledger_hash: string;
  35. ledger_index: number;
  36. ledger_time: number;
  37. reserve_base: number;
  38. reserve_inc: number;
  39. txn_count: number;
  40. validated_ledgers?: string;
  41. }
  42. export interface LedgerStreamResponse {
  43. fee_base: number;
  44. fee_ref: number;
  45. ledger_hash: string;
  46. ledger_index: number;
  47. ledger_time: number;
  48. reserve_base: number;
  49. reserve_inc: number;
  50. validated_ledgers?: string;
  51. }
  52. export interface ValidationStream extends BaseStream {
  53. type: 'validationReceived';
  54. amendments?: string[];
  55. base_fee?: number;
  56. cookie?: string;
  57. data?: string;
  58. flags: number;
  59. full: boolean;
  60. ledger_hash: string;
  61. ledger_index: string;
  62. load_fee?: number;
  63. master_key?: string;
  64. reserve_base?: number;
  65. reserve_inc?: number;
  66. signature: string;
  67. signing_time: number;
  68. validation_public_key: string;
  69. }
  70. export interface TransactionStream extends BaseStream {
  71. status: string;
  72. type: 'transaction';
  73. engine_result: string;
  74. engine_result_code: number;
  75. engine_result_message: string;
  76. ledger_current_index?: number;
  77. ledger_hash?: string;
  78. ledger_index?: number;
  79. meta?: TransactionMetadata;
  80. transaction: Transaction & ResponseOnlyTxInfo;
  81. validated?: boolean;
  82. warnings?: Array<{
  83. id: number;
  84. message: string;
  85. }>;
  86. }
  87. export interface PeerStatusStream extends BaseStream {
  88. type: 'peerStatusChange';
  89. action: 'CLOSING_LEDGER' | 'ACCEPTED_LEDGER' | 'SWITCHED_LEDGER' | 'LOST_SYNC';
  90. date: number;
  91. ledger_hash?: string;
  92. ledger_index?: number;
  93. ledger_index_max?: number;
  94. ledger_index_min?: number;
  95. }
  96. interface ModifiedOfferCreateTransaction extends OfferCreate {
  97. owner_funds: string;
  98. }
  99. export interface OrderBookStream extends BaseStream {
  100. status: string;
  101. type: 'transaction';
  102. engine_result: string;
  103. engine_result_code: number;
  104. engine_result_message: string;
  105. ledger_current_index?: number;
  106. ledger_hash?: string;
  107. ledger_index?: number;
  108. meta: TransactionMetadata;
  109. transaction: (Transaction | ModifiedOfferCreateTransaction) & {
  110. date?: number;
  111. hash?: string;
  112. };
  113. validated: boolean;
  114. }
  115. export interface ConsensusStream extends BaseStream {
  116. type: 'consensusPhase';
  117. consensus: 'open' | 'establish' | 'accepted';
  118. }
  119. export interface PathFindStream extends BaseStream {
  120. type: 'path_find';
  121. source_account: string;
  122. destination_account: string;
  123. destination_amount: Amount;
  124. full_reply: boolean;
  125. id: number | string;
  126. send_max?: Amount;
  127. alternatives: [] | {
  128. paths_computed: Path[];
  129. source_amount: Amount;
  130. };
  131. }
  132. export type Stream = LedgerStream | ValidationStream | TransactionStream | PathFindStream | PeerStatusStream | OrderBookStream | ConsensusStream;
  133. export {};
  134. //# sourceMappingURL=subscribe.d.ts.map