xrpl 2.12.0-beta.0 → 2.12.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 (263) 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 +139 -312
  4. package/build/xrpl-latest.js.map +1 -1
  5. package/dist/npm/models/common/index.d.ts +2 -1
  6. package/dist/npm/models/common/index.d.ts.map +1 -1
  7. package/dist/npm/models/ledger/AMM.d.ts +5 -3
  8. package/dist/npm/models/ledger/AMM.d.ts.map +1 -1
  9. package/dist/npm/models/ledger/AccountRoot.d.ts +1 -0
  10. package/dist/npm/models/ledger/AccountRoot.d.ts.map +1 -1
  11. package/dist/npm/models/ledger/AccountRoot.js.map +1 -1
  12. package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts +11 -1
  13. package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts.map +1 -1
  14. package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +10 -1
  15. package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -1
  16. package/dist/npm/models/ledger/index.d.ts +2 -1
  17. package/dist/npm/models/ledger/index.d.ts.map +1 -1
  18. package/dist/npm/models/ledger/index.js.map +1 -1
  19. package/dist/npm/models/methods/accountObjects.d.ts +3 -3
  20. package/dist/npm/models/methods/accountObjects.d.ts.map +1 -1
  21. package/dist/npm/models/methods/ammInfo.d.ts +4 -3
  22. package/dist/npm/models/methods/ammInfo.d.ts.map +1 -1
  23. package/dist/npm/models/methods/ledgerEntry.d.ts +4 -4
  24. package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
  25. package/dist/npm/models/methods/serverInfo.d.ts +6 -0
  26. package/dist/npm/models/methods/serverInfo.d.ts.map +1 -1
  27. package/dist/npm/models/transactions/AMMBid.d.ts +3 -3
  28. package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -1
  29. package/dist/npm/models/transactions/AMMBid.js.map +1 -1
  30. package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -1
  31. package/dist/npm/models/transactions/AMMDeposit.js.map +1 -1
  32. package/dist/npm/models/transactions/AMMWithdraw.d.ts.map +1 -1
  33. package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -1
  34. package/dist/npm/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -1
  35. package/dist/npm/models/transactions/XChainAccountCreateCommit.js +5 -26
  36. package/dist/npm/models/transactions/XChainAccountCreateCommit.js.map +1 -1
  37. package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -1
  38. package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js +11 -68
  39. package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -1
  40. package/dist/npm/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -1
  41. package/dist/npm/models/transactions/XChainAddClaimAttestation.js +10 -59
  42. package/dist/npm/models/transactions/XChainAddClaimAttestation.js.map +1 -1
  43. package/dist/npm/models/transactions/XChainClaim.d.ts.map +1 -1
  44. package/dist/npm/models/transactions/XChainClaim.js +5 -30
  45. package/dist/npm/models/transactions/XChainClaim.js.map +1 -1
  46. package/dist/npm/models/transactions/XChainCommit.d.ts.map +1 -1
  47. package/dist/npm/models/transactions/XChainCommit.js +4 -24
  48. package/dist/npm/models/transactions/XChainCommit.js.map +1 -1
  49. package/dist/npm/models/transactions/XChainCreateBridge.d.ts.map +1 -1
  50. package/dist/npm/models/transactions/XChainCreateBridge.js +3 -17
  51. package/dist/npm/models/transactions/XChainCreateBridge.js.map +1 -1
  52. package/dist/npm/models/transactions/XChainCreateClaimID.d.ts.map +1 -1
  53. package/dist/npm/models/transactions/XChainCreateClaimID.js +3 -19
  54. package/dist/npm/models/transactions/XChainCreateClaimID.js.map +1 -1
  55. package/dist/npm/models/transactions/XChainModifyBridge.d.ts.map +1 -1
  56. package/dist/npm/models/transactions/XChainModifyBridge.js +3 -14
  57. package/dist/npm/models/transactions/XChainModifyBridge.js.map +1 -1
  58. package/dist/npm/models/transactions/accountSet.d.ts.map +1 -1
  59. package/dist/npm/models/transactions/accountSet.js.map +1 -1
  60. package/dist/npm/models/transactions/checkCash.d.ts.map +1 -1
  61. package/dist/npm/models/transactions/checkCash.js.map +1 -1
  62. package/dist/npm/models/transactions/checkCreate.d.ts.map +1 -1
  63. package/dist/npm/models/transactions/checkCreate.js.map +1 -1
  64. package/dist/npm/models/transactions/common.d.ts +4 -0
  65. package/dist/npm/models/transactions/common.d.ts.map +1 -1
  66. package/dist/npm/models/transactions/common.js +33 -38
  67. package/dist/npm/models/transactions/common.js.map +1 -1
  68. package/dist/npm/models/transactions/depositPreauth.d.ts.map +1 -1
  69. package/dist/npm/models/transactions/depositPreauth.js.map +1 -1
  70. package/dist/npm/models/transactions/escrowCancel.d.ts +1 -1
  71. package/dist/npm/models/transactions/escrowCancel.d.ts.map +1 -1
  72. package/dist/npm/models/transactions/escrowCancel.js +5 -3
  73. package/dist/npm/models/transactions/escrowCancel.js.map +1 -1
  74. package/dist/npm/models/transactions/escrowCreate.d.ts.map +1 -1
  75. package/dist/npm/models/transactions/escrowCreate.js.map +1 -1
  76. package/dist/npm/models/transactions/escrowFinish.d.ts +1 -1
  77. package/dist/npm/models/transactions/escrowFinish.d.ts.map +1 -1
  78. package/dist/npm/models/transactions/escrowFinish.js +5 -3
  79. package/dist/npm/models/transactions/escrowFinish.js.map +1 -1
  80. package/dist/npm/models/transactions/offerCreate.d.ts.map +1 -1
  81. package/dist/npm/models/transactions/offerCreate.js.map +1 -1
  82. package/dist/npm/models/transactions/payment.d.ts.map +1 -1
  83. package/dist/npm/models/transactions/payment.js.map +1 -1
  84. package/dist/npm/models/transactions/paymentChannelClaim.d.ts.map +1 -1
  85. package/dist/npm/models/transactions/paymentChannelClaim.js.map +1 -1
  86. package/dist/npm/models/transactions/paymentChannelCreate.d.ts.map +1 -1
  87. package/dist/npm/models/transactions/paymentChannelCreate.js.map +1 -1
  88. package/dist/npm/models/transactions/signerListSet.d.ts.map +1 -1
  89. package/dist/npm/models/transactions/signerListSet.js.map +1 -1
  90. package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
  91. package/dist/npm/models/transactions/transaction.js.map +1 -1
  92. package/dist/npm/models/utils/flags.d.ts.map +1 -1
  93. package/dist/npm/models/utils/flags.js.map +1 -1
  94. package/dist/npm/snippets/src/bridgeTransfer.js +12 -10
  95. package/dist/npm/snippets/src/bridgeTransfer.js.map +1 -1
  96. package/dist/npm/src/models/common/index.d.ts +2 -1
  97. package/dist/npm/src/models/common/index.d.ts.map +1 -1
  98. package/dist/npm/src/models/ledger/AMM.d.ts +5 -3
  99. package/dist/npm/src/models/ledger/AMM.d.ts.map +1 -1
  100. package/dist/npm/src/models/ledger/AccountRoot.d.ts +1 -0
  101. package/dist/npm/src/models/ledger/AccountRoot.d.ts.map +1 -1
  102. package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
  103. package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts +11 -1
  104. package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts.map +1 -1
  105. package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +10 -1
  106. package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -1
  107. package/dist/npm/src/models/ledger/index.d.ts +2 -1
  108. package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
  109. package/dist/npm/src/models/ledger/index.js.map +1 -1
  110. package/dist/npm/src/models/methods/accountObjects.d.ts +3 -3
  111. package/dist/npm/src/models/methods/accountObjects.d.ts.map +1 -1
  112. package/dist/npm/src/models/methods/ammInfo.d.ts +4 -3
  113. package/dist/npm/src/models/methods/ammInfo.d.ts.map +1 -1
  114. package/dist/npm/src/models/methods/ledgerEntry.d.ts +4 -4
  115. package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
  116. package/dist/npm/src/models/methods/serverInfo.d.ts +6 -0
  117. package/dist/npm/src/models/methods/serverInfo.d.ts.map +1 -1
  118. package/dist/npm/src/models/transactions/AMMBid.d.ts +3 -3
  119. package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -1
  120. package/dist/npm/src/models/transactions/AMMBid.js.map +1 -1
  121. package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -1
  122. package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -1
  123. package/dist/npm/src/models/transactions/AMMWithdraw.d.ts.map +1 -1
  124. package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -1
  125. package/dist/npm/src/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -1
  126. package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js +5 -26
  127. package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js.map +1 -1
  128. package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -1
  129. package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js +11 -68
  130. package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -1
  131. package/dist/npm/src/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -1
  132. package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js +10 -59
  133. package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js.map +1 -1
  134. package/dist/npm/src/models/transactions/XChainClaim.d.ts.map +1 -1
  135. package/dist/npm/src/models/transactions/XChainClaim.js +5 -30
  136. package/dist/npm/src/models/transactions/XChainClaim.js.map +1 -1
  137. package/dist/npm/src/models/transactions/XChainCommit.d.ts.map +1 -1
  138. package/dist/npm/src/models/transactions/XChainCommit.js +4 -24
  139. package/dist/npm/src/models/transactions/XChainCommit.js.map +1 -1
  140. package/dist/npm/src/models/transactions/XChainCreateBridge.d.ts.map +1 -1
  141. package/dist/npm/src/models/transactions/XChainCreateBridge.js +3 -17
  142. package/dist/npm/src/models/transactions/XChainCreateBridge.js.map +1 -1
  143. package/dist/npm/src/models/transactions/XChainCreateClaimID.d.ts.map +1 -1
  144. package/dist/npm/src/models/transactions/XChainCreateClaimID.js +3 -19
  145. package/dist/npm/src/models/transactions/XChainCreateClaimID.js.map +1 -1
  146. package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts.map +1 -1
  147. package/dist/npm/src/models/transactions/XChainModifyBridge.js +3 -14
  148. package/dist/npm/src/models/transactions/XChainModifyBridge.js.map +1 -1
  149. package/dist/npm/src/models/transactions/accountSet.d.ts.map +1 -1
  150. package/dist/npm/src/models/transactions/accountSet.js.map +1 -1
  151. package/dist/npm/src/models/transactions/checkCash.d.ts.map +1 -1
  152. package/dist/npm/src/models/transactions/checkCash.js.map +1 -1
  153. package/dist/npm/src/models/transactions/checkCreate.d.ts.map +1 -1
  154. package/dist/npm/src/models/transactions/checkCreate.js.map +1 -1
  155. package/dist/npm/src/models/transactions/common.d.ts +4 -0
  156. package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
  157. package/dist/npm/src/models/transactions/common.js +33 -38
  158. package/dist/npm/src/models/transactions/common.js.map +1 -1
  159. package/dist/npm/src/models/transactions/depositPreauth.d.ts.map +1 -1
  160. package/dist/npm/src/models/transactions/depositPreauth.js.map +1 -1
  161. package/dist/npm/src/models/transactions/escrowCancel.d.ts +1 -1
  162. package/dist/npm/src/models/transactions/escrowCancel.d.ts.map +1 -1
  163. package/dist/npm/src/models/transactions/escrowCancel.js +5 -3
  164. package/dist/npm/src/models/transactions/escrowCancel.js.map +1 -1
  165. package/dist/npm/src/models/transactions/escrowCreate.d.ts.map +1 -1
  166. package/dist/npm/src/models/transactions/escrowCreate.js.map +1 -1
  167. package/dist/npm/src/models/transactions/escrowFinish.d.ts +1 -1
  168. package/dist/npm/src/models/transactions/escrowFinish.d.ts.map +1 -1
  169. package/dist/npm/src/models/transactions/escrowFinish.js +5 -3
  170. package/dist/npm/src/models/transactions/escrowFinish.js.map +1 -1
  171. package/dist/npm/src/models/transactions/offerCreate.d.ts.map +1 -1
  172. package/dist/npm/src/models/transactions/offerCreate.js.map +1 -1
  173. package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
  174. package/dist/npm/src/models/transactions/payment.js.map +1 -1
  175. package/dist/npm/src/models/transactions/paymentChannelClaim.d.ts.map +1 -1
  176. package/dist/npm/src/models/transactions/paymentChannelClaim.js.map +1 -1
  177. package/dist/npm/src/models/transactions/paymentChannelCreate.d.ts.map +1 -1
  178. package/dist/npm/src/models/transactions/paymentChannelCreate.js.map +1 -1
  179. package/dist/npm/src/models/transactions/signerListSet.d.ts.map +1 -1
  180. package/dist/npm/src/models/transactions/signerListSet.js.map +1 -1
  181. package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
  182. package/dist/npm/src/models/transactions/transaction.js.map +1 -1
  183. package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
  184. package/dist/npm/src/models/utils/flags.js.map +1 -1
  185. package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
  186. package/dist/npm/src/sugar/autofill.js.map +1 -1
  187. package/dist/npm/src/utils/getXChainClaimID.d.ts +3 -0
  188. package/dist/npm/src/utils/getXChainClaimID.d.ts.map +1 -0
  189. package/dist/npm/src/utils/getXChainClaimID.js +29 -0
  190. package/dist/npm/src/utils/getXChainClaimID.js.map +1 -0
  191. package/dist/npm/src/utils/index.d.ts +2 -1
  192. package/dist/npm/src/utils/index.d.ts.map +1 -1
  193. package/dist/npm/src/utils/index.js +3 -1
  194. package/dist/npm/src/utils/index.js.map +1 -1
  195. package/dist/npm/src/utils/signPaymentChannelClaim.d.ts +1 -1
  196. package/dist/npm/src/utils/signPaymentChannelClaim.d.ts.map +1 -1
  197. package/dist/npm/src/utils/signPaymentChannelClaim.js +2 -2
  198. package/dist/npm/src/utils/signPaymentChannelClaim.js.map +1 -1
  199. package/dist/npm/src/utils/verifyPaymentChannelClaim.d.ts +1 -1
  200. package/dist/npm/src/utils/verifyPaymentChannelClaim.d.ts.map +1 -1
  201. package/dist/npm/src/utils/verifyPaymentChannelClaim.js +2 -2
  202. package/dist/npm/src/utils/verifyPaymentChannelClaim.js.map +1 -1
  203. package/dist/npm/sugar/autofill.d.ts.map +1 -1
  204. package/dist/npm/sugar/autofill.js.map +1 -1
  205. package/dist/npm/utils/getXChainClaimID.d.ts +3 -0
  206. package/dist/npm/utils/getXChainClaimID.d.ts.map +1 -0
  207. package/dist/npm/utils/getXChainClaimID.js +29 -0
  208. package/dist/npm/utils/getXChainClaimID.js.map +1 -0
  209. package/dist/npm/utils/index.d.ts +2 -1
  210. package/dist/npm/utils/index.d.ts.map +1 -1
  211. package/dist/npm/utils/index.js +3 -1
  212. package/dist/npm/utils/index.js.map +1 -1
  213. package/dist/npm/utils/signPaymentChannelClaim.d.ts +1 -1
  214. package/dist/npm/utils/signPaymentChannelClaim.d.ts.map +1 -1
  215. package/dist/npm/utils/signPaymentChannelClaim.js +2 -2
  216. package/dist/npm/utils/signPaymentChannelClaim.js.map +1 -1
  217. package/dist/npm/utils/verifyPaymentChannelClaim.d.ts +1 -1
  218. package/dist/npm/utils/verifyPaymentChannelClaim.d.ts.map +1 -1
  219. package/dist/npm/utils/verifyPaymentChannelClaim.js +2 -2
  220. package/dist/npm/utils/verifyPaymentChannelClaim.js.map +1 -1
  221. package/package.json +6 -7
  222. package/src/models/common/index.ts +2 -1
  223. package/src/models/ledger/AMM.ts +11 -3
  224. package/src/models/ledger/AccountRoot.ts +6 -0
  225. package/src/models/ledger/XChainOwnedClaimID.ts +18 -2
  226. package/src/models/ledger/XChainOwnedCreateAccountClaimID.ts +16 -2
  227. package/src/models/ledger/index.ts +3 -0
  228. package/src/models/methods/accountObjects.ts +3 -0
  229. package/src/models/methods/ammInfo.ts +8 -3
  230. package/src/models/methods/ledgerEntry.ts +4 -4
  231. package/src/models/methods/serverInfo.ts +21 -0
  232. package/src/models/transactions/AMMBid.ts +5 -6
  233. package/src/models/transactions/AMMDeposit.ts +0 -1
  234. package/src/models/transactions/AMMWithdraw.ts +0 -1
  235. package/src/models/transactions/XChainAccountCreateCommit.ts +9 -47
  236. package/src/models/transactions/XChainAddAccountCreateAttestation.ts +34 -138
  237. package/src/models/transactions/XChainAddClaimAttestation.ts +33 -116
  238. package/src/models/transactions/XChainClaim.ts +15 -41
  239. package/src/models/transactions/XChainCommit.ts +14 -35
  240. package/src/models/transactions/XChainCreateBridge.ts +7 -29
  241. package/src/models/transactions/XChainCreateClaimID.ts +7 -32
  242. package/src/models/transactions/XChainModifyBridge.ts +7 -23
  243. package/src/models/transactions/accountSet.ts +0 -2
  244. package/src/models/transactions/checkCash.ts +0 -1
  245. package/src/models/transactions/checkCreate.ts +0 -1
  246. package/src/models/transactions/common.ts +82 -53
  247. package/src/models/transactions/depositPreauth.ts +0 -1
  248. package/src/models/transactions/escrowCancel.ts +8 -4
  249. package/src/models/transactions/escrowCreate.ts +0 -1
  250. package/src/models/transactions/escrowFinish.ts +8 -4
  251. package/src/models/transactions/offerCreate.ts +0 -1
  252. package/src/models/transactions/payment.ts +0 -1
  253. package/src/models/transactions/paymentChannelClaim.ts +0 -1
  254. package/src/models/transactions/paymentChannelCreate.ts +0 -1
  255. package/src/models/transactions/signerListSet.ts +0 -1
  256. package/src/models/transactions/transaction.ts +0 -1
  257. package/src/models/utils/flags.ts +0 -1
  258. package/src/sugar/autofill.ts +0 -2
  259. package/src/utils/getXChainClaimID.ts +64 -0
  260. package/src/utils/index.ts +2 -0
  261. package/src/utils/signPaymentChannelClaim.ts +3 -3
  262. package/src/utils/verifyPaymentChannelClaim.ts +3 -3
  263. package/dist/npm/snippets/tsconfig.tsbuildinfo +0 -1
