xrpl 4.0.0 → 4.1.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 (274) hide show
  1. package/README.md +1 -1
  2. package/build/xrpl-latest.js +2789 -731
  3. package/build/xrpl-latest.js.map +1 -1
  4. package/dist/npm/client/partialPayment.d.ts +2 -2
  5. package/dist/npm/client/partialPayment.d.ts.map +1 -1
  6. package/dist/npm/client/partialPayment.js +11 -3
  7. package/dist/npm/client/partialPayment.js.map +1 -1
  8. package/dist/npm/models/common/index.d.ts +10 -0
  9. package/dist/npm/models/common/index.d.ts.map +1 -1
  10. package/dist/npm/models/index.d.ts +1 -1
  11. package/dist/npm/models/index.d.ts.map +1 -1
  12. package/dist/npm/models/index.js +2 -1
  13. package/dist/npm/models/index.js.map +1 -1
  14. package/dist/npm/models/ledger/Credential.d.ts +17 -0
  15. package/dist/npm/models/ledger/Credential.d.ts.map +1 -0
  16. package/dist/npm/models/ledger/Credential.js +3 -0
  17. package/dist/npm/models/ledger/Credential.js.map +1 -0
  18. package/dist/npm/models/ledger/DepositPreauth.d.ts +3 -1
  19. package/dist/npm/models/ledger/DepositPreauth.d.ts.map +1 -1
  20. package/dist/npm/models/ledger/Ledger.d.ts +1 -0
  21. package/dist/npm/models/ledger/Ledger.d.ts.map +1 -1
  22. package/dist/npm/models/ledger/LedgerEntry.d.ts +3 -2
  23. package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
  24. package/dist/npm/models/ledger/MPToken.d.ts +10 -0
  25. package/dist/npm/models/ledger/MPToken.d.ts.map +1 -0
  26. package/dist/npm/models/ledger/MPToken.js +3 -0
  27. package/dist/npm/models/ledger/MPToken.js.map +1 -0
  28. package/dist/npm/models/ledger/MPTokenIssuance.d.ts +13 -0
  29. package/dist/npm/models/ledger/MPTokenIssuance.d.ts.map +1 -0
  30. package/dist/npm/models/ledger/MPTokenIssuance.js +3 -0
  31. package/dist/npm/models/ledger/MPTokenIssuance.js.map +1 -0
  32. package/dist/npm/models/ledger/index.d.ts +4 -1
  33. package/dist/npm/models/ledger/index.d.ts.map +1 -1
  34. package/dist/npm/models/ledger/index.js.map +1 -1
  35. package/dist/npm/models/methods/depositAuthorized.d.ts +2 -0
  36. package/dist/npm/models/methods/depositAuthorized.d.ts.map +1 -1
  37. package/dist/npm/models/methods/index.d.ts +2 -2
  38. package/dist/npm/models/methods/index.d.ts.map +1 -1
  39. package/dist/npm/models/methods/ledgerEntry.d.ts +12 -0
  40. package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
  41. package/dist/npm/models/methods/subscribe.d.ts +7 -3
  42. package/dist/npm/models/methods/subscribe.d.ts.map +1 -1
  43. package/dist/npm/models/transactions/CredentialAccept.d.ts +9 -0
  44. package/dist/npm/models/transactions/CredentialAccept.d.ts.map +1 -0
  45. package/dist/npm/models/transactions/CredentialAccept.js +12 -0
  46. package/dist/npm/models/transactions/CredentialAccept.js.map +1 -0
  47. package/dist/npm/models/transactions/CredentialCreate.d.ts +11 -0
  48. package/dist/npm/models/transactions/CredentialCreate.d.ts.map +1 -0
  49. package/dist/npm/models/transactions/CredentialCreate.js +34 -0
  50. package/dist/npm/models/transactions/CredentialCreate.js.map +1 -0
  51. package/dist/npm/models/transactions/CredentialDelete.d.ts +10 -0
  52. package/dist/npm/models/transactions/CredentialDelete.d.ts.map +1 -0
  53. package/dist/npm/models/transactions/CredentialDelete.js +17 -0
  54. package/dist/npm/models/transactions/CredentialDelete.js.map +1 -0
  55. package/dist/npm/models/transactions/MPTokenAuthorize.d.ts +15 -0
  56. package/dist/npm/models/transactions/MPTokenAuthorize.d.ts.map +1 -0
  57. package/dist/npm/models/transactions/MPTokenAuthorize.js +15 -0
  58. package/dist/npm/models/transactions/MPTokenAuthorize.js.map +1 -0
  59. package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts +31 -0
  60. package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -0
  61. package/dist/npm/models/transactions/MPTokenIssuanceCreate.js +54 -0
  62. package/dist/npm/models/transactions/MPTokenIssuanceCreate.js.map +1 -0
  63. package/dist/npm/models/transactions/MPTokenIssuanceDestroy.d.ts +7 -0
  64. package/dist/npm/models/transactions/MPTokenIssuanceDestroy.d.ts.map +1 -0
  65. package/dist/npm/models/transactions/MPTokenIssuanceDestroy.js +10 -0
  66. package/dist/npm/models/transactions/MPTokenIssuanceDestroy.js.map +1 -0
  67. package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts +17 -0
  68. package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -0
  69. package/dist/npm/models/transactions/MPTokenIssuanceSet.js +29 -0
  70. package/dist/npm/models/transactions/MPTokenIssuanceSet.js.map +1 -0
  71. package/dist/npm/models/transactions/accountDelete.d.ts +1 -0
  72. package/dist/npm/models/transactions/accountDelete.d.ts.map +1 -1
  73. package/dist/npm/models/transactions/accountDelete.js +1 -0
  74. package/dist/npm/models/transactions/accountDelete.js.map +1 -1
  75. package/dist/npm/models/transactions/clawback.d.ts +3 -2
  76. package/dist/npm/models/transactions/clawback.d.ts.map +1 -1
  77. package/dist/npm/models/transactions/clawback.js +11 -1
  78. package/dist/npm/models/transactions/clawback.js.map +1 -1
  79. package/dist/npm/models/transactions/common.d.ts +4 -1
  80. package/dist/npm/models/transactions/common.d.ts.map +1 -1
  81. package/dist/npm/models/transactions/common.js +79 -4
  82. package/dist/npm/models/transactions/common.js.map +1 -1
  83. package/dist/npm/models/transactions/depositPreauth.d.ts +3 -0
  84. package/dist/npm/models/transactions/depositPreauth.d.ts.map +1 -1
  85. package/dist/npm/models/transactions/depositPreauth.js +20 -7
  86. package/dist/npm/models/transactions/depositPreauth.js.map +1 -1
  87. package/dist/npm/models/transactions/escrowFinish.d.ts +1 -0
  88. package/dist/npm/models/transactions/escrowFinish.d.ts.map +1 -1
  89. package/dist/npm/models/transactions/escrowFinish.js +1 -0
  90. package/dist/npm/models/transactions/escrowFinish.js.map +1 -1
  91. package/dist/npm/models/transactions/index.d.ts +8 -1
  92. package/dist/npm/models/transactions/index.d.ts.map +1 -1
  93. package/dist/npm/models/transactions/index.js +9 -1
  94. package/dist/npm/models/transactions/index.js.map +1 -1
  95. package/dist/npm/models/transactions/metadata.d.ts +5 -4
  96. package/dist/npm/models/transactions/metadata.d.ts.map +1 -1
  97. package/dist/npm/models/transactions/metadata.js.map +1 -1
  98. package/dist/npm/models/transactions/payment.d.ts +7 -6
  99. package/dist/npm/models/transactions/payment.d.ts.map +1 -1
  100. package/dist/npm/models/transactions/payment.js +1 -0
  101. package/dist/npm/models/transactions/payment.js.map +1 -1
  102. package/dist/npm/models/transactions/paymentChannelClaim.d.ts +1 -0
  103. package/dist/npm/models/transactions/paymentChannelClaim.d.ts.map +1 -1
  104. package/dist/npm/models/transactions/paymentChannelClaim.js +1 -0
  105. package/dist/npm/models/transactions/paymentChannelClaim.js.map +1 -1
  106. package/dist/npm/models/transactions/transaction.d.ts +8 -1
  107. package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
  108. package/dist/npm/models/transactions/transaction.js +28 -0
  109. package/dist/npm/models/transactions/transaction.js.map +1 -1
  110. package/dist/npm/models/utils/flags.d.ts +1 -0
  111. package/dist/npm/models/utils/flags.d.ts.map +1 -1
  112. package/dist/npm/models/utils/flags.js +23 -1
  113. package/dist/npm/models/utils/flags.js.map +1 -1
  114. package/dist/npm/models/utils/index.d.ts +1 -0
  115. package/dist/npm/models/utils/index.d.ts.map +1 -1
  116. package/dist/npm/models/utils/index.js +2 -1
  117. package/dist/npm/models/utils/index.js.map +1 -1
  118. package/dist/npm/snippets/src/paths.js +5 -9
  119. package/dist/npm/snippets/src/paths.js.map +1 -1
  120. package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
  121. package/dist/npm/src/client/partialPayment.d.ts +2 -2
  122. package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
  123. package/dist/npm/src/client/partialPayment.js +11 -3
  124. package/dist/npm/src/client/partialPayment.js.map +1 -1
  125. package/dist/npm/src/models/common/index.d.ts +10 -0
  126. package/dist/npm/src/models/common/index.d.ts.map +1 -1
  127. package/dist/npm/src/models/index.d.ts +1 -1
  128. package/dist/npm/src/models/index.d.ts.map +1 -1
  129. package/dist/npm/src/models/index.js +2 -1
  130. package/dist/npm/src/models/index.js.map +1 -1
  131. package/dist/npm/src/models/ledger/Credential.d.ts +17 -0
  132. package/dist/npm/src/models/ledger/Credential.d.ts.map +1 -0
  133. package/dist/npm/src/models/ledger/Credential.js +3 -0
  134. package/dist/npm/src/models/ledger/Credential.js.map +1 -0
  135. package/dist/npm/src/models/ledger/DepositPreauth.d.ts +3 -1
  136. package/dist/npm/src/models/ledger/DepositPreauth.d.ts.map +1 -1
  137. package/dist/npm/src/models/ledger/Ledger.d.ts +1 -0
  138. package/dist/npm/src/models/ledger/Ledger.d.ts.map +1 -1
  139. package/dist/npm/src/models/ledger/LedgerEntry.d.ts +3 -2
  140. package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
  141. package/dist/npm/src/models/ledger/MPToken.d.ts +10 -0
  142. package/dist/npm/src/models/ledger/MPToken.d.ts.map +1 -0
  143. package/dist/npm/src/models/ledger/MPToken.js +3 -0
  144. package/dist/npm/src/models/ledger/MPToken.js.map +1 -0
  145. package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts +13 -0
  146. package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts.map +1 -0
  147. package/dist/npm/src/models/ledger/MPTokenIssuance.js +3 -0
  148. package/dist/npm/src/models/ledger/MPTokenIssuance.js.map +1 -0
  149. package/dist/npm/src/models/ledger/index.d.ts +4 -1
  150. package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
  151. package/dist/npm/src/models/ledger/index.js.map +1 -1
  152. package/dist/npm/src/models/methods/depositAuthorized.d.ts +2 -0
  153. package/dist/npm/src/models/methods/depositAuthorized.d.ts.map +1 -1
  154. package/dist/npm/src/models/methods/index.d.ts +2 -2
  155. package/dist/npm/src/models/methods/index.d.ts.map +1 -1
  156. package/dist/npm/src/models/methods/ledgerEntry.d.ts +12 -0
  157. package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
  158. package/dist/npm/src/models/methods/subscribe.d.ts +7 -3
  159. package/dist/npm/src/models/methods/subscribe.d.ts.map +1 -1
  160. package/dist/npm/src/models/transactions/CredentialAccept.d.ts +9 -0
  161. package/dist/npm/src/models/transactions/CredentialAccept.d.ts.map +1 -0
  162. package/dist/npm/src/models/transactions/CredentialAccept.js +12 -0
  163. package/dist/npm/src/models/transactions/CredentialAccept.js.map +1 -0
  164. package/dist/npm/src/models/transactions/CredentialCreate.d.ts +11 -0
  165. package/dist/npm/src/models/transactions/CredentialCreate.d.ts.map +1 -0
  166. package/dist/npm/src/models/transactions/CredentialCreate.js +34 -0
  167. package/dist/npm/src/models/transactions/CredentialCreate.js.map +1 -0
  168. package/dist/npm/src/models/transactions/CredentialDelete.d.ts +10 -0
  169. package/dist/npm/src/models/transactions/CredentialDelete.d.ts.map +1 -0
  170. package/dist/npm/src/models/transactions/CredentialDelete.js +17 -0
  171. package/dist/npm/src/models/transactions/CredentialDelete.js.map +1 -0
  172. package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts +15 -0
  173. package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts.map +1 -0
  174. package/dist/npm/src/models/transactions/MPTokenAuthorize.js +15 -0
  175. package/dist/npm/src/models/transactions/MPTokenAuthorize.js.map +1 -0
  176. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts +31 -0
  177. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -0
  178. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js +54 -0
  179. package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js.map +1 -0
  180. package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.d.ts +7 -0
  181. package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.d.ts.map +1 -0
  182. package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.js +10 -0
  183. package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.js.map +1 -0
  184. package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts +17 -0
  185. package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -0
  186. package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js +29 -0
  187. package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js.map +1 -0
  188. package/dist/npm/src/models/transactions/accountDelete.d.ts +1 -0
  189. package/dist/npm/src/models/transactions/accountDelete.d.ts.map +1 -1
  190. package/dist/npm/src/models/transactions/accountDelete.js +1 -0
  191. package/dist/npm/src/models/transactions/accountDelete.js.map +1 -1
  192. package/dist/npm/src/models/transactions/clawback.d.ts +3 -2
  193. package/dist/npm/src/models/transactions/clawback.d.ts.map +1 -1
  194. package/dist/npm/src/models/transactions/clawback.js +11 -1
  195. package/dist/npm/src/models/transactions/clawback.js.map +1 -1
  196. package/dist/npm/src/models/transactions/common.d.ts +4 -1
  197. package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
  198. package/dist/npm/src/models/transactions/common.js +79 -4
  199. package/dist/npm/src/models/transactions/common.js.map +1 -1
  200. package/dist/npm/src/models/transactions/depositPreauth.d.ts +3 -0
  201. package/dist/npm/src/models/transactions/depositPreauth.d.ts.map +1 -1
  202. package/dist/npm/src/models/transactions/depositPreauth.js +20 -7
  203. package/dist/npm/src/models/transactions/depositPreauth.js.map +1 -1
  204. package/dist/npm/src/models/transactions/escrowFinish.d.ts +1 -0
  205. package/dist/npm/src/models/transactions/escrowFinish.d.ts.map +1 -1
  206. package/dist/npm/src/models/transactions/escrowFinish.js +1 -0
  207. package/dist/npm/src/models/transactions/escrowFinish.js.map +1 -1
  208. package/dist/npm/src/models/transactions/index.d.ts +8 -1
  209. package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
  210. package/dist/npm/src/models/transactions/index.js +9 -1
  211. package/dist/npm/src/models/transactions/index.js.map +1 -1
  212. package/dist/npm/src/models/transactions/metadata.d.ts +5 -4
  213. package/dist/npm/src/models/transactions/metadata.d.ts.map +1 -1
  214. package/dist/npm/src/models/transactions/metadata.js.map +1 -1
  215. package/dist/npm/src/models/transactions/payment.d.ts +7 -6
  216. package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
  217. package/dist/npm/src/models/transactions/payment.js +1 -0
  218. package/dist/npm/src/models/transactions/payment.js.map +1 -1
  219. package/dist/npm/src/models/transactions/paymentChannelClaim.d.ts +1 -0
  220. package/dist/npm/src/models/transactions/paymentChannelClaim.d.ts.map +1 -1
  221. package/dist/npm/src/models/transactions/paymentChannelClaim.js +1 -0
  222. package/dist/npm/src/models/transactions/paymentChannelClaim.js.map +1 -1
  223. package/dist/npm/src/models/transactions/transaction.d.ts +8 -1
  224. package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
  225. package/dist/npm/src/models/transactions/transaction.js +28 -0
  226. package/dist/npm/src/models/transactions/transaction.js.map +1 -1
  227. package/dist/npm/src/models/utils/flags.d.ts +1 -0
  228. package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
  229. package/dist/npm/src/models/utils/flags.js +23 -1
  230. package/dist/npm/src/models/utils/flags.js.map +1 -1
  231. package/dist/npm/src/models/utils/index.d.ts +1 -0
  232. package/dist/npm/src/models/utils/index.d.ts.map +1 -1
  233. package/dist/npm/src/models/utils/index.js +2 -1
  234. package/dist/npm/src/models/utils/index.js.map +1 -1
  235. package/package.json +5 -5
  236. package/src/client/partialPayment.ts +37 -7
  237. package/src/models/common/index.ts +15 -0
  238. package/src/models/index.ts +1 -0
  239. package/src/models/ledger/Credential.ts +47 -0
  240. package/src/models/ledger/DepositPreauth.ts +6 -2
  241. package/src/models/ledger/Ledger.ts +5 -0
  242. package/src/models/ledger/LedgerEntry.ts +5 -0
  243. package/src/models/ledger/MPToken.ts +11 -0
  244. package/src/models/ledger/MPTokenIssuance.ts +13 -0
  245. package/src/models/ledger/index.ts +6 -0
  246. package/src/models/methods/depositAuthorized.ts +10 -0
  247. package/src/models/methods/index.ts +2 -0
  248. package/src/models/methods/ledgerEntry.ts +45 -1
  249. package/src/models/methods/subscribe.ts +34 -3
  250. package/src/models/transactions/CredentialAccept.ts +44 -0
  251. package/src/models/transactions/CredentialCreate.ts +81 -0
  252. package/src/models/transactions/CredentialDelete.ts +55 -0
  253. package/src/models/transactions/MPTokenAuthorize.ts +67 -0
  254. package/src/models/transactions/MPTokenIssuanceCreate.ts +179 -0
  255. package/src/models/transactions/MPTokenIssuanceDestroy.ts +34 -0
  256. package/src/models/transactions/MPTokenIssuanceSet.ts +86 -0
  257. package/src/models/transactions/accountDelete.ts +14 -0
  258. package/src/models/transactions/clawback.ts +27 -6
  259. package/src/models/transactions/common.ts +139 -1
  260. package/src/models/transactions/depositPreauth.ts +51 -15
  261. package/src/models/transactions/escrowFinish.ts +12 -0
  262. package/src/models/transactions/index.ts +20 -1
  263. package/src/models/transactions/metadata.ts +9 -3
  264. package/src/models/transactions/payment.ts +19 -6
  265. package/src/models/transactions/paymentChannelClaim.ts +18 -1
  266. package/src/models/transactions/transaction.ts +51 -0
  267. package/src/models/utils/flags.ts +33 -1
  268. package/src/models/utils/index.ts +1 -0
  269. package/build/xrpl-latest-min.js +0 -3
  270. package/build/xrpl-latest-min.js.map +0 -1
  271. package/dist/npm/snippets/src/bridgeTransfer.d.ts +0 -2
  272. package/dist/npm/snippets/src/bridgeTransfer.d.ts.map +0 -1
  273. package/dist/npm/snippets/src/bridgeTransfer.js +0 -126
  274. package/dist/npm/snippets/src/bridgeTransfer.js.map +0 -1
