xrpl 4.3.0 → 4.4.0

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 (349) hide show
  1. package/build/xrpl-latest-min.js +1 -1
  2. package/build/xrpl-latest-min.js.map +1 -1
  3. package/build/xrpl-latest.js +1609 -1773
  4. package/build/xrpl-latest.js.map +1 -1
  5. package/dist/npm/client/index.d.ts +3 -3
  6. package/dist/npm/client/index.d.ts.map +1 -1
  7. package/dist/npm/client/index.js +10 -7
  8. package/dist/npm/client/index.js.map +1 -1
  9. package/dist/npm/client/partialPayment.d.ts.map +1 -1
  10. package/dist/npm/client/partialPayment.js +2 -2
  11. package/dist/npm/client/partialPayment.js.map +1 -1
  12. package/dist/npm/models/common/index.d.ts +17 -0
  13. package/dist/npm/models/common/index.d.ts.map +1 -1
  14. package/dist/npm/models/ledger/AccountRoot.d.ts +4 -2
  15. package/dist/npm/models/ledger/AccountRoot.d.ts.map +1 -1
  16. package/dist/npm/models/ledger/AccountRoot.js +1 -0
  17. package/dist/npm/models/ledger/AccountRoot.js.map +1 -1
  18. package/dist/npm/models/ledger/DirectoryNode.d.ts +1 -0
  19. package/dist/npm/models/ledger/DirectoryNode.d.ts.map +1 -1
  20. package/dist/npm/models/ledger/Escrow.d.ts +2 -0
  21. package/dist/npm/models/ledger/Escrow.d.ts.map +1 -1
  22. package/dist/npm/models/ledger/LedgerEntry.d.ts +3 -2
  23. package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
  24. package/dist/npm/models/ledger/MPToken.d.ts +1 -0
  25. package/dist/npm/models/ledger/MPToken.d.ts.map +1 -1
  26. package/dist/npm/models/ledger/MPTokenIssuance.d.ts +1 -0
  27. package/dist/npm/models/ledger/MPTokenIssuance.d.ts.map +1 -1
  28. package/dist/npm/models/ledger/Offer.d.ts +10 -1
  29. package/dist/npm/models/ledger/Offer.d.ts.map +1 -1
  30. package/dist/npm/models/ledger/Offer.js +1 -0
  31. package/dist/npm/models/ledger/Offer.js.map +1 -1
  32. package/dist/npm/models/ledger/Vault.d.ts +21 -0
  33. package/dist/npm/models/ledger/Vault.d.ts.map +1 -0
  34. package/dist/npm/models/ledger/Vault.js +3 -0
  35. package/dist/npm/models/ledger/Vault.js.map +1 -0
  36. package/dist/npm/models/ledger/index.d.ts +2 -1
  37. package/dist/npm/models/ledger/index.d.ts.map +1 -1
  38. package/dist/npm/models/ledger/index.js.map +1 -1
  39. package/dist/npm/models/methods/bookOffers.d.ts +1 -0
  40. package/dist/npm/models/methods/bookOffers.d.ts.map +1 -1
  41. package/dist/npm/models/methods/index.d.ts +5 -4
  42. package/dist/npm/models/methods/index.d.ts.map +1 -1
  43. package/dist/npm/models/methods/pathFind.d.ts +2 -0
  44. package/dist/npm/models/methods/pathFind.d.ts.map +1 -1
  45. package/dist/npm/models/methods/ripplePathFind.d.ts +1 -0
  46. package/dist/npm/models/methods/ripplePathFind.d.ts.map +1 -1
  47. package/dist/npm/models/methods/subscribe.d.ts +4 -0
  48. package/dist/npm/models/methods/subscribe.d.ts.map +1 -1
  49. package/dist/npm/models/methods/vaultInfo.d.ts +46 -0
  50. package/dist/npm/models/methods/vaultInfo.d.ts.map +1 -0
  51. package/dist/npm/models/methods/vaultInfo.js +3 -0
  52. package/dist/npm/models/methods/vaultInfo.js.map +1 -0
  53. package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -1
  54. package/dist/npm/models/transactions/AMMBid.js +7 -5
  55. package/dist/npm/models/transactions/AMMBid.js.map +1 -1
  56. package/dist/npm/models/transactions/AMMClawback.d.ts.map +1 -1
  57. package/dist/npm/models/transactions/AMMClawback.js +5 -6
  58. package/dist/npm/models/transactions/AMMClawback.js.map +1 -1
  59. package/dist/npm/models/transactions/AMMDelete.d.ts.map +1 -1
  60. package/dist/npm/models/transactions/AMMDelete.js +2 -2
  61. package/dist/npm/models/transactions/AMMDelete.js.map +1 -1
  62. package/dist/npm/models/transactions/AMMDeposit.js +3 -3
  63. package/dist/npm/models/transactions/AMMDeposit.js.map +1 -1
  64. package/dist/npm/models/transactions/AMMVote.d.ts.map +1 -1
  65. package/dist/npm/models/transactions/AMMVote.js +2 -2
  66. package/dist/npm/models/transactions/AMMVote.js.map +1 -1
  67. package/dist/npm/models/transactions/AMMWithdraw.js +3 -3
  68. package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -1
  69. package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts +1 -1
  70. package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
  71. package/dist/npm/models/transactions/MPTokenIssuanceCreate.js +17 -8
  72. package/dist/npm/models/transactions/MPTokenIssuanceCreate.js.map +1 -1
  73. package/dist/npm/models/transactions/MPTokenIssuanceSet.js +4 -4
  74. package/dist/npm/models/transactions/MPTokenIssuanceSet.js.map +1 -1
  75. package/dist/npm/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
  76. package/dist/npm/models/transactions/NFTokenCancelOffer.js +1 -1
  77. package/dist/npm/models/transactions/NFTokenCancelOffer.js.map +1 -1
  78. package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
  79. package/dist/npm/models/transactions/NFTokenCreateOffer.js +6 -2
  80. package/dist/npm/models/transactions/NFTokenCreateOffer.js.map +1 -1
  81. package/dist/npm/models/transactions/accountSet.d.ts +2 -1
  82. package/dist/npm/models/transactions/accountSet.d.ts.map +1 -1
  83. package/dist/npm/models/transactions/accountSet.js +1 -0
  84. package/dist/npm/models/transactions/accountSet.js.map +1 -1
  85. package/dist/npm/models/transactions/checkCreate.d.ts.map +1 -1
  86. package/dist/npm/models/transactions/checkCreate.js +1 -2
  87. package/dist/npm/models/transactions/checkCreate.js.map +1 -1
  88. package/dist/npm/models/transactions/clawback.d.ts +2 -2
  89. package/dist/npm/models/transactions/clawback.d.ts.map +1 -1
  90. package/dist/npm/models/transactions/clawback.js +4 -6
  91. package/dist/npm/models/transactions/clawback.js.map +1 -1
  92. package/dist/npm/models/transactions/common.d.ts +13 -4
  93. package/dist/npm/models/transactions/common.d.ts.map +1 -1
  94. package/dist/npm/models/transactions/common.js +184 -28
  95. package/dist/npm/models/transactions/common.js.map +1 -1
  96. package/dist/npm/models/transactions/escrowCreate.d.ts +2 -1
  97. package/dist/npm/models/transactions/escrowCreate.d.ts.map +1 -1
  98. package/dist/npm/models/transactions/escrowCreate.js +1 -6
  99. package/dist/npm/models/transactions/escrowCreate.js.map +1 -1
  100. package/dist/npm/models/transactions/index.d.ts +9 -3
  101. package/dist/npm/models/transactions/index.d.ts.map +1 -1
  102. package/dist/npm/models/transactions/index.js +5 -1
  103. package/dist/npm/models/transactions/index.js.map +1 -1
  104. package/dist/npm/models/transactions/offerCreate.d.ts +4 -1
  105. package/dist/npm/models/transactions/offerCreate.d.ts.map +1 -1
  106. package/dist/npm/models/transactions/offerCreate.js +10 -0
  107. package/dist/npm/models/transactions/offerCreate.js.map +1 -1
  108. package/dist/npm/models/transactions/oracleSet.d.ts.map +1 -1
  109. package/dist/npm/models/transactions/oracleSet.js +22 -21
  110. package/dist/npm/models/transactions/oracleSet.js.map +1 -1
  111. package/dist/npm/models/transactions/payment.d.ts +2 -0
  112. package/dist/npm/models/transactions/payment.d.ts.map +1 -1
  113. package/dist/npm/models/transactions/payment.js +7 -4
  114. package/dist/npm/models/transactions/payment.js.map +1 -1
  115. package/dist/npm/models/transactions/signerListSet.d.ts.map +1 -1
  116. package/dist/npm/models/transactions/signerListSet.js +10 -16
  117. package/dist/npm/models/transactions/signerListSet.js.map +1 -1
  118. package/dist/npm/models/transactions/transaction.d.ts +7 -1
  119. package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
  120. package/dist/npm/models/transactions/transaction.js +28 -35
  121. package/dist/npm/models/transactions/transaction.js.map +1 -1
  122. package/dist/npm/models/transactions/vaultClawback.d.ts +10 -0
  123. package/dist/npm/models/transactions/vaultClawback.d.ts.map +1 -0
  124. package/dist/npm/models/transactions/vaultClawback.js +12 -0
  125. package/dist/npm/models/transactions/vaultClawback.js.map +1 -0
  126. package/dist/npm/models/transactions/vaultCreate.d.ts +24 -0
  127. package/dist/npm/models/transactions/vaultCreate.d.ts.map +1 -0
  128. package/dist/npm/models/transactions/vaultCreate.js +60 -0
  129. package/dist/npm/models/transactions/vaultCreate.js.map +1 -0
  130. package/dist/npm/models/transactions/vaultDelete.d.ts +7 -0
  131. package/dist/npm/models/transactions/vaultDelete.d.ts.map +1 -0
  132. package/dist/npm/models/transactions/vaultDelete.js +10 -0
  133. package/dist/npm/models/transactions/vaultDelete.js.map +1 -0
  134. package/dist/npm/models/transactions/vaultDeposit.d.ts +9 -0
  135. package/dist/npm/models/transactions/vaultDeposit.d.ts.map +1 -0
  136. package/dist/npm/models/transactions/vaultDeposit.js +11 -0
  137. package/dist/npm/models/transactions/vaultDeposit.js.map +1 -0
  138. package/dist/npm/models/transactions/vaultSet.d.ts +10 -0
  139. package/dist/npm/models/transactions/vaultSet.d.ts.map +1 -0
  140. package/dist/npm/models/transactions/vaultSet.js +25 -0
  141. package/dist/npm/models/transactions/vaultSet.js.map +1 -0
  142. package/dist/npm/models/transactions/vaultWithdraw.d.ts +10 -0
  143. package/dist/npm/models/transactions/vaultWithdraw.d.ts.map +1 -0
  144. package/dist/npm/models/transactions/vaultWithdraw.js +12 -0
  145. package/dist/npm/models/transactions/vaultWithdraw.js.map +1 -0
  146. package/dist/npm/models/utils/flags.d.ts.map +1 -1
  147. package/dist/npm/models/utils/flags.js +2 -0
  148. package/dist/npm/models/utils/flags.js.map +1 -1
  149. package/dist/npm/snippets/src/permissionedDEX.d.ts +2 -0
  150. package/dist/npm/snippets/src/permissionedDEX.d.ts.map +1 -0
  151. package/dist/npm/snippets/src/permissionedDEX.js +173 -0
  152. package/dist/npm/snippets/src/permissionedDEX.js.map +1 -0
  153. package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
  154. package/dist/npm/src/client/index.d.ts +3 -3
  155. package/dist/npm/src/client/index.d.ts.map +1 -1
  156. package/dist/npm/src/client/index.js +10 -7
  157. package/dist/npm/src/client/index.js.map +1 -1
  158. package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
  159. package/dist/npm/src/client/partialPayment.js +2 -2
  160. package/dist/npm/src/client/partialPayment.js.map +1 -1
  161. package/dist/npm/src/models/common/index.d.ts +17 -0
  162. package/dist/npm/src/models/common/index.d.ts.map +1 -1
  163. package/dist/npm/src/models/ledger/AccountRoot.d.ts +4 -2
  164. package/dist/npm/src/models/ledger/AccountRoot.d.ts.map +1 -1
  165. package/dist/npm/src/models/ledger/AccountRoot.js +1 -0
  166. package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
  167. package/dist/npm/src/models/ledger/DirectoryNode.d.ts +1 -0
  168. package/dist/npm/src/models/ledger/DirectoryNode.d.ts.map +1 -1
  169. package/dist/npm/src/models/ledger/Escrow.d.ts +2 -0
  170. package/dist/npm/src/models/ledger/Escrow.d.ts.map +1 -1
  171. package/dist/npm/src/models/ledger/LedgerEntry.d.ts +3 -2
  172. package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
  173. package/dist/npm/src/models/ledger/MPToken.d.ts +1 -0
  174. package/dist/npm/src/models/ledger/MPToken.d.ts.map +1 -1
  175. package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts +1 -0
  176. package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts.map +1 -1
  177. package/dist/npm/src/models/ledger/Offer.d.ts +10 -1
  178. package/dist/npm/src/models/ledger/Offer.d.ts.map +1 -1
  179. package/dist/npm/src/models/ledger/Offer.js +1 -0
  180. package/dist/npm/src/models/ledger/Offer.js.map +1 -1
  181. package/dist/npm/src/models/ledger/Vault.d.ts +21 -0
  182. package/dist/npm/src/models/ledger/Vault.d.ts.map +1 -0
  183. package/dist/npm/src/models/ledger/Vault.js +3 -0
  184. package/dist/npm/src/models/ledger/Vault.js.map +1 -0
  185. package/dist/npm/src/models/ledger/index.d.ts +2 -1
  186. package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
  187. package/dist/npm/src/models/ledger/index.js.map +1 -1
  188. package/dist/npm/src/models/methods/bookOffers.d.ts +1 -0
  189. package/dist/npm/src/models/methods/bookOffers.d.ts.map +1 -1
  190. package/dist/npm/src/models/methods/index.d.ts +5 -4
  191. package/dist/npm/src/models/methods/index.d.ts.map +1 -1
  192. package/dist/npm/src/models/methods/pathFind.d.ts +2 -0
  193. package/dist/npm/src/models/methods/pathFind.d.ts.map +1 -1
  194. package/dist/npm/src/models/methods/ripplePathFind.d.ts +1 -0
  195. package/dist/npm/src/models/methods/ripplePathFind.d.ts.map +1 -1
  196. package/dist/npm/src/models/methods/subscribe.d.ts +4 -0
  197. package/dist/npm/src/models/methods/subscribe.d.ts.map +1 -1
  198. package/dist/npm/src/models/methods/vaultInfo.d.ts +46 -0
  199. package/dist/npm/src/models/methods/vaultInfo.d.ts.map +1 -0
  200. package/dist/npm/src/models/methods/vaultInfo.js +3 -0
  201. package/dist/npm/src/models/methods/vaultInfo.js.map +1 -0
  202. package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -1
  203. package/dist/npm/src/models/transactions/AMMBid.js +7 -5
  204. package/dist/npm/src/models/transactions/AMMBid.js.map +1 -1
  205. package/dist/npm/src/models/transactions/AMMClawback.d.ts.map +1 -1
  206. package/dist/npm/src/models/transactions/AMMClawback.js +5 -6
  207. package/dist/npm/src/models/transactions/AMMClawback.js.map +1 -1
  208. package/dist/npm/src/models/transactions/AMMDelete.d.ts.map +1 -1
  209. package/dist/npm/src/models/transactions/AMMDelete.js +2 -2
  210. package/dist/npm/src/models/transactions/AMMDelete.js.map +1 -1
  211. package/dist/npm/src/models/transactions/AMMDeposit.js +3 -3
  212. package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -1
  213. package/dist/npm/src/models/transactions/AMMVote.d.ts.map +1 -1
  214. package/dist/npm/src/models/transactions/AMMVote.js +2 -2
  215. package/dist/npm/src/models/transactions/AMMVote.js.map +1 -1
  216. package/dist/npm/src/models/transactions/AMMWithdraw.js +3 -3
  217. package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -1
  218. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts +1 -1
  219. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
  220. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js +17 -8
  221. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js.map +1 -1
  222. package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js +4 -4
  223. package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js.map +1 -1
  224. package/dist/npm/src/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
  225. package/dist/npm/src/models/transactions/NFTokenCancelOffer.js +1 -1
  226. package/dist/npm/src/models/transactions/NFTokenCancelOffer.js.map +1 -1
  227. package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
  228. package/dist/npm/src/models/transactions/NFTokenCreateOffer.js +6 -2
  229. package/dist/npm/src/models/transactions/NFTokenCreateOffer.js.map +1 -1
  230. package/dist/npm/src/models/transactions/accountSet.d.ts +2 -1
  231. package/dist/npm/src/models/transactions/accountSet.d.ts.map +1 -1
  232. package/dist/npm/src/models/transactions/accountSet.js +1 -0
  233. package/dist/npm/src/models/transactions/accountSet.js.map +1 -1
  234. package/dist/npm/src/models/transactions/checkCreate.d.ts.map +1 -1
  235. package/dist/npm/src/models/transactions/checkCreate.js +1 -2
  236. package/dist/npm/src/models/transactions/checkCreate.js.map +1 -1
  237. package/dist/npm/src/models/transactions/clawback.d.ts +2 -2
  238. package/dist/npm/src/models/transactions/clawback.d.ts.map +1 -1
  239. package/dist/npm/src/models/transactions/clawback.js +4 -6
  240. package/dist/npm/src/models/transactions/clawback.js.map +1 -1
  241. package/dist/npm/src/models/transactions/common.d.ts +13 -4
  242. package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
  243. package/dist/npm/src/models/transactions/common.js +184 -28
  244. package/dist/npm/src/models/transactions/common.js.map +1 -1
  245. package/dist/npm/src/models/transactions/escrowCreate.d.ts +2 -1
  246. package/dist/npm/src/models/transactions/escrowCreate.d.ts.map +1 -1
  247. package/dist/npm/src/models/transactions/escrowCreate.js +1 -6
  248. package/dist/npm/src/models/transactions/escrowCreate.js.map +1 -1
  249. package/dist/npm/src/models/transactions/index.d.ts +9 -3
  250. package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
  251. package/dist/npm/src/models/transactions/index.js +5 -1
  252. package/dist/npm/src/models/transactions/index.js.map +1 -1
  253. package/dist/npm/src/models/transactions/offerCreate.d.ts +4 -1
  254. package/dist/npm/src/models/transactions/offerCreate.d.ts.map +1 -1
  255. package/dist/npm/src/models/transactions/offerCreate.js +10 -0
  256. package/dist/npm/src/models/transactions/offerCreate.js.map +1 -1
  257. package/dist/npm/src/models/transactions/oracleSet.d.ts.map +1 -1
  258. package/dist/npm/src/models/transactions/oracleSet.js +22 -21
  259. package/dist/npm/src/models/transactions/oracleSet.js.map +1 -1
  260. package/dist/npm/src/models/transactions/payment.d.ts +2 -0
  261. package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
  262. package/dist/npm/src/models/transactions/payment.js +7 -4
  263. package/dist/npm/src/models/transactions/payment.js.map +1 -1
  264. package/dist/npm/src/models/transactions/signerListSet.d.ts.map +1 -1
  265. package/dist/npm/src/models/transactions/signerListSet.js +10 -16
  266. package/dist/npm/src/models/transactions/signerListSet.js.map +1 -1
  267. package/dist/npm/src/models/transactions/transaction.d.ts +7 -1
  268. package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
  269. package/dist/npm/src/models/transactions/transaction.js +28 -35
  270. package/dist/npm/src/models/transactions/transaction.js.map +1 -1
  271. package/dist/npm/src/models/transactions/vaultClawback.d.ts +10 -0
  272. package/dist/npm/src/models/transactions/vaultClawback.d.ts.map +1 -0
  273. package/dist/npm/src/models/transactions/vaultClawback.js +12 -0
  274. package/dist/npm/src/models/transactions/vaultClawback.js.map +1 -0
  275. package/dist/npm/src/models/transactions/vaultCreate.d.ts +24 -0
  276. package/dist/npm/src/models/transactions/vaultCreate.d.ts.map +1 -0
  277. package/dist/npm/src/models/transactions/vaultCreate.js +60 -0
  278. package/dist/npm/src/models/transactions/vaultCreate.js.map +1 -0
  279. package/dist/npm/src/models/transactions/vaultDelete.d.ts +7 -0
  280. package/dist/npm/src/models/transactions/vaultDelete.d.ts.map +1 -0
  281. package/dist/npm/src/models/transactions/vaultDelete.js +10 -0
  282. package/dist/npm/src/models/transactions/vaultDelete.js.map +1 -0
  283. package/dist/npm/src/models/transactions/vaultDeposit.d.ts +9 -0
  284. package/dist/npm/src/models/transactions/vaultDeposit.d.ts.map +1 -0
  285. package/dist/npm/src/models/transactions/vaultDeposit.js +11 -0
  286. package/dist/npm/src/models/transactions/vaultDeposit.js.map +1 -0
  287. package/dist/npm/src/models/transactions/vaultSet.d.ts +10 -0
  288. package/dist/npm/src/models/transactions/vaultSet.d.ts.map +1 -0
  289. package/dist/npm/src/models/transactions/vaultSet.js +25 -0
  290. package/dist/npm/src/models/transactions/vaultSet.js.map +1 -0
  291. package/dist/npm/src/models/transactions/vaultWithdraw.d.ts +10 -0
  292. package/dist/npm/src/models/transactions/vaultWithdraw.d.ts.map +1 -0
  293. package/dist/npm/src/models/transactions/vaultWithdraw.js +12 -0
  294. package/dist/npm/src/models/transactions/vaultWithdraw.js.map +1 -0
  295. package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
  296. package/dist/npm/src/models/utils/flags.js +2 -0
  297. package/dist/npm/src/models/utils/flags.js.map +1 -1
  298. package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
  299. package/dist/npm/src/sugar/autofill.js.map +1 -1
  300. package/dist/npm/sugar/autofill.d.ts.map +1 -1
  301. package/dist/npm/sugar/autofill.js.map +1 -1
  302. package/package.json +6 -5
  303. package/src/client/index.ts +43 -38
  304. package/src/client/partialPayment.ts +1 -2
  305. package/src/models/common/index.ts +27 -0
  306. package/src/models/ledger/AccountRoot.ts +11 -1
  307. package/src/models/ledger/DirectoryNode.ts +3 -0
  308. package/src/models/ledger/Escrow.ts +14 -1
  309. package/src/models/ledger/LedgerEntry.ts +3 -0
  310. package/src/models/ledger/MPToken.ts +1 -0
  311. package/src/models/ledger/MPTokenIssuance.ts +1 -0
  312. package/src/models/ledger/Offer.ts +21 -0
  313. package/src/models/ledger/Vault.ts +83 -0
  314. package/src/models/ledger/index.ts +3 -1
  315. package/src/models/methods/bookOffers.ts +7 -0
  316. package/src/models/methods/index.ts +10 -0
  317. package/src/models/methods/pathFind.ts +10 -0
  318. package/src/models/methods/ripplePathFind.ts +5 -0
  319. package/src/models/methods/subscribe.ts +21 -0
  320. package/src/models/methods/vaultInfo.ts +193 -0
  321. package/src/models/transactions/AMMBid.ts +12 -20
  322. package/src/models/transactions/AMMClawback.ts +8 -11
  323. package/src/models/transactions/AMMDelete.ts +7 -3
  324. package/src/models/transactions/AMMDeposit.ts +4 -4
  325. package/src/models/transactions/AMMVote.ts +7 -3
  326. package/src/models/transactions/AMMWithdraw.ts +4 -4
  327. package/src/models/transactions/MPTokenIssuanceCreate.ts +36 -11
  328. package/src/models/transactions/MPTokenIssuanceSet.ts +1 -1
  329. package/src/models/transactions/NFTokenCancelOffer.ts +2 -2
  330. package/src/models/transactions/NFTokenCreateOffer.ts +8 -4
  331. package/src/models/transactions/accountSet.ts +2 -0
  332. package/src/models/transactions/checkCreate.ts +2 -6
  333. package/src/models/transactions/clawback.ts +9 -10
  334. package/src/models/transactions/common.ts +350 -42
  335. package/src/models/transactions/escrowCreate.ts +8 -12
  336. package/src/models/transactions/index.ts +14 -3
  337. package/src/models/transactions/offerCreate.ts +25 -0
  338. package/src/models/transactions/oracleSet.ts +32 -39
  339. package/src/models/transactions/payment.ts +25 -7
  340. package/src/models/transactions/signerListSet.ts +21 -21
  341. package/src/models/transactions/transaction.ts +46 -43
  342. package/src/models/transactions/vaultClawback.ts +55 -0
  343. package/src/models/transactions/vaultCreate.ts +166 -0
  344. package/src/models/transactions/vaultDelete.ts +32 -0
  345. package/src/models/transactions/vaultDeposit.ts +42 -0
  346. package/src/models/transactions/vaultSet.ts +71 -0
  347. package/src/models/transactions/vaultWithdraw.ts +51 -0
  348. package/src/models/utils/flags.ts +2 -0
  349. package/src/sugar/autofill.ts +5 -6
