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,11 +1,14 @@
1
- import { ValidationError } from '../../errors'
2
1
  import { Amount, XChainBridge } from '../common'
3
2
 
4
3
  import {
5
4
  BaseTransaction,
6
5
  isAmount,
6
+ isNumber,
7
+ isString,
7
8
  isXChainBridge,
8
9
  validateBaseTransaction,
10
+ validateOptionalField,
11
+ validateRequiredField,
9
12
  } from './common'
10
13
 
11
14
  /**
@@ -72,127 +75,41 @@ export interface XChainAddClaimAttestation extends BaseTransaction {
72
75
  }
73
76
 
74
77
  /**
75
- * Verify the form and type of a XChainAddClaimAttestation at runtime.
78
+ * Verify the form and type of an XChainAddClaimAttestation at runtime.
76
79
  *
77
- * @param tx - A XChainAddClaimAttestation Transaction.
80
+ * @param tx - An XChainAddClaimAttestation Transaction.
78
81
  * @throws When the XChainAddClaimAttestation is malformed.
79
82
  */
80
- // eslint-disable-next-line max-lines-per-function, max-statements, complexity -- okay for this function, lots of things to check
81
83
  export function validateXChainAddClaimAttestation(
82
84
  tx: Record<string, unknown>,
83
85
  ): void {
84
86
  validateBaseTransaction(tx)
85
87
 
86
- if (tx.Amount == null) {
87
- throw new ValidationError('XChainAddClaimAttestation: missing field Amount')
88
- }
89
-
90
- if (!isAmount(tx.Amount)) {
91
- throw new ValidationError('XChainAddClaimAttestation: invalid field Amount')
92
- }
93
-
94
- if (tx.AttestationRewardAccount == null) {
95
- throw new ValidationError(
96
- 'XChainAddClaimAttestation: missing field AttestationRewardAccount',
97
- )
98
- }
99
-
100
- if (typeof tx.AttestationRewardAccount !== 'string') {
101
- throw new ValidationError(
102
- 'XChainAddClaimAttestation: invalid field AttestationRewardAccount',
103
- )
104
- }
105
-
106
- if (tx.AttestationSignerAccount == null) {
107
- throw new ValidationError(
108
- 'XChainAddClaimAttestation: missing field AttestationSignerAccount',
109
- )
110
- }
111
-
112
- if (typeof tx.AttestationSignerAccount !== 'string') {
113
- throw new ValidationError(
114
- 'XChainAddClaimAttestation: invalid field AttestationSignerAccount',
115
- )
116
- }
117
-
118
- if (tx.Destination !== undefined && typeof tx.Destination !== 'string') {
119
- throw new ValidationError(
120
- 'XChainAddClaimAttestation: invalid field Destination',
121
- )
122
- }
123
-
124
- if (tx.OtherChainSource == null) {
125
- throw new ValidationError(
126
- 'XChainAddClaimAttestation: missing field OtherChainSource',
127
- )
128
- }
129
-
130
- if (typeof tx.OtherChainSource !== 'string') {
131
- throw new ValidationError(
132
- 'XChainAddClaimAttestation: invalid field OtherChainSource',
133
- )
134
- }
135
-
136
- if (tx.PublicKey == null) {
137
- throw new ValidationError(
138
- 'XChainAddClaimAttestation: missing field PublicKey',
139
- )
140
- }
141
-
142
- if (typeof tx.PublicKey !== 'string') {
143
- throw new ValidationError(
144
- 'XChainAddClaimAttestation: invalid field PublicKey',
145
- )
146
- }
147
-
148
- if (tx.Signature == null) {
149
- throw new ValidationError(
150
- 'XChainAddClaimAttestation: missing field Signature',
151
- )
152
- }
153
-
154
- if (typeof tx.Signature !== 'string') {
155
- throw new ValidationError(
156
- 'XChainAddClaimAttestation: invalid field Signature',
157
- )
158
- }
159
-
160
- if (tx.WasLockingChainSend == null) {
161
- throw new ValidationError(
162
- 'XChainAddClaimAttestation: missing field WasLockingChainSend',
163
- )
164
- }
165
-
166
- if (tx.WasLockingChainSend !== 0 && tx.WasLockingChainSend !== 1) {
167
- throw new ValidationError(
168
- 'XChainAddClaimAttestation: invalid field WasLockingChainSend',
169
- )
170
- }
171
-
172
- if (tx.XChainBridge == null) {
173
- throw new ValidationError(
174
- 'XChainAddClaimAttestation: missing field XChainBridge',
175
- )
176
- }
177
-
178
- if (!isXChainBridge(tx.XChainBridge)) {
179
- throw new ValidationError(
180
- 'XChainAddClaimAttestation: invalid field XChainBridge',
181
- )
182
- }
183
-
184
- if (tx.XChainClaimID == null) {
185
- throw new ValidationError(
186
- 'XChainAddClaimAttestation: missing field XChainClaimID',
187
- )
188
- }
189
-
190
- if (
191
- typeof tx.XChainClaimID !== 'string' &&
192
- typeof tx.XChainClaimID !== 'number'
193
- ) {
194
- throw new ValidationError(
195
- 'XChainAddClaimAttestation: invalid field XChainClaimID',
196
- )
197
- }
88
+ validateRequiredField(tx, 'Amount', isAmount)
89
+
90
+ validateRequiredField(tx, 'AttestationRewardAccount', isString)
91
+
92
+ validateRequiredField(tx, 'AttestationSignerAccount', isString)
93
+
94
+ validateOptionalField(tx, 'Destination', isString)
95
+
96
+ validateRequiredField(tx, 'OtherChainSource', isString)
97
+
98
+ validateRequiredField(tx, 'PublicKey', isString)
99
+
100
+ validateRequiredField(tx, 'Signature', isString)
101
+
102
+ validateRequiredField(
103
+ tx,
104
+ 'WasLockingChainSend',
105
+ (inp) => inp === 0 || inp === 1,
106
+ )
107
+
108
+ validateRequiredField(tx, 'XChainBridge', isXChainBridge)
109
+
110
+ validateRequiredField(
111
+ tx,
112
+ 'XChainClaimID',
113
+ (inp) => isNumber(inp) || isString(inp),
114
+ )
198
115
  }