@@ -1,6 +1,3 @@
1
- /* eslint-disable max-lines-per-function -- Necessary for validateBaseTransaction */
2
- /* eslint-disable complexity -- Necessary for validateBaseTransaction */
3
- /* eslint-disable max-statements -- Necessary for validateBaseTransaction */
4
1
  import { TRANSACTION_TYPES } from 'ripple-binary-codec'
5
2
 
6
3
  import { ValidationError } from '../../errors'
@@ -66,6 +63,26 @@ function isRecord(value: unknown): value is Record<string, unknown> {
66
63
  return value !== null && typeof value === 'object'
67
64
  }
68
65
 
66
+ /**
67
+ * Verify the form and type of a string at runtime.
68
+ *
69
+ * @param str - The object to check the form and type of.
70
+ * @returns Whether the string is properly formed.
71
+ */
72
+ export function isString(str: unknown): str is string {
73
+ return typeof str === 'string'
74
+ }
75
+
76
+ /**
77
+ * Verify the form and type of a number at runtime.
78
+ *
79
+ * @param num - The object to check the form and type of.
80
+ * @returns Whether the number is properly formed.
81
+ */
82
+ export function isNumber(num: unknown): num is number {
83
+ return typeof num === 'number'
84
+ }
85
+
69
86
  /**
70
87
  * Verify the form and type of an IssuedCurrency at runtime.
71
88
  *
@@ -128,6 +145,56 @@ export function isXChainBridge(input: unknown): input is XChainBridge {
128
145
  )
129
146
  }
130
147
 
148
+ /* eslint-disable @typescript-eslint/restrict-template-expressions -- tx.TransactionType is checked before any calls */
149
+
150
+ /**
151
+ * Verify the form and type of a required type for a transaction at runtime.
152
+ *
153
+ * @param tx - The transaction input to check the form and type of.
154
+ * @param paramName - The name of the transaction parameter.
155
+ * @param checkValidity - The function to use to check the type.
156
+ * @throws
157
+ */
158
+ export function validateRequiredField(
159
+ tx: Record<string, unknown>,
160
+ paramName: string,
161
+ checkValidity: (inp: unknown) => boolean,
162
+ ): void {
163
+ if (tx[paramName] == null) {
164
+ throw new ValidationError(
165
+ `${tx.TransactionType}: missing field ${paramName}`,
166
+ )
167
+ }
168
+
169
+ if (!checkValidity(tx[paramName])) {
170
+ throw new ValidationError(
171
+ `${tx.TransactionType}: invalid field ${paramName}`,
172
+ )
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Verify the form and type of an optional type for a transaction at runtime.
178
+ *
179
+ * @param tx - The transaction input to check the form and type of.
180
+ * @param paramName - The name of the transaction parameter.
181
+ * @param checkValidity - The function to use to check the type.
182
+ * @throws
183
+ */
184
+ export function validateOptionalField(
185
+ tx: Record<string, unknown>,
186
+ paramName: string,
187
+ checkValidity: (inp: unknown) => boolean,
188
+ ): void {
189
+ if (tx[paramName] !== undefined && !checkValidity(tx[paramName])) {
190
+ throw new ValidationError(
191
+ `${tx.TransactionType}: invalid field ${paramName}`,
192
+ )
193
+ }
194
+ }
195
+
196
+ /* eslint-enable @typescript-eslint/restrict-template-expressions -- checked before */
197
+
131
198
  // eslint-disable-next-line @typescript-eslint/no-empty-interface -- no global flags right now, so this is fine
132
199
  export interface GlobalFlags {}
133
200
 
@@ -216,14 +283,6 @@ export interface BaseTransaction {
216
283
  * @throws When the common param is malformed.
217
284
  */
218
285
  export function validateBaseTransaction(common: Record<string, unknown>): void {
219
- if (common.Account === undefined) {
220
- throw new ValidationError('BaseTransaction: missing field Account')
221
- }
222
-
223
- if (typeof common.Account !== 'string') {
224
- throw new ValidationError('BaseTransaction: Account not string')
225
- }
226
-
227
286
  if (common.TransactionType === undefined) {
228
287
  throw new ValidationError('BaseTransaction: missing field TransactionType')
229
288
  }
@@ -236,27 +295,15 @@ export function validateBaseTransaction(common: Record<string, unknown>): void {
236
295
  throw new ValidationError('BaseTransaction: Unknown TransactionType')
237
296
  }
238
297
 
239
- if (common.Fee !== undefined && typeof common.Fee !== 'string') {
240
- throw new ValidationError('BaseTransaction: invalid Fee')
241
- }
298
+ validateRequiredField(common, 'Account', isString)
242
299
 
243
- if (common.Sequence !== undefined && typeof common.Sequence !== 'number') {
244
- throw new ValidationError('BaseTransaction: invalid Sequence')
245
- }
300
+ validateOptionalField(common, 'Fee', isString)
246
301
 
247
- if (
248
- common.AccountTxnID !== undefined &&
249
- typeof common.AccountTxnID !== 'string'
250
- ) {
251
- throw new ValidationError('BaseTransaction: invalid AccountTxnID')
252
- }
302
+ validateOptionalField(common, 'Sequence', isNumber)
253
303
 
254
- if (
255
- common.LastLedgerSequence !== undefined &&
256
- typeof common.LastLedgerSequence !== 'number'
257
- ) {
258
- throw new ValidationError('BaseTransaction: invalid LastLedgerSequence')
259
- }
304
+ validateOptionalField(common, 'AccountTxnID', isString)
305
+
306
+ validateOptionalField(common, 'LastLedgerSequence', isNumber)
260
307
 
261
308
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
262
309
  const memos = common.Memos as Array<{ Memo?: unknown }> | undefined
@@ -274,33 +321,15 @@ export function validateBaseTransaction(common: Record<string, unknown>): void {
274
321
  throw new ValidationError('BaseTransaction: invalid Signers')
275
322
  }
276
323
 
277
- if (common.SourceTag !== undefined && typeof common.SourceTag !== 'number') {
278
- throw new ValidationError('BaseTransaction: invalid SourceTag')
279
- }
324
+ validateOptionalField(common, 'SourceTag', isNumber)
280
325
 
281
- if (
282
- common.SigningPubKey !== undefined &&
283
- typeof common.SigningPubKey !== 'string'
284
- ) {
285
- throw new ValidationError('BaseTransaction: invalid SigningPubKey')
286
- }
326
+ validateOptionalField(common, 'SigningPubKey', isString)
287
327
 
288
- if (
289
- common.TicketSequence !== undefined &&
290
- typeof common.TicketSequence !== 'number'
291
- ) {
292
- throw new ValidationError('BaseTransaction: invalid TicketSequence')
293
- }
328
+ validateOptionalField(common, 'TicketSequence', isNumber)
294
329
 
295
- if (
296
- common.TxnSignature !== undefined &&
297
- typeof common.TxnSignature !== 'string'
298
- ) {
299
- throw new ValidationError('BaseTransaction: invalid TxnSignature')
300
- }
301
- if (common.NetworkID !== undefined && typeof common.NetworkID !== 'number') {
302
- throw new ValidationError('BaseTransaction: invalid NetworkID')
303
- }
330
+ validateOptionalField(common, 'TxnSignature', isString)
331
+
332
+ validateOptionalField(common, 'NetworkID', isNumber)
304
333
  }
305
334
 
306
335
  /**
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validateDepositPreauth */
2
1
  import { ValidationError } from '../../errors'
3
2
 
4
3
  import { BaseTransaction, validateBaseTransaction } from './common'
@@ -15,7 +15,7 @@ export interface EscrowCancel extends BaseTransaction {
15
15
  * Transaction sequence (or Ticket number) of EscrowCreate transaction that.
16
16
  * created the escrow to cancel.
17
17
  */
18
- OfferSequence: number
18
+ OfferSequence: number | string
19
19
  }
20
20
 
21
21
  /**
@@ -27,7 +27,7 @@ export interface EscrowCancel extends BaseTransaction {
27
27
  export function validateEscrowCancel(tx: Record<string, unknown>): void {
28
28
  validateBaseTransaction(tx)
29
29
 
30
- if (tx.Owner === undefined) {
30
+ if (tx.Owner == null) {
31
31
  throw new ValidationError('EscrowCancel: missing Owner')
32
32
  }
33
33
 
@@ -35,11 +35,15 @@ export function validateEscrowCancel(tx: Record<string, unknown>): void {
35
35
  throw new ValidationError('EscrowCancel: Owner must be a string')
36
36
  }
37
37
 
38
- if (tx.OfferSequence === undefined) {
38
+ if (tx.OfferSequence == null) {
39
39
  throw new ValidationError('EscrowCancel: missing OfferSequence')
40
40
  }
41
41
 
42
- if (typeof tx.OfferSequence !== 'number') {
42
+ if (
43
+ (typeof tx.OfferSequence !== 'number' &&
44
+ typeof tx.OfferSequence !== 'string') ||
45
+ Number.isNaN(Number(tx.OfferSequence))
46
+ ) {
43
47
  throw new ValidationError('EscrowCancel: OfferSequence must be a number')
44
48
  }
45
49
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validateEscrowCreate */
2
1
  import { ValidationError } from '../../errors'
3
2
 
4
3
  import { BaseTransaction, validateBaseTransaction } from './common'
@@ -15,7 +15,7 @@ export interface EscrowFinish extends BaseTransaction {
15
15
  * Transaction sequence of EscrowCreate transaction that created the held.
16
16
  * payment to finish.
17
17
  */
18
- OfferSequence: number
18
+ OfferSequence: number | string
19
19
  /**
20
20
  * Hex value matching the previously-supplied PREIMAGE-SHA-256.
21
21
  * crypto-condition of the held payment.
@@ -37,7 +37,7 @@ export interface EscrowFinish extends BaseTransaction {
37
37
  export function validateEscrowFinish(tx: Record<string, unknown>): void {
38
38
  validateBaseTransaction(tx)
39
39
 
40
- if (tx.Owner === undefined) {
40
+ if (tx.Owner == null) {
41
41
  throw new ValidationError('EscrowFinish: missing field Owner')
42
42
  }
43
43
 
@@ -45,11 +45,15 @@ export function validateEscrowFinish(tx: Record<string, unknown>): void {
45
45
  throw new ValidationError('EscrowFinish: Owner must be a string')
46
46
  }
47
47
 
48
- if (tx.OfferSequence === undefined) {
48
+ if (tx.OfferSequence == null) {
49
49
  throw new ValidationError('EscrowFinish: missing field OfferSequence')
50
50
  }
51
51
 
52
- if (typeof tx.OfferSequence !== 'number') {
52
+ if (
53
+ (typeof tx.OfferSequence !== 'number' &&
54
+ typeof tx.OfferSequence !== 'string') ||
55
+ Number.isNaN(Number(tx.OfferSequence))
56
+ ) {
53
57
  throw new ValidationError('EscrowFinish: OfferSequence must be a number')
54
58
  }
55
59
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validateOfferCreate */
2
1
  import { ValidationError } from '../../errors'
3
2
  import { Amount } from '../common'
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validatePayment */
2
1
  import { ValidationError } from '../../errors'
3
2
  import { Amount, Path } from '../common'
4
3
  import { isFlagEnabled } from '../utils'
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validatePaymentChannelClaim */
2
1
  import { ValidationError } from '../../errors'
3
2
 
4
3
  import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validatePaymentChannelCreate */
2
1
  import { ValidationError } from '../../errors'
3
2
 
4
3
  import { BaseTransaction, validateBaseTransaction } from './common'
@@ -36,7 +36,6 @@ const HEX_WALLET_LOCATOR_REGEX = /^[0-9A-Fa-f]{64}$/u
36
36
  * @param tx - An SignerListSet Transaction.
37
37
  * @throws When the SignerListSet is Malformed.
38
38
  */
39
- // eslint-disable-next-line complexity -- validation can be complex
40
39
  export function validateSignerListSet(tx: Record<string, unknown>): void {
41
40
  validateBaseTransaction(tx)
42
41
 
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable max-lines -- need to work with a lot of transactions in a switch statement */
2
- /* eslint-disable complexity -- verifies many tx types hence a lot of checks needed */
3
2
  /* eslint-disable max-lines-per-function -- need to work with a lot of Tx verifications */
4
3
 
5
4
  import { ValidationError } from '../../errors'
@@ -48,7 +48,6 @@ export function parseAccountRootFlags(
48
48
  *
49
49
  * @param tx - A transaction to set its flags to its numeric representation.
50
50
  */
51
- // eslint-disable-next-line complexity -- there's a lot of txs with flags
52
51
  export function setTransactionFlagsToNumber(tx: Transaction): void {
53
52
  if (tx.Flags == null) {
54
53
  tx.Flags = 0
@@ -176,8 +176,6 @@ function txNeedsNetworkID(client: Client): boolean {
176
176
  client.networkID !== undefined &&
177
177
  client.networkID > RESTRICTED_NETWORKS
178
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
179
  if (
182
180
  (client.buildVersion &&
183
181
  isNotLaterRippledVersion(
@@ -0,0 +1,64 @@
1
+ import { decode } from 'ripple-binary-codec'
2
+
3
+ import {
4
+ CreatedNode,
5
+ isCreatedNode,
6
+ TransactionMetadata,
7
+ } from '../models/transactions/metadata'
8
+
9
+ /**
10
+ * Ensures that the metadata is in a deserialized format to parse.
11
+ *
12
+ * @param meta - the metadata from a `tx` method call. Can be in json format or binary format.
13
+ * @returns the metadata in a deserialized format.
14
+ */
15
+ function ensureDecodedMeta(
16
+ meta: TransactionMetadata | string,
17
+ ): TransactionMetadata {
18
+ if (typeof meta === 'string') {
19
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Meta is either metadata or serialized metadata.
20
+ return decode(meta) as unknown as TransactionMetadata
21
+ }
22
+ return meta
23
+ }
24
+
25
+ /**
26
+ * Gets the XChainClaimID value from the metadata of an `XChainCreateClaimID` transaction.
27
+ *
28
+ * @param meta - Metadata from the response to submitting and waiting for an XChainCreateClaimID transaction
29
+ * or from a `tx` method call.
30
+ * @returns The XChainClaimID for the minted NFT.
31
+ * @throws if meta is not TransactionMetadata.
32
+ */
33
+ export default function getXChainClaimID(
34
+ meta: TransactionMetadata | string | undefined,
35
+ ): string | undefined {
36
+ if (typeof meta !== 'string' && meta?.AffectedNodes === undefined) {
37
+ throw new TypeError(`Unable to parse the parameter given to getXChainClaimID.
38
+ 'meta' must be the metadata from an XChainCreateClaimID transaction. Received ${JSON.stringify(
39
+ meta,
40
+ )} instead.`)
41
+ }
42
+
43
+ const decodedMeta = ensureDecodedMeta(meta)
44
+
45
+ if (!decodedMeta.TransactionResult) {
46
+ throw new TypeError(
47
+ 'Cannot get XChainClaimID from un-validated transaction',
48
+ )
49
+ }
50
+
51
+ if (decodedMeta.TransactionResult !== 'tesSUCCESS') {
52
+ return undefined
53
+ }
54
+
55
+ const createdNode = decodedMeta.AffectedNodes.find(
56
+ (node) =>
57
+ isCreatedNode(node) &&
58
+ node.CreatedNode.LedgerEntryType === 'XChainOwnedClaimID',
59
+ )
60
+
61
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- necessary here
62
+ return (createdNode as CreatedNode).CreatedNode.NewFields
63
+ .XChainClaimID as string
64
+ }
@@ -25,6 +25,7 @@ import { Transaction } from '../models/transactions/transaction'
25
25
  import { deriveKeypair, deriveAddress, deriveXAddress } from './derive'
26
26
  import getBalanceChanges from './getBalanceChanges'
27
27
  import getNFTokenID from './getNFTokenID'
28
+ import getXChainClaimID from './getXChainClaimID'
28
29
  import {
29
30
  hashSignedTx,
30
31
  hashTx,
@@ -220,4 +221,5 @@ export {
220
221
  encodeForSigningClaim,
221
222
  getNFTokenID,
222
223
  parseNFTokenID,
224
+ getXChainClaimID,
223
225
  }
@@ -7,19 +7,19 @@ import { xrpToDrops } from './xrpConversion'
7
7
  * Sign a payment channel claim.
8
8
  *
9
9
  * @param channel - Channel identifier specified by the paymentChannelClaim.
10
- * @param amount - Amount specified by the paymentChannelClaim.
10
+ * @param xrpAmount - XRP Amount specified by the paymentChannelClaim.
11
11
  * @param privateKey - Private Key to sign paymentChannelClaim with.
12
12
  * @returns True if the channel is valid.
13
13
  * @category Utilities
14
14
  */
15
15
  function signPaymentChannelClaim(
16
16
  channel: string,
17
- amount: string,
17
+ xrpAmount: string,
18
18
  privateKey: string,
19
19
  ): string {
20
20
  const signingData = encodeForSigningClaim({
21
21
  channel,
22
- amount: xrpToDrops(amount),
22
+ amount: xrpToDrops(xrpAmount),
23
23
  })
24
24
  return sign(signingData, privateKey)
25
25
  }
@@ -7,7 +7,7 @@ import { xrpToDrops } from './xrpConversion'
7
7
  * Verify the signature of a payment channel claim.
8
8
  *
9
9
  * @param channel - Channel identifier specified by the paymentChannelClaim.
10
- * @param amount - Amount specified by the paymentChannelClaim.
10
+ * @param xrpAmount - XRP Amount specified by the paymentChannelClaim.
11
11
  * @param signature - Signature produced from signing paymentChannelClaim.
12
12
  * @param publicKey - Public key that signed the paymentChannelClaim.
13
13
  * @returns True if the channel is valid.
@@ -16,13 +16,13 @@ import { xrpToDrops } from './xrpConversion'
16
16
  // eslint-disable-next-line max-params -- Needs 4 params
17
17
  function verifyPaymentChannelClaim(
18
18
  channel: string,
19
- amount: string,
19
+ xrpAmount: string,
20
20
  signature: string,
21
21
  publicKey: string,
22
22
  ): boolean {
23
23
  const signingData = encodeForSigningClaim({
24
24
  channel,
25
- amount: xrpToDrops(amount),
25
+ amount: xrpToDrops(xrpAmount),
26
26
  })
27
27
  return verify(signingData, signature, publicKey)
28
28
  }