xrpl 2.10.0 → 2.11.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 (301) 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 +728 -28
  4. package/build/xrpl-latest.js.map +1 -1
  5. package/dist/npm/Wallet/walletFromSecretNumbers.d.ts +7 -0
  6. package/dist/npm/Wallet/walletFromSecretNumbers.d.ts.map +1 -0
  7. package/dist/npm/Wallet/walletFromSecretNumbers.js +27 -0
  8. package/dist/npm/Wallet/walletFromSecretNumbers.js.map +1 -0
  9. package/dist/npm/client/index.d.ts +2 -1
  10. package/dist/npm/client/index.d.ts.map +1 -1
  11. package/dist/npm/client/index.js.map +1 -1
  12. package/dist/npm/index.d.ts +1 -0
  13. package/dist/npm/index.d.ts.map +1 -1
  14. package/dist/npm/index.js +3 -1
  15. package/dist/npm/index.js.map +1 -1
  16. package/dist/npm/models/common/index.d.ts +5 -0
  17. package/dist/npm/models/common/index.d.ts.map +1 -1
  18. package/dist/npm/models/ledger/AMM.d.ts +27 -0
  19. package/dist/npm/models/ledger/AMM.d.ts.map +1 -0
  20. package/dist/npm/models/ledger/AMM.js +3 -0
  21. package/dist/npm/models/ledger/AMM.js.map +1 -0
  22. package/dist/npm/models/ledger/AccountRoot.d.ts +2 -0
  23. package/dist/npm/models/ledger/AccountRoot.d.ts.map +1 -1
  24. package/dist/npm/models/ledger/AccountRoot.js +1 -0
  25. package/dist/npm/models/ledger/AccountRoot.js.map +1 -1
  26. package/dist/npm/models/ledger/LedgerEntry.d.ts +2 -1
  27. package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
  28. package/dist/npm/models/methods/ammInfo.d.ts +39 -0
  29. package/dist/npm/models/methods/ammInfo.d.ts.map +1 -0
  30. package/dist/npm/models/methods/ammInfo.js +3 -0
  31. package/dist/npm/models/methods/ammInfo.js.map +1 -0
  32. package/dist/npm/models/methods/index.d.ts +4 -3
  33. package/dist/npm/models/methods/index.d.ts.map +1 -1
  34. package/dist/npm/models/methods/ledgerEntry.d.ts +10 -0
  35. package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
  36. package/dist/npm/models/transactions/AMMBid.d.ts +12 -0
  37. package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -0
  38. package/dist/npm/models/transactions/AMMBid.js +56 -0
  39. package/dist/npm/models/transactions/AMMBid.js.map +1 -0
  40. package/dist/npm/models/transactions/AMMCreate.d.ts +11 -0
  41. package/dist/npm/models/transactions/AMMCreate.d.ts.map +1 -0
  42. package/dist/npm/models/transactions/AMMCreate.js +32 -0
  43. package/dist/npm/models/transactions/AMMCreate.js.map +1 -0
  44. package/dist/npm/models/transactions/AMMDelete.d.ts +9 -0
  45. package/dist/npm/models/transactions/AMMDelete.d.ts.map +1 -0
  46. package/dist/npm/models/transactions/AMMDelete.js +22 -0
  47. package/dist/npm/models/transactions/AMMDelete.js.map +1 -0
  48. package/dist/npm/models/transactions/AMMDeposit.d.ts +27 -0
  49. package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -0
  50. package/dist/npm/models/transactions/AMMDeposit.js +51 -0
  51. package/dist/npm/models/transactions/AMMDeposit.js.map +1 -0
  52. package/dist/npm/models/transactions/AMMVote.d.ts +10 -0
  53. package/dist/npm/models/transactions/AMMVote.d.ts.map +1 -0
  54. package/dist/npm/models/transactions/AMMVote.js +32 -0
  55. package/dist/npm/models/transactions/AMMVote.js.map +1 -0
  56. package/dist/npm/models/transactions/AMMWithdraw.d.ts +31 -0
  57. package/dist/npm/models/transactions/AMMWithdraw.d.ts.map +1 -0
  58. package/dist/npm/models/transactions/AMMWithdraw.js +50 -0
  59. package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -0
  60. package/dist/npm/models/transactions/common.d.ts +2 -1
  61. package/dist/npm/models/transactions/common.d.ts.map +1 -1
  62. package/dist/npm/models/transactions/common.js +12 -1
  63. package/dist/npm/models/transactions/common.js.map +1 -1
  64. package/dist/npm/models/transactions/index.d.ts +6 -0
  65. package/dist/npm/models/transactions/index.d.ts.map +1 -1
  66. package/dist/npm/models/transactions/index.js +5 -1
  67. package/dist/npm/models/transactions/index.js.map +1 -1
  68. package/dist/npm/models/transactions/transaction.d.ts +7 -1
  69. package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
  70. package/dist/npm/models/transactions/transaction.js +24 -0
  71. package/dist/npm/models/transactions/transaction.js.map +1 -1
  72. package/dist/npm/models/utils/flags.d.ts.map +1 -1
  73. package/dist/npm/models/utils/flags.js +14 -21
  74. package/dist/npm/models/utils/flags.js.map +1 -1
  75. package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
  76. package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts +7 -0
  77. package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts.map +1 -0
  78. package/dist/npm/src/Wallet/walletFromSecretNumbers.js +27 -0
  79. package/dist/npm/src/Wallet/walletFromSecretNumbers.js.map +1 -0
  80. package/dist/npm/src/client/index.d.ts +2 -1
  81. package/dist/npm/src/client/index.d.ts.map +1 -1
  82. package/dist/npm/src/client/index.js.map +1 -1
  83. package/dist/npm/src/index.d.ts +1 -0
  84. package/dist/npm/src/index.d.ts.map +1 -1
  85. package/dist/npm/src/index.js +3 -1
  86. package/dist/npm/src/index.js.map +1 -1
  87. package/dist/npm/src/models/common/index.d.ts +5 -0
  88. package/dist/npm/src/models/common/index.d.ts.map +1 -1
  89. package/dist/npm/src/models/ledger/AMM.d.ts +27 -0
  90. package/dist/npm/src/models/ledger/AMM.d.ts.map +1 -0
  91. package/dist/npm/src/models/ledger/AMM.js +3 -0
  92. package/dist/npm/src/models/ledger/AMM.js.map +1 -0
  93. package/dist/npm/src/models/ledger/AccountRoot.d.ts +2 -0
  94. package/dist/npm/src/models/ledger/AccountRoot.d.ts.map +1 -1
  95. package/dist/npm/src/models/ledger/AccountRoot.js +1 -0
  96. package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
  97. package/dist/npm/src/models/ledger/LedgerEntry.d.ts +2 -1
  98. package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
  99. package/dist/npm/src/models/methods/ammInfo.d.ts +39 -0
  100. package/dist/npm/src/models/methods/ammInfo.d.ts.map +1 -0
  101. package/dist/npm/src/models/methods/ammInfo.js +3 -0
  102. package/dist/npm/src/models/methods/ammInfo.js.map +1 -0
  103. package/dist/npm/src/models/methods/index.d.ts +4 -3
  104. package/dist/npm/src/models/methods/index.d.ts.map +1 -1
  105. package/dist/npm/src/models/methods/ledgerEntry.d.ts +10 -0
  106. package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
  107. package/dist/npm/src/models/transactions/AMMBid.d.ts +12 -0
  108. package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -0
  109. package/dist/npm/src/models/transactions/AMMBid.js +56 -0
  110. package/dist/npm/src/models/transactions/AMMBid.js.map +1 -0
  111. package/dist/npm/src/models/transactions/AMMCreate.d.ts +11 -0
  112. package/dist/npm/src/models/transactions/AMMCreate.d.ts.map +1 -0
  113. package/dist/npm/src/models/transactions/AMMCreate.js +32 -0
  114. package/dist/npm/src/models/transactions/AMMCreate.js.map +1 -0
  115. package/dist/npm/src/models/transactions/AMMDelete.d.ts +9 -0
  116. package/dist/npm/src/models/transactions/AMMDelete.d.ts.map +1 -0
  117. package/dist/npm/src/models/transactions/AMMDelete.js +22 -0
  118. package/dist/npm/src/models/transactions/AMMDelete.js.map +1 -0
  119. package/dist/npm/src/models/transactions/AMMDeposit.d.ts +27 -0
  120. package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -0
  121. package/dist/npm/src/models/transactions/AMMDeposit.js +51 -0
  122. package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -0
  123. package/dist/npm/src/models/transactions/AMMVote.d.ts +10 -0
  124. package/dist/npm/src/models/transactions/AMMVote.d.ts.map +1 -0
  125. package/dist/npm/src/models/transactions/AMMVote.js +32 -0
  126. package/dist/npm/src/models/transactions/AMMVote.js.map +1 -0
  127. package/dist/npm/src/models/transactions/AMMWithdraw.d.ts +31 -0
  128. package/dist/npm/src/models/transactions/AMMWithdraw.d.ts.map +1 -0
  129. package/dist/npm/src/models/transactions/AMMWithdraw.js +50 -0
  130. package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -0
  131. package/dist/npm/src/models/transactions/common.d.ts +2 -1
  132. package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
  133. package/dist/npm/src/models/transactions/common.js +12 -1
  134. package/dist/npm/src/models/transactions/common.js.map +1 -1
  135. package/dist/npm/src/models/transactions/index.d.ts +6 -0
  136. package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
  137. package/dist/npm/src/models/transactions/index.js +5 -1
  138. package/dist/npm/src/models/transactions/index.js.map +1 -1
  139. package/dist/npm/src/models/transactions/transaction.d.ts +7 -1
  140. package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
  141. package/dist/npm/src/models/transactions/transaction.js +24 -0
  142. package/dist/npm/src/models/transactions/transaction.js.map +1 -1
  143. package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
  144. package/dist/npm/src/models/utils/flags.js +14 -21
  145. package/dist/npm/src/models/utils/flags.js.map +1 -1
  146. package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
  147. package/dist/npm/src/sugar/autofill.js +4 -3
  148. package/dist/npm/src/sugar/autofill.js.map +1 -1
  149. package/dist/npm/sugar/autofill.d.ts.map +1 -1
  150. package/dist/npm/sugar/autofill.js +4 -3
  151. package/dist/npm/sugar/autofill.js.map +1 -1
  152. package/package.json +8 -6
  153. package/src/ECDSA.ts +6 -0
  154. package/src/Wallet/defaultFaucets.ts +82 -0
  155. package/src/Wallet/fundWallet.ts +344 -0
  156. package/src/Wallet/index.ts +504 -0
  157. package/src/Wallet/rfc1751.ts +190 -0
  158. package/src/Wallet/rfc1751Words.json +243 -0
  159. package/src/Wallet/signer.ts +173 -0
  160. package/src/Wallet/walletFromSecretNumbers.ts +37 -0
  161. package/src/client/BroadcastClient.ts +84 -0
  162. package/src/client/ConnectionManager.ts +40 -0
  163. package/src/client/ExponentialBackoff.ts +71 -0
  164. package/src/client/RequestManager.ts +194 -0
  165. package/src/client/WSWrapper.ts +106 -0
  166. package/src/client/connection.ts +593 -0
  167. package/src/client/index.ts +712 -0
  168. package/src/client/partialPayment.ts +153 -0
  169. package/src/errors.ts +161 -0
  170. package/src/index.ts +20 -0
  171. package/src/models/common/index.ts +149 -0
  172. package/src/models/index.ts +16 -0
  173. package/src/models/ledger/AMM.ts +78 -0
  174. package/src/models/ledger/AccountRoot.ts +217 -0
  175. package/src/models/ledger/Amendments.ts +45 -0
  176. package/src/models/ledger/BaseLedgerEntry.ts +3 -0
  177. package/src/models/ledger/Check.ts +70 -0
  178. package/src/models/ledger/DepositPreauth.ts +35 -0
  179. package/src/models/ledger/DirectoryNode.ts +46 -0
  180. package/src/models/ledger/Escrow.ts +74 -0
  181. package/src/models/ledger/FeeSettings.ts +52 -0
  182. package/src/models/ledger/Ledger.ts +65 -0
  183. package/src/models/ledger/LedgerEntry.ts +34 -0
  184. package/src/models/ledger/LedgerHashes.ts +24 -0
  185. package/src/models/ledger/NFTokenOffer.ts +16 -0
  186. package/src/models/ledger/NFTokenPage.ts +20 -0
  187. package/src/models/ledger/NegativeUNL.ts +34 -0
  188. package/src/models/ledger/Offer.ts +52 -0
  189. package/src/models/ledger/PayChannel.ts +107 -0
  190. package/src/models/ledger/RippleState.ts +88 -0
  191. package/src/models/ledger/SignerList.ts +56 -0
  192. package/src/models/ledger/Ticket.ts +36 -0
  193. package/src/models/ledger/index.ts +58 -0
  194. package/src/models/methods/accountChannels.ts +93 -0
  195. package/src/models/methods/accountCurrencies.ts +45 -0
  196. package/src/models/methods/accountInfo.ts +182 -0
  197. package/src/models/methods/accountLines.ts +137 -0
  198. package/src/models/methods/accountNFTs.ts +72 -0
  199. package/src/models/methods/accountObjects.ts +120 -0
  200. package/src/models/methods/accountOffers.ts +100 -0
  201. package/src/models/methods/accountTx.ts +109 -0
  202. package/src/models/methods/ammInfo.ts +145 -0
  203. package/src/models/methods/baseMethod.ts +58 -0
  204. package/src/models/methods/bookOffers.ts +96 -0
  205. package/src/models/methods/channelVerify.ts +41 -0
  206. package/src/models/methods/depositAuthorized.ts +56 -0
  207. package/src/models/methods/fee.ts +91 -0
  208. package/src/models/methods/gatewayBalances.ts +85 -0
  209. package/src/models/methods/index.ts +391 -0
  210. package/src/models/methods/ledger.ts +125 -0
  211. package/src/models/methods/ledgerClosed.ts +32 -0
  212. package/src/models/methods/ledgerCurrent.ts +31 -0
  213. package/src/models/methods/ledgerData.ts +78 -0
  214. package/src/models/methods/ledgerEntry.ts +177 -0
  215. package/src/models/methods/manifest.ts +54 -0
  216. package/src/models/methods/nftBuyOffers.ts +37 -0
  217. package/src/models/methods/nftHistory.ts +113 -0
  218. package/src/models/methods/nftInfo.ts +25 -0
  219. package/src/models/methods/nftSellOffers.ts +37 -0
  220. package/src/models/methods/norippleCheck.ts +82 -0
  221. package/src/models/methods/pathFind.ts +116 -0
  222. package/src/models/methods/ping.ts +21 -0
  223. package/src/models/methods/random.ts +23 -0
  224. package/src/models/methods/ripplePathFind.ts +81 -0
  225. package/src/models/methods/serverInfo.ts +257 -0
  226. package/src/models/methods/serverState.ts +77 -0
  227. package/src/models/methods/submit.ts +94 -0
  228. package/src/models/methods/submitMultisigned.ts +51 -0
  229. package/src/models/methods/subscribe.ts +435 -0
  230. package/src/models/methods/transactionEntry.ts +47 -0
  231. package/src/models/methods/tx.ts +69 -0
  232. package/src/models/methods/unsubscribe.ts +49 -0
  233. package/src/models/transactions/AMMBid.ts +140 -0
  234. package/src/models/transactions/AMMCreate.ts +80 -0
  235. package/src/models/transactions/AMMDelete.ts +55 -0
  236. package/src/models/transactions/AMMDeposit.ts +130 -0
  237. package/src/models/transactions/AMMVote.ts +71 -0
  238. package/src/models/transactions/AMMWithdraw.ts +126 -0
  239. package/src/models/transactions/NFTokenAcceptOffer.ts +104 -0
  240. package/src/models/transactions/NFTokenBurn.ts +48 -0
  241. package/src/models/transactions/NFTokenCancelOffer.ts +45 -0
  242. package/src/models/transactions/NFTokenCreateOffer.ts +145 -0
  243. package/src/models/transactions/NFTokenMint.ts +123 -0
  244. package/src/models/transactions/UNLModify.ts +20 -0
  245. package/src/models/transactions/accountDelete.ts +50 -0
  246. package/src/models/transactions/accountSet.ts +228 -0
  247. package/src/models/transactions/checkCancel.ts +34 -0
  248. package/src/models/transactions/checkCash.ts +73 -0
  249. package/src/models/transactions/checkCreate.ts +90 -0
  250. package/src/models/transactions/clawback.ts +49 -0
  251. package/src/models/transactions/common.ts +295 -0
  252. package/src/models/transactions/depositPreauth.ts +68 -0
  253. package/src/models/transactions/enableAmendment.ts +26 -0
  254. package/src/models/transactions/escrowCancel.ts +45 -0
  255. package/src/models/transactions/escrowCreate.ts +100 -0
  256. package/src/models/transactions/escrowFinish.ts +63 -0
  257. package/src/models/transactions/index.ts +66 -0
  258. package/src/models/transactions/metadata.ts +69 -0
  259. package/src/models/transactions/offerCancel.ts +37 -0
  260. package/src/models/transactions/offerCreate.ts +144 -0
  261. package/src/models/transactions/payment.ts +278 -0
  262. package/src/models/transactions/paymentChannelClaim.ts +165 -0
  263. package/src/models/transactions/paymentChannelCreate.ts +116 -0
  264. package/src/models/transactions/paymentChannelFund.ts +65 -0
  265. package/src/models/transactions/setFee.ts +48 -0
  266. package/src/models/transactions/setRegularKey.ts +33 -0
  267. package/src/models/transactions/signerListSet.ts +89 -0
  268. package/src/models/transactions/ticketCreate.ts +50 -0
  269. package/src/models/transactions/transaction.ts +303 -0
  270. package/src/models/transactions/trustSet.ts +146 -0
  271. package/src/models/utils/flags.ts +98 -0
  272. package/src/models/utils/index.ts +37 -0
  273. package/src/sugar/autofill.ts +373 -0
  274. package/src/sugar/balances.ts +123 -0
  275. package/src/sugar/getFeeXrp.ts +45 -0
  276. package/src/sugar/getLedgerIndex.ts +15 -0
  277. package/src/sugar/getOrderbook.ts +152 -0
  278. package/src/sugar/index.ts +11 -0
  279. package/src/sugar/submit.ts +305 -0
  280. package/src/sugar/utils.ts +29 -0
  281. package/src/utils/derive.ts +23 -0
  282. package/src/utils/getBalanceChanges.ts +186 -0
  283. package/src/utils/getNFTokenID.ts +97 -0
  284. package/src/utils/hashes/HashPrefix.ts +40 -0
  285. package/src/utils/hashes/README.md +65 -0
  286. package/src/utils/hashes/SHAMap/InnerNode.ts +124 -0
  287. package/src/utils/hashes/SHAMap/LeafNode.ts +69 -0
  288. package/src/utils/hashes/SHAMap/index.ts +41 -0
  289. package/src/utils/hashes/SHAMap/node.ts +14 -0
  290. package/src/utils/hashes/hashLedger.ts +236 -0
  291. package/src/utils/hashes/index.ts +187 -0
  292. package/src/utils/hashes/ledgerSpaces.ts +34 -0
  293. package/src/utils/hashes/sha512Half.ts +19 -0
  294. package/src/utils/index.ts +223 -0
  295. package/src/utils/parseNFTokenID.ts +84 -0
  296. package/src/utils/quality.ts +169 -0
  297. package/src/utils/signPaymentChannelClaim.ts +27 -0
  298. package/src/utils/stringConversion.ts +27 -0
  299. package/src/utils/timeConversion.ts +53 -0
  300. package/src/utils/verifyPaymentChannelClaim.ts +30 -0
  301. package/src/utils/xrpConversion.ts +104 -0