@@ -1,11 +1,14 @@
1
- import { ValidationError } from '../../errors'
2
1
  import { Amount, XChainBridge } from '../common'
3
2
 
4
3
  import {
5
4
  BaseTransaction,
6
5
  isAmount,
6
+ isNumber,
7
+ isString,
7
8
  isXChainBridge,
8
9
  validateBaseTransaction,
10
+ validateOptionalField,
11
+ validateRequiredField,
9
12
  } from './common'
10
13
 
11
14
  /**
@@ -50,54 +53,25 @@ export interface XChainClaim extends BaseTransaction {
50
53
  }
51
54
 
52
55
  /**
53
- * Verify the form and type of a XChainClaim at runtime.
56
+ * Verify the form and type of an XChainClaim at runtime.
54
57
  *
55
- * @param tx - A XChainClaim Transaction.
58
+ * @param tx - An XChainClaim Transaction.
56
59
  * @throws When the XChainClaim is malformed.
57
60
  */
58
- // eslint-disable-next-line complexity -- okay for this function, lots of things to check
59
61
  export function validateXChainClaim(tx: Record<string, unknown>): void {
60
62
  validateBaseTransaction(tx)
61
63
 
62
- if (tx.XChainBridge == null) {
63
- throw new ValidationError('XChainClaim: missing field XChainBridge')
64
- }
64
+ validateRequiredField(tx, 'XChainBridge', isXChainBridge)
65
65
 
66
- if (!isXChainBridge(tx.XChainBridge)) {
67
- throw new ValidationError('XChainClaim: invalid field XChainBridge')
68
- }
66
+ validateRequiredField(
67
+ tx,
68
+ 'XChainClaimID',
69
+ (inp) => isNumber(inp) || isString(inp),
70
+ )
69
71
 
70
- if (tx.XChainClaimID == null) {
71
- throw new ValidationError('XChainClaim: missing field XChainClaimID')
72
- }
72
+ validateRequiredField(tx, 'Destination', isString)
73
73
 
74
- if (
75
- typeof tx.XChainClaimID !== 'number' &&
76
- typeof tx.XChainClaimID !== 'string'
77
- ) {
78
- throw new ValidationError('XChainClaim: invalid field XChainClaimID')
79
- }
74
+ validateOptionalField(tx, 'DestinationTag', isNumber)
80
75
 
81
- if (tx.Destination == null) {
82
- throw new ValidationError('XChainClaim: missing field Destination')
83
- }
84
-
85
- if (typeof tx.Destination !== 'string') {
86
- throw new ValidationError('XChainClaim: invalid field Destination')
87
- }
88
-
89
- if (
90
- tx.DestinationTag !== undefined &&
91
- typeof tx.DestinationTag !== 'number'
92
- ) {
93
- throw new ValidationError('XChainClaim: invalid field DestinationTag')
94
- }
95
-
96
- if (tx.Amount == null) {
97
- throw new ValidationError('XChainClaim: missing field Amount')
98
- }
99
-
100
- if (!isAmount(tx.Amount)) {
101
- throw new ValidationError('XChainClaim: invalid field Amount')
102
- }
76
+ validateRequiredField(tx, 'Amount', isAmount)
103
77
  }
