xrpl 2.9.1 → 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 (325) 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 +2680 -481
  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 +5 -1
  23. package/dist/npm/models/ledger/AccountRoot.d.ts.map +1 -1
  24. package/dist/npm/models/ledger/AccountRoot.js +2 -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/accountInfo.d.ts +1 -0
  29. package/dist/npm/models/methods/accountInfo.d.ts.map +1 -1
  30. package/dist/npm/models/methods/ammInfo.d.ts +39 -0
  31. package/dist/npm/models/methods/ammInfo.d.ts.map +1 -0
  32. package/dist/npm/models/methods/ammInfo.js +3 -0
  33. package/dist/npm/models/methods/ammInfo.js.map +1 -0
  34. package/dist/npm/models/methods/index.d.ts +4 -3
  35. package/dist/npm/models/methods/index.d.ts.map +1 -1
  36. package/dist/npm/models/methods/ledgerEntry.d.ts +10 -0
  37. package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
  38. package/dist/npm/models/transactions/AMMBid.d.ts +12 -0
  39. package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -0
  40. package/dist/npm/models/transactions/AMMBid.js +56 -0
  41. package/dist/npm/models/transactions/AMMBid.js.map +1 -0
  42. package/dist/npm/models/transactions/AMMCreate.d.ts +11 -0
  43. package/dist/npm/models/transactions/AMMCreate.d.ts.map +1 -0
  44. package/dist/npm/models/transactions/AMMCreate.js +32 -0
  45. package/dist/npm/models/transactions/AMMCreate.js.map +1 -0
  46. package/dist/npm/models/transactions/AMMDelete.d.ts +9 -0
  47. package/dist/npm/models/transactions/AMMDelete.d.ts.map +1 -0
  48. package/dist/npm/models/transactions/AMMDelete.js +22 -0
  49. package/dist/npm/models/transactions/AMMDelete.js.map +1 -0
  50. package/dist/npm/models/transactions/AMMDeposit.d.ts +27 -0
  51. package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -0
  52. package/dist/npm/models/transactions/AMMDeposit.js +51 -0
  53. package/dist/npm/models/transactions/AMMDeposit.js.map +1 -0
  54. package/dist/npm/models/transactions/AMMVote.d.ts +10 -0
  55. package/dist/npm/models/transactions/AMMVote.d.ts.map +1 -0
  56. package/dist/npm/models/transactions/AMMVote.js +32 -0
  57. package/dist/npm/models/transactions/AMMVote.js.map +1 -0
  58. package/dist/npm/models/transactions/AMMWithdraw.d.ts +31 -0
  59. package/dist/npm/models/transactions/AMMWithdraw.d.ts.map +1 -0
  60. package/dist/npm/models/transactions/AMMWithdraw.js +50 -0
  61. package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -0
  62. package/dist/npm/models/transactions/accountSet.d.ts +2 -1
  63. package/dist/npm/models/transactions/accountSet.d.ts.map +1 -1
  64. package/dist/npm/models/transactions/accountSet.js +1 -0
  65. package/dist/npm/models/transactions/accountSet.js.map +1 -1
  66. package/dist/npm/models/transactions/clawback.d.ts +9 -0
  67. package/dist/npm/models/transactions/clawback.d.ts.map +1 -0
  68. package/dist/npm/models/transactions/clawback.js +19 -0
  69. package/dist/npm/models/transactions/clawback.js.map +1 -0
  70. package/dist/npm/models/transactions/common.d.ts +2 -1
  71. package/dist/npm/models/transactions/common.d.ts.map +1 -1
  72. package/dist/npm/models/transactions/common.js +12 -1
  73. package/dist/npm/models/transactions/common.js.map +1 -1
  74. package/dist/npm/models/transactions/index.d.ts +7 -0
  75. package/dist/npm/models/transactions/index.d.ts.map +1 -1
  76. package/dist/npm/models/transactions/index.js +5 -1
  77. package/dist/npm/models/transactions/index.js.map +1 -1
  78. package/dist/npm/models/transactions/transaction.d.ts +8 -1
  79. package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
  80. package/dist/npm/models/transactions/transaction.js +28 -0
  81. package/dist/npm/models/transactions/transaction.js.map +1 -1
  82. package/dist/npm/models/utils/flags.d.ts.map +1 -1
  83. package/dist/npm/models/utils/flags.js +17 -23
  84. package/dist/npm/models/utils/flags.js.map +1 -1
  85. package/dist/npm/models/utils/index.js +1 -1
  86. package/dist/npm/models/utils/index.js.map +1 -1
  87. package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
  88. package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts +7 -0
  89. package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts.map +1 -0
  90. package/dist/npm/src/Wallet/walletFromSecretNumbers.js +27 -0
  91. package/dist/npm/src/Wallet/walletFromSecretNumbers.js.map +1 -0
  92. package/dist/npm/src/client/index.d.ts +2 -1
  93. package/dist/npm/src/client/index.d.ts.map +1 -1
  94. package/dist/npm/src/client/index.js.map +1 -1
  95. package/dist/npm/src/index.d.ts +1 -0
  96. package/dist/npm/src/index.d.ts.map +1 -1
  97. package/dist/npm/src/index.js +3 -1
  98. package/dist/npm/src/index.js.map +1 -1
  99. package/dist/npm/src/models/common/index.d.ts +5 -0
  100. package/dist/npm/src/models/common/index.d.ts.map +1 -1
  101. package/dist/npm/src/models/ledger/AMM.d.ts +27 -0
  102. package/dist/npm/src/models/ledger/AMM.d.ts.map +1 -0
  103. package/dist/npm/src/models/ledger/AMM.js +3 -0
  104. package/dist/npm/src/models/ledger/AMM.js.map +1 -0
  105. package/dist/npm/src/models/ledger/AccountRoot.d.ts +5 -1
  106. package/dist/npm/src/models/ledger/AccountRoot.d.ts.map +1 -1
  107. package/dist/npm/src/models/ledger/AccountRoot.js +2 -0
  108. package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
  109. package/dist/npm/src/models/ledger/LedgerEntry.d.ts +2 -1
  110. package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
  111. package/dist/npm/src/models/methods/accountInfo.d.ts +1 -0
  112. package/dist/npm/src/models/methods/accountInfo.d.ts.map +1 -1
  113. package/dist/npm/src/models/methods/ammInfo.d.ts +39 -0
  114. package/dist/npm/src/models/methods/ammInfo.d.ts.map +1 -0
  115. package/dist/npm/src/models/methods/ammInfo.js +3 -0
  116. package/dist/npm/src/models/methods/ammInfo.js.map +1 -0
  117. package/dist/npm/src/models/methods/index.d.ts +4 -3
  118. package/dist/npm/src/models/methods/index.d.ts.map +1 -1
  119. package/dist/npm/src/models/methods/ledgerEntry.d.ts +10 -0
  120. package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
  121. package/dist/npm/src/models/transactions/AMMBid.d.ts +12 -0
  122. package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -0
  123. package/dist/npm/src/models/transactions/AMMBid.js +56 -0
  124. package/dist/npm/src/models/transactions/AMMBid.js.map +1 -0
  125. package/dist/npm/src/models/transactions/AMMCreate.d.ts +11 -0
  126. package/dist/npm/src/models/transactions/AMMCreate.d.ts.map +1 -0
  127. package/dist/npm/src/models/transactions/AMMCreate.js +32 -0
  128. package/dist/npm/src/models/transactions/AMMCreate.js.map +1 -0
  129. package/dist/npm/src/models/transactions/AMMDelete.d.ts +9 -0
  130. package/dist/npm/src/models/transactions/AMMDelete.d.ts.map +1 -0
  131. package/dist/npm/src/models/transactions/AMMDelete.js +22 -0
  132. package/dist/npm/src/models/transactions/AMMDelete.js.map +1 -0
  133. package/dist/npm/src/models/transactions/AMMDeposit.d.ts +27 -0
  134. package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -0
  135. package/dist/npm/src/models/transactions/AMMDeposit.js +51 -0
  136. package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -0
  137. package/dist/npm/src/models/transactions/AMMVote.d.ts +10 -0
  138. package/dist/npm/src/models/transactions/AMMVote.d.ts.map +1 -0
  139. package/dist/npm/src/models/transactions/AMMVote.js +32 -0
  140. package/dist/npm/src/models/transactions/AMMVote.js.map +1 -0
  141. package/dist/npm/src/models/transactions/AMMWithdraw.d.ts +31 -0
  142. package/dist/npm/src/models/transactions/AMMWithdraw.d.ts.map +1 -0
  143. package/dist/npm/src/models/transactions/AMMWithdraw.js +50 -0
  144. package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -0
  145. package/dist/npm/src/models/transactions/accountSet.d.ts +2 -1
  146. package/dist/npm/src/models/transactions/accountSet.d.ts.map +1 -1
  147. package/dist/npm/src/models/transactions/accountSet.js +1 -0
  148. package/dist/npm/src/models/transactions/accountSet.js.map +1 -1
  149. package/dist/npm/src/models/transactions/clawback.d.ts +9 -0
  150. package/dist/npm/src/models/transactions/clawback.d.ts.map +1 -0
  151. package/dist/npm/src/models/transactions/clawback.js +19 -0
  152. package/dist/npm/src/models/transactions/clawback.js.map +1 -0
  153. package/dist/npm/src/models/transactions/common.d.ts +2 -1
  154. package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
  155. package/dist/npm/src/models/transactions/common.js +12 -1
  156. package/dist/npm/src/models/transactions/common.js.map +1 -1
  157. package/dist/npm/src/models/transactions/index.d.ts +7 -0
  158. package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
  159. package/dist/npm/src/models/transactions/index.js +5 -1
  160. package/dist/npm/src/models/transactions/index.js.map +1 -1
  161. package/dist/npm/src/models/transactions/transaction.d.ts +8 -1
  162. package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
  163. package/dist/npm/src/models/transactions/transaction.js +28 -0
  164. package/dist/npm/src/models/transactions/transaction.js.map +1 -1
  165. package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
  166. package/dist/npm/src/models/utils/flags.js +17 -23
  167. package/dist/npm/src/models/utils/flags.js.map +1 -1
  168. package/dist/npm/src/models/utils/index.js +1 -1
  169. package/dist/npm/src/models/utils/index.js.map +1 -1
  170. package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
  171. package/dist/npm/src/sugar/autofill.js +4 -3
  172. package/dist/npm/src/sugar/autofill.js.map +1 -1
  173. package/dist/npm/sugar/autofill.d.ts.map +1 -1
  174. package/dist/npm/sugar/autofill.js +4 -3
  175. package/dist/npm/sugar/autofill.js.map +1 -1
  176. package/package.json +8 -6
  177. package/src/ECDSA.ts +6 -0
  178. package/src/Wallet/defaultFaucets.ts +82 -0
  179. package/src/Wallet/fundWallet.ts +344 -0
  180. package/src/Wallet/index.ts +504 -0
  181. package/src/Wallet/rfc1751.ts +190 -0
  182. package/src/Wallet/rfc1751Words.json +243 -0
  183. package/src/Wallet/signer.ts +173 -0
  184. package/src/Wallet/walletFromSecretNumbers.ts +37 -0
  185. package/src/client/BroadcastClient.ts +84 -0
  186. package/src/client/ConnectionManager.ts +40 -0
  187. package/src/client/ExponentialBackoff.ts +71 -0
  188. package/src/client/RequestManager.ts +194 -0
  189. package/src/client/WSWrapper.ts +106 -0
  190. package/src/client/connection.ts +593 -0
  191. package/src/client/index.ts +712 -0
  192. package/src/client/partialPayment.ts +153 -0
  193. package/src/errors.ts +161 -0
  194. package/src/index.ts +20 -0
  195. package/src/models/common/index.ts +149 -0
  196. package/src/models/index.ts +16 -0
  197. package/src/models/ledger/AMM.ts +78 -0
  198. package/src/models/ledger/AccountRoot.ts +217 -0
  199. package/src/models/ledger/Amendments.ts +45 -0
  200. package/src/models/ledger/BaseLedgerEntry.ts +3 -0
  201. package/src/models/ledger/Check.ts +70 -0
  202. package/src/models/ledger/DepositPreauth.ts +35 -0
  203. package/src/models/ledger/DirectoryNode.ts +46 -0
  204. package/src/models/ledger/Escrow.ts +74 -0
  205. package/src/models/ledger/FeeSettings.ts +52 -0
  206. package/src/models/ledger/Ledger.ts +65 -0
  207. package/src/models/ledger/LedgerEntry.ts +34 -0
  208. package/src/models/ledger/LedgerHashes.ts +24 -0
  209. package/src/models/ledger/NFTokenOffer.ts +16 -0
  210. package/src/models/ledger/NFTokenPage.ts +20 -0
  211. package/src/models/ledger/NegativeUNL.ts +34 -0
  212. package/src/models/ledger/Offer.ts +52 -0
  213. package/src/models/ledger/PayChannel.ts +107 -0
  214. package/src/models/ledger/RippleState.ts +88 -0
  215. package/src/models/ledger/SignerList.ts +56 -0
  216. package/src/models/ledger/Ticket.ts +36 -0
  217. package/src/models/ledger/index.ts +58 -0
  218. package/src/models/methods/accountChannels.ts +93 -0
  219. package/src/models/methods/accountCurrencies.ts +45 -0
  220. package/src/models/methods/accountInfo.ts +182 -0
  221. package/src/models/methods/accountLines.ts +137 -0
  222. package/src/models/methods/accountNFTs.ts +72 -0
  223. package/src/models/methods/accountObjects.ts +120 -0
  224. package/src/models/methods/accountOffers.ts +100 -0
  225. package/src/models/methods/accountTx.ts +109 -0
  226. package/src/models/methods/ammInfo.ts +145 -0
  227. package/src/models/methods/baseMethod.ts +58 -0
  228. package/src/models/methods/bookOffers.ts +96 -0
  229. package/src/models/methods/channelVerify.ts +41 -0
  230. package/src/models/methods/depositAuthorized.ts +56 -0
  231. package/src/models/methods/fee.ts +91 -0
  232. package/src/models/methods/gatewayBalances.ts +85 -0
  233. package/src/models/methods/index.ts +391 -0
  234. package/src/models/methods/ledger.ts +125 -0
  235. package/src/models/methods/ledgerClosed.ts +32 -0
  236. package/src/models/methods/ledgerCurrent.ts +31 -0
  237. package/src/models/methods/ledgerData.ts +78 -0
  238. package/src/models/methods/ledgerEntry.ts +177 -0
  239. package/src/models/methods/manifest.ts +54 -0
  240. package/src/models/methods/nftBuyOffers.ts +37 -0
  241. package/src/models/methods/nftHistory.ts +113 -0
  242. package/src/models/methods/nftInfo.ts +25 -0
  243. package/src/models/methods/nftSellOffers.ts +37 -0
  244. package/src/models/methods/norippleCheck.ts +82 -0
  245. package/src/models/methods/pathFind.ts +116 -0
  246. package/src/models/methods/ping.ts +21 -0
  247. package/src/models/methods/random.ts +23 -0
  248. package/src/models/methods/ripplePathFind.ts +81 -0
  249. package/src/models/methods/serverInfo.ts +257 -0
  250. package/src/models/methods/serverState.ts +77 -0
  251. package/src/models/methods/submit.ts +94 -0
  252. package/src/models/methods/submitMultisigned.ts +51 -0
  253. package/src/models/methods/subscribe.ts +435 -0
  254. package/src/models/methods/transactionEntry.ts +47 -0
  255. package/src/models/methods/tx.ts +69 -0
  256. package/src/models/methods/unsubscribe.ts +49 -0
  257. package/src/models/transactions/AMMBid.ts +140 -0
  258. package/src/models/transactions/AMMCreate.ts +80 -0
  259. package/src/models/transactions/AMMDelete.ts +55 -0
  260. package/src/models/transactions/AMMDeposit.ts +130 -0
  261. package/src/models/transactions/AMMVote.ts +71 -0
  262. package/src/models/transactions/AMMWithdraw.ts +126 -0
  263. package/src/models/transactions/NFTokenAcceptOffer.ts +104 -0
  264. package/src/models/transactions/NFTokenBurn.ts +48 -0
  265. package/src/models/transactions/NFTokenCancelOffer.ts +45 -0
  266. package/src/models/transactions/NFTokenCreateOffer.ts +145 -0
  267. package/src/models/transactions/NFTokenMint.ts +123 -0
  268. package/src/models/transactions/UNLModify.ts +20 -0
  269. package/src/models/transactions/accountDelete.ts +50 -0
  270. package/src/models/transactions/accountSet.ts +228 -0
  271. package/src/models/transactions/checkCancel.ts +34 -0
  272. package/src/models/transactions/checkCash.ts +73 -0
  273. package/src/models/transactions/checkCreate.ts +90 -0
  274. package/src/models/transactions/clawback.ts +49 -0
  275. package/src/models/transactions/common.ts +295 -0
  276. package/src/models/transactions/depositPreauth.ts +68 -0
  277. package/src/models/transactions/enableAmendment.ts +26 -0
  278. package/src/models/transactions/escrowCancel.ts +45 -0
  279. package/src/models/transactions/escrowCreate.ts +100 -0
  280. package/src/models/transactions/escrowFinish.ts +63 -0
  281. package/src/models/transactions/index.ts +66 -0
  282. package/src/models/transactions/metadata.ts +69 -0
  283. package/src/models/transactions/offerCancel.ts +37 -0
  284. package/src/models/transactions/offerCreate.ts +144 -0
  285. package/src/models/transactions/payment.ts +278 -0
  286. package/src/models/transactions/paymentChannelClaim.ts +165 -0
  287. package/src/models/transactions/paymentChannelCreate.ts +116 -0
  288. package/src/models/transactions/paymentChannelFund.ts +65 -0
  289. package/src/models/transactions/setFee.ts +48 -0
  290. package/src/models/transactions/setRegularKey.ts +33 -0
  291. package/src/models/transactions/signerListSet.ts +89 -0
  292. package/src/models/transactions/ticketCreate.ts +50 -0
  293. package/src/models/transactions/transaction.ts +303 -0
  294. package/src/models/transactions/trustSet.ts +146 -0
  295. package/src/models/utils/flags.ts +98 -0
  296. package/src/models/utils/index.ts +37 -0
  297. package/src/sugar/autofill.ts +373 -0
  298. package/src/sugar/balances.ts +123 -0
  299. package/src/sugar/getFeeXrp.ts +45 -0
  300. package/src/sugar/getLedgerIndex.ts +15 -0
  301. package/src/sugar/getOrderbook.ts +152 -0
  302. package/src/sugar/index.ts +11 -0
  303. package/src/sugar/submit.ts +305 -0
  304. package/src/sugar/utils.ts +29 -0
  305. package/src/utils/derive.ts +23 -0
  306. package/src/utils/getBalanceChanges.ts +186 -0
  307. package/src/utils/getNFTokenID.ts +97 -0
  308. package/src/utils/hashes/HashPrefix.ts +40 -0
  309. package/src/utils/hashes/README.md +65 -0
  310. package/src/utils/hashes/SHAMap/InnerNode.ts +124 -0
  311. package/src/utils/hashes/SHAMap/LeafNode.ts +69 -0
  312. package/src/utils/hashes/SHAMap/index.ts +41 -0
  313. package/src/utils/hashes/SHAMap/node.ts +14 -0
  314. package/src/utils/hashes/hashLedger.ts +236 -0
  315. package/src/utils/hashes/index.ts +187 -0
  316. package/src/utils/hashes/ledgerSpaces.ts +34 -0
  317. package/src/utils/hashes/sha512Half.ts +19 -0
  318. package/src/utils/index.ts +223 -0
  319. package/src/utils/parseNFTokenID.ts +84 -0
  320. package/src/utils/quality.ts +169 -0
  321. package/src/utils/signPaymentChannelClaim.ts +27 -0
  322. package/src/utils/stringConversion.ts +27 -0
  323. package/src/utils/timeConversion.ts +53 -0
  324. package/src/utils/verifyPaymentChannelClaim.ts +30 -0
  325. package/src/utils/xrpConversion.ts +104 -0