@@ -0,0 +1,104 @@
1
+ import { ValidationError } from '../../errors'
2
+ import { Amount } from '../common'
3
+
4
+ import {
5
+ BaseTransaction,
6
+ parseAmountValue,
7
+ validateBaseTransaction,
8
+ } from './common'
9
+
10
+ /**
11
+ * The NFTokenOfferAccept transaction is used to accept offers
12
+ * to buy or sell an NFToken. It can either:
13
+ *
14
+ * 1. Allow one offer to be accepted. This is called direct
15
+ * mode.
16
+ * 2. Allow two distinct offers, one offering to buy a
17
+ * given NFToken and the other offering to sell the same
18
+ * NFToken, to be accepted in an atomic fashion. This is
19
+ * called brokered mode.
20
+ *
21
+ * To indicate direct mode, use either the `sell_offer` or
22
+ * `buy_offer` fields, but not both. To indicate brokered mode,
23
+ * use both the `sell_offer` and `buy_offer` fields. If you use
24
+ * neither `sell_offer` nor `buy_offer`, the transaction is invalid.
25
+ */
26
+ export interface NFTokenAcceptOffer extends BaseTransaction {
27
+ TransactionType: 'NFTokenAcceptOffer'
28
+ /**
29
+ * Identifies the NFTokenOffer that offers to sell the NFToken.
30
+ *
31
+ * In direct mode this field is optional, but either NFTokenSellOffer or
32
+ * NFTokenBuyOffer must be specified. In brokered mode, both NFTokenSellOffer
33
+ * and NFTokenBuyOffer must be specified.
34
+ */
35
+ NFTokenSellOffer?: string
36
+ /**
37
+ * Identifies the NFTokenOffer that offers to buy the NFToken.
38
+ *
39
+ * In direct mode this field is optional, but either NFTokenSellOffer or
40
+ * NFTokenBuyOffer must be specified. In brokered mode, both NFTokenSellOffer
41
+ * and NFTokenBuyOffer must be specified.
42
+ */
43
+ NFTokenBuyOffer?: string
44
+ /**
45
+ * This field is only valid in brokered mode. It specifies the
46
+ * amount that the broker will keep as part of their fee for
47
+ * bringing the two offers together; the remaining amount will
48
+ * be sent to the seller of the NFToken being bought. If
49
+ * specified, the fee must be such that, prior to accounting
50
+ * for the transfer fee charged by the issuer, the amount that
51
+ * the seller would receive is at least as much as the amount
52
+ * indicated in the sell offer.
53
+ *
54
+ * This functionality is intended to allow the owner of an
55
+ * NFToken to offer their token for sale to a third party
56
+ * broker, who may then attempt to sell the NFToken on for a
57
+ * larger amount, without the broker having to own the NFToken
58
+ * or custody funds.
59
+ *
60
+ * Note: in brokered mode, the offers referenced by NFTokenBuyOffer
61
+ * and NFTokenSellOffer must both specify the same NFTokenID; that is,
62
+ * both must be for the same NFToken.
63
+ */
64
+ NFTokenBrokerFee?: Amount
65
+ }
66
+
67
+ function validateNFTokenBrokerFee(tx: Record<string, unknown>): void {
68
+ const value = parseAmountValue(tx.NFTokenBrokerFee)
69
+ if (Number.isNaN(value)) {
70
+ throw new ValidationError('NFTokenAcceptOffer: invalid NFTokenBrokerFee')
71
+ }
72
+
73
+ if (value <= 0) {
74
+ throw new ValidationError(
75
+ 'NFTokenAcceptOffer: NFTokenBrokerFee must be greater than 0; omit if there is no fee',
76
+ )
77
+ }
78
+
79
+ if (tx.NFTokenSellOffer == null || tx.NFTokenBuyOffer == null) {
80
+ throw new ValidationError(
81
+ 'NFTokenAcceptOffer: both NFTokenSellOffer and NFTokenBuyOffer must be set if using brokered mode',
82
+ )
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Verify the form and type of an NFTokenAcceptOffer at runtime.
88
+ *
89
+ * @param tx - An NFTokenAcceptOffer Transaction.
90
+ * @throws When the NFTokenAcceptOffer is Malformed.
91
+ */
92
+ export function validateNFTokenAcceptOffer(tx: Record<string, unknown>): void {
93
+ validateBaseTransaction(tx)
94
+
95
+ if (tx.NFTokenBrokerFee != null) {
96
+ validateNFTokenBrokerFee(tx)
97
+ }
98
+
99
+ if (tx.NFTokenSellOffer == null && tx.NFTokenBuyOffer == null) {
100
+ throw new ValidationError(
101
+ 'NFTokenAcceptOffer: must set either NFTokenSellOffer or NFTokenBuyOffer',
102
+ )
103
+ }
104
+ }
@@ -0,0 +1,48 @@
1
+ import { ValidationError } from '../../errors'
2
+
3
+ import { BaseTransaction, validateBaseTransaction } from './common'
4
+
5
+ /**
6
+ * The NFTokenBurn transaction is used to remove an NFToken object from the
7
+ * NFTokenPage in which it is being held, effectively removing the token from
8
+ * the ledger ("burning" it).
9
+ *
10
+ * If this operation succeeds, the corresponding NFToken is removed. If this
11
+ * operation empties the NFTokenPage holding the NFToken or results in the
12
+ * consolidation, thus removing an NFTokenPage, the owner’s reserve requirement
13
+ * is reduced by one.
14
+ */
15
+ export interface NFTokenBurn extends BaseTransaction {
16
+ TransactionType: 'NFTokenBurn'
17
+ /**
18
+ * Indicates the AccountID that submitted this transaction. The account MUST
19
+ * be either the present owner of the token or, if the lsfBurnable flag is set
20
+ * in the NFToken, either the issuer account or an account authorized by the
21
+ * issuer, i.e. MintAccount.
22
+ */
23
+ Account: string
24
+ /**
25
+ * Identifies the NFToken object to be removed by the transaction.
26
+ */
27
+ NFTokenID: string
28
+ /**
29
+ * Indicates which account currently owns the token if it is different than
30
+ * Account. Only used to burn tokens which have the lsfBurnable flag enabled
31
+ * and are not owned by the signing account.
32
+ */
33
+ Owner?: string
34
+ }
35
+
36
+ /**
37
+ * Verify the form and type of an NFTokenBurn at runtime.
38
+ *
39
+ * @param tx - An NFTokenBurn Transaction.
40
+ * @throws When the NFTokenBurn is Malformed.
41
+ */
42
+ export function validateNFTokenBurn(tx: Record<string, unknown>): void {
43
+ validateBaseTransaction(tx)
44
+
45
+ if (tx.NFTokenID == null) {
46
+ throw new ValidationError('NFTokenBurn: missing field NFTokenID')
47
+ }
48
+ }
@@ -0,0 +1,45 @@
1
+ import { ValidationError } from '../../errors'
2
+
3
+ import { BaseTransaction, validateBaseTransaction } from './common'
4
+
5
+ /**
6
+ * The NFTokenCancelOffer transaction deletes existing NFTokenOffer objects.
7
+ * It is useful if you want to free up space on your account to lower your
8
+ * reserve requirement.
9
+ *
10
+ * The transaction can be executed by the account that originally created
11
+ * the NFTokenOffer, the account in the `Recipient` field of the NFTokenOffer
12
+ * (if present), or any account if the NFTokenOffer has an `Expiration` and
13
+ * the NFTokenOffer has already expired.
14
+ */
15
+ export interface NFTokenCancelOffer extends BaseTransaction {
16
+ TransactionType: 'NFTokenCancelOffer'
17
+ /**
18
+ * An array of identifiers of NFTokenOffer objects that should be cancelled
19
+ * by this transaction.
20
+ *
21
+ * It is an error if an entry in this list points to an
22
+ * object that is not an NFTokenOffer object. It is not an
23
+ * error if an entry in this list points to an object that
24
+ * does not exist. This field is required.
25
+ */
26
+ NFTokenOffers: string[]
27
+ }
28
+
29
+ /**
30
+ * Verify the form and type of an NFTokenCancelOffer at runtime.
31
+ *
32
+ * @param tx - An NFTokenCancelOffer Transaction.
33
+ * @throws When the NFTokenCancelOffer is Malformed.
34
+ */
35
+ export function validateNFTokenCancelOffer(tx: Record<string, unknown>): void {
36
+ validateBaseTransaction(tx)
37
+
38
+ if (!Array.isArray(tx.NFTokenOffers)) {
39
+ throw new ValidationError('NFTokenCancelOffer: missing field NFTokenOffers')
40
+ }
41
+
42
+ if (tx.NFTokenOffers.length < 1) {
43
+ throw new ValidationError('NFTokenCancelOffer: empty field NFTokenOffers')
44
+ }
45
+ }
@@ -0,0 +1,145 @@
1
+ import { ValidationError } from '../../errors'
2
+ import { Amount } from '../common'
3
+ import { isFlagEnabled } from '../utils'
4
+
5
+ import {
6
+ BaseTransaction,
7
+ GlobalFlags,
8
+ validateBaseTransaction,
9
+ isAmount,
10
+ parseAmountValue,
11
+ } from './common'
12
+
13
+ /**
14
+ * Transaction Flags for an NFTokenCreateOffer Transaction.
15
+ *
16
+ * @category Transaction Flags
17
+ */
18
+ export enum NFTokenCreateOfferFlags {
19
+ /**
20
+ * If set, indicates that the offer is a sell offer.
21
+ * Otherwise, it is a buy offer.
22
+ */
23
+ tfSellNFToken = 0x00000001,
24
+ }
25
+
26
+ /**
27
+ * Map of flags to boolean values representing {@link NFTokenCreateOffer} transaction
28
+ * flags.
29
+ *
30
+ * @category Transaction Flags
31
+ */
32
+ export interface NFTokenCreateOfferFlagsInterface extends GlobalFlags {
33
+ tfSellNFToken?: boolean
34
+ }
35
+
36
+ /**
37
+ * The NFTokenCreateOffer transaction creates either an offer to buy an
38
+ * NFT the submitting account does not own, or an offer to sell an NFT
39
+ * the submitting account does own.
40
+ */
41
+ export interface NFTokenCreateOffer extends BaseTransaction {
42
+ TransactionType: 'NFTokenCreateOffer'
43
+ /**
44
+ * Identifies the NFTokenID of the NFToken object that the
45
+ * offer references.
46
+ */
47
+ NFTokenID: string
48
+ /**
49
+ * Indicates the amount expected or offered for the Token.
50
+ *
51
+ * The amount must be non-zero, except when this is a sell
52
+ * offer and the asset is XRP. This would indicate that the current
53
+ * owner of the token is giving it away free, either to anyone at all,
54
+ * or to the account identified by the Destination field.
55
+ */
56
+ Amount: Amount
57
+ /**
58
+ * Indicates the AccountID of the account that owns the
59
+ * corresponding NFToken.
60
+ *
61
+ * If the offer is to buy a token, this field must be present
62
+ * and it must be different than Account (since an offer to
63
+ * buy a token one already holds is meaningless).
64
+ *
65
+ * If the offer is to sell a token, this field must not be
66
+ * present, as the owner is, implicitly, the same as Account
67
+ * (since an offer to sell a token one doesn't already hold
68
+ * is meaningless).
69
+ */
70
+ Owner?: string
71
+ /**
72
+ * Indicates the time after which the offer will no longer
73
+ * be valid. The value is the number of seconds since the
74
+ * Ripple Epoch.
75
+ */
76
+ Expiration?: number
77
+ /**
78
+ * If present, indicates that this offer may only be
79
+ * accepted by the specified account. Attempts by other
80
+ * accounts to accept this offer MUST fail.
81
+ */
82
+ Destination?: string
83
+ Flags?: number | NFTokenCreateOfferFlagsInterface
84
+ }
85
+
86
+ function validateNFTokenSellOfferCases(tx: Record<string, unknown>): void {
87
+ if (tx.Owner != null) {
88
+ throw new ValidationError(
89
+ 'NFTokenCreateOffer: Owner must not be present for sell offers',
90
+ )
91
+ }
92
+ }
93
+
94
+ function validateNFTokenBuyOfferCases(tx: Record<string, unknown>): void {
95
+ if (tx.Owner == null) {
96
+ throw new ValidationError(
97
+ 'NFTokenCreateOffer: Owner must be present for buy offers',
98
+ )
99
+ }
100
+
101
+ if (parseAmountValue(tx.Amount) <= 0) {
102
+ throw new ValidationError(
103
+ 'NFTokenCreateOffer: Amount must be greater than 0 for buy offers',
104
+ )
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Verify the form and type of an NFTokenCreateOffer at runtime.
110
+ *
111
+ * @param tx - An NFTokenCreateOffer Transaction.
112
+ * @throws When the NFTokenCreateOffer is Malformed.
113
+ */
114
+ export function validateNFTokenCreateOffer(tx: Record<string, unknown>): void {
115
+ validateBaseTransaction(tx)
116
+
117
+ if (tx.Account === tx.Owner) {
118
+ throw new ValidationError(
119
+ 'NFTokenCreateOffer: Owner and Account must not be equal',
120
+ )
121
+ }
122
+
123
+ if (tx.Account === tx.Destination) {
124
+ throw new ValidationError(
125
+ 'NFTokenCreateOffer: Destination and Account must not be equal',
126
+ )
127
+ }
128
+
129
+ if (tx.NFTokenID == null) {
130
+ throw new ValidationError('NFTokenCreateOffer: missing field NFTokenID')
131
+ }
132
+
133
+ if (!isAmount(tx.Amount)) {
134
+ throw new ValidationError('NFTokenCreateOffer: invalid Amount')
135
+ }
136
+
137
+ if (
138
+ typeof tx.Flags === 'number' &&
139
+ isFlagEnabled(tx.Flags, NFTokenCreateOfferFlags.tfSellNFToken)
140
+ ) {
141
+ validateNFTokenSellOfferCases(tx)
142
+ } else {
143
+ validateNFTokenBuyOfferCases(tx)
144
+ }
145
+ }
@@ -0,0 +1,123 @@
1
+ import { ValidationError } from '../../errors'
2
+ import { isHex } from '../utils'
3
+
4
+ import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
5
+
6
+ /**
7
+ * Transaction Flags for an NFTokenMint Transaction.
8
+ *
9
+ * @category Transaction Flags
10
+ */
11
+ export enum NFTokenMintFlags {
12
+ /**
13
+ * If set, indicates that the minted token may be burned by the issuer even
14
+ * if the issuer does not currently hold the token. The current holder of
15
+ * the token may always burn it.
16
+ */
17
+ tfBurnable = 0x00000001,
18
+ /**
19
+ * If set, indicates that the token may only be offered or sold for XRP.
20
+ */
21
+ tfOnlyXRP = 0x00000002,
22
+ /**
23
+ * If set, indicates that the issuer wants a trustline to be automatically
24
+ * created.
25
+ */
26
+ tfTrustLine = 0x00000004,
27
+ /**
28
+ * If set, indicates that this NFT can be transferred. This flag has no
29
+ * effect if the token is being transferred from the issuer or to the
30
+ * issuer.
31
+ */
32
+ tfTransferable = 0x00000008,
33
+ }
34
+
35
+ /**
36
+ * Map of flags to boolean values representing {@link NFTokenMint} transaction
37
+ * flags.
38
+ *
39
+ * @category Transaction Flags
40
+ */
41
+ export interface NFTokenMintFlagsInterface extends GlobalFlags {
42
+ tfBurnable?: boolean
43
+ tfOnlyXRP?: boolean
44
+ tfTrustLine?: boolean
45
+ tfTransferable?: boolean
46
+ }
47
+
48
+ /**
49
+ * The NFTokenMint transaction creates an NFToken object and adds it to the
50
+ * relevant NFTokenPage object of the minter. If the transaction is
51
+ * successful, the newly minted token will be owned by the minter account
52
+ * specified by the transaction.
53
+ */
54
+ export interface NFTokenMint extends BaseTransaction {
55
+ TransactionType: 'NFTokenMint'
56
+ /**
57
+ * Indicates the taxon associated with this token. The taxon is generally a
58
+ * value chosen by the minter of the token and a given taxon may be used for
59
+ * multiple tokens. The implementation reserves taxon identifiers greater
60
+ * than or equal to 2147483648 (0x80000000). If you have no use for this
61
+ * field, set it to 0.
62
+ */
63
+ NFTokenTaxon: number
64
+ /**
65
+ * Indicates the account that should be the issuer of this token. This value
66
+ * is optional and should only be specified if the account executing the
67
+ * transaction is not the `Issuer` of the `NFToken` object. If it is
68
+ * present, the `MintAccount` field in the `AccountRoot` of the `Issuer`
69
+ * field must match the `Account`, otherwise the transaction will fail.
70
+ */
71
+ Issuer?: string
72
+ /**
73
+ * Specifies the fee charged by the issuer for secondary sales of the Token,
74
+ * if such sales are allowed. Valid values for this field are between 0 and
75
+ * 50000 inclusive, allowing transfer rates between 0.000% and 50.000% in
76
+ * increments of 0.001%. This field must NOT be present if the
77
+ * `tfTransferable` flag is not set.
78
+ */
79
+ TransferFee?: number
80
+ /**
81
+ * URI that points to the data and/or metadata associated with the NFT.
82
+ * This field need not be an HTTP or HTTPS URL; it could be an IPFS URI, a
83
+ * magnet link, immediate data encoded as an RFC2379 "data" URL, or even an
84
+ * opaque issuer-specific encoding. The URI is NOT checked for validity, but
85
+ * the field is limited to a maximum length of 256 bytes.
86
+ *
87
+ * This field must be hex-encoded. You can use `convertStringToHex` to
88
+ * convert this field to the proper encoding.
89
+ *
90
+ * This field must not be an empty string. Omit it from the transaction or
91
+ * set to `undefined` value if you do not use it.
92
+ */
93
+ URI?: string | null
94
+ Flags?: number | NFTokenMintFlagsInterface
95
+ }
96
+
97
+ /**
98
+ * Verify the form and type of an NFTokenMint at runtime.
99
+ *
100
+ * @param tx - An NFTokenMint Transaction.
101
+ * @throws When the NFTokenMint is Malformed.
102
+ */
103
+ export function validateNFTokenMint(tx: Record<string, unknown>): void {
104
+ validateBaseTransaction(tx)
105
+
106
+ if (tx.Account === tx.Issuer) {
107
+ throw new ValidationError(
108
+ 'NFTokenMint: Issuer must not be equal to Account',
109
+ )
110
+ }
111
+
112
+ if (typeof tx.URI === 'string' && tx.URI === '') {
113
+ throw new ValidationError('NFTokenMint: URI must not be empty string')
114
+ }
115
+
116
+ if (typeof tx.URI === 'string' && !isHex(tx.URI)) {
117
+ throw new ValidationError('NFTokenMint: URI must be in hex format')
118
+ }
119
+
120
+ if (tx.NFTokenTaxon == null) {
121
+ throw new ValidationError('NFTokenMint: missing field NFTokenTaxon')
122
+ }
123
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Mark a change to the Negative UNL.
3
+ *
4
+ * @category Pseudo Transaction Models
5
+ */
6
+ export interface UNLModify {
7
+ TransactionType: 'UNLModify'
8
+ /**
9
+ * The ledger index where this pseudo-transaction appears.
10
+ * This distinguishes the pseudo-transaction from other occurrences of the same change.
11
+ */
12
+ LedgerSequence: number
13
+ /**
14
+ * If 0, this change represents removing a validator from the Negative UNL.
15
+ * If 1, this change represents adding a validator to the Negative UNL.
16
+ */
17
+ UNLModifyDisabling: 0 | 1
18
+ /** The validator to add or remove, as identified by its master public key. */
19
+ UNLModifyValidator: string
20
+ }
@@ -0,0 +1,50 @@
1
+ import { ValidationError } from '../../errors'
2
+
3
+ import { BaseTransaction, validateBaseTransaction } from './common'
4
+
5
+ /**
6
+ * An AccountDelete transaction deletes an account and any objects it owns in
7
+ * the XRP Ledger, if possible, sending the account's remaining XRP to a
8
+ * specified destination account.
9
+ *
10
+ * @category Transaction Models
11
+ */
12
+ export interface AccountDelete extends BaseTransaction {
13
+ TransactionType: 'AccountDelete'
14
+ /**
15
+ * The address of an account to receive any leftover XRP after deleting the
16
+ * sending account. Must be a funded account in the ledger, and must not be.
17
+ * the sending account.
18
+ */
19
+ Destination: string
20
+ /**
21
+ * Arbitrary destination tag that identifies a hosted recipient or other.
22
+ * information for the recipient of the deleted account's leftover XRP.
23
+ */
24
+ DestinationTag?: number
25
+ }
26
+
27
+ /**
28
+ * Verify the form and type of an AccountDelete at runtime.
29
+ *
30
+ * @param tx - An AccountDelete Transaction.
31
+ * @throws When the AccountDelete is Malformed.
32
+ */
33
+ export function validateAccountDelete(tx: Record<string, unknown>): void {
34
+ validateBaseTransaction(tx)
35
+
36
+ if (tx.Destination === undefined) {
37
+ throw new ValidationError('AccountDelete: missing field Destination')
38
+ }
39
+
40
+ if (typeof tx.Destination !== 'string') {
41
+ throw new ValidationError('AccountDelete: invalid Destination')
42
+ }
43
+
44
+ if (
45
+ tx.DestinationTag !== undefined &&
46
+ typeof tx.DestinationTag !== 'number'
47
+ ) {
48
+ throw new ValidationError('AccountDelete: invalid DestinationTag')
49
+ }
50
+ }