@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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ export declare function parseUint32(buf: Buffer, cur: number): string;
3
+ export declare function parseUint64(buf: Buffer, cur: number): string;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseUint64 = exports.parseUint32 = void 0;
4
+ function parseUint32(buf, cur) {
5
+ return ((BigInt(buf[cur]) << 24n) + (BigInt(buf[cur + 1]) << 16n) + (BigInt(buf[cur + 2]) << 8n) + BigInt(buf[cur + 3]) + "");
6
+ }
7
+ exports.parseUint32 = parseUint32;
8
+ function parseUint64(buf, cur) {
9
+ return ((BigInt(buf[cur]) << 56n) +
10
+ (BigInt(buf[cur + 1]) << 48n) +
11
+ (BigInt(buf[cur + 2]) << 40n) +
12
+ (BigInt(buf[cur + 3]) << 32n) +
13
+ (BigInt(buf[cur + 4]) << 24n) +
14
+ (BigInt(buf[cur + 5]) << 16n) +
15
+ (BigInt(buf[cur + 6]) << 8n) +
16
+ BigInt(buf[cur + 7]) +
17
+ "");
18
+ }
19
+ exports.parseUint64 = parseUint64;
@@ -0,0 +1,60 @@
1
+ import { ManifestInterface } from "./manifest";
2
+ export interface VLInterface {
3
+ version?: number;
4
+ public_key?: string;
5
+ manifest?: string;
6
+ blob?: string;
7
+ signature?: string;
8
+ }
9
+ export interface ParsedVLInterface {
10
+ version?: number;
11
+ PublicKey?: string;
12
+ manifest?: string;
13
+ decodedManifest?: ManifestInterface;
14
+ blob?: ParsedVLBlobInterface;
15
+ signature?: string;
16
+ error?: string;
17
+ }
18
+ export interface ValidatorInterface {
19
+ validation_public_key?: string;
20
+ manifest?: string;
21
+ }
22
+ export interface ParsedValidatorInterface {
23
+ PublicKey?: string;
24
+ manifest?: string;
25
+ decodedManifest?: ManifestInterface;
26
+ }
27
+ export interface VLBlobInterface {
28
+ sequence?: number;
29
+ expiration?: number;
30
+ validators?: ValidatorInterface[];
31
+ }
32
+ export interface ParsedVLBlobInterface {
33
+ sequence?: number;
34
+ expiration?: number;
35
+ validators?: ParsedValidatorInterface[];
36
+ }
37
+ export interface VLDataInterface {
38
+ Flags?: number;
39
+ LedgerSequence?: number;
40
+ CloseTime?: number;
41
+ SigningTime?: number;
42
+ LoadFee?: string;
43
+ ReserveBase?: string;
44
+ ReserveIncrement?: string;
45
+ BaseFee?: string;
46
+ Cookie?: string;
47
+ ServerVersion?: string;
48
+ LedgerHash?: string;
49
+ ConsensusHash?: string;
50
+ ValidatedHash?: string;
51
+ SigningPubKey?: string;
52
+ Signature?: string;
53
+ Amendments?: string[];
54
+ error?: string;
55
+ _verified?: boolean;
56
+ }
57
+ export declare function parseVL(vl: VLInterface): ParsedVLInterface;
58
+ export declare function isValidVL(vl: VLInterface): string | null;
59
+ export declare function encodeVLBlob(vlBlob: VLBlobInterface): string;
60
+ export declare function parseValidationData(data: string, publicKey: string): VLDataInterface;
@@ -0,0 +1,377 @@
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.parseValidationData = exports.encodeVLBlob = exports.isValidVL = exports.parseVL = void 0;
27
+ const manifest_1 = require("./manifest");
28
+ const utils_1 = require("./utils");
29
+ const Validator = __importStar(require("../validator"));
30
+ function parseVL(vl) {
31
+ const decoded = {};
32
+ decoded.version = vl.version;
33
+ decoded.PublicKey = vl.public_key;
34
+ decoded.manifest = vl.manifest;
35
+ let error = isValidVLFormat(vl);
36
+ if (error) {
37
+ decoded.error = error;
38
+ }
39
+ decoded.decodedManifest = (0, manifest_1.parseManifest)(vl.manifest);
40
+ if (!decoded.error && decoded.decodedManifest.error) {
41
+ decoded.error = decoded.decodedManifest.error;
42
+ }
43
+ if (!decoded.error &&
44
+ decoded.PublicKey !== decoded.decodedManifest.PublicKey &&
45
+ decoded.PublicKey !== decoded.decodedManifest.SigningPubKey) {
46
+ decoded.error = "PublicKey does not match manifest";
47
+ }
48
+ decoded.signature = vl.signature;
49
+ if (!decoded.error && !decoded.signature) {
50
+ decoded.error = "Signature (blob) is missing";
51
+ }
52
+ if (decoded.signature && decoded.decodedManifest.SigningPubKey && vl.blob) {
53
+ if (!decoded.error &&
54
+ !Validator.verify(Buffer.from(vl.blob, "base64"), decoded.signature, decoded.decodedManifest.SigningPubKey)) {
55
+ decoded.error = "Signature is not valid";
56
+ }
57
+ }
58
+ const blob = decodeVLBlob(vl.blob);
59
+ error = isValidVLBlob(blob);
60
+ if (!decoded.error && error) {
61
+ decoded.error = error;
62
+ }
63
+ decoded.blob = {
64
+ sequence: blob?.sequence,
65
+ expiration: blob?.expiration,
66
+ validators: [],
67
+ };
68
+ for (const validator of blob?.validators) {
69
+ error = isValidVLBlobValidator(validator);
70
+ if (!decoded.error && error) {
71
+ decoded.error = error;
72
+ }
73
+ const validatorManifest = (0, manifest_1.parseManifest)(validator.manifest);
74
+ if (!decoded.error && validatorManifest.error) {
75
+ decoded.error = validatorManifest.error;
76
+ }
77
+ if (decoded.blob.validators) {
78
+ decoded.blob.validators.push({
79
+ PublicKey: validator.validation_public_key,
80
+ manifest: validator.manifest,
81
+ decodedManifest: validatorManifest,
82
+ });
83
+ }
84
+ }
85
+ return decoded;
86
+ }
87
+ exports.parseVL = parseVL;
88
+ function isValidVL(vl) {
89
+ let error = isValidVLFormat(vl);
90
+ if (error) {
91
+ return error;
92
+ }
93
+ const vlManifest = (0, manifest_1.parseManifest)(vl.manifest);
94
+ if (vlManifest.error) {
95
+ return vlManifest.error;
96
+ }
97
+ const blob = decodeVLBlob(vl.blob);
98
+ error = isValidVLBlob(blob);
99
+ if (error) {
100
+ return error;
101
+ }
102
+ for (const validator of blob?.validators) {
103
+ error = isValidVLBlobValidator(validator);
104
+ if (error) {
105
+ return error;
106
+ }
107
+ }
108
+ return error;
109
+ }
110
+ exports.isValidVL = isValidVL;
111
+ function isValidVLFormat(vl) {
112
+ const { version, public_key, manifest, blob } = vl;
113
+ let error = null;
114
+ if (version === undefined) {
115
+ error = "Version missing from vl";
116
+ }
117
+ if (public_key === undefined) {
118
+ error = "Public key missing from vl";
119
+ }
120
+ if (manifest === undefined) {
121
+ error = "Manifest missing from vl";
122
+ }
123
+ if (blob === undefined) {
124
+ error = "Blob missing from vl";
125
+ }
126
+ if (version !== 1) {
127
+ error = "Version is not supported";
128
+ }
129
+ return error;
130
+ }
131
+ function decodeVLBlob(blob) {
132
+ const decoded = Buffer.from(blob, "base64").toString("ascii");
133
+ return JSON.parse(decoded);
134
+ }
135
+ function encodeVLBlob(vlBlob) {
136
+ return Buffer.from(JSON.stringify(vlBlob)).toString("base64");
137
+ }
138
+ exports.encodeVLBlob = encodeVLBlob;
139
+ function isValidVLBlob(blob) {
140
+ if (blob === null) {
141
+ return "Blob is not valid";
142
+ }
143
+ const { sequence, expiration, validators } = blob;
144
+ let error = null;
145
+ if (sequence === undefined) {
146
+ error = "Sequence missing from blob";
147
+ }
148
+ if (expiration === undefined) {
149
+ error = "Expiration missing from blob";
150
+ }
151
+ if (validators === undefined) {
152
+ error = "Validators missing from blob";
153
+ }
154
+ if (validators && validators.length === 0) {
155
+ error = "Validators is empty";
156
+ }
157
+ return error;
158
+ }
159
+ function isValidVLBlobValidator(validator) {
160
+ const { validation_public_key, manifest } = validator;
161
+ let error = null;
162
+ if (validation_public_key === undefined) {
163
+ error = "Validation public key missing from validator";
164
+ }
165
+ if (manifest === undefined) {
166
+ error = "Manifest missing from validator";
167
+ }
168
+ const parsedManifest = (0, manifest_1.parseManifest)(manifest);
169
+ if (parsedManifest.error) {
170
+ return parsedManifest.error;
171
+ }
172
+ return error;
173
+ }
174
+ function parseValidationData(data, publicKey) {
175
+ const buf = Buffer.from(data, "hex");
176
+ const decoded = {};
177
+ let cur = 0;
178
+ if (buf[cur++] !== 0x22 || buf.length - cur < 5) {
179
+ decoded.error = "sfFlags missing or incomplete";
180
+ return decoded;
181
+ }
182
+ decoded.Flags = parseInt((0, utils_1.parseUint32)(buf, cur), 10);
183
+ cur += 4;
184
+ if (buf[cur++] !== 0x26 || buf.length - cur < 5) {
185
+ decoded.error = "sfLedgerSequnece missing or incomplete";
186
+ return decoded;
187
+ }
188
+ decoded.LedgerSequence = parseInt((0, utils_1.parseUint32)(buf, cur), 10);
189
+ cur += 4;
190
+ if (buf[cur] === 0x27) {
191
+ cur++;
192
+ if (buf.length - cur < 4) {
193
+ decoded.error = "sfCloseTime missing or incomplete";
194
+ return decoded;
195
+ }
196
+ decoded.CloseTime = parseInt((0, utils_1.parseUint32)(buf, cur), 10);
197
+ cur += 4;
198
+ }
199
+ if (buf[cur++] !== 0x29 || buf.length - cur < 5) {
200
+ decoded.error = "sfSigningTime missing or incomplete";
201
+ return decoded;
202
+ }
203
+ decoded.SigningTime = parseInt((0, utils_1.parseUint32)(buf, cur), 10);
204
+ cur += 4;
205
+ if (buf[cur] === 0x20 && buf.length - cur >= 1 && buf[cur + 1] === 0x18) {
206
+ cur += 2;
207
+ if (buf.length - cur < 4) {
208
+ decoded.error = "sfLoadFee payload missing";
209
+ return decoded;
210
+ }
211
+ decoded.LoadFee = (0, utils_1.parseUint32)(buf, cur);
212
+ cur += 4;
213
+ }
214
+ if (buf[cur] === 0x20 && buf.length - cur >= 1 && buf[cur + 1] === 0x1f) {
215
+ cur += 2;
216
+ if (buf.length - cur < 4) {
217
+ decoded.error = "sfReserveBase payload missing";
218
+ return decoded;
219
+ }
220
+ decoded.ReserveBase = (0, utils_1.parseUint32)(buf, cur);
221
+ cur += 4;
222
+ }
223
+ if (buf[cur] === 0x20 && buf.length - cur >= 1 && buf[cur + 1] === 0x20) {
224
+ cur += 2;
225
+ if (buf.length - cur < 4) {
226
+ decoded.error = "sfReserveIncrement payload missing";
227
+ return decoded;
228
+ }
229
+ decoded.ReserveIncrement = (0, utils_1.parseUint32)(buf, cur);
230
+ cur += 4;
231
+ }
232
+ if (buf[cur] === 0x35) {
233
+ cur++;
234
+ if (buf.length - cur < 8) {
235
+ decoded.error = "sfBaseFee missing or incomplete";
236
+ return decoded;
237
+ }
238
+ decoded.BaseFee = (0, utils_1.parseUint64)(buf, cur);
239
+ cur += 8;
240
+ }
241
+ if (buf[cur] === 0x3a) {
242
+ cur++;
243
+ if (buf.length - cur < 8) {
244
+ decoded.error = "sfCookie missing or incomplete";
245
+ return decoded;
246
+ }
247
+ decoded.Cookie = (0, utils_1.parseUint64)(buf, cur);
248
+ cur += 8;
249
+ }
250
+ if (buf[cur] === 0x3b) {
251
+ cur++;
252
+ if (buf.length - cur < 8) {
253
+ decoded.error = "sfServerVersion missing or incomplete";
254
+ return decoded;
255
+ }
256
+ decoded.ServerVersion = (0, utils_1.parseUint64)(buf, cur);
257
+ cur += 8;
258
+ }
259
+ if (buf[cur++] !== 0x51 || buf.length - cur < 5) {
260
+ decoded.error = "sfLedgerHash missing or incomplete";
261
+ return decoded;
262
+ }
263
+ decoded.LedgerHash = buf
264
+ .slice(cur, cur + 32)
265
+ .toString("hex")
266
+ .toUpperCase();
267
+ cur += 32;
268
+ if (buf[cur] === 0x50 && buf.length - cur >= 1 && buf[cur + 1] === 0x17) {
269
+ cur += 2;
270
+ if (buf.length - cur < 32) {
271
+ decoded.error = "sfConsensusHash payload missing";
272
+ return decoded;
273
+ }
274
+ decoded.ConsensusHash = buf
275
+ .slice(cur, cur + 32)
276
+ .toString("hex")
277
+ .toUpperCase();
278
+ cur += 32;
279
+ }
280
+ if (buf[cur] === 0x50 && buf.length - cur >= 1 && buf[cur + 1] === 0x19) {
281
+ cur += 2;
282
+ if (buf.length - cur < 32) {
283
+ decoded.error = "sfValidatedHash payload missing";
284
+ return decoded;
285
+ }
286
+ decoded.ValidatedHash = buf
287
+ .slice(cur, cur + 32)
288
+ .toString("hex")
289
+ .toUpperCase();
290
+ cur += 32;
291
+ }
292
+ if (buf[cur++] !== 0x73 || buf.length - cur < 2) {
293
+ decoded.error = "sfSigningPubKey missing or incomplete";
294
+ return decoded;
295
+ }
296
+ const keySize = buf[cur++];
297
+ if (buf.length - cur < keySize) {
298
+ decoded.error = "sfSigningPubKey payload missing";
299
+ return decoded;
300
+ }
301
+ decoded.SigningPubKey = buf
302
+ .slice(cur, cur + keySize)
303
+ .toString("hex")
304
+ .toUpperCase();
305
+ cur += keySize;
306
+ const sigStart = cur;
307
+ if (buf[cur++] !== 0x76 || buf.length - cur < 2) {
308
+ decoded.error = "sfSignature missing or incomplete";
309
+ return decoded;
310
+ }
311
+ const sigSize = buf[cur++];
312
+ if (buf.length - cur < sigSize) {
313
+ decoded.error = "sfSignature payload missing";
314
+ return decoded;
315
+ }
316
+ decoded.Signature = buf
317
+ .slice(cur, cur + sigSize)
318
+ .toString("hex")
319
+ .toUpperCase();
320
+ cur += sigSize;
321
+ const sigEnd = cur;
322
+ if (buf.length - cur >= 1 && buf[cur] === 0x03 && buf[cur + 1] === 0x13) {
323
+ cur += 2;
324
+ if (buf.length - cur < 1) {
325
+ decoded.error = "sfAmendments payload missing or incomplete [1]";
326
+ return decoded;
327
+ }
328
+ let len = buf[cur++];
329
+ if (len <= 192) {
330
+ }
331
+ else if (len >= 193 && len <= 240) {
332
+ if (buf.length - cur < 1) {
333
+ decoded.error = "sfAmendments payload missing or incomplete [2]";
334
+ return decoded;
335
+ }
336
+ len = 193 + (len - 193) * 256 + buf[cur++];
337
+ }
338
+ else if (len >= 241 && len <= 254) {
339
+ if (buf.length - cur < 2) {
340
+ decoded.error = "sfAmendments payload missing or incomplete [3]";
341
+ return decoded;
342
+ }
343
+ len = 12481 + (len - 241) * 65536 + buf[cur + 1] * 256 + buf[cur + 2];
344
+ cur += 2;
345
+ }
346
+ if (buf.length - cur < len) {
347
+ decoded.error = "sfAmendments payload missing or incomplete [3]";
348
+ return decoded;
349
+ }
350
+ decoded.Amendments = [];
351
+ const amendmentsCurEnd = cur + len;
352
+ while (cur < amendmentsCurEnd) {
353
+ decoded.Amendments.push(buf.slice(cur, cur + 32).toString("hex"));
354
+ cur += 32;
355
+ }
356
+ }
357
+ if (publicKey.toUpperCase() !== decoded.SigningPubKey) {
358
+ decoded._verified = false;
359
+ decoded.error = "SigningPubKey did not match or was not present";
360
+ return decoded;
361
+ }
362
+ const verifyFields = Buffer.concat([
363
+ Buffer.from("VAL\x00", "utf-8"),
364
+ buf.slice(0, sigStart),
365
+ buf.slice(sigEnd, buf.length),
366
+ ]);
367
+ if (decoded.SigningPubKey && decoded.Signature) {
368
+ if (!Validator.verify(verifyFields, decoded.Signature, decoded.SigningPubKey)) {
369
+ decoded._verified = false;
370
+ decoded.error = "Signature did not match or was not present";
371
+ return decoded;
372
+ }
373
+ }
374
+ decoded._verified = true;
375
+ return decoded;
376
+ }
377
+ exports.parseValidationData = parseValidationData;
@@ -0,0 +1,3 @@
1
+ export * as Ledger from "./ledger";
2
+ export { parseOutcome } from "./outcome";
3
+ export { parseTransactionType, parseTransaction } from "./transaction";
@@ -0,0 +1,32 @@
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.parseTransaction = exports.parseTransactionType = exports.parseOutcome = exports.Ledger = void 0;
27
+ exports.Ledger = __importStar(require("./ledger"));
28
+ var outcome_1 = require("./outcome");
29
+ Object.defineProperty(exports, "parseOutcome", { enumerable: true, get: function () { return outcome_1.parseOutcome; } });
30
+ var transaction_1 = require("./transaction");
31
+ Object.defineProperty(exports, "parseTransactionType", { enumerable: true, get: function () { return transaction_1.parseTransactionType; } });
32
+ Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return transaction_1.parseTransaction; } });
@@ -0,0 +1,10 @@
1
+ import { FormattedOfferCreateSpecification } from "../../v1/common/types/objects";
2
+ export type FormattedAccountOrder = {
3
+ specification: FormattedOfferCreateSpecification;
4
+ properties: {
5
+ maker: string;
6
+ sequence: number;
7
+ makerExchangeRate: string;
8
+ };
9
+ };
10
+ export declare function parseAccountOrder(address: string, order: any): FormattedAccountOrder;
@@ -0,0 +1,39 @@
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.parseAccountOrder = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const amount_1 = __importDefault(require("./amount"));
9
+ const utils_1 = require("../utils");
10
+ const common_1 = require("../../common");
11
+ const flags_1 = require("../../v1/common/types/objects/flags");
12
+ function computeQuality(takerGets, takerPays) {
13
+ const quotient = new bignumber_js_1.default(takerPays.value).dividedBy(takerGets.value);
14
+ return quotient.precision(16, bignumber_js_1.default.ROUND_HALF_UP).toString();
15
+ }
16
+ function parseAccountOrder(address, order) {
17
+ const direction = (order.flags & flags_1.orderFlags.Sell) === 0 ? "buy" : "sell";
18
+ const takerGetsAmount = (0, amount_1.default)(order.taker_gets);
19
+ const takerPaysAmount = (0, amount_1.default)(order.taker_pays);
20
+ const quantity = direction === "buy" ? takerPaysAmount : takerGetsAmount;
21
+ const totalPrice = direction === "buy" ? takerGetsAmount : takerPaysAmount;
22
+ const specification = (0, common_1.removeUndefined)({
23
+ direction: direction,
24
+ quantity: quantity,
25
+ totalPrice: totalPrice,
26
+ passive: (order.flags & flags_1.orderFlags.Passive) !== 0 || undefined,
27
+ expirationTime: (0, utils_1.parseTimestamp)(order.expiration),
28
+ });
29
+ const makerExchangeRate = order.quality
30
+ ? (0, utils_1.adjustQualityForXRP)(order.quality.toString(), takerGetsAmount.currency, takerPaysAmount.currency)
31
+ : computeQuality(takerGetsAmount, takerPaysAmount);
32
+ const properties = {
33
+ maker: address,
34
+ sequence: order.seq,
35
+ makerExchangeRate: makerExchangeRate,
36
+ };
37
+ return { specification, properties };
38
+ }
39
+ exports.parseAccountOrder = parseAccountOrder;
@@ -0,0 +1,3 @@
1
+ import { Trustline, FormattedTrustline } from "../../v1/common/types/objects/trustlines";
2
+ declare function parseAccountTrustline(trustline: Trustline): FormattedTrustline;
3
+ export default parseAccountTrustline;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../utils");
4
+ const common_1 = require("../../common");
5
+ function parseAccountTrustline(trustline) {
6
+ const specification = (0, common_1.removeUndefined)({
7
+ limit: trustline.limit,
8
+ currency: trustline.currency,
9
+ counterparty: trustline.account,
10
+ qualityIn: (0, utils_1.parseQuality)(trustline.quality_in) || undefined,
11
+ qualityOut: (0, utils_1.parseQuality)(trustline.quality_out) || undefined,
12
+ ripplingDisabled: trustline.no_ripple,
13
+ frozen: trustline.freeze,
14
+ authorized: trustline.authorized,
15
+ });
16
+ const counterparty = (0, common_1.removeUndefined)({
17
+ limit: trustline.limit_peer,
18
+ ripplingDisabled: trustline.no_ripple_peer,
19
+ frozen: trustline.freeze_peer,
20
+ authorized: trustline.peer_authorized,
21
+ });
22
+ const state = {
23
+ balance: trustline.balance,
24
+ };
25
+ return { specification, counterparty, state };
26
+ }
27
+ exports.default = parseAccountTrustline;
@@ -0,0 +1,3 @@
1
+ import { FormattedIssuedCurrencyAmount, Amount } from "../../v1/common/types/objects";
2
+ declare function parseAmount(amount: Amount): FormattedIssuedCurrencyAmount;
3
+ export default parseAmount;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_1 = require("../../common");
4
+ function parseAmount(amount) {
5
+ if (typeof amount === "string") {
6
+ return {
7
+ currency: "XRP",
8
+ value: (0, common_1.dropsToXrp)(amount),
9
+ };
10
+ }
11
+ return {
12
+ currency: amount.currency,
13
+ value: amount.value,
14
+ counterparty: amount.issuer,
15
+ };
16
+ }
17
+ exports.default = parseAmount;
@@ -0,0 +1,3 @@
1
+ import { FormattedAmount, Amount } from "../../v1/common/types/objects";
2
+ declare function parseCurrencyAmount(amount: Amount): FormattedAmount | undefined;
3
+ export default parseCurrencyAmount;
@@ -0,0 +1,13 @@
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
+ const amount_1 = __importDefault(require("./amount"));
7
+ function parseCurrencyAmount(amount) {
8
+ if (amount === undefined) {
9
+ return undefined;
10
+ }
11
+ return (0, amount_1.default)(amount);
12
+ }
13
+ exports.default = parseCurrencyAmount;
@@ -0,0 +1,2 @@
1
+ declare function parseFields(data: any): object;
2
+ export default parseFields;
@@ -0,0 +1,42 @@
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
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
7
+ const account_info_1 = require("../../models/account_info");
8
+ function parseField(info, value) {
9
+ if (info.encoding === "hex" && !info.length) {
10
+ return Buffer.from(value, "hex").toString("ascii");
11
+ }
12
+ if (info.shift) {
13
+ return new bignumber_js_1.default(value).shiftedBy(-info.shift).toNumber();
14
+ }
15
+ return value;
16
+ }
17
+ function parseFields(data) {
18
+ const settings = {};
19
+ for (const fieldName in account_info_1.AccountFields) {
20
+ const fieldValue = data[fieldName];
21
+ if (fieldValue != null) {
22
+ const info = account_info_1.AccountFields[fieldName];
23
+ settings[info.name] = parseField(info, fieldValue);
24
+ }
25
+ }
26
+ if (data.signer_lists && data.signer_lists.length === 1) {
27
+ settings.signers = {};
28
+ if (data.signer_lists[0].SignerQuorum) {
29
+ settings.signers.threshold = data.signer_lists[0].SignerQuorum;
30
+ }
31
+ if (data.signer_lists[0].SignerEntries) {
32
+ settings.signers.weights = data.signer_lists[0].SignerEntries.map((entry) => {
33
+ return {
34
+ address: entry.SignerEntry.Account,
35
+ weight: entry.SignerEntry.SignerWeight,
36
+ };
37
+ });
38
+ }
39
+ }
40
+ return settings;
41
+ }
42
+ exports.default = parseFields;
@@ -0,0 +1,4 @@
1
+ declare function parseFlags(value: number, keys: any, options?: {
2
+ excludeFalse?: boolean;
3
+ }): any;
4
+ export { parseFlags };