@bithomp/xrpl-api 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +101 -0
  3. package/lib/base58.d.ts +3 -0
  4. package/lib/base58.js +33 -0
  5. package/lib/client.d.ts +19 -0
  6. package/lib/client.js +122 -0
  7. package/lib/common/errors/index.d.ts +3 -0
  8. package/lib/common/errors/index.js +7 -0
  9. package/lib/common/errors/ripple_error.d.ts +9 -0
  10. package/lib/common/errors/ripple_error.js +28 -0
  11. package/lib/common/errors/utils.d.ts +2 -0
  12. package/lib/common/errors/utils.js +19 -0
  13. package/lib/common/errors/validation_error.d.ts +4 -0
  14. package/lib/common/errors/validation_error.js +7 -0
  15. package/lib/common/index.d.ts +6 -0
  16. package/lib/common/index.js +44 -0
  17. package/lib/common/sha512Half.d.ts +2 -0
  18. package/lib/common/sha512Half.js +12 -0
  19. package/lib/common/utils.d.ts +10 -0
  20. package/lib/common/utils.js +113 -0
  21. package/lib/connection.d.ts +57 -0
  22. package/lib/connection.js +369 -0
  23. package/lib/faucet.d.ts +58 -0
  24. package/lib/faucet.js +89 -0
  25. package/lib/index.d.ts +9 -0
  26. package/lib/index.js +35 -0
  27. package/lib/ledger/account_info.d.ts +12 -0
  28. package/lib/ledger/account_info.js +78 -0
  29. package/lib/ledger/account_lines.d.ts +11 -0
  30. package/lib/ledger/account_lines.js +69 -0
  31. package/lib/ledger/account_nfts.d.ts +21 -0
  32. package/lib/ledger/account_nfts.js +185 -0
  33. package/lib/ledger/account_objects.d.ts +28 -0
  34. package/lib/ledger/account_objects.js +169 -0
  35. package/lib/ledger/account_offers.d.ts +8 -0
  36. package/lib/ledger/account_offers.js +67 -0
  37. package/lib/ledger/account_tx.d.ts +29 -0
  38. package/lib/ledger/account_tx.js +256 -0
  39. package/lib/ledger/book_offers.d.ts +11 -0
  40. package/lib/ledger/book_offers.js +90 -0
  41. package/lib/ledger/currency.d.ts +27 -0
  42. package/lib/ledger/currency.js +167 -0
  43. package/lib/ledger/fee.d.ts +5 -0
  44. package/lib/ledger/fee.js +45 -0
  45. package/lib/ledger/gateway_balances.d.ts +13 -0
  46. package/lib/ledger/gateway_balances.js +101 -0
  47. package/lib/ledger/index.d.ts +16 -0
  48. package/lib/ledger/index.js +32 -0
  49. package/lib/ledger/ledger.d.ts +11 -0
  50. package/lib/ledger/ledger.js +72 -0
  51. package/lib/ledger/manifest.d.ts +8 -0
  52. package/lib/ledger/manifest.js +56 -0
  53. package/lib/ledger/nft_info.d.ts +4 -0
  54. package/lib/ledger/nft_info.js +56 -0
  55. package/lib/ledger/server_info.d.ts +8 -0
  56. package/lib/ledger/server_info.js +54 -0
  57. package/lib/ledger/transaction.d.ts +37 -0
  58. package/lib/ledger/transaction.js +214 -0
  59. package/lib/ledger/vl.d.ts +10 -0
  60. package/lib/ledger/vl.js +92 -0
  61. package/lib/models/account_info.d.ts +122 -0
  62. package/lib/models/account_info.js +102 -0
  63. package/lib/models/account_lines.d.ts +24 -0
  64. package/lib/models/account_lines.js +2 -0
  65. package/lib/models/account_nfts.d.ts +19 -0
  66. package/lib/models/account_nfts.js +45 -0
  67. package/lib/models/account_object.d.ts +38 -0
  68. package/lib/models/account_object.js +61 -0
  69. package/lib/models/base_model.d.ts +14 -0
  70. package/lib/models/base_model.js +2 -0
  71. package/lib/models/book_offers.d.ts +9 -0
  72. package/lib/models/book_offers.js +41 -0
  73. package/lib/models/index.d.ts +23 -0
  74. package/lib/models/index.js +56 -0
  75. package/lib/models/ledger.d.ts +6 -0
  76. package/lib/models/ledger.js +20 -0
  77. package/lib/models/manifest.d.ts +26 -0
  78. package/lib/models/manifest.js +187 -0
  79. package/lib/models/transaction/affected_objects.d.ts +6 -0
  80. package/lib/models/transaction/affected_objects.js +104 -0
  81. package/lib/models/transaction/balance_changes.d.ts +7 -0
  82. package/lib/models/transaction/balance_changes.js +125 -0
  83. package/lib/models/transaction/channel_changes.d.ts +9 -0
  84. package/lib/models/transaction/channel_changes.js +57 -0
  85. package/lib/models/transaction/locked_balance_changes.d.ts +7 -0
  86. package/lib/models/transaction/locked_balance_changes.js +114 -0
  87. package/lib/models/transaction/nftoken_changes.d.ts +1 -0
  88. package/lib/models/transaction/nftoken_changes.js +163 -0
  89. package/lib/models/transaction/nftoken_offer_changes.d.ts +1 -0
  90. package/lib/models/transaction/nftoken_offer_changes.js +107 -0
  91. package/lib/models/transaction/orderbook_changes.d.ts +3 -0
  92. package/lib/models/transaction/orderbook_changes.js +136 -0
  93. package/lib/models/transaction/quality.d.ts +2 -0
  94. package/lib/models/transaction/quality.js +46 -0
  95. package/lib/models/transaction.d.ts +39 -0
  96. package/lib/models/transaction.js +45 -0
  97. package/lib/models/trustline.d.ts +15 -0
  98. package/lib/models/trustline.js +2 -0
  99. package/lib/models/utils.d.ts +3 -0
  100. package/lib/models/utils.js +19 -0
  101. package/lib/models/vl.d.ts +60 -0
  102. package/lib/models/vl.js +377 -0
  103. package/lib/parse/index.d.ts +3 -0
  104. package/lib/parse/index.js +32 -0
  105. package/lib/parse/ledger/account-order.d.ts +10 -0
  106. package/lib/parse/ledger/account-order.js +39 -0
  107. package/lib/parse/ledger/account-trustline.d.ts +3 -0
  108. package/lib/parse/ledger/account-trustline.js +27 -0
  109. package/lib/parse/ledger/amount.d.ts +3 -0
  110. package/lib/parse/ledger/amount.js +17 -0
  111. package/lib/parse/ledger/currency-amount.d.ts +3 -0
  112. package/lib/parse/ledger/currency-amount.js +13 -0
  113. package/lib/parse/ledger/fields.d.ts +2 -0
  114. package/lib/parse/ledger/fields.js +42 -0
  115. package/lib/parse/ledger/flags.d.ts +4 -0
  116. package/lib/parse/ledger/flags.js +18 -0
  117. package/lib/parse/ledger/index.d.ts +4 -0
  118. package/lib/parse/ledger/index.js +25 -0
  119. package/lib/parse/ledger/ledger.d.ts +2 -0
  120. package/lib/parse/ledger/ledger.js +61 -0
  121. package/lib/parse/ledger/memos.d.ts +3 -0
  122. package/lib/parse/ledger/memos.js +17 -0
  123. package/lib/parse/ledger/nftoken-flags.d.ts +5 -0
  124. package/lib/parse/ledger/nftoken-flags.js +8 -0
  125. package/lib/parse/ledger/nftoken-offer-flags.d.ts +5 -0
  126. package/lib/parse/ledger/nftoken-offer-flags.js +8 -0
  127. package/lib/parse/ledger/orderbook-order.d.ts +16 -0
  128. package/lib/parse/ledger/orderbook-order.js +39 -0
  129. package/lib/parse/ledger/pathfind.d.ts +4 -0
  130. package/lib/parse/ledger/pathfind.js +41 -0
  131. package/lib/parse/ledger/payment-channel.d.ts +16 -0
  132. package/lib/parse/ledger/payment-channel.js +27 -0
  133. package/lib/parse/ledger/ripple-amount.d.ts +3 -0
  134. package/lib/parse/ledger/ripple-amount.js +17 -0
  135. package/lib/parse/outcome/affected_objects.d.ts +6 -0
  136. package/lib/parse/outcome/affected_objects.js +109 -0
  137. package/lib/parse/outcome/balance_changes.d.ts +7 -0
  138. package/lib/parse/outcome/balance_changes.js +103 -0
  139. package/lib/parse/outcome/channel_changes.d.ts +9 -0
  140. package/lib/parse/outcome/channel_changes.js +53 -0
  141. package/lib/parse/outcome/index.d.ts +7 -0
  142. package/lib/parse/outcome/index.js +17 -0
  143. package/lib/parse/outcome/locked_balance_changes.d.ts +7 -0
  144. package/lib/parse/outcome/locked_balance_changes.js +92 -0
  145. package/lib/parse/outcome/nftoken_changes.d.ts +1 -0
  146. package/lib/parse/outcome/nftoken_changes.js +143 -0
  147. package/lib/parse/outcome/nftoken_offer_changes.d.ts +2 -0
  148. package/lib/parse/outcome/nftoken_offer_changes.js +107 -0
  149. package/lib/parse/outcome/orderbook_changes.d.ts +3 -0
  150. package/lib/parse/outcome/orderbook_changes.js +111 -0
  151. package/lib/parse/outcome/orderbook_quality.d.ts +2 -0
  152. package/lib/parse/outcome/orderbook_quality.js +45 -0
  153. package/lib/parse/outcome.d.ts +3 -0
  154. package/lib/parse/outcome.js +80 -0
  155. package/lib/parse/specification/account-delete.d.ts +3 -0
  156. package/lib/parse/specification/account-delete.js +42 -0
  157. package/lib/parse/specification/amendment.d.ts +3 -0
  158. package/lib/parse/specification/amendment.js +14 -0
  159. package/lib/parse/specification/check-cancel.d.ts +3 -0
  160. package/lib/parse/specification/check-cancel.js +39 -0
  161. package/lib/parse/specification/check-cash.d.ts +3 -0
  162. package/lib/parse/specification/check-cash.js +42 -0
  163. package/lib/parse/specification/check-create.d.ts +3 -0
  164. package/lib/parse/specification/check-create.js +45 -0
  165. package/lib/parse/specification/deposit-preauth.d.ts +3 -0
  166. package/lib/parse/specification/deposit-preauth.js +40 -0
  167. package/lib/parse/specification/escrow-cancel.d.ts +3 -0
  168. package/lib/parse/specification/escrow-cancel.js +40 -0
  169. package/lib/parse/specification/escrow-create.d.ts +3 -0
  170. package/lib/parse/specification/escrow-create.js +47 -0
  171. package/lib/parse/specification/escrow-finish.d.ts +3 -0
  172. package/lib/parse/specification/escrow-finish.js +42 -0
  173. package/lib/parse/specification/fee-update.d.ts +3 -0
  174. package/lib/parse/specification/fee-update.js +19 -0
  175. package/lib/parse/specification/nftoken-accept-offer.d.ts +3 -0
  176. package/lib/parse/specification/nftoken-accept-offer.js +41 -0
  177. package/lib/parse/specification/nftoken-burn.d.ts +3 -0
  178. package/lib/parse/specification/nftoken-burn.js +40 -0
  179. package/lib/parse/specification/nftoken-cancel-offer.d.ts +3 -0
  180. package/lib/parse/specification/nftoken-cancel-offer.js +39 -0
  181. package/lib/parse/specification/nftoken-create-offer.d.ts +3 -0
  182. package/lib/parse/specification/nftoken-create-offer.js +50 -0
  183. package/lib/parse/specification/nftoken-mint.d.ts +3 -0
  184. package/lib/parse/specification/nftoken-mint.js +44 -0
  185. package/lib/parse/specification/offer-cancel.d.ts +3 -0
  186. package/lib/parse/specification/offer-cancel.js +38 -0
  187. package/lib/parse/specification/offer-create.d.ts +3 -0
  188. package/lib/parse/specification/offer-create.js +53 -0
  189. package/lib/parse/specification/payment-channel-claim.d.ts +3 -0
  190. package/lib/parse/specification/payment-channel-claim.js +47 -0
  191. package/lib/parse/specification/payment-channel-create.d.ts +3 -0
  192. package/lib/parse/specification/payment-channel-create.js +47 -0
  193. package/lib/parse/specification/payment-channel-fund.d.ts +3 -0
  194. package/lib/parse/specification/payment-channel-fund.js +43 -0
  195. package/lib/parse/specification/payment-channel.d.ts +16 -0
  196. package/lib/parse/specification/payment-channel.js +27 -0
  197. package/lib/parse/specification/payment.d.ts +3 -0
  198. package/lib/parse/specification/payment.js +67 -0
  199. package/lib/parse/specification/settings.d.ts +2 -0
  200. package/lib/parse/specification/settings.js +80 -0
  201. package/lib/parse/specification/ticket-create.d.ts +3 -0
  202. package/lib/parse/specification/ticket-create.js +39 -0
  203. package/lib/parse/specification/trustline.d.ts +3 -0
  204. package/lib/parse/specification/trustline.js +57 -0
  205. package/lib/parse/transaction.d.ts +27 -0
  206. package/lib/parse/transaction.js +114 -0
  207. package/lib/parse/utils.d.ts +6 -0
  208. package/lib/parse/utils.js +38 -0
  209. package/lib/types/amounts.d.ts +16 -0
  210. package/lib/types/amounts.js +2 -0
  211. package/lib/types/index.d.ts +1 -0
  212. package/lib/types/index.js +2 -0
  213. package/lib/v1/common/constants.d.ts +16 -0
  214. package/lib/v1/common/constants.js +6 -0
  215. package/lib/v1/common/errors/index.d.ts +3 -0
  216. package/lib/v1/common/errors/index.js +7 -0
  217. package/lib/v1/common/errors/ripple_error.d.ts +9 -0
  218. package/lib/v1/common/errors/ripple_error.js +28 -0
  219. package/lib/v1/common/errors/utils.d.ts +2 -0
  220. package/lib/v1/common/errors/utils.js +19 -0
  221. package/lib/v1/common/errors/validation_error.d.ts +4 -0
  222. package/lib/v1/common/errors/validation_error.js +7 -0
  223. package/lib/v1/common/index.d.ts +3 -0
  224. package/lib/v1/common/index.js +31 -0
  225. package/lib/v1/common/txflags.d.ts +51 -0
  226. package/lib/v1/common/txflags.js +55 -0
  227. package/lib/v1/common/types/commands/account_info.d.ts +17 -0
  228. package/lib/v1/common/types/commands/account_info.js +2 -0
  229. package/lib/v1/common/types/commands/account_lines.d.ts +17 -0
  230. package/lib/v1/common/types/commands/account_lines.js +2 -0
  231. package/lib/v1/common/types/commands/account_objects.d.ts +26 -0
  232. package/lib/v1/common/types/commands/account_objects.js +2 -0
  233. package/lib/v1/common/types/commands/account_offers.d.ts +24 -0
  234. package/lib/v1/common/types/commands/account_offers.js +2 -0
  235. package/lib/v1/common/types/commands/book_offers.d.ts +23 -0
  236. package/lib/v1/common/types/commands/book_offers.js +2 -0
  237. package/lib/v1/common/types/commands/gateway_balances.d.ts +23 -0
  238. package/lib/v1/common/types/commands/gateway_balances.js +2 -0
  239. package/lib/v1/common/types/commands/index.d.ts +10 -0
  240. package/lib/v1/common/types/commands/index.js +26 -0
  241. package/lib/v1/common/types/commands/ledger.d.ts +18 -0
  242. package/lib/v1/common/types/commands/ledger.js +2 -0
  243. package/lib/v1/common/types/commands/ledger_data.d.ts +10 -0
  244. package/lib/v1/common/types/commands/ledger_data.js +2 -0
  245. package/lib/v1/common/types/commands/ledger_entry.d.ts +29 -0
  246. package/lib/v1/common/types/commands/ledger_entry.js +2 -0
  247. package/lib/v1/common/types/commands/path_find.d.ts +33 -0
  248. package/lib/v1/common/types/commands/path_find.js +2 -0
  249. package/lib/v1/common/types/commands/server_info.d.ts +49 -0
  250. package/lib/v1/common/types/commands/server_info.js +2 -0
  251. package/lib/v1/common/types/objects/account.d.ts +6 -0
  252. package/lib/v1/common/types/objects/account.js +2 -0
  253. package/lib/v1/common/types/objects/adjustments.d.ts +16 -0
  254. package/lib/v1/common/types/objects/adjustments.js +2 -0
  255. package/lib/v1/common/types/objects/amendments.d.ts +4 -0
  256. package/lib/v1/common/types/objects/amendments.js +2 -0
  257. package/lib/v1/common/types/objects/amounts.d.ts +13 -0
  258. package/lib/v1/common/types/objects/amounts.js +2 -0
  259. package/lib/v1/common/types/objects/checks.d.ts +17 -0
  260. package/lib/v1/common/types/objects/checks.js +2 -0
  261. package/lib/v1/common/types/objects/deposits.d.ts +5 -0
  262. package/lib/v1/common/types/objects/deposits.js +2 -0
  263. package/lib/v1/common/types/objects/escrows.d.ts +21 -0
  264. package/lib/v1/common/types/objects/escrows.js +2 -0
  265. package/lib/v1/common/types/objects/fees.d.ts +7 -0
  266. package/lib/v1/common/types/objects/fees.js +2 -0
  267. package/lib/v1/common/types/objects/flags.d.ts +5 -0
  268. package/lib/v1/common/types/objects/flags.js +8 -0
  269. package/lib/v1/common/types/objects/index.d.ts +15 -0
  270. package/lib/v1/common/types/objects/index.js +31 -0
  271. package/lib/v1/common/types/objects/ledger.d.ts +45 -0
  272. package/lib/v1/common/types/objects/ledger.js +2 -0
  273. package/lib/v1/common/types/objects/ledger_data.d.ts +10 -0
  274. package/lib/v1/common/types/objects/ledger_data.js +2 -0
  275. package/lib/v1/common/types/objects/ledger_entries.d.ts +158 -0
  276. package/lib/v1/common/types/objects/ledger_entries.js +2 -0
  277. package/lib/v1/common/types/objects/memos.d.ts +12 -0
  278. package/lib/v1/common/types/objects/memos.js +2 -0
  279. package/lib/v1/common/types/objects/nftokens.d.ts +47 -0
  280. package/lib/v1/common/types/objects/nftokens.js +13 -0
  281. package/lib/v1/common/types/objects/offers.d.ts +15 -0
  282. package/lib/v1/common/types/objects/offers.js +2 -0
  283. package/lib/v1/common/types/objects/orders.d.ts +13 -0
  284. package/lib/v1/common/types/objects/orders.js +2 -0
  285. package/lib/v1/common/types/objects/path_find.d.ts +27 -0
  286. package/lib/v1/common/types/objects/path_find.js +2 -0
  287. package/lib/v1/common/types/objects/payment_channels.d.ts +25 -0
  288. package/lib/v1/common/types/objects/payment_channels.js +2 -0
  289. package/lib/v1/common/types/objects/payments.d.ts +20 -0
  290. package/lib/v1/common/types/objects/payments.js +2 -0
  291. package/lib/v1/common/types/objects/queue_data.d.ts +15 -0
  292. package/lib/v1/common/types/objects/queue_data.js +2 -0
  293. package/lib/v1/common/types/objects/settings.d.ts +34 -0
  294. package/lib/v1/common/types/objects/settings.js +2 -0
  295. package/lib/v1/common/types/objects/signers.d.ts +6 -0
  296. package/lib/v1/common/types/objects/signers.js +2 -0
  297. package/lib/v1/common/types/objects/specification.d.ts +4 -0
  298. package/lib/v1/common/types/objects/specification.js +2 -0
  299. package/lib/v1/common/types/objects/tickets.d.ts +4 -0
  300. package/lib/v1/common/types/objects/tickets.js +2 -0
  301. package/lib/v1/common/types/objects/transactions.d.ts +21 -0
  302. package/lib/v1/common/types/objects/transactions.js +2 -0
  303. package/lib/v1/common/types/objects/trustlines.d.ts +38 -0
  304. package/lib/v1/common/types/objects/trustlines.js +2 -0
  305. package/lib/v1/common/types/pathfind-types.d.ts +59 -0
  306. package/lib/v1/common/types/pathfind-types.js +2 -0
  307. package/lib/v1/common/utils.d.ts +6 -0
  308. package/lib/v1/common/utils.js +58 -0
  309. package/lib/v1/index.d.ts +2 -0
  310. package/lib/v1/index.js +28 -0
  311. package/lib/v1/ledger/index.d.ts +1 -0
  312. package/lib/v1/ledger/index.js +27 -0
  313. package/lib/v1/ledger/parse/account-delete.d.ts +7 -0
  314. package/lib/v1/ledger/parse/account-delete.js +42 -0
  315. package/lib/v1/ledger/parse/account-order.d.ts +10 -0
  316. package/lib/v1/ledger/parse/account-order.js +39 -0
  317. package/lib/v1/ledger/parse/account-trustline.d.ts +3 -0
  318. package/lib/v1/ledger/parse/account-trustline.js +27 -0
  319. package/lib/v1/ledger/parse/amendment.d.ts +5 -0
  320. package/lib/v1/ledger/parse/amendment.js +14 -0
  321. package/lib/v1/ledger/parse/amount.d.ts +3 -0
  322. package/lib/v1/ledger/parse/amount.js +40 -0
  323. package/lib/v1/ledger/parse/cancellation.d.ts +2 -0
  324. package/lib/v1/ledger/parse/cancellation.js +38 -0
  325. package/lib/v1/ledger/parse/check-cancel.d.ts +5 -0
  326. package/lib/v1/ledger/parse/check-cancel.js +39 -0
  327. package/lib/v1/ledger/parse/check-cash.d.ts +8 -0
  328. package/lib/v1/ledger/parse/check-cash.js +42 -0
  329. package/lib/v1/ledger/parse/check-create.d.ts +10 -0
  330. package/lib/v1/ledger/parse/check-create.js +45 -0
  331. package/lib/v1/ledger/parse/currency-amount.d.ts +3 -0
  332. package/lib/v1/ledger/parse/currency-amount.js +13 -0
  333. package/lib/v1/ledger/parse/deposit-preauth.d.ts +6 -0
  334. package/lib/v1/ledger/parse/deposit-preauth.js +40 -0
  335. package/lib/v1/ledger/parse/escrow-cancellation.d.ts +2 -0
  336. package/lib/v1/ledger/parse/escrow-cancellation.js +40 -0
  337. package/lib/v1/ledger/parse/escrow-creation.d.ts +2 -0
  338. package/lib/v1/ledger/parse/escrow-creation.js +47 -0
  339. package/lib/v1/ledger/parse/escrow-execution.d.ts +2 -0
  340. package/lib/v1/ledger/parse/escrow-execution.js +42 -0
  341. package/lib/v1/ledger/parse/fee-update.d.ts +8 -0
  342. package/lib/v1/ledger/parse/fee-update.js +19 -0
  343. package/lib/v1/ledger/parse/fields.d.ts +2 -0
  344. package/lib/v1/ledger/parse/fields.js +42 -0
  345. package/lib/v1/ledger/parse/flags.d.ts +15 -0
  346. package/lib/v1/ledger/parse/flags.js +19 -0
  347. package/lib/v1/ledger/parse/index.d.ts +4 -0
  348. package/lib/v1/ledger/parse/index.js +25 -0
  349. package/lib/v1/ledger/parse/ledger.d.ts +18 -0
  350. package/lib/v1/ledger/parse/ledger.js +77 -0
  351. package/lib/v1/ledger/parse/memos.d.ts +3 -0
  352. package/lib/v1/ledger/parse/memos.js +17 -0
  353. package/lib/v1/ledger/parse/order.d.ts +3 -0
  354. package/lib/v1/ledger/parse/order.js +53 -0
  355. package/lib/v1/ledger/parse/orderbook-order.d.ts +16 -0
  356. package/lib/v1/ledger/parse/orderbook-order.js +66 -0
  357. package/lib/v1/ledger/parse/pathfind.d.ts +3 -0
  358. package/lib/v1/ledger/parse/pathfind.js +66 -0
  359. package/lib/v1/ledger/parse/payment-channel-claim.d.ts +2 -0
  360. package/lib/v1/ledger/parse/payment-channel-claim.js +47 -0
  361. package/lib/v1/ledger/parse/payment-channel-create.d.ts +2 -0
  362. package/lib/v1/ledger/parse/payment-channel-create.js +47 -0
  363. package/lib/v1/ledger/parse/payment-channel-fund.d.ts +2 -0
  364. package/lib/v1/ledger/parse/payment-channel-fund.js +43 -0
  365. package/lib/v1/ledger/parse/payment-channel.d.ts +16 -0
  366. package/lib/v1/ledger/parse/payment-channel.js +27 -0
  367. package/lib/v1/ledger/parse/payment.d.ts +2 -0
  368. package/lib/v1/ledger/parse/payment.js +69 -0
  369. package/lib/v1/ledger/parse/ripple-amount.d.ts +3 -0
  370. package/lib/v1/ledger/parse/ripple-amount.js +40 -0
  371. package/lib/v1/ledger/parse/settings.d.ts +2 -0
  372. package/lib/v1/ledger/parse/settings.js +82 -0
  373. package/lib/v1/ledger/parse/ticket-create.d.ts +2 -0
  374. package/lib/v1/ledger/parse/ticket-create.js +39 -0
  375. package/lib/v1/ledger/parse/transaction.d.ts +3 -0
  376. package/lib/v1/ledger/parse/transaction.js +110 -0
  377. package/lib/v1/ledger/parse/trustline.d.ts +2 -0
  378. package/lib/v1/ledger/parse/trustline.js +57 -0
  379. package/lib/v1/ledger/parse/utils.d.ts +6 -0
  380. package/lib/v1/ledger/parse/utils.js +63 -0
  381. package/lib/v1/ledger/parse_outcome.d.ts +2 -0
  382. package/lib/v1/ledger/parse_outcome.js +80 -0
  383. package/lib/v1/ledger/pathfind-types.d.ts +59 -0
  384. package/lib/v1/ledger/pathfind-types.js +2 -0
  385. package/lib/v1/transaction/payment.d.ts +14 -0
  386. package/lib/v1/transaction/payment.js +130 -0
  387. package/lib/v1/transaction/types.d.ts +40 -0
  388. package/lib/v1/transaction/types.js +2 -0
  389. package/lib/v1/transaction/utils.d.ts +8 -0
  390. package/lib/v1/transaction/utils.js +38 -0
  391. package/lib/validator.d.ts +12 -0
  392. package/lib/validator.js +134 -0
  393. package/lib/wallet.d.ts +17 -0
  394. package/lib/wallet.js +140 -0
  395. package/package.json +62 -0
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.parseFinalLockedBalances = exports.parseLockedBalanceChanges = void 0;
30
+ const _ = __importStar(require("lodash"));
31
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
32
+ const utils_1 = require("../../v1/common/utils");
33
+ function groupByAddress(lockedBalanceChanges) {
34
+ const grouped = _.groupBy(lockedBalanceChanges, function (node) {
35
+ return node.address;
36
+ });
37
+ return _.mapValues(grouped, function (group) {
38
+ return _.map(group, function (node) {
39
+ return node.lockedBalance;
40
+ });
41
+ });
42
+ }
43
+ function parseValue(value) {
44
+ return new bignumber_js_1.default(value.value || value);
45
+ }
46
+ function computeBalanceChange(node) {
47
+ var value = null;
48
+ if (node.newFields.LockedBalance) {
49
+ value = parseValue(node.newFields.LockedBalance);
50
+ }
51
+ else if (node.previousFields.LockedBalance && node.finalFields.LockedBalance) {
52
+ value = parseValue(node.finalFields.LockedBalance).minus(parseValue(node.previousFields.LockedBalance));
53
+ }
54
+ return value === null ? null : value.isZero() ? null : value;
55
+ }
56
+ function parseFinalBalance(node) {
57
+ if (node.newFields.LockedBalance) {
58
+ return parseValue(node.newFields.LockedBalance);
59
+ }
60
+ else if (node.finalFields.LockedBalance) {
61
+ return parseValue(node.finalFields.LockedBalance);
62
+ }
63
+ return null;
64
+ }
65
+ function parseXRPQuantity(node, valueParser) {
66
+ var value = valueParser(node);
67
+ if (value === null) {
68
+ return null;
69
+ }
70
+ return {
71
+ address: node.finalFields.Account || node.newFields.Account,
72
+ lockedBalance: {
73
+ counterparty: '',
74
+ currency: 'XRP',
75
+ value: (0, utils_1.dropsToXrp)(value).toString()
76
+ }
77
+ };
78
+ }
79
+ function parseTrustlineQuantity(node, valueParser) {
80
+ var value = valueParser(node);
81
+ if (value === null) {
82
+ return null;
83
+ }
84
+ var fields = _.isEmpty(node.newFields) ? node.finalFields : node.newFields;
85
+ var result = {
86
+ address: fields.LowLimit.issuer,
87
+ lockedBalance: {
88
+ counterparty: fields.HighLimit.issuer,
89
+ currency: fields.LockedBalance.currency,
90
+ value: value.toString()
91
+ }
92
+ };
93
+ return [result];
94
+ }
95
+ function parseQuantities(metadata, valueParser) {
96
+ var values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
97
+ if (node.entryType === 'AccountRoot') {
98
+ return [parseXRPQuantity(node, valueParser)];
99
+ }
100
+ else if (node.entryType === 'RippleState') {
101
+ return parseTrustlineQuantity(node, valueParser);
102
+ }
103
+ return [];
104
+ });
105
+ return groupByAddress(_.compact(_.flatten(values)));
106
+ }
107
+ function parseLockedBalanceChanges(metadata) {
108
+ return parseQuantities(metadata, computeBalanceChange);
109
+ }
110
+ exports.parseLockedBalanceChanges = parseLockedBalanceChanges;
111
+ function parseFinalLockedBalances(metadata) {
112
+ return parseQuantities(metadata, parseFinalBalance);
113
+ }
114
+ exports.parseFinalLockedBalances = parseFinalLockedBalances;
@@ -0,0 +1 @@
1
+ export declare function parseNFTokenChanges(tx: object): object;
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.parseNFTokenChanges = void 0;
27
+ const _ = __importStar(require("lodash"));
28
+ const AddressCodec = require("ripple-address-codec");
29
+ const common_1 = require("../../v1/common");
30
+ function parseNFTokenChanges(tx) {
31
+ return new NFTokenChanges(tx).call();
32
+ }
33
+ exports.parseNFTokenChanges = parseNFTokenChanges;
34
+ class NFTokenChanges {
35
+ constructor(tx) {
36
+ this.tx = tx;
37
+ this.changes = {};
38
+ this.affectedAccounts = [];
39
+ this.finalNFTokens = {};
40
+ this.previousNFTokens = {};
41
+ }
42
+ call() {
43
+ if (this.hasAffectedNodes() === false) {
44
+ return this.changes;
45
+ }
46
+ this.parseAffectedNodes();
47
+ this.parseNFTokensChanges();
48
+ return this.changes;
49
+ }
50
+ hasAffectedNodes() {
51
+ if (this.tx.meta?.AffectedNodes === undefined) {
52
+ return false;
53
+ }
54
+ if (this.tx.meta?.AffectedNodes?.length === 0) {
55
+ return false;
56
+ }
57
+ return true;
58
+ }
59
+ addChange(account, change) {
60
+ if (!this.changes[account]) {
61
+ this.changes[account] = [];
62
+ }
63
+ this.changes[account].push((0, common_1.removeUndefined)(change));
64
+ }
65
+ parseAffectedNodes() {
66
+ for (const affectedNode of this.tx.meta.AffectedNodes) {
67
+ const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
68
+ if (node?.LedgerEntryType === "NFTokenPage" && node?.LedgerIndex) {
69
+ const account = AddressCodec.encodeAccountID(Buffer.from(node?.LedgerIndex.slice(0, 40), "hex"));
70
+ if (this.affectedAccounts.includes(account) === false) {
71
+ this.affectedAccounts.push(account);
72
+ }
73
+ if (affectedNode.CreatedNode) {
74
+ this.parseFinalNFTokens(account, node.NewFields?.NFTokens);
75
+ }
76
+ if ((affectedNode.ModifiedNode || affectedNode.DeletedNode) && Array.isArray(node.PreviousFields?.NFTokens)) {
77
+ this.parseFinalNFTokens(account, node.FinalFields?.NFTokens);
78
+ this.parsePreviousNFTokens(account, node.PreviousFields?.NFTokens);
79
+ }
80
+ if (affectedNode.DeletedNode && node.PreviousFields === undefined) {
81
+ this.parsePreviousNFTokens(account, node.FinalFields?.NFTokens);
82
+ }
83
+ }
84
+ }
85
+ }
86
+ parseFinalNFTokens(account, NFTokens) {
87
+ if (this.finalNFTokens[account] === undefined) {
88
+ this.finalNFTokens[account] = [];
89
+ }
90
+ if (Array.isArray(NFTokens)) {
91
+ this.finalNFTokens[account] = _.concat(this.finalNFTokens[account], NFTokens);
92
+ }
93
+ }
94
+ parsePreviousNFTokens(account, NFTokens) {
95
+ if (this.previousNFTokens[account] === undefined) {
96
+ this.previousNFTokens[account] = [];
97
+ }
98
+ if (Array.isArray(NFTokens)) {
99
+ this.previousNFTokens[account] = _.concat(this.previousNFTokens[account], NFTokens);
100
+ }
101
+ }
102
+ parseNFTokensChanges() {
103
+ for (const account of this.affectedAccounts) {
104
+ let finalTokens = [];
105
+ if (Array.isArray(this.finalNFTokens[account])) {
106
+ finalTokens = this.finalNFTokens[account].map((NFToken) => NFToken.NFToken.NFTokenID);
107
+ finalTokens = [...new Set(finalTokens)];
108
+ }
109
+ let previousTokens = [];
110
+ if (Array.isArray(this.previousNFTokens[account])) {
111
+ previousTokens = this.previousNFTokens[account].map((NFToken) => NFToken.NFToken.NFTokenID);
112
+ previousTokens = [...new Set(previousTokens)];
113
+ }
114
+ const added = _.difference(finalTokens, previousTokens);
115
+ const removed = _.difference(previousTokens, finalTokens);
116
+ for (const nftokenID of added) {
117
+ const uri = this.findNFTokenUri(nftokenID);
118
+ this.addChange(account, {
119
+ status: "added",
120
+ nftokenID,
121
+ uri,
122
+ });
123
+ }
124
+ for (const nftokenID of removed) {
125
+ const uri = this.findNFTokenUri(nftokenID);
126
+ this.addChange(account, {
127
+ status: "removed",
128
+ nftokenID,
129
+ uri,
130
+ });
131
+ }
132
+ }
133
+ }
134
+ findNFTokenUri(nftokenID) {
135
+ for (const affectedNode of this.tx.meta.AffectedNodes) {
136
+ const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
137
+ if (node?.LedgerEntryType === "NFTokenPage") {
138
+ if (Array.isArray(node.NewFields?.NFTokens)) {
139
+ for (const tokenNode of node.NewFields?.NFTokens) {
140
+ if (tokenNode.NFToken.NFTokenID === nftokenID) {
141
+ return tokenNode.NFToken.URI;
142
+ }
143
+ }
144
+ }
145
+ if (Array.isArray(node.FinalFields?.NFTokens)) {
146
+ for (const tokenNode of node.FinalFields?.NFTokens) {
147
+ if (tokenNode.NFToken.NFTokenID === nftokenID) {
148
+ return tokenNode.NFToken.URI;
149
+ }
150
+ }
151
+ }
152
+ if (Array.isArray(node.PreviousFields?.NFTokens)) {
153
+ for (const tokenNode of node.PreviousFields?.NFTokens) {
154
+ if (tokenNode.NFToken.NFTokenID === nftokenID) {
155
+ return tokenNode.NFToken.URI;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ return undefined;
162
+ }
163
+ }
@@ -0,0 +1 @@
1
+ export declare function parseNFTokenOfferChanges(tx: object): object;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseNFTokenOfferChanges = void 0;
4
+ const ledger_1 = require("../../models/ledger");
5
+ const common_1 = require("../../v1/common");
6
+ function parseNFTokenOfferChanges(tx) {
7
+ return new NFTokenOfferChanges(tx).call();
8
+ }
9
+ exports.parseNFTokenOfferChanges = parseNFTokenOfferChanges;
10
+ class NFTokenOfferChanges {
11
+ constructor(tx) {
12
+ this.tx = tx;
13
+ this.changes = {};
14
+ }
15
+ call() {
16
+ if (this.hasAffectedNodes() === false) {
17
+ return this.changes;
18
+ }
19
+ for (const affectedNode of this.tx.meta.AffectedNodes) {
20
+ this.parseAffectedNode(affectedNode);
21
+ }
22
+ return this.changes;
23
+ }
24
+ addChange(account, change) {
25
+ if (!this.changes[account]) {
26
+ this.changes[account] = [];
27
+ }
28
+ this.changes[account].push((0, common_1.removeUndefined)(change));
29
+ }
30
+ hasAffectedNodes() {
31
+ if (this.tx.meta?.AffectedNodes === undefined) {
32
+ return false;
33
+ }
34
+ if (this.tx.meta?.AffectedNodes?.length === 0) {
35
+ return false;
36
+ }
37
+ return true;
38
+ }
39
+ parseAffectedNode(affectedNode) {
40
+ if (this.isNFTokensCreateOfferNode(affectedNode)) {
41
+ this.parseNFTokensCreateOfferNode(affectedNode);
42
+ }
43
+ else if (this.isNFTokensDeleteOfferNode(affectedNode)) {
44
+ this.parseNFTokensDeleteOfferNode(affectedNode);
45
+ }
46
+ }
47
+ isNFTokensCreateOfferNode(affectedNode) {
48
+ return affectedNode.CreatedNode?.LedgerEntryType === "NFTokenOffer" && affectedNode.CreatedNode?.NewFields;
49
+ }
50
+ parseNFTokensCreateOfferNode(affectedNode) {
51
+ const status = "created";
52
+ const amount = affectedNode.CreatedNode.NewFields.Amount;
53
+ const flags = affectedNode.CreatedNode.NewFields.Flags;
54
+ const nftokenID = affectedNode.CreatedNode.NewFields.NFTokenID;
55
+ const owner = affectedNode.CreatedNode.NewFields.Owner;
56
+ const index = affectedNode.CreatedNode.LedgerIndex;
57
+ const destination = affectedNode.CreatedNode.NewFields.Destination;
58
+ const prevTxHash = affectedNode.CreatedNode.NewFields.PreviousTxnID;
59
+ const prevLedgerIndex = affectedNode.CreatedNode.NewFields.PreviousTxnLgrSeq;
60
+ let expiration = affectedNode.CreatedNode.NewFields.Expiration;
61
+ if (typeof expiration === "number") {
62
+ expiration = (0, ledger_1.ledgerTimeToUnixTime)(expiration);
63
+ }
64
+ this.addChange(this.tx.Account, {
65
+ status,
66
+ amount,
67
+ flags,
68
+ nftokenID,
69
+ owner,
70
+ destination,
71
+ expiration,
72
+ index,
73
+ prevTxHash,
74
+ prevLedgerIndex,
75
+ });
76
+ }
77
+ isNFTokensDeleteOfferNode(affectedNode) {
78
+ return affectedNode.DeletedNode?.LedgerEntryType === "NFTokenOffer" && affectedNode.DeletedNode?.FinalFields;
79
+ }
80
+ parseNFTokensDeleteOfferNode(affectedNode) {
81
+ const status = "deleted";
82
+ const amount = affectedNode.DeletedNode.FinalFields.Amount;
83
+ const flags = affectedNode.DeletedNode.FinalFields.Flags;
84
+ const nftokenID = affectedNode.DeletedNode.FinalFields.NFTokenID;
85
+ const owner = affectedNode.DeletedNode.FinalFields.Owner;
86
+ const index = affectedNode.DeletedNode.LedgerIndex;
87
+ const destination = affectedNode.DeletedNode.FinalFields.Destination;
88
+ const prevTxHash = affectedNode.DeletedNode.FinalFields.PreviousTxnID;
89
+ const prevLedgerIndex = affectedNode.DeletedNode.FinalFields.PreviousTxnLgrSeq;
90
+ let expiration = affectedNode.DeletedNode.FinalFields.Expiration;
91
+ if (typeof expiration === "number") {
92
+ expiration = (0, ledger_1.ledgerTimeToUnixTime)(expiration);
93
+ }
94
+ this.addChange(owner, {
95
+ status,
96
+ amount,
97
+ flags,
98
+ nftokenID,
99
+ owner,
100
+ destination,
101
+ expiration,
102
+ index,
103
+ prevTxHash,
104
+ prevLedgerIndex,
105
+ });
106
+ }
107
+ }
@@ -0,0 +1,3 @@
1
+ import * as _ from 'lodash';
2
+ declare function parseOrderbookChanges(metadata: any): _.Dictionary<any[]>;
3
+ export { parseOrderbookChanges };
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.parseOrderbookChanges = void 0;
30
+ const _ = __importStar(require("lodash"));
31
+ const bignumber_js_1 = require("bignumber.js");
32
+ const BigNumber = bignumber_js_1.BigNumber.clone({ DECIMAL_PLACES: 40 });
33
+ const utils_1 = require("../../v1/common/utils");
34
+ const quality_1 = require("./quality");
35
+ const currency_amount_1 = __importDefault(require("../../v1/ledger/parse/currency-amount"));
36
+ const lsfSell = 0x00020000;
37
+ function removeUndefined(obj) {
38
+ return _.omitBy(obj, _.isUndefined);
39
+ }
40
+ function convertOrderChange(order) {
41
+ var takerGets = order.taker_gets;
42
+ var takerPays = order.taker_pays;
43
+ var direction = order.sell ? 'sell' : 'buy';
44
+ var quantity = (direction === 'buy') ? takerPays : takerGets;
45
+ var totalPrice = (direction === 'buy') ? takerGets : takerPays;
46
+ return removeUndefined({
47
+ direction: direction,
48
+ quantity: quantity,
49
+ totalPrice: totalPrice,
50
+ sequence: order.sequence,
51
+ status: order.status,
52
+ makerExchangeRate: order.quality,
53
+ expirationTime: order.expiration
54
+ });
55
+ }
56
+ function getExpirationTime(node) {
57
+ var expirationTime = node.finalFields.Expiration || node.newFields.Expiration;
58
+ if (expirationTime === undefined) {
59
+ return undefined;
60
+ }
61
+ return (new Date((0, utils_1.rippleToUnixTimestamp)(expirationTime))).toISOString();
62
+ }
63
+ function getQuality(node) {
64
+ var takerGets = node.finalFields.TakerGets || node.newFields.TakerGets;
65
+ var takerPays = node.finalFields.TakerPays || node.newFields.TakerPays;
66
+ var takerGetsCurrency = takerGets.currency || 'XRP';
67
+ var takerPaysCurrency = takerPays.currency || 'XRP';
68
+ var bookDirectory = node.finalFields.BookDirectory
69
+ || node.newFields.BookDirectory;
70
+ var qualityHex = bookDirectory.substring(bookDirectory.length - 16);
71
+ return (0, quality_1.parseQuality)(qualityHex, takerGetsCurrency, takerPaysCurrency);
72
+ }
73
+ function parseOrderStatus(node) {
74
+ if (node.diffType === 'CreatedNode') {
75
+ return 'created';
76
+ }
77
+ if (node.diffType === 'ModifiedNode') {
78
+ return 'partially-filled';
79
+ }
80
+ if (node.diffType === 'DeletedNode') {
81
+ if (node.previousFields.hasOwnProperty('TakerPays')) {
82
+ return 'filled';
83
+ }
84
+ return 'cancelled';
85
+ }
86
+ return undefined;
87
+ }
88
+ function calculateDelta(finalAmount, previousAmount) {
89
+ if (previousAmount) {
90
+ var finalValue = new BigNumber(finalAmount.value);
91
+ var previousValue = new BigNumber(previousAmount.value);
92
+ return finalValue.minus(previousValue).abs().toString();
93
+ }
94
+ return '0';
95
+ }
96
+ function parseChangeAmount(node, type) {
97
+ var status = parseOrderStatus(node);
98
+ if (status === 'cancelled') {
99
+ return (0, currency_amount_1.default)(node.finalFields[type]);
100
+ }
101
+ else if (status === 'created') {
102
+ return (0, currency_amount_1.default)(node.newFields[type]);
103
+ }
104
+ var finalAmount = (0, currency_amount_1.default)(node.finalFields[type]);
105
+ var previousAmount = (0, currency_amount_1.default)(node.previousFields[type]);
106
+ var value = calculateDelta(finalAmount, previousAmount);
107
+ return _.assign({}, finalAmount, { value: value });
108
+ }
109
+ function parseOrderChange(node) {
110
+ var orderChange = convertOrderChange({
111
+ taker_pays: parseChangeAmount(node, 'TakerPays'),
112
+ taker_gets: parseChangeAmount(node, 'TakerGets'),
113
+ sell: (node.finalFields.Flags & lsfSell) !== 0,
114
+ sequence: node.finalFields.Sequence || node.newFields.Sequence,
115
+ status: parseOrderStatus(node),
116
+ quality: getQuality(node),
117
+ expiration: getExpirationTime(node)
118
+ });
119
+ Object.defineProperty(orderChange, 'account', {
120
+ value: node.finalFields.Account || node.newFields.Account
121
+ });
122
+ return orderChange;
123
+ }
124
+ function groupByAddress(orderChanges) {
125
+ return _.groupBy(orderChanges, function (change) {
126
+ return change.account;
127
+ });
128
+ }
129
+ function parseOrderbookChanges(metadata) {
130
+ var nodes = (0, utils_1.normalizeNodes)(metadata);
131
+ var orderChanges = _.map(_.filter(nodes, function (node) {
132
+ return node.entryType === 'Offer';
133
+ }), parseOrderChange);
134
+ return groupByAddress(orderChanges);
135
+ }
136
+ exports.parseOrderbookChanges = parseOrderbookChanges;
@@ -0,0 +1,2 @@
1
+ declare function parseQuality(qualityHex: any, takerGetsCurrency: any, takerPaysCurrency: any): string;
2
+ export { parseQuality };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.parseQuality = void 0;
30
+ const assert = __importStar(require("assert"));
31
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
32
+ function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
33
+ var numeratorShift = (takerPaysCurrency === 'XRP' ? -6 : 0);
34
+ var denominatorShift = (takerGetsCurrency === 'XRP' ? -6 : 0);
35
+ var shift = numeratorShift - denominatorShift;
36
+ return shift === 0 ? (new bignumber_js_1.default(quality)).toString() :
37
+ (new bignumber_js_1.default(quality)).shiftedBy(shift).toString();
38
+ }
39
+ function parseQuality(qualityHex, takerGetsCurrency, takerPaysCurrency) {
40
+ assert.ok(qualityHex.length === 16);
41
+ var mantissa = new bignumber_js_1.default(qualityHex.substring(2), 16);
42
+ var offset = parseInt(qualityHex.substring(0, 2), 16) - 100;
43
+ var quality = mantissa.toString() + 'e' + offset.toString();
44
+ return adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency);
45
+ }
46
+ exports.parseQuality = parseQuality;
@@ -0,0 +1,39 @@
1
+ import { Transaction, TransactionMetadata } from "xrpl";
2
+ import { FormattedSpecification, FormattedTransaction } from "../parse/transaction";
3
+ export { FormattedTransaction } from "../parse/transaction";
4
+ import { Outcome } from "../v1/transaction/types";
5
+ export interface TransactionBaseResponse {
6
+ hash: string;
7
+ ledger_index?: number;
8
+ meta?: TransactionMetadata | string;
9
+ validated?: boolean;
10
+ date?: number;
11
+ specification?: FormattedSpecification;
12
+ outcome?: Outcome;
13
+ rawTransaction?: string;
14
+ }
15
+ export type TransactionResponse = TransactionBaseResponse & Transaction;
16
+ export type AccountTransaction = {
17
+ tx: TransactionResponse;
18
+ meta: TransactionMetadata;
19
+ validated: boolean;
20
+ };
21
+ export type LedgerTransaction = TransactionBaseResponse & {
22
+ metaData?: TransactionMetadata;
23
+ };
24
+ export type StreamTransaction = TransactionBaseResponse & {
25
+ transaction: TransactionResponse;
26
+ meta: TransactionMetadata;
27
+ };
28
+ export interface AccountPaymentParamsInterface {
29
+ fee?: string;
30
+ sequence?: number;
31
+ lastLedgerSequence?: number;
32
+ }
33
+ export declare function getTxDetails(tx: TransactionResponse, includeRawTransaction: boolean): FormattedTransaction;
34
+ export declare function getAccountTxDetails(tx: AccountTransaction, includeRawTransaction: boolean): FormattedTransaction;
35
+ export declare function getLedgerTxDetails(tx: LedgerTransaction, ledgerIndex: number, closeTime: number, includeRawTransaction: boolean): FormattedTransaction;
36
+ export declare function getStreamTxDetails(tx: StreamTransaction, includeRawTransaction: boolean): FormattedTransaction;
37
+ export declare function AccountTxToTx(accountTx: AccountTransaction): TransactionResponse;
38
+ export declare function LedgerTxToTx(ledgerTx: LedgerTransaction, ledgerIndex: number, closeTime: number): TransactionResponse;
39
+ export declare function StreamTxToTx(streamTx: StreamTransaction): TransactionResponse;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StreamTxToTx = exports.LedgerTxToTx = exports.AccountTxToTx = exports.getStreamTxDetails = exports.getLedgerTxDetails = exports.getAccountTxDetails = exports.getTxDetails = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const transaction_1 = require("../parse/transaction");
9
+ function getTxDetails(tx, includeRawTransaction) {
10
+ return (0, transaction_1.parseTransaction)(tx, includeRawTransaction);
11
+ }
12
+ exports.getTxDetails = getTxDetails;
13
+ function getAccountTxDetails(tx, includeRawTransaction) {
14
+ return getTxDetails(AccountTxToTx(tx), includeRawTransaction);
15
+ }
16
+ exports.getAccountTxDetails = getAccountTxDetails;
17
+ function getLedgerTxDetails(tx, ledgerIndex, closeTime, includeRawTransaction) {
18
+ return getTxDetails(LedgerTxToTx(tx, ledgerIndex, closeTime), includeRawTransaction);
19
+ }
20
+ exports.getLedgerTxDetails = getLedgerTxDetails;
21
+ function getStreamTxDetails(tx, includeRawTransaction) {
22
+ return getTxDetails(StreamTxToTx(tx), includeRawTransaction);
23
+ }
24
+ exports.getStreamTxDetails = getStreamTxDetails;
25
+ function AccountTxToTx(accountTx) {
26
+ return Object.assign({}, accountTx.tx, { meta: accountTx.meta, validated: accountTx.validated });
27
+ }
28
+ exports.AccountTxToTx = AccountTxToTx;
29
+ function LedgerTxToTx(ledgerTx, ledgerIndex, closeTime) {
30
+ const tx = lodash_1.default.omit(ledgerTx, "metaData");
31
+ return Object.assign({}, tx, {
32
+ meta: ledgerTx.metaData,
33
+ date: closeTime,
34
+ ledger_index: ledgerIndex,
35
+ });
36
+ }
37
+ exports.LedgerTxToTx = LedgerTxToTx;
38
+ function StreamTxToTx(streamTx) {
39
+ return Object.assign({}, streamTx.transaction, {
40
+ meta: streamTx.meta,
41
+ ledger_index: streamTx.ledger_index,
42
+ validated: streamTx.validated,
43
+ });
44
+ }
45
+ exports.StreamTxToTx = StreamTxToTx;
@@ -0,0 +1,15 @@
1
+ export interface Trustline {
2
+ account: string;
3
+ balance: string;
4
+ currency: string;
5
+ limit: string;
6
+ limit_peer: string;
7
+ quality_in: number;
8
+ quality_out: number;
9
+ no_ripple?: boolean;
10
+ no_ripple_peer?: boolean;
11
+ authorized?: boolean;
12
+ peer_authorized?: boolean;
13
+ freeze?: boolean;
14
+ freeze_peer?: boolean;
15
+ }