@@ -4,7 +4,9 @@ import { isHex } from '../utils'
4
4
 
5
5
  import {
6
6
  BaseTransaction,
7
+ isArray,
7
8
  isNumber,
9
+ isRecord,
8
10
  isString,
9
11
  validateBaseTransaction,
10
12
  validateOptionalField,
@@ -90,7 +92,7 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
90
92
  tx,
91
93
  'PriceDataSeries',
92
94
  (value: unknown): value is PriceData => {
93
- if (!Array.isArray(value)) {
95
+ if (!isArray(value)) {
94
96
  throw new ValidationError('OracleSet: PriceDataSeries must be an array')
95
97
  }
96
98
 
@@ -102,14 +104,15 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
102
104
 
103
105
  // TODO: add support for handling inner objects easier (similar to validateRequiredField/validateOptionalField)
104
106
  for (const priceData of value) {
105
- if (typeof priceData !== 'object') {
107
+ if (!isRecord(priceData)) {
106
108
  throw new ValidationError(
107
109
  'OracleSet: PriceDataSeries must be an array of objects',
108
110
  )
109
111
  }
110
112
 
111
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
112
- if (priceData.PriceData == null) {
113
+ const priceDataInner = priceData.PriceData
114
+
115
+ if (!isRecord(priceDataInner)) {
113
116
  throw new ValidationError(
114
117
  'OracleSet: PriceDataSeries must have a `PriceData` object',
115
118
  )
@@ -122,15 +125,16 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
122
125
  )
123
126
  }
124
127
 
125
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
126
- if (typeof priceData.PriceData.BaseAsset !== 'string') {
128
+ if (
129
+ priceDataInner.BaseAsset == null ||
130
+ typeof priceDataInner.BaseAsset !== 'string'
131
+ ) {
127
132
  throw new ValidationError(
128
133
  'OracleSet: PriceDataSeries must have a `BaseAsset` string',
129
134
  )
130
135
  }
131
136
 
132
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
133
- if (typeof priceData.PriceData.QuoteAsset !== 'string') {
137
+ if (typeof priceDataInner.QuoteAsset !== 'string') {
134
138
  throw new ValidationError(
135
139
  'OracleSet: PriceDataSeries must have a `QuoteAsset` string',
136
140
  )
@@ -138,34 +142,31 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
138
142
 
139
143
  // Either AssetPrice and Scale are both present or both excluded
140
144
  if (
141
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
142
- (priceData.PriceData.AssetPrice == null) !==
143
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
144
- (priceData.PriceData.Scale == null)
145
+ (priceDataInner.AssetPrice == null) !==
146
+ (priceDataInner.Scale == null)
145
147
  ) {
146
148
  throw new ValidationError(
147
149
  'OracleSet: PriceDataSeries must have both `AssetPrice` and `Scale` if any are present',
148
150
  )
149
151
  }
150
152
 
151
- /* eslint-disable @typescript-eslint/no-unsafe-member-access, max-depth --
152
- we need to validate priceData.PriceData.AssetPrice value */
153
- if ('AssetPrice' in priceData.PriceData) {
154
- if (!isNumber(priceData.PriceData.AssetPrice)) {
155
- if (typeof priceData.PriceData.AssetPrice !== 'string') {
153
+ /* eslint-disable max-depth --
154
+ we need to validate priceDataInner.AssetPrice value */
155
+ if ('AssetPrice' in priceDataInner) {
156
+ if (!isNumber(priceDataInner.AssetPrice)) {
157
+ if (typeof priceDataInner.AssetPrice !== 'string') {
156
158
  throw new ValidationError(
157
159
  'OracleSet: Field AssetPrice must be a string or a number',
158
160
  )
159
161
  }
160
- if (!isHex(priceData.PriceData.AssetPrice)) {
162
+ if (!isHex(priceDataInner.AssetPrice)) {
161
163
  throw new ValidationError(
162
164
  'OracleSet: Field AssetPrice must be a valid hex string',
163
165
  )
164
166
  }
165
167
  if (
166
- priceData.PriceData.AssetPrice.length <
167
- MINIMUM_ASSET_PRICE_LENGTH ||
168
- priceData.PriceData.AssetPrice.length > MAXIMUM_ASSET_PRICE_LENGTH
168
+ priceDataInner.AssetPrice.length < MINIMUM_ASSET_PRICE_LENGTH ||
169
+ priceDataInner.AssetPrice.length > MAXIMUM_ASSET_PRICE_LENGTH
169
170
  ) {
170
171
  throw new ValidationError(
171
172
  `OracleSet: Length of AssetPrice field must be between ${MINIMUM_ASSET_PRICE_LENGTH} and ${MAXIMUM_ASSET_PRICE_LENGTH} characters long`,
@@ -173,26 +174,18 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
173
174
  }
174
175
  }
175
176
  }
176
- /* eslint-enable @typescript-eslint/no-unsafe-member-access, max-depth */
177
177
 
178
- if (
179
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
180
- 'Scale' in priceData.PriceData &&
181
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
182
- !isNumber(priceData.PriceData.Scale)
183
- ) {
184
- throw new ValidationError('OracleSet: invalid field Scale')
185
- }
178
+ if ('Scale' in priceDataInner) {
179
+ if (!isNumber(priceDataInner.Scale)) {
180
+ throw new ValidationError('OracleSet: invalid field Scale')
181
+ }
186
182
 
187
- if (
188
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
189
- priceData.PriceData.Scale < 0 ||
190
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
191
- priceData.PriceData.Scale > SCALE_MAX
192
- ) {
193
- throw new ValidationError(
194
- `OracleSet: Scale must be in range 0-${SCALE_MAX}`,
195
- )
183
+ if (priceDataInner.Scale < 0 || priceDataInner.Scale > SCALE_MAX) {
184
+ throw new ValidationError(
185
+ `OracleSet: Scale must be in range 0-${SCALE_MAX}`,
186
+ )
187
+ }
188
+ /* eslint-enable max-depth */
196
189
  }
197
190
  }
198
191
  return true
@@ -8,12 +8,14 @@ import {
8
8
  GlobalFlagsInterface,
9
9
  validateBaseTransaction,
10
10
  isAccount,
11
+ isDomainID,
11
12
  validateRequiredField,
12
13
  validateOptionalField,
13
14
  isNumber,
14
15
  Account,
15
16
  validateCredentialsList,
16
17
  MAX_AUTHORIZED_CREDENTIALS,
18
+ isArray,
17
19
  } from './common'
18
20
  import type { TransactionMetadataBase } from './metadata'
19
21
 
@@ -119,6 +121,9 @@ export interface Payment extends BaseTransaction {
119
121
  * to this amount instead.
120
122
  */
121
123
  Amount: Amount | MPTAmount
124
+
125
+ DeliverMax?: Amount | MPTAmount
126
+
122
127
  /** The unique address of the account receiving the payment. */
123
128
  Destination: Account
124
129
  /**
@@ -156,6 +161,18 @@ export interface Payment extends BaseTransaction {
156
161
  * The credentials included must not be expired.
157
162
  */
158
163
  CredentialIDs?: string[]
164
+ /**
165
+ * The domain the sender intends to use. Both the sender and destination must
166
+ * be part of this domain. The DomainID can be included if the sender intends
167
+ * it to be a cross-currency payment (i.e. if the payment is going to interact
168
+ * with the DEX). The domain will only play it's role if there is a path that
169
+ * crossing an orderbook.
170
+ *
171
+ * Note: it's still possible that DomainID is included but the payment does
172
+ * not interact with DEX, it simply means that the DomainID will be ignored
173
+ * during payment paths.
174
+ */
175
+ DomainID?: string
159
176
  Flags?: number | PaymentFlagsInterface
160
177
  }
161
178
 
@@ -195,11 +212,12 @@ export function validatePayment(tx: Record<string, unknown>): void {
195
212
  throw new ValidationError('PaymentTransaction: InvoiceID must be a string')
196
213
  }
197
214
 
198
- if (
199
- tx.Paths !== undefined &&
200
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
201
- !isPaths(tx.Paths as Array<Array<Record<string, unknown>>>)
202
- ) {
215
+ validateOptionalField(tx, 'DomainID', isDomainID, {
216
+ txType: 'PaymentTransaction',
217
+ paramName: 'DomainID',
218
+ })
219
+
220
+ if (tx.Paths !== undefined && !isPaths(tx.Paths)) {
203
221
  throw new ValidationError('PaymentTransaction: invalid Paths')
204
222
  }
205
223
 
@@ -276,12 +294,12 @@ function isPath(path: unknown): path is Path {
276
294
  }
277
295
 
278
296
  function isPaths(paths: unknown): paths is Path[] {
279
- if (!Array.isArray(paths) || paths.length === 0) {
297
+ if (!isArray(paths) || paths.length === 0) {
280
298
  return false
281
299
  }
282
300
 
283
301
  for (const path of paths) {
284
- if (!Array.isArray(path) || path.length === 0) {
302
+ if (!isArray(path) || path.length === 0) {
285
303
  return false
286
304
  }
287
305
 
@@ -1,7 +1,15 @@
1
1
  import { ValidationError } from '../../errors'
2
2
  import { SignerEntry } from '../common'
3
3
 
4
- import { BaseTransaction, isArray, validateBaseTransaction } from './common'
4
+ import {
5
+ BaseTransaction,
6
+ isArray,
7
+ isNumber,
8
+ isRecord,
9
+ isString,
10
+ validateBaseTransaction,
11
+ validateRequiredField,
12
+ } from './common'
5
13
 
6
14
  /**
7
15
  * The SignerListSet transaction creates, replaces, or removes a list of
@@ -39,27 +47,14 @@ const HEX_WALLET_LOCATOR_REGEX = /^[0-9A-Fa-f]{64}$/u
39
47
  export function validateSignerListSet(tx: Record<string, unknown>): void {
40
48
  validateBaseTransaction(tx)
41
49
 
42
- if (tx.SignerQuorum === undefined) {
43
- throw new ValidationError('SignerListSet: missing field SignerQuorum')
44
- }
45
-
46
- if (typeof tx.SignerQuorum !== 'number') {
47
- throw new ValidationError('SignerListSet: invalid SignerQuorum')
48
- }
50
+ validateRequiredField(tx, 'SignerQuorum', isNumber)
49
51
 
50
52
  // All other checks are for if SignerQuorum is greater than 0
51
53
  if (tx.SignerQuorum === 0) {
52
54
  return
53
55
  }
54
56
 
55
- if (tx.SignerEntries === undefined) {
56
- throw new ValidationError('SignerListSet: missing field SignerEntries')
57
- }
58
-
59
- if (!isArray(tx.SignerEntries)) {
60
- throw new ValidationError('SignerListSet: invalid SignerEntries')
61
- }
62
-
57
+ validateRequiredField(tx, 'SignerEntries', isArray)
63
58
  if (tx.SignerEntries.length === 0) {
64
59
  throw new ValidationError(
65
60
  'SignerListSet: need at least 1 member in SignerEntries',
@@ -73,12 +68,17 @@ export function validateSignerListSet(tx: Record<string, unknown>): void {
73
68
  }
74
69
 
75
70
  for (const entry of tx.SignerEntries) {
76
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Should be a SignerEntry
77
- const signerEntry = entry as SignerEntry
78
- const { WalletLocator } = signerEntry.SignerEntry
71
+ if (!isRecord(entry) || !isRecord(entry.SignerEntry)) {
72
+ throw new ValidationError(
73
+ 'SignerListSet: SignerEntries must be an array of SignerEntry objects',
74
+ )
75
+ }
76
+ const signerEntry = entry.SignerEntry
77
+ const { WalletLocator } = signerEntry
79
78
  if (
80
- WalletLocator !== undefined &&
81
- !HEX_WALLET_LOCATOR_REGEX.test(WalletLocator)
79
+ WalletLocator != null &&
80
+ (!isString(WalletLocator) ||
81
+ !HEX_WALLET_LOCATOR_REGEX.test(WalletLocator))
82
82
  ) {
83
83
  throw new ValidationError(
84
84
  `SignerListSet: WalletLocator in SignerEntry must be a 256-bit (32-byte) hexadecimal value`,
@@ -2,8 +2,6 @@
2
2
  /* eslint-disable max-lines-per-function -- need to work with a lot of Tx verifications */
3
3
 
4
4
  import { ValidationError } from '../../errors'
5
- import { IssuedCurrencyAmount, Memo } from '../common'
6
- import { isHex } from '../utils'
7
5
  import { convertTxFlagsToNumber } from '../utils/flags'
8
6
 
9
7
  import { AccountDelete, validateAccountDelete } from './accountDelete'
@@ -20,7 +18,11 @@ import { CheckCancel, validateCheckCancel } from './checkCancel'
20
18
  import { CheckCash, validateCheckCash } from './checkCash'
21
19
  import { CheckCreate, validateCheckCreate } from './checkCreate'
22
20
  import { Clawback, validateClawback } from './clawback'
23
- import { BaseTransaction, isIssuedCurrency } from './common'
21
+ import {
22
+ BaseTransaction,
23
+ isIssuedCurrencyAmount,
24
+ validateBaseTransaction,
25
+ } from './common'
24
26
  import { CredentialAccept, validateCredentialAccept } from './CredentialAccept'
25
27
  import { CredentialCreate, validateCredentialCreate } from './CredentialCreate'
26
28
  import { CredentialDelete, validateCredentialDelete } from './CredentialDelete'
@@ -92,6 +94,12 @@ import { SignerListSet, validateSignerListSet } from './signerListSet'
92
94
  import { TicketCreate, validateTicketCreate } from './ticketCreate'
93
95
  import { TrustSet, validateTrustSet } from './trustSet'
94
96
  import { UNLModify } from './UNLModify'
97
+ import { VaultClawback, validateVaultClawback } from './vaultClawback'
98
+ import { VaultCreate, validateVaultCreate } from './vaultCreate'
99
+ import { VaultDelete, validateVaultDelete } from './vaultDelete'
100
+ import { VaultDeposit, validateVaultDeposit } from './vaultDeposit'
101
+ import { VaultSet, validateVaultSet } from './vaultSet'
102
+ import { VaultWithdraw, validateVaultWithdraw } from './vaultWithdraw'
95
103
  import {
96
104
  XChainAccountCreateCommit,
97
105
  validateXChainAccountCreateCommit,
@@ -173,6 +181,12 @@ export type SubmittableTransaction =
173
181
  | SignerListSet
174
182
  | TicketCreate
175
183
  | TrustSet
184
+ | VaultClawback
185
+ | VaultCreate
186
+ | VaultDelete
187
+ | VaultDeposit
188
+ | VaultSet
189
+ | VaultWithdraw
176
190
  | XChainAccountCreateCommit
177
191
  | XChainAddAccountCreateAttestation
178
192
  | XChainAddClaimAttestation
@@ -216,50 +230,15 @@ export interface TransactionAndMetadata<
216
230
  */
217
231
  export function validate(transaction: Record<string, unknown>): void {
218
232
  const tx = { ...transaction }
219
- if (tx.TransactionType == null) {
220
- throw new ValidationError('Object does not have a `TransactionType`')
221
- }
222
- if (typeof tx.TransactionType !== 'string') {
223
- throw new ValidationError("Object's `TransactionType` is not a string")
224
- }
225
-
226
- /*
227
- * - Memos have exclusively hex data.
228
- */
229
- if (tx.Memos != null && typeof tx.Memos !== 'object') {
230
- throw new ValidationError('Memo must be array')
231
- }
232
- if (tx.Memos != null) {
233
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- needed here
234
- ;(tx.Memos as Array<Memo | null>).forEach((memo) => {
235
- if (memo?.Memo == null) {
236
- throw new ValidationError('Memo data must be in a `Memo` field')
237
- }
238
- if (memo.Memo.MemoData) {
239
- if (!isHex(memo.Memo.MemoData)) {
240
- throw new ValidationError('MemoData field must be a hex value')
241
- }
242
- }
243
-
244
- if (memo.Memo.MemoType) {
245
- if (!isHex(memo.Memo.MemoType)) {
246
- throw new ValidationError('MemoType field must be a hex value')
247
- }
248
- }
249
233
 
250
- if (memo.Memo.MemoFormat) {
251
- if (!isHex(memo.Memo.MemoFormat)) {
252
- throw new ValidationError('MemoFormat field must be a hex value')
253
- }
254
- }
255
- })
256
- }
234
+ // should already be done in the tx-specific validation, but doesn't hurt to check again
235
+ validateBaseTransaction(tx)
257
236
 
258
237
  Object.keys(tx).forEach((key) => {
259
238
  const standard_currency_code_len = 3
260
- if (tx[key] && isIssuedCurrency(tx[key])) {
261
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- needed
262
- const txCurrency = (tx[key] as IssuedCurrencyAmount).currency
239
+ const value = tx[key]
240
+ if (value && isIssuedCurrencyAmount(value)) {
241
+ const txCurrency = value.currency
263
242
 
264
243
  if (
265
244
  txCurrency.length === standard_currency_code_len &&
@@ -476,6 +455,30 @@ export function validate(transaction: Record<string, unknown>): void {
476
455
  validateTrustSet(tx)
477
456
  break
478
457
 
458
+ case 'VaultClawback':
459
+ validateVaultClawback(tx)
460
+ break
461
+
462
+ case 'VaultCreate':
463
+ validateVaultCreate(tx)
464
+ break
465
+
466
+ case 'VaultDelete':
467
+ validateVaultDelete(tx)
468
+ break
469
+
470
+ case 'VaultDeposit':
471
+ validateVaultDeposit(tx)
472
+ break
473
+
474
+ case 'VaultSet':
475
+ validateVaultSet(tx)
476
+ break
477
+
478
+ case 'VaultWithdraw':
479
+ validateVaultWithdraw(tx)
480
+ break
481
+
479
482
  case 'XChainAccountCreateCommit':
480
483
  validateXChainAccountCreateCommit(tx)
481
484
  break
@@ -0,0 +1,55 @@
1
+ import { ClawbackAmount } from '../common'
2
+
3
+ import {
4
+ BaseTransaction,
5
+ validateBaseTransaction,
6
+ validateRequiredField,
7
+ isString,
8
+ Account,
9
+ isAccount,
10
+ validateOptionalField,
11
+ isClawbackAmount,
12
+ } from './common'
13
+
14
+ /**
15
+ * The VaultClawback transaction performs a Clawback from the Vault, exchanging the shares of an account.
16
+ *
17
+ * Conceptually, the transaction performs VaultWithdraw on behalf of the Holder, sending the funds to the
18
+ * Issuer account of the asset. In case there are insufficient funds for the entire Amount the transaction
19
+ * will perform a partial Clawback, up to the Vault.AssetsAvailable. The Clawback transaction must respect
20
+ * any future fees or penalties.
21
+ *
22
+ * @category Transaction Models
23
+ */
24
+ export interface VaultClawback extends BaseTransaction {
25
+ TransactionType: 'VaultClawback'
26
+
27
+ /**
28
+ * The ID of the vault from which assets are withdrawn.
29
+ */
30
+ VaultID: string
31
+
32
+ /**
33
+ * The account ID from which to clawback the assets.
34
+ */
35
+ Holder: Account
36
+
37
+ /**
38
+ * The asset amount to clawback. When Amount is 0 clawback all funds, up to the total shares the Holder owns.
39
+ */
40
+ Amount?: ClawbackAmount
41
+ }
42
+
43
+ /**
44
+ * Verify the form and type of a {@link VaultClawback} at runtime.
45
+ *
46
+ * @param tx - A {@link VaultClawback} Transaction.
47
+ * @throws When the {@link VaultClawback} is malformed.
48
+ */
49
+ export function validateVaultClawback(tx: Record<string, unknown>): void {
50
+ validateBaseTransaction(tx)
51
+
52
+ validateRequiredField(tx, 'VaultID', isString)
53
+ validateRequiredField(tx, 'Holder', isAccount)
54
+ validateOptionalField(tx, 'Amount', isClawbackAmount)
55
+ }
@@ -0,0 +1,166 @@
1
+ import { ValidationError } from '../../errors'
2
+ import { Currency } from '../common'
3
+ import { hasFlag, isHex } from '../utils'
4
+
5
+ import {
6
+ BaseTransaction,
7
+ validateBaseTransaction,
8
+ GlobalFlagsInterface,
9
+ validateOptionalField,
10
+ isNumber,
11
+ isCurrency,
12
+ validateRequiredField,
13
+ isString,
14
+ VAULT_DATA_MAX_BYTE_LENGTH,
15
+ XRPLNumber,
16
+ isXRPLNumber,
17
+ MAX_MPT_META_BYTE_LENGTH,
18
+ MPT_META_WARNING_HEADER,
19
+ validateMPTokenMetadata,
20
+ } from './common'
21
+
22
+ /**
23
+ * Enum representing withdrawal strategies for a Vault.
24
+ */
25
+ export enum VaultWithdrawalPolicy {
26
+ vaultStrategyFirstComeFirstServe = 0x0001,
27
+ }
28
+
29
+ /**
30
+ * Enum representing values of {@link VaultCreate} transaction flags.
31
+ *
32
+ * @category Transaction Flags
33
+ */
34
+ export enum VaultCreateFlags {
35
+ tfVaultPrivate = 0x00010000,
36
+ tfVaultShareNonTransferable = 0x00020000,
37
+ }
38
+
39
+ /**
40
+ * Map of flags to boolean values representing {@link VaultCreate} transaction
41
+ * flags.
42
+ *
43
+ * @category Transaction Flags
44
+ */
45
+ export interface VaultCreateFlagsInterface extends GlobalFlagsInterface {
46
+ tfVaultPrivate?: boolean
47
+ tfVaultShareNonTransferable?: boolean
48
+ }
49
+
50
+ /**
51
+ * The VaultCreate transaction creates a new Vault object.
52
+ *
53
+ * @category Transaction Models
54
+ */
55
+ export interface VaultCreate extends BaseTransaction {
56
+ TransactionType: 'VaultCreate'
57
+
58
+ /**
59
+ * The asset (XRP, IOU or MPT) of the Vault.
60
+ */
61
+ Asset: Currency
62
+
63
+ /**
64
+ * Arbitrary Vault metadata, limited to 256 bytes.
65
+ */
66
+ Data?: string
67
+
68
+ /**
69
+ * The maximum asset amount that can be held in a vault.
70
+ */
71
+ AssetsMaximum?: XRPLNumber
72
+
73
+ /**
74
+ * Arbitrary metadata about the share MPT, in hex format, limited to 1024 bytes.
75
+ *
76
+ * The decoded value must be a UTF-8 encoded JSON object that adheres to the
77
+ * XLS-89d MPTokenMetadata standard.
78
+ *
79
+ * While adherence to the XLS-89d format is not mandatory, non-compliant metadata
80
+ * may not be discoverable by ecosystem tools such as explorers and indexers.
81
+ */
82
+ MPTokenMetadata?: string
83
+
84
+ /**
85
+ * Indicates the withdrawal strategy used by the Vault.
86
+ */
87
+ WithdrawalPolicy?: number
88
+
89
+ /**
90
+ * The PermissionedDomain object ID associated with the shares of this Vault.
91
+ */
92
+ DomainID?: string
93
+ }
94
+
95
+ /* eslint-disable max-lines-per-function -- Not needed to reduce function */
96
+ /* eslint-disable max-statements -- required to do all field validations */
97
+ /**
98
+ * Verify the form and type of an {@link VaultCreate} at runtime.
99
+ *
100
+ * @param tx - A {@link VaultCreate} Transaction.
101
+ * @throws When the {@link VaultCreate} is malformed.
102
+ */
103
+ export function validateVaultCreate(tx: Record<string, unknown>): void {
104
+ validateBaseTransaction(tx)
105
+
106
+ validateRequiredField(tx, 'Asset', isCurrency)
107
+ validateOptionalField(tx, 'Data', isString)
108
+ validateOptionalField(tx, 'AssetsMaximum', isXRPLNumber)
109
+ validateOptionalField(tx, 'MPTokenMetadata', isString)
110
+ validateOptionalField(tx, 'WithdrawalPolicy', isNumber)
111
+ validateOptionalField(tx, 'DomainID', isString)
112
+
113
+ if (tx.Data !== undefined) {
114
+ const dataHex = tx.Data
115
+ if (!isHex(dataHex)) {
116
+ throw new ValidationError('VaultCreate: Data must be a valid hex string')
117
+ }
118
+ const dataByteLength = dataHex.length / 2
119
+ if (dataByteLength > VAULT_DATA_MAX_BYTE_LENGTH) {
120
+ throw new ValidationError(
121
+ `VaultCreate: Data exceeds ${VAULT_DATA_MAX_BYTE_LENGTH} bytes (actual: ${dataByteLength})`,
122
+ )
123
+ }
124
+ }
125
+
126
+ if (tx.MPTokenMetadata !== undefined) {
127
+ const metaHex = tx.MPTokenMetadata
128
+ if (!isHex(metaHex)) {
129
+ throw new ValidationError(
130
+ 'VaultCreate: MPTokenMetadata must be a valid non-empty hex string',
131
+ )
132
+ }
133
+ const metaByteLength = metaHex.length / 2
134
+ if (metaByteLength > MAX_MPT_META_BYTE_LENGTH) {
135
+ throw new ValidationError(
136
+ `VaultCreate: MPTokenMetadata exceeds ${MAX_MPT_META_BYTE_LENGTH} bytes (actual: ${metaByteLength})`,
137
+ )
138
+ }
139
+ }
140
+
141
+ // If DomainID present, tfVaultPrivate must be set
142
+ if (
143
+ tx.DomainID !== undefined &&
144
+ !hasFlag(tx, VaultCreateFlags.tfVaultPrivate, 'tfVaultPrivate')
145
+ ) {
146
+ throw new ValidationError(
147
+ 'VaultCreate: Cannot set DomainID unless tfVaultPrivate flag is set.',
148
+ )
149
+ }
150
+
151
+ if (tx.MPTokenMetadata != null) {
152
+ const validationMessages = validateMPTokenMetadata(tx.MPTokenMetadata)
153
+
154
+ if (validationMessages.length > 0) {
155
+ const message = [
156
+ MPT_META_WARNING_HEADER,
157
+ ...validationMessages.map((msg) => `- ${msg}`),
158
+ ].join('\n')
159
+
160
+ // eslint-disable-next-line no-console -- Required here.
161
+ console.warn(message)
162
+ }
163
+ }
164
+ }
165
+ /* eslint-enable max-lines-per-function */
166
+ /* eslint-enable max-statements */
@@ -0,0 +1,32 @@
1
+ import {
2
+ BaseTransaction,
3
+ validateBaseTransaction,
4
+ validateRequiredField,
5
+ isString,
6
+ } from './common'
7
+
8
+ /**
9
+ * The VaultDelete transaction deletes an existing vault object.
10
+ *
11
+ * @category Transaction Models
12
+ */
13
+ export interface VaultDelete extends BaseTransaction {
14
+ TransactionType: 'VaultDelete'
15
+
16
+ /**
17
+ * The ID of the vault to be deleted.
18
+ */
19
+ VaultID: string
20
+ }
21
+
22
+ /**
23
+ * Verify the form and type of a {@link VaultDelete} at runtime.
24
+ *
25
+ * @param tx - A {@link VaultDelete} Transaction.
26
+ * @throws When the {@link VaultDelete} is malformed.
27
+ */
28
+ export function validateVaultDelete(tx: Record<string, unknown>): void {
29
+ validateBaseTransaction(tx)
30
+
31
+ validateRequiredField(tx, 'VaultID', isString)
32
+ }