@@ -4,22 +4,35 @@ import { decode } from 'ripple-binary-codec'
4
4
  import type {
5
5
  TransactionEntryResponse,
6
6
  TransactionStream,
7
+ TransactionV1Stream,
7
8
  TxResponse,
8
9
  } from '..'
9
- import type { Amount, APIVersion, DEFAULT_API_VERSION } from '../models/common'
10
+ import type {
11
+ Amount,
12
+ IssuedCurrency,
13
+ APIVersion,
14
+ DEFAULT_API_VERSION,
15
+ MPTAmount,
16
+ } from '../models/common'
10
17
  import type {
11
18
  AccountTxTransaction,
12
19
  RequestResponseMap,
13
20
  } from '../models/methods'
14
21
  import { AccountTxVersionResponseMap } from '../models/methods/accountTx'
15
22
  import { BaseRequest, BaseResponse } from '../models/methods/baseMethod'
16
- import { PaymentFlags, Transaction } from '../models/transactions'
23
+ import { PaymentFlags, Transaction, isMPTAmount } from '../models/transactions'
17
24
  import type { TransactionMetadata } from '../models/transactions/metadata'
18
25
  import { isFlagEnabled } from '../models/utils'
19
26
 
20
27
  const WARN_PARTIAL_PAYMENT_CODE = 2001