@@ -1,11 +1,14 @@
1
- import { ValidationError } from '../../errors'
2
1
  import { Amount, XChainBridge } from '../common'
3
2
 
4
3
  import {
5
4
  BaseTransaction,
6
5
  isAmount,
6
+ isNumber,
7
+ isString,
7
8
  isXChainBridge,
8
9
  validateBaseTransaction,
10
+ validateOptionalField,
11
+ validateRequiredField,
9
12
  } from './common'
10
13
 
11
14
  /**
@@ -49,47 +52,23 @@ export interface XChainCommit extends BaseTransaction {
49
52
  }
50
53
 
51
54
  /**
52
- * Verify the form and type of a XChainCommit at runtime.
55
+ * Verify the form and type of an XChainCommit at runtime.
53
56
  *
54
- * @param tx - A XChainCommit Transaction.
57
+ * @param tx - An XChainCommit Transaction.
55
58
  * @throws When the XChainCommit is malformed.
56
59
  */
57
60
  export function validateXChainCommit(tx: Record<string, unknown>): void {
58
61
  validateBaseTransaction(tx)
59
62
 
60
- if (tx.XChainBridge == null) {
61
- throw new ValidationError('XChainCommit: missing field XChainBridge')
62
- }
63
+ validateRequiredField(tx, 'XChainBridge', isXChainBridge)
63
64
 
64
- if (!isXChainBridge(tx.XChainBridge)) {
65
- throw new ValidationError('XChainCommit: invalid field XChainBridge')
66
- }
65
+ validateRequiredField(
66
+ tx,
67
+ 'XChainClaimID',
68
+ (inp) => isNumber(inp) || isString(inp),
69
+ )
67
70
 
68
- if (tx.XChainClaimID == null) {
69
- throw new ValidationError('XChainCommit: missing field XChainClaimID')
70
- }
71
+ validateOptionalField(tx, 'OtherChainDestination', isString)
71
72
 
72
- if (
73
- typeof tx.XChainClaimID !== 'number' &&
74
- typeof tx.XChainClaimID !== 'string'
75
- ) {
76
- throw new ValidationError('XChainCommit: invalid field XChainClaimID')
77
- }
78
-
79
- if (
80
- tx.OtherChainDestination !== undefined &&
81
- typeof tx.OtherChainDestination !== 'string'
82
- ) {
83
- throw new ValidationError(
84
- 'XChainCommit: invalid field OtherChainDestination',
85
- )
86
- }
87
-
88
- if (tx.Amount == null) {
89
- throw new ValidationError('XChainCommit: missing field Amount')
90
- }
91
-
92
- if (!isAmount(tx.Amount)) {
93
- throw new ValidationError('XChainCommit: invalid field Amount')
94
- }
73
+ validateRequiredField(tx, 'Amount', isAmount)
95
74
  }