@@ -0,0 +1,146 @@
1
+ import { ValidationError } from '../../errors'
2
+ import { IssuedCurrencyAmount } from '../common'
3
+
4
+ import {
5
+ BaseTransaction,
6
+ GlobalFlags,
7
+ isAmount,
8
+ validateBaseTransaction,
9
+ } from './common'
10
+
11
+ /**
12
+ * Enum representing values of {@link TrustSet} transaction flags.
13
+ *
14
+ * @category Transaction Flags
15
+ */
16
+ export enum TrustSetFlags {
17
+ /**
18
+ * Authorize the other party to hold currency issued by this account. (No
19
+ * effect unless using the asfRequireAuth AccountSet flag.) Cannot be unset.
20
+ */
21
+ tfSetfAuth = 0x00010000,
22
+ /**
23
+ * Enable the No Ripple flag, which blocks rippling between two trust lines.
24
+ * of the same currency if this flag is enabled on both.
25
+ */
26
+ tfSetNoRipple = 0x00020000,
27
+ /** Disable the No Ripple flag, allowing rippling on this trust line. */
28
+ tfClearNoRipple = 0x00040000,
29
+ /** Freeze the trust line. */
30
+ tfSetFreeze = 0x00100000,
31
+ /** Unfreeze the trust line. */
32
+ tfClearFreeze = 0x00200000,
33
+ }
34
+
35
+ /**
36
+ * Map of flags to boolean values representing {@link TrustSet} transaction
37
+ * flags.
38
+ *
39
+ * @category Transaction Flags
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ *
44
+ * const trustSetTx: TrustSet = {
45
+ * TransactionType: 'TrustSet',
46
+ * Account: wallet2.getClassicAddress(),
47
+ * LimitAmount: {
48
+ * currency: 'FOO',
49
+ * issuer: wallet1.getClassicAddress(),
50
+ * value: '10000000000',
51
+ * },
52
+ * Flags: {
53
+ * tfSetNoRipple: true
54
+ * }
55
+ * }
56
+ *
57
+ * // Autofill the tx to see how flags actually look compared to the interface usage.
58
+ * const autofilledTx = await client.autofill(trustSetTx)
59
+ * console.log(autofilledTx)
60
+ * // {
61
+ * // TransactionType: 'TrustSet',
62
+ * // Account: 'r9dAdQQCBcGajVSeC9CqW3LCugjPDnAkEb',
63
+ * // LimitAmount: {
64
+ * // currency: 'FOO',
65
+ * // issuer: 'rWZzUjo5xGiAoRBqzsndyzonXz47UV8u1',
66
+ * // value: '10000000000'
67
+ * // },
68
+ * // Flags: 131072,
69
+ * // Sequence: 21971483,
70
+ * // Fee: '12',
71
+ * // LastLedgerSequence: 21971503
72
+ * // }
73
+ * ```
74
+ */
75
+ export interface TrustSetFlagsInterface extends GlobalFlags {
76
+ /**
77
+ * Authorize the other party to hold currency issued by this account. (No
78
+ * effect unless using the asfRequireAuth AccountSet flag.) Cannot be unset.
79
+ */
80
+ tfSetfAuth?: boolean
81
+ /**
82
+ * Enable the No Ripple flag, which blocks rippling between two trust lines
83
+ * of the same currency if this flag is enabled on both.
84
+ */
85
+ tfSetNoRipple?: boolean
86
+ /** Disable the No Ripple flag, allowing rippling on this trust line. */
87
+ tfClearNoRipple?: boolean
88
+ /** Freeze the trust line. */
89
+ tfSetFreeze?: boolean
90
+ /** Unfreeze the trust line. */
91
+ tfClearFreeze?: boolean
92
+ }
93
+
94
+ /**
95
+ * Create or modify a trust line linking two accounts.
96
+ *
97
+ * @category Transaction Models
98
+ */
99
+ export interface TrustSet extends BaseTransaction {
100
+ TransactionType: 'TrustSet'
101
+ /**
102
+ * Object defining the trust line to create or modify, in the format of a
103
+ * Currency Amount.
104
+ */
105
+ LimitAmount: IssuedCurrencyAmount
106
+ /**
107
+ * Value incoming balances on this trust line at the ratio of this number per
108
+ * 1,000,000,000 units. A value of 0 is shorthand for treating balances at
109
+ * face value.
110
+ */
111
+ QualityIn?: number
112
+ /**
113
+ * Value outgoing balances on this trust line at the ratio of this number per
114
+ * 1,000,000,000 units. A value of 0 is shorthand for treating balances at
115
+ * face value.
116
+ */
117
+ QualityOut?: number
118
+ Flags?: number | TrustSetFlagsInterface
119
+ }
120
+
121
+ /**
122
+ * Verify the form and type of a TrustSet at runtime.
123
+ *
124
+ * @param tx - A TrustSet Transaction.
125
+ * @throws When the TrustSet is malformed.
126
+ */
127
+ export function validateTrustSet(tx: Record<string, unknown>): void {
128
+ validateBaseTransaction(tx)
129
+ const { LimitAmount, QualityIn, QualityOut } = tx
130
+
131
+ if (LimitAmount === undefined) {
132
+ throw new ValidationError('TrustSet: missing field LimitAmount')
133
+ }
134
+
135
+ if (!isAmount(LimitAmount)) {
136
+ throw new ValidationError('TrustSet: invalid LimitAmount')
137
+ }
138
+
139
+ if (QualityIn !== undefined && typeof QualityIn !== 'number') {
140
+ throw new ValidationError('TrustSet: QualityIn must be a number')
141
+ }
142
+
143
+ if (QualityOut !== undefined && typeof QualityOut !== 'number') {
144
+ throw new ValidationError('TrustSet: QualityOut must be a number')
145
+ }
146
+ }
@@ -0,0 +1,98 @@
1
+ /* eslint-disable no-param-reassign -- param reassign is safe */
2
+ /* eslint-disable no-bitwise -- flags require bitwise operations */
3
+
4
+ import { ValidationError } from '../../errors'
5
+ import {
6
+ AccountRootFlagsInterface,
7
+ AccountRootFlags,
8
+ } from '../ledger/AccountRoot'
9
+ import { AccountSetTfFlags } from '../transactions/accountSet'
10
+ import { AMMDepositFlags } from '../transactions/AMMDeposit'
11
+ import { AMMWithdrawFlags } from '../transactions/AMMWithdraw'
12
+ import { GlobalFlags } from '../transactions/common'
13
+ import { OfferCreateFlags } from '../transactions/offerCreate'
14
+ import { PaymentFlags } from '../transactions/payment'
15
+ import { PaymentChannelClaimFlags } from '../transactions/paymentChannelClaim'
16
+ import type { Transaction } from '../transactions/transaction'
17
+ import { TrustSetFlags } from '../transactions/trustSet'
18
+
19
+ import { isFlagEnabled } from '.'
20
+
21
+ /**
22
+ * Convert an AccountRoot Flags number into an interface for easy interpretation.
23
+ *
24
+ * @param flags - A number which is the bitwise and of all enabled AccountRootFlagsInterface.
25
+ * @returns An interface with all flags as booleans.
26
+ */
27
+ export function parseAccountRootFlags(
28
+ flags: number,
29
+ ): AccountRootFlagsInterface {
30
+ const flagsInterface: AccountRootFlagsInterface = {}
31
+
32
+ // If we use keys all will be strings and enums are reversed during transpilation
33
+ Object.values(AccountRootFlags).forEach((flag) => {
34
+ if (
35
+ typeof flag === 'string' &&
36
+ isFlagEnabled(flags, AccountRootFlags[flag])
37
+ ) {
38
+ flagsInterface[flag] = true
39
+ }
40
+ })
41
+
42
+ return flagsInterface
43
+ }
44
+
45
+ /**
46
+ * Sets a transaction's flags to its numeric representation.
47
+ *
48
+ * @param tx - A transaction to set its flags to its numeric representation.
49
+ */
50
+ export function setTransactionFlagsToNumber(tx: Transaction): void {
51
+ if (tx.Flags == null) {
52
+ tx.Flags = 0
53
+ return
54
+ }
55
+ if (typeof tx.Flags === 'number') {
56
+ return
57
+ }
58
+
59
+ switch (tx.TransactionType) {
60
+ case 'AccountSet':
61
+ tx.Flags = convertFlagsToNumber(tx.Flags, AccountSetTfFlags)
62
+ return
63
+ case 'AMMDeposit':
64
+ tx.Flags = convertFlagsToNumber(tx.Flags, AMMDepositFlags)
65
+ return
66
+ case 'AMMWithdraw':
67
+ tx.Flags = convertFlagsToNumber(tx.Flags, AMMWithdrawFlags)
68
+ return
69
+ case 'OfferCreate':
70
+ tx.Flags = convertFlagsToNumber(tx.Flags, OfferCreateFlags)
71
+ return
72
+ case 'PaymentChannelClaim':
73
+ tx.Flags = convertFlagsToNumber(tx.Flags, PaymentChannelClaimFlags)
74
+ return
75
+ case 'Payment':
76
+ tx.Flags = convertFlagsToNumber(tx.Flags, PaymentFlags)
77
+ return
78
+ case 'TrustSet':
79
+ tx.Flags = convertFlagsToNumber(tx.Flags, TrustSetFlags)
80
+ return
81
+ default:
82
+ tx.Flags = 0
83
+ }
84
+ }
85
+
86
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- added ValidationError check for flagEnum
87
+ function convertFlagsToNumber(flags: GlobalFlags, flagEnum: any): number {
88
+ return Object.keys(flags).reduce((resultFlags, flag) => {
89
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- safe member access
90
+ if (flagEnum[flag] == null) {
91
+ throw new ValidationError(
92
+ `flag ${flag} doesn't exist in flagEnum: ${JSON.stringify(flagEnum)}`,
93
+ )
94
+ }
95
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- safe member access
96
+ return flags[flag] ? resultFlags | flagEnum[flag] : resultFlags
97
+ }, 0)
98
+ }
@@ -0,0 +1,37 @@
1
+ const HEX_REGEX = /^[0-9A-Fa-f]+$/u
2
+
3
+ /**
4
+ * Verify that all fields of an object are in fields.
5
+ *
6
+ * @param obj - Object to verify fields.
7
+ * @param fields - Fields to verify.
8
+ * @returns True if keys in object are all in fields.
9
+ */
10
+ export function onlyHasFields(
11
+ obj: Record<string, unknown>,
12
+ fields: string[],
13
+ ): boolean {
14
+ return Object.keys(obj).every((key: string) => fields.includes(key))
15
+ }
16
+
17
+ /**
18
+ * Perform bitwise AND (&) to check if a flag is enabled within Flags (as a number).
19
+ *
20
+ * @param Flags - A number that represents flags enabled.
21
+ * @param checkFlag - A specific flag to check if it's enabled within Flags.
22
+ * @returns True if checkFlag is enabled within Flags.
23
+ */
24
+ export function isFlagEnabled(Flags: number, checkFlag: number): boolean {
25
+ // eslint-disable-next-line no-bitwise -- flags need bitwise
26
+ return (BigInt(checkFlag) & BigInt(Flags)) === BigInt(checkFlag)
27
+ }
28
+
29
+ /**
30
+ * Check if string is in hex format.
31
+ *
32
+ * @param str - The string to check if it's in hex format.
33
+ * @returns True if string is in hex format
34
+ */
35
+ export function isHex(str: string): boolean {
36
+ return HEX_REGEX.test(str)
37
+ }
@@ -0,0 +1,373 @@
1
+ import BigNumber from 'bignumber.js'
2
+ import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
3
+
4
+ import type { Client } from '..'
5
+ import { ValidationError, XrplError } from '../errors'
6
+ import { AccountInfoRequest, AccountObjectsRequest } from '../models/methods'
7
+ import { Transaction } from '../models/transactions'
8
+ import { setTransactionFlagsToNumber } from '../models/utils/flags'
9
+ import { xrpToDrops } from '../utils'
10
+
11
+ import getFeeXrp from './getFeeXrp'
12
+
13
+ // Expire unconfirmed transactions after 20 ledger versions, approximately 1 minute, by default
14
+ const LEDGER_OFFSET = 20
15
+ // Sidechains are expected to have network IDs above this.
16
+ // Networks with ID above this restricted number are expected specify an accurate NetworkID field
17
+ // in every transaction to that chain to prevent replay attacks.
18
+ // Mainnet and testnet are exceptions. More context: https://github.com/XRPLF/rippled/pull/4370
19
+ const RESTRICTED_NETWORKS = 1024
20
+ const REQUIRED_NETWORKID_VERSION = '1.11.0'
21
+ const HOOKS_TESTNET_ID = 21338
22
+ interface ClassicAccountAndTag {
23
+ classicAccount: string
24
+ tag: number | false | undefined
25
+ }
26
+
27
+ /**
28
+ * Autofills fields in a transaction. This will set `Sequence`, `Fee`,
29
+ * `lastLedgerSequence` according to the current state of the server this Client
30
+ * is connected to. It also converts all X-Addresses to classic addresses and
31
+ * flags interfaces into numbers.
32
+ *
33
+ * @example
34
+ *
35
+ * ```ts
36
+ * const { Client } = require('xrpl')
37
+ *
38
+ * const client = new Client('wss://s.altnet.rippletest.net:51233')
39
+ *
40
+ * async function createAndAutofillTransaction() {
41
+ * const transaction = {
42
+ * TransactionType: 'Payment',
43
+ * Account: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
44
+ * Destination: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
45
+ * Amount: '10000000' // 10 XRP in drops (1/1,000,000th of an XRP)
46
+ * }
47
+ *
48
+ * try {
49
+ * const autofilledTransaction = await client.autofill(transaction)
50
+ * console.log(autofilledTransaction)
51
+ * } catch (error) {
52
+ * console.error(`Failed to autofill transaction: ${error}`)
53
+ * }
54
+ * }
55
+ *
56
+ * createAndAutofillTransaction()
57
+ * ```
58
+ *
59
+ * Autofill helps fill in fields which should be included in a transaction, but can be determined automatically
60
+ * such as `LastLedgerSequence` and `Fee`. If you override one of the fields `autofill` changes, your explicit
61
+ * values will be used instead. By default, this is done as part of `submit` and `submitAndWait` when you pass
62
+ * in an unsigned transaction along with your wallet to be submitted.
63
+ *
64
+ * @param this - A client.
65
+ * @param transaction - A {@link Transaction} in JSON format
66
+ * @param signersCount - The expected number of signers for this transaction.
67
+ * Only used for multisigned transactions.
68
+ * @returns The autofilled transaction.
69
+ */
70
+ async function autofill<T extends Transaction>(
71
+ this: Client,
72
+ transaction: T,
73
+ signersCount?: number,
74
+ ): Promise<T> {
75
+ const tx = { ...transaction }
76
+
77
+ setValidAddresses(tx)
78
+
79
+ setTransactionFlagsToNumber(tx)
80
+ const promises: Array<Promise<void>> = []
81
+ if (tx.NetworkID == null) {
82
+ tx.NetworkID = txNeedsNetworkID(this) ? this.networkID : undefined
83
+ }
84
+ if (tx.Sequence == null) {
85
+ promises.push(setNextValidSequenceNumber(this, tx))
86
+ }
87
+ if (tx.Fee == null) {
88
+ promises.push(calculateFeePerTransactionType(this, tx, signersCount))
89
+ }
90
+ if (tx.LastLedgerSequence == null) {
91
+ promises.push(setLatestValidatedLedgerSequence(this, tx))
92
+ }
93
+ if (tx.TransactionType === 'AccountDelete') {
94
+ promises.push(checkAccountDeleteBlockers(this, tx))
95
+ }
96
+
97
+ return Promise.all(promises).then(() => tx)
98
+ }
99
+
100
+ /**
101
+ * Determines whether the source rippled version is not later than the target rippled version.
102
+ * Example usage: isNotLaterRippledVersion('1.10.0', '1.11.0') returns true.
103
+ * isNotLaterRippledVersion('1.10.0', '1.10.0-b1') returns false.
104
+ *
105
+ * @param source -- The source rippled version.
106
+ * @param target -- The target rippled version.
107
+ * @returns True if source is earlier than target, false otherwise.
108
+ */
109
+ // eslint-disable-next-line max-lines-per-function, max-statements -- Disable for this helper functions.
110
+ function isNotLaterRippledVersion(source: string, target: string): boolean {
111
+ if (source === target) {
112
+ return true
113
+ }
114
+ const sourceDecomp = source.split('.')
115
+ const targetDecomp = target.split('.')
116
+ const sourceMajor = parseInt(sourceDecomp[0], 10)
117
+ const sourceMinor = parseInt(sourceDecomp[1], 10)
118
+ const targetMajor = parseInt(targetDecomp[0], 10)
119
+ const targetMinor = parseInt(targetDecomp[1], 10)
120
+ // Compare major version
121
+ if (sourceMajor !== targetMajor) {
122
+ return sourceMajor < targetMajor
123
+ }
124
+ // Compare minor version
125
+ if (sourceMinor !== targetMinor) {
126
+ return sourceMinor < targetMinor
127
+ }
128
+ const sourcePatch = sourceDecomp[2].split('-')
129
+ const targetPatch = targetDecomp[2].split('-')
130
+
131
+ const sourcePatchVersion = parseInt(sourcePatch[0], 10)
132
+ const targetPatchVersion = parseInt(targetPatch[0], 10)
133
+
134
+ // Compare patch version
135
+ if (sourcePatchVersion !== targetPatchVersion) {
136
+ return sourcePatchVersion < targetPatchVersion
137
+ }
138
+
139
+ // Compare release version
140
+ if (sourcePatch.length !== targetPatch.length) {
141
+ return sourcePatch.length > targetPatch.length
142
+ }
143
+
144
+ if (sourcePatch.length === 2) {
145
+ // Compare different release types
146
+ if (!sourcePatch[1][0].startsWith(targetPatch[1][0])) {
147
+ return sourcePatch[1] < targetPatch[1]
148
+ }
149
+ // Compare beta version
150
+ if (sourcePatch[1].startsWith('b')) {
151
+ return (
152
+ parseInt(sourcePatch[1].slice(1), 10) <
153
+ parseInt(targetPatch[1].slice(1), 10)
154
+ )
155
+ }
156
+ // Compare rc version
157
+ return (
158
+ parseInt(sourcePatch[1].slice(2), 10) <
159
+ parseInt(targetPatch[1].slice(2), 10)
160
+ )
161
+ }
162
+
163
+ return false
164
+ }
165
+
166
+ /**
167
+ * Determine if the transaction required a networkID to be valid.
168
+ * Transaction needs networkID if later than restricted ID and either the network is hooks testnet
169
+ * or build version is >= 1.11.0
170
+ *
171
+ * @param client -- The connected client.
172
+ * @returns True if required networkID, false otherwise.
173
+ */
174
+ function txNeedsNetworkID(client: Client): boolean {
175
+ if (
176
+ client.networkID !== undefined &&
177
+ client.networkID > RESTRICTED_NETWORKS
178
+ ) {
179
+ // TODO: remove the buildVersion logic when 1.11.0 is out and widely used.
180
+ // Issue: https://github.com/XRPLF/xrpl.js/issues/2339
181
+ if (
182
+ (client.buildVersion &&
183
+ isNotLaterRippledVersion(
184
+ REQUIRED_NETWORKID_VERSION,
185
+ client.buildVersion,
186
+ )) ||
187
+ client.networkID === HOOKS_TESTNET_ID
188
+ ) {
189
+ return true
190
+ }
191
+ }
192
+ return false
193
+ }
194
+
195
+ function setValidAddresses(tx: Transaction): void {
196
+ validateAccountAddress(tx, 'Account', 'SourceTag')
197
+ // eslint-disable-next-line @typescript-eslint/dot-notation -- Destination can exist on Transaction
198
+ if (tx['Destination'] != null) {
199
+ validateAccountAddress(tx, 'Destination', 'DestinationTag')
200
+ }
201
+
202
+ // DepositPreauth:
203
+ convertToClassicAddress(tx, 'Authorize')
204
+ convertToClassicAddress(tx, 'Unauthorize')
205
+ // EscrowCancel, EscrowFinish:
206
+ convertToClassicAddress(tx, 'Owner')
207
+ // SetRegularKey:
208
+ convertToClassicAddress(tx, 'RegularKey')
209
+ }
210
+
211
+ function validateAccountAddress(
212
+ tx: Transaction,
213
+ accountField: string,
214
+ tagField: string,
215
+ ): void {
216
+ // if X-address is given, convert it to classic address
217
+ const { classicAccount, tag } = getClassicAccountAndTag(tx[accountField])
218
+ // eslint-disable-next-line no-param-reassign -- param reassign is safe
219
+ tx[accountField] = classicAccount
220
+
221
+ if (tag != null && tag !== false) {
222
+ if (tx[tagField] && tx[tagField] !== tag) {
223
+ throw new ValidationError(
224
+ `The ${tagField}, if present, must match the tag of the ${accountField} X-address`,
225
+ )
226
+ }
227
+ // eslint-disable-next-line no-param-reassign -- param reassign is safe
228
+ tx[tagField] = tag
229
+ }
230
+ }
231
+
232
+ function getClassicAccountAndTag(
233
+ Account: string,
234
+ expectedTag?: number,
235
+ ): ClassicAccountAndTag {
236
+ if (isValidXAddress(Account)) {
237
+ const classic = xAddressToClassicAddress(Account)
238
+ if (expectedTag != null && classic.tag !== expectedTag) {
239
+ throw new ValidationError(
240
+ 'address includes a tag that does not match the tag specified in the transaction',
241
+ )
242
+ }
243
+ return {
244
+ classicAccount: classic.classicAddress,
245
+ tag: classic.tag,
246
+ }
247
+ }
248
+ return {
249
+ classicAccount: Account,
250
+ tag: expectedTag,
251
+ }
252
+ }
253
+
254
+ function convertToClassicAddress(tx: Transaction, fieldName: string): void {
255
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- assignment is safe
256
+ const account = tx[fieldName]
257
+ if (typeof account === 'string') {
258
+ const { classicAccount } = getClassicAccountAndTag(account)
259
+ // eslint-disable-next-line no-param-reassign -- param reassign is safe
260
+ tx[fieldName] = classicAccount
261
+ }
262
+ }
263
+
264
+ async function setNextValidSequenceNumber(
265
+ client: Client,
266
+ tx: Transaction,
267
+ ): Promise<void> {
268
+ const request: AccountInfoRequest = {
269
+ command: 'account_info',
270
+ account: tx.Account,
271
+ ledger_index: 'current',
272
+ }
273
+ const data = await client.request(request)
274
+ // eslint-disable-next-line no-param-reassign, require-atomic-updates -- param reassign is safe with no race condition
275
+ tx.Sequence = data.result.account_data.Sequence
276
+ }
277
+
278
+ async function fetchOwnerReserveFee(client: Client): Promise<BigNumber> {
279
+ const response = await client.request({ command: 'server_state' })
280
+ const fee = response.result.state.validated_ledger?.reserve_inc
281
+
282
+ if (fee == null) {
283
+ return Promise.reject(new Error('Could not fetch Owner Reserve.'))
284
+ }
285
+
286
+ return new BigNumber(fee)
287
+ }
288
+
289
+ async function calculateFeePerTransactionType(
290
+ client: Client,
291
+ tx: Transaction,
292
+ signersCount = 0,
293
+ ): Promise<void> {
294
+ // netFee is usually 0.00001 XRP (10 drops)
295
+ const netFeeXRP = await getFeeXrp(client)
296
+ const netFeeDrops = xrpToDrops(netFeeXRP)
297
+ let baseFee = new BigNumber(netFeeDrops)
298
+
299
+ // EscrowFinish Transaction with Fulfillment
300
+ if (tx.TransactionType === 'EscrowFinish' && tx.Fulfillment != null) {
301
+ const fulfillmentBytesSize: number = Math.ceil(tx.Fulfillment.length / 2)
302
+ // 10 drops × (33 + (Fulfillment size in bytes / 16))
303
+ const product = new BigNumber(
304
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- expected use of magic numbers
305
+ scaleValue(netFeeDrops, 33 + fulfillmentBytesSize / 16),
306
+ )
307
+ baseFee = product.dp(0, BigNumber.ROUND_CEIL)
308
+ }
309
+
310
+ if (
311
+ tx.TransactionType === 'AccountDelete' ||
312
+ tx.TransactionType === 'AMMCreate'
313
+ ) {
314
+ baseFee = await fetchOwnerReserveFee(client)
315
+ }
316
+
317
+ /*
318
+ * Multi-signed Transaction
319
+ * 10 drops × (1 + Number of Signatures Provided)
320
+ */
321
+ if (signersCount > 0) {
322
+ baseFee = BigNumber.sum(baseFee, scaleValue(netFeeDrops, 1 + signersCount))
323
+ }
324
+
325
+ const maxFeeDrops = xrpToDrops(client.maxFeeXRP)
326
+ const totalFee =
327
+ tx.TransactionType === 'AccountDelete'
328
+ ? baseFee
329
+ : BigNumber.min(baseFee, maxFeeDrops)
330
+
331
+ // Round up baseFee and return it as a string
332
+ // eslint-disable-next-line no-param-reassign, @typescript-eslint/no-magic-numbers -- param reassign is safe, base 10 magic num
333
+ tx.Fee = totalFee.dp(0, BigNumber.ROUND_CEIL).toString(10)
334
+ }
335
+
336
+ function scaleValue(value, multiplier): string {
337
+ return new BigNumber(value).times(multiplier).toString()
338
+ }
339
+
340
+ async function setLatestValidatedLedgerSequence(
341
+ client: Client,
342
+ tx: Transaction,
343
+ ): Promise<void> {
344
+ const ledgerSequence = await client.getLedgerIndex()
345
+ // eslint-disable-next-line no-param-reassign -- param reassign is safe
346
+ tx.LastLedgerSequence = ledgerSequence + LEDGER_OFFSET
347
+ }
348
+
349
+ async function checkAccountDeleteBlockers(
350
+ client: Client,
351
+ tx: Transaction,
352
+ ): Promise<void> {
353
+ const request: AccountObjectsRequest = {
354
+ command: 'account_objects',
355
+ account: tx.Account,
356
+ ledger_index: 'validated',
357
+ deletion_blockers_only: true,
358
+ }
359
+ const response = await client.request(request)
360
+ return new Promise((resolve, reject) => {
361
+ if (response.result.account_objects.length > 0) {
362
+ reject(
363
+ new XrplError(
364
+ `Account ${tx.Account} cannot be deleted; there are Escrows, PayChannels, RippleStates, or Checks associated with the account.`,
365
+ response.result.account_objects,
366
+ ),
367
+ )
368
+ }
369
+ resolve()
370
+ })
371
+ }
372
+
373
+ export default autofill