21
28
 
22
- function amountsEqual(amt1: Amount, amt2: Amount): boolean {
29
+ /* eslint-disable complexity -- check different token types */
30
+ /* eslint-disable @typescript-eslint/consistent-type-assertions -- known currency type */
31
+ function amountsEqual(
32
+ amt1: Amount | MPTAmount,
33
+ amt2: Amount | MPTAmount,
34
+ ): boolean {
35
+ // Compare XRP
23
36
  if (typeof amt1 === 'string' && typeof amt2 === 'string') {
24
37
  return amt1 === amt2
25
38
  }
@@ -28,15 +41,32 @@ function amountsEqual(amt1: Amount, amt2: Amount): boolean {
28
41
  return false
29
42
  }
30
43
 
44
+ // Compare MPTs
45
+ if (isMPTAmount(amt1) && isMPTAmount(amt2)) {
46
+ const aValue = new BigNumber(amt1.value)
47
+ const bValue = new BigNumber(amt2.value)
48
+
49
+ return (
50
+ amt1.mpt_issuance_id === amt2.mpt_issuance_id && aValue.isEqualTo(bValue)
51
+ )
52
+ }
53
+
54
+ if (isMPTAmount(amt1) || isMPTAmount(amt2)) {
55
+ return false
56
+ }
57
+
58
+ // Compare issued currency (IOU)
31
59
  const aValue = new BigNumber(amt1.value)
32
60
  const bValue = new BigNumber(amt2.value)
33
61
 
34
62
  return (
35
- amt1.currency === amt2.currency &&
36
- amt1.issuer === amt2.issuer &&
63
+ (amt1 as IssuedCurrency).currency === (amt2 as IssuedCurrency).currency &&
64
+ (amt1 as IssuedCurrency).issuer === (amt2 as IssuedCurrency).issuer &&
37
65
  aValue.isEqualTo(bValue)
38
66
  )
39
67
  }
68
+ /* eslint-enable complexity */
69
+ /* eslint-enable @typescript-eslint/consistent-type-assertions */
40
70
 
41
71
  function isPartialPayment(
42
72
  tx?: Transaction,
@@ -159,10 +189,10 @@ export function handlePartialPayment<
159
189
  * @param log - The method used for logging by the connection (to report the partial payment).
160
190
  */
161
191
  export function handleStreamPartialPayment(
162
- stream: TransactionStream,
192
+ stream: TransactionStream | TransactionV1Stream,
163
193
  log: (id: string, message: string) => void,
164
194
  ): void {
165
- if (isPartialPayment(stream.transaction, stream.meta)) {
195
+ if (isPartialPayment(stream.tx_json ?? stream.transaction, stream.meta)) {
166
196
  const warnings = stream.warnings ?? []
167
197
 
168
198
  const warning = {
@@ -20,6 +20,11 @@ export interface IssuedCurrencyAmount extends IssuedCurrency {
20
20
  value: string
21
21
  }
22
22
 
23
+ export interface MPTAmount {
24
+ mpt_issuance_id: string
25
+ value: string
26
+ }
27
+
23
28
  export type Amount = IssuedCurrencyAmount | string
24
29
 
25
30
  export interface Balance {
@@ -157,6 +162,16 @@ export interface AuthAccount {
157
162
  }
158
163
  }
159
164
 
165
+ export interface AuthorizeCredential {
166
+ Credential: {
167
+ /** The issuer of the credential. */
168
+ Issuer: string
169
+
170
+ /** A hex-encoded value to identify the type of credential from the issuer. */
171
+ CredentialType: string
172
+ }
173
+ }
174
+
160
175
  export interface XChainBridge {
161
176
  LockingChainDoor: string
162
177
  LockingChainIssue: Currency
@@ -10,6 +10,7 @@ export * as LedgerEntry from './ledger'
10
10
  export {
11
11
  setTransactionFlagsToNumber,
12
12
  parseAccountRootFlags,
13
+ parseTransactionFlags,
13
14
  } from './utils/flags'
14
15
  export * from './methods'
15
16
  export * from './transactions'
@@ -0,0 +1,47 @@
1
+ import { GlobalFlags } from '../transactions/common'
2
+
3
+ import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
4
+
5
+ export interface CredentialFlags extends GlobalFlags {
6
+ lsfAccepted?: boolean
7
+ }
8
+
9
+ /**
10
+ *
11
+ * A Credential object describes a credential, similar to a passport, which is an issuable identity verifier
12
+ * that can be used as a prerequisite for other transactions
13
+ *
14
+ * @category Ledger Entries
15
+ */
16
+ export default interface Credential extends BaseLedgerEntry, HasPreviousTxnID {
17
+ LedgerEntryType: 'Credential'
18
+ /**
19
+ * A bit-map of boolean flags
20
+ */
21
+ Flags: number | CredentialFlags
22
+
23
+ /** The account that the credential is for. */
24
+ Subject: string
25
+
26
+ /** The issuer of the credential. */
27
+ Issuer: string
28
+
29
+ /** A hex-encoded value to identify the type of credential from the issuer. */
30
+ CredentialType: string
31
+
32
+ /** A hint indicating which page of the subject's owner directory links to this object,
33
+ * in case the directory consists of multiple pages.
34
+ */
35
+ SubjectNode: string
36
+
37
+ /** A hint indicating which page of the issuer's owner directory links to this object,
38
+ * in case the directory consists of multiple pages.
39
+ */
40
+ IssuerNode: string
41
+
42
+ /** Credential expiration. */
43
+ Expiration?: number
44
+
45
+ /** Additional data about the credential (such as a link to the VC document). */
46
+ URI?: string
47
+ }
@@ -1,3 +1,5 @@
1
+ import { AuthorizeCredential } from '../common'
2
+
1
3
  import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
2
4
 
3
5
  /**
@@ -12,8 +14,6 @@ export default interface DepositPreauth
12
14
  LedgerEntryType: 'DepositPreauth'
13
15
  /** The account that granted the preauthorization. */
14
16
  Account: string
15
- /** The account that received the preauthorization. */
16
- Authorize: string
17
17
  /**
18
18
  * A bit-map of boolean flags. No flags are defined for DepositPreauth
19
19
  * objects, so this value is always 0.
@@ -24,4 +24,8 @@ export default interface DepositPreauth
24
24
  * object, in case the directory consists of multiple pages.
25
25
  */
26
26
  OwnerNode: string
27
+ /** The account that received the preauthorization. */
28
+ Authorize?: string
29
+ /** The credential(s) that received the preauthorization. */
30
+ AuthorizeCredentials?: AuthorizeCredential[]
27
31
  }
@@ -31,6 +31,11 @@ interface BaseLedger {
31
31
  * by which the close_time could be rounded.
32
32
  */
33
33
  close_time_resolution: number
34
+ /**
35
+ * The approximate time this ledger was closed, in date time string format.
36
+ * Always uses the UTC time zone.
37
+ */
38
+ close_time_iso: string
34
39
  /** Whether or not this ledger has been closed. */
35
40
  closed: boolean
36
41
  /**
@@ -3,6 +3,7 @@ import Amendments from './Amendments'
3
3
  import AMM from './AMM'
4
4
  import Bridge from './Bridge'
5
5
  import Check from './Check'
6
+ import Credential from './Credential'
6
7
  import DepositPreauth from './DepositPreauth'
7
8
  import DirectoryNode from './DirectoryNode'
8
9
  import Escrow from './Escrow'
@@ -24,6 +25,7 @@ type LedgerEntry =
24
25
  | AMM
25
26
  | Bridge
26
27
  | Check
28
+ | Credential
27
29
  | DepositPreauth
28
30
  | DirectoryNode
29
31
  | Escrow
@@ -45,12 +47,15 @@ type LedgerEntryFilter =
45
47
  | 'amm'
46
48
  | 'bridge'
47
49
  | 'check'
50
+ | 'credential'
48
51
  | 'deposit_preauth'
49
52
  | 'did'
50
53
  | 'directory'
51
54
  | 'escrow'
52
55
  | 'fee'
53
56
  | 'hashes'
57
+ | 'mpt_issuance'
58
+ | 'mptoken'
54
59
  | 'nft_offer'
55
60
  | 'nft_page'
56
61
  | 'offer'
@@ -0,0 +1,11 @@
1
+ import { MPTAmount } from '../common'
2
+
3
+ import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
4
+
5
+ export interface MPToken extends BaseLedgerEntry, HasPreviousTxnID {
6
+ LedgerEntryType: 'MPToken'
7
+ MPTokenIssuanceID: string
8
+ MPTAmount?: MPTAmount
9
+ Flags: number
10
+ OwnerNode?: string
11
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
2
+
3
+ export interface MPTokenIssuance extends BaseLedgerEntry, HasPreviousTxnID {
4
+ LedgerEntryType: 'MPTokenIssuance'
5
+ Flags: number
6
+ Issuer: string
7
+ AssetScale?: number
8
+ MaximumAmount?: string
9
+ OutstandingAmount: string
10
+ TransferFee?: number
11
+ MPTokenMetadata?: string
12
+ OwnerNode?: string
13
+ }
@@ -6,6 +6,7 @@ import Amendments, { Majority, AMENDMENTS_ID } from './Amendments'
6
6
  import AMM, { VoteSlot } from './AMM'
7
7
  import Bridge from './Bridge'
8
8
  import Check from './Check'
9
+ import Credential from './Credential'
9
10
  import DepositPreauth from './DepositPreauth'
10
11
  import DID from './DID'
11
12
  import DirectoryNode from './DirectoryNode'
@@ -18,6 +19,8 @@ import FeeSettings, {
18
19
  import { Ledger, LedgerV1 } from './Ledger'
19
20
  import { LedgerEntry, LedgerEntryFilter } from './LedgerEntry'
20
21
  import LedgerHashes from './LedgerHashes'
22
+ import { MPToken } from './MPToken'
23
+ import { MPTokenIssuance } from './MPTokenIssuance'
21
24
  import NegativeUNL, { NEGATIVE_UNL_ID } from './NegativeUNL'
22
25
  import { NFTokenOffer } from './NFTokenOffer'
23
26
  import { NFToken, NFTokenPage } from './NFTokenPage'
@@ -39,6 +42,7 @@ export {
39
42
  AMM,
40
43
  Bridge,
41
44
  Check,
45
+ Credential,
42
46
  DepositPreauth,
43
47
  DirectoryNode,
44
48
  DID,
@@ -55,6 +59,8 @@ export {
55
59
  Majority,
56
60
  NEGATIVE_UNL_ID,
57
61
  NegativeUNL,
62
+ MPTokenIssuance,
63
+ MPToken,
58
64
  NFTokenOffer,
59
65
  NFTokenPage,
60
66
  NFToken,
@@ -15,6 +15,12 @@ export interface DepositAuthorizedRequest
15
15
  source_account: string
16
16
  /** The recipient of a possible payment. */
17
17
  destination_account: string
18
+ /**
19
+ * The object IDs of Credential objects. If this field is included, then the
20
+ * credential will be taken into account when analyzing whether the sender can send
21
+ * funds to the destination.
22
+ */
23
+ credentials?: string[]
18
24
  }
19
25
 
20
26
  /**
@@ -52,5 +58,9 @@ export interface DepositAuthorizedResponse extends BaseResponse {
52
58
  source_account: string
53
59
  /** If true, the information comes from a validated ledger version. */
54
60
  validated?: boolean
61
+ /** The object IDs of `Credential` objects. If this field is included,
62
+ * then the credential will be taken into account when analyzing whether
63
+ * the sender can send funds to the destination. */
64
+ credentials?: string[]
55
65
  }
56
66
  }
@@ -168,6 +168,7 @@ import {
168
168
  SubscribeRequest,
169
169
  SubscribeResponse,
170
170
  TransactionStream,
171
+ TransactionV1Stream,
171
172
  ValidationStream,
172
173
  } from './subscribe'
173
174
  import {
@@ -583,6 +584,7 @@ export {
583
584
  LedgerStreamResponse,
584
585
  ValidationStream,
585
586
  TransactionStream,
587
+ TransactionV1Stream,
586
588
  PathFindStream,
587
589
  PeerStatusStream,
588
590
  OrderBookStream,
@@ -21,6 +21,22 @@ import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
21
21
  */
22
22
  export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
23
23
  command: 'ledger_entry'
24
+
25
+ /**
26
+ * Retrieve a MPTokenIssuance object from the ledger.
27
+ */
28
+ mpt_issuance?: string
29
+
30
+ /**
31
+ * Retrieve a MPToken object from the ledger.
32
+ */
33
+ mptoken?:
34
+ | {
35
+ mpt_issuance_id: string
36
+ account: string
37
+ }
38
+ | string
39
+
24
40
  /**
25
41
  * Retrieve an Automated Market Maker (AMM) object from the ledger.
26
42
  * This is similar to amm_info method, but the ledger_entry version returns only the ledger entry as stored.
@@ -35,7 +51,14 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
35
51
  issuer?: string
36
52
  }
37
53
  }
38
-
54
+ /**
55
+ * (Optional) If set to true and the queried object has been deleted,
56
+ * return its complete data prior to its deletion.
57
+ * If set to false or not provided and the queried object has been deleted,
58
+ * return objectNotFound (current behavior).
59
+ * This parameter is supported only by Clio servers
60
+ */
61
+ include_deleted?: boolean
39
62
  /**
40
63
  * If true, return the requested ledger object's contents as a hex string in
41
64
  * the XRP Ledger's binary format. Otherwise, return data in JSON format. The
@@ -60,6 +83,23 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
60
83
  /** The object ID of a Check object to retrieve. */
61
84
  check?: string
62
85
 
86
+ /* Specify the Credential to retrieve. If a string, must be the ledger entry ID of
87
+ * the entry, as hexadecimal. If an object, requires subject, issuer, and
88
+ * credential_type sub-fields.
89
+ */
90
+ credential?:
91
+ | {
92
+ /** The account that is the subject of the credential. */
93
+ subject: string
94
+
95
+ /** The account that issued the credential. */
96
+ issuer: string
97
+
98
+ /** The type of the credential, as issued. */
99
+ credentialType: string
100
+ }
101
+ | string
102
+
63
103
  /**
64
104
  * Specify a DepositPreauth object to retrieve. If a string, must be the
65
105
  * object ID of the DepositPreauth object, as hexadecimal. If an object,
@@ -204,5 +244,9 @@ export interface LedgerEntryResponse<T = LedgerEntry> extends BaseResponse {
204
244
  /** The binary representation of the ledger object, as hexadecimal. */
205
245
  node_binary?: string
206
246
  validated?: boolean
247
+ /**
248
+ * (Optional) Indicates the ledger index at which the object was deleted.
249
+ */
250
+ deleted_ledger_index?: number
207
251
  }
208
252
  }
@@ -4,6 +4,10 @@ import type {
4
4
  Path,
5
5
  StreamType,
6
6
  ResponseOnlyTxInfo,
7
+ APIVersion,
8
+ DEFAULT_API_VERSION,
9
+ RIPPLED_API_V1,
10
+ RIPPLED_API_V2,
7
11
  } from '../common'
8
12
  import { Offer } from '../ledger'
9
13
  import { OfferCreate, Transaction } from '../transactions'
@@ -262,9 +266,16 @@ export interface ValidationStream extends BaseStream {
262
266
  *
263
267
  * @category Streams
264
268
  */
265
- export interface TransactionStream extends BaseStream {
269
+ interface TransactionStreamBase<
270
+ Version extends APIVersion = typeof DEFAULT_API_VERSION,
271
+ > extends BaseStream {
266
272
  status: string
267
273
  type: 'transaction'
274
+ /**
275
+ * The approximate time this ledger was closed, in date time string format.
276
+ * Always uses the UTC time zone.
277
+ */
278
+ close_time_iso: string
268
279
  /** String Transaction result code. */
269
280
  engine_result: string
270
281
  /** Numeric transaction response code, if applicable. */
@@ -285,8 +296,14 @@ export interface TransactionStream extends BaseStream {
285
296
  * in detail.
286
297
  */
287
298
  meta?: TransactionMetadata
288
- /** The definition of the transaction in JSON format. */
289
- transaction: Transaction & ResponseOnlyTxInfo
299
+ /** JSON object defining the transaction. */
300
+ tx_json?: Version extends typeof RIPPLED_API_V2
301
+ ? Transaction & ResponseOnlyTxInfo
302
+ : never
303
+ /** JSON object defining the transaction in rippled API v1. */
304
+ transaction?: Version extends typeof RIPPLED_API_V1
305
+ ? Transaction & ResponseOnlyTxInfo
306
+ : never
290
307
  /**
291
308
  * If true, this transaction is included in a validated ledger and its
292
309
  * outcome is final. Responses from the transaction stream should always be
@@ -296,6 +313,20 @@ export interface TransactionStream extends BaseStream {
296
313
  warnings?: Array<{ id: number; message: string }>
297
314
  }
298
315
 
316
+ /**
317
+ * Expected response from an {@link AccountTxRequest}.
318
+ *
319
+ * @category Streams
320
+ */
321
+ export type TransactionStream = TransactionStreamBase
322
+
323
+ /**
324
+ * Expected response from an {@link AccountTxRequest} with `api_version` set to 1.
325
+ *
326
+ * @category Streams
327
+ */
328
+ export type TransactionV1Stream = TransactionStreamBase<typeof RIPPLED_API_V1>
329
+
299
330
  /**
300
331
  * The admin-only `peer_status` stream reports a large amount of information on
301
332
  * the activities of other rippled servers to which this server is connected, in
@@ -0,0 +1,44 @@
1
+ import {
2
+ BaseTransaction,
3
+ isString,
4
+ validateBaseTransaction,
5
+ validateCredentialType,
6
+ validateRequiredField,
7
+ } from './common'
8
+
9
+ /**
10
+ * Accepts a credential issued to the Account (i.e. the Account is the Subject of the Credential object).
11
+ * Credentials are represented in hex. Whilst they are allowed a maximum length of 64
12
+ * bytes, every byte requires 2 hex characters for representation.
13
+ * The credential is not considered valid until it has been transferred/accepted.
14
+ *
15
+ * @category Transaction Models
16
+ * */
17
+ export interface CredentialAccept extends BaseTransaction {
18
+ TransactionType: 'CredentialAccept'
19
+
20
+ /** The subject of the credential. */
21
+ Account: string
22
+
23
+ /** The issuer of the credential. */
24
+ Issuer: string
25
+
26
+ /** A hex-encoded value to identify the type of credential from the issuer. */
27
+ CredentialType: string
28
+ }
29
+
30
+ /**
31
+ * Verify the form and type of a CredentialAccept at runtime.
32
+ *
33
+ * @param tx - A CredentialAccept Transaction.
34
+ * @throws When the CredentialAccept is Malformed.
35
+ */
36
+ export function validateCredentialAccept(tx: Record<string, unknown>): void {
37
+ validateBaseTransaction(tx)
38
+
39
+ validateRequiredField(tx, 'Account', isString)
40
+
41
+ validateRequiredField(tx, 'Issuer', isString)
42
+
43
+ validateCredentialType(tx)
44
+ }
@@ -0,0 +1,81 @@
1
+ import { HEX_REGEX } from '@xrplf/isomorphic/utils'
2
+
3
+ import { ValidationError } from '../../errors'
4
+
5
+ import {
6
+ BaseTransaction,
7
+ isNumber,
8
+ isString,
9
+ validateBaseTransaction,
10
+ validateCredentialType,
11
+ validateOptionalField,
12
+ validateRequiredField,
13
+ } from './common'
14
+
15
+ const MAX_URI_LENGTH = 256
16
+
17
+ /**
18
+ * Creates a Credential object. It must be sent by the issuer.
19
+ *
20
+ * @category Transaction Models
21
+ * */
22
+ export interface CredentialCreate extends BaseTransaction {
23
+ TransactionType: 'CredentialCreate'
24
+
25
+ /** The issuer of the credential. */
26
+ Account: string
27
+
28
+ /** The subject of the credential. */
29
+ Subject: string
30
+
31
+ /** A hex-encoded value to identify the type of credential from the issuer. */
32
+ CredentialType: string
33
+
34
+ /** Credential expiration. */
35
+ Expiration?: number
36
+
37
+ /** Additional data about the credential (such as a link to the VC document). */
38
+ URI?: string
39
+ }
40
+
41
+ /**
42
+ * Verify the form and type of a CredentialCreate at runtime.
43
+ *
44
+ * @param tx - A CredentialCreate Transaction.
45
+ * @throws When the CredentialCreate is Malformed.
46
+ */
47
+ export function validateCredentialCreate(tx: Record<string, unknown>): void {
48
+ validateBaseTransaction(tx)
49
+
50
+ validateRequiredField(tx, 'Account', isString)
51
+
52
+ validateRequiredField(tx, 'Subject', isString)
53
+
54
+ validateCredentialType(tx)
55
+
56
+ validateOptionalField(tx, 'Expiration', isNumber)
57
+
58
+ validateURI(tx.URI)
59
+ }
60
+
61
+ function validateURI(URI: unknown): void {
62
+ if (URI === undefined) {
63
+ return
64
+ }
65
+
66
+ if (typeof URI !== 'string') {
67
+ throw new ValidationError('CredentialCreate: invalid field URI')
68
+ }
69
+
70
+ if (URI.length === 0) {
71
+ throw new ValidationError('CredentialCreate: URI cannot be an empty string')
72
+ } else if (URI.length > MAX_URI_LENGTH) {
73
+ throw new ValidationError(
74
+ `CredentialCreate: URI length must be <= ${MAX_URI_LENGTH}`,
75
+ )
76
+ }
77
+
78
+ if (!HEX_REGEX.test(URI)) {
79
+ throw new ValidationError('CredentialCreate: URI must be encoded in hex')
80
+ }
81
+ }
@@ -0,0 +1,55 @@
1
+ import { ValidationError } from '../../errors'
2
+
3
+ import {
4
+ BaseTransaction,
5
+ isString,
6
+ validateBaseTransaction,
7
+ validateCredentialType,
8
+ validateOptionalField,
9
+ validateRequiredField,
10
+ } from './common'
11
+
12
+ /**
13
+ * Deletes a Credential object.
14
+ *
15
+ * @category Transaction Models
16
+ * */
17
+ export interface CredentialDelete extends BaseTransaction {
18
+ TransactionType: 'CredentialDelete'
19
+
20
+ /** The transaction submitter. */
21
+ Account: string
22
+
23
+ /** A hex-encoded value to identify the type of credential from the issuer. */
24
+ CredentialType: string
25
+
26
+ /** The person that the credential is for. If omitted, Account is assumed to be the subject. */
27
+ Subject?: string
28
+
29
+ /** The issuer of the credential. If omitted, Account is assumed to be the issuer. */
30
+ Issuer?: string
31
+ }
32
+
33
+ /**
34
+ * Verify the form and type of a CredentialDelete at runtime.
35
+ *
36
+ * @param tx - A CredentialDelete Transaction.
37
+ * @throws When the CredentialDelete is Malformed.
38
+ */
39
+ export function validateCredentialDelete(tx: Record<string, unknown>): void {
40
+ validateBaseTransaction(tx)
41
+
42
+ if (!tx.Subject && !tx.Issuer) {
43
+ throw new ValidationError(
44
+ 'CredentialDelete: either `Issuer` or `Subject` must be provided',
45
+ )
46
+ }
47
+
48
+ validateRequiredField(tx, 'Account', isString)
49
+
50
+ validateCredentialType(tx)
51
+
52
+ validateOptionalField(tx, 'Subject', isString)
53
+
54
+ validateOptionalField(tx, 'Issuer', isString)
55
+ }