@@ -1,4 +1,3 @@
1
- import { ValidationError } from '../../errors'
2
1
  import { Amount, XChainBridge } from '../common'
3
2
 
4
3
  import {
@@ -6,6 +5,8 @@ import {
6
5
  isAmount,
7
6
  isXChainBridge,
8
7
  validateBaseTransaction,
8
+ validateOptionalField,
9
+ validateRequiredField,
9
10
  } from './common'
10
11
 
11
12
  /**
@@ -39,40 +40,17 @@ export interface XChainCreateBridge extends BaseTransaction {
39
40
  }
40
41
 
41
42
  /**
42
- * Verify the form and type of a XChainCreateBridge at runtime.
43
+ * Verify the form and type of an XChainCreateBridge at runtime.
43
44
  *
44
- * @param tx - A XChainCreateBridge Transaction.
45
+ * @param tx - An XChainCreateBridge Transaction.
45
46
  * @throws When the XChainCreateBridge is malformed.
46
47
  */
47
48
  export function validateXChainCreateBridge(tx: Record<string, unknown>): void {
48
49
  validateBaseTransaction(tx)
49
50
 
50
- if (tx.XChainBridge == null) {
51
- throw new ValidationError('XChainCreateBridge: missing field XChainBridge')
52
- }
51
+ validateRequiredField(tx, 'XChainBridge', isXChainBridge)
53
52
 
54
- if (!isXChainBridge(tx.XChainBridge)) {
55
- throw new ValidationError('XChainCreateBridge: invalid field XChainBridge')
56
- }
53
+ validateRequiredField(tx, 'SignatureReward', isAmount)
57
54
 
58
- if (tx.SignatureReward == null) {
59
- throw new ValidationError(
60
- 'XChainCreateBridge: missing field SignatureReward',
61
- )
62
- }
63
-
64
- if (!isAmount(tx.SignatureReward)) {
65
- throw new ValidationError(
66
- 'XChainCreateBridge: invalid field SignatureReward',
67
- )
68
- }
69
-
70
- if (
71
- tx.MinAccountCreateAmount !== undefined &&
72
- !isAmount(tx.MinAccountCreateAmount)
73
- ) {
74
- throw new ValidationError(
75
- 'XChainCreateBridge: invalid field MinAccountCreateAmount',
76
- )
77
- }
55
+ validateOptionalField(tx, 'MinAccountCreateAmount', isAmount)
78
56
  }
@@ -1,11 +1,12 @@
1
- import { ValidationError } from '../../errors'
2
1
  import { Amount, XChainBridge } from '../common'
3
2
 
4
3
  import {
5
4
  BaseTransaction,
6
5
  isAmount,
6
+ isString,
7
7
  isXChainBridge,
8
8
  validateBaseTransaction,
9
+ validateRequiredField,
9
10
  } from './common'
10
11
 
11
12
  /**
@@ -36,43 +37,17 @@ export interface XChainCreateClaimID extends BaseTransaction {
36
37
  }
37
38
 
38
39
  /**
39
- * Verify the form and type of a XChainCreateClaimID at runtime.
40
+ * Verify the form and type of an XChainCreateClaimID at runtime.
40
41
  *
41
- * @param tx - A XChainCreateClaimID Transaction.
42
+ * @param tx - An XChainCreateClaimID Transaction.
42
43
  * @throws When the XChainCreateClaimID is malformed.
43
44
  */
44
45
  export function validateXChainCreateClaimID(tx: Record<string, unknown>): void {
45
46
  validateBaseTransaction(tx)
46
47
 
47
- if (tx.XChainBridge == null) {
48
- throw new ValidationError('XChainCreateClaimID: missing field XChainBridge')
49
- }
48
+ validateRequiredField(tx, 'XChainBridge', isXChainBridge)
50
49
 
51
- if (!isXChainBridge(tx.XChainBridge)) {
52
- throw new ValidationError('XChainCreateClaimID: invalid field XChainBridge')
53
- }
50
+ validateRequiredField(tx, 'SignatureReward', isAmount)
54
51
 
55
- if (tx.SignatureReward == null) {
56
- throw new ValidationError(
57
- 'XChainCreateClaimID: missing field SignatureReward',
58
- )
59
- }
60
-
61
- if (!isAmount(tx.SignatureReward)) {
62
- throw new ValidationError(
63
- 'XChainCreateClaimID: invalid field SignatureReward',
64
- )
65
- }
66
-
67
- if (tx.OtherChainSource == null) {
68
- throw new ValidationError(
69
- 'XChainCreateClaimID: missing field OtherChainSource',
70
- )
71
- }
72
-
73
- if (typeof tx.OtherChainSource !== 'string') {
74
- throw new ValidationError(
75
- 'XChainCreateClaimID: invalid field OtherChainSource',
76
- )
77
- }
52
+ validateRequiredField(tx, 'OtherChainSource', isString)
78
53
  }
@@ -1,4 +1,3 @@
1
- import { ValidationError } from '../../errors'
2
1
  import { Amount, XChainBridge } from '../common'
3
2
 
4
3
  import {
@@ -7,6 +6,8 @@ import {
7
6
  isAmount,
8
7
  isXChainBridge,
9
8
  validateBaseTransaction,
9
+ validateOptionalField,
10
+ validateRequiredField,
10
11
  } from './common'
11
12
 
12
13
  /**
@@ -60,34 +61,17 @@ export interface XChainModifyBridge extends BaseTransaction {
60
61
  }
61
62
 
62
63
  /**
63
- * Verify the form and type of a XChainModifyBridge at runtime.
64
+ * Verify the form and type of an XChainModifyBridge at runtime.
64
65
  *
65
- * @param tx - A XChainModifyBridge Transaction.
66
+ * @param tx - An XChainModifyBridge Transaction.
66
67
  * @throws When the XChainModifyBridge is malformed.
67
68
  */
68
69
  export function validateXChainModifyBridge(tx: Record<string, unknown>): void {
69
70
  validateBaseTransaction(tx)
70
71
 
71
- if (tx.XChainBridge == null) {
72
- throw new ValidationError('XChainModifyBridge: missing field XChainBridge')
73
- }
72
+ validateRequiredField(tx, 'XChainBridge', isXChainBridge)
74
73
 
75
- if (!isXChainBridge(tx.XChainBridge)) {
76
- throw new ValidationError('XChainModifyBridge: invalid field XChainBridge')
77
- }
74
+ validateOptionalField(tx, 'SignatureReward', isAmount)
78
75
 
79
- if (tx.SignatureReward !== undefined && !isAmount(tx.SignatureReward)) {
80
- throw new ValidationError(
81
- 'XChainModifyBridge: invalid field SignatureReward',
82
- )
83
- }
84
-
85
- if (
86
- tx.MinAccountCreateAmount !== undefined &&
87
- !isAmount(tx.MinAccountCreateAmount)
88
- ) {
89
- throw new ValidationError(
90
- 'XChainModifyBridge: invalid field MinAccountCreateAmount',
91
- )
92
- }
76
+ validateOptionalField(tx, 'MinAccountCreateAmount', isAmount)
93
77
  }
@@ -1,5 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validateAccountSet */
2
-
3
1
  import { isValidClassicAddress } from 'ripple-address-codec'
4
2
 
5
3
  import { ValidationError } from '../../errors'
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validateCheckCash */
2
1
  import { ValidationError } from '../../errors'
3
2
  import { Amount } from '../common'
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity -- Necessary for validateCheckCreate */
2
1
  import { ValidationError } from '../../errors'
3
2
  import { Amount } from '../common'